active_scaffold 3.0.26 → 3.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (236) hide show
  1. data/CHANGELOG +1 -1
  2. data/{frontends/default → app/assets}/images/add.gif +0 -0
  3. data/{frontends/default → app/assets}/images/arrow_down.gif +0 -0
  4. data/{frontends/default → app/assets}/images/arrow_up.gif +0 -0
  5. data/{frontends/default → app/assets}/images/close.gif +0 -0
  6. data/{frontends/default → app/assets}/images/close_touch.png +0 -0
  7. data/{frontends/default → app/assets}/images/config.png +0 -0
  8. data/{frontends/default → app/assets}/images/cross.png +0 -0
  9. data/{frontends/default → app/assets}/images/gears.png +0 -0
  10. data/{frontends/default → app/assets}/images/indicator-small.gif +0 -0
  11. data/{frontends/default → app/assets}/images/indicator.gif +0 -0
  12. data/{frontends/default → app/assets}/images/magnifier.png +0 -0
  13. data/app/assets/javascripts/active_scaffold.js.erb +16 -0
  14. data/{frontends/default → app/assets}/javascripts/jquery/active_scaffold.js +16 -28
  15. data/app/assets/javascripts/jquery/active_scaffold.js~ +1036 -0
  16. data/{lib/active_scaffold/bridges/date_picker/public/javascripts/date_picker_bridge.js → app/assets/javascripts/jquery/date_picker_bridge.js.erb} +3 -1
  17. data/{frontends/default → app/assets}/javascripts/jquery/jquery.editinplace.js +0 -0
  18. data/app/assets/javascripts/prototype/active_scaffold.js +1033 -0
  19. data/{frontends/default/javascripts/prototype/active_scaffold.js → app/assets/javascripts/prototype/active_scaffold.js~} +1 -0
  20. data/{frontends/default → app/assets}/javascripts/prototype/dhtml_history.js +0 -0
  21. data/{frontends/default → app/assets}/javascripts/prototype/form_enhancements.js +0 -0
  22. data/{frontends/default → app/assets}/javascripts/prototype/rico_corner.js +0 -0
  23. data/{frontends/default/stylesheets/stylesheet-ie.css → app/assets/stylesheets/active_scaffold-ie.css} +0 -0
  24. data/{frontends/default/stylesheets/stylesheet.css → app/assets/stylesheets/active_scaffold.css.erb} +29 -24
  25. data/{lib/active_scaffold/locale → config/locales}/de.yml +3 -0
  26. data/{lib/active_scaffold/locale → config/locales}/en.yml +3 -0
  27. data/{lib/active_scaffold/locale → config/locales}/es.yml +5 -0
  28. data/{lib/active_scaffold/locale → config/locales}/fr.yml +3 -0
  29. data/{lib/active_scaffold/locale → config/locales}/hu.yml +13 -2
  30. data/{lib/active_scaffold/locale → config/locales}/ja.yml +9 -0
  31. data/{lib/active_scaffold/locale → config/locales}/ru.yml +3 -0
  32. data/frontends/default/views/_form.html.erb +1 -1
  33. data/frontends/default/views/_form_association.html.erb +1 -5
  34. data/frontends/default/views/_horizontal_subform.html.erb +7 -4
  35. data/frontends/default/views/_horizontal_subform.html.erb~ +2 -5
  36. data/frontends/default/views/_horizontal_subform_footer.html.erb +0 -0
  37. data/frontends/default/views/_horizontal_subform_header.html.erb +1 -1
  38. data/frontends/default/views/_horizontal_subform_header.html.erb~ +1 -1
  39. data/frontends/default/views/_horizontal_subform_record.html.erb~ +1 -1
  40. data/frontends/default/views/_list_actions.html.erb +1 -1
  41. data/frontends/default/views/_list_messages.html.erb +1 -3
  42. data/frontends/default/views/_render_field.js.erb +20 -0
  43. data/frontends/default/views/_row.html.erb +3 -9
  44. data/frontends/default/views/_show.html.erb +2 -2
  45. data/frontends/default/views/add_existing.js.erb +20 -0
  46. data/frontends/default/views/destroy.js.erb +24 -0
  47. data/frontends/default/views/{edit_associated.js.rjs → edit_associated.js.erb} +3 -2
  48. data/frontends/default/views/form_messages.js.erb +1 -0
  49. data/frontends/default/views/list.js.erb +1 -0
  50. data/frontends/default/views/mark.js.rjs +6 -0
  51. data/frontends/default/views/on_action_update.js.erb +13 -0
  52. data/frontends/default/views/{on_create.js.erb~ → on_create.js.erb} +0 -0
  53. data/frontends/default/views/on_mark_all.js.erb +12 -0
  54. data/frontends/default/views/{on_update.js.erb~ → on_update.js.erb} +0 -0
  55. data/frontends/default/views/render_field.js.erb +1 -0
  56. data/frontends/default/views/search.html.erb +1 -1
  57. data/frontends/default/views/{update_column.js.erb~ → update_column.js.erb} +3 -3
  58. data/frontends/default/views/update_row.js.erb +1 -0
  59. data/lib/active_scaffold.rb +22 -46
  60. data/lib/active_scaffold/actions/core.rb +14 -6
  61. data/lib/active_scaffold/actions/core.rb~ +3 -3
  62. data/lib/active_scaffold/actions/create.rb +2 -5
  63. data/lib/active_scaffold/actions/create.rb~ +3 -2
  64. data/lib/active_scaffold/actions/delete.rb +1 -0
  65. data/lib/active_scaffold/actions/field_search.rb +1 -1
  66. data/lib/active_scaffold/actions/list.rb +10 -6
  67. data/lib/active_scaffold/actions/list.rb~ +3 -3
  68. data/lib/active_scaffold/actions/mark.rb +8 -8
  69. data/lib/active_scaffold/actions/nested.rb +2 -9
  70. data/lib/active_scaffold/actions/nested.rb~ +5 -7
  71. data/lib/active_scaffold/actions/search.rb +2 -1
  72. data/lib/active_scaffold/actions/subform.rb +1 -5
  73. data/lib/active_scaffold/actions/update.rb +1 -4
  74. data/lib/active_scaffold/actions/update.rb~ +5 -5
  75. data/lib/active_scaffold/attribute_params.rb +15 -26
  76. data/lib/active_scaffold/attribute_params.rb~ +1 -2
  77. data/lib/active_scaffold/bridges.rb +61 -0
  78. data/lib/active_scaffold/bridges/ancestry.rb +5 -0
  79. data/lib/active_scaffold/bridges/ancestry/{lib/ancestry_bridge.rb → ancestry_bridge.rb} +3 -3
  80. data/lib/active_scaffold/bridges/{calendar_date_select/bridge.rb → calendar_date_select.rb} +13 -5
  81. data/lib/active_scaffold/bridges/calendar_date_select/{lib/as_cds_bridge.rb → as_cds_bridge.rb} +4 -20
  82. data/lib/active_scaffold/bridges/cancan.rb +15 -0
  83. data/lib/active_scaffold/bridges/cancan/{lib/cancan_bridge.rb → cancan_bridge.rb} +2 -2
  84. data/lib/active_scaffold/bridges/carrierwave.rb +12 -0
  85. data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge.rb +31 -0
  86. data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge_helpers.rb +10 -0
  87. data/lib/active_scaffold/bridges/carrierwave/{lib/form_ui.rb → form_ui.rb} +0 -0
  88. data/lib/active_scaffold/bridges/carrierwave/{lib/list_ui.rb → list_ui.rb} +1 -1
  89. data/lib/active_scaffold/bridges/country_helper.rb +9 -0
  90. data/lib/active_scaffold/bridges/country_helper/{lib/country_helper_bridge.rb → country_helper_bridge.rb} +5 -5
  91. data/lib/active_scaffold/bridges/date_picker.rb +23 -0
  92. data/lib/active_scaffold/bridges/date_picker/ext.rb +54 -0
  93. data/lib/active_scaffold/bridges/date_picker/helper.rb +188 -0
  94. data/lib/active_scaffold/bridges/dragonfly.rb +9 -0
  95. data/lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb +34 -0
  96. data/lib/active_scaffold/bridges/dragonfly/dragonfly_bridge_helpers.rb +10 -0
  97. data/lib/active_scaffold/bridges/dragonfly/{lib/form_ui.rb → form_ui.rb} +0 -0
  98. data/lib/active_scaffold/bridges/dragonfly/{lib/list_ui.rb → list_ui.rb} +2 -2
  99. data/lib/active_scaffold/bridges/file_column.rb +11 -0
  100. data/lib/active_scaffold/bridges/file_column/{lib/as_file_column_bridge.rb → as_file_column_bridge.rb} +2 -2
  101. data/lib/active_scaffold/bridges/file_column/file_column_helpers.rb +57 -0
  102. data/lib/active_scaffold/bridges/file_column/{lib/form_ui.rb → form_ui.rb} +2 -2
  103. data/lib/active_scaffold/bridges/file_column/{lib/list_ui.rb → list_ui.rb} +0 -0
  104. data/lib/active_scaffold/bridges/paperclip.rb +12 -0
  105. data/lib/active_scaffold/bridges/paperclip/{lib/form_ui.rb → form_ui.rb} +0 -0
  106. data/lib/active_scaffold/bridges/paperclip/{lib/list_ui.rb → list_ui.rb} +3 -3
  107. data/lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb +36 -0
  108. data/lib/active_scaffold/bridges/paperclip/paperclip_bridge_helpers.rb +24 -0
  109. data/lib/active_scaffold/bridges/record_select.rb +11 -0
  110. data/lib/active_scaffold/bridges/record_select/{lib/record_select_bridge.rb → helpers.rb} +5 -16
  111. data/lib/active_scaffold/bridges/record_select/helpers.rb~ +9 -14
  112. data/lib/active_scaffold/bridges/semantic_attributes.rb +5 -0
  113. data/lib/active_scaffold/bridges/semantic_attributes/{lib/semantic_attributes_bridge.rb → column.rb} +3 -3
  114. data/lib/active_scaffold/bridges/tiny_mce.rb +5 -0
  115. data/lib/active_scaffold/bridges/tiny_mce/{lib/tiny_mce_bridge.rb → helpers.rb} +16 -8
  116. data/lib/active_scaffold/config/base.rb +9 -1
  117. data/lib/active_scaffold/config/core.rb +1 -1
  118. data/lib/active_scaffold/config/create.rb +3 -10
  119. data/lib/active_scaffold/config/delete.rb +1 -2
  120. data/lib/active_scaffold/config/field_search.rb +1 -2
  121. data/lib/active_scaffold/config/form.rb +2 -6
  122. data/lib/active_scaffold/config/list.rb +8 -2
  123. data/lib/active_scaffold/config/nested.rb +2 -6
  124. data/lib/active_scaffold/config/search.rb +6 -2
  125. data/lib/active_scaffold/config/show.rb +1 -4
  126. data/lib/active_scaffold/config/subform.rb +1 -1
  127. data/lib/active_scaffold/config/update.rb +1 -6
  128. data/lib/active_scaffold/data_structures/action_columns.rb +3 -0
  129. data/lib/active_scaffold/data_structures/action_link.rb +14 -10
  130. data/lib/active_scaffold/data_structures/bridge.rb +22 -0
  131. data/lib/active_scaffold/data_structures/column.rb +36 -4
  132. data/lib/active_scaffold/data_structures/nested_info.rb +4 -4
  133. data/lib/active_scaffold/data_structures/set.rb +1 -6
  134. data/lib/active_scaffold/data_structures/sorting.rb +2 -2
  135. data/lib/active_scaffold/engine.rb +4 -0
  136. data/lib/active_scaffold/extensions/action_controller_rendering.rb +2 -2
  137. data/lib/active_scaffold/extensions/action_controller_rendering.rb~ +1 -1
  138. data/lib/active_scaffold/extensions/action_view_rendering.rb +90 -93
  139. data/lib/active_scaffold/extensions/action_view_rendering.rb~ +1 -13
  140. data/lib/active_scaffold/extensions/active_association_reflection.rb +16 -7
  141. data/lib/active_scaffold/extensions/cache_association.rb +16 -0
  142. data/lib/active_scaffold/extensions/reverse_associations.rb +15 -13
  143. data/lib/active_scaffold/extensions/unsaved_associated.rb +1 -1
  144. data/lib/active_scaffold/finder.rb +40 -23
  145. data/lib/active_scaffold/finder.rb~ +3 -11
  146. data/lib/active_scaffold/helpers/association_helpers.rb +1 -1
  147. data/lib/active_scaffold/helpers/controller_helpers.rb +9 -1
  148. data/lib/active_scaffold/helpers/controller_helpers.rb~ +12 -5
  149. data/lib/active_scaffold/helpers/form_column_helpers.rb +20 -21
  150. data/lib/active_scaffold/helpers/form_column_helpers.rb~ +2 -1
  151. data/lib/active_scaffold/helpers/id_helpers.rb +5 -5
  152. data/lib/active_scaffold/helpers/list_column_helpers.rb +14 -24
  153. data/lib/active_scaffold/helpers/list_column_helpers.rb~ +15 -20
  154. data/lib/active_scaffold/helpers/search_column_helpers.rb +10 -1
  155. data/lib/active_scaffold/helpers/search_column_helpers.rb~ +1 -1
  156. data/lib/active_scaffold/helpers/view_helpers.rb +14 -40
  157. data/lib/active_scaffold/helpers/view_helpers.rb~ +3 -3
  158. data/lib/active_scaffold/version.rb +2 -2
  159. data/lib/active_scaffold_env.rb +0 -2
  160. data/test/bridges/active_scaffold_dependent_protect_test.rb +34 -0
  161. data/test/bridges/bridge_test.rb +43 -0
  162. data/test/bridges/company.rb +81 -0
  163. data/test/bridges/paperclip_test.rb +68 -0
  164. data/test/bridges/tiny_mce_test.rb +27 -0
  165. data/test/bridges/unobtrusive_date_picker_test.rb +49 -0
  166. data/test/bridges/validation_reflection_test.rb +57 -0
  167. data/test/config/base_test.rb +1 -1
  168. data/test/config/core_test.rb +58 -0
  169. data/test/config/create_test.rb +8 -5
  170. data/test/config/delete_test.rb +33 -0
  171. data/test/config/field_search_test.rb +47 -0
  172. data/test/config/list_test.rb +64 -9
  173. data/test/config/nested_test.rb +62 -0
  174. data/test/config/search_test.rb +60 -0
  175. data/test/config/show_test.rb +5 -5
  176. data/test/config/subform_test.rb +17 -0
  177. data/test/config/update_test.rb +27 -4
  178. data/test/helpers/list_column_helpers_test.rb +16 -5
  179. data/test/helpers/pagination_helpers_test.rb +4 -0
  180. data/test/misc/attribute_params_test.rb +37 -1
  181. data/test/misc/finder_test.rb +0 -1
  182. data/test/misc/lang_test.rb +2 -3
  183. data/test/mock_app/public/javascripts/active_scaffold/default/active_scaffold.js +2 -2
  184. data/test/mock_app/public/stylesheets/active_scaffold/default/stylesheet.css +13 -7
  185. metadata +137 -154
  186. data/frontends/default/views/_list_with_header.html.erb~ +0 -32
  187. data/frontends/default/views/_render_field.js.rjs +0 -14
  188. data/frontends/default/views/_show.html.erb~ +0 -8
  189. data/frontends/default/views/_update_form.html.erb~ +0 -6
  190. data/frontends/default/views/add_existing.js.erb~ +0 -18
  191. data/frontends/default/views/add_existing.js.rjs +0 -17
  192. data/frontends/default/views/destroy.js.rjs +0 -23
  193. data/frontends/default/views/form_messages.js.rjs +0 -1
  194. data/frontends/default/views/list.js.rjs +0 -1
  195. data/frontends/default/views/on_action_update.js.rjs +0 -10
  196. data/frontends/default/views/on_create.js.rjs +0 -41
  197. data/frontends/default/views/on_mark_all.js.rjs +0 -12
  198. data/frontends/default/views/on_update.js.rjs +0 -28
  199. data/frontends/default/views/render_field.js.rjs +0 -1
  200. data/frontends/default/views/update_column.js.rjs +0 -13
  201. data/frontends/default/views/update_row.js.rjs +0 -1
  202. data/lib/active_scaffold.rb~ +0 -362
  203. data/lib/active_scaffold/bridges/ancestry/bridge.rb +0 -5
  204. data/lib/active_scaffold/bridges/bridge.rb +0 -59
  205. data/lib/active_scaffold/bridges/cancan/bridge.rb +0 -12
  206. data/lib/active_scaffold/bridges/carrierwave/bridge.rb +0 -9
  207. data/lib/active_scaffold/bridges/carrierwave/lib/carrierwave_bridge.rb +0 -33
  208. data/lib/active_scaffold/bridges/carrierwave/lib/carrierwave_bridge_helpers.rb +0 -12
  209. data/lib/active_scaffold/bridges/country_helper/bridge.rb +0 -9
  210. data/lib/active_scaffold/bridges/date_picker/bridge.rb +0 -24
  211. data/lib/active_scaffold/bridges/date_picker/lib/datepicker_bridge.rb +0 -234
  212. data/lib/active_scaffold/bridges/dragonfly/bridge.rb +0 -9
  213. data/lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge.rb +0 -36
  214. data/lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge_helpers.rb +0 -12
  215. data/lib/active_scaffold/bridges/file_column/bridge.rb +0 -11
  216. data/lib/active_scaffold/bridges/file_column/lib/file_column_helpers.rb +0 -59
  217. data/lib/active_scaffold/bridges/paperclip/bridge.rb +0 -12
  218. data/lib/active_scaffold/bridges/paperclip/lib/paperclip_bridge.rb +0 -38
  219. data/lib/active_scaffold/bridges/paperclip/lib/paperclip_bridge_helpers.rb +0 -26
  220. data/lib/active_scaffold/bridges/record_select/bridge.rb +0 -5
  221. data/lib/active_scaffold/bridges/semantic_attributes/bridge.rb +0 -5
  222. data/lib/active_scaffold/bridges/shared/date_bridge.rb~ +0 -209
  223. data/lib/active_scaffold/bridges/tiny_mce/bridge.rb +0 -5
  224. data/lib/active_scaffold/bridges/validation_reflection/bridge.rb +0 -8
  225. data/lib/active_scaffold/bridges/validation_reflection/lib/validation_reflection_bridge.rb +0 -21
  226. data/lib/active_scaffold/config/base.rb~ +0 -70
  227. data/lib/active_scaffold/config/nested.rb~ +0 -41
  228. data/lib/active_scaffold/constraints.rb~ +0 -186
  229. data/lib/active_scaffold/data_structures/action_link.rb~ +0 -179
  230. data/lib/active_scaffold/data_structures/nested_info.rb~ +0 -123
  231. data/lib/active_scaffold/extensions/action_view_resolver.rb +0 -7
  232. data/lib/active_scaffold/extensions/active_association_reflection.rb~ +0 -22
  233. data/lib/active_scaffold/extensions/unsaved_associated.rb~ +0 -62
  234. data/lib/active_scaffold_assets.rb +0 -45
  235. data/lib/generators/active_scaffold_setup/USAGE +0 -10
  236. data/lib/generators/active_scaffold_setup/active_scaffold_setup_generator.rb +0 -59
