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
@@ -17,6 +17,8 @@ module ActiveScaffold::Actions
17
17
 
18
18
  def list
19
19
  do_list
20
+ do_new if active_scaffold_config.list.always_show_create
21
+ @record ||= new_model if active_scaffold_config.list.always_show_search
20
22
  @nested_auto_open = active_scaffold_config.list.nested_auto_open
21
23
  respond_to_action(:list)
22
24
  end
@@ -173,9 +175,7 @@ module ActiveScaffold::Actions
173
175
  end
174
176
  alias_method :index_formats, :list_formats
175
177
 
176
- def row_formats
177
- ([:html] + active_scaffold_config.formats + active_scaffold_config.list.formats).uniq
178
- end
178
+ alias_method :row_formats, :list_formats
179
179
 
180
180
  def action_update_formats
181
181
  (default_formats + active_scaffold_config.formats).uniq
@@ -2,8 +2,8 @@ module ActiveScaffold::Actions
2
2
  module Mark
3
3
 
4
4
  def self.included(base)
5
- base.before_filter :mark_authorized?, :only => [:mark_all]
6
- base.prepend_before_filter :assign_marked_records_to_model
5
+ base.before_filter :mark_authorized?, :only => :mark
6
+ #base.prepend_before_filter :assign_marked_records_to_model
7
7
  base.helper_method :marked_records
8
8
  end
9
9
 
@@ -11,7 +11,7 @@ module ActiveScaffold::Actions
11
11
  if mark_all? || mark_all_scope_forced?
12
12
  do_mark_all
13
13
  else
14
- do_demark_all
14
+ do_unmark
15
15
  end
16
16
  respond_to_action(:mark_all)
17
17
  end
@@ -33,9 +33,9 @@ module ActiveScaffold::Actions
33
33
  def assign_marked_records_to_model
34
34
  active_scaffold_config.model.marked_records = marked_records
35
35
  end
36
-
37
- def marked_records
38
- active_scaffold_session_storage[:marked_records] ||= Set.new
36
+
37
+ def mark?
38
+ params[:value] == 'true'
39
39
  end
40
40
 
41
41
  def mark_all?
@@ -65,11 +65,11 @@ module ActiveScaffold::Actions
65
65
  # The default security delegates to ActiveRecordPermissions.
66
66
  # You may override the method to customize.
67
67
  def mark_authorized?
68
- authorized_for?(:action => :read)
68
+ authorized_for?(:crud_type => :read)
69
69
  end
70
70
 
71
71
  def mark_all_formats
72
72
  (default_formats + active_scaffold_config.formats).uniq
73
73
  end
74
74
  end
75
- end
75
+ end
@@ -82,12 +82,8 @@ module ActiveScaffold::Actions
82
82
  end
83
83
 
84
84
  def beginning_of_chain
85
- if nested? && nested.association && !nested.association.belongs_to?
86
- if nested.association.collection?
87
- nested.parent_scope.send(nested.association.name)
88
- elsif nested.child_association.belongs_to?
89
- active_scaffold_config.model.where(nested.child_association.foreign_key => nested.parent_scope)
90
- end
85
+ if nested? && nested.association && nested.association.collection?
86
+ nested.parent_scope.send(nested.association.name)
91
87
  elsif nested? && nested.scope
92
88
  nested.parent_scope.send(nested.scope)
93
89
  else
@@ -127,9 +123,6 @@ module ActiveScaffold::Actions::Nested
127
123
 
128
124
  def self.included(base)
129
125
  super
130
- base.verify :method => :post,
131
- :only => :add_existing,
132
- :redirect_to => { :action => :index }
133
126
  end
134
127
 
135
128
  def new_existing
@@ -82,13 +82,8 @@ module ActiveScaffold::Actions
82
82
  end
83
83
 
84
84
  def beginning_of_chain
85
- if nested? && nested.association && !nested.association.belongs_to?
86
- debugger
87
- if nested.association.collection?
88
- nested.parent_scope.send(nested.association.name)
89
- elsif nested.child_association.belongs_to?
90
- active_scaffold_config.model.where(nested.child_association.foreign_key => nested.parent_scope)
91
- end
85
+ if nested? && nested.association && nested.association.collection?
86
+ nested.parent_scope.send(nested.association.name)
92
87
  elsif nested? && nested.scope
93
88
  nested.parent_scope.send(nested.scope)
94
89
  else
@@ -128,6 +123,9 @@ module ActiveScaffold::Actions::Nested
128
123
 
129
124
  def self.included(base)
