active_scaffold 3.0.4 → 3.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. data/CHANGELOG +5 -0
  2. data/active_scaffold.gemspec +1 -1
  3. data/frontends/default/stylesheets/stylesheet.css +40 -2
  4. data/lib/active_scaffold.rb +111 -21
  5. data/lib/active_scaffold/actions/nested.rb +5 -1
  6. data/lib/active_scaffold/actions/subform.rb +4 -1
  7. data/lib/active_scaffold/attribute_params.rb +4 -4
  8. data/lib/active_scaffold/bridges/bridge.rb +2 -5
  9. data/lib/active_scaffold/config/list.rb +9 -9
  10. data/lib/active_scaffold/config/update.rb +1 -1
  11. data/lib/active_scaffold/data_structures/action_links.rb +4 -3
  12. data/lib/active_scaffold/finder.rb +13 -13
  13. data/lib/active_scaffold/helpers/controller_helpers.rb +5 -3
  14. data/lib/active_scaffold/helpers/country_helpers.rb +263 -257
  15. data/lib/active_scaffold/helpers/form_column_helpers.rb +5 -5
  16. data/lib/active_scaffold/helpers/id_helpers.rb +2 -2
  17. data/lib/active_scaffold/helpers/search_column_helpers.rb +11 -11
  18. data/lib/active_scaffold/helpers/view_helpers.rb +15 -15
  19. data/lib/active_scaffold/marked_model.rb +6 -6
  20. data/lib/extensions/action_view_rendering.rb +5 -5
  21. data/lib/extensions/active_record_offset.rb +7 -7
  22. data/lib/extensions/localize.rb +1 -1
  23. data/lib/extensions/name_option_for_datetime.rb +1 -1
  24. data/lib/extensions/paginator_extensions.rb +2 -2
  25. data/lib/extensions/reverse_associations.rb +1 -1
  26. data/lib/extensions/routing_mapper.rb +2 -2
  27. data/lib/extensions/usa_state.rb +15 -11
  28. data/lib/generators/active_scaffold/active_scaffold_generator.rb +5 -5
  29. data/lib/generators/active_scaffold_controller/active_scaffold_controller_generator.rb +2 -2
  30. data/lib/generators/active_scaffold_setup/active_scaffold_setup_generator.rb +10 -10
  31. metadata +4 -6
  32. data/environment.rb +0 -24
  33. data/install_assets.rb +0 -44
@@ -4,9 +4,9 @@ module ActiveScaffold
4
4
  def self.included(controller)
5
5
  controller.class_eval { helper_method :params_for, :main_path_to_return }
6
6
  end
7
-
7
+
8
8
  include ActiveScaffold::Helpers::IdHelpers
9
-
9
+
10
10
  def params_for(options = {})
11
11
  # :adapter and :position are one-use rendering arguments. they should not propagate.
12
12
  # :sort, :sort_direction, and :page are arguments that stored in the session. they need not propagate.
@@ -22,7 +22,9 @@ module ActiveScaffold
22
22
  @params_for.merge(options)
23
23
  end
24
24
 
25
- # Parameters to generate url to the main page (override if the ActiveScaffold is used as a component on another controllers page)
25
+ # Parameters to generate url to the main page (override if the
26
+ # ActiveScaffold is used as a component on another controllers
27
+ # page)
26
28
  def main_path_to_return
27
29
  parameters = {}
28
30
  if params[:parent_controller]
@@ -1,7 +1,9 @@
1
1
  module ActiveScaffold
2
2
  module Helpers
3
3
  module CountryHelpers
4
- # Return select and option tags for the given object and method, using country_options_for_select to generate the list of option tags.
4
+ # Return select and option tags for the given object and method,
5
+ # using country_options_for_select to generate the list of
6
+ # option tags.
5
7
  def country_select(object, method, priority_countries = nil, options = {}, html_options = {})
6
8
  ActionView::Helpers::InstanceTag.new(object, method, self, options.delete(:object)).to_country_select_tag(priority_countries, options, html_options)
7
9
  end
@@ -10,9 +12,11 @@ module ActiveScaffold
10
12
  ActionView::Helpers::InstanceTag.new(object, method, self, options.delete(:object)).to_usa_state_select_tag(priority_states, options, html_options)
