active_list 6.8.3 → 6.9.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43cd0de92791ecf694d3312c293f8746eb1d5ac9
|
4
|
+
data.tar.gz: 3d67108f2fd9b1bf609a0cb163c4324ecd214cf7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 977c013131fd6e3131df738f996cd605d3112e2118635c2dad4d4675868528f65292369f0e8302e449acb56d12a50f19dc320a73ed897b9d5bc655d552c2eca7
|
7
|
+
data.tar.gz: 3b45a3a9d72e5090af3659075a475c068bc117221aa22e3e186818759662d0a6343b7f9319449c2adba77130605f4d0d6da78482f445aaa732153634e2b1f306
|
@@ -101,12 +101,12 @@ ActiveList = {}
|
|
101
101
|
total = values.reduce (t, s) -> t + s
|
102
102
|
total /= values.length if AL.computation_for(list, column) == 'average'
|
103
103
|
list.attr("data-list-result-#{column}", total)
|
104
|
-
|
105
|
-
|
106
|
-
if
|
107
|
-
magnitude = Math.pow(10,
|
104
|
+
unit_precision = parseInt(AL.column_for(list, column).data('list-column-unit-precision'))
|
105
|
+
unit_symbol = AL.column_for(list, column).data('list-column-unit-symbol')
|
106
|
+
if unit_precision and unit_symbol
|
107
|
+
magnitude = Math.pow(10, unit_precision)
|
108
108
|
rounded = Math.round(total * magnitude) / magnitude
|
109
|
-
displayable_total = "#{rounded.toFixed(
|
109
|
+
displayable_total = "#{rounded.toFixed(unit_precision)} #{unit_symbol}"
|
110
110
|
list.find("#computation-results td[data-list-result-for=\"#{column}\"] #list-computation-result").html(displayable_total)
|
111
111
|
for column in list.find("th[data-list-column-computation]")
|
112
112
|
col_number = $(column).data('list-column-cells')
|
@@ -1,11 +1,16 @@
|
|
1
1
|
module ActiveList
|
2
2
|
module Definition
|
3
3
|
class AttributeColumn < DataColumn
|
4
|
-
attr_reader :column, :label_method, :sort_column, :computation_method
|
4
|
+
attr_reader :column, :value_method, :label_method, :sort_column, :computation_method
|
5
5
|
|
6
6
|
def initialize(table, name, options = {})
|
7
7
|
super(table, name, options)
|
8
8
|
@label_method = (options[:label_method] || @name).to_sym
|
9
|
+
if options[:value_method].present?
|
10
|
+
@value_method = options[:value_method].to_sym
|
11
|
+
else
|
12
|
+
@value_method = @label_method.to_s.gsub('human_', '').to_sym
|
13
|
+
end
|
9
14
|
unless @sort_column = options[:sort]
|
10
15
|
@sort_column = if @table.model.columns_hash[@label_method.to_s]
|
11
16
|
@label_method
|
@@ -25,13 +30,27 @@ module ActiveList
|
|
25
30
|
'nil'
|
26
31
|
else
|
27
32
|
"#{record}.#{table.options[:children]}.#{@options[:children] || @label_method}"
|
28
|
-
|
33
|
+
end
|
29
34
|
else
|
30
35
|
"#{record}.#{@label_method}"
|
31
36
|
end
|
32
37
|
code.c
|
33
38
|
end
|
34
39
|
|
40
|
+
def datum_value(record = 'record of the death', child = false)
|
41
|
+
code = ''
|
42
|
+
code = if child
|
43
|
+
if @options[:childer].is_a?(FalseClass)
|
44
|
+
'nil'
|
45
|
+
else
|
46
|
+
"#{record}.#{table.options[:children]}.#{@options[:children] || @value_method}"
|
47
|
+
end
|
48
|
+
else
|
49
|
+
"#{record}.#{@value_method}"
|
50
|
+
end
|
51
|
+
code.c
|
52
|
+
end
|
53
|
+
|
35
54
|
# Returns the class name of the used model
|
36
55
|
def class_name
|
37
56
|
table.model.name
|
@@ -237,7 +237,7 @@ module ActiveList
|
|
237
237
|
end
|
238
238
|
code << "content_tag(:td, :class => \"#{column_classes(column)}\","
|
239
239
|
code << " data: { 'list-column-header' => '#{column.short_id}'"
|
240
|
-
code << ", 'list-cell-value' => \"\#{#{column.
|
240
|
+
code << ", 'list-cell-value' => \"\#{#{column.datum_value(record, children_mode)}.to_f}\"" if column.computable?
|
241
241
|
code << " } ) do\n"
|
242
242
|
code << value_code.dig
|
243
243
|
code << "end +\n"
|
@@ -304,9 +304,18 @@ module ActiveList
|
|
304
304
|
code << " data-list-column-cells=\"#{column.short_id}\""
|
305
305
|
code << " data-list-column-sort=\"'+(#{var_name(:params)}[:sort] != '#{column.sort_id}' ? 'asc' : #{var_name(:params)}[:dir] == 'asc' ? 'desc' : 'asc')+'\"" if column.sortable?
|
306
306
|
code << " data-list-column-computation=\"#{column.computation_method}\"" if column.computable?
|
307
|
-
if table.selectable? && column.is_a?(ActiveList::Definition::DataColumn) && column.options[:currency]
|
308
|
-
|
309
|
-
|
307
|
+
if table.selectable? && column.is_a?(ActiveList::Definition::DataColumn) && (column.options[:currency] || column.computable?)
|
308
|
+
unit = "''"
|
309
|
+
precision = "''"
|
310
|
+
if column.options[:currency]
|
311
|
+
unit = "Nomen::Currency.find(#{column.currency_for(generator.records_variable_name + '.first').inspect} || 'EUR').symbol.to_s"
|
312
|
+
precision = "Nomen::Currency.find(#{column.currency_for(generator.records_variable_name + '.first').inspect} || 'EUR').precision.to_s"
|
313
|
+
elsif column.computable?
|
314
|
+
unit = "#{generator.records_variable_name}.first.#{column.value_method}.symbol"
|
315
|
+
precision = "'2'"
|
316
|
+
end
|
317
|
+
code << " data-list-column-unit-symbol=\"' + (#{generator.records_variable_name}.any? ? #{unit} : '') + '\""
|
318
|
+
code << " data-list-column-unit-precision=\"' + (#{generator.records_variable_name}.any? ? #{precision} : '') + '\""
|
310
319
|
end
|
311
320
|
code << " class=\"#{column_classes(column, true, true)}\""
|
312
321
|
code << '>'
|
data/lib/active_list/version.rb
CHANGED
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: 6.
|
4
|
+
version: 6.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brice Texier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|