active_scaffold_batch_vho 3.0.1 → 3.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -22,7 +22,7 @@ Jeweler::Tasks.new do |gem|
22
22
  gem.description = %Q{You want to destroy/update many records at once with activescaffold?}
23
23
  gem.email = "activescaffold@googlegroups.com"
24
24
  gem.authors = ["Volker Hochstein"]
25
- gem.add_runtime_dependency 'active_scaffold_vho', '~> 3.0'
25
+ gem.add_runtime_dependency 'active_scaffold_vho', '> 3.0.12'
26
26
  # Include your dependencies below. Runtime dependencies are required when using your gem,
27
27
  # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
28
28
  # gem.add_runtime_dependency 'jabber4r', '> 0.1'
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{active_scaffold_batch_vho}
8
- s.version = "3.0.1"
8
+ s.version = "3.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Volker Hochstein"]
12
- s.date = %q{2011-01-26}
12
+ s.date = %q{2011-02-18}
13
13
  s.description = %q{You want to destroy/update many records at once with activescaffold?}
14
14
  s.email = %q{activescaffold@googlegroups.com}
15
15
  s.extra_rdoc_files = [
@@ -22,25 +22,35 @@ Gem::Specification.new do |s|
22
22
  "README",
23
23
  "Rakefile",
24
24
  "active_scaffold_batch_vho.gemspec",
25
+ "frontends/default/views/_batch_create_form.html.erb",
26
+ "frontends/default/views/_batch_create_form_attribute.html.erb",
27
+ "frontends/default/views/_batch_create_form_body.html.erb",
25
28
  "frontends/default/views/_batch_update_form.html.erb",
26
29
  "frontends/default/views/_batch_update_form_attribute.html.erb",
27
30
  "frontends/default/views/_batch_update_form_attribute_scope.html.erb",
28
31
  "frontends/default/views/_batch_update_form_body.html.erb",
32
+ "frontends/default/views/batch_create.html.erb",
29
33
  "frontends/default/views/batch_update.html.erb",
30
34
  "frontends/default/views/on_batch_base.js.rjs",
35
+ "frontends/default/views/on_batch_create.js.rjs",
31
36
  "frontends/default/views/on_batch_update.js.rjs",
32
37
  "init.rb",
33
38
  "lib/active_scaffold/actions/batch_base.rb",
39
+ "lib/active_scaffold/actions/batch_create.rb",
34
40
  "lib/active_scaffold/actions/batch_destroy.rb",
35
41
  "lib/active_scaffold/actions/batch_update.rb",
36
42
  "lib/active_scaffold/config/batch_base.rb",
43
+ "lib/active_scaffold/config/batch_create.rb",
37
44
  "lib/active_scaffold/config/batch_destroy.rb",
38
45
  "lib/active_scaffold/config/batch_update.rb",
46
+ "lib/active_scaffold/helpers/batch_create_column_helpers.rb",
39
47
  "lib/active_scaffold/helpers/calendar_date_select_update_column_helpers.rb",
40
48
  "lib/active_scaffold/helpers/datepicker_update_column_helpers.rb",
41
49
  "lib/active_scaffold/helpers/update_column_helpers.rb",
42
50
  "lib/active_scaffold_batch.rb",
43
51
  "lib/active_scaffold_batch/config/core.rb",
52
+ "lib/active_scaffold_batch/locale/de.yml",
53
+ "lib/active_scaffold_batch/locale/en.yml",
44
54
  "lib/active_scaffold_batch/version.rb",
45
55
  "lib/active_scaffold_batch_vho.rb",
46
56
  "uninstall.rb"
@@ -60,20 +70,20 @@ Gem::Specification.new do |s|
60
70
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
61
71
  s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
62
72
  s.add_development_dependency(%q<rcov>, [">= 0"])
63
- s.add_runtime_dependency(%q<active_scaffold_vho>, ["~> 3.0"])
73
+ s.add_runtime_dependency(%q<active_scaffold_vho>, ["> 3.0.12"])
64
74
  else
65
75
  s.add_dependency(%q<shoulda>, [">= 0"])
66
76
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
67
77
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
68
78
  s.add_dependency(%q<rcov>, [">= 0"])
69
- s.add_dependency(%q<active_scaffold_vho>, ["~> 3.0"])
79
+ s.add_dependency(%q<active_scaffold_vho>, ["> 3.0.12"])
70
80
  end
71
81
  else
72
82
  s.add_dependency(%q<shoulda>, [">= 0"])
73
83
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
74
84
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
75
85
  s.add_dependency(%q<rcov>, [">= 0"])
76
- s.add_dependency(%q<active_scaffold_vho>, ["~> 3.0"])
86
+ s.add_dependency(%q<active_scaffold_vho>, ["> 3.0.12"])
77
87
  end
78
88
  end
79
89
 
@@ -0,0 +1,7 @@
1
+ <%= render :partial => "base_form", :locals => {:xhr => xhr ||= nil,
2
+ :form_action => form_action ||= :batch_create,
3
+ :method => method ||= :post,
4
+ :cancel_link => cancel_link ||= true,
5
+ :body_partial => 'batch_create_form_body',
6
+ :headline => headline ||= active_scaffold_config.batch_create.label} %>
7
+
@@ -0,0 +1,19 @@
1
+ <% scope ||= nil %>
2
+ <dl>
3
+ <dt>
4
+ <label for="<%= active_scaffold_input_options(column, scope)[:id] %>"><%= column.label %></label>
5
+ </dt>
6
+ <dd>
7
+ <% if column.name == batch_create_by_column %>
8
+ <%= active_scaffold_batch_create_by_column column, scope %>
9
+ <% else %>
10
+ <%= active_scaffold_input_for column, scope %>
11
+ <% if column.update_columns -%>
12
+ <%= loading_indicator_tag(:action => :render_field, :id => params[:id]) %>
13
+ <% end -%>
14
+ <% end %>
15
+ <% if column.description -%>
16
+ <span class="description"><%= column.description %></span>
17
+ <% end -%>
18
+ </dd>
19
+ </dl>
@@ -0,0 +1,25 @@
1
+ <% subsection_id ||= nil %>
2
+ <ol class="form" <%= "id=#{subsection_id}" unless subsection_id.nil? %> <%= 'style="display: none;"' if columns.collapsed -%>>
3
+ <li class="form-element">
4
+ <%= hidden_field_tag("batch_scope", (batch_scope || 'LISTED')) %>
5
+ </li>
6
+ <% columns.each :for => @record do |column| %>
7
+ <% next if column.plural_association? || (column.association && [:has_one].include?(column.association.macro)) %>
8
+ <% renders_as = column_renders_as(column) %>
9
+ <% if renders_as == :subsection -%>
10
+ <% subsection_id = sub_section_id(:sub_section => column.label) %>
11
+ <li class="sub-section">
12
+ <h5><%= column.label %></h5>
13
+ <%= render :partial => 'form', :locals => { :columns => column, :subsection_id => subsection_id} %>
14
+ <%= link_to_visibility_toggle(subsection_id, {:default_visible => !column.collapsed}) -%>
15
+ </li>
16
+ <% elsif column.readonly_association?
17
+ next %>
18
+ <% else
19
+ renders_as = :field if renders_as == :subform -%>
20
+ <li class="form-element <%= column.css_class unless column.css_class.nil? %>">
21
+ <%= render :partial => 'batch_create_form_attribute', :locals => { :column => column } -%>
22
+ </li>
23
+ <% end -%>
24
+ <% end -%>
25
+ </ol>
@@ -1,9 +1,14 @@
1
- <% scope ||= nil %>
1
+ <% scope ||= nil
2
+ scope_select_options = active_scaffold_update_scope_select_options %>
3
+ <% if scope_select_options.length < 2 %>
4
+ <%= active_scaffold_update_scope_select(scope_select_options) %>
5
+ <% else %>
2
6
  <dl>
3
7
  <dt>
4
8
  <label for="record_batch_scope"><%= as_(:records) %></label>
5
9
  </dt>
6
10
  <dd>
7
- <%= active_scaffold_update_scope_select %>
11
+ <%= active_scaffold_update_scope_select(scope_select_options) %>
8
12
  </dd>
9
- </dl>
13
+ </dl>
14
+ <% end %>
@@ -0,0 +1,5 @@
1
+ <div class="active-scaffold">
2
+ <div class="batch-create-view <%= "#{params[:controller]}-view" %> view">
3
+ <%= render :partial => 'batch_create_form' -%>
4
+ </div>
5
+ </div>
@@ -0,0 +1,19 @@
1
+ form_selector = "#{element_form_id(:action => :batch_create)}"
2
+
3
+ if controller.send :batch_successful?
4
+ called_by_controller = params.delete(:batch_create_by)
5
+ if called_by_controller.nil?
6
+ page.call 'ActiveScaffold.replace_html', active_scaffold_content_id, render(:partial => 'list', :layout => false)
7
+ else
8
+ options = {:checked => false,
9
+ :include_mark_all => false}
10
+ tbody_id = "#{controller_id(called_by_controller)}-tbody"
11
+ page << "ActiveScaffold.mark_records('#{tbody_id}', #{options.to_json});"
12
+ end
13
+ page << "ActiveScaffold.find_action_link('#{form_selector}').close();"
14
+ else
15
+ page << "ActiveScaffold.find_action_link('#{form_selector}').update_flash_messages('#{escape_javascript(render(:partial => 'messages').strip)}');"
16
+ page.call 'ActiveScaffold.replace', form_selector, render(:partial => 'batch_create_form', :locals => {:xhr => true})
17
+ page.call 'ActiveScaffold.scroll_to', form_selector
18
+ #have to uncheck successfully created marked_records
19
+ end
data/init.rb CHANGED
@@ -1,9 +1,17 @@
1
- ACTIVE_SCAFFOLD_BATCH_INSTALLED = :plugin
2
-
3
1
  require 'active_scaffold_batch'
4
2
 
5
3
  begin
6
4
  ActiveScaffoldAssets.copy_to_public(ActiveScaffoldBatch.root)
7
5
  rescue
8
6
  raise $! unless Rails.env == 'production'
7
+ end
8
+
9
+ ActionView::Base.class_eval do
10
+ include ActiveScaffold::Helpers::UpdateColumnHelpers
11
+ if ActiveScaffold.js_framework == :jquery
12
+ include ActiveScaffold::Helpers::DatepickerUpdateColumnHelpers
13
+ elsif ActiveScaffold.js_framework == :prototype
14
+ include ActiveScaffold::Helpers::CalendarDateSelectUpdateColumnHelpers
15
+ end
16
+ include ActiveScaffold::Helpers::BatchCreateColumnHelpers
9
17
  end
@@ -0,0 +1,198 @@
1
+ module ActiveScaffold::Actions
2
+ module BatchCreate
3
+
4
+ def self.included(base)
5
+ base.before_filter :batch_create_authorized_filter, :only => [:batch_new, :batch_create]
6
+ base.verify :method => [:post, :put],
7
+ :only => :batch_create,
8
+ :redirect_to => { :action => :index }
9
+ base.helper_method :batch_create_values
10
+ base.helper_method :batch_create_by_column
11
+ base.helper_method :batch_create_by_records
12
+ end
13
+
14
+ def batch_new
15
+ do_batch_new
16
+ respond_to_action(:batch_new)
17
+ end
18
+
19
+ def batch_create
20
+ batch_action
21
+ end
22
+
23
+
24
+ protected
25
+ def batch_new_respond_to_html
26
+ if batch_successful?
27
+ render(:action => 'batch_create')
28
+ else
29
+ return_to_main
30
+ end
31
+ end
32
+
33
+ def batch_new_respond_to_js
34
+ render(:partial => 'batch_create_form')
35
+ end
36
+
37
+ def batch_create_values
38
+ @batch_create_values || {}
39
+ end
40
+
41
+ def batch_create_by_records
42
+ @batch_create_by_records || []
43
+ end
44
+
45
+ def batch_create_respond_to_html
46
+ if params[:iframe]=='true' # was this an iframe post ?
47
+ responds_to_parent do
48
+ render :action => 'on_batch_create.js', :layout => false
49
+ end
50
+ else # just a regular post
51
+ if batch_successful?
52
+ flash[:info] = as_(:created_model, :model => @record.to_label)
53
+ return_to_main
54
+ else
55
+ render(:action => 'batch_create')
56
+ end
57
+ end
58
+ end
59
+
60
+ def batch_create_respond_to_js
61
+ render :action => 'on_batch_create'
62
+ end
63
+
64
+ def do_batch_new
65
+ self.successful = true
66
+ do_new
67
+ if marked_records_parent
68
+ batch_scope # that s a dummy call to remove batch_scope parameter
69
+ column = active_scaffold_config.columns[batch_create_by_column.to_sym]
70
+ @batch_create_by_records = column_plural_assocation_value_from_value(column, marked_records_parent)
71
+ end
72
+ end
73
+
74
+ def marked_records_parent
75
+ if params[:batch_create_by]
76
+ session_parent = active_scaffold_session_storage(params[:batch_create_by])
77
+ @marked_records_parent = session_parent[:marked_records] || Set.new
78
+ else
79
+ @marked_records_parent = false
80
+ end if @marked_records_parent.nil?
81
+ @marked_records_parent
82
+ end
83
+
84
+ def before_do_batch_create
85
+ create_columns = active_scaffold_config.batch_create.columns
86
+ @batch_create_values = attribute_values_from_params(create_columns, params[:record])
87
+ end
88
+
89
+ # in case of an error we have to prepare @record object to have assigned all
90
+ # defined batch_update values, however, do not set those ones with an override
91
+ # these ones will manage on their own
92
+ def prepare_error_record
93
+ do_new
94
+ batch_create_values.each do |attribute, value|
95
+ form_ui = colunm_form_ui(value[:column])
96
+ set_record_attribute(value[:column], attribute, value[:value]) unless form_ui && override_batch_create_value?(form_ui)
97
+ end
98
+ end
99
+
100
+ def batch_create_listed
101
+ case active_scaffold_config.batch_create.process_mode
102
+ when :create then
103
+ batch_create_by_records.each {|batch_record| create_record(batch_record)}
104
+ else
105
+ Rails.logger.error("Unknown process_mode: #{active_scaffold_config.batch_create.process_mode} for action batch_create")
106
+ end
107
+ end
108
+
109
+ def batch_create_marked
110
+ case active_scaffold_config.batch_create.process_mode
111
+ when :create then
112
+ batch_create_by_records.each do |by_record|
113
+ create_record(by_record)
114
+ end
115
+ else
116
+ Rails.logger.error("Unknown process_mode: #{active_scaffold_config.batch_create.process_mode} for action batch_create")
117
+ end
118
+ end
119
+
120
+ def create_record(batch_record)
121
+ @successful = nil
122
+ @record = new_model
123
+ @record.send("#{batch_create_by_column.to_s}=", batch_record)
124
+ batch_create_values.each do |attribute, value|
125
+ set_record_attribute(value[:column], attribute, value[:value])
126
+ end
127
+
128
+ if authorized_for_job?(@record)
129
+ create_save
130
+ if successful?
131
+ marked_records_parent.delete(batch_record.id) if batch_scope == 'MARKED' && marked_records_parent
132
+ else
133
+ error_records << @record
134
+ end
135
+ end
136
+ end
137
+
138
+ def set_record_attribute(column, attribute, value)
139
+ form_ui = colunm_form_ui(column)
140
+ if form_ui && override_batch_create_value?(form_ui)
141
+ @record.send("#{attribute}=", send(override_batch_create_value(form_ui), column, @record, value))
142
+ else
143
+ @record.send("#{attribute}=", value)
144
+ end
145
+ end
146
+
147
+ def colunm_form_ui(column)
148
+ form_ui = column.form_ui
149
+ form_ui = column.column.type if form_ui.nil? && column.column
150
+ end
151
+
152
+ def batch_create_by_column
153
+ active_scaffold_config.batch_create.default_batch_by_column
154
+ end
155
+
156
+
157
+ def attribute_values_from_params(columns, attributes)
158
+ values = {}
159
+ columns.each :for => active_scaffold_config.model.new, :crud_type => :create, :flatten => true do |column|
160
+ if batch_create_by_column == column.name
161
+ @batch_create_by_records = column_plural_assocation_value_from_value(column, attributes[column.name])
162
+ else
163
+ values[column.name] = {:column => column, :value => column_value_from_param_value(nil, column, attributes[column.name])}
164
+ end if attributes.has_key?(column.name)
165
+ end
166
+ values
167
+ end
168
+
169
+
170
+ # The default security delegates to ActiveRecordPermissions.
171
+ # You may override the method to customize.
172
+ def batch_create_authorized?(record = nil)
173
+ authorized_for?(:crud_type => :create)
174
+ end
175
+
176
+ def batch_create_ignore?(record = nil)
177
+ false
178
+ end
179
+
180
+ def override_batch_create_value?(form_ui)
181
+ respond_to?(override_batch_create_value(form_ui))
182
+ end
183
+
184
+ def override_batch_create_value(form_ui)
185
+ "batch_create_value_for_#{form_ui}"
186
+ end
187
+
188
+ private
189
+
190
+ def batch_create_authorized_filter
191
+ link = active_scaffold_config.batch_create.link || active_scaffold_config.batch_create.class.link
192
+ raise ActiveScaffold::ActionNotAllowed unless self.send(link.security_method)
193
+ end
194
+ def batch_new_formats
195
+ (default_formats + active_scaffold_config.formats).uniq
196
+ end
197
+ end
198
+ end
@@ -219,6 +219,10 @@ module ActiveScaffold::Actions
219
219
  authorized_for?(:crud_type => :update)
220
220
  end
221
221
 
222
+ def batch_update_ignore?(record = nil)
223
+ false
224
+ end
225
+
222
226
  def batch_update_value_for_numeric(column, record, calculation_info)
223
227
  current_value = record.send(column.name)
224
228
  if ActiveScaffold::Actions::BatchUpdate::GenericOperators.include?(calculation_info[:operator]) || ActiveScaffold::Actions::BatchUpdate::NumericOperators.include?(calculation_info[:operator])
@@ -0,0 +1,57 @@
1
+ module ActiveScaffold::Config
2
+ class BatchCreate < ActiveScaffold::Config::Form
3
+ self.crud_type = :create
4
+ def initialize(*args)
5
+ super
6
+ @process_mode = self.class.process_mode
7
+ @action_group ||= 'collection.batch'
8
+ @list_mode_enabled = self.class.list_mode_enabled
9
+ end
10
+
11
+ # global level configuration
12
+ # --------------------------
13
+ # the ActionLink for this action
14
+ def self.link
15
+ @@link
16
+ end
17
+ def self.link=(val)
18
+ @@link = val
19
+ end
20
+ @@link = ActiveScaffold::DataStructures::ActionLink.new('batch_new', :label => :create, :type => :collection, :security_method => :batch_create_authorized?, :ignore_method => :batch_create_ignore?)
21
+
22
+ # configures where the plugin itself is located. there is no instance version of this.
23
+ cattr_accessor :plugin_directory
24
+ @@plugin_directory = File.expand_path(__FILE__).match(%{(^.*)/lib/active_scaffold/config/batch_create.rb})[1]
25
+
26
+ # configures how batch create should be processed
27
+ # :create => standard activerecord create including validations
28
+ cattr_accessor :process_mode
29
+ @@process_mode = :create
30
+
31
+ # you may update all records in list view or all marked records
32
+ # you might disable list mode with this switch if you think it is
33
+ # too "dangerous"
34
+ cattr_accessor :list_mode_enabled
35
+ @@list_mode_enabled = true
36
+ # instance-level configuration
37
+ # ----------------------------
38
+
39
+ # see class accessor
40
+ attr_accessor :process_mode
41
+
42
+ attr_accessor :list_mode_enabled
43
+
44
+ # you may use create_batch to create a record for each record
45
+ # of a belong_to association (reverse must be has_many)
46
+ # eg. player belongs to team
47
+ # you may batch create a player records for a list of teams
48
+ attr_accessor :default_batch_by_column
49
+
50
+
51
+ # the label= method already exists in the Form base class
52
+ def label(model = nil)
53
+ model ||= @core.label(:count => 2)
54
+ @label ? as_(@label) : as_(:create_model, :model => model)
55
+ end
56
+ end
57
+ end
@@ -5,6 +5,7 @@ module ActiveScaffold::Config
5
5
  super
6
6
  @process_mode = self.class.process_mode
7
7
  @action_group ||= 'collection.batch'
8
+ @list_mode_enabled = self.class.list_mode_enabled
8
9
  end
9
10
 
10
11
  # global level configuration
@@ -16,7 +17,7 @@ module ActiveScaffold::Config
16
17
  def self.link=(val)
17
18
  @@link = val
18
19
  end
19
- @@link = ActiveScaffold::DataStructures::ActionLink.new('batch_edit', :label => :edit, :type => :collection, :security_method => :batch_update_authorized?)
20
+ @@link = ActiveScaffold::DataStructures::ActionLink.new('batch_edit', :label => :edit, :type => :collection, :security_method => :batch_update_authorized?, :ignore_method => :batch_update_ignore?)
20
21
 
21
22
  # configures where the plugin itself is located. there is no instance version of this.
22
23
  cattr_accessor :plugin_directory
@@ -28,13 +29,19 @@ module ActiveScaffold::Config
28
29
  cattr_accessor :process_mode
29
30
  @@process_mode = :update
30
31
 
31
-
32
+ # you may update all records in list view or all marked records
33
+ # you might disable list mode with this switch if you think it is
34
+ # too "dangerous"
35
+ cattr_accessor :list_mode_enabled
36
+ @@list_mode_enabled = true
32
37
  # instance-level configuration
33
38
  # ----------------------------
34
39
 
35
40
  # see class accessor
36
41
  attr_accessor :process_mode
37
42
 
43
+ attr_accessor :list_mode_enabled
44
+
38
45
 
39
46
  # the label= method already exists in the Form base class
40
47
  def label(model = nil)
@@ -0,0 +1,30 @@
1
+ module ActiveScaffold
2
+ module Helpers
3
+ # Helpers that assist with the rendering of a Form Column
4
+ module BatchCreateColumnHelpers
5
+ # This method decides which input to use for the given column.
6
+ # It does not do any rendering. It only decides which method is responsible for rendering.
7
+ def active_scaffold_batch_create_by_column(column, scope = nil, options = {})
8
+ options = active_scaffold_input_options(column, scope, options)
9
+
10
+ if column.form_ui == :record_select
11
+ active_scaffold_record_select(column, options, batch_create_by_records, true)
12
+ else
13
+ active_scaffold_batch_create_singular_association(column, options)
14
+ end
15
+
16
+ end
17
+
18
+ def active_scaffold_batch_create_singular_association(column, html_options)
19
+ associated_options = batch_create_by_records.collect {|r| r.id}
20
+ select_options = options_for_association(column.association)
21
+ html_options.update(column.options[:html_options] || {})
22
+ options = {}
23
+ options.update(column.options)
24
+ html_options[:name] = "#{html_options[:name]}[]"
25
+ html_options[:multiple] = true
26
+ select_tag(column.name, options_for_select(select_options.uniq, associated_options), html_options)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -13,7 +13,7 @@ module ActiveScaffold
13
13
  # second, check if the dev has specified a valid form_ui for this column, using specific ui for searches
14
14
  elsif column.form_ui and override_update?(column.form_ui)
15
15
  send(override_update(column.form_ui), column, options)
16
- elsif column.column and override_update?(column.column.type)
16
+ elsif column.column && column.form_ui.nil? && override_update?(column.column.type)
17
17
  send(override_update(column.column.type), column, options)
18
18
  else
19
19
  active_scaffold_update_generic_operators_select(column, options)<< ' ' << active_scaffold_render_input(column, options.merge(:name => "record[#{column.name}][value]"))
@@ -57,12 +57,21 @@ module ActiveScaffold
57
57
  alias_method :active_scaffold_update_decimal, :active_scaffold_update_numeric
58
58
  alias_method :active_scaffold_update_float, :active_scaffold_update_numeric
59
59
 
60
- def active_scaffold_update_scope_select
61
- select_options = [[as_(:listed), 'LISTED']]
60
+ def active_scaffold_update_scope_select(select_options = active_scaffold_update_scope_select_options)
61
+ if select_options.length > 1
62
+ select_tag("batch_scope",
63
+ options_for_select(select_options, batch_scope || select_options.last[1]),
64
+ :class => "text_input")
65
+ else
66
+ hidden_field_tag("batch_scope", select_options.first[1]) unless select_options.empty?
67
+ end
68
+ end
69
+
70
+ def active_scaffold_update_scope_select_options
71
+ select_options = []
72
+ select_options << [as_(:listed), 'LISTED'] if active_scaffold_config.batch_update.list_mode_enabled
62
73
  select_options << [as_(:marked), 'MARKED'] if active_scaffold_config.actions.include?(:mark)
63
- select_tag("batch_scope",
64
- options_for_select(select_options, batch_scope || select_options.last[1]),
65
- :class => "text_input")
74
+ select_options
66
75
  end
67
76
 
68
77
  ##
@@ -2,6 +2,8 @@
2
2
  ActiveScaffold::Config::Core.class_eval do
3
3
  ActionDispatch::Routing::ACTIVE_SCAFFOLD_CORE_ROUTING[:collection][:batch_edit] = :get
4
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
5
7
  #not working because routing picks show route instead
6
8
  #ActionDispatch::Routing::ACTIVE_SCAFFOLD_CORE_ROUTING[:collection][:batch_destroy] = :get
7
9
  #you may define a route for your controller before resource routes
@@ -0,0 +1,10 @@
1
+ de:
2
+ active_scaffold:
3
+ no_update: ---
4
+ replace: Ersetzen
5
+ plus: '+'
6
+ minus: '-'
7
+ times: '*'
8
+ division: '/'
9
+ absolute: abs
10
+ percent: '%'
@@ -0,0 +1,10 @@
1
+ en:
2
+ active_scaffold:
3
+ no_update: No Update
4
+ replace: Replace
5
+ plus: '+'
6
+ minus: '-'
7
+ times: '*'
8
+ division: '/'
9
+ absolute: abs
10
+ percent: '%'
@@ -2,7 +2,7 @@ module ActiveScaffoldBatch
2
2
  module Version
3
3
  MAJOR = 3
4
4
  MINOR = 0
5
- PATCH = 1
5
+ PATCH = 3
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
@@ -2,7 +2,7 @@
2
2
  ActiveScaffold rescue throw "should have included ActiveScaffold plug in first. Please make sure that this overwrite plugging comes alphabetically after the ActiveScaffold plug in"
3
3
 
4
4
  # Load our overrides
5
- require "#{File.dirname(__FILE__)}/active_scaffold_batch/config/core.rb"
5
+ require "active_scaffold_batch/config/core.rb"
6
6
 
7
7
  module ActiveScaffoldBatch
8
8
  def self.root
@@ -24,14 +24,7 @@ module ActiveScaffold
24
24
  end
25
25
  end
26
26
 
27
- ActionView::Base.class_eval do
28
- include ActiveScaffold::Helpers::UpdateColumnHelpers
29
- if ActiveScaffold.js_framework == :jquery
30
- include ActiveScaffold::Helpers::DatepickerUpdateColumnHelpers
31
- elsif ActiveScaffold.js_framework == :prototype
32
- include ActiveScaffold::Helpers::CalendarDateSelectUpdateColumnHelpers
33
- end
34
- end
27
+ I18n.load_path += Dir[File.join(File.dirname(__FILE__), 'active_scaffold_batch', 'locale', '*.{rb,yml}')]
35
28
 
36
29
  ##
37
30
  ## Run the install assets script, too, just to make sure
@@ -40,7 +33,16 @@ end
40
33
  Rails::Application.initializer("active_scaffold_batch.install_assets", :after => "active_scaffold.install_assets") do
41
34
  begin
42
35
  ActiveScaffoldAssets.copy_to_public(ActiveScaffoldBatch.root)
36
+ ActionView::Base.class_eval do
37
+ include ActiveScaffold::Helpers::UpdateColumnHelpers
38
+ if ActiveScaffold.js_framework == :jquery
39
+ include ActiveScaffold::Helpers::DatepickerUpdateColumnHelpers
40
+ elsif ActiveScaffold.js_framework == :prototype
41
+ include ActiveScaffold::Helpers::CalendarDateSelectUpdateColumnHelpers
42
+ end
43
+ include ActiveScaffold::Helpers::BatchCreateColumnHelpers
44
+ end
43
45
  rescue
44
46
  raise $! unless Rails.env == 'production'
45
47
  end
46
- end unless defined?(ACTIVE_SCAFFOLD_BATCH_INSTALLED) && ACTIVE_SCAFFOLD_BATCH_INSTALLED == :plugin
48
+ end if defined?(ACTIVE_SCAFFOLD_BATCH_GEM)
@@ -1,2 +1,2 @@
1
- ACTIVE_SCAFFOLD_BATCH_INSTALLED = :gem
1
+ ACTIVE_SCAFFOLD_BATCH_GEM = true
2
2
  require 'active_scaffold_batch'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_scaffold_batch_vho
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 1
5
5
  prerelease: false
6
6
  segments:
7
7
  - 3
8
8
  - 0
9
- - 1
10
- version: 3.0.1
9
+ - 3
10
+ version: 3.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Volker Hochstein
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-26 00:00:00 +01:00
18
+ date: 2011-02-18 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -84,13 +84,14 @@ dependencies:
84
84
  version_requirements: &id005 !ruby/object:Gem::Requirement
85
85
  none: false
86
86
  requirements:
87
- - - ~>
87
+ - - ">"
88
88
  - !ruby/object:Gem::Version
89
- hash: 7
89
+ hash: 31
90
90
  segments:
91
91
  - 3
92
92
  - 0
93
- version: "3.0"
93
+ - 12
94
+ version: 3.0.12
94
95
  requirement: *id005
95
96
  type: :runtime
96
97
  description: You want to destroy/update many records at once with activescaffold?
@@ -108,25 +109,35 @@ files:
108
109
  - README
109
110
  - Rakefile
110
111
  - active_scaffold_batch_vho.gemspec
112
+ - frontends/default/views/_batch_create_form.html.erb
113
+ - frontends/default/views/_batch_create_form_attribute.html.erb
114
+ - frontends/default/views/_batch_create_form_body.html.erb
111
115
  - frontends/default/views/_batch_update_form.html.erb
112
116
  - frontends/default/views/_batch_update_form_attribute.html.erb
113
117
  - frontends/default/views/_batch_update_form_attribute_scope.html.erb
114
118
  - frontends/default/views/_batch_update_form_body.html.erb
119
+ - frontends/default/views/batch_create.html.erb
115
120
  - frontends/default/views/batch_update.html.erb
116
121
  - frontends/default/views/on_batch_base.js.rjs
122
+ - frontends/default/views/on_batch_create.js.rjs
117
123
  - frontends/default/views/on_batch_update.js.rjs
118
124
  - init.rb
119
125
  - lib/active_scaffold/actions/batch_base.rb
126
+ - lib/active_scaffold/actions/batch_create.rb
120
127
  - lib/active_scaffold/actions/batch_destroy.rb
121
128
  - lib/active_scaffold/actions/batch_update.rb
122
129
  - lib/active_scaffold/config/batch_base.rb
130
+ - lib/active_scaffold/config/batch_create.rb
123
131
  - lib/active_scaffold/config/batch_destroy.rb
124
132
  - lib/active_scaffold/config/batch_update.rb
133
+ - lib/active_scaffold/helpers/batch_create_column_helpers.rb
125
134
  - lib/active_scaffold/helpers/calendar_date_select_update_column_helpers.rb
126
135
  - lib/active_scaffold/helpers/datepicker_update_column_helpers.rb
127
136
  - lib/active_scaffold/helpers/update_column_helpers.rb
128
137
  - lib/active_scaffold_batch.rb
129
138
  - lib/active_scaffold_batch/config/core.rb
139
+ - lib/active_scaffold_batch/locale/de.yml
140
+ - lib/active_scaffold_batch/locale/en.yml
130
141
  - lib/active_scaffold_batch/version.rb
131
142
  - lib/active_scaffold_batch_vho.rb
132
143
  - uninstall.rb