active_scaffold_batch 3.5.2 → 3.6.1

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
  SHA256:
3
- metadata.gz: 57996a4d8d4924a4d1dd7bea60e270cc86906312e3b98a806425e4b0742f248e
4
- data.tar.gz: acb26347253ee5fa7f8babd740de40897ce9d8673f6c004aa36c8536459f85ef
3
+ metadata.gz: e95a8d9d4e5992e891a21ce962d70afafe38fec0ec4657c7a83d2fe7cbb92029
4
+ data.tar.gz: be53b9d4c5c36a261ecec93d28408bed9f13d9772d1029121ad9d43ea9431073
5
5
  SHA512:
6
- metadata.gz: b70ebd0b00056a6ad2a6432d179efa852deb037dd271c492bee28fc982743779d0a2df0d5e3cf5bded88aa7e6d5a5412a227a4829e5909052e99d90a3105db5a
7
- data.tar.gz: ae11b116e3bd9195797bb0e00d57911c51433b329c7b7af3d58e902fc05955c2bda96d288fef118f722204ca13a9d4e041bf7b2dd759f13b6b86ae87317a6fea
6
+ metadata.gz: da80d681008c619906e14e6442e156fd9ddc3109ad0c58f08a9d92dcb2521be1c6e51dd449a777ce837c6043b6af667b7f206d7cf4954b7d6f7884caf9098971
7
+ data.tar.gz: ba40cf458703959ec5d4a8a12a192372754be3bb772ae017efe252ddceb075c11b710344ec0849d0f2934f385a3173378365e6d474c913a4b2994e4caeff4ce0
@@ -10,4 +10,10 @@ jQuery(document).ready(function() {
10
10
  record.prev('.form_record-errors').remove();
11
11
  record.remove();
12
12
  });
13
+ jQuery(document).on('change', 'select.as_update_date_operator, select.as_batch_update_operator', function(event) {
14
+ ActiveScaffold[jQuery(this).val() === 'REPLACE' ? 'show' : 'hide'](jQuery(this).next());
15
+ });
16
+ jQuery(document).on('change', 'select.as_update_date_operator', function(event) {
17
+ ActiveScaffold[['REPLACE', 'NO_UPDATE', 'NULL'].indexOf(jQuery(this).val()) !== -1 ? 'hide' : 'show'](jQuery(this).next().next());
18
+ });
13
19
  });
@@ -217,7 +217,8 @@ module ActiveScaffold::Actions
217
217
  alias_method :batch_update_value_for_float, :batch_update_value_for_numeric
218
218
 
219
219
  def batch_update_all_value_for_numeric(column, calculation_info)
220
- if ActiveScaffold::Actions::BatchUpdate::GenericOperators.include?(calculation_info[:operator]) || ActiveScaffold::Actions::BatchUpdate::NumericOperators.include?(calculation_info[:operator])
220
+ operator = calculation_info[:operator]
221
+ if operator == 'NULL' || ActiveScaffold::Actions::BatchUpdate::GenericOperators.include?(operator) || ActiveScaffold::Actions::BatchUpdate::NumericOperators.include?(operator)
221
222
  operand = active_scaffold_config.model.quote_value(self.class.condition_value_for_numeric(column, calculation_info[:value]))
222
223
  if calculation_info[:opt] == 'PERCENT'
223
224
  operand = "#{active_scaffold_config.model.connection.quote_column_name(column.name)} / 100.0 * #{operand}"
@@ -242,18 +243,18 @@ module ActiveScaffold::Actions
242
243
 
243
244
  def batch_update_value_for_date_picker(column, record, calculation_info)
244
245
  current_value = record.send(column.name)
245
- {"number"=>"", "unit"=>"DAYS", "value"=>"November 16, 2010", "operator"=>"REPLACE"}
246
- if ActiveScaffold::Actions::BatchUpdate::GenericOperators.include?(calculation_info[:operator]) || ActiveScaffold::Actions::BatchUpdate::DateOperators.include?(calculation_info[:operator])
246
+ operator = calculation_info[:operator]
247
+ if operator == 'NULL' || ActiveScaffold::Actions::BatchUpdate::GenericOperators.include?(operator) || ActiveScaffold::Actions::BatchUpdate::DateOperators.include?(operator)
247
248
  operand = self.class.condition_value_for_datetime(column, calculation_info[:value], column.column.type == :date ? :to_date : :to_time)
