active_scaffold 3.2.7 → 3.2.8
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +16 -1
- data/app/assets/javascripts/jquery/active_scaffold.js +50 -16
- data/app/assets/javascripts/jquery/jquery.editinplace.js +6 -6
- data/app/assets/javascripts/prototype/active_scaffold.js +39 -15
- data/app/assets/stylesheets/active_scaffold_layout.css +24 -1
- data/frontends/default/views/_base_form.html.erb +9 -10
- data/frontends/default/views/_form.html.erb +8 -7
- data/frontends/default/views/_form_attribute.html.erb +6 -3
- data/frontends/default/views/_form_messages.html.erb +3 -3
- data/frontends/default/views/_horizontal_subform_record.html.erb +1 -1
- data/frontends/default/views/_list_calculations.html.erb +1 -1
- data/frontends/default/views/_list_messages.html.erb +10 -13
- data/frontends/default/views/_list_record_columns.html.erb +2 -2
- data/frontends/default/views/_messages.html.erb +1 -1
- data/frontends/default/views/_refresh_list.js.erb +1 -0
- data/frontends/default/views/_row.html.erb +2 -2
- data/frontends/default/views/_search.html.erb +2 -2
- data/frontends/default/views/_update_calculations.js.erb +4 -0
- data/frontends/default/views/_update_messages.js.erb +2 -0
- data/frontends/default/views/_vertical_subform_record.html.erb +1 -1
- data/frontends/default/views/add_existing.js.erb +2 -6
- data/frontends/default/views/destroy.js.erb +25 -23
- data/frontends/default/views/on_action_update.js.erb +21 -12
- data/frontends/default/views/on_create.js.erb +24 -21
- data/frontends/default/views/on_update.js.erb +19 -18
- data/frontends/default/views/refresh_list.js.erb +2 -1
- data/frontends/default/views/row.js.erb +1 -0
- data/frontends/default/views/update_column.js.erb +14 -15
- data/lib/active_scaffold.rb +1 -1
- data/lib/active_scaffold/actions/core.rb +6 -2
- data/lib/active_scaffold/actions/create.rb +9 -12
- data/lib/active_scaffold/actions/delete.rb +1 -4
- data/lib/active_scaffold/actions/list.rb +15 -12
- data/lib/active_scaffold/actions/mark.rb +1 -2
- data/lib/active_scaffold/actions/nested.rb +2 -1
- data/lib/active_scaffold/actions/update.rb +5 -8
- data/lib/active_scaffold/config/list.rb +18 -0
- data/lib/active_scaffold/constraints.rb +2 -12
- data/lib/active_scaffold/data_structures/column.rb +5 -2
- data/lib/active_scaffold/data_structures/nested_info.rb +6 -5
- data/lib/active_scaffold/finder.rb +11 -7
- data/lib/active_scaffold/helpers/controller_helpers.rb +16 -6
- data/lib/active_scaffold/helpers/form_column_helpers.rb +10 -20
- data/lib/active_scaffold/helpers/id_helpers.rb +2 -2
- data/lib/active_scaffold/helpers/list_column_helpers.rb +15 -20
- data/lib/active_scaffold/helpers/search_column_helpers.rb +15 -27
- data/lib/active_scaffold/helpers/show_column_helpers.rb +9 -20
- data/lib/active_scaffold/helpers/view_helpers.rb +20 -1
- data/lib/active_scaffold/version.rb +1 -1
- metadata +8 -4
@@ -48,8 +48,7 @@ module ActiveScaffold::Actions
|
|
48
48
|
end
|
49
49
|
else
|
50
50
|
if !nested? && active_scaffold_config.actions.include?(:list) && active_scaffold_config.list.always_show_create
|
51
|
-
|
52
|
-
render(:action => 'list')
|
51
|
+
list
|
53
52
|
else
|
54
53
|
render(:action => 'create')
|
55
54
|
end
|
@@ -58,10 +57,7 @@ module ActiveScaffold::Actions
|
|
58
57
|
end
|
59
58
|
|
60
59
|
def create_respond_to_js
|
61
|
-
if successful? && active_scaffold_config.create.refresh_list && !render_parent?
|
62
|
-
do_search if respond_to? :do_search
|
63
|
-
do_list
|
64
|
-
end
|
60
|
+
do_refresh_list if successful? && active_scaffold_config.create.refresh_list && !render_parent?
|
65
61
|
render :action => 'on_create'
|
66
62
|
end
|
67
63
|
|
@@ -84,26 +80,27 @@ module ActiveScaffold::Actions
|
|
84
80
|
apply_constraints_to_record(@record)
|
85
81
|
if nested?
|
86
82
|
create_association_with_parent(@record)
|
87
|
-
register_constraints_with_action_columns
|
83
|
+
register_constraints_with_action_columns
|
88
84
|
end
|
89
85
|
@record
|
90
86
|
end
|
91
87
|
|
92
88
|
# A somewhat complex method to actually create a new record. The complexity is from support for subforms and associated records.
|
93
89
|
# If you want to customize this behavior, consider using the +before_create_save+ and +after_create_save+ callbacks.
|
94
|
-
def do_create
|
90
|
+
def do_create(hash = nil)
|
91
|
+
hash ||= params[:record]
|
95
92
|
begin
|
96
93
|
active_scaffold_config.model.transaction do
|
97
|
-
@record = update_record_from_params(new_model, active_scaffold_config.create.columns,
|
94
|
+
@record = update_record_from_params(new_model, active_scaffold_config.create.columns, hash)
|
98
95
|
apply_constraints_to_record(@record, :allow_autosave => true)
|
99
96
|
if nested?
|
100
97
|
create_association_with_parent(@record)
|
101
|
-
register_constraints_with_action_columns
|
98
|
+
register_constraints_with_action_columns
|
102
99
|
end
|
103
100
|
create_save
|
104
101
|
end
|
105
|
-
rescue ActiveRecord::
|
106
|
-
flash[:error] =
|
102
|
+
rescue ActiveRecord::ActiveRecordError => ex
|
103
|
+
flash[:error] = ex.message
|
107
104
|
self.successful = false
|
108
105
|
end
|
109
106
|
end
|
@@ -23,10 +23,7 @@ module ActiveScaffold::Actions
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def destroy_respond_to_js
|
26
|
-
if successful? && active_scaffold_config.delete.refresh_list && !render_parent?
|
27
|
-
do_search if respond_to? :do_search
|
28
|
-
do_list
|
29
|
-
end
|
26
|
+
do_refresh_list if successful? && active_scaffold_config.delete.refresh_list && !render_parent?
|
30
27
|
render(:action => 'destroy')
|
31
28
|
end
|
32
29
|
|
@@ -16,7 +16,11 @@ module ActiveScaffold::Actions
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def list
|
19
|
-
|
19
|
+
if %w(index list).include? action_name
|
20
|
+
do_list
|
21
|
+
else
|
22
|
+
do_refresh_list
|
23
|
+
end
|
20
24
|
@nested_auto_open = active_scaffold_config.list.nested_auto_open
|
21
25
|
respond_to_action(:list)
|
22
26
|
end
|
@@ -33,7 +37,7 @@ module ActiveScaffold::Actions
|
|
33
37
|
if params[:adapter] || embedded?
|
34
38
|
render(:partial => 'list_with_header')
|
35
39
|
else
|
36
|
-
render :
|
40
|
+
render :partial => 'refresh_list', :formats => [:js]
|
37
41
|
end
|
38
42
|
end
|
39
43
|
def list_respond_to_xml
|
@@ -78,6 +82,11 @@ module ActiveScaffold::Actions
|
|
78
82
|
end
|
79
83
|
@page, @records = page, page.items
|
80
84
|
end
|
85
|
+
|
86
|
+
def do_refresh_list
|
87
|
+
do_search if respond_to? :do_search
|
88
|
+
do_list
|
89
|
+
end
|
81
90
|
|
82
91
|
def each_record_in_page
|
83
92
|
_page = active_scaffold_config.list.user.page
|
@@ -89,13 +98,7 @@ module ActiveScaffold::Actions
|
|
89
98
|
|
90
99
|
def each_record_in_scope
|
91
100
|
do_search if respond_to? :do_search
|
92
|
-
finder_options
|
93
|
-
:conditions => all_conditions,
|
94
|
-
:joins => joins_for_finder}
|
95
|
-
finder_options.merge! custom_finder_options
|
96
|
-
finder_options.merge! :include => (active_scaffold_includes.blank? ? nil : active_scaffold_includes)
|
97
|
-
klass = beginning_of_chain
|
98
|
-
klass.all(finder_options).each {|record| yield record}
|
101
|
+
append_to_query(beginning_of_chain, finder_options).all.each {|record| yield record}
|
99
102
|
end
|
100
103
|
|
101
104
|
# The default security delegates to ActiveRecordPermissions.
|
@@ -117,6 +120,7 @@ module ActiveScaffold::Actions
|
|
117
120
|
@record = find_if_allowed(params[:id], :read) if params[:id] && params[:id] && params[:id].to_i > 0
|
118
121
|
respond_to_action(:action_confirmation)
|
119
122
|
else
|
123
|
+
@action_link = active_scaffold_config.action_links[action_name]
|
120
124
|
if params[:id] && params[:id] && params[:id].to_i > 0
|
121
125
|
crud_type ||= (request.post? || request.put?) ? :update : :delete
|
122
126
|
@record = find_if_allowed(params[:id], crud_type)
|
@@ -139,12 +143,11 @@ module ActiveScaffold::Actions
|
|
139
143
|
end
|
140
144
|
|
141
145
|
def action_update_respond_to_html
|
142
|
-
do_search if respond_to? :do_search
|
143
|
-
do_list
|
144
146
|
redirect_to :action => 'index'
|
145
147
|
end
|
146
148
|
|
147
149
|
def action_update_respond_to_js
|
150
|
+
do_refresh_list unless @record.present?
|
148
151
|
render(:action => 'on_action_update')
|
149
152
|
end
|
150
153
|
|
@@ -171,7 +174,7 @@ module ActiveScaffold::Actions
|
|
171
174
|
alias_method :index_formats, :list_formats
|
172
175
|
|
173
176
|
def row_formats
|
174
|
-
([:html] + active_scaffold_config.formats + active_scaffold_config.list.formats).uniq
|
177
|
+
([:html, :js] + active_scaffold_config.formats + active_scaffold_config.list.formats).uniq
|
175
178
|
end
|
176
179
|
|
177
180
|
def action_update_formats
|
@@ -13,17 +13,16 @@ module ActiveScaffold::Actions
|
|
13
13
|
else
|
14
14
|
do_unmark
|
15
15
|
end
|
16
|
+
do_list
|
16
17
|
respond_to_action(:mark_all)
|
17
18
|
end
|
18
19
|
protected
|
19
20
|
|
20
21
|
def mark_all_respond_to_html
|
21
|
-
do_list
|
22
22
|
list_respond_to_html
|
23
23
|
end
|
24
24
|
|
25
25
|
def mark_all_respond_to_js
|
26
|
-
do_list
|
27
26
|
render :action => 'on_mark_all', :locals => {:mark_all => mark_all?}
|
28
27
|
end
|
29
28
|
|
@@ -27,8 +27,9 @@ module ActiveScaffold::Actions
|
|
27
27
|
if params[:parent_scaffold] && (params[:association] || params[:named_scope])
|
28
28
|
@nested = ActiveScaffold::DataStructures::NestedInfo.get(active_scaffold_config.model, params)
|
29
29
|
unless @nested.nil?
|
30
|
+
active_scaffold_constraints.merge! @nested.constraints
|
30
31
|
active_scaffold_constraints[:id] = params[:id] if @nested.belongs_to?
|
31
|
-
register_constraints_with_action_columns
|
32
|
+
register_constraints_with_action_columns
|
32
33
|
end
|
33
34
|
end
|
34
35
|
end
|
@@ -48,10 +48,7 @@ module ActiveScaffold::Actions
|
|
48
48
|
end
|
49
49
|
def update_respond_to_js
|
50
50
|
if successful?
|
51
|
-
if update_refresh_list? && !render_parent?
|
52
|
-
do_search if respond_to? :do_search
|
53
|
-
do_list
|
54
|
-
end
|
51
|
+
do_refresh_list if update_refresh_list? && !render_parent?
|
55
52
|
flash.now[:info] = as_(:updated_model, :model => @record.to_label) if active_scaffold_config.update.persistent
|
56
53
|
end
|
57
54
|
render :action => 'on_update'
|
@@ -68,7 +65,7 @@ module ActiveScaffold::Actions
|
|
68
65
|
# A simple method to find and prepare a record for editing
|
69
66
|
# May be overridden to customize the record (set default values, etc.)
|
70
67
|
def do_edit
|
71
|
-
register_constraints_with_action_columns(
|
68
|
+
register_constraints_with_action_columns(active_scaffold_config.update.hide_nested_column ? [] : [:update]) if nested?
|
72
69
|
@record = find_if_allowed(params[:id], :update)
|
73
70
|
end
|
74
71
|
|
@@ -94,15 +91,15 @@ module ActiveScaffold::Actions
|
|
94
91
|
raise ActiveRecord::Rollback, "don't save habtm associations unless record is valid"
|
95
92
|
end
|
96
93
|
end
|
97
|
-
rescue ActiveRecord::RecordInvalid
|
98
|
-
flash[:error] = $!.message
|
99
|
-
self.successful = false
|
100
94
|
rescue ActiveRecord::StaleObjectError
|
101
95
|
@record.errors.add(:base, as_(:version_inconsistency))
|
102
96
|
self.successful = false
|
103
97
|
rescue ActiveRecord::RecordNotSaved
|
104
98
|
@record.errors.add(:base, as_(:record_not_saved)) if @record.errors.empty?
|
105
99
|
self.successful = false
|
100
|
+
rescue ActiveRecord::ActiveRecordError => ex
|
101
|
+
flash[:error] = ex.message
|
102
|
+
self.successful = false
|
106
103
|
end
|
107
104
|
end
|
108
105
|
|
@@ -19,7 +19,9 @@ module ActiveScaffold::Config
|
|
19
19
|
@association_join_text = self.class.association_join_text
|
20
20
|
@pagination = self.class.pagination
|
21
21
|
@show_search_reset = true
|
22
|
+
@reset_link = self.class.reset_link.clone
|
22
23
|
@mark_records = self.class.mark_records
|
24
|
+
@wrap_tag = self.class.wrap_tag
|
23
25
|
end
|
24
26
|
|
25
27
|
# global level configuration
|
@@ -61,6 +63,15 @@ module ActiveScaffold::Config
|
|
61
63
|
# Add a checkbox in front of each record to mark them and use them with a batch action later
|
62
64
|
cattr_accessor :mark_records
|
63
65
|
|
66
|
+
# the ActionLink to reset search
|
67
|
+
cattr_accessor :reset_link
|
68
|
+
@@reset_link = ActiveScaffold::DataStructures::ActionLink.new('index', :label => :click_to_reset, :type => :collection, :position => false)
|
69
|
+
|
70
|
+
# wrap normal cells (not inplace editable columns or with link) with a tag
|
71
|
+
# it allows for more css styling
|
72
|
+
cattr_accessor :wrap_tag
|
73
|
+
@@wrap_tag = nil
|
74
|
+
|
64
75
|
# instance-level configuration
|
65
76
|
# ----------------------------
|
66
77
|
|
@@ -101,6 +112,9 @@ module ActiveScaffold::Config
|
|
101
112
|
# show a link to reset the search next to filtered message
|
102
113
|
attr_accessor :show_search_reset
|
103
114
|
|
115
|
+
# the ActionLink to reset search
|
116
|
+
attr_reader :reset_link
|
117
|
+
|
104
118
|
# Add a checkbox in front of each record to mark them and use them with a batch action later
|
105
119
|
attr_accessor :mark_records
|
106
120
|
|
@@ -161,6 +175,10 @@ module ActiveScaffold::Config
|
|
161
175
|
# will open nested players view if there are 2 or less records in parent
|
162
176
|
attr_accessor :nested_auto_open
|
163
177
|
|
178
|
+
# wrap normal cells (not inplace editable columns or with link) with a tag
|
179
|
+
# it allows for more css styling
|
180
|
+
attr_accessor :wrap_tag
|
181
|
+
|
164
182
|
class UserSettings < UserSettings
|
165
183
|
def initialize(conf, storage, params)
|
166
184
|
super(conf,storage,params)
|
@@ -8,23 +8,13 @@ module ActiveScaffold
|
|
8
8
|
@active_scaffold_constraints ||= active_scaffold_session_storage[:constraints] || {}
|
9
9
|
end
|
10
10
|
|
11
|
-
def set_active_scaffold_constraints
|
12
|
-
associations_by_params = {}
|
13
|
-
active_scaffold_config.model.reflect_on_all_associations.each do |association|
|
14
|
-
associations_by_params[association.klass.name.foreign_key] = association.name unless association.options[:polymorphic]
|
15
|
-
end
|
16
|
-
params.each do |key, value|
|
17
|
-
active_scaffold_constraints[associations_by_params[key]] = value if associations_by_params.include? key
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
11
|
# For each enabled action, adds the constrained columns to the ActionColumns object (if it exists).
|
22
12
|
# This lets the ActionColumns object skip constrained columns.
|
23
13
|
#
|
24
14
|
# If the constraint value is a Hash, then we assume the constraint is a multi-level association constraint (the reverse of a has_many :through) and we do NOT register the constraint column.
|
25
|
-
def register_constraints_with_action_columns(
|
15
|
+
def register_constraints_with_action_columns(exclude_actions = [])
|
26
16
|
constrained_fields = active_scaffold_constraints.reject{|k, v| v.is_a? Hash}.keys.collect{|k| k.to_sym}
|
27
|
-
|
17
|
+
exclude_actions << :list unless active_scaffold_config.list.hide_nested_column
|
28
18
|
if self.class.uses_active_scaffold?
|
29
19
|
# we actually want to do this whether constrained_fields exist or not, so that we can reset the array when they don't
|
30
20
|
active_scaffold_config.actions.each do |action_name|
|
@@ -67,7 +67,10 @@ module ActiveScaffold::DataStructures
|
|
67
67
|
attr_accessor :send_form_on_update_column
|
68
68
|
|
69
69
|
# column to be updated in a form when this column changes
|
70
|
-
|
70
|
+
def update_column=(column_name)
|
71
|
+
ActiveSupport::Deprecation.warn "Use update_columns= instead of update_column="
|
72
|
+
self.update_columns = column_name
|
73
|
+
end
|
71
74
|
|
72
75
|
# send all the form instead of only new value when this column change
|
73
76
|
cattr_accessor :send_form_on_update_column
|
@@ -165,7 +168,7 @@ module ActiveScaffold::DataStructures
|
|
165
168
|
attr_reader :includes
|
166
169
|
def includes=(value)
|
167
170
|
@includes = case value
|
168
|
-
when Array
|
171
|
+
when Array then value
|
169
172
|
else [value] # automatically convert to an array
|
170
173
|
end
|
171
174
|
end
|
@@ -19,7 +19,7 @@ module ActiveScaffold::DataStructures
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
attr_accessor :association, :child_association, :parent_model, :parent_scaffold, :parent_id, :constrained_fields, :scope
|
22
|
+
attr_accessor :association, :child_association, :parent_model, :parent_scaffold, :parent_id, :constrained_fields, :constraints, :scope
|
23
23
|
|
24
24
|
def initialize(model, nested_info)
|
25
25
|
@parent_model = nested_info[:parent_model]
|
@@ -108,16 +108,16 @@ module ActiveScaffold::DataStructures
|
|
108
108
|
protected
|
109
109
|
|
110
110
|
def iterate_model_associations(model)
|
111
|
-
@
|
112
|
-
@
|
111
|
+
@constraints = {}
|
112
|
+
@constraints[association.foreign_key.to_sym] = parent_id unless association.belongs_to?
|
113
113
|
model.reflect_on_all_associations.each do |current|
|
114
114
|
if !current.belongs_to? && association.foreign_key == current.association_foreign_key
|
115
|
-
|
115
|
+
constraints[current.name.to_sym] = parent_id
|
116
116
|
@child_association = current if current.klass == @parent_model
|
117
117
|
end
|
118
118
|
if association.foreign_key == current.foreign_key
|
119
119
|
# show columns for has_many and has_one child associationes
|
120
|
-
|
120
|
+
constraints[current.name.to_sym] = parent_id if current.belongs_to?
|
121
121
|
if association.options[:as] and current.options[:polymorphic]
|
122
122
|
@child_association = current if association.options[:as].to_sym == current.name
|
123
123
|
else
|
@@ -125,6 +125,7 @@ module ActiveScaffold::DataStructures
|
|
125
125
|
end
|
126
126
|
end
|
127
127
|
end
|
128
|
+
@constrained_fields = @constraints.keys
|
128
129
|
end
|
129
130
|
end
|
130
131
|
|
@@ -121,11 +121,17 @@ module ActiveScaffold
|
|
121
121
|
Date.strptime(value, I18n.t('date.formats.default')) rescue nil
|
122
122
|
else
|
123
123
|
parts = Date._parse(value)
|
124
|
-
|
125
|
-
|
124
|
+
format = I18n.translate 'time.formats.picker', :default => '' if ActiveScaffold.js_framework == :jquery
|
125
|
+
if format.blank?
|
126
|
+
time_parts = [[:hour, '%H'], [:min, '%M'], [:sec, '%S']].collect {|part, format_part| format_part if parts[part].present?}.compact
|
127
|
+
format = "#{I18n.t('date.formats.default')} #{time_parts.join(':')} #{'%z' if parts[:offset].present?}"
|
128
|
+
else
|
129
|
+
format += ' %z' if parts[:offset].present? && format !~ /%z/i
|
130
|
+
end
|
126
131
|
time = DateTime.strptime(value, format)
|
127
|
-
time = Time.zone.local_to_utc(time) unless parts[:offset]
|
128
|
-
time.
|
132
|
+
time = Time.zone.local_to_utc(time).in_time_zone unless parts[:offset]
|
133
|
+
time = time.send(conversion) unless conversion == :to_time
|
134
|
+
time
|
129
135
|
end unless value.nil? || value.blank?
|
130
136
|
end
|
131
137
|
|
@@ -265,8 +271,6 @@ module ActiveScaffold
|
|
265
271
|
# * :per_page
|
266
272
|
# * :page
|
267
273
|
def finder_options(options = {})
|
268
|
-
options.assert_valid_keys :sorting, :per_page, :page, :count_includes, :pagination, :select
|
269
|
-
|
270
274
|
search_conditions = all_conditions
|
271
275
|
full_includes = (active_scaffold_includes.blank? ? nil : active_scaffold_includes)
|
272
276
|
|
@@ -291,8 +295,8 @@ module ActiveScaffold
|
|
291
295
|
|
292
296
|
# returns a Paginator::Page (not from ActiveRecord::Paginator) for the given parameters
|
293
297
|
# See finder_options for valid options
|
294
|
-
# TODO: this should reside on the model, not the controller
|
295
298
|
def find_page(options = {})
|
299
|
+
options.assert_valid_keys :sorting, :per_page, :page, :count_includes, :pagination
|
296
300
|
options[:per_page] ||= 999999999
|
297
301
|
options[:page] ||= 1
|
298
302
|
|
@@ -59,7 +59,7 @@ module ActiveScaffold
|
|
59
59
|
if nested_singular_association?
|
60
60
|
{:controller => nested.parent_scaffold.controller_path, :action => :row, :id => nested.parent_id}
|
61
61
|
elsif params[:parent_sti]
|
62
|
-
options = {:controller => params[:parent_sti], :action => render_parent_action
|
62
|
+
options = {:controller => params[:parent_sti], :action => render_parent_action}
|
63
63
|
if render_parent_action(params[:parent_sti]) == :index
|
64
64
|
options.merge(params.slice(:eid))
|
65
65
|
else
|
@@ -68,17 +68,27 @@ module ActiveScaffold
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
def render_parent_action
|
71
|
+
def render_parent_action
|
72
72
|
begin
|
73
73
|
@parent_action = :row
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
74
|
+
if params[:parent_sti]
|
75
|
+
parent_controller = "#{params[:parent_sti].to_s.camelize}Controller".constantize
|
76
|
+
@parent_action = :index if action_name == 'create' && parent_controller.active_scaffold_config.actions.include?(:create) && parent_controller.active_scaffold_config.create.refresh_list == true
|
77
|
+
@parent_action = :index if action_name == 'update' && parent_controller.active_scaffold_config.actions.include?(:update) && parent_controller.active_scaffold_config.update.refresh_list == true
|
78
|
+
@parent_action = :index if action_name == 'destroy' && parent_controller.active_scaffold_config.actions.include?(:delete) && parent_controller.active_scaffold_config.delete.refresh_list == true
|
79
|
+
end
|
78
80
|
rescue ActiveScaffold::ControllerNotFound
|
79
81
|
end if @parent_action.nil?
|
80
82
|
@parent_action
|
81
83
|
end
|
84
|
+
|
85
|
+
def render_parent_controller
|
86
|
+
if nested_singular_association?
|
87
|
+
nested.parent_scaffold.controller_path
|
88
|
+
else
|
89
|
+
params[:parent_sti]
|
90
|
+
end
|
91
|
+
end
|
82
92
|
|
83
93
|
def build_associated(column, record)
|
84
94
|
if column.singular_association?
|
@@ -15,11 +15,11 @@ module ActiveScaffold
|
|
15
15
|
def active_scaffold_render_input(column, options)
|
16
16
|
begin
|
17
17
|
# first, check if the dev has created an override for this specific field
|
18
|
-
if override_form_field
|
19
|
-
send(
|
18
|
+
if (method = override_form_field(column))
|
19
|
+
send(method, @record, options)
|
20
20
|
# second, check if the dev has specified a valid form_ui for this column
|
21
|
-
elsif column.form_ui and override_input
|
22
|
-
send(
|
21
|
+
elsif column.form_ui and (method = override_input(column.form_ui))
|
22
|
+
send(method, column, options)
|
23
23
|
# fallback: we get to make the decision
|
24
24
|
else
|
25
25
|
if column.association
|
@@ -36,8 +36,8 @@ module ActiveScaffold
|
|
36
36
|
|
37
37
|
else # regular model attribute column
|
38
38
|
# if we (or someone else) have created a custom render option for the column type, use that
|
39
|
-
if override_input
|
40
|
-
send(
|
39
|
+
if (method = override_input(column.column.type))
|
40
|
+
send(method, column, options)
|
41
41
|
# final ultimate fallback: use rails' generic input method
|
42
42
|
else
|
43
43
|
# for textual fields we pass different options
|
@@ -229,26 +229,16 @@ module ActiveScaffold
|
|
229
229
|
end
|
230
230
|
|
231
231
|
def override_form_field(column)
|
232
|
-
|
233
|
-
return method_with_class if respond_to?(method_with_class)
|
234
|
-
method = override_form_field_name(column)
|
235
|
-
method if respond_to?(method)
|
232
|
+
override_helper column, 'form_column'
|
236
233
|
end
|
237
234
|
alias_method :override_form_field?, :override_form_field
|
238
235
|
|
239
|
-
# the naming convention for overriding form fields with helpers
|
240
|
-
def override_form_field_name(column, class_prefix = false)
|
241
|
-
"#{clean_class_name(column.active_record_class.name) + '_' if class_prefix}#{clean_column_name(column.name)}_form_column"
|
242
|
-
end
|
243
|
-
|
244
|
-
def override_input?(form_ui)
|
245
|
-
respond_to?(override_input(form_ui))
|
246
|
-
end
|
247
|
-
|
248
236
|
# the naming convention for overriding form input types with helpers
|
249
237
|
def override_input(form_ui)
|
250
|
-
"active_scaffold_input_#{form_ui}"
|
238
|
+
method = "active_scaffold_input_#{form_ui}"
|
239
|
+
method if respond_to? method
|
251
240
|
end
|
241
|
+
alias_method :override_input?, :override_input
|
252
242
|
|
253
243
|
def form_partial_for_column(column, renders_as = nil)
|
254
244
|
renders_as ||= column_renders_as(column)
|