130
125
  super
126
+ base.verify :method => :post,
127
+ :only => :add_existing,
128
+ :redirect_to => { :action => :index }
131
129
  end
132
130
 
133
131
  def new_existing
@@ -24,7 +24,8 @@ module ActiveScaffold::Actions
24
24
  unless query.empty?
25
25
  columns = active_scaffold_config.search.columns
26
26
  text_search = active_scaffold_config.search.text_search
27
- search_conditions = self.class.create_conditions_for_columns(query.split(' '), columns, text_search)
27
+ query = query.split(active_scaffold_config.search.split_terms) if active_scaffold_config.search.split_terms
28
+ search_conditions = self.class.create_conditions_for_columns(query, columns, text_search)
28
29
  self.active_scaffold_conditions = merge_conditions(self.active_scaffold_conditions, search_conditions)
29
30
  @filtered = !search_conditions.blank?
30
31
 
@@ -13,11 +13,7 @@ module ActiveScaffold::Actions
13
13
 
14
14
  # NOTE: we don't check whether the user is allowed to update this record, because if not, we'll still let them associate the record. we'll just refuse to do more than associate, is all.
15
15
  @record = @column.association.klass.find(params[:associated_id]) if params[:associated_id]
16
- @record ||= if @column.singular_association?
17
- @parent_record.send("build_#{@column.name}".to_sym)
18
- else
19
- @parent_record.send(@column.name).build
20
- end
16
+ @record ||= build_associated(@column, @parent_record)
21
17
 
22
18
  @scope = "[#{@column.name}]"
23
19
  @scope += (@record.new_record?) ? "[#{(Time.now.to_f*1000).to_i.to_s}]" : "[#{@record.id}]" if @column.plural_association?
@@ -2,9 +2,6 @@ module ActiveScaffold::Actions
2
2
  module Update
3
3
  def self.included(base)
4
4
  base.before_filter :update_authorized_filter, :only => [:edit, :update]
5
- base.verify :method => [:post, :put],
6
- :only => :update,
7
- :redirect_to => { :action => :index }
8
5
  base.helper_method :update_refresh_list?
9
6
  end
10
7
 
@@ -35,7 +32,7 @@ module ActiveScaffold::Actions
35
32
  def edit_respond_to_js
36
33
  render(:partial => 'update_form')
37
34
  end
38
- def update_respond_to_html
35
+ def update_respond_to_html
39
36
  if params[:iframe]=='true' # was this an iframe post ?
40
37
  responds_to_parent do
41
38
  render :action => 'on_update.js', :layout => false
@@ -18,7 +18,7 @@ module ActiveScaffold::Actions
18
18
  # for inline (inlist) editing
19
19
  def update_column
20
20
  do_update_column
21
- @column_span_id = params[:editor_id] || params[:editorId]
21
+ render :action => 'update_column', :locals => {:column_span_id => params[:editor_id] || params[:editorId]}
22
22
  end
23
23
 
24
24
  protected
@@ -32,7 +32,8 @@ module ActiveScaffold::Actions
32
32
  def edit_respond_to_js
33
33
  render(:partial => 'update_form')
34
34
  end
35
- def update_respond_to_html
35
+ def update_respond_to_html
36
+ debugger
36
37
  if params[:iframe]=='true' # was this an iframe post ?
37
38
  responds_to_parent do
38
39
  render :action => 'on_update.js', :layout => false
@@ -47,6 +48,7 @@ module ActiveScaffold::Actions
47
48
  end
48
49
  end
49
50
  def update_respond_to_js
51
+ debugger
50
52
  if successful? && update_refresh_list? && !render_parent?
51
53
  do_search if respond_to? :do_search
52
54
  do_list
@@ -92,11 +94,9 @@ module ActiveScaffold::Actions
92
94
  end
93
95
  end
94
96
  rescue ActiveRecord::RecordInvalid
95
- self.successful = false
96
- flash[:error] = $!.message
97
97
  rescue ActiveRecord::StaleObjectError
98
98
  @record.errors.add(:base, as_(:version_inconsistency))
99
- self.successful = false
99
+ self.successful=false
100
100
  rescue ActiveRecord::RecordNotSaved
101
101
  @record.errors.add(:base, as_(:record_not_saved)) if @record.errors.empty?
102
102
  self.successful = false
@@ -39,7 +39,6 @@ module ActiveScaffold
39
39
  crud_type = parent_record.new_record? ? :create : :update
40
40
  return parent_record unless parent_record.authorized_for?(:crud_type => crud_type)
