effective_datatables 4.7.21 → 4.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/effective_datatables/reset.js.coffee +23 -2
- data/app/helpers/effective_datatables_helper.rb +1 -0
- data/app/models/effective/datatable.rb +6 -1
- data/app/models/effective/effective_datatable/resource.rb +6 -0
- data/app/views/effective/datatables/_active_storage_column.html.haml +4 -0
- data/lib/effective_datatables/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5a9a4233ee452020c92387b3bb140eac9df58bd52548c55a2eb41881c731f67
|
4
|
+
data.tar.gz: f738131e50148095ea9c1cee3b0f68911d4b2a4f1815b7d5aa6445ec4d849a49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2279b8c6b0f72dc5427a2d0cc876ee83021806a3152d325edcccbaf8532dd65de27c1a8275320a306568790a60965d6235ee585e4bba41c1337148568df62d51
|
7
|
+
data.tar.gz: a7e514c7caf226a633fbd5d6098df1241b38336343fc9d6927f3bab07419d56300c06c4cecab752ed4a43819f9f6946c820cff5af7e0b25c317922a06625155e
|
@@ -1,11 +1,32 @@
|
|
1
1
|
$(document).on 'click', '.dataTables_wrapper a.buttons-reset-search', (event) ->
|
2
2
|
event.preventDefault() # prevent the click
|
3
3
|
|
4
|
+
# Reset the HTML
|
4
5
|
$table = $(event.currentTarget).closest('.dataTables_wrapper').find('table.dataTable').first()
|
5
6
|
$thead = $table.children('thead').first()
|
6
7
|
|
7
|
-
|
8
|
+
# Reset all inputs
|
8
9
|
$thead.find('select').val('').trigger('change.select2')
|
9
10
|
|
10
|
-
$
|
11
|
+
$inputs = $thead.find('input')
|
12
|
+
$inputs.val('').removeAttr('checked').removeAttr('selected')
|
13
|
+
|
14
|
+
# Reset delayedChange
|
15
|
+
$.each $inputs, (input) =>
|
16
|
+
$input = $(input)
|
17
|
+
if ($input.delayedChange.oldVal)
|
18
|
+
$input.delayedChange.oldVal = undefined
|
19
|
+
|
20
|
+
# Reset the datatable
|
21
|
+
datatable = $table.DataTable()
|
22
|
+
|
23
|
+
# Reset search
|
24
|
+
datatable.search('').columns().search('')
|
25
|
+
|
26
|
+
# Reset to default visibility
|
27
|
+
$.each $table.data('default-visibility'), (index, visible) =>
|
28
|
+
datatable.column(index).visible(visible, false)
|
29
|
+
|
30
|
+
# Don't pass up the click
|
31
|
+
false
|
11
32
|
|
@@ -44,6 +44,7 @@ module EffectiveDatatablesHelper
|
|
44
44
|
'authenticity-token' => form_authenticity_token,
|
45
45
|
'bulk-actions' => datatable_bulk_actions(datatable),
|
46
46
|
'columns' => datatable_columns(datatable),
|
47
|
+
'default-visibility' => datatable.default_visibility.to_json,
|
47
48
|
'display-length' => datatable.display_length,
|
48
49
|
'display-order' => datatable_display_order(datatable),
|
49
50
|
'display-records' => datatable.to_json[:recordsFiltered],
|
@@ -33,7 +33,7 @@ module Effective
|
|
33
33
|
include Effective::EffectiveDatatable::Resource
|
34
34
|
include Effective::EffectiveDatatable::State
|
35
35
|
|
36
|
-
def initialize(view = nil, attributes = nil)
|
36
|
+
def initialize(view = nil, attributes = nil)
|
37
37
|
(attributes = view; view = nil) if view.kind_of?(Hash)
|
38
38
|
|
39
39
|
@attributes = (attributes || {})
|
@@ -49,6 +49,7 @@ module Effective
|
|
49
49
|
|
50
50
|
raise 'expected a hash of arguments' unless @attributes.kind_of?(Hash)
|
51
51
|
raise 'collection is defined as a method. Please use the collection do ... end syntax.' unless collection.nil?
|
52
|
+
|
52
53
|
self.view = view if view
|
53
54
|
end
|
54
55
|
|
@@ -170,6 +171,10 @@ module Effective
|
|
170
171
|
@fallback_effective_resource ||= Effective::Resource.new('', namespace: controller_namespace)
|
171
172
|
end
|
172
173
|
|
174
|
+
def default_visibility
|
175
|
+
columns.values.inject({}) { |h, col| h[col[:index]] = col[:visible]; h }
|
176
|
+
end
|
177
|
+
|
173
178
|
private
|
174
179
|
|
175
180
|
def column_tool
|
@@ -91,6 +91,8 @@ module Effective
|
|
91
91
|
opts[:sql_column] = :effective_addresses
|
92
92
|
when :effective_roles
|
93
93
|
opts[:sql_column] = :effective_roles
|
94
|
+
when :active_storage
|
95
|
+
opts[:sql_column] = :active_storage
|
94
96
|
when :string # This is the fallback
|
95
97
|
# Anything that doesn't belong to the model or the sql table, we assume is a SELECT SUM|AVG|RANK() as fancy
|
96
98
|
opts[:sql_as_column] = true if (effective_resource.table && effective_resource.column(name).blank?)
|
@@ -137,6 +139,10 @@ module Effective
|
|
137
139
|
opts[:partial] ||= '/effective/datatables/resource_column'
|
138
140
|
end
|
139
141
|
|
142
|
+
if opts[:as] == :active_storage
|
143
|
+
opts[:partial] ||= '/effective/datatables/active_storage_column'
|
144
|
+
end
|
145
|
+
|
140
146
|
opts[:col_class] = [
|
141
147
|
"col-#{opts[:as]}",
|
142
148
|
"col-#{name.to_s.parameterize}",
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_datatables
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -153,6 +153,7 @@ files:
|
|
153
153
|
- app/models/effective/effective_datatable/params.rb
|
154
154
|
- app/models/effective/effective_datatable/resource.rb
|
155
155
|
- app/models/effective/effective_datatable/state.rb
|
156
|
+
- app/views/effective/datatables/_active_storage_column.html.haml
|
156
157
|
- app/views/effective/datatables/_bulk_actions_column.html.haml
|
157
158
|
- app/views/effective/datatables/_bulk_actions_dropdown.html.haml
|
158
159
|
- app/views/effective/datatables/_chart.html.haml
|