11
13
  end
12
14
 
13
- # Returns a string of option tags for pretty much any country in the world. Supply a country name as +selected+ to
14
- # have it marked as the selected option tag. You can also supply an array of countries as +priority_countries+, so
15
- # that they will be listed above the rest of the (long) list.
15
+ # Returns a string of option tags for pretty much any country in
16
+ # the world. Supply a country name as +selected+ to have it
17
+ # marked as the selected option tag. You can also supply an
18
+ # array of countries as +priority_countries+, so that they will
19
+ # be listed above the rest of the (long) list.
16
20
  #
17
21
  # NOTE: Only the option tags are returned, you have to wrap this call in a regular HTML select tag.
18
22
  def country_options_for_select(selected = nil, priority_countries = nil)
@@ -25,10 +29,12 @@ module ActiveScaffold
25
29
  return country_options + options_for_select(COUNTRIES.collect {|country| [I18n.t("countries.#{country}", :default => country.to_s.titleize), country.to_s]}, :selected => selected)
26
30
  end
27
31
 
28
- # Returns a string of option tags for the states in the United States. Supply a state name as +selected to
29
- # have it marked as the selected option tag. Included also is the option to set a couple of +priority_states+
30
- # in case you want to highligh a local area
31
- # NOTE: Only the option tags are returned from this method, wrap it in a <select>
32
+ # Returns a string of option tags for the states in the United
33
+ # States. Supply a state name as +selected to have it marked as
34
+ # the selected option tag. Included also is the option to set a
35
+ # couple of +priority_states+ in case you want to highligh a
36
+ # local area NOTE: Only the option tags are returned from this
37
+ # method, wrap it in a <select>
32
38
  def usa_state_options_for_select(selected = nil, priority_states = nil)
33
39
  if priority_states
34
40
  state_options = options_for_select(priority_states + [['-------------', '']], :selected => selected, :disabled => '')
@@ -46,254 +52,254 @@ module ActiveScaffold
46
52
  end
47
53
  # All the countries included in the country_options output.