@@ -108,18 +108,11 @@ module ActiveScaffold
108
108
 
109
109
  def condition_value_for_datetime(value, conversion = :to_time)
110
110
  if value.is_a? Hash
111
- Time.zone.local(*[:year, :month, :day, :hour, :minute, :second].collect {|part| value[part].to_i}) rescue nil
111
+ Time.zone.local(*[:year, :month, :day, :hour, :minute, :second].collect {|part| value[field][part].to_i}) rescue nil
112
112
  elsif value.respond_to?(:strftime)
113
113
  value.send(conversion)
114
- elsif conversion == :to_date
115
- Date.strptime(value, I18n.t('date.formats.default')) rescue nil
116
114
  else
117
- parts = Date._parse(value)
118
- time_parts = [[:hour, '%H'], [:min, '%M'], [:sec, '%S']].collect {|part, format_part| format_part if parts[part].present?}.compact
119
- format = "#{I18n.t('date.formats.default')} #{time_parts.join(':')} #{'%z' if parts[:offset].present?}"
120
- time = DateTime.strptime(value, format)
121
- time = Time.zone.local_to_utc(time) unless parts[:offset]
122
- time.in_time_zone.send(conversion) rescue nil
115
+ Time.zone.parse(value).in_time_zone.send(conversion) rescue nil
123
116
  end unless value.nil? || value.blank?
