effective_datatables 3.5.4 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/app/assets/stylesheets/dataTables/buttons/{buttons.bootstrap.css → buttons.bootstrap.scss} +0 -0
- data/app/assets/stylesheets/dataTables/{dataTables.bootstrap.css → dataTables.bootstrap.scss} +0 -0
- data/app/assets/stylesheets/dataTables/responsive/{responsive.bootstrap.css → responsive.bootstrap.scss} +0 -0
- data/app/models/effective/effective_datatable/format.rb +70 -21
- data/app/views/effective/datatables/_resource_column.html.haml +11 -8
- data/lib/effective_datatables/version.rb +1 -1
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 831a378f29e67058bc5d8d313fd61f33f91589fc8a4968a1163963c63e1fa2ab
|
4
|
+
data.tar.gz: '0106983a5a9a22c509c3bb2f5302bcf1e9a0b15a6d9a00c296a62d1379f0f040'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 239f60681837ec733870367b539697a50249ba25380d727a147b084f170251457be6ab79665387a8edaf0642d5d81a214c9e84f83c21fff48c9e3bed6f288c59
|
7
|
+
data.tar.gz: 8daf8acdbcadc0c4de990bd1ddf0f3d1e49edb692dd1108ca415116717d459ce567f6d82016f25bd63e5cfaff1138ecebb60f516be81ad11d64d1954474a9282
|
data/app/assets/stylesheets/dataTables/buttons/{buttons.bootstrap.css → buttons.bootstrap.scss}
RENAMED
File without changes
|
data/app/assets/stylesheets/dataTables/{dataTables.bootstrap.css → dataTables.bootstrap.scss}
RENAMED
File without changes
|
File without changes
|
@@ -16,7 +16,7 @@ module Effective
|
|
16
16
|
next unless state[:visible][name]
|
17
17
|
|
18
18
|
if opts[:partial]
|
19
|
-
locals = { datatable: self, column:
|
19
|
+
locals = { datatable: self, column: opts }.merge(resource_col_locals(opts))
|
20
20
|
|
21
21
|
rendered[name] = (view.render(
|
22
22
|
partial: opts[:partial],
|
@@ -29,11 +29,24 @@ module Effective
|
|
29
29
|
elsif opts[:as] == :actions # This is actions_col and actions_col do .. end, but not actions_col partial: 'something'
|
30
30
|
resources = collection.map { |row| row[opts[:index]] }
|
31
31
|
locals = { datatable: self, column: opts, spacer_template: SPACER_TEMPLATE }
|
32
|
-
atts = { actions: actions_col_actions(opts), effective_resource: resource, locals: locals, partial: opts[:actions_partial] }.merge(opts[:actions])
|
33
32
|
|
34
|
-
|
35
|
-
|
33
|
+
atts = {
|
34
|
+
actions: actions_col_actions(opts),
|
35
|
+
btn_class: opts[:btn_class],
|
36
|
+
effective_resource: effective_resource,
|
37
|
+
locals: locals,
|
38
|
+
partial: opts[:actions_partial],
|
39
|
+
}.compact.merge(opts[:actions])
|
36
40
|
|
41
|
+
rendered[name] = if effective_resource.blank?
|
42
|
+
resources.map do |resource|
|
43
|
+
polymorphic_resource = Effective::Resource.new(resource, namespace: controller_namespace)
|
44
|
+
(view.render_resource_actions(resource, atts.merge(effective_resource: polymorphic_resource), &opts[:format]) || '')
|
45
|
+
end
|
46
|
+
else
|
47
|
+
(view.render_resource_actions(resources, atts, &opts[:format]) || '').split(SPACER)
|
48
|
+
end
|
49
|
+
end
|
37
50
|
end
|
38
51
|
|
39
52
|
collection.each_with_index do |row, row_index|
|
@@ -69,8 +82,7 @@ module Effective
|
|
69
82
|
|
70
83
|
case column[:as]
|
71
84
|
when :actions
|
72
|
-
|
73
|
-
(view.render_resource_actions(value, atts) || '')
|
85
|
+
raise("please use actions_col instead of col(#{name}, as: :actions)")
|
74
86
|
when :boolean
|
75
87
|
case value
|
76
88
|
when true ; 'Yes'
|
@@ -96,10 +108,10 @@ module Effective
|
|
96
108
|
view.mail_to(value)
|
97
109
|
when :integer
|
98
110
|
value
|
99
|
-
when :
|
111
|
+
when :percent
|
100
112
|
case value
|
101
|
-
when Integer ;
|
102
|
-
when Numeric ; view.number_to_percentage(value
|
113
|
+
when Integer ; view.number_to_percentage(value / 1000.0, precision: 3).gsub('.000%', '%')
|
114
|
+
when Numeric ; view.number_to_percentage(value, precision: 3).gsub('.000%', '%')
|
103
115
|
end
|
104
116
|
when :price
|
105
117
|
case value
|
@@ -115,29 +127,66 @@ module Effective
|
|
115
127
|
|
116
128
|
# Takes all default resource actions
|
117
129
|
# Applies data-remote to anything that's data-method post or delete
|
130
|
+
# Merges in any extra attributes when passed as a Hash
|
118
131
|
def actions_col_actions(column)
|
119
|
-
|
132
|
+
resource_actions = (effective_resource&.resource_actions || fallback_effective_resource.fallback_resource_actions)
|
133
|
+
|
134
|
+
actions = if column[:inline]
|
135
|
+
resource_actions.transform_values { |opts| opts['data-remote'] = true; opts }
|
136
|
+
else
|
137
|
+
resource_actions.transform_values { |opts| opts['data-remote'] = true if opts['data-method']; opts }
|
138
|
+
end
|
139
|
+
|
140
|
+
# Merge local options. Special behaviour for remote: false
|
141
|
+
if column[:actions].kind_of?(Hash)
|
142
|
+
column[:actions].each do |action, opts|
|
143
|
+
next unless opts.kind_of?(Hash)
|
144
|
+
|
145
|
+
existing = actions.find { |_, v| v[:action] == action }&.first
|
146
|
+
next unless existing.present?
|
147
|
+
|
148
|
+
actions[existing]['data-remote'] = opts[:remote] if opts.key?(:remote)
|
149
|
+
actions[existing]['data-remote'] = opts['remote'] if opts.key?('remote')
|
150
|
+
|
151
|
+
actions[existing].merge!(opts.except(:remote, 'remote'))
|
152
|
+
end
|
153
|
+
|
154
|
+
actions = actions.sort do |(_, a), (_, b)|
|
155
|
+
(column[:actions].keys.index(a[:action]) || 99) <=> (column[:actions].keys.index(b[:action]) || 99)
|
156
|
+
end.to_h
|
157
|
+
|
158
|
+
end
|
159
|
+
|
160
|
+
actions
|
120
161
|
end
|
121
162
|
|
122
163
|
def resource_col_locals(opts)
|
123
|
-
return {} unless (
|
164
|
+
return {} unless (associated_resource = opts[:resource]).present?
|
165
|
+
|
166
|
+
associated = associated_resource.macros.include?(opts[:as])
|
167
|
+
polymorphic = (opts[:as] == :belongs_to_polymorphic)
|
124
168
|
|
125
|
-
|
169
|
+
resource_name = opts[:name] if associated
|
170
|
+
resource_to_s = opts[:name] unless associated || array_collection?
|
171
|
+
|
172
|
+
locals = {
|
173
|
+
resource_name: resource_name,
|
174
|
+
resource_to_s: resource_to_s,
|
175
|
+
effective_resource: associated_resource,
|
176
|
+
show_action: false,
|
177
|
+
edit_action: false
|
178
|
+
}
|
126
179
|
|
127
180
|
case opts[:action]
|
128
181
|
when :edit
|
129
|
-
locals[:edit_action] = (
|
182
|
+
locals[:edit_action] = (polymorphic || associated_resource.routes[:edit].present?)
|
130
183
|
when :show
|
131
|
-
locals[:show_action] = (
|
184
|
+
locals[:show_action] = (polymorphic || associated_resource.routes[:show].present?)
|
132
185
|
when false
|
133
|
-
# Nothing
|
186
|
+
# Nothing. Already false.
|
134
187
|
else
|
135
|
-
|
136
|
-
|
137
|
-
locals[:edit_action] = true
|
138
|
-
elsif resource.routes[:show] && EffectiveDatatables.authorized?(view.controller, :show, resource.klass)
|
139
|
-
locals[:show_action] = true
|
140
|
-
end
|
188
|
+
locals[:edit_action] = (polymorphic || associated_resource.routes[:edit].present?)
|
189
|
+
locals[:show_action] = (polymorphic || associated_resource.routes[:show].present?)
|
141
190
|
end
|
142
191
|
|
143
192
|
locals
|
@@ -1,8 +1,11 @@
|
|
1
|
-
- Array(
|
2
|
-
.
|
3
|
-
|
4
|
-
|
5
|
-
-
|
6
|
-
|
7
|
-
|
8
|
-
= resource.
|
1
|
+
- Array(local_assigns[:resource_name] ? resource.public_send(resource_name) : resource).each do |resource|
|
2
|
+
- resource_to_s = ((local_assigns[:resource_to_s] && resource) ? resource.public_send(resource_to_s) : resource.to_s)
|
3
|
+
|
4
|
+
- if resource_to_s.present?
|
5
|
+
.col-resource_item
|
6
|
+
- if edit_action && EffectiveDatatables.authorized?(controller, :edit, resource) && (path = effective_resource.action_path(:edit, resource)).present?
|
7
|
+
= link_to resource_to_s, path, title: resource_to_s
|
8
|
+
- elsif show_action && EffectiveDatatables.authorized?(controller, :show, resource) && (path = effective_resource.action_path(:show, resource)).present?
|
9
|
+
= link_to resource_to_s, path, title: resource_to_s
|
10
|
+
- else
|
11
|
+
= resource_to_s.to_s.html_safe
|
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: 3.
|
4
|
+
version: 3.6.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: 2019-
|
11
|
+
date: 2019-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -113,9 +113,9 @@ files:
|
|
113
113
|
- app/assets/javascripts/effective_datatables/responsive.js.coffee
|
114
114
|
- app/assets/javascripts/vendor/jquery.delayedChange.js
|
115
115
|
- app/assets/javascripts/vendor/jquery.fileDownload.js
|
116
|
-
- app/assets/stylesheets/dataTables/buttons/buttons.bootstrap.
|
117
|
-
- app/assets/stylesheets/dataTables/dataTables.bootstrap.
|
118
|
-
- app/assets/stylesheets/dataTables/responsive/responsive.bootstrap.
|
116
|
+
- app/assets/stylesheets/dataTables/buttons/buttons.bootstrap.scss
|
117
|
+
- app/assets/stylesheets/dataTables/dataTables.bootstrap.scss
|
118
|
+
- app/assets/stylesheets/dataTables/responsive/responsive.bootstrap.scss
|
119
119
|
- app/assets/stylesheets/effective_datatables.scss
|
120
120
|
- app/assets/stylesheets/effective_datatables/_filters.scss
|
121
121
|
- app/assets/stylesheets/effective_datatables/_overrides.scss
|
@@ -179,8 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '0'
|
181
181
|
requirements: []
|
182
|
-
|
183
|
-
rubygems_version: 2.4.5.1
|
182
|
+
rubygems_version: 3.0.3
|
184
183
|
signing_key:
|
185
184
|
specification_version: 4
|
186
185
|
summary: Uniquely powerful server-side searching, sorting and filtering of any ActiveRecord
|