48
54
  COUNTRIES = [
49
- :afghanistan,
50
- :aland_islands,
51
- :albania,
52
- :algeria,
53
- :american_samoa,
54
- :andorra,
55
- :angola,
56
- :anguilla,
57
- :antarctica,
58
- :antigua_and_barbuda,
59
- :argentina,
60
- :armenia,
61
- :aruba,
62
- :australia,
63
- :austria,
64
- :azerbaijan,
65
- :bahamas,
66
- :bahrain,
67
- :bangladesh,
68
- :barbados,
69
- :belarus,
70
- :belgium,
71
- :belize,
72
- :benin,
73
- :bermuda,
74
- :bhutan,
75
- :bolivia,
76
- :bosnia_and_herzegowina,
77
- :botswana,
78
- :bouvet_island,
79
- :brazil,
80
- :british_indian_ocean_territory,
81
- :brunei_darussalam,
82
- :bulgaria,
83
- :burkina_faso,
84
- :burundi,
85
- :cambodia,
86
- :cameroon,
87
- :canada,
88
- :cape_verde,
89
- :cayman_islands,
90
- :central_african_republic,
91
- :chad,
92
- :chile,
93
- :china,
94
- :christmas_island,
95
- :cocos_keeling_islands,
96
- :colombia,
97
- :comoros,
98
- :congo,
99
- :congo_the_democratic_republic_of_the,
100
- :cook_islands,
101
- :costa_rica,
102
- :cote_divoire,
103
- :croatia,
104
- :cuba,
105
- :cyprus,
106
- :czech_republic,
107
- :denmark,
108
- :djibouti,
109
- :dominica,
110
- :dominican_republic,
111
- :ecuador,
112
- :egypt,
113
- :el_salvador,
114
- :equatorial_guinea,
115
- :eritrea,
116
- :estonia,
117
- :ethiopia,
118
- :falkland_islands_malvinas,
119
- :faroe_islands,
120
- :fiji,
121
- :finland,
122
- :france,
123
- :french_guiana,
124
- :french_polynesia,
125
- :french_southern_territories,
126
- :gabon,
127
- :gambia,
128
- :georgia,
129
- :germany,
130
- :ghana,
131
- :gibraltar,
132
- :greece,
133
- :greenland,
134
- :grenada,
135
- :guadeloupe,
136
- :guam,
137
- :guatemala,
138
- :guernsey,
139
- :guinea,
140
- :guinea_bissau,
141
- :guyana,
142
- :haiti,
143
- :heard_and_mcdonald_islands,
144
- :holy_see_vatican_city_state,
145
- :honduras,
146
- :hong_kong,
147
- :hungary,
148
- :iceland,
149
- :india,
150
- :indonesia,
151
- :iran_islamic_republic_of,
152
- :iraq,
153
- :ireland,
154
- :isle_of_man,
155
- :israel,
156
- :italy,
157
- :jamaica,
158
- :japan,
159
- :jersey,
160
- :jordan,
161
- :kazakhstan,
162
- :kenya,
163
- :kiribati,
164
- :korea_democratic_peoples_republic_of,
165
- :korea_republic_of,
166
- :kuwait,
167
- :kyrgyzstan,
168
- :lao_peoples_democratic_republic,
169
- :latvia,
170
- :lebanon,
171
- :lesotho,
172
- :liberia,
173
- :libyan_arab_jamahiriya,
174
- :liechtenstein,
175
- :lithuania,
176
- :luxembourg,
177
- :macao,
178
- :macedonia_the_former_yugoslav_republic_of,
179
- :madagascar,
180
- :malawi,
181
- :malaysia,
182
- :maldives,
183
- :mali,
184
- :malta,
185
- :marshall_islands,
186
- :martinique,
187
- :mauritania,
188
- :mauritius,
189
- :mayotte,
190
- :mexico,
191
- :micronesia_federated_states_of,
192
- :moldova_republic_of,
193
- :monaco,
194
- :mongolia,
195
- :montenegro,
196
- :montserrat,
197
- :morocco,
198
- :mozambique,
199
- :myanmar,
200
- :namibia,
201
- :nauru,
202
- :nepal,
203
- :netherlands,
204
- :netherlands_antilles,
205
- :new_caledonia,
206
- :new_zealand,
207
- :nicaragua,
208
- :niger,
209
- :nigeria,
210
- :niue,
211
- :norfolk_island,
212
- :northern_mariana_islands,
213
- :norway,
214
- :oman,
215
- :pakistan,
216
- :palau,
217
- :palestinian_territory_occupied,
218
- :panama,
219
- :papua_new_guinea,
220
- :paraguay,
221
- :peru,
222
- :philippines,
223
- :pitcairn,
224
- :poland,
225
- :portugal,
226
- :puerto_rico,
227
- :qatar,
228
- :reunion,
229
- :romania,
230
- :russian_federation,
231
- :rwanda,
232
- :saint_barthelemy,
233
- :saint_helena,
234
- :saint_kitts_and_nevis,
235
- :saint_lucia,
236
- :saint_pierre_and_miquelon,
237
- :saint_vincent_and_the_grenadines,
238
- :samoa,
239
- :san_marino,
240
- :sao_tome_and_principe,
241
- :saudi_arabia,
242
- :senegal,
243
- :serbia,
244
- :seychelles,
245
- :sierra_leone,
246
- :singapore,
247
- :slovakia,
248
- :slovenia,
249
- :solomon_islands,
250
- :somalia,
251
- :south_africa,
252
- :south_georgia_and_the_south_sandwich_islands,
253
- :spain,
254
- :sri_lanka,
255
- :sudan,
256
- :suriname,
257
- :svalbard_and_jan_mayen,
258
- :swaziland,
259
- :sweden,
260
- :switzerland,
261
- :syrian_arab_republic,
262
- :taiwan_province_of_china,
263
- :tajikistan,
264
- :tanzania_united_republic_of,
265
- :thailand,
266
- :timor_leste,
267
- :togo,
268
- :tokelau,
269
- :tonga,
270
- :trinidad_and_tobago,
271
- :tunisia,
272
- :turkey,
273
- :turkmenistan,
274
- :turks_and_caicos_islands,
275
- :tuvalu,
276
- :uganda,
277
- :ukraine,
278
- :united_arab_emirates,
279
- :united_kingdom,
280
- :united_states,
281
- :united_states_minor_outlying_islands,
282
- :uruguay,
283
- :uzbekistan,
284
- :vanuatu,
285
- :venezuela,
286
- :viet_nam,
287
- :virgin_islands_british,
288
- :virgin_islands_us,
289
- :wallis_and_futuna,
290
- :western_sahara,
291
- :yemen,
292
- :zambia,
55
+ :afghanistan,
56
+ :aland_islands,
57
+ :albania,
58
+ :algeria,
59
+ :american_samoa,
60
+ :andorra,
61
+ :angola,
62
+ :anguilla,
63
+ :antarctica,
64
+ :antigua_and_barbuda,
65
+ :argentina,
66
+ :armenia,
67
+ :aruba,
68
+ :australia,
69
+ :austria,
70
+ :azerbaijan,
71
+ :bahamas,
72
+ :bahrain,
73
+ :bangladesh,
74
+ :barbados,
75
+ :belarus,
76
+ :belgium,
77
+ :belize,
78
+ :benin,
79
+ :bermuda,
80
+ :bhutan,
81
+ :bolivia,
82
+ :bosnia_and_herzegowina,
83
+ :botswana,
84
+ :bouvet_island,
85
+ :brazil,
86
+ :british_indian_ocean_territory,
87
+ :brunei_darussalam,
88
+ :bulgaria,
89
+ :burkina_faso,
90
+ :burundi,
91
+ :cambodia,
92
+ :cameroon,
93
+ :canada,
94
+ :cape_verde,
95
+ :cayman_islands,
96
+ :central_african_republic,
97
+ :chad,
98
+ :chile,
99
+ :china,
100
+ :christmas_island,
101
+ :cocos_keeling_islands,
102
+ :colombia,
103
+ :comoros,
104
+ :congo,
105
+ :congo_the_democratic_republic_of_the,
106
+ :cook_islands,
107
+ :costa_rica,
108
+ :cote_divoire,
109
+ :croatia,
110
+ :cuba,
111
+ :cyprus,
112
+ :czech_republic,
113
+ :denmark,
114
+ :djibouti,
115
+ :dominica,
116
+ :dominican_republic,
117
+ :ecuador,
118
+ :egypt,
119
+ :el_salvador,
120
+ :equatorial_guinea,
121
+ :eritrea,
122
+ :estonia,
123
+ :ethiopia,
124
+ :falkland_islands_malvinas,
125
+ :faroe_islands,
126
+ :fiji,
127
+ :finland,
128
+ :france,
129
+ :french_guiana,
130
+ :french_polynesia,
131
+ :french_southern_territories,
132
+ :gabon,
133
+ :gambia,
134
+ :georgia,
135
+ :germany,
136
+ :ghana,
137
+ :gibraltar,
138
+ :greece,
139
+ :greenland,
140
+ :grenada,
141
+ :guadeloupe,
142
+ :guam,
143
+ :guatemala,
144
+ :guernsey,
145
+ :guinea,
146
+ :guinea_bissau,
147
+ :guyana,
148
+ :haiti,
149
+ :heard_and_mcdonald_islands,
150
+ :holy_see_vatican_city_state,
151
+ :honduras,
152
+ :hong_kong,
153
+ :hungary,
154
+ :iceland,
155
+ :india,
156
+ :indonesia,
157
+ :iran_islamic_republic_of,
158
+ :iraq,
159
+ :ireland,
160
+ :isle_of_man,
161
+ :israel,
162
+ :italy,
163
+ :jamaica,
164
+ :japan,
165
+ :jersey,
166
+ :jordan,
167
+ :kazakhstan,
168
+ :kenya,
169
+ :kiribati,
170
+ :korea_democratic_peoples_republic_of,
171
+ :korea_republic_of,
172
+ :kuwait,
173
+ :kyrgyzstan,
174
+ :lao_peoples_democratic_republic,
175
+ :latvia,
176
+ :lebanon,
177
+ :lesotho,
178
+ :liberia,
179
+ :libyan_arab_jamahiriya,
180
+ :liechtenstein,
181
+ :lithuania,
182
+ :luxembourg,
183
+ :macao,
184
+ :macedonia_the_former_yugoslav_republic_of,
185
+ :madagascar,
186
+ :malawi,
187
+ :malaysia,
188
+ :maldives,
189
+ :mali,
190
+ :malta,
191
+ :marshall_islands,
192
+ :martinique,
193
+ :mauritania,
194
+ :mauritius,
195
+ :mayotte,
196
+ :mexico,
197
+ :micronesia_federated_states_of,
198
+ :moldova_republic_of,
199
+ :monaco,
200
+ :mongolia,
201
+ :montenegro,
202
+ :montserrat,
203
+ :morocco,
204
+ :mozambique,
205
+ :myanmar,
206
+ :namibia,
207
+ :nauru,
208
+ :nepal,
209
+ :netherlands,
210
+ :netherlands_antilles,
211
+ :new_caledonia,
212
+ :new_zealand,
213
+ :nicaragua,
214
+ :niger,
215
+ :nigeria,
216
+ :niue,
217
+ :norfolk_island,
218
+ :northern_mariana_islands,
219
+ :norway,
220
+ :oman,
221
+ :pakistan,
222
+ :palau,
223
+ :palestinian_territory_occupied,
224
+ :panama,
225
+ :papua_new_guinea,
226
+ :paraguay,
227
+ :peru,
228
+ :philippines,
229
+ :pitcairn,
230
+ :poland,
231
+ :portugal,
232
+ :puerto_rico,
233
+ :qatar,
234
+ :reunion,
235
+ :romania,
236
+ :russian_federation,
237
+ :rwanda,
238
+ :saint_barthelemy,
239
+ :saint_helena,
240
+ :saint_kitts_and_nevis,
241
+ :saint_lucia,
242
+ :saint_pierre_and_miquelon,
243
+ :saint_vincent_and_the_grenadines,
244
+ :samoa,
245
+ :san_marino,
246
+ :sao_tome_and_principe,
247
+ :saudi_arabia,
248
+ :senegal,
249
+ :serbia,
250
+ :seychelles,
251
+ :sierra_leone,
252
+ :singapore,
253
+ :slovakia,
254
+ :slovenia,
255
+ :solomon_islands,
256
+ :somalia,
257
+ :south_africa,
258
+ :south_georgia_and_the_south_sandwich_islands,
259
+ :spain,
260
+ :sri_lanka,
261
+ :sudan,
262
+ :suriname,
263
+ :svalbard_and_jan_mayen,
264
+ :swaziland,
265
+ :sweden,
266
+ :switzerland,
267
+ :syrian_arab_republic,
268
+ :taiwan_province_of_china,
269
+ :tajikistan,
270
+ :tanzania_united_republic_of,
271
+ :thailand,
272
+ :timor_leste,
273
+ :togo,
274
+ :tokelau,
275
+ :tonga,
276
+ :trinidad_and_tobago,
277
+ :tunisia,
278
+ :turkey,
279
+ :turkmenistan,
280
+ :turks_and_caicos_islands,
281
+ :tuvalu,
282
+ :uganda,
283
+ :ukraine,
284
+ :united_arab_emirates,
285
+ :united_kingdom,
286
+ :united_states,
287
+ :united_states_minor_outlying_islands,
288
+ :uruguay,
289
+ :uzbekistan,
290
+ :vanuatu,
291
+ :venezuela,
292
+ :viet_nam,
293
+ :virgin_islands_british,
294
+ :virgin_islands_us,
295
+ :wallis_and_futuna,
296
+ :western_sahara,
297
+ :yemen,
298
+ :zambia,
293
299
  :zimbabwe] unless const_defined?("COUNTRIES")
