active_scaffold-sequel 0.6.2 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  <%
2
- record = list_record if list_record # compat with render :partial :collection
2
+ record = list_record if defined?(list_record) # compat with render :partial :collection
3
3
  columns ||= list_columns
4
4
  tr_class = cycle("", "even-record")
5
5
  tr_class += " #{list_row_class(record)}" if respond_to? :list_row_class
@@ -1,7 +1,3 @@
1
- unless Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR >= 1
2
- raise "This version of ActiveScaffold requires Rails 3.1 or higher. Please use an earlier version."
3
- end
4
-
5
1
  require 'active_scaffold/version'
6
2
  require 'active_scaffold/engine' unless defined? ACTIVE_SCAFFOLD_PLUGIN
7
3
  require 'json' # for js_config
@@ -1,15 +1,21 @@
1
1
  module ActiveScaffold::Bridges
2
2
  class CountryHelper
3
3
  module CountryHelpers
4
+ def country_select_class
5
+ defined?(ActionView::Helpers::InstanceTag) ? ActionView::Helpers::InstanceTag : ActionView::Helpers::Tags::CountrySelect
6
+ end
7
+
4
8
  # Return select and option tags for the given object and method, using country_options_for_select to generate the list of option tags.
5
9
  def country_select(object, method, priority_countries = nil, options = {}, html_options = {})
6
- ActionView::Helpers::InstanceTag.new(object, method, self, options.delete(:object)).to_country_select_tag(priority_countries, options, html_options)
10
+ country_select_class.new(object, method, self, options).to_country_select_tag(priority_countries, options, html_options)
7
11
  end
8
12
 
9
13
  def usa_state_select(object, method, priority_states = nil, options = {}, html_options = {})
10
- ActionView::Helpers::InstanceTag.new(object, method, self, options.delete(:object)).to_usa_state_select_tag(priority_states, options, html_options)
14
+ country_select_class.new(object, method, self, options).to_usa_state_select_tag(priority_states, options, html_options)
11
15
  end
16
+ end
12
17
 
18
+ module CountryOptionsHelpers
13
19
  # Returns a string of option tags for pretty much any country in the world. Supply a country name as +selected+ to
14
20
  # have it marked as the selected option tag. You can also supply an array of countries as +priority_countries+, so
15
21
  # that they will be listed above the rest of the (long) list.
@@ -19,21 +25,21 @@ module ActiveScaffold::Bridges
19
25
  if priority_countries
20
26
  country_options = options_for_select(priority_countries.collect {|country| [I18n.t("countries.#{country}", :default => country.to_s.titleize), country.to_s]} + [['-------------', '']], :selected => selected, :disabled => '')
21
27
  else
22
- country_options = ""
28
+ country_options = options_for_select([])
23
29
  end
24
30
 
25
31
  return country_options + options_for_select(COUNTRIES.collect {|country| [I18n.t("countries.#{country}", :default => country.to_s.titleize), country.to_s]}, :selected => selected)
26
32
  end
27
33
 
28
34
  # 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+
35
+ # have it marked as the selected option tag. Included also is the option to set a couple of +priority_states+
30
36
  # in case you want to highligh a local area
31
37
  # NOTE: Only the option tags are returned from this 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 => '')
35
41
  else
36
- state_options = ""
42
+ state_options = options_for_select([])
37
43
  end
38
44
 
39
45
  if priority_states && priority_states.include?(selected)
@@ -44,283 +50,281 @@ module ActiveScaffold::Bridges
44
50
 
45
51
  return state_options
46
52
  end
47
- # All the countries included in the country_options output.
48
- 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,
293
- :zimbabwe] unless const_defined?("COUNTRIES")
294
53
 