124
117
  end
125
118
 
@@ -277,7 +270,7 @@ module ActiveScaffold
277
270
  # Returns a hash with options to count records, rejecting select and order options
278
271
  # See finder_options for valid options
279
272
  def count_options(find_options = {}, count_includes = nil)
280
- count_includes ||= find_options[:includes] unless find_options[:where].nil?
273
+ count_includes ||= find_options[:includes] unless find_options[:conditions].nil?
281
274
  options = find_options.reject{|k,v| [:select, :order].include? k}
282
275
  options[:includes] = count_includes
283
276
  options
@@ -296,7 +289,6 @@ module ActiveScaffold
296
289
  # NOTE: we must use :include in the count query, because some conditions may reference other tables
297
290
  if options[:pagination] && options[:pagination] != :infinite
298
291
  count_query = append_to_query(klass, count_options(find_options, options[:count_includes]))
299
- debugger
300
292
  count = count_query.count unless options[:pagination] == :infinite
301
293
  end
302
294
 
@@ -31,7 +31,7 @@ module ActiveScaffold
31
31
  case association.macro
32
32
  when :has_one, :has_many
33
33
  # Find only orphaned objects
34
- "#{association.primary_key_name} IS NULL"
34
+ "#{association.foreign_key} IS NULL"
35
35
  when :belongs_to, :has_and_belongs_to_many
