active_scaffold 3.6.0.pre → 3.6.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{CHANGELOG → CHANGELOG.rdoc} +39 -0
- data/app/assets/javascripts/active_scaffold.js.erb +0 -1
- data/app/assets/javascripts/jquery/active_scaffold.js +35 -4
- data/app/assets/stylesheets/active_scaffold_colors.scss +1 -1
- data/app/assets/stylesheets/active_scaffold_layout.css +52 -29
- data/app/views/active_scaffold_overrides/_list_header.html.erb +5 -7
- data/app/views/active_scaffold_overrides/_list_record.html.erb +4 -5
- data/app/views/active_scaffold_overrides/_list_with_header.html.erb +1 -1
- data/app/views/active_scaffold_overrides/_refresh_list.js.erb +4 -0
- data/config/locales/de.yml +2 -1
- data/config/locales/en.yml +1 -0
- data/config/locales/es.yml +1 -0
- data/config/locales/fr.yml +2 -1
- data/config/locales/hu.yml +1 -0
- data/config/locales/ja.yml +1 -0
- data/config/locales/ru.yml +1 -0
- data/lib/active_scaffold.rb +8 -3
- data/lib/active_scaffold/actions/common_search.rb +11 -8
- data/lib/active_scaffold/actions/core.rb +79 -51
- data/lib/active_scaffold/actions/create.rb +27 -27
- data/lib/active_scaffold/actions/delete.rb +1 -1
- data/lib/active_scaffold/actions/field_search.rb +52 -42
- data/lib/active_scaffold/actions/list.rb +106 -23
- data/lib/active_scaffold/actions/nested.rb +59 -42
- data/lib/active_scaffold/actions/show.rb +3 -3
- data/lib/active_scaffold/actions/subform.rb +9 -16
- data/lib/active_scaffold/actions/update.rb +95 -77
- data/lib/active_scaffold/attribute_params.rb +93 -68
- data/lib/active_scaffold/bridges/active_storage.rb +6 -0
- data/lib/active_scaffold/bridges/active_storage/active_storage_bridge.rb +33 -0
- data/lib/active_scaffold/bridges/active_storage/active_storage_helpers.rb +54 -0
- data/lib/active_scaffold/bridges/active_storage/form_ui.rb +22 -0
- data/lib/active_scaffold/bridges/active_storage/list_ui.rb +36 -0
- data/lib/active_scaffold/bridges/bitfields.rb +1 -0
- data/lib/active_scaffold/bridges/bitfields/bitfields_bridge.rb +12 -15
- data/lib/active_scaffold/bridges/cancan/cancan_bridge.rb +6 -0
- data/lib/active_scaffold/bridges/carrierwave/list_ui.rb +2 -2
- data/lib/active_scaffold/bridges/date_picker/helper.rb +46 -41
- data/lib/active_scaffold/bridges/dragonfly/list_ui.rb +1 -1
- data/lib/active_scaffold/bridges/file_column/file_column_helpers.rb +2 -2
- data/lib/active_scaffold/bridges/file_column/form_ui.rb +3 -3
- data/lib/active_scaffold/bridges/file_column/test/functional/file_column_keep_test.rb +3 -1
- data/lib/active_scaffold/bridges/paperclip/paperclip_bridge_helpers.rb +2 -2
- data/lib/active_scaffold/bridges/record_select/helpers.rb +3 -7
- data/lib/active_scaffold/bridges/shared/date_bridge.rb +19 -18
- data/lib/active_scaffold/bridges/tiny_mce/helpers.rb +3 -1
- data/lib/active_scaffold/bridges/usa_state_select/usa_state_select_helper.rb +20 -3
- data/lib/active_scaffold/config/base.rb +58 -34
- data/lib/active_scaffold/config/core.rb +31 -12
- data/lib/active_scaffold/config/delete.rb +12 -1
- data/lib/active_scaffold/config/list.rb +17 -7
- data/lib/active_scaffold/config/mark.rb +1 -1
- data/lib/active_scaffold/configurable.rb +5 -3
- data/lib/active_scaffold/constraints.rb +21 -19
- data/lib/active_scaffold/core.rb +35 -26
- data/lib/active_scaffold/data_structures/action_columns.rb +1 -1
- data/lib/active_scaffold/data_structures/action_link.rb +34 -16
- data/lib/active_scaffold/data_structures/action_links.rb +9 -11
- data/lib/active_scaffold/data_structures/association/abstract.rb +35 -13
- data/lib/active_scaffold/data_structures/association/active_mongoid.rb +2 -6
- data/lib/active_scaffold/data_structures/association/active_record.rb +5 -1
- data/lib/active_scaffold/data_structures/association/mongoid.rb +0 -3
- data/lib/active_scaffold/data_structures/column.rb +49 -58
- data/lib/active_scaffold/data_structures/columns.rb +3 -2
- data/lib/active_scaffold/data_structures/nested_info.rb +20 -18
- data/lib/active_scaffold/data_structures/sorting.rb +5 -0
- data/lib/active_scaffold/delayed_setup.rb +16 -6
- data/lib/active_scaffold/extensions/action_controller_rendering.rb +1 -1
- data/lib/active_scaffold/extensions/action_view_rendering.rb +34 -14
- data/lib/active_scaffold/extensions/cow_proxy.rb +50 -2
- data/lib/active_scaffold/extensions/localize.rb +3 -1
- data/lib/active_scaffold/extensions/routing_mapper.rb +2 -2
- data/lib/active_scaffold/extensions/to_label.rb +3 -2
- data/lib/active_scaffold/finder.rb +81 -46
- data/lib/active_scaffold/helpers/action_link_helpers.rb +47 -21
- data/lib/active_scaffold/helpers/association_helpers.rb +13 -11
- data/lib/active_scaffold/helpers/controller_helpers.rb +14 -11
- data/lib/active_scaffold/helpers/form_column_helpers.rb +133 -99
- data/lib/active_scaffold/helpers/human_condition_helpers.rb +1 -1
- data/lib/active_scaffold/helpers/id_helpers.rb +4 -0
- data/lib/active_scaffold/helpers/list_column_helpers.rb +76 -49
- data/lib/active_scaffold/helpers/pagination_helpers.rb +2 -2
- data/lib/active_scaffold/helpers/search_column_helpers.rb +25 -30
- data/lib/active_scaffold/helpers/show_column_helpers.rb +3 -5
- data/lib/active_scaffold/helpers/view_helpers.rb +31 -22
- data/lib/active_scaffold/orm_checks.rb +2 -2
- data/lib/active_scaffold/paginator.rb +1 -3
- data/lib/active_scaffold/registry.rb +11 -0
- data/lib/active_scaffold/responds_to_parent.rb +6 -5
- data/lib/active_scaffold/tableless.rb +6 -8
- data/lib/active_scaffold/version.rb +1 -1
- data/shoulda_macros/macros.rb +3 -1
- data/test/bridges/paperclip_test.rb +1 -1
- data/test/company.rb +2 -2
- data/test/data_structures/action_columns_test.rb +2 -2
- data/test/data_structures/column_test.rb +3 -6
- data/test/data_structures/columns_test.rb +2 -2
- data/test/extensions/active_record_test.rb +4 -4
- data/test/extensions/routing_mapper_test.rb +2 -2
- data/test/helpers/list_column_helpers_test.rb +3 -1
- data/test/misc/active_record_permissions_test.rb +2 -2
- data/test/misc/attribute_params_test.rb +4 -0
- data/test/misc/configurable_test.rb +10 -10
- data/test/misc/convert_numbers_format_test.rb +4 -0
- data/test/mock_app/app/assets/config/manifest.js +0 -0
- data/test/mock_app/app/controllers/cars_controller.rb +1 -0
- data/test/mock_app/app/controllers/people_controller.rb +3 -1
- data/test/mock_app/config/application.rb +1 -0
- data/test/mock_app/config/routes.rb +4 -1
- data/test/mock_app/db/schema.rb +2 -0
- data/test/performance/list_cars_performance_test.rb +34 -0
- data/test/performance/list_people_performance_test.rb +31 -0
- data/test/performance_test_help.rb +3 -0
- data/test/test_helper.rb +2 -1
- metadata +22 -12
- data/app/assets/javascripts/prototype/rico_corner.js +0 -370
- data/lib/active_scaffold/bridges/file_column/test/test_helper.rb +0 -5
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= content_tag(:div, id: active_scaffold_id, class: as_main_div_class, data:
|
1
|
+
<%= content_tag(:div, id: active_scaffold_id, class: as_main_div_class, data: as_main_div_data) do %>
|
2
2
|
<div class="active-scaffold-header">
|
3
3
|
<%= render :partial => 'list_header' %>
|
4
4
|
</div>
|
@@ -4,7 +4,11 @@
|
|
4
4
|
|
5
5
|
<% if @page.pager.infinite? || @page.number < @page.pager.number_of_pages -%>
|
6
6
|
ActiveScaffold.auto_load_page('<%= url_for main_path_to_return %>', {auto_pagination: true, page: <%= @page.number + 1 %>});
|
7
|
+
<% else %>
|
8
|
+
ActiveScaffold.hide('<%= loading_indicator_id(action: :pagination) %>');
|
7
9
|
<% end # @page.pager.infinite?... %>
|
10
|
+
<% else %>
|
11
|
+
ActiveScaffold.hide('<%= loading_indicator_id(action: :pagination) %>');
|
8
12
|
<% end # @page.items.present? %>
|
9
13
|
|
10
14
|
<% elsif active_scaffold_config.list.refresh_with_header -%>
|
data/config/locales/de.yml
CHANGED
@@ -107,7 +107,8 @@ de:
|
|
107
107
|
other: "%{count} %{model} makriert"
|
108
108
|
refresh: Neu laden
|
109
109
|
remove: Entfernen
|
110
|
-
remove_file: Entferne oder
|
110
|
+
remove_file: Entferne oder Ersetzte Datei
|
111
|
+
remove_files: Entfernen oder Hinzufügen Dateien
|
111
112
|
replace_existing: Existierenden ersetzen
|
112
113
|
replace_with_new: Mit Neuer ersetzen
|
113
114
|
reset: Zurücksetzen
|
data/config/locales/en.yml
CHANGED
data/config/locales/es.yml
CHANGED
data/config/locales/fr.yml
CHANGED
@@ -107,7 +107,8 @@ fr:
|
|
107
107
|
other: "%{count} %{model} marqués"
|
108
108
|
refresh: Rafraîchir
|
109
109
|
remove: Supprimer
|
110
|
-
remove_file: Supprimer
|
110
|
+
remove_file: Supprimer ou remplacer le fichier
|
111
|
+
remove_files: Supprimer ou Ajouter des fichiers
|
111
112
|
replace_existing: Remplacer existant(e)
|
112
113
|
replace_with_new: Remplacer avec le nouveau
|
113
114
|
reset: Annuler
|
data/config/locales/hu.yml
CHANGED
data/config/locales/ja.yml
CHANGED
data/config/locales/ru.yml
CHANGED
data/lib/active_scaffold.rb
CHANGED
@@ -41,8 +41,8 @@ module ActiveScaffold
|
|
41
41
|
|
42
42
|
class ControllerNotFound < RuntimeError; end
|
43
43
|
class MalformedConstraint < RuntimeError; end
|
44
|
-
class RecordNotAllowed <
|
45
|
-
class ActionNotAllowed <
|
44
|
+
class RecordNotAllowed < RuntimeError; end
|
45
|
+
class ActionNotAllowed < RuntimeError; end
|
46
46
|
class ReverseAssociationRequired < RuntimeError; end
|
47
47
|
|
48
48
|
mattr_accessor :delayed_setup, instance_writer: false
|
@@ -84,7 +84,12 @@ module ActiveScaffold
|
|
84
84
|
File.dirname(__FILE__) + '/..'
|
85
85
|
end
|
86
86
|
|
87
|
-
def self.set_defaults(&block)
|
87
|
+
def self.set_defaults(&block) # rubocop:disable Naming/AccessorMethodName
|
88
|
+
ActiveSupport::Deprecation.warn 'use ActiveScaffold.defaults'
|
89
|
+
defaults(&block)
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.defaults(&block)
|
88
93
|
ActiveScaffold::Config::Core.configure(&block)
|
89
94
|
end
|
90
95
|
end
|
@@ -1,13 +1,12 @@
|
|
1
1
|
module ActiveScaffold::Actions
|
2
2
|
module CommonSearch
|
3
3
|
def self.included(base)
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
4
|
+
return if base < InstanceMethods
|
5
|
+
base.send :include, InstanceMethods
|
6
|
+
base.before_action :search_authorized_filter, :only => :show_search
|
7
|
+
base.before_action :store_search_params_into_session, :only => [:index]
|
8
|
+
base.before_action :do_search, :only => [:index]
|
9
|
+
base.helper_method :search_params
|
11
10
|
end
|
12
11
|
|
13
12
|
module InstanceMethods
|
@@ -34,7 +33,11 @@ module ActiveScaffold::Actions
|
|
34
33
|
|
35
34
|
def store_search_params_into_session
|
36
35
|
if active_scaffold_config.store_user_settings
|
37
|
-
|
36
|
+
if params[:search].present?
|
37
|
+
active_scaffold_session_storage['search'] = permitted_search_params
|
38
|
+
elsif params.key? :search
|
39
|
+
active_scaffold_session_storage.delete 'search'
|
40
|
+
end
|
38
41
|
else
|
39
42
|
@search_params = permitted_search_params
|
40
43
|
end
|
@@ -6,7 +6,7 @@ module ActiveScaffold::Actions
|
|
6
6
|
before_action :check_input_device
|
7
7
|
before_action :register_constraints_with_action_columns, :unless => :nested?
|
8
8
|
after_action :clear_flashes
|
9
|
-
|
9
|
+
around_action :clear_storage
|
10
10
|
rescue_from ActiveScaffold::RecordNotAllowed, ActiveScaffold::ActionNotAllowed, :with => :deny_access
|
11
11
|
end
|
12
12
|
base.helper_method :active_scaffold_config
|
@@ -72,7 +72,7 @@ module ActiveScaffold::Actions
|
|
72
72
|
else
|
73
73
|
updated_record_with_column(@column, params.delete(:value), @scope)
|
74
74
|
end
|
75
|
-
|
75
|
+
setup_parent(@record) if main_form_controller && @scope
|
76
76
|
after_render_field(@record, @column)
|
77
77
|
end
|
78
78
|
|
@@ -111,7 +111,7 @@ module ActiveScaffold::Actions
|
|
111
111
|
"#{params[:parent_controller].camelize}Controller"
|
112
112
|
end
|
113
113
|
|
114
|
-
def
|
114
|
+
def setup_parent(record)
|
115
115
|
cfg = main_form_controller.active_scaffold_config
|
116
116
|
association = cfg.columns[subform_child_association]&.association&.reverse_association
|
117
117
|
return if association.nil?
|
@@ -129,8 +129,8 @@ module ActiveScaffold::Actions
|
|
129
129
|
end
|
130
130
|
|
131
131
|
if params[:nested] # form in nested scaffold, set nested parent_record to parent
|
132
|
-
nested = ActiveScaffold::DataStructures::NestedInfo.get(parent.class, params
|
133
|
-
if nested.child_association
|
132
|
+
nested = ActiveScaffold::DataStructures::NestedInfo.get(parent.class, params[:nested])
|
133
|
+
if nested&.child_association && !nested.child_association.polymorphic?
|
134
134
|
apply_constraints_to_record(parent, constraints: {nested.child_association.name => nested.parent_id})
|
135
135
|
end
|
136
136
|
end
|
@@ -179,14 +179,12 @@ module ActiveScaffold::Actions
|
|
179
179
|
# ex: accepts? :html, :xml
|
180
180
|
def accepts?(*types)
|
181
181
|
request.accepts.compact.each do |priority|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
return true
|
189
|
-
end
|
182
|
+
# Because IE always sends */* in the accepts header and we assume
|
183
|
+
# that if you really wanted XML or something else you would say so
|
184
|
+
# explicitly, we will assume */* to only ask for :html
|
185
|
+
return types.include?(:html) if priority == Mime::ALL
|
186
|
+
|
187
|
+
return true if types.include?(priority.to_sym)
|
190
188
|
end
|
191
189
|
false
|
192
190
|
end
|
@@ -204,6 +202,18 @@ module ActiveScaffold::Actions
|
|
204
202
|
@response_object ||= successful? ? (@record || @records) : @record.errors
|
205
203
|
end
|
206
204
|
|
205
|
+
def response_to_api(format, columns_names, options = {})
|
206
|
+
render(
|
207
|
+
options.reverse_merge(
|
208
|
+
format => response_object,
|
209
|
+
:only => columns_names + [active_scaffold_config.model.primary_key],
|
210
|
+
:include => association_columns(columns_names),
|
211
|
+
:methods => virtual_columns(columns_names),
|
212
|
+
:status => response_status
|
213
|
+
)
|
214
|
+
)
|
215
|
+
end
|
216
|
+
|
207
217
|
# Success is the existence of one or more model objects. Most actions
|
208
218
|
# circumvent this method by setting @success directly.
|
209
219
|
def successful?
|
@@ -234,18 +244,19 @@ module ActiveScaffold::Actions
|
|
234
244
|
# Builds search conditions by search params for column names. This allows urls like "contacts/list?company_id=5".
|
235
245
|
def conditions_from_params
|
236
246
|
@conditions_from_params ||= begin
|
237
|
-
conditions = {}
|
247
|
+
conditions = [{}]
|
238
248
|
params.except(:controller, :action, :page, :sort, :sort_direction, :format, :id).each do |key, value|
|
239
|
-
|
249
|
+
distinct = true if key =~ /!$/
|
250
|
+
column = active_scaffold_config._columns_hash[key.to_s[0..(distinct ? -2 : -1)]]
|
240
251
|
next unless column
|
241
|
-
key =
|
252
|
+
key = column.name.to_sym
|
242
253
|
not_string = %i[string text].exclude?(column.type)
|
243
254
|
next if active_scaffold_constraints[key]
|
244
255
|
next if nested? && nested.param_name == key
|
245
256
|
|
246
|
-
range = %i[date datetime].include?(column.type) && value.is_a?(String) && value.scan('..').size == 1
|
257
|
+
range = %i[date datetime integer decimal float bigint].include?(column.type) && value.is_a?(String) && value.scan('..').size == 1
|
247
258
|
value = value.split('..') if range
|
248
|
-
|
259
|
+
value =
|
249
260
|
if value.is_a?(Array)
|
250
261
|
value.map { |v| v == '' && not_string ? nil : ActiveScaffold::Core.column_type_cast(v, column) }
|
251
262
|
elsif value == '' && (not_string || column.null)
|
@@ -253,30 +264,36 @@ module ActiveScaffold::Actions
|
|
253
264
|
else
|
254
265
|
ActiveScaffold::Core.column_type_cast(value, column)
|
255
266
|
end
|
256
|
-
|
267
|
+
value = Range.new(*value) if range
|
268
|
+
if distinct
|
269
|
+
conditions << active_scaffold_config.model.arel_table[key].not_eq(value)
|
270
|
+
else
|
271
|
+
conditions[0][key] = value
|
272
|
+
end
|
257
273
|
end
|
258
274
|
conditions
|
259
275
|
end
|
260
276
|
end
|
261
277
|
|
262
278
|
def new_model
|
263
|
-
# ignore nested unrelated to current controller, e.g. adding record in subform inside subform, would create wrong parent_record
|
264
|
-
if nested? && nested.association && nested.association.klass != active_scaffold_config.model
|
265
|
-
return active_scaffold_config.model.new
|
266
|
-
end
|
267
279
|
relation = beginning_of_chain
|
268
|
-
|
269
|
-
column = relation.klass.inheritance_column if config
|
270
|
-
if column && config._columns_hash[column]
|
271
|
-
model_name = params.delete(column) # in new action inheritance_column must be in params
|
272
|
-
model_name ||= params[:record]&.delete(column) # in create action must be inside record key
|
273
|
-
model_name = model_name.camelize if model_name
|
274
|
-
model_name ||= active_scaffold_config.model.name
|
275
|
-
build_options = {column.to_sym => model_name} if model_name
|
276
|
-
end
|
280
|
+
build_options = sti_nested_build_options(relation.klass) if nested? && nested.plural_association?
|
277
281
|
relation.respond_to?(:build) ? relation.build(build_options || {}) : relation.new
|
278
282
|
end
|
279
283
|
|
284
|
+
def sti_nested_build_options(klass)
|
285
|
+
config = active_scaffold_config_for(klass)
|
286
|
+
return unless config
|
287
|
+
column = klass.inheritance_column
|
288
|
+
return unless column && config._columns_hash[column]
|
289
|
+
|
290
|
+
model_name = params.delete(column) # in new action inheritance_column must be in params
|
291
|
+
model_name ||= params[:record]&.delete(column) # in create action must be inside record key
|
292
|
+
model_name = model_name.camelize if model_name
|
293
|
+
model_name ||= active_scaffold_config.model.name
|
294
|
+
{column.to_sym => model_name} if model_name
|
295
|
+
end
|
296
|
+
|
280
297
|
def get_row(crud_type_or_security_options = :read)
|
281
298
|
klass = beginning_of_chain
|
282
299
|
klass = klass.preload(active_scaffold_preload) unless active_scaffold_config.mongoid?
|
@@ -288,6 +305,8 @@ module ActiveScaffold::Actions
|
|
288
305
|
end
|
289
306
|
|
290
307
|
def clear_storage
|
308
|
+
yield if block_given?
|
309
|
+
ensure
|
291
310
|
session_index = active_scaffold_session_storage_key
|
292
311
|
session.delete(session_index) if session[session_index].blank?
|
293
312
|
end
|
@@ -297,14 +316,13 @@ module ActiveScaffold::Actions
|
|
297
316
|
end
|
298
317
|
|
299
318
|
def check_input_device
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
end
|
319
|
+
return unless session[:input_device_type].nil?
|
320
|
+
if request.env['HTTP_USER_AGENT'] =~ /(iPhone|iPod|iPad)/i
|
321
|
+
session[:input_device_type] = 'TOUCH'
|
322
|
+
session[:hover_supported] = false
|
323
|
+
else
|
324
|
+
session[:input_device_type] = 'MOUSE'
|
325
|
+
session[:hover_supported] = true
|
308
326
|
end
|
309
327
|
end
|
310
328
|
|
@@ -367,12 +385,12 @@ module ActiveScaffold::Actions
|
|
367
385
|
render :action => 'action_confirmation', :locals => {:record => @record, :link => link}
|
368
386
|
end
|
369
387
|
|
388
|
+
def action_update_respond_on_iframe
|
389
|
+
responds_to_parent { action_update_respond_to_js }
|
390
|
+
end
|
391
|
+
|
370
392
|
def action_update_respond_to_html
|
371
|
-
|
372
|
-
responds_to_parent { action_update_respond_to_js }
|
373
|
-
else
|
374
|
-
redirect_to :action => 'index'
|
375
|
-
end
|
393
|
+
redirect_to :action => 'index'
|
376
394
|
end
|
377
395
|
|
378
396
|
def action_update_respond_to_js
|
@@ -380,11 +398,11 @@ module ActiveScaffold::Actions
|
|
380
398
|
end
|
381
399
|
|
382
400
|
def action_update_respond_to_xml
|
383
|
-
|
401
|
+
response_to_api(:xml, list_columns_names)
|
384
402
|
end
|
385
403
|
|
386
404
|
def action_update_respond_to_json
|
387
|
-
|
405
|
+
response_to_api(:json, list_columns_names)
|
388
406
|
end
|
389
407
|
|
390
408
|
def objects_for_etag
|
@@ -410,7 +428,9 @@ module ActiveScaffold::Actions
|
|
410
428
|
end
|
411
429
|
|
412
430
|
def virtual_columns(columns)
|
413
|
-
columns.reject
|
431
|
+
columns.reject do |col|
|
432
|
+
active_scaffold_config._columns_hash[col.to_s] || active_scaffold_config.columns[col]&.association
|
433
|
+
end
|
414
434
|
end
|
415
435
|
|
416
436
|
def association_columns(columns)
|
@@ -424,14 +444,22 @@ module ActiveScaffold::Actions
|
|
424
444
|
respond_to do |type|
|
425
445
|
action_formats.each do |format|
|
426
446
|
type.send(format) do
|
427
|
-
|
428
|
-
|
429
|
-
end
|
447
|
+
method_name = respond_method_for(action, format)
|
448
|
+
send(method_name) if method_name
|
430
449
|
end
|
431
450
|
end
|
432
451
|
end
|
433
452
|
end
|
434
453
|
|
454
|
+
def respond_method_for(action, format)
|
455
|
+
if format == :html && params[:iframe] == 'true'
|
456
|
+
method_name = "#{action}_respond_on_iframe"
|
457
|
+
return method_name if respond_to?(method_name, true)
|
458
|
+
end
|
459
|
+
method_name = "#{action}_respond_to_#{format}"
|
460
|
+
method_name if respond_to?(method_name, true)
|
461
|
+
end
|
462
|
+
|
435
463
|
def action_formats
|
436
464
|
@action_formats ||=
|
437
465
|
if respond_to? "#{action_name}_formats", true
|
@@ -32,47 +32,47 @@ module ActiveScaffold::Actions
|
|
32
32
|
render(:partial => 'create_form')
|
33
33
|
end
|
34
34
|
|
35
|
+
def create_respond_on_iframe
|
36
|
+
do_refresh_list if successful? && active_scaffold_config.create.refresh_list && !render_parent?
|
37
|
+
responds_to_parent do
|
38
|
+
render :action => 'on_create', :formats => [:js], :layout => false
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
35
42
|
def create_respond_to_html
|
36
|
-
if
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
if successful?
|
43
|
-
flash[:info] = as_(:created_model, :model => ERB::Util.h(@record.to_label))
|
44
|
-
if (action = active_scaffold_config.create.action_after_create)
|
45
|
-
redirect_to params_for(:action => action, :id => @record.to_param)
|
46
|
-
elsif params[:dont_close]
|
47
|
-
redirect_to params_for(:action => 'new')
|
48
|
-
else
|
49
|
-
return_to_main
|
50
|
-
end
|
43
|
+
if successful?
|
44
|
+
flash[:info] = as_(:created_model, :model => ERB::Util.h(@record.to_label))
|
45
|
+
if (action = active_scaffold_config.create.action_after_create)
|
46
|
+
redirect_to params_for(:action => action, :id => @record.to_param)
|
47
|
+
elsif params[:dont_close]
|
48
|
+
redirect_to params_for(:action => 'new')
|
51
49
|
else
|
52
|
-
|
53
|
-
list
|
54
|
-
else
|
55
|
-
render(:action => 'create')
|
56
|
-
end
|
50
|
+
return_to_main
|
57
51
|
end
|
52
|
+
elsif active_scaffold_config.actions.include?(:list) && active_scaffold_config.list.always_show_create
|
53
|
+
list
|
54
|
+
else
|
55
|
+
render(:action => 'create')
|
58
56
|
end
|
59
57
|
end
|
60
58
|
|
61
59
|
def create_respond_to_js
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
60
|
+
if successful? && !render_parent?
|
61
|
+
do_refresh_list if active_scaffold_config.create.refresh_list
|
62
|
+
if params[:dont_close]
|
63
|
+
@saved_record = @record
|
64
|
+
do_new
|
65
|
+
end
|
66
66
|
end
|
67
67
|
render :action => 'on_create'
|
68
68
|
end
|
69
69
|
|
70
70
|
def create_respond_to_xml
|
71
|
-
|
71
|
+
response_to_api(:xml, create_columns_names, location: response_location)
|
72
72
|
end
|
73
73
|
|
74
74
|
def create_respond_to_json
|
75
|
-
|
75
|
+
response_to_api(:json, create_columns_names, location: response_location)
|
76
76
|
end
|
77
77
|
|
78
78
|
def create_columns_names
|
@@ -136,7 +136,7 @@ module ActiveScaffold::Actions
|
|
136
136
|
private
|
137
137
|
|
138
138
|
def create_authorized_filter
|
139
|
-
link = active_scaffold_config.create.link || active_scaffold_config.create.class.link
|
139
|
+
link = active_scaffold_config.create.link || self.class.active_scaffold_config.create.class.link
|
140
140
|
raise ActiveScaffold::ActionNotAllowed unless send(link.security_method)
|
141
141
|
end
|
142
142
|
|