41
41
 
42
- attributes = {} unless attributes.is_a?(Hash)
43
42
  multi_parameter_attributes = {}
44
43
  attributes.each do |k, v|
45
44
  next unless k.include? '('
@@ -62,22 +61,17 @@ module ActiveScaffold
62
61
  # we avoid assigning a value that already exists because otherwise has_one associations will break (AR bug in has_one_association.rb#replace)
63
62
  parent_record.send("#{column.name}=", value) unless parent_record.send(column.name) == value
64
63
 
65
- # plural associations may not actually appear in the params if all of the options have been unselected or cleared away.
66
- # the "form_ui" check is necessary, becuase without it we have problems
67
- # with subforms. the UI cuts out deep associations, which means they're not present in the
68
- # params even though they're in the columns list. the result is that associations were being
69
- # emptied out way too often.
70
- elsif column.form_ui and column.plural_association?
64
+ elsif column.plural_association?
71
65
  parent_record.send("#{column.name}=", [])
72
66
  end
73
67
  end
74
68
 
75
69
  if parent_record.new_record?
76
70
  parent_record.class.reflect_on_all_associations.each do |a|
77
- next unless [:has_one, :has_many].include?(a.macro) and not a.options[:through]
71
+ next unless [:has_one, :has_many].include?(a.macro) and not (a.options[:through] || a.options[:finder_sql])
78
72
  next unless association_proxy = parent_record.send(a.name)
79
73
 
80
- raise ActiveScaffold::ReverseAssociationRequired, "Association #{a.name}: In order to support :has_one and :has_many where the parent record is new and the child record(s) validate the presence of the parent, ActiveScaffold requires the reverse association (the belongs_to)." unless a.reverse
74
+ raise ActiveScaffold::ReverseAssociationRequired, "Association #{a.name} in class #{parent_record.class.name}: In order to support :has_one and :has_many where the parent record is new and the child record(s) validate the presence of the parent, ActiveScaffold requires the reverse association (the belongs_to)." unless a.reverse
81
75
 
82
76
  association_proxy = [association_proxy] if a.macro == :has_one
83
77
  association_proxy.each { |record| record.send("#{a.reverse}=", parent_record) }
@@ -112,7 +106,7 @@ module ActiveScaffold
112
106
  column.association.klass.find(value) if value and not value.empty?
113
107
  elsif column.plural_association?
114
108
  column_plural_assocation_value_from_value(column, value)
115
- elsif column.column && column.number? && [:i18n_number, :currency].include?(column.options[:format])
109
+ elsif column.number? && [:i18n_number, :currency].include?(column.options[:format])
116
110
  self.class.i18n_number_to_native_format(value)
117
111
  else
118
112
  # convert empty strings into nil. this works better with 'null => true' columns (and validations),
@@ -150,36 +144,31 @@ module ActiveScaffold
150
144
  end
151
145
  end
152
146
 
153
- # Attempts to create or find an instance of klass (which must be an ActiveRecord object) from the
147
+ # Attempts to create or find an instance of klass (which must be an ActiveRecord object) from the
154
148
  # request parameters given. If params[:id] exists it will attempt to find an existing object
155
149
  # otherwise it will build a new one.
156
150
  def find_or_create_for_params(params, parent_column, parent_record)
157
151
  current = parent_record.send(parent_column.name)
158
152
  klass = parent_column.association.klass
159
- return nil if parent_column.show_blank_record and attributes_hash_is_empty?(params, klass)
153
+ pk = klass.primary_key.to_sym
154
+ return nil if parent_column.show_blank_record?(current) and attributes_hash_is_empty?(params, klass)
160
155
 
161
- if params.has_key? :id
156
+ if params.has_key? pk
162
157
  # modifying the current object of a singular association
163
- if current and current.is_a? ActiveRecord::Base and current.id.to_s == params[:id]
164
- return current
158
+ pk_val = params[pk]
159
+ if current and current.is_a? ActiveRecord::Base and current.id.to_s == pk_val
160
+ current
165
161
  # modifying one of the current objects in a plural association
166
- elsif current and current.respond_to?(:any?) and current.any? {|o| o.id.to_s == params[:id]}
167
- return current.detect {|o| o.id.to_s == params[:id]}
162
+ elsif current and current.respond_to?(:any?) and current.any? {|o| o.id.to_s == pk_val}
163
+ current.detect {|o| o.id.to_s == pk_val}
168
164
  # attaching an existing but not-current object
169
165
  else