36
36
  # Find all
37
37
  nil
@@ -2,7 +2,7 @@ module ActiveScaffold
2
2
  module Helpers
3
3
  module ControllerHelpers
4
4
  def self.included(controller)
5
- controller.class_eval { helper_method :params_for, :main_path_to_return, :render_parent?, :render_parent_options, :render_parent_action, :nested_singular_association?}
5
+ controller.class_eval { helper_method :params_for, :main_path_to_return, :render_parent?, :render_parent_options, :render_parent_action, :nested_singular_association?, :build_associated}
6
6
  end
7
7
 
8
8
  include ActiveScaffold::Helpers::IdHelpers
@@ -82,6 +82,14 @@ module ActiveScaffold
82
82
  end if @parent_action.nil?
83
83
  @parent_action
84
84
  end
85
+
86
+ def build_associated(column, record)
87
+ if column.singular_association?
88
+ record.send(:"build_#{column.name}")
89
+ else
90
+ record.send(column.name).build
91
+ end
92
+ end
85
93
  end
86
94
  end
87
95
  end
@@ -33,7 +33,8 @@ module ActiveScaffold
33
33
  parameters[:eid] = params[:parent_controller]
34
34
  end
35
35
  if nested?
36
- parameters.merge! nested.to_params
36
+ parameters[:controller] = nested.parent_scaffold.controller_path
37
+ parameters[:eid] = nil
37
38
  end