248
249
  case calculation_info[:operator]
249
250
  when 'REPLACE' then operand
250
251
  when 'NULL' then nil
251
252
  when 'PLUS' then
252
253
  trend_number = [calculation_info['number'].to_i, 1].max
253
- current_value.in((trend_number).send(calculation_info['unit'].downcase.singularize.to_sym))
254
+ current_value&.in((trend_number).send(calculation_info['unit'].downcase.singularize.to_sym))
254
255
  when 'MINUS' then
255
256
  trend_number = [calculation_info['number'].to_i, 1].max
256
- current_value.ago((trend_number).send(calculation_info['unit'].downcase.singularize.to_sym))
257
+ current_value&.ago((trend_number).send(calculation_info['unit'].downcase.singularize.to_sym))
257
258
  else
258
259
  current_value
259
260
  end
@@ -261,7 +262,6 @@ module ActiveScaffold::Actions
261
262
  current_value
262
263
  end
263
264
  end
264
- alias_method :batch_update_value_for_calendar_date_select, :batch_update_value_for_date_picker
265
265
 
266
266
  def override_batch_update_value(form_ui)
267
267
  method = "batch_update_value_for_#{form_ui}"
@@ -3,26 +3,25 @@ module ActiveScaffold
3
3
  module DatepickerUpdateColumnHelpers
4
4
  def active_scaffold_update_date_picker(column, options)
5
5
  current_params = {:value => nil, :number => nil, :unit => nil, :operator => 'NO_UPDATE'}
6
- current_params.merge!(batch_update_values[column.name][:value].symbolize_keys) if batch_update_values[column.name] && batch_update_values[column.name][:value]
6
+ current_params.merge!(batch_update_values[column.name][:value].symbolize_keys) if batch_update_values.dig(column.name, :value)
7
7
  operator_options = active_scaffold_update_generic_operators(column)
8
8
  operator_options.concat(ActiveScaffold::Actions::BatchUpdate::DateOperators.collect {|comp| [as_(comp.downcase.to_sym), comp]}) if active_scaffold_config.batch_update.process_mode == :update
9
9
  options = options.merge(:show => ['PLUS', 'MINUS'].exclude?(current_params[:operator]))
10
10
  tags = []