54
+ # All the countries included in the country_options output.
55
+ COUNTRIES = [
56
+ :afghanistan,
57
+ :aland_islands,
58
+ :albania,
59
+ :algeria,
60
+ :american_samoa,
61
+ :andorra,
62
+ :angola,
63
+ :anguilla,
64
+ :antarctica,
65
+ :antigua_and_barbuda,
66
+ :argentina,
67
+ :armenia,
68
+ :aruba,
69
+ :australia,
70
+ :austria,
71
+ :azerbaijan,
72
+ :bahamas,
73
+ :bahrain,
74
+ :bangladesh,
75
+ :barbados,
76
+ :belarus,
77
+ :belgium,
78
+ :belize,
79
+ :benin,
80
+ :bermuda,
81
+ :bhutan,
82
+ :bolivia,
83
+ :bosnia_and_herzegowina,
84
+ :botswana,
85
+ :bouvet_island,
86
+ :brazil,
87
+ :british_indian_ocean_territory,
88
+ :brunei_darussalam,
89
+ :bulgaria,
90
+ :burkina_faso,
91
+ :burundi,
92
+ :cambodia,
93
+ :cameroon,
94
+ :canada,
95
+ :cape_verde,
96
+ :cayman_islands,
97
+ :central_african_republic,
98
+ :chad,
99
+ :chile,
100
+ :china,
101
+ :christmas_island,
102
+ :cocos_keeling_islands,
103
+ :colombia,
104
+ :comoros,
105
+ :congo,
106
+ :congo_the_democratic_republic_of_the,
107
+ :cook_islands,
108
+ :costa_rica,
109
+ :cote_divoire,
110
+ :croatia,
111
+ :cuba,
112
+ :cyprus,
113
+ :czech_republic,
114
+ :denmark,
115
+ :djibouti,
116
+ :dominica,
117
+ :dominican_republic,
118
+ :ecuador,
119
+ :egypt,
120
+ :el_salvador,
121
+ :equatorial_guinea,
122
+ :eritrea,
123
+ :estonia,
124
+ :ethiopia,
125
+ :falkland_islands_malvinas,
126
+ :faroe_islands,
127
+ :fiji,
128
+ :finland,
129
+ :france,
130
+ :french_guiana,
131
+ :french_polynesia,
132
+ :french_southern_territories,
133
+ :gabon,
134
+ :gambia,
135
+ :georgia,
136
+ :germany,
137
+ :ghana,
138
+ :gibraltar,
139
+ :greece,
140
+ :greenland,
141
+ :grenada,
142
+ :guadeloupe,
143
+ :guam,
144
+ :guatemala,
145
+ :guernsey,
146
+ :guinea,
147
+ :guinea_bissau,
148
+ :guyana,
149
+ :haiti,
150
+ :heard_and_mcdonald_islands,
151
+ :holy_see_vatican_city_state,
152
+ :honduras,
153
+ :hong_kong,
154
+ :hungary,
155
+ :iceland,
156
+ :india,
157
+ :indonesia,
158
+ :iran_islamic_republic_of,
159
+ :iraq,
160
+ :ireland,
161
+ :isle_of_man,
162
+ :israel,
163
+ :italy,
164
+ :jamaica,
165
+ :japan,
166
+ :jersey,
167
+ :jordan,
168
+ :kazakhstan,
169
+ :kenya,
170
+ :kiribati,
171
+ :korea_democratic_peoples_republic_of,
172
+ :korea_republic_of,
173
+ :kuwait,
174
+ :kyrgyzstan,
175
+ :lao_peoples_democratic_republic,
176
+ :latvia,
177
+ :lebanon,
178
+ :lesotho,
179
+ :liberia,
180
+ :libyan_arab_jamahiriya,
181
+ :liechtenstein,
182
+ :lithuania,
183
+ :luxembourg,
184
+ :macao,
185
+ :macedonia_the_former_yugoslav_republic_of,
186
+ :madagascar,
187
+ :malawi,
188
+ :malaysia,
189
+ :maldives,
190
+ :mali,
191
+ :malta,
192
+ :marshall_islands,
193
+ :martinique,
194
+ :mauritania,
195
+ :mauritius,
196
+ :mayotte,
197
+ :mexico,
198
+ :micronesia_federated_states_of,
199
+ :moldova_republic_of,
200
+ :monaco,
201
+ :mongolia,
202
+ :montenegro,
203
+ :montserrat,
204
+ :morocco,
205
+ :mozambique,
206
+ :myanmar,
207
+ :namibia,
208
+ :nauru,
209
+ :nepal,
210
+ :netherlands,
211
+ :netherlands_antilles,
212
+ :new_caledonia,
213
+ :new_zealand,
214
+ :nicaragua,
215
+ :niger,
216
+ :nigeria,
217
+ :niue,
218
+ :norfolk_island,
219
+ :northern_mariana_islands,
220
+ :norway,
221
+ :oman,
222
+ :pakistan,
223
+ :palau,
224
+ :palestinian_territory_occupied,
225
+ :panama,
226
+ :papua_new_guinea,
227
+ :paraguay,
228
+ :peru,
229
+ :philippines,
230
+ :pitcairn,
231
+ :poland,
232
+ :portugal,
233
+ :puerto_rico,
234
+ :qatar,
235
+ :reunion,
236
+ :romania,
237
+ :russian_federation,
238
+ :rwanda,
239
+ :saint_barthelemy,
240
+ :saint_helena,
241
+ :saint_kitts_and_nevis,
242
+ :saint_lucia,
243
+ :saint_pierre_and_miquelon,
244
+ :saint_vincent_and_the_grenadines,
245
+ :samoa,
246
+ :san_marino,
247
+ :sao_tome_and_principe,
248
+ :saudi_arabia,
249
+ :senegal,
250
+ :serbia,
251
+ :seychelles,
252
+ :sierra_leone,
253
+ :singapore,
254
+ :slovakia,
255
+ :slovenia,
256
+ :solomon_islands,
257
+ :somalia,
258
+ :south_africa,
259
+ :south_georgia_and_the_south_sandwich_islands,
260
+ :spain,
261
+ :sri_lanka,
262
+ :sudan,
263
+ :suriname,
264
+ :svalbard_and_jan_mayen,
265
+ :swaziland,
266
+ :sweden,
267
+ :switzerland,
268
+ :syrian_arab_republic,
269
+ :taiwan_province_of_china,
270
+ :tajikistan,
271
+ :tanzania_united_republic_of,
272
+ :thailand,
273
+ :timor_leste,
274
+ :togo,
275
+ :tokelau,
276
+ :tonga,
277
+ :trinidad_and_tobago,
278
+ :tunisia,
279
+ :turkey,
280
+ :turkmenistan,
281
+ :turks_and_caicos_islands,
282
+ :tuvalu,
283
+ :uganda,
284
+ :ukraine,
285
+ :united_arab_emirates,
286
+ :united_kingdom,
287
+ :united_states,
288
+ :united_states_minor_outlying_islands,
289
+ :uruguay,
290
+ :uzbekistan,
291
+ :vanuatu,
292
+ :venezuela,
293
+ :viet_nam,
294
+ :virgin_islands_british,
295
+ :virgin_islands_us,
296
+ :wallis_and_futuna,
297
+ :western_sahara,
298
+ :yemen,
299
+ :zambia,
300
+ :zimbabwe] unless const_defined?("COUNTRIES")
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")
297
-
298
- class ActionView::Helpers::InstanceTag #:nodoc:
299
- include CountryHelpers
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")
303
+ end
300
304
 