38
39
  if params[:parent_sti]
39
40
  parameters[:controller] = params[:parent_sti]
@@ -83,11 +84,17 @@ module ActiveScaffold
83
84
  end
84
85
 
85
86
  def build_associated(column, record)
86
- if column.singular_association?
87
- record.send(:"build_#{column.name}")
88
- else
89
- record.send(column.name).build
87
+ child = column.singular_association? ? record.send(:"build_#{column.name}") : record.send(column.name).build
88
+ if record.new_record? && (reflection = record.class.reflect_on_association(column.name)).try(:reverse)
89
+ reverse_macro = child.class.reflect_on_association(reflection.reverse).macro
90
+ if [:has_one, :belongs_to].include?(reverse_macro) # singular
91
+ child.send(:"#{reflection.reverse}=", record)
92
+ # TODO: Might want to extend with this branch in the future
93
+ # else # plural
94
+ # child.send(:"#{reflection.reverse}") << record
95
+ end
90
96
  end
97
+ child
91
98
  end
92
99
  end
93
100
  end
@@ -72,7 +72,7 @@ module ActiveScaffold
72
72
 
73
73
  # Fix for keeping unique IDs in subform
74
74
  id_control = "record_#{column.name}_#{[params[:eid], params[:id]].compact.join '_'}"
75
- id_control += scope.gsub(/(\[|\])/, '_').gsub('__', '_').gsub(/_$/, '') if scope
75
+ id_control += scope_id(scope) if scope
76
76
 
77
77
  { :name => name, :class => "#{column.name}-input", :id => id_control}.merge(options)
78
78
  end
@@ -102,10 +102,9 @@ module ActiveScaffold
102
102
  select_options = options_for_association(column.association)
103
103
  select_options.unshift([ associated.to_label, associated.id ]) unless associated.nil? or select_options.find {|label, id| id == associated.id}
104
104
 
105
- selected = associated.nil? ? nil : associated.id
106
105
  method = column.name
107
106
  #html_options[:name] += '[id]'
108
- options = {:selected => selected, :include_blank => as_(:_select_)}
107
+ options = {:selected => associated.try(:id), :include_blank => as_(:_select_)}
109
108
 
110
109
  html_options.update(column.options[:html_options] || {})
111
110
  options.update(column.options)
@@ -116,25 +115,26 @@ module ActiveScaffold
116
115
  def active_scaffold_input_plural_association(column, options)
117
116
  associated_options = @record.send(column.association.name).collect {|r| [r.to_label, r.id]}