11
- tags << select_tag("[record][#{column.name}][operator]",
11
+ tags << select_tag("#{options[:name]}[operator]",
12
12
  options_for_select(operator_options, current_params[:operator]),
13
13
  :id => "#{options[:id]}_operator",
14
14
  :class => "text-input as_update_date_operator")
15
- tags << active_scaffold_search_date_bridge_calendar_control(column, options, current_params[:value], 'value')
15
+ tags << active_scaffold_search_date_picker_field(column, options.merge(show: current_params[:operator] == 'REPLACE'), current_params[:value], 'value')
16
16
  tags << active_scaffold_update_date_bridge_trend_tag(column, current_params, options)
17
17
  tags.join("&nbsp;").html_safe
18
18
  end
19
19
 
20
20
  def active_scaffold_update_date_bridge_trend_tag(column, current_params, options)
21
- active_scaffold_date_bridge_trend_tag(column, options,
22
- {:name_prefix => '[record]',
23
- :number_value => current_params[:number],
24
- :unit_value => current_params[:unit],
25
- :show => ['PLUS','MINUS'].include?(current_params[:operator])})
21
+ active_scaffold_search_datetime_trend_tag(column, options,
22
+ {'number' => current_params[:number],
23
+ 'unit' => current_params[:unit],
24
+ show: ['PLUS','MINUS'].include?(current_params[:operator])})
26
25
  end
27
26
  end
28
27
  end
@@ -17,7 +17,9 @@ module ActiveScaffold
17
17
  elsif column.column and column.form_ui.nil? and (method = override_update(column.column.type))
18
18
  send(method, column, options)
19
19
  else
20
- active_scaffold_update_generic_operators_select(column, options)<< ' ' << active_scaffold_render_input(column, options.merge(:name => "record[#{column.name}][value]"))
20
+ show_field = batch_update_values.dig(column.name, :value, :operator) == 'REPLACE'
21
+ active_scaffold_update_generic_operators_select(column, options) << ' ' <<
22
+ active_scaffold_render_input(column, options.merge(name: "record[#{column.name}][value]", style: ('display: none;' unless show_field)))
21
23
  end
22
24
  end
23
25
 
@@ -31,8 +33,8 @@ module ActiveScaffold
31
33
 
32
34
  def active_scaffold_update_generic_operators_select(column, options)
33
35
  current = {:operator => 'NO_UPDATE'}
34
- current.merge!(batch_update_values[column.name][:value].symbolize_keys) if batch_update_values[column.name] && batch_update_values[column.name][:value]
35
- select_tag("[record][#{column.name}][operator]",
36
+ current.merge!(batch_update_values[column.name][:value].symbolize_keys) if batch_update_values.dig(column.name, :value)
37
+ select_tag("record[#{column.name}][operator]",
36
38
  options_for_select(active_scaffold_update_generic_operators(column), current[:operator]),
37
39
  :id => "#{options[:id]}_operator",
38
40
  :class => "as_batch_update_operator text_input")
@@ -43,12 +45,12 @@ module ActiveScaffold
43
45
  current.merge!(batch_update_values[column.name][:value].symbolize_keys) if batch_update_values[column.name] && batch_update_values[column.name][:value]
44
46
  operator_options = active_scaffold_update_generic_operators(column) + ActiveScaffold::Actions::BatchUpdate::NumericOperators.collect {|comp| [as_(comp.downcase.to_sym), comp]}
45
47
  select_options = ActiveScaffold::Actions::BatchUpdate::NumericOptions.collect {|comp| [as_(comp.downcase.to_sym), comp]}
46
- html = select_tag("[record][#{column.name}][operator]",
48
+ html = select_tag("record[#{column.name}][operator]",
47
49
  options_for_select(operator_options, current[:operator]),
48
50
  :id => "#{options[:id]}_operator",
49
51
  :class => "as_update_numeric_option")
50
- html << ' ' << text_field_tag("[record][#{column.name}][value]", current[:value], active_scaffold_input_text_options)
51
- html << ' ' << select_tag("[record][#{column.name}][opt]",
52
+ html << ' ' << text_field_tag("record[#{column.name}][value]", current[:value], active_scaffold_input_text_options)
53
+ html << ' ' << select_tag("record[#{column.name}][opt]",
52
54
  options_for_select(select_options, current[:opt]),
53
55
  :id => "#{options[:id]}_opt",
54
56
  :class => "as_update_numeric_option")
@@ -19,11 +19,7 @@ module ActiveScaffoldBatch
19
19
  ActiveSupport.on_load(:action_view) do
20
20
  begin
21
21
  include ActiveScaffold::Helpers::UpdateColumnHelpers
22
- if ActiveScaffold.js_framework == :jquery
23
- include ActiveScaffold::Helpers::DatepickerUpdateColumnHelpers
24
- elsif ActiveScaffold.js_framework == :prototype
25
- include ActiveScaffold::Helpers::CalendarDateSelectUpdateColumnHelpers if defined? CalendarDateSelect
26
- end
22
+ include ActiveScaffold::Helpers::DatepickerUpdateColumnHelpers
27
23
  include ActiveScaffold::Helpers::BatchCreateColumnHelpers
28
24
  rescue
29
25
  raise $! unless Rails.env == 'production'
@@ -1,8 +1,8 @@
1
1
  module ActiveScaffoldBatch
2
2
  module Version
3
3
  MAJOR = 3
4
- MINOR = 5
5
- PATCH = 2
4
+ MINOR = 6
5
+ PATCH = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
@@ -22,4 +22,4 @@ module ActiveScaffold
22
22
  end
23
23
 
24
24
  ActiveScaffold.stylesheets << 'active_scaffold_batch'
25
- ActiveScaffold.javascripts << "#{ActiveScaffold.js_framework}/active_scaffold_batch"
25
+ ActiveScaffold.javascripts << 'active_scaffold_batch'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_scaffold_batch
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.2
4
+ version: 3.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergio Cambra
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-08-23 00:00:00.000000000 Z
12
+ date: 2025-04-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: active_scaffold
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: 3.7.1
20
+ version: 4.0.4
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: 3.7.1
27
+ version: 4.0.4
28
28
  description: You want to destroy/update many records at once with activescaffold?
29
29
  email: activescaffold@googlegroups.com
30
30
  executables: []
@@ -34,8 +34,7 @@ extra_rdoc_files:
34
34
  files:
35
35
  - LICENSE.txt
36
36
  - README
37
- - app/assets/javascripts/jquery/active_scaffold_batch.js
38
- - app/assets/javascripts/prototype/active_scaffold_batch.js
37
+ - app/assets/javascripts/active_scaffold_batch.js
39
38
  - app/assets/stylesshets/active_scaffold_batch.scss
40
39
  - app/views/active_scaffold_overrides/_batch_create_form.html.erb
41
40
  - app/views/active_scaffold_overrides/_batch_create_form_attribute.html.erb
@@ -69,7 +68,6 @@ files:
69
68
  - lib/active_scaffold/config/batch_destroy.rb
70
69
  - lib/active_scaffold/config/batch_update.rb
71
70
  - lib/active_scaffold/helpers/batch_create_column_helpers.rb
72
- - lib/active_scaffold/helpers/calendar_date_select_update_column_helpers.rb
73
71
  - lib/active_scaffold/helpers/datepicker_update_column_helpers.rb
74
72
  - lib/active_scaffold/helpers/update_column_helpers.rb
75
73
  - lib/active_scaffold_batch.rb
@@ -94,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
92
  - !ruby/object:Gem::Version
95
93
  version: '0'
96
94
  requirements: []
97
- rubygems_version: 3.2.3
95
+ rubygems_version: 3.5.11
98
96
  signing_key:
99
97
  specification_version: 4
100
98
  summary: Batch Processing for ActiveScaffold
@@ -1,13 +0,0 @@
1
- document.observe("dom:loaded", function() {
2
- document.on('ajax:create', '.batch-create-rows a', function(event, response) {
3
- var num_records = $(this).up('.batch-create-rows').down('input[name=num_records]').value();
4
- if (num_records) response.request.url += (response.request.url.include('?') ? '&' : '?') + 'num_records=' + num_records;
5
- return true;
6
- });
7
- document.on('click', '.multiple .form_record > a.remove', function(event) {
8
- event.stop();
9
- var record = $(this).up('.form_record'), errors = record.previous('.form_record-errors');
10
- if (errors) errors.remove();
11
- record.remove();
12
- });
13
- });
@@ -1,33 +0,0 @@
1
- module ActiveScaffold
2
- module Helpers
3
- module CalendarDateSelectUpdateColumnHelpers
4
- def active_scaffold_update_calendar_date_select(column, options)
5
- current_params = {:value => nil, :number => nil, :unit => nil, :operator => 'NO_UPDATE'}
6
- current_params.merge!(batch_update_values[column.name][:value].symbolize_keys) if batch_update_values[column.name] && batch_update_values[column.name][:value]
7
- Rails.logger.info("update_date column: #{column.name}: #{current_params[:value].inspect}, class: #{current_params[:value].class}")
8
- Rails.logger.info("update_date column: #{column.name}: options #{options.inspect}")
9
- current_params[:value] = nil if current_params[:value].is_a?(String)
10
- Rails.logger.info("update_date2 column: #{column.name}: #{current_params[:value].inspect}, class: #{current_params[:value].class}")
11
- operator_options = active_scaffold_update_generic_operators(column)
12
- operator_options.concat(ActiveScaffold::Actions::BatchUpdate::DateOperators.collect {|comp| [as_(comp.downcase.to_sym), comp]}) if active_scaffold_config.batch_update.process_mode == :update
13
- options = options.merge(:show => ['PLUS', 'MINUS'].exclude?(current_params[:operator]))
14
- tags = []
15
- tags << select_tag("[record][#{column.name}][operator]",
16
- options_for_select(operator_options, current_params[:operator]),
17
- :id => "#{options[:id]}_operator",
18
- :class => "text-input as_update_date_operator")
19
- tags << active_scaffold_search_date_bridge_calendar_control(column, options, current_params[:value], 'value')
20
- tags << active_scaffold_update_date_bridge_trend_tag(column, current_params, options)
21
- tags.join("&nbsp;").html_safe
22
- end
23
-
24
- def active_scaffold_update_date_bridge_trend_tag(column, current_params, options)
25
- active_scaffold_date_bridge_trend_tag(column, options,
26
- {:name_prefix => '[record]',
27
- :number_value => current_params[:number],
28
- :unit_value => current_params[:unit],
29
- :show => ['PLUS','MINUS'].include?(current_params[:operator])})
30
- end
31
- end
32
- end
33
- end