170
- return klass.find(params[:id])
166
+ klass.find(pk_val)
171
167
  end
172
168
  else
173
- if klass.authorized_for?(:crud_type => :create)
174
- if parent_column.singular_association?
175
- return parent_record.send("build_#{parent_column.name}")
176
- else
177
- return parent_record.send(parent_column.name).build
178
- end
179
- end
169
+ build_associated(parent_column, parent_record) if klass.authorized_for?(:crud_type => :create)
180
170
  end
181
171
  end
182
-
183
172
  # Determines whether the given attributes hash is "empty".
184
173
  # This isn't a literal emptiness - it's an attempt to discern whether the user intended it to be empty or not.
185
174
  def attributes_hash_is_empty?(hash, klass)
@@ -85,8 +85,6 @@ module ActiveScaffold
85
85
  record = find_or_create_for_params(attributes, column, parent_record)
86
86
  if record
87
87
  record_columns = active_scaffold_config_for(column.association.klass).subform.columns
88
- record_columns.constraint_columns = [column.association.reverse]
89
- debugger
90
88
  update_record_from_params(record, record_columns, attributes)
91
89
  record.unsaved = true
92
90
  end
@@ -103,6 +101,7 @@ module ActiveScaffold
103
101
  end
104
102
 
105
103
  def column_value_from_param_simple_value(parent_record, column, value)
104
+ debugger if column.name == :working_days
106
105
  if column.singular_association?
107
106
  # it's a single id
108
107
  column.association.klass.find(value) if value and not value.empty?
@@ -0,0 +1,61 @@
1
+ module ActiveScaffold
2
+ module Bridges
3
+ ActiveScaffold.autoload_subdir('bridges', self)
4
+ module Shared
5
+ autoload :DateBridge, 'active_scaffold/bridges/shared/date_bridge'
6
+ end
7
+
8
+ mattr_accessor :bridges
9
+ mattr_accessor :bridges_run
10
+ self.bridges = {}
11
+
12
+ def self.register(file)
13
+ match = file.match(/(active_scaffold\/bridges\/(.*))\.rb\Z/)
14
+ self.bridges[match[2].to_sym] = match[1] if match
15
+ end
16
+
17
+ def self.load(bridge_name)
18
+ bridge = self.bridges[bridge_name.to_sym]
19
+ if bridge.is_a? String
20
+ if ActiveScaffold.exclude_bridges.exclude? bridge_name.to_sym
21
+ bridge = bridge.camelize.constantize
22
+ self.bridges[bridge_name.to_sym] = bridge
23
+ else
24
+ self.bridges.delete bridge_name
25
+ bridge = nil
26
+ end
27
+ end
28
+ bridge
29
+ end
30
+ class << self
31
+ alias_method :[], :load
32
+ end
33
+
34
+ def self.run_all
35
+ return false if self.bridges_run
36
+ self.bridges.keys.each do |bridge_name|
37
+ bridge = self[bridge_name]
38
+ bridge.run if bridge
39
+ end
40
+ self.bridges_run = true
41
+ end
42
+
43
+ def self.all_stylesheets
44
+ self.bridges.keys.collect do |bridge_name|
45
+ bridge = self[bridge_name]
46
+ bridge.stylesheets if bridge and bridge.install?
47
+ end.compact.flatten
48
+ end
49
+
50
+ def self.all_javascripts
51
+ self.bridges.keys.collect do |bridge_name|
52
+ bridge = self[bridge_name]
53
+ bridge.javascripts if bridge and bridge.install?
54
+ end.compact.flatten
55
+ end
56
+ end
57
+ end
58
+
59
+ (Dir[File.join(File.dirname(__FILE__), "bridges/*.rb")] - [__FILE__]).each{|bridge_require|
60
+ ActiveScaffold::Bridges.register bridge_require
61
+ }
@@ -0,0 +1,5 @@
1
+ class ActiveScaffold::Bridges::Ancestry < ActiveScaffold::DataStructures::Bridge
2
+ def self.install
3
+ require File.join(File.dirname(__FILE__), "ancestry/ancestry_bridge.rb")
4
+ end
5
+ end
@@ -14,8 +14,8 @@ ActiveScaffold::Config::Core.class_eval do
14
14
  alias_method_chain :initialize, :ancestry
15
15
  end
16
16
 
17
- module ActiveScaffold
18
- module AncestryBridge
17
+ module ActiveScaffold::Bridges
18
+ class Ancestry
19
19
  module FormColumnHelpers
20
20
  def active_scaffold_input_ancestry(column, options)