118
117
  select_options = associated_options | options_for_association(column.association)
119
- return content_tag(:span, as_(:no_options), :id => options[:id]) if select_options.empty?
118
+ return content_tag(:span, as_(:no_options), :class => options[:class], :id => options[:id]) if select_options.empty?
120
119
 
121
120
  active_scaffold_checkbox_list(column, select_options, associated_options.collect {|a| a[1]}, options)
122
121
  end
123
122
 
124
123
  def active_scaffold_checkbox_list(column, select_options, associated_ids, options)
125
- html = "<ul class=\"checkbox-list\" id=\"#{options[:id]}\">"
126
-
127
- select_options.each_with_index do |option, i|
128
- label, id = option
129
- this_id = "#{options[:id]}_#{i}_id"
130
- html << content_tag(:li) do
131
- check_box_tag("#{options[:name]}[]", id, associated_ids.include?(id), :id => this_id) <<
132
- content_tag(:label, h(label), :for => this_id)
124
+ html = content_tag :ul, :class => "#{options[:class]} checkbox-list", :id => options[:id] do
125
+ content = "".html_safe
126
+ select_options.each_with_index do |option, i|
127
+ label, id = option
128
+ this_id = "#{options[:id]}_#{i}_id"
129
+ content << content_tag(:li) do
130
+ check_box_tag("#{options[:name]}[]", id, associated_ids.include?(id), :id => this_id) <<
131
+ content_tag(:label, h(label), :for => this_id)
132
+ end
133
133
  end
134
+ content
134
135
  end
135
- html << '</ul>'
136
136
  html << javascript_tag("new DraggableLists('#{options[:id]}')") if column.options[:draggable_lists]
137
- html.html_safe
137
+ html
138
138
  end
139
139
 
140
140
  def active_scaffold_translated_option(column, text, value = nil)
@@ -171,7 +171,7 @@ module ActiveScaffold
171
171
  end
172
172
 
173
173
  def active_scaffold_input_checkbox(column, options)
174
- check_box(:record, column.name, options)
174
+ check_box(:record, column.name, options.merge(column.options))
175
175
  end
176
176
 
177
177
  def active_scaffold_input_password(column, options)
@@ -210,8 +210,7 @@ module ActiveScaffold
210
210
 
211
211
  # add functionality for overriding subform partials from association class path
212
212
  def override_subform_partial?(column, subform_partial)
213
- path, partial_name = partial_pieces(override_subform_partial(column, subform_partial))
214
- template_exists?(partial_name, path, true)
213
+ template_exists?(override_subform_partial(column, subform_partial), true)
215
214
  end
216
215
 
217
216
  def override_subform_partial(column, subform_partial)
@@ -219,13 +218,13 @@ module ActiveScaffold
219
218
  end
220
219
 
221
220
  def override_form_field_partial?(column)
222
- path, partial_name = partial_pieces(override_form_field_partial(column))
223
- template_exists?(partial_name, path, true)
221
+ template_exists?(override_form_field_partial(column), true)
224
222
  end
225
223
 
226
- # the naming convention for overriding form fields with partials
224
+ # the naming convention for overriding form fields with helpers
227
225
  def override_form_field_partial(column)
228
- "#{column.name}_form_column"
226
+ path = active_scaffold_controller_for(column.active_record_class).controller_path
227
+ File.join(path, "#{clean_column_name(column.name)}_form_column")
229
228
  end
230
229
 
231
230
  def override_form_field(column)
@@ -121,7 +121,8 @@ module ActiveScaffold
121
121
  end
122
122
 
123
123
  def active_scaffold_checkbox_list(column, select_options, associated_ids, options)
124
- html = content_tag :ul, :class => "#{options[:class]} checkbox-list", :id => options[:id] do
124
+ options[:class] << " checkbox-list"
125
+ html = content_tag :ul, :class => options[:class], :id => options[:id] do
125
126
  content = "".html_safe
126
127
  select_options.each_with_index do |option, i|
127
128
  label, id = option
@@ -3,7 +3,7 @@ module ActiveScaffold
3
3
  # A bunch of helper methods to produce the common view ids
4
4
  module IdHelpers
5
5
  def id_from_controller(controller)
6
- controller.to_s.gsub("/", "__")
6
+ controller.to_s.gsub("/", "__").html_safe
7
7
  end
8
8
 
9
9
  def controller_id(controller = (params[:eid] || params[:parent_controller] || params[:controller]))
@@ -42,10 +42,6 @@ module ActiveScaffold
42
42
  "#{controller_id}-search-input"
43
43
  end
44
44
 
45
- def table_action_id(name)
46
- "#{controller_id}-action-table-#{name}"
47
- end
48
-
49
45
  def action_link_id(link_action,link_id)
50
46
  "#{controller_id}-#{link_action}-#{link_id}-link"
51
47
  end
@@ -115,6 +111,10 @@ module ActiveScaffold
115
111
  def action_iframe_id(options)
116
112
  "#{controller_id}-#{options[:action]}-#{options[:id]}-iframe"
117
113
  end
114
+
115
+ def scope_id(scope)
116
+ scope.gsub(/(\[|\])/, '_').gsub('__', '_').gsub(/_$/, '')
117
+ end
118
118
 
119
119
  private
120
120
 
