active_scaffold_batch 3.3.4 → 3.4.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 315bc6bae86fcc614c4d42ec9281c4e77b04bf03
4
- data.tar.gz: d68dcac19cb8e728015cc8307c4c4326180cb334
2
+ SHA256:
3
+ metadata.gz: 6682c4f57d85297bde0f373eea697058af433332ef1dd589d08ec57c55a30bf2
4
+ data.tar.gz: 0284ed6ea296322340d47685837e58b96cebc59eac33709430b761f278199541
5
5
  SHA512:
6
- metadata.gz: 2848273ba0912eefc100f95c16862f672fe1d6a665b24981b2fed40689a4146031113397cf1466b63624d4a619dba6f1af8c204f5f891063c54ecfce7e24b286
7
- data.tar.gz: 7ccca54e85cfcf4be69da73449721ce730bc6228e75775de035a2e5b22f5faa899c1e0fc178abef759db978a6a704b3c2f849d263d979735650f372b2bacbb96
6
+ metadata.gz: 7632a402c2ae1c0ca45e4b42c372bee61aae6f7c972e03d26b7bc7eae532cd26d61efaf70d9efbe62d73f6d7360af7546c75682ce3a934b37c1965cb4072b4e9
7
+ data.tar.gz: f8c39f5bfde77928e78693008848b53de9a9c087fc92cc6f58a6c92027223b012ffd8b7bf5d652f7d0ca49a895c5221f996e95c8621d5b8ebcd20601bd67c0c3
data/README CHANGED
@@ -2,6 +2,9 @@ ActiveScaffold batch is a gem which adds batch_update, batch_create and batch_de
2
2
 
3
3
  gem 'active_scaffold_batch'
4
4
 
5
+ It works with ActiveScaffold >= 3.4.18 and rails >= 4.0.
6
+ Use 3.3.x for rails 3.2.x.
7
+
5
8
  In the config block of an activescaffold you can add any of the following lines:
6
9
 
7
10
  config.actions.add :batch_create
@@ -9,7 +9,7 @@
9
9
  border-top: 0;
10
10
  }
