active_list 7.1.0 → 7.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/app/assets/javascripts/active_list.jquery.js.coffee +5 -0
- data/lib/active_list/definition/abstract_column.rb +2 -1
- data/lib/active_list/definition/action_column.rb +2 -2
- data/lib/active_list/definition/attribute_column.rb +1 -1
- data/lib/active_list/definition/empty_column.rb +4 -0
- data/lib/active_list/definition/status_column.rb +13 -0
- data/lib/active_list/definition/table.rb +4 -0
- data/lib/active_list/generator.rb +1 -1
- data/lib/active_list/generator/finder.rb +3 -3
- data/lib/active_list/helpers.rb +5 -4
- data/lib/active_list/renderers/simple_renderer.rb +41 -9
- data/lib/active_list/version.rb +1 -1
- data/test/dummy/Gemfile +2 -0
- data/test/dummy/config/application.rb +1 -0
- data/test/dummy/config/initializers/secret_token.rb +0 -1
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 884ba63410b0ba502c551bdbf9035360ad2ddefefc959de5d0b3809274e57b60
|
4
|
+
data.tar.gz: 38f2ddcea9c3beb17cc6c4527152f1dba440869e4830d73d8f2c46db0b7c5f7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfa9c5a61880233f0b49f883cfe340a6b63d197a2369fd6a26a079ff87f059fea98ed8ee9f4bc853a97dd6b20112de497923ab62995f642907eb3dfabfcaa877
|
7
|
+
data.tar.gz: e3bf5e8a58a7ecdc81924f71476a433c03fb52b313ff304ebc8755ab13a39b7d2ea60194c669368d1139fbe37321fadbb38c854932fc46fce04d025c1e55e9e1
|
@@ -158,6 +158,11 @@ ActiveList = {}
|
|
158
158
|
|
159
159
|
# Select row
|
160
160
|
$(document).on "click", "*[data-list-source] td>input[data-list-selector]", (event) ->
|
161
|
+
mainCheckbox = $("input[data-list-selector]").first()
|
162
|
+
someChecked = $("*[data-list-source] td>input[data-list-selector]:checked").length > 0
|
163
|
+
someUnchecked = $("*[data-list-source] td>input[data-list-selector]:not(:checked)").length > 0
|
164
|
+
mainCheckbox.prop("indeterminate", someChecked && someUnchecked);
|
165
|
+
mainCheckbox.prop("checked", someChecked || !someUnchecked);
|
161
166
|
AL.select $(this)
|
162
167
|
true
|
163
168
|
|
@@ -1,13 +1,14 @@
|
|
1
1
|
module ActiveList
|
2
2
|
module Definition
|
3
3
|
class AbstractColumn
|
4
|
-
attr_reader :table, :name, :id, :options
|
4
|
+
attr_reader :table, :name, :id, :options, :condition
|
5
5
|
|
6
6
|
def initialize(table, name, options = {})
|
7
7
|
@table = table
|
8
8
|
@name = name.to_sym
|
9
9
|
@options = options
|
10
10
|
@hidden = !!@options.delete(:hidden)
|
11
|
+
@condition = @options.delete(:condition)
|
11
12
|
@id = 'c' + @table.new_column_id # ActiveList.new_uid
|
12
13
|
end
|
13
14
|
|
@@ -94,7 +94,7 @@ module ActiveList
|
|
94
94
|
url[:redirect] ||= 'params[:redirect]'.c
|
95
95
|
url.delete_if { |_k, v| v.nil? }
|
96
96
|
cases << "#{record}.#{@name} == #{expected.inspect}\nlink_to(content_tag(:i) + h(#{url[:action].inspect}.t(scope: 'rest.actions'))"\
|
97
|
-
', {' + url.collect { |k, v| "#{k}: " + urlify(v, record) }.join(', ') + format + '}' \
|
97
|
+
', {' + url.collect { |k, v| "#{k}: " + urlify(k, v, record) }.join(', ') + format + '}' \
|
98
98
|
", {class: '#{@options[:icon_name] || @name}'" + link_options + '}'\
|
99
99
|
")\n"
|
100
100
|
end
|
@@ -108,7 +108,7 @@ module ActiveList
|
|
108
108
|
url[:id] = 'RECORD.id'.c if url[:id] == ID_PLACEHOLDER
|
109
109
|
url[:redirect] ||= 'params[:redirect]'.c
|
110
110
|
url.delete_if { |_k, v| v.nil? }
|
111
|
-
url = '{' + url.collect { |k, v| "#{k}: " + urlify(v, record) }.join(', ') + format + '}'
|
111
|
+
url = '{' + url.collect { |k, v| "#{k}: " + urlify(k, v, record) }.join(', ') + format + '}'
|
112
112
|
code = "{class: '#{@options[:icon_name] || @name}'" + link_options + '}'
|
113
113
|
code = "link_to(content_tag(:i) + h(' ' + :#{action}.t(scope: 'rest.actions')), " + url + ', ' + code + ')'
|
114
114
|
end
|
@@ -1,6 +1,19 @@
|
|
1
1
|
module ActiveList
|
2
2
|
module Definition
|
3
3
|
class StatusColumn < AttributeColumn
|
4
|
+
def initialize(table, name, options = {})
|
5
|
+
super
|
6
|
+
|
7
|
+
@tooltip_method = options.fetch(:tooltip_method, nil)
|
8
|
+
end
|
9
|
+
|
10
|
+
def tooltip_title_code(record, child)
|
11
|
+
c = if @tooltip_method.nil?
|
12
|
+
"#{record}.try(:human_status) || #{record}&.try(:human_state_name) || #{datum_value(record, child)}.to_s.capitalize"
|
13
|
+
else
|
14
|
+
"#{record}.#{@tooltip_method}"
|
15
|
+
end
|
16
|
+
end
|
4
17
|
end
|
5
18
|
end
|
6
19
|
end
|
@@ -103,6 +103,10 @@ module ActiveList
|
|
103
103
|
add :action, name, options
|
104
104
|
end
|
105
105
|
|
106
|
+
# Add a new method in Table which permit to define empty columns
|
107
|
+
def empty(name, options = {})
|
108
|
+
add :empty, name, options
|
109
|
+
end
|
106
110
|
# # Add a new method in Table which permit to define data columns
|
107
111
|
# def attribute(name, options = {})
|
108
112
|
# add :attribute, name, options
|
@@ -7,7 +7,7 @@ module ActiveList
|
|
7
7
|
@controller = options[:controller]
|
8
8
|
name = args.shift || @controller.controller_name.to_sym
|
9
9
|
model = (options[:model] || name).to_s.classify.constantize
|
10
|
-
@collection = !!(model.name == @controller.controller_name.to_s.classify)
|
10
|
+
@collection = options[:collection] || !!(model.name == @controller.controller_name.to_s.classify)
|
11
11
|
@controller_method_name = "list#{'_' + name.to_s if name != @controller.controller_name.to_sym}"
|
12
12
|
@view_method_name = "_#{@controller.controller_name}_list_#{name}_tag"
|
13
13
|
@records_variable_name = "@#{name}"
|
@@ -10,8 +10,8 @@ module ActiveList
|
|
10
10
|
@table.options[:order] = (columns.any? ? columns.first.name.to_sym : { id: :desc })
|
11
11
|
end
|
12
12
|
|
13
|
-
class_name = @table.model.name
|
14
|
-
class_name = "(controller_name != '#{class_name.tableize}' ? controller_name.to_s.classify.constantize : #{class_name})" if collection?
|
13
|
+
class_name = "options[\"constant_name\"]&.constantize || #{@table.model.name}"
|
14
|
+
class_name = "(controller_name != '#{class_name.tableize}' && !options[\"constant_name\"] ? controller_name.to_s.classify.constantize : #{class_name})" if collection?
|
15
15
|
|
16
16
|
# Find data
|
17
17
|
query_code = class_name.to_s
|
@@ -144,7 +144,7 @@ module ActiveList
|
|
144
144
|
else
|
145
145
|
code << "#{@table.model.table_name}.*"
|
146
146
|
end
|
147
|
-
("'
|
147
|
+
('"' + code + '"').c
|
148
148
|
end
|
149
149
|
|
150
150
|
def sanitize_condition(value)
|
data/lib/active_list/helpers.rb
CHANGED
@@ -20,11 +20,12 @@ module ActiveList
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
def urlify(value, record_name)
|
24
|
-
|
25
|
-
|
23
|
+
def urlify(key, value, record_name, namespace = nil)
|
24
|
+
return value.inspect unless value.is_a?(CodeString)
|
25
|
+
if key == :controller && namespace
|
26
|
+
'(' + "'/#{namespace}/' + " + value.gsub(/RECORD/, record_name) + ')'
|
26
27
|
else
|
27
|
-
value.
|
28
|
+
'(' + value.gsub(/RECORD/, record_name) + ')'
|
28
29
|
end
|
29
30
|
end
|
30
31
|
end
|
@@ -41,7 +41,7 @@ module ActiveList
|
|
41
41
|
header = header_code
|
42
42
|
extras = extras_codes
|
43
43
|
|
44
|
-
code = generator.select_data_code
|
44
|
+
code = "#{generator.select_data_code}(options)\n"
|
45
45
|
# Hack for Rails 5
|
46
46
|
code << "__params = params.permit!\n"
|
47
47
|
code << "#{var_name(:tbody)} = '<tbody data-total=\"' + #{var_name(:count)}.to_s + '\""
|
@@ -53,7 +53,12 @@ module ActiveList
|
|
53
53
|
code << "if #{var_name(:count)} > 0\n"
|
54
54
|
code << " #{generator.records_variable_name}.each do |#{record}|\n"
|
55
55
|
code << " #{var_name(:attrs)} = {id: 'r' + #{record}.id.to_s}\n"
|
56
|
-
code << "
|
56
|
+
code << " if #{var_name(:params)}[:data]\n"
|
57
|
+
code << " #{var_name(:params)}[:data] = [#{var_name(:params)}[:data]] unless #{var_name(:params)}[:data].is_a?(Array)\n"
|
58
|
+
code << " #{var_name(:params)}[:data].each do |attr|\n"
|
59
|
+
code << " #{var_name(:attrs)}['data-' + attr.gsub('_', '-')] = #{record}.send(attr)\n"
|
60
|
+
code << " end\n"
|
61
|
+
code << " end\n"
|
57
62
|
if table.options[:line_class]
|
58
63
|
code << " #{var_name(:attrs)}[:class] = (#{recordify!(table.options[:line_class], record)}).to_s\n"
|
59
64
|
code << " #{var_name(:attrs)}[:class] << ' focus' if __params['#{table.name}-id'].to_i == #{record}.id\n"
|
@@ -165,17 +170,20 @@ module ActiveList
|
|
165
170
|
children_mode = !!(nature == :children)
|
166
171
|
for column in table.columns
|
167
172
|
value_code = ''
|
173
|
+
title_value_code = ''
|
168
174
|
if column.is_a? ActiveList::Definition::EmptyColumn
|
169
175
|
value_code = 'nil'
|
170
176
|
elsif column.is_a? ActiveList::Definition::StatusColumn
|
171
|
-
|
177
|
+
title_value_code = nil
|
172
178
|
value_code = column.datum_code(record, children_mode)
|
179
|
+
title_code = column.tooltip_title_code(record, children_mode)
|
173
180
|
levels = %w[go caution stop]
|
174
181
|
lights = levels.collect do |light|
|
175
182
|
"content_tag(:span, '', :class => #{light.inspect})"
|
176
183
|
end.join(' + ')
|
177
184
|
# Expected value are :valid, :warning, :error
|
178
|
-
|
185
|
+
|
186
|
+
value_code = "content_tag(:span, #{lights}, :class => 'lights lights-' + (#{levels.inspect}.include?(#{value_code}.to_s) ? #{value_code}.to_s : 'undefined'), data: { toggle: :tooltip, placement: :top }, title: #{title_code})"
|
179
187
|
|
180
188
|
elsif column.is_a? ActiveList::Definition::DataColumn
|
181
189
|
if column.options[:children].is_a?(FalseClass) && children_mode
|
@@ -183,6 +191,7 @@ module ActiveList
|
|
183
191
|
else
|
184
192
|
value_code = column.datum_code(record, children_mode)
|
185
193
|
if column.datatype == :boolean
|
194
|
+
title_value_code = value_code
|
186
195
|
value_code = "content_tag(:div, '', :class => 'checkbox-'+(" + value_code.to_s + " ? 'true' : 'false'))"
|
187
196
|
elsif %i[date datetime timestamp measure].include? column.datatype
|
188
197
|
value_code = "(#{value_code}.nil? ? '' : #{value_code}.l)"
|
@@ -204,15 +213,21 @@ module ActiveList
|
|
204
213
|
column.options[:url] = {} unless column.options[:url].is_a?(Hash)
|
205
214
|
column.options[:url][:id] ||= (column.record_expr(record) + '.id').c
|
206
215
|
column.options[:url][:action] ||= :show
|
207
|
-
|
208
|
-
|
209
|
-
|
216
|
+
default_controller = column.class_name.is_a?(CodeString) ? column.class_name : column.class_name.tableize.to_sym
|
217
|
+
column.options[:url][:controller] ||= default_controller
|
218
|
+
namespace = column.options[:url].delete(:namespace)
|
219
|
+
url = column.options[:url].collect { |k, v| "#{k}: " + urlify(k, v, record, namespace) }.join(', ')
|
220
|
+
|
221
|
+
title_value_code = value_code
|
210
222
|
value_code = "(#{value_code}.blank? ? '' : link_to(#{value_code}.to_s, #{url}))"
|
211
223
|
elsif column.options[:mode] || column.label_method == :email
|
224
|
+
title_value_code = value_code
|
212
225
|
value_code = "(#{value_code}.blank? ? '' : mail_to(#{value_code}))"
|
213
226
|
elsif column.options[:mode] || column.label_method == :website
|
227
|
+
title_value_code = value_code
|
214
228
|
value_code = "(#{value_code}.blank? ? '' : link_to(" + value_code + ', ' + value_code + '))'
|
215
229
|
elsif column.label_method == :color
|
230
|
+
title_value_code = value_code
|
216
231
|
value_code = "content_tag(:div, #{column.datum_code(record)}, style: 'background: #'+" + column.datum_code(record) + ')'
|
217
232
|
elsif column.label_method.to_s.match(/(^|\_)currency$/) && column.datatype == :string
|
218
233
|
value_code = "(Nomen::Currency[#{value_code}] ? Nomen::Currency[#{value_code}].human_name : #{value_code})"
|
@@ -222,11 +237,13 @@ module ActiveList
|
|
222
237
|
value_code = "(Nomen::Country[#{value_code}] ? (image_tag('countries/' + #{value_code}.to_s + '.png') + ' ' + Nomen::Country[#{value_code}].human_name).html_safe : #{value_code})"
|
223
238
|
else # if column.datatype == :string
|
224
239
|
value_code = "h(#{value_code}.to_s)"
|
240
|
+
title_value_code = nil
|
225
241
|
end
|
226
242
|
|
227
243
|
value_code = "if #{record}\n#{value_code.dig}end" if column.is_a?(ActiveList::Definition::AssociationColumn)
|
228
244
|
end
|
229
245
|
elsif column.is_a?(ActiveList::Definition::CheckBoxColumn)
|
246
|
+
title_value_code = nil
|
230
247
|
if nature == :body
|
231
248
|
form_name = column.form_name || "'#{table.name}[' + #{record}.id.to_s + '][#{column.name}]'".c
|
232
249
|
value = 'nil'
|
@@ -241,15 +258,26 @@ module ActiveList
|
|
241
258
|
value_code << 'nil'
|
242
259
|
end
|
243
260
|
elsif column.is_a?(ActiveList::Definition::TextFieldColumn)
|
261
|
+
title_value_code = nil
|
244
262
|
form_name = column.form_name || "'#{table.name}[' + #{record}.id.to_s + '][#{column.name}]'".c
|
245
263
|
value_code = (nature == :body ? "text_field_tag(#{form_name.inspect}, #{recordify!(column.options[:value] || column.name, record)}#{column.options[:size] ? ', size: ' + column.options[:size].to_s : ''})" : 'nil') # , id: '#{table.name}_'+#{record}.id.to_s + '_#{column.name}'
|
246
264
|
elsif column.is_a?(ActiveList::Definition::ActionColumn)
|
265
|
+
title_value_code = nil
|
247
266
|
next unless column.use_single?
|
248
267
|
value_code = (nature == :body ? column.operation(record) : 'nil')
|
249
268
|
else
|
250
269
|
value_code = "' ∅ '.html_safe"
|
251
270
|
end
|
252
|
-
|
271
|
+
|
272
|
+
title_attr_code = if title_value_code.nil?
|
273
|
+
''
|
274
|
+
elsif title_value_code.blank?
|
275
|
+
":title => (#{value_code}),"
|
276
|
+
else
|
277
|
+
":title => (#{title_value_code}),"
|
278
|
+
end
|
279
|
+
|
280
|
+
code << "content_tag(:td, #{title_attr_code} :class => \"#{column_classes(column)}\","
|
253
281
|
code << " data: { 'list-column-header' => '#{column.short_id}'"
|
254
282
|
code << ", 'list-cell-value' => \"\#{#{column.datum_value(record, children_mode)}.to_f}\"" if column.computable?
|
255
283
|
code << " } ) do\n"
|
@@ -424,7 +452,11 @@ module ActiveList
|
|
424
452
|
classes = []
|
425
453
|
conds = []
|
426
454
|
conds << [:sor, "#{var_name(:params)}[:sort] == '#{column.sort_id}'".c] if column.sortable?
|
427
|
-
|
455
|
+
if column.is_a? ActiveList::Definition::DataColumn
|
456
|
+
conds << [:hidden, "#{var_name(:params)}[:hidden_columns].include?(:#{column.name})".c]
|
457
|
+
elsif column.condition
|
458
|
+
conds << [:hidden, "h(#{column.condition}) == 'false'".c]
|
459
|
+
end
|
428
460
|
classes << column.options[:class].to_s.strip unless column.options[:class].blank?
|
429
461
|
classes << column.short_id unless without_id
|
430
462
|
if column.is_a? ActiveList::Definition::ActionColumn
|
data/lib/active_list/version.rb
CHANGED
data/test/dummy/Gemfile
CHANGED
@@ -39,6 +39,7 @@ module Dummy
|
|
39
39
|
# Configure sensitive parameters which will be filtered from the log file.
|
40
40
|
config.filter_parameters += [:password]
|
41
41
|
|
42
|
+
config.active_record.sqlite3.represent_boolean_as_integer = true
|
42
43
|
# Use SQL instead of Active Record's schema dumper when creating the database.
|
43
44
|
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
44
45
|
# like if you have constraints or database-specific column types
|
@@ -5,4 +5,3 @@
|
|
5
5
|
# Make sure the secret is at least 30 characters and all random,
|
6
6
|
# no regular words or you'll be exposed to dictionary attacks.
|
7
7
|
Dummy::Application.config.secret_key_base = '7a06e73398090c095bed02f2dff3808b043e50cb928f7b7bfd02faadd988a0d9cf31dfc74d1bf661ac94c8d0d73c8ceb4d98210d09f251f0c6d70f09923db784'
|
8
|
-
Dummy::Application.config.secret_token = '7a06e73398090c095bed02f2dff3808b043e50cb928f7b7bfd02faadd988a0d9cf31dfc74d1bf661ac94c8d0d73c8ceb4d98210d09f251f0c6d70f09923db784'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_list
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.
|
4
|
+
version: 7.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brice Texier
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -208,11 +208,11 @@ files:
|
|
208
208
|
- test/people_controller_test.rb
|
209
209
|
- test/table_test.rb
|
210
210
|
- test/test_helper.rb
|
211
|
-
homepage: http://
|
211
|
+
homepage: http://gitlab.com/ekylibre/active_list
|
212
212
|
licenses:
|
213
213
|
- MIT
|
214
214
|
metadata: {}
|
215
|
-
post_install_message:
|
215
|
+
post_install_message:
|
216
216
|
rdoc_options: []
|
217
217
|
require_paths:
|
218
218
|
- lib
|
@@ -227,9 +227,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
227
227
|
- !ruby/object:Gem::Version
|
228
228
|
version: '0'
|
229
229
|
requirements: []
|
230
|
-
|
231
|
-
|
232
|
-
signing_key:
|
230
|
+
rubygems_version: 3.0.3
|
231
|
+
signing_key:
|
233
232
|
specification_version: 4
|
234
233
|
summary: Simple interactive tables for Rails app
|
235
234
|
test_files:
|