@@ -34,14 +34,13 @@ module ActiveScaffold
34
34
  if column.link
35
35
  link = column.link
36
36
  associated = record.send(column.association.name) if column.association
37
- url_options = params_for(:action => nil, :id => record.id)
37
+ url_options = params_for(:action => nil, :id => record.id, :link => text)
38
38
 
39
39
  # setup automatic link
40
40
  if column.autolink? && column.singular_association? # link to inline form
41
- link = action_link_to_inline_form(column, record, associated, text)
42
- return text if link.nil?
43
- else
44
- url_options[:link] = text
41
+ link = action_link_to_inline_form(column, record, associated)
42
+ return text if link.crud_type.nil?
43
+ url_options[:link] = as_(:create_new) if link.crud_type == :create
45
44
  end
46
45
 
47
46
  if column_link_authorized?(link, column, record, associated)
@@ -56,9 +55,8 @@ module ActiveScaffold
56
55
  end
57
56
 
58
57
  # setup the action link to inline form
59
- def action_link_to_inline_form(column, record, associated, text)
58
+ def action_link_to_inline_form(column, record, associated)
60
59
  link = column.link.clone
61
- link.label = text
62
60
  if column.polymorphic_association?
63
61
  polymorphic_controller = controller_path_for_activerecord(record.send(column.association.name).class)
64
62
  return link if polymorphic_controller.nil?
@@ -72,7 +70,6 @@ module ActiveScaffold
72
70
  if actions.include?(:new)
73
71
  link.action = 'new'
74
72
  link.crud_type = :create
75
- link.label = as_(:create_new)
76
73
  end
77
74
  elsif actions.include?(:edit)
78
75
  link.action = 'edit'
@@ -84,7 +81,7 @@ module ActiveScaffold
84
81
  link.action = 'index'
85
82
  link.crud_type = :read
86
83
  end
87
- link if link.action.present?
84
+ link
88
85
  end
89
86
 
90
87
  def column_link_authorized?(link, column, record, associated)
@@ -122,17 +119,6 @@ module ActiveScaffold
122
119
  truncate(clean_column_value(record.send(column.name)), :length => column.options[:truncate] || 50)
123
120
  end
124
121
 
125
- def active_scaffold_column_select(column, record)
126
- if column.association
127
- format_column_value(record, column)
128
- else
129
- value = record.send(column.name)
130
- text, val = column.options[:options].find {|text, val| (val || text).to_s == value}
131
- value = active_scaffold_translated_option(column, text, val).first if text
132
- format_column_value(record, column, value)
133
- end
134
- end
135
-
136
122
  def active_scaffold_column_checkbox(column, record)
137
123
  options = {:disabled => true, :id => nil, :object => record}
138
124
  options.delete(:disabled) if inplace_edit?(record, column)
@@ -167,9 +153,13 @@ module ActiveScaffold
167
153
  value ||= record.send(column.name) unless record.nil?
168
154
  if value && column.association # cache association size before calling column_empty?
169
155
  associated_size = value.size if column.plural_association? and column.associated_number? # get count before cache association
170
- cache_association(value, column)
156
+ cache_association(value, column) if column.plural_association?
171
157
  end
172
158
  if column.association.nil? or column_empty?(value)
159
+ if column.form_ui == :select && column.options[:options]
160
+ text, val = column.options[:options].find {|text, val| (val.nil? ? text : val).to_s == value.to_s}
161
+ value = active_scaffold_translated_option(column, text, val).first if text
162
+ end
173
163
  if value.is_a? Numeric
174
164
  format_number_value(value, column.options)
175
165
  else
@@ -189,7 +179,7 @@ module ActiveScaffold
189
179
  when :currency
190
180
  number_to_currency(value, options[:i18n_options] || {})
191
181
  when :i18n_number
192
- send("number_with_#{value.is_a?(Integer) ? 'delimiter' : 'precision'}", value, options[:i18n_options] || {})
182
+ number_with_delimiter(value, options[:i18n_options] || {})
193
183
  else
194
184
  value
195
185
  end
@@ -206,10 +196,10 @@ module ActiveScaffold
206
196
  end
207
197
  when :has_many, :has_and_belongs_to_many
208
198
  if column.associated_limit.nil?
209
- firsts = value.collect { |v| v.to_label }
199
+ firsts = value.collect { |v| clean_column_value(v.to_label) }
210
200
  else
211
201
  firsts = value.first(column.associated_limit)
212
- firsts.collect! { |v| v.to_label }
202
+ firsts.collect! { |v| clean_column_value(v.to_label) }
213
203
  firsts[column.associated_limit] = '…' if value.size > column.associated_limit
214
204
  end
215
205
  if column.associated_limit == 0
@@ -34,14 +34,13 @@ module ActiveScaffold
34
34
  if column.link
35
35
  link = column.link
36
36
  associated = record.send(column.association.name) if column.association
37
- url_options = params_for(:action => nil, :id => record.id)
37
+ url_options = params_for(:action => nil, :id => record.id, :link => text)
38
38
 
39
39
  # setup automatic link
40
40
  if column.autolink? && column.singular_association? # link to inline form
41
- link = action_link_to_inline_form(column, record, associated, text)
42
- return text if link.nil?
43
- else
44
- url_options[:link] = text
41
+ link = action_link_to_inline_form(column, record, associated)
42
+ return text if link.crud_type.nil?
43
+ url_options[:link] = as_(:create_new) if link.crud_type == :create
45
44
  end