11
11
  .active-scaffold .multiple .form_record a.remove {
12
- background-image: url("/assets/active_scaffold/cross.png");
12
+ background-image: image-url("active_scaffold/cross.png");
13
13
  display: block;
14
14
  font-weight: bold;
15
15
  height: 16px;
@@ -27,7 +27,7 @@
27
27
  .active-scaffold-header div.actions > a.batch_new {
28
28
  background-position: 5px 50%;
29
29
  background-repeat: no-repeat;
30
- background-image: url("/assets/active_scaffold/add.png");
30
+ background-image: image-url("active_scaffold/add.png");
31
31
  margin: 0;
32
32
  padding: 5px 5px 5px 25px;
33
33
  }
@@ -3,8 +3,8 @@
3
3
  <li class="form-element">
4
4
  <%= hidden_field_tag("batch_scope", (batch_scope || 'LISTED')) %>
5
5
  </li>
6
- <% columns.each :for => @record do |column| %>
7
- <% next if column.plural_association? || (column.association && [:has_one].include?(column.association.macro)) %>
6
+ <% columns.each_column(for: @record) do |column| %>
7
+ <% next unless column.association.nil? || column.association.belongs_to? %>
8
8
  <% renders_as = column_renders_as(column) %>
9
9
  <% if renders_as == :subsection -%>
10
10
  <% subsection_id = sub_section_id(:sub_section => column.label) %>
@@ -13,7 +13,7 @@
13
13
  <%= render :partial => 'form', :locals => { :columns => column, :subsection_id => subsection_id} %>
14
14
  <%= link_to_visibility_toggle(subsection_id, {:default_visible => !column.collapsed}) -%>
15
15
  </li>
16
- <% elsif column.readonly_association?
16
+ <% elsif column.association.try(:readonly?)
17
17
  next %>
18
18
  <% else
19
19
  renders_as = :field if renders_as == :subform -%>
@@ -1,6 +1,6 @@
1
1
  <thead>
2
2
  <tr>
3
- <% columns.each :flatten => true do |column| -%>
3
+ <% columns.each_column(flatten: true) do |column| -%>
4
4
  <% next if column_renders_as(column) == :hidden -%>
5
5
  <th class="<%= 'required' if column.required? %>"><label><%= column.label %></label></th>
6
6
  <% end -%>
@@ -7,7 +7,7 @@
7
7
  </tr>
8
8
  <% end %>
9
9
  <tr class="form_record">
10
- <% columns.each :flatten => true do |column| -%>
10
+ <% columns.each_column(flatten: true) do |column| -%>
11
11
  <%
12
12
  next if column_renders_as(column) == :hidden
13
13
  next unless record.authorized_for?(:crud_type => :create, :column => column.name)
@@ -3,8 +3,8 @@
3
3
  <li class="form-element">
4
4
  <%= render :partial => 'batch_update_form_attribute_scope' -%>
5
5
  </li>
6
- <% columns.each :for => @record do |column| %>
7
- <% next if column.plural_association? || (column.association && [:has_one].include?(column.association.macro)) %>
6
+ <% columns.each_column(for: @record) do |column| %>
7
+ <% next unless column.association.nil? || column.association.belongs_to? %>
8
8
  <% renders_as = column_renders_as(column) %>
9
9
  <% if renders_as == :subsection -%>
10
10
  <% subsection_id = sub_section_id(:sub_section => column.label) %>
@@ -13,7 +13,7 @@
13
13
  <%= render :partial => 'form', :locals => { :columns => column, :subsection_id => subsection_id } %>
14
14
  <%= link_to_visibility_toggle(subsection_id, :default_visible => !column.collapsed) -%>
15
15
  </li>
16
- <% elsif column.readonly_association?
16
+ <% elsif column.association.try(:readonly?)
17
17
  next %>
18
18
  <% else
19
19
  renders_as = :field if renders_as == :subform -%>
@@ -104,7 +104,7 @@ module ActiveScaffold::Actions
104
104
  if respond_to? "#{action_name}_respond_to_xml", true
105
105
  send("#{action_name}_respond_to_xml")
106
106
  else
107
- render :xml => response_object.to_xml(:only => active_scaffold_config.send(action_name).columns.names), :content_type => Mime::XML, :status => response_status
107
+ render :xml => response_object.to_xml(:only => active_scaffold_config.send(action_name).columns.visible_columns_names), :content_type => Mime::XML, :status => response_status
108
108
  end
109
109
  end
110
110
 
@@ -112,7 +112,7 @@ module ActiveScaffold::Actions
112
112
  if respond_to? "#{action_name}_respond_to_json", true
113
113
  send("#{action_name}_respond_to_json")
114
114
  else
115
- render :text => response_object.to_json(:only => active_scaffold_config.send(action_name).columns.names), :content_type => Mime::JSON, :status => response_status
115
+ render :text => response_object.to_json(:only => active_scaffold_config.send(action_name).columns.visible_columns_names), :content_type => Mime::JSON, :status => response_status
116
116
  end
117
117
  end
118
118
 
@@ -120,7 +120,7 @@ module ActiveScaffold::Actions
120
120
  if respond_to? "#{action_name}_respond_to_yaml", true
121
121
  send("#{action_name}_respond_to_yaml")
122
122
  else
123
- render :text => Hash.from_xml(response_object.to_xml(:only => active_scaffold_config.send(action_name).columns.names)).to_yaml, :content_type => Mime::YAML, :status => response_status
123
+ render :text => Hash.from_xml(response_object.to_xml(:only => active_scaffold_config.send(action_name).columns.visible_columns_names)).to_yaml, :content_type => Mime::YAML, :status => response_status
124
124
  end
125
125
  end
126
126
 
@@ -3,7 +3,7 @@ module ActiveScaffold::Actions
3
3
 
4
4
  def self.included(base)
5
5
  base.send :include, ActiveScaffold::Actions::BatchBase unless base < ActiveScaffold::Actions::BatchBase
6
- base.before_filter :batch_create_authorized_filter, :only => [:batch_new, :batch_create]
6
+ base.before_action :batch_create_authorized_filter, :only => [:batch_new, :batch_create]
7
7
  base.helper_method :batch_create_values
8
8
  base.helper_method :batch_create_by_column
9
9
  base.helper_method :batch_create_by_records
@@ -49,7 +49,7 @@ module ActiveScaffold::Actions
49
49
  if @batch_create_by_records.nil?
50
50
  if marked_records_parent
51
51
  column = active_scaffold_config.columns[batch_create_by_column.to_sym]
52
- @batch_create_by_records = if column.polymorphic_association?
52
+ @batch_create_by_records = if column.association.polymorphic?
53
53
  active_scaffold_config_for(params[:batch_create_by].singularize).model.find(marked_records_parent.keys)
54
54
  else
55
55
  column_plural_assocation_value_from_value(column, marked_records_parent.keys)
@@ -212,7 +212,7 @@ module ActiveScaffold::Actions
212
212
  def create_attribute_values_from_params(columns, attributes)
213
213
  values = {}
214
214
  parent_record = active_scaffold_config.model.new
215
- columns.each :for => active_scaffold_config.model, :crud_type => :create, :flatten => true do |column|
215
+ columns.each_column(for: active_scaffold_config.model, crud_type: :create, flatten: true) do |column|
216
216
  next unless attributes.has_key?(column.name)
217
217
  if column == batch_create_by_column.to_sym
218
218
  @batch_create_by_records = batch_values_for_column(column, attributes[column.name])
@@ -3,7 +3,7 @@ module ActiveScaffold::Actions
3
3
 
4
4
  def self.included(base)
5
5
  base.send :include, ActiveScaffold::Actions::BatchBase unless base < ActiveScaffold::Actions::BatchBase
6
- base.before_filter :batch_destroy_authorized_filter, :only => [:batch_destroy]
6
+ base.before_action :batch_destroy_authorized_filter, :only => [:batch_destroy]
7
7
  end
8
8
 
9
9
  def batch_destroy
@@ -23,7 +23,7 @@ module ActiveScaffold::Actions
23
23
 
24
24
  def self.included(base)
25
25
  base.send :include, ActiveScaffold::Actions::BatchBase unless base < ActiveScaffold::Actions::BatchBase
26
- base.before_filter :batch_update_authorized_filter, :only => [:batch_edit, :batch_update]
26
+ base.before_action :batch_update_authorized_filter, :only => [:batch_edit, :batch_update]
27
27
  base.helper_method :batch_update_values
28
28
  end
29
29
 
@@ -166,13 +166,18 @@ module ActiveScaffold::Actions
166
166
  return sql_set, update_value
167
167
  end
168
168
 
169
+ # TODO: delete when ActiveScaffold 3.5 is released and required
170
+ def params_hash?(value)
171
+ value.is_a?(Hash) || (Rails.version >= '5.0' && value.is_a?(ActionController::Parameters))
172
+ end
173
+
169
174
  def update_attribute_values_from_params(columns, attributes)
170
175
  values = {}
171
- attributes = {} unless attributes.is_a?(Hash)
172
- columns.each :for => new_model, :crud_type => :update, :flatten => true do |column|
173
- next unless attributes[column.name].is_a?(Hash) && params[:record][column.name][:operator] != 'NO_UPDATE'
176
+ return values unless params_hash? attributes
177
+ columns.each_column(for: new_model, crud_type: :update, flatten: true) do |column|
178
+ next unless params_hash?(attributes[column.name]) && attributes[column.name][:operator] != 'NO_UPDATE'
174
179
  value = attributes[column.name]
175
- value = value.merge(:value => (value[:operator] == 'NULL') ? nil : column_value_from_param_value(nil, column, value[:value]))
180
+ value[:value] = value[:operator] == 'NULL' ? nil : column_value_from_param_value(nil, column, value[:value])
176
181
  values[column.name] = {:column => column, :value => value}
177
182
  end
178
183
  values
@@ -3,11 +3,7 @@ module ActiveScaffold::Config
3
3
  self.crud_type = :delete
4
4
 
5
5
  def initialize(core_config)
6
- @core = core_config
7
-
8
- # start with the ActionLink defined globally
9
- @link = self.class.link.map(&:clone) unless self.class.link.nil?
10
- @action_group = self.class.action_group.clone if self.class.action_group
6
+ super
11
7
  @action_group ||= 'collection.batch.destroy'
12
8
  @process_mode = self.class.process_mode
13
9
  end
@@ -35,6 +35,16 @@ module ActiveScaffold
35
35
  def batch_create_multiple_layout
36
36
  "batch_create_form_#{active_scaffold_config.batch_create.layout}"
37
37
  end
38
+
39
+ def current_form_columns(record, scope, subform_controller = nil)
40
+ columns = super
41
+ return columns if columns
42
+ if %i[batch_new batch_create].include? action_name.to_sym
43
+ active_scaffold_config.batch_create.columns.visible_columns_names
44
+ elsif %i[batch_edit batch_update].include? action_name.to_sym
45
+ active_scaffold_config.batch_update.columns.visible_columns_names
46
+ end
47
+ end
38
48
  end
39
49
  end
40
50
  end
@@ -1,13 +1,13 @@
1
1
  # Need to open the AS module carefully due to Rails 2.3 lazy loading
2
2
  ActiveScaffold::Config::Core.class_eval do
3
- ActionDispatch::Routing::ACTIVE_SCAFFOLD_CORE_ROUTING[:collection][:batch_edit] = :get
4
- ActionDispatch::Routing::ACTIVE_SCAFFOLD_CORE_ROUTING[:collection][:batch_update] = :post
5
- ActionDispatch::Routing::ACTIVE_SCAFFOLD_CORE_ROUTING[:collection][:batch_new] = :get
6
- ActionDispatch::Routing::ACTIVE_SCAFFOLD_CORE_ROUTING[:collection][:batch_create] = :post
7
- ActionDispatch::Routing::ACTIVE_SCAFFOLD_CORE_ROUTING[:collection][:batch_add] = :get
3
+ ActiveScaffold::Routing::ACTIVE_SCAFFOLD_CORE_ROUTING[:collection][:batch_edit] = :get
4
+ ActiveScaffold::Routing::ACTIVE_SCAFFOLD_CORE_ROUTING[:collection][:batch_update] = :post
5
+ ActiveScaffold::Routing::ACTIVE_SCAFFOLD_CORE_ROUTING[:collection][:batch_new] = :get
6
+ ActiveScaffold::Routing::ACTIVE_SCAFFOLD_CORE_ROUTING[:collection][:batch_create] = :post
7
+ ActiveScaffold::Routing::ACTIVE_SCAFFOLD_CORE_ROUTING[:collection][:batch_add] = :get
8
8
  #not working because routing picks show route instead
9
- #ActionDispatch::Routing::ACTIVE_SCAFFOLD_CORE_ROUTING[:collection][:batch_destroy] = :get
9
+ #ActiveScaffold::Routing::ACTIVE_SCAFFOLD_CORE_ROUTING[:collection][:batch_destroy] = :get
10
10
  #you may define a route for your controller before resource routes
11
11
  #match 'players/batch_destroy' => 'players#batch_destroy', :via => [:get]
12
- ActionDispatch::Routing::ACTIVE_SCAFFOLD_CORE_ROUTING[:collection][:batch_destroy] = :delete
12
+ ActiveScaffold::Routing::ACTIVE_SCAFFOLD_CORE_ROUTING[:collection][:batch_destroy] = :delete
13
13
  end
@@ -1,7 +1,7 @@
1
1
  module ActiveScaffoldBatch
2
2
  module Version
3
3
  MAJOR = 3
4
- MINOR = 3
4
+ MINOR = 4
5
5
  PATCH = 4
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
metadata CHANGED
@@ -1,30 +1,44 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_scaffold_batch
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.4
4
+ version: 3.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergio Cambra
8
8
  - Volker Hochstein
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-04-18 00:00:00.000000000 Z
12
+ date: 2020-07-16 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.0'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.0'
14
28
  - !ruby/object:Gem::Dependency
15
29
  name: active_scaffold
16
30
  requirement: !ruby/object:Gem::Requirement
17
31
  requirements:
18
- - - '>='
32
+ - - ">="
19
33
  - !ruby/object:Gem::Version
20
- version: 3.4.18
34
+ version: 3.6.0.pre
21
35
  type: :runtime
22
36
  prerelease: false
23
37
  version_requirements: !ruby/object:Gem::Requirement
24
38
  requirements:
25
- - - '>='
39
+ - - ">="
26
40
  - !ruby/object:Gem::Version
27
- version: 3.4.18
41
+ version: 3.6.0.pre
28
42
  description: You want to destroy/update many records at once with activescaffold?
29
43
  email: activescaffold@googlegroups.com
30
44
  executables: []
@@ -36,7 +50,7 @@ files:
36
50
  - README
37
51
  - app/assets/javascripts/jquery/active_scaffold_batch.js
38
52
  - app/assets/javascripts/prototype/active_scaffold_batch.js
39
- - app/assets/stylesshets/active_scaffold_batch.css
53
+ - app/assets/stylesshets/active_scaffold_batch.scss
40
54
  - app/views/active_scaffold_overrides/_batch_create_form.html.erb
41
55
  - app/views/active_scaffold_overrides/_batch_create_form_attribute.html.erb
42
56
  - app/views/active_scaffold_overrides/_batch_create_form_body.html.erb
@@ -80,24 +94,24 @@ homepage: http://github.com/scambra/active_scaffold_batch
80
94
  licenses:
81
95
  - MIT
82
96
  metadata: {}
83
- post_install_message:
97
+ post_install_message:
84
98
  rdoc_options: []
85
99
  require_paths:
86
100
  - lib
87
101
  required_ruby_version: !ruby/object:Gem::Requirement
88
102
  requirements:
89
- - - '>='
103
+ - - ">="
90
104
  - !ruby/object:Gem::Version
91
105
  version: '0'
92
106
  required_rubygems_version: !ruby/object:Gem::Requirement
93
107
  requirements:
94
- - - '>='
108
+ - - ">="
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
97
111
  requirements: []
98
- rubyforge_project:
99
- rubygems_version: 2.4.8
100
- signing_key:
112
+ rubyforge_project:
113
+ rubygems_version: 2.7.9
114
+ signing_key:
101
115
  specification_version: 4
102
116
  summary: Batch Processing for ActiveScaffold
103
117
  test_files: []