294
300
 
295
301
 
296
- USASTATES = [["Alabama", "AL"], ["Alaska", "AK"], ["Arizona", "AZ"], ["Arkansas", "AR"], ["California", "CA"], ["Colorado", "CO"], ["Connecticut", "CT"], ["Delaware", "DE"], ["District of Columbia", "DC"], ["Florida", "FL"], ["Georgia", "GA"], ["Hawaii", "HI"], ["Idaho", "ID"], ["Illinois", "IL"], ["Indiana", "IN"], ["Iowa", "IA"], ["Kansas", "KS"], ["Kentucky", "KY"], ["Louisiana", "LA"], ["Maine", "ME"], ["Maryland", "MD"], ["Massachusetts", "MA"], ["Michigan", "MI"], ["Minnesota", "MN"], ["Mississippi", "MS"], ["Missouri", "MO"], ["Montana", "MT"], ["Nebraska", "NE"], ["Nevada", "NV"], ["New Hampshire", "NH"], ["New Jersey", "NJ"], ["New Mexico", "NM"], ["New York", "NY"], ["North Carolina", "NC"], ["North Dakota", "ND"], ["Ohio", "OH"], ["Oklahoma", "OK"], ["Oregon", "OR"], ["Pennsylvania", "PA"], ["Rhode Island", "RI"], ["South Carolina", "SC"], ["South Dakota", "SD"], ["Tennessee", "TN"], ["Texas", "TX"], ["Utah", "UT"], ["Vermont", "VT"], ["Virginia", "VA"], ["Washington", "WA"], ["Wisconsin", "WI"], ["West Virginia", "WV"], ["Wyoming", "WY"]] unless const_defined?("USASTATES")
302
+ USASTATES = [["Alabama", "AL"], ["Alaska", "AK"], ["Arizona", "AZ"], ["Arkansas", "AR"], ["California", "CA"], ["Colorado", "CO"], ["Connecticut", "CT"], ["Delaware", "DE"], ["District of Columbia", "DC"], ["Florida", "FL"], ["Georgia", "GA"], ["Hawaii", "HI"], ["Idaho", "ID"], ["Illinois", "IL"], ["Indiana", "IN"], ["Iowa", "IA"], ["Kansas", "KS"], ["Kentucky", "KY"], ["Louisiana", "LA"], ["Maine", "ME"], ["Maryland", "MD"], ["Massachusetts", "MA"], ["Michigan", "MI"], ["Minnesota", "MN"], ["Mississippi", "MS"], ["Missouri", "MO"], ["Montana", "MT"], ["Nebraska", "NE"], ["Nevada", "NV"], ["New Hampshire", "NH"], ["New Jersey", "NJ"], ["New Mexico", "NM"], ["New York", "NY"], ["North Carolina", "NC"], ["North Dakota", "ND"], ["Ohio", "OH"], ["Oklahoma", "OK"], ["Oregon", "OR"], ["Pennsylvania", "PA"], ["Rhode Island", "RI"], ["South Carolina", "SC"], ["South Dakota", "SD"], ["Tennessee", "TN"], ["Texas", "TX"], ["Utah", "UT"], ["Vermont", "VT"], ["Virginia", "VA"], ["Washington", "WA"], ["Wisconsin", "WI"], ["West Virginia", "WV"], ["Wyoming", "WY"]] unless const_defined?("USASTATES")
297
303
 
298
304
  class ActionView::Helpers::InstanceTag #:nodoc:
299
305
  include CountryHelpers
@@ -320,7 +326,7 @@ module ActiveScaffold
320
326
  end
321
327
  end
322
328
  end
323
-
329
+
324
330
  module FormColumnHelpers
325
331
  def active_scaffold_input_country(column, options)
326
332
  select_options = {:prompt => as_(:_select_)}
@@ -338,14 +344,14 @@ module ActiveScaffold
338
344
  usa_state_select(:record, column.name, column.options[:priority], select_options, options)
339
345
  end
340
346
  end
341
-
347
+
342
348
  module SearchColumnHelpers
343
349
  def active_scaffold_search_country(column, options)
344
- active_scaffold_input_country(column, options.merge!(:selected => options.delete(:value)))
350
+ active_scaffold_input_country(column, options.merge!(:selected => options.delete(:value)))
345
351
  end
346
352
 
347
353
  def active_scaffold_search_usa_state(column, options)
348
- active_scaffold_input_usa_state(column, options.merge!(:selected => options.delete(:value)))
354
+ active_scaffold_input_usa_state(column, options.merge!(:selected => options.delete(:value)))
349
355
  end
350
356
  end
351
357
  end