21
21
  select_options = []
@@ -35,5 +35,5 @@ module ActiveScaffold
35
35
  end
36
36
 
37
37
  ActionView::Base.class_eval do
38
- include ActiveScaffold::AncestryBridge::FormColumnHelpers
38
+ include ActiveScaffold::Bridges::Ancestry::FormColumnHelpers
39
39
  end
@@ -1,5 +1,5 @@
1
- ActiveScaffold::Bridges.bridge "CalendarDateSelect" do
2
- install do
1
+ class ActiveScaffold::Bridges::CalendarDateSelect < ActiveScaffold::DataStructures::Bridge
2
+ def self.install
3
3
  # check to see if the old bridge was installed. If so, warn them
4
4
  # we can detect this by checking to see if the bridge was installed before calling this code
5
5
 
@@ -7,10 +7,18 @@ ActiveScaffold::Bridges.bridge "CalendarDateSelect" do
7
7
  raise RuntimeError, "We've detected that you have active_scaffold_calendar_date_select_bridge installed. This plugin has been moved to core. Please remove active_scaffold_calendar_date_select_bridge to prevent any conflicts"
8
8
  end
9
9
 
10
- require File.join(File.dirname(__FILE__), "lib/as_cds_bridge.rb")
10
+ require File.join(File.dirname(__FILE__), "calendar_date_select/as_cds_bridge.rb")
11
11
  end
12
12
 
13
- install? do
14
- Object.const_defined?(name) && ActiveScaffold.js_framework == :prototype
13
+ def self.install?
14
+ super && ActiveScaffold.js_framework == :prototype
15
+ end
16
+
17
+ def self.stylesheets
18
+ calendar_date_select_stylesheets
19
+ end
20
+
21
+ def self.javascripts
22
+ calendar_date_select_javascripts
15
23
  end
16
24
  end
@@ -22,7 +22,7 @@ end
22
22
 
23
23
  module ActiveScaffold
24
24
  module Bridges
25
- module CalendarDateSelectBridge
25
+ class CalendarDateSelect
26
26
  # Helpers that assist with the rendering of a Form Column
27
27
  module FormColumnHelpers
28
28
  def active_scaffold_input_calendar_date_select(column, options)
@@ -47,34 +47,18 @@ module ActiveScaffold
47
47
  :style => "display:#{(options[:show].nil? || options[:show]) ? '' : 'none'}"})
48
48
  end
49
49
  end
50
-
51
- module ViewHelpers
52
- def self.included(base)
53
- base.alias_method_chain :active_scaffold_stylesheets, :calendar_date_select
54
- base.alias_method_chain :active_scaffold_javascripts, :calendar_date_select
55
- end
56
- # Provides stylesheets to include with +stylesheet_link_tag+
57
- def active_scaffold_stylesheets_with_calendar_date_select(frontend = :default)
58
- active_scaffold_stylesheets_without_calendar_date_select + [calendar_date_select_stylesheets]
59
- end
60
-
61
- # Provides stylesheets to include with +stylesheet_link_tag+
62
- def active_scaffold_javascripts_with_calendar_date_select(frontend = :default)
63
- active_scaffold_javascripts_without_calendar_date_select + [calendar_date_select_javascripts]
64
- end
65
- end
66
50
  end
67
51
  end
68
52
  end
69
53
 
70
54
  ActionView::Base.class_eval do
71
- include ActiveScaffold::Bridges::CalendarDateSelectBridge::FormColumnHelpers
55
+ include ActiveScaffold::Bridges::CalendarDateSelect::FormColumnHelpers
72
56
  include ActiveScaffold::Bridges::Shared::DateBridge::SearchColumnHelpers
73
57
  alias_method :active_scaffold_search_calendar_date_select, :active_scaffold_search_date_bridge
74
58
  include ActiveScaffold::Bridges::Shared::DateBridge::HumanConditionHelpers
75
59
  alias_method :active_scaffold_human_condition_calendar_date_select, :active_scaffold_human_condition_date_bridge
76
- include ActiveScaffold::Bridges::CalendarDateSelectBridge::SearchColumnHelpers
77
- include ActiveScaffold::Bridges::CalendarDateSelectBridge::ViewHelpers
60
+ include ActiveScaffold::Bridges::CalendarDateSelect::SearchColumnHelpers
61
+ include ActiveScaffold::Bridges::CalendarDateSelect::ViewHelpers
78
62
  end
79
63
 
80
64
  ActiveScaffold::Finder::ClassMethods.module_eval do