301
- def to_country_select_tag(priority_countries, options, html_options)
302
- html_options = html_options.stringify_keys
303
- add_default_name_and_id(html_options)
304
- value = value(object)
305
- selected_value = options.has_key?(:selected) ? options[:selected] : value
306
- content_tag("select",
307
- add_options(
308
- country_options_for_select(selected_value, priority_countries),
309
- options, selected_value
310
- ), html_options
311
- )
312
- end
305
+ module InstanceTagMethods
306
+ def to_country_select_tag(priority_countries, options, html_options)
307
+ html_options = html_options.stringify_keys
308
+ add_default_name_and_id(html_options)
309
+ value = value(object)
310
+ selected_value = options.has_key?(:selected) ? options[:selected] : value
311
+ content_tag("select",
312
+ add_options(
313
+ country_options_for_select(selected_value, priority_countries),
314
+ options, selected_value
315
+ ), html_options
316
+ )
317
+ end
313
318
 
314
- def to_usa_state_select_tag(priority_states, options, html_options)
315
- html_options = html_options.stringify_keys
316
- add_default_name_and_id(html_options)
317
- value = value(object)
318
- selected_value = options.has_key?(:selected) ? options[:selected] : value
319
- content_tag("select", add_options(usa_state_options_for_select(selected_value, priority_states), options, selected_value), html_options)
320
- end
319
+ def to_usa_state_select_tag(priority_states, options, html_options)
320
+ html_options = html_options.stringify_keys
321
+ add_default_name_and_id(html_options)
322
+ value = value(object)
323
+ selected_value = options.has_key?(:selected) ? options[:selected] : value
324
+ content_tag("select", add_options(usa_state_options_for_select(selected_value, priority_states), options, selected_value), html_options)
321
325
  end