46
45
 
47
46
  if column_link_authorized?(link, column, record, associated)
@@ -56,9 +55,8 @@ module ActiveScaffold
56
55
  end
57
56
 
58
57
  # setup the action link to inline form
59
- def action_link_to_inline_form(column, record, associated, text)
58
+ def action_link_to_inline_form(column, record, associated)
60
59
  link = column.link.clone
61
- link.label = text
62
60
  if column.polymorphic_association?
63
61
  polymorphic_controller = controller_path_for_activerecord(record.send(column.association.name).class)
64
62
  return link if polymorphic_controller.nil?
@@ -72,7 +70,6 @@ module ActiveScaffold
72
70
  if actions.include?(:new)
73
71
  link.action = 'new'
74
72
  link.crud_type = :create
75
- link.label = as_(:create_new)
76
73
  end
77
74
  elsif actions.include?(:edit)
78
75
  link.action = 'edit'
@@ -84,7 +81,7 @@ module ActiveScaffold
84
81
  link.action = 'index'
85
82
  link.crud_type = :read
86
83
  end
87
- link if link.action.present?
84
+ link
88
85
  end
89
86
 
90
87
  def column_link_authorized?(link, column, record, associated)
@@ -119,7 +116,7 @@ module ActiveScaffold
119
116
  ## Overrides
120
117
  ##
121
118
  def active_scaffold_column_text(column, record)
122
- clean_column_value(truncate(record.send(column.name), :length => column.options[:truncate] || 50))
119
+ truncate(clean_column_value(record.send(column.name)), :length => column.options[:truncate] || 50)
123
120
  end
124
121
 
125
122
  def active_scaffold_column_checkbox(column, record)
@@ -190,25 +187,25 @@ module ActiveScaffold
190
187
  end
191
188
 
192
189
  def format_association_value(value, column, size)
193
- format_value case column.association.macro
190
+ case column.association.macro
194
191
  when :has_one, :belongs_to
195
192
  if column.polymorphic_association?
196
- "#{value.class.model_name.human}: #{value.to_label}"
193
+ format_value("#{value.class.model_name.human}: #{value.to_label}")
197
194
  else
198
- value.to_label
195
+ format_value(value.to_label)
199
196
  end
200
197
  when :has_many, :has_and_belongs_to_many
201
198
  if column.associated_limit.nil?
202
- firsts = value.collect { |v| v.to_label }
199
+ firsts = value.collect { |v| clean_column_value(v.to_label) }
203
200
  else
204
201
  firsts = value.first(column.associated_limit)
205
- firsts.collect! { |v| v.to_label }
202
+ firsts.collect! { |v| clean_column_value(v.to_label) }
206
203
  firsts[column.associated_limit] = '…' if value.size > column.associated_limit
207
204
  end
208
205
  if column.associated_limit == 0
209
206
  size if column.associated_number?
210
207
  else
211
- joined_associated = firsts.join(active_scaffold_config.list.association_join_text)
208
+ joined_associated = format_value(firsts.join(active_scaffold_config.list.association_join_text))
212
209
  joined_associated << " (#{size})" if column.associated_number? and column.associated_limit and value.size > column.associated_limit
213
210
  joined_associated
214
211
  end
@@ -275,13 +272,11 @@ module ActiveScaffold
275
272
 
276
273
  def inplace_edit_control(column)
277
274
  if inplace_edit?(active_scaffold_config.model, column) and inplace_edit_cloning?(column)
278
- old_record, @record = @record, new_model
275
+ @record = new_model
279
276
  column = column.clone
280
277
  column.options = column.options.clone
281
278
  column.form_ui = :select if (column.association && column.form_ui.nil?)
282
- content_tag(:div, active_scaffold_input_for(column), :style => "display:none;", :class => inplace_edit_control_css_class).tap do
283
- @record = old_record
284
- end
279
+ content_tag(:div, active_scaffold_input_for(column), {:style => "display:none;", :class => inplace_edit_control_css_class})
285
280
  end
286
281
  end
287
282
 
@@ -74,7 +74,7 @@ module ActiveScaffold
74
74
  associated = html_options.delete :value
75
75
  if column.association
76
76
  associated = associated.is_a?(Array) ? associated.map(&:to_i) : associated.to_i unless associated.nil?
77
- method = column.association.macro == :belongs_to ? column.association.primary_key_name : column.name
77
+ method = column.association.macro == :belongs_to ? column.association.foreign_key : column.name
78
78
  select_options = options_for_association(column.association, true)
79
79
  else
80
80
  method = column.name
@@ -146,6 +146,15 @@ module ActiveScaffold
146
146
  select_options
147
147
  end
148
148
 
149
+ def include_null_comparators?(column)
150
+ return column.options[:null_comparators] if column.options.has_key? :null_comparators
151
+ if column.association
152
+ column.association.macro != :belongs_to || active_scaffold_config.columns[column.association.primary_key_name].column.try(:null)
153
+ else
154
+ column.column.try(:null)
155
+ end
156
+ end
157
+
149
158
  def active_scaffold_search_range(column, options)
150
159
  opt_value, from_value, to_value = field_search_params_range_values(column)
151
160