active_scaffold 3.0.12 → 3.0.21
Sign up to get free protection for your applications and to get access to all the features.
- data/README +21 -11
- data/frontends/default/images/close_touch.png +0 -0
- data/frontends/default/javascripts/jquery/active_scaffold.js +187 -99
- data/frontends/default/javascripts/prototype/active_scaffold.js +105 -33
- data/frontends/default/javascripts/prototype/dhtml_history.js +80 -77
- data/frontends/default/stylesheets/stylesheet.css +121 -2
- data/frontends/default/views/_action_group.html.erb +6 -2
- data/frontends/default/views/_base_form.html.erb +11 -5
- data/frontends/default/views/_base_form.html.erb~ +42 -0
- data/frontends/default/views/_field_search.html.erb +1 -1
- data/frontends/default/views/_form.html.erb +9 -7
- data/frontends/default/views/_form_association.html.erb +8 -3
- data/frontends/default/views/_form_association_footer.html.erb +10 -3
- data/frontends/default/views/_form_attribute.html.erb +8 -3
- data/frontends/default/views/_horizontal_subform.html.erb +12 -2
- data/frontends/default/views/_horizontal_subform_header.html.erb +1 -1
- data/frontends/default/views/_horizontal_subform_record.html.erb +5 -4
- data/frontends/default/views/_list_messages.html.erb +1 -1
- data/frontends/default/views/_list_with_header.html.erb +1 -1
- data/frontends/default/views/_render_field.js.rjs +4 -6
- data/frontends/default/views/_vertical_subform.html.erb +1 -1
- data/frontends/default/views/_vertical_subform_record.html.erb +2 -2
- data/frontends/default/views/on_action_update.js.rjs +3 -1
- data/frontends/default/views/on_mark_all.js.rjs +12 -0
- data/frontends/default/views/on_update.js.rjs +1 -1
- data/frontends/default/views/render_field.js.rjs +1 -0
- data/frontends/default/views/update_column.js.rjs +1 -1
- data/lib/active_scaffold.rb +60 -21
- data/lib/active_scaffold/actions/common_search.rb +2 -2
- data/lib/active_scaffold/actions/core.rb +30 -9
- data/lib/active_scaffold/actions/create.rb +14 -10
- data/lib/active_scaffold/actions/field_search.rb +6 -6
- data/lib/active_scaffold/actions/list.rb +22 -12
- data/lib/active_scaffold/actions/mark.rb +34 -9
- data/lib/active_scaffold/actions/nested.rb +12 -16
- data/lib/active_scaffold/actions/show.rb +2 -2
- data/lib/active_scaffold/actions/subform.rb +15 -8
- data/lib/active_scaffold/actions/update.rb +14 -4
- data/lib/active_scaffold/attribute_params.rb +15 -10
- data/lib/active_scaffold/bridges/bridge.rb +21 -12
- data/lib/active_scaffold/bridges/calendar_date_select/bridge.rb +3 -3
- data/lib/active_scaffold/bridges/cancan/bridge.rb +12 -0
- data/lib/active_scaffold/bridges/cancan/lib/cancan_bridge.rb +107 -0
- data/lib/active_scaffold/bridges/carrierwave/bridge.rb +1 -1
- data/lib/active_scaffold/bridges/carrierwave/lib/carrierwave_bridge.rb +3 -8
- data/lib/active_scaffold/bridges/carrierwave/lib/carrierwave_bridge_helpers.rb +1 -15
- data/lib/active_scaffold/bridges/carrierwave/lib/form_ui.rb +23 -13
- data/lib/active_scaffold/bridges/carrierwave/lib/list_ui.rb +1 -1
- data/lib/active_scaffold/bridges/country_helper/bridge.rb +9 -0
- data/lib/active_scaffold/bridges/country_helper/lib/country_helper_bridge.rb +358 -0
- data/lib/active_scaffold/bridges/date_picker/bridge.rb +5 -3
- data/lib/active_scaffold/bridges/date_picker/lib/datepicker_bridge.rb +9 -0
- data/lib/active_scaffold/bridges/dragonfly/bridge.rb +9 -0
- data/lib/active_scaffold/bridges/dragonfly/bridge.rb~ +12 -0
- data/lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge.rb +36 -0
- data/lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge.rb~ +36 -0
- data/lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge_helpers.rb +12 -0
- data/lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge_helpers.rb~ +12 -0
- data/lib/active_scaffold/bridges/dragonfly/lib/form_ui.rb +27 -0
- data/lib/active_scaffold/bridges/dragonfly/lib/form_ui.rb~ +27 -0
- data/lib/active_scaffold/bridges/dragonfly/lib/list_ui.rb +16 -0
- data/lib/active_scaffold/bridges/dragonfly/lib/list_ui.rb~ +16 -0
- data/lib/active_scaffold/bridges/paperclip/bridge.rb +1 -1
- data/lib/active_scaffold/bridges/record_select/bridge.rb +5 -0
- data/lib/active_scaffold/bridges/record_select/lib/record_select_bridge.rb +87 -0
- data/lib/active_scaffold/bridges/record_select/lib/record_select_bridge.rb~ +84 -0
- data/lib/active_scaffold/bridges/shared/date_bridge.rb +56 -34
- data/lib/active_scaffold/bridges/tiny_mce/lib/tiny_mce_bridge.rb +19 -3
- data/lib/active_scaffold/config/base.rb +4 -4
- data/lib/active_scaffold/config/core.rb +4 -0
- data/lib/active_scaffold/config/create.rb +1 -1
- data/lib/active_scaffold/config/field_search.rb +7 -7
- data/lib/active_scaffold/config/form.rb +8 -2
- data/lib/active_scaffold/config/list.rb +22 -8
- data/lib/active_scaffold/config/mark.rb +18 -5
- data/lib/active_scaffold/config/nested.rb +3 -3
- data/lib/active_scaffold/config/search.rb +1 -1
- data/lib/active_scaffold/config/show.rb +1 -1
- data/lib/active_scaffold/data_structures/action_columns.rb +10 -6
- data/lib/active_scaffold/data_structures/action_link.rb +14 -10
- data/lib/active_scaffold/data_structures/action_links.rb +2 -2
- data/lib/active_scaffold/data_structures/column.rb +25 -11
- data/lib/active_scaffold/data_structures/nested_info.rb +21 -21
- data/lib/active_scaffold/data_structures/set.rb +2 -3
- data/lib/active_scaffold/data_structures/sorting.rb +8 -8
- data/lib/{extensions → active_scaffold/extensions}/action_controller_rendering.rb +3 -1
- data/lib/{extensions → active_scaffold/extensions}/action_view_rendering.rb +31 -33
- data/lib/{extensions → active_scaffold/extensions}/action_view_resolver.rb +0 -0
- data/lib/{extensions → active_scaffold/extensions}/active_association_reflection.rb +0 -0
- data/lib/active_scaffold/extensions/active_record_offset.rb +12 -0
- data/lib/{extensions → active_scaffold/extensions}/array.rb +0 -0
- data/lib/{extensions → active_scaffold/extensions}/localize.rb +1 -1
- data/lib/{extensions → active_scaffold/extensions}/name_option_for_datetime.rb +1 -1
- data/lib/{extensions → active_scaffold/extensions}/nil_id_in_url_params.rb +0 -0
- data/lib/{extensions → active_scaffold/extensions}/paginator_extensions.rb +2 -2
- data/lib/{extensions → active_scaffold/extensions}/reverse_associations.rb +1 -1
- data/lib/{extensions → active_scaffold/extensions}/routing_mapper.rb +2 -2
- data/lib/{extensions → active_scaffold/extensions}/to_label.rb +0 -0
- data/lib/{extensions → active_scaffold/extensions}/unsaved_associated.rb +0 -0
- data/lib/{extensions → active_scaffold/extensions}/unsaved_record.rb +0 -0
- data/lib/active_scaffold/extensions/usa_state.rb +46 -0
- data/lib/active_scaffold/finder.rb +30 -19
- data/lib/active_scaffold/helpers/controller_helpers.rb +3 -5
- data/lib/active_scaffold/helpers/form_column_helpers.rb +19 -45
- data/lib/active_scaffold/helpers/human_condition_helpers.rb +1 -1
- data/lib/active_scaffold/helpers/id_helpers.rb +2 -2
- data/lib/active_scaffold/helpers/list_column_helpers.rb +28 -17
- data/lib/active_scaffold/helpers/search_column_helpers.rb +51 -40
- data/lib/active_scaffold/helpers/search_column_helpers.rb~ +215 -0
- data/lib/active_scaffold/helpers/show_column_helpers.rb +8 -4
- data/lib/active_scaffold/helpers/view_helpers.rb +50 -27
- data/lib/active_scaffold/locale/de.yml +111 -0
- data/lib/active_scaffold/locale/en.yml +115 -0
- data/lib/active_scaffold/locale/es.yml +32 -32
- data/lib/active_scaffold/locale/fr.yml +118 -0
- data/lib/active_scaffold/marked_model.rb +6 -6
- data/lib/active_scaffold/version.rb +1 -1
- data/lib/active_scaffold_assets.rb +1 -3
- data/lib/active_scaffold_env.rb +1 -2
- data/lib/generators/active_scaffold/active_scaffold_generator.rb +5 -5
- data/lib/generators/active_scaffold_controller/active_scaffold_controller_generator.rb +3 -2
- data/lib/generators/active_scaffold_controller/templates/helper.rb +2 -0
- data/lib/generators/active_scaffold_setup/active_scaffold_setup_generator.rb +17 -19
- data/shoulda_macros/macros.rb +4 -4
- data/test/misc/finder_test.rb +2 -2
- data/test/mock_app/public/stylesheets/active_scaffold/default/stylesheet.css +4 -1
- metadata +144 -126
- data/.autotest +0 -27
- data/.document +0 -5
- data/Gemfile +0 -13
- data/Gemfile.lock +0 -20
- data/Rakefile +0 -53
- data/active_scaffold.gemspec +0 -385
- data/init.rb +0 -2
- data/lib/active_scaffold/helpers/country_helpers.rb +0 -358
- data/lib/active_scaffold/locale/de.rb +0 -120
- data/lib/active_scaffold/locale/en.rb +0 -119
- data/lib/active_scaffold/locale/fr.rb +0 -116
- data/lib/extensions/active_record_offset.rb +0 -12
- data/lib/extensions/usa_state.rb +0 -50
- data/test/mock_app/.gitignore +0 -2
- data/uninstall.rb +0 -13
@@ -4,7 +4,7 @@ module ActiveScaffold::Actions
|
|
4
4
|
def store_search_params_into_session
|
5
5
|
active_scaffold_session_storage[:search] = params.delete :search if params[:search]
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
def search_params
|
9
9
|
active_scaffold_session_storage[:search]
|
10
10
|
end
|
@@ -12,7 +12,7 @@ module ActiveScaffold::Actions
|
|
12
12
|
def search_ignore?
|
13
13
|
active_scaffold_config.list.always_show_search
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
# The default security delegates to ActiveRecordPermissions.
|
17
17
|
# You may override the method to customize.
|
18
18
|
def search_authorized?
|
@@ -6,6 +6,7 @@ module ActiveScaffold::Actions
|
|
6
6
|
end
|
7
7
|
base.helper_method :nested?
|
8
8
|
base.helper_method :beginning_of_chain
|
9
|
+
base.helper_method :new_model
|
9
10
|
end
|
10
11
|
def render_field
|
11
12
|
if params[:in_place_editing]
|
@@ -14,7 +15,7 @@ module ActiveScaffold::Actions
|
|
14
15
|
render_field_for_update_columns
|
15
16
|
end
|
16
17
|
end
|
17
|
-
|
18
|
+
|
18
19
|
protected
|
19
20
|
|
20
21
|
def nested?
|
@@ -31,10 +32,22 @@ module ActiveScaffold::Actions
|
|
31
32
|
@record = new_model
|
32
33
|
column = active_scaffold_config.columns[params[:column]]
|
33
34
|
unless column.nil?
|
34
|
-
|
35
|
-
|
35
|
+
if column.send_form_on_update_column
|
36
|
+
hash = if params[:scope]
|
37
|
+
hash = params[:scope].gsub('[','').split(']').inject(params[:record]) do |hash, index|
|
38
|
+
hash[index]
|
39
|
+
end
|
40
|
+
else
|
41
|
+
params[:record]
|
42
|
+
end
|
43
|
+
@record = update_record_from_params(@record, active_scaffold_config.update.columns, hash)
|
44
|
+
else
|
45
|
+
value = column_value_from_param_value(@record, column, params[:value])
|
46
|
+
@record.send "#{column.name}=", value
|
47
|
+
end
|
36
48
|
after_render_field(@record, column)
|
37
|
-
|
49
|
+
source_id = params.delete(:source_id)
|
50
|
+
render :locals => {:source_id => source_id, :columns => column.update_columns, :scope => params[:scope]}
|
38
51
|
end
|
39
52
|
end
|
40
53
|
|
@@ -107,21 +120,21 @@ module ActiveScaffold::Actions
|
|
107
120
|
# Override this method on your controller to define conditions to be used when querying a recordset (e.g. for List). The return of this method should be any format compatible with the :conditions clause of ActiveRecord::Base's find.
|
108
121
|
def conditions_for_collection
|
109
122
|
end
|
110
|
-
|
123
|
+
|
111
124
|
# Override this method on your controller to define joins to be used when querying a recordset (e.g. for List). The return of this method should be any format compatible with the :joins clause of ActiveRecord::Base's find.
|
112
125
|
def joins_for_collection
|
113
126
|
end
|
114
|
-
|
127
|
+
|
115
128
|
# Override this method on your controller to provide custom finder options to the find() call. The return of this method should be a hash.
|
116
129
|
def custom_finder_options
|
117
130
|
{}
|
118
131
|
end
|
119
|
-
|
132
|
+
|
120
133
|
#Overide this method on your controller to provide model with named scopes
|
121
134
|
def beginning_of_chain
|
122
135
|
active_scaffold_config.model
|
123
136
|
end
|
124
|
-
|
137
|
+
|
125
138
|
# Builds search conditions by search params for column names. This allows urls like "contacts/list?company_id=5".
|
126
139
|
def conditions_from_params
|
127
140
|
conditions = nil
|
@@ -150,12 +163,20 @@ module ActiveScaffold::Actions
|
|
150
163
|
private
|
151
164
|
def respond_to_action(action)
|
152
165
|
respond_to do |type|
|
153
|
-
|
166
|
+
action_formats.each do |format|
|
154
167
|
type.send(format){ send("#{action}_respond_to_#{format}") }
|
155
168
|
end
|
156
169
|
end
|
157
170
|
end
|
158
171
|
|
172
|
+
def action_formats
|
173
|
+
@action_formats ||= if respond_to? "#{action_name}_formats", true
|
174
|
+
send("#{action_name}_formats")
|
175
|
+
else
|
176
|
+
(default_formats + active_scaffold_config.formats).uniq
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
159
180
|
def response_code_for_rescue(exception)
|
160
181
|
case exception
|
161
182
|
when ActiveScaffold::RecordNotAllowed
|
@@ -29,7 +29,7 @@ module ActiveScaffold::Actions
|
|
29
29
|
return_to_main
|
30
30
|
end
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
def new_respond_to_js
|
34
34
|
render(:partial => 'create_form')
|
35
35
|
end
|
@@ -100,20 +100,24 @@ module ActiveScaffold::Actions
|
|
100
100
|
@record = update_record_from_params(new_model, active_scaffold_config.create.columns, params[:record])
|
101
101
|
apply_constraints_to_record(@record, :allow_autosave => true)
|
102
102
|
if nested?
|
103
|
-
create_association_with_parent(@record)
|
103
|
+
create_association_with_parent(@record)
|
104
104
|
register_constraints_with_action_columns(nested.constrained_fields)
|
105
105
|
end
|
106
|
-
|
107
|
-
self.successful = [@record.valid?, @record.associated_valid?].all? {|v| v == true} # this syntax avoids a short-circuit
|
108
|
-
if successful?
|
109
|
-
@record.save! and @record.save_associated!
|
110
|
-
after_create_save(@record)
|
111
|
-
end
|
106
|
+
create_save
|
112
107
|
end
|
113
108
|
rescue ActiveRecord::RecordInvalid
|
114
109
|
end
|
115
110
|
end
|
116
111
|
|
112
|
+
def create_save
|
113
|
+
before_create_save(@record)
|
114
|
+
self.successful = [@record.valid?, @record.associated_valid?].all? {|v| v == true} # this syntax avoids a short-circuit
|
115
|
+
if successful?
|
116
|
+
@record.save! and @record.save_associated!
|
117
|
+
after_create_save(@record)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
117
121
|
# override this method if you want to inject data in the record (or its associated objects) before the save
|
118
122
|
def before_create_save(record); end
|
119
123
|
|
@@ -122,11 +126,11 @@ module ActiveScaffold::Actions
|
|
122
126
|
|
123
127
|
# The default security delegates to ActiveRecordPermissions.
|
124
128
|
# You may override the method to customize.
|
125
|
-
|
129
|
+
|
126
130
|
def create_ignore?
|
127
131
|
nested? && active_scaffold_config.list.always_show_create
|
128
132
|
end
|
129
|
-
|
133
|
+
|
130
134
|
def create_authorized?
|
131
135
|
(!nested? || !nested.readonly?) && authorized_for?(:crud_type => :create)
|
132
136
|
end
|
@@ -11,24 +11,24 @@ module ActiveScaffold::Actions
|
|
11
11
|
# FieldSearch uses params[:search] and not @record because search conditions do not always pass the Model's validations.
|
12
12
|
# This facilitates for example, textual searches against associations via .search_sql
|
13
13
|
def show_search
|
14
|
-
@record =
|
14
|
+
@record = new_model
|
15
15
|
respond_to_action(:field_search)
|
16
16
|
end
|
17
17
|
|
18
18
|
protected
|
19
|
-
|
19
|
+
|
20
20
|
def store_search_params_into_session
|
21
21
|
set_field_search_default_params(active_scaffold_config.field_search.default_params) unless active_scaffold_config.field_search.default_params.nil?
|
22
22
|
super
|
23
23
|
active_scaffold_session_storage[:search] = nil if search_params.is_a?(String)
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
def set_field_search_default_params(default_params)
|
27
27
|
if (params[:search].nil? && search_params.nil?) || (params[:search].is_a?(String) && params[:search].blank?)
|
28
28
|
params[:search] = default_params.is_a?(Proc) ? self.instance_eval(&default_params) : default_params
|
29
29
|
end
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
def field_search_params
|
33
33
|
search_params || {}
|
34
34
|
end
|
@@ -36,7 +36,7 @@ module ActiveScaffold::Actions
|
|
36
36
|
def field_search_respond_to_html
|
37
37
|
render(:action => "field_search")
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
def field_search_respond_to_js
|
41
41
|
render(:partial => "field_search")
|
42
42
|
end
|
@@ -70,7 +70,7 @@ module ActiveScaffold::Actions
|
|
70
70
|
end
|
71
71
|
|
72
72
|
private
|
73
|
-
|
73
|
+
|
74
74
|
def search_authorized_filter
|
75
75
|
link = active_scaffold_config.field_search.link || active_scaffold_config.field_search.class.link
|
76
76
|
raise ActiveScaffold::ActionNotAllowed unless self.send(link.security_method)
|
@@ -18,11 +18,11 @@ module ActiveScaffold::Actions
|
|
18
18
|
def list
|
19
19
|
do_list
|
20
20
|
do_new if active_scaffold_config.list.always_show_create
|
21
|
-
@record ||=
|
21
|
+
@record ||= new_model if active_scaffold_config.list.always_show_search
|
22
22
|
@nested_auto_open = active_scaffold_config.list.nested_auto_open
|
23
23
|
respond_to_action(:list)
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
protected
|
27
27
|
def list_respond_to_html
|
28
28
|
if params.delete(:embedded)
|
@@ -65,14 +65,14 @@ module ActiveScaffold::Actions
|
|
65
65
|
self.active_scaffold_includes.concat includes_for_list_columns
|
66
66
|
|
67
67
|
options = { :sorting => active_scaffold_config.list.user.sorting,
|
68
|
-
|
68
|
+
:count_includes => active_scaffold_config.list.user.count_includes }
|
69
69
|
paginate = (params[:format].nil?) ? (accepts? :html, :js) : ['html', 'js'].include?(params[:format])
|
70
70
|
if paginate
|
71
71
|
options.merge!({
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
:per_page => active_scaffold_config.list.user.per_page,
|
73
|
+
:page => active_scaffold_config.list.user.page,
|
74
|
+
:pagination => active_scaffold_config.list.pagination
|
75
|
+
})
|
76
76
|
end
|
77
77
|
|
78
78
|
page = find_page(options);
|
@@ -83,11 +83,19 @@ module ActiveScaffold::Actions
|
|
83
83
|
@page, @records = page, page.items
|
84
84
|
end
|
85
85
|
|
86
|
+
def each_record_in_page
|
87
|
+
_page = active_scaffold_config.list.user.page
|
88
|
+
do_search if respond_to? :do_search
|
89
|
+
active_scaffold_config.list.user.page = _page
|
90
|
+
do_list
|
91
|
+
@page.items.each {|record| yield record}
|
92
|
+
end
|
93
|
+
|
86
94
|
def each_record_in_scope
|
87
95
|
do_search if respond_to? :do_search
|
88
96
|
finder_options = { :order => "#{active_scaffold_config.model.connection.quote_table_name(active_scaffold_config.model.table_name)}.#{active_scaffold_config.model.primary_key} ASC",
|
89
|
-
|
90
|
-
|
97
|
+
:conditions => all_conditions,
|
98
|
+
:joins => joins_for_finder}
|
91
99
|
finder_options.merge! custom_finder_options
|
92
100
|
finder_options.merge! :include => (active_scaffold_includes.blank? ? nil : active_scaffold_includes)
|
93
101
|
klass = beginning_of_chain
|
@@ -107,14 +115,15 @@ module ActiveScaffold::Actions
|
|
107
115
|
# self.successful = true
|
108
116
|
# flash[:info] = 'Player fired'
|
109
117
|
# end
|
110
|
-
def process_action_link_action(render_action = :action_update)
|
118
|
+
def process_action_link_action(render_action = :action_update, crud_type = nil)
|
111
119
|
if request.get?
|
112
120
|
# someone has disabled javascript, we have to show confirmation form first
|
113
121
|
@record = find_if_allowed(params[:id], :read) if params[:id] && params[:id] && params[:id].to_i > 0
|
114
122
|
respond_to_action(:action_confirmation)
|
115
123
|
else
|
116
124
|
if params[:id] && params[:id] && params[:id].to_i > 0
|
117
|
-
|
125
|
+
crud_type ||= (request.post? || request.put?) ? :update : :delete
|
126
|
+
@record = find_if_allowed(params[:id], crud_type)
|
118
127
|
unless @record.nil?
|
119
128
|
yield @record
|
120
129
|
else
|
@@ -154,7 +163,7 @@ module ActiveScaffold::Actions
|
|
154
163
|
def action_update_respond_to_yaml
|
155
164
|
render :text => successful? ? "" : Hash.from_xml(response_object.to_xml(:only => list_columns_names)).to_yaml, :content_type => Mime::YAML, :status => response_status
|
156
165
|
end
|
157
|
-
|
166
|
+
|
158
167
|
private
|
159
168
|
def list_authorized_filter
|
160
169
|
raise ActiveScaffold::ActionNotAllowed unless list_authorized?
|
@@ -163,6 +172,7 @@ module ActiveScaffold::Actions
|
|
163
172
|
def list_formats
|
164
173
|
(default_formats + active_scaffold_config.formats + active_scaffold_config.list.formats).uniq
|
165
174
|
end
|
175
|
+
alias_method :index_formats, :list_formats
|
166
176
|
alias_method :row_formats, :list_formats
|
167
177
|
|
168
178
|
def action_update_formats
|
@@ -8,43 +8,68 @@ module ActiveScaffold::Actions
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def mark_all
|
11
|
-
if mark_all?
|
11
|
+
if mark_all? || mark_all_scope_forced?
|
12
12
|
do_mark_all
|
13
13
|
else
|
14
14
|
do_demark_all
|
15
15
|
end
|
16
|
+
respond_to_action(:mark_all)
|
17
|
+
end
|
18
|
+
protected
|
19
|
+
|
20
|
+
def mark_all_respond_to_html
|
16
21
|
do_list
|
17
|
-
|
22
|
+
list_respond_to_html
|
18
23
|
end
|
19
|
-
protected
|
20
24
|
|
25
|
+
def mark_all_respond_to_js
|
26
|
+
do_list
|
27
|
+
render :action => 'on_mark_all', :locals => {:mark_all => mark_all?}
|
28
|
+
end
|
29
|
+
|
21
30
|
# We need to give the ActiveRecord classes a handle to currently marked records. We don't want to just pass the object,
|
22
31
|
# because the object may change. So we give ActiveRecord a proc that ties to the
|
23
32
|
# marked_records_method on this ApplicationController.
|
24
33
|
def assign_marked_records_to_model
|
25
34
|
active_scaffold_config.model.marked_records = marked_records
|
26
35
|
end
|
27
|
-
|
36
|
+
|
28
37
|
def marked_records
|
29
38
|
active_scaffold_session_storage[:marked_records] ||= Set.new
|
30
39
|
end
|
31
|
-
|
40
|
+
|
32
41
|
def mark_all?
|
33
42
|
@mark_all ||= [true, 'true', 1, '1', 'T', 't'].include?(params[:value].class == String ? params[:value].downcase : params[:value])
|
34
43
|
end
|
35
44
|
|
45
|
+
def mark_all_scope_forced?
|
46
|
+
!params[:mark_target].nil? && params[:mark_target]=='scope'
|
47
|
+
end
|
48
|
+
|
36
49
|
def do_mark_all
|
37
|
-
|
50
|
+
if active_scaffold_config.mark.mark_all_mode == :page && !mark_all_scope_forced? then
|
51
|
+
each_record_in_page {|record| marked_records << record.id}
|
52
|
+
else
|
53
|
+
each_record_in_scope {|record| marked_records << record.id}
|
54
|
+
end
|
38
55
|
end
|
39
56
|
|
40
57
|
def do_demark_all
|
41
|
-
|
58
|
+
if active_scaffold_config.mark.mark_all_mode == :page then
|
59
|
+
each_record_in_page {|record| marked_records.delete(record.id)}
|
60
|
+
else
|
61
|
+
each_record_in_scope {|record| marked_records.delete(record.id)}
|
62
|
+
end
|
42
63
|
end
|
43
|
-
|
64
|
+
|
44
65
|
# The default security delegates to ActiveRecordPermissions.
|
45
66
|
# You may override the method to customize.
|
46
67
|
def mark_authorized?
|
47
68
|
authorized_for?(:action => :read)
|
48
69
|
end
|
70
|
+
|
71
|
+
def mark_all_formats
|
72
|
+
(default_formats + active_scaffold_config.formats).uniq
|
73
|
+
end
|
49
74
|
end
|
50
|
-
end
|
75
|
+
end
|
@@ -1,9 +1,5 @@
|
|
1
1
|
module ActiveScaffold::Actions
|
2
|
-
# The Nested module basically handles automatically linking
|
3
|
-
# controllers together. It does this by creating column links with
|
4
|
-
# the right parameters, and by providing any supporting systems
|
5
|
-
# (like a /:controller/nested action for returning associated
|
6
|
-
# scaffolds).
|
2
|
+
# The Nested module basically handles automatically linking controllers together. It does this by creating column links with the right parameters, and by providing any supporting systems (like a /:controller/nested action for returning associated scaffolds).
|
7
3
|
module Nested
|
8
4
|
|
9
5
|
def self.included(base)
|
@@ -23,16 +19,16 @@ module ActiveScaffold::Actions
|
|
23
19
|
def nested
|
24
20
|
@nested ||= ActiveScaffold::DataStructures::NestedInfo.get(active_scaffold_config.model, active_scaffold_session_storage)
|
25
21
|
if !@nested.nil? && @nested.new_instance?
|
26
|
-
register_constraints_with_action_columns(@nested.constrained_fields)
|
22
|
+
register_constraints_with_action_columns(@nested.constrained_fields, active_scaffold_config.list.hide_nested_column ? [] : [:list])
|
27
23
|
active_scaffold_constraints[:id] = params[:id] if @nested.belongs_to?
|
28
24
|
end
|
29
25
|
@nested
|
30
26
|
end
|
31
|
-
|
27
|
+
|
32
28
|
def nested?
|
33
29
|
!nested.nil?
|
34
30
|
end
|
35
|
-
|
31
|
+
|
36
32
|
def set_nested
|
37
33
|
if params[:parent_scaffold] && ((params[:association] && params[:assoc_id]) || params[:named_scope])
|
38
34
|
@nested = nil
|
@@ -42,7 +38,7 @@ module ActiveScaffold::Actions
|
|
42
38
|
params.delete_if {|key, value| [:parent_scaffold, :association, :named_scope, :assoc_id].include? key.to_sym}
|
43
39
|
end
|
44
40
|
end
|
45
|
-
|
41
|
+
|
46
42
|
def configure_nested
|
47
43
|
if nested?
|
48
44
|
active_scaffold_session_storage[:list][:label] = if nested.belongs_to?
|
@@ -55,7 +51,7 @@ module ActiveScaffold::Actions
|
|
55
51
|
end
|
56
52
|
end
|
57
53
|
end
|
58
|
-
|
54
|
+
|
59
55
|
def nested_authorized?(record = nil)
|
60
56
|
true
|
61
57
|
end
|
@@ -74,7 +70,7 @@ module ActiveScaffold::Actions
|
|
74
70
|
else
|
75
71
|
# Production mode is caching this link into a non nested scaffold
|
76
72
|
active_scaffold_config.action_links.delete('new_existing') if active_scaffold_config.action_links['new_existing']
|
77
|
-
|
73
|
+
|
78
74
|
if active_scaffold_config.nested.shallow_delete
|
79
75
|
active_scaffold_config.action_links.delete("destroy_existing") if active_scaffold_config.action_links['destroy_existing']
|
80
76
|
if active_scaffold_config.actions.include?(:delete)
|
@@ -84,7 +80,7 @@ module ActiveScaffold::Actions
|
|
84
80
|
end
|
85
81
|
end
|
86
82
|
end
|
87
|
-
|
83
|
+
|
88
84
|
def beginning_of_chain
|
89
85
|
if nested? && nested.association && nested.association.collection?
|
90
86
|
nested.parent_scope.send(nested.association.name)
|
@@ -98,7 +94,7 @@ module ActiveScaffold::Actions
|
|
98
94
|
def nested_parent_record(crud = :read)
|
99
95
|
@nested_parent_record ||= find_if_allowed(nested.parent_id, crud, nested.parent_model)
|
100
96
|
end
|
101
|
-
|
97
|
+
|
102
98
|
def create_association_with_parent(record)
|
103
99
|
if nested?
|
104
100
|
if (nested.belongs_to? || nested.has_one? || nested.habtm?) && nested.child_association
|
@@ -114,7 +110,7 @@ module ActiveScaffold::Actions
|
|
114
110
|
end
|
115
111
|
end
|
116
112
|
end
|
117
|
-
|
113
|
+
|
118
114
|
private
|
119
115
|
def nested_formats
|
120
116
|
(default_formats + active_scaffold_config.formats + active_scaffold_config.nested.formats).uniq
|
@@ -147,7 +143,7 @@ module ActiveScaffold::Actions::Nested
|
|
147
143
|
do_destroy_existing
|
148
144
|
respond_to_action(:destroy_existing)
|
149
145
|
end
|
150
|
-
|
146
|
+
|
151
147
|
protected
|
152
148
|
def new_existing_respond_to_html
|
153
149
|
if successful?
|
@@ -210,7 +206,7 @@ module ActiveScaffold::Actions::Nested
|
|
210
206
|
def delete_existing_authorized?(record = nil)
|
211
207
|
true
|
212
208
|
end
|
213
|
-
|
209
|
+
|
214
210
|
def after_create_save(record)
|
215
211
|
if params[:association_macro] == :has_and_belongs_to_many
|
216
212
|
params[:associated_id] = record
|