322
326
  end
323
-
327
+
324
328
  module FormColumnHelpers
325
329
  def active_scaffold_input_country(column, options)
326
330
  select_options = {:prompt => as_(:_select_)}
@@ -338,14 +342,14 @@ module ActiveScaffold::Bridges
338
342
  usa_state_select(:record, column.name, column.options[:priority], select_options, options)
339
343
  end
340
344
  end
341
-
345
+
342
346
  module SearchColumnHelpers
343
347
  def active_scaffold_search_country(column, options)
344
- active_scaffold_input_country(column, options.merge!(:selected => options.delete(:value)))
348
+ active_scaffold_input_country(column, options.merge!(:selected => options.delete(:value)))
345
349
  end
346
350
 
347
351
  def active_scaffold_search_usa_state(column, options)
348
- active_scaffold_input_usa_state(column, options.merge!(:selected => options.delete(:value)))
352
+ active_scaffold_input_usa_state(column, options.merge!(:selected => options.delete(:value)))
349
353
  end
350
354
  end
351
355
  end
@@ -353,6 +357,19 @@ end
353
357
 
354
358
  ActionView::Base.class_eval do
355
359
  include ActiveScaffold::Bridges::CountryHelper::CountryHelpers
360
+ include ActiveScaffold::Bridges::CountryHelper::CountryOptionsHelpers
356
361
  include ActiveScaffold::Bridges::CountryHelper::FormColumnHelpers
357
362
  include ActiveScaffold::Bridges::CountryHelper::SearchColumnHelpers
358
363
  end
364
+
365
+ if defined? ActionView::Helpers::InstanceTag
366
+ ActionView::Helpers::InstanceTag.class_eval do
367
+ include ActiveScaffold::Bridges::CountryHelper::CountryOptionsHelpers
368
+ include ActiveScaffold::Bridges::CountryHelper::InstanceTagMethods
369
+ end
370
+ else
371
+ class ActionView::Helpers::Tags::CountrySelect < ActionView::Helpers::Tags::Base #:nodoc:
372
+ include ActiveScaffold::Bridges::CountryHelper::CountryOptionsHelpers
373
+ include ActiveScaffold::Bridges::CountryHelper::InstanceTagMethods
374
+ end
375
+ end
@@ -1,12 +1,17 @@
1
- module ActionView
2
- module Helpers
3
- class InstanceTag
4
- private
5
- def datetime_selector_with_name(options, html_options)
6
- options.merge!(:prefix => options[:name].gsub(/\[[^\[]*\]$/,'')) if options[:name]
7
- datetime_selector_without_name(options, html_options)
1
+ module ActiveScaffold
2
+ module DateSelectExtension
3
+ def datetime_selector_with_name(options, html_options)
4
+ options.merge!(:prefix => options[:name].gsub(/\[[^\[]*\]$/,'')) if options[:name]
5
+ datetime_selector_without_name(options, html_options)
6
+ end
7
+ def self.included(base)
8
+ base.class_eval do
9
+ alias_method_chain :datetime_selector, :name
10
+ private :datetime_selector_without_name, :datetime_selector_with_name, :datetime_selector
8
11
  end
9
- alias_method_chain :datetime_selector, :name
10
12
  end
11
13
  end
12
14
  end
15
+ (defined?(ActionView::Helpers::Tags::DateSelect) ? ActionView::Helpers::Tags::DateSelect : ActionView::Helpers::InstanceTag).class_eval do
16
+ include ActiveScaffold::DateSelectExtension
17
+ end
@@ -45,7 +45,7 @@ module ActiveScaffold
45
45
  options = active_scaffold_input_text_options(options) if text_types.include?(column.column[:type])
46
46
  if column.column[:type] == :string && options[:maxlength].blank?
47
47
  options[:maxlength] = column.maxlength
48
- options[:size] ||= ActionView::Helpers::InstanceTag::DEFAULT_FIELD_OPTIONS["size"]
48
+ options[:size] ||= options[:maxlength].to_i > 30 ? 30 : options[:maxlength]
49
49
  end
50
50
  options[:include_blank] = true if column.column[:allow_null] and [:date, :datetime, :time].include?(column.column[:type])
51
51
  options[:value] = format_number_value(@record.send(column.name), column.options) if column.number?
@@ -1,8 +1,8 @@
1
1
  module ActiveScaffold
2
2
  module Version
3
3
  MAJOR = 0
4
- MINOR = 6
5
- PATCH = 2
4
+ MINOR = 7
5
+ PATCH = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_scaffold-sequel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.7.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-28 00:00:00.000000000 Z
12
+ date: 2014-03-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: shoulda
@@ -244,8 +244,8 @@ files:
244
244
  - lib/active_scaffold/config/show.rb
245
245
  - lib/active_scaffold/config/subform.rb
246
246
  - lib/active_scaffold/config/update.rb
247
- - lib/active_scaffold/data_structures/action_columns.rb
248
247
  - lib/active_scaffold/data_structures/action_link.rb
248
+ - lib/active_scaffold/data_structures/action_columns.rb
249
249
  - lib/active_scaffold/data_structures/action_links.rb
250
250
  - lib/active_scaffold/data_structures/actions.rb
251
251
  - lib/active_scaffold/data_structures/bridge.rb
@@ -263,7 +263,6 @@ files:
263
263
  - lib/active_scaffold/extensions/to_label.rb
264
264
  - lib/active_scaffold/extensions/unsaved_associated.rb
265
265
  - lib/active_scaffold/extensions/unsaved_record.rb
266
- - lib/active_scaffold/extensions/usa_state.rb
267
266
  - lib/active_scaffold/helpers/human_condition_helpers.rb
268
267
  - lib/active_scaffold/helpers/association_helpers.rb
269
268
  - lib/active_scaffold/helpers/controller_helpers.rb
@@ -272,8 +271,8 @@ files:
272
271
  - lib/active_scaffold/helpers/id_helpers.rb
273
272
  - lib/active_scaffold/helpers/search_column_helpers.rb
274
273
  - lib/active_scaffold/helpers/pagination_helpers.rb
275
- - lib/active_scaffold/helpers/show_column_helpers.rb
276
274
  - lib/active_scaffold/helpers/view_helpers.rb
275
+ - lib/active_scaffold/helpers/show_column_helpers.rb
277
276
  - lib/active_scaffold/model_permissions.rb
278
277
  - lib/active_scaffold/attribute_params.rb
279
278
  - lib/active_scaffold/bridges.rb
@@ -416,7 +415,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
416
415
  version: '0'
417
416
  requirements: []
418
417
  rubyforge_project:
419
- rubygems_version: 1.8.23
418
+ rubygems_version: 1.8.23.2
420
419
  signing_key:
421
420
  specification_version: 3
422
421
  summary: ActiveScaffold version supporting Sequel with Rails 3.1.
@@ -1,46 +0,0 @@
1
- module ActionView
2
- module Helpers
3
- module FormOptionsHelper
4
-
5
- # Return a full select and option tags for the given object and method, using usa_state_options_for_select to generate the list of option <tags>.
6
- def usa_state_select(object, method, priority_states = nil, options = {}, html_options = {})
7
- InstanceTag.new(object, method, self, options.delete(:object)).to_usa_state_select_tag(priority_states, options, html_options)
8
- end
9
-
10
-
11
- # Returns a string of option tags for the states in the United States. Supply a state name as +selected to
12
- # have it marked as the selected option tag. Included also is the option to set a couple of +priority_states+
13
- # in case you want to highligh a local area
14
- # NOTE: Only the option tags are returned from this method, wrap it in a <select>
15
- def usa_state_options_for_select(selected = nil, priority_states = nil)
16
- state_options = ""
17
- if priority_states
18
- state_options += options_for_select(priority_states, selected)
19
- state_options += "<option>-------------</option>\n"
20
- end
21
-
22
- if priority_states && priority_states.include?(selected)
23
- state_options += options_for_select(USASTATES - priority_states, selected)
24
- else
25
- state_options += options_for_select(USASTATES, selected)
26
- end
27
-
28
- return state_options
29
- end
30
-
31
- 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")
32
-
33
- end
34
-
35
- class InstanceTag #:nodoc:
36
- include FormOptionsHelper
37
-
38
- def to_usa_state_select_tag(priority_states, options, html_options)
39
- html_options = html_options.stringify_keys
40
- add_default_name_and_id(html_options)
41
- value = value(object) if method(:value).arity > 0
42
- content_tag("select", add_options(usa_state_options_for_select(value, priority_states), options, value), html_options)
43
- end
44
- end
45
- end
46
- end