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
@@ -1,8 +1,8 @@
1
- <h4><%= active_scaffold_config.show.label -%></h4>
1
+ <h4><%= active_scaffold_config.show.label(@record.to_label.nil? ? nil : clean_column_value(@record.to_label)) %></h4>
2
2
 
3
3
  <%= render :partial => 'show_columns', :locals => {:columns => active_scaffold_config.show.columns} -%>
4
4
 
5
5
  <p class="form-footer">
6
6
  <%= link_to as_(:close), main_path_to_return, :class => 'as_cancel', :remote => request.xhr?, 'data-refresh' => false %>
7
7
  <%= loading_indicator_tag(:action => :create, :id => params[:id]) %>
8
- </p>
8
+ </p>
@@ -0,0 +1,20 @@
1
+ <% new_row = render :partial => 'list_record', :locals => {:record => @record}%>
2
+ ActiveScaffold.create_record_row('#{active_scaffold_id}','#{escape_javascript(new_row)}', #{{:insert_at => :top}.to_json.html_safe});
3
+ <%%>
4
+ <% if active_scaffold_config.list.columns.any? {|c| c.calculation?} %>
5
+ ActiveScaffold.replace('<%=active_scaffold_calculations_id%>', '<%=escape_javascript(render(:partial => 'list_calculations'))%>');
6
+ <%end%>
7
+ <%%>
8
+ <% if(form_stays_open == true)%>
9
+ <%# why not just re-render the form? that wouldn't utilize a possible do_new override which sets default values.%>
10
+ ActiveScaffold.reset_form('<%element_form_id%>');
11
+ ActiveScaffold.replace_html('<%element_messages_id(:action => :add_existing)%>', '<%=escape_javascript(render(:partial => 'form_messages'))%>');
12
+ <%# have to delay the focus, because there's no "firstElement" in prototype until at least one element is not disabled%>
13
+ <%if ActiveScaffold.js_framework == :prototype%>
14
+ page.delay 0.1 do
15
+ page << "ActiveScaffold.focus_first_element_of_form('#{element_form_id}');"
16
+ end
17
+ <%end%>
18
+ <%else%>
19
+ ActiveScaffold.find_action_link('<%element_form_id(:action => :new_existing)%>').close();
20
+ <%end%>
@@ -0,0 +1,24 @@
1
+ <%messages_id = active_scaffold_messages_id%>
2
+ <%if controller.send(:successful?)%>
3
+ <%if render_parent? && controller.respond_to?(:render_component_into_view)%>
4
+ <%render_parent_options%>
5
+ <%if render_parent_action == :row%>
6
+ <%# TODO: That s not working with delete....%>
7
+ ActiveScaffold.delete_record_row('<%=element_row_id(:controller_id => "as_#{id_from_controller(params[:eid] || params[:parent_sti])}", :action => 'list', :id => params[:id])%>', '<%=url_for(params_for(:action => :index, :id => nil, :page => [active_scaffold_config.list.user.page.to_i - 1, 1].max, :escape => false))%>');
8
+ <%messages_id = active_scaffold_messages_id(:controller_id => "as_#{id_from_controller(params[:eid] || params[:parent_sti])}")%>
9
+ <%elsif render_parent_action == :index%>
10
+ <%= escape_javascript(controller.send(:render_component_into_view, render_parent_options))%>
11
+ <%end%>
12
+ <%#page.call 'ActiveScaffold.replace', active_scaffold_calculations_id, render(:partial => 'list_calculations') if active_scaffold_config.list.columns.any? {|c| c.calculation?}%>
13
+ <%elsif (active_scaffold_config.delete.refresh_list)%>
14
+ ActiveScaffold.replace('<%=active_scaffold_content_id%>', '<%=escape_javascript(render(:partial => 'list', :layout => false))%>');
15
+ <%else%>
16
+ ActiveScaffold.delete_record_row('<%=element_row_id(:action => 'list', :id => params[:id])%>', '<%=url_for(params_for(:action => :index, :id => nil, :page => [active_scaffold_config.list.user.page.to_i - 1, 1].max, :escape => false))%>');
17
+ <% if active_scaffold_config.list.columns.any? {|c| c.calculation?}%>
18
+ ActiveScaffold.replace('<%=active_scaffold_calculations_id%>', '<%=escape_javascript(render(:partial => 'list_calculations'))%>');
19
+ <% end %>
20
+ <%end%>
21
+ <%else%>
22
+ <%flash[:error] = active_scaffold_error_messages_for(@record, :object_name => "#{@record.class.model_name.human.downcase}#{@record.new_record? ? '' : ": #{@record.to_label}"}", :header_message => '', :message => "#{@record.class.model_name.human.downcase}#{@record.new_record? ? '' : ": #{@record.to_label}"}", :container_tag => nil, :list_type => :br)%>
23
+ <%end%>
24
+ ActiveScaffold.replace_html('<%=messages_id%>', '<%=escape_javascript(render(:partial => 'messages'))%>');
@@ -1,3 +1,4 @@
1
+ <%
1
2
  associated_form = render :partial => "#{subform_partial_for_column(@column)}_record", :locals => {:scope => @scope, :parent_record => @parent_record, :column => @column, :locked => @record.new_record? && @column.singular_association?}
2
3
  options = {:singular => false}
3
4
  if @column.singular_association?
@@ -7,5 +8,5 @@ else
7
8
  column = active_scaffold_config_for(@record.class).columns[@record.class.primary_key]
8
9
  options[:id] = active_scaffold_input_options(column, @scope)[:id]
9
10
  end
10
- end
11
- page.call 'ActiveScaffold.create_associated_record_form', sub_form_list_id(:association => @column.name), associated_form, options
11
+ end %>
12
+ ActiveScaffold.create_associated_record_form('<%=sub_form_list_id(:association => @column.name)%>','<%=escape_javascript(associated_form)%>', <%= options.to_json.html_safe %>);
@@ -0,0 +1 @@
1
+ ActiveScaffold.replace_html('<%=element_messages_id%>','<%=escape_javascript(render(:partial => 'form_messages'))%>');
@@ -0,0 +1 @@
1
+ ActiveScaffold.replace_html('<%=active_scaffold_content_id%>','<%=escape_javascript(render(:partial => 'list', :layout => false))%>');
@@ -0,0 +1,6 @@
1
+ if params[:id]
2
+ # FIXME: It isn't right when there are filtered records by a search
3
+ page << "$('#{active_scaffold_id}').down('.mark_record').checked = #{@mark ? true : false};"
4
+ else
5
+ page << "$$('##{active_scaffold_tbody_id} > tr > td > .mark_record').each(function(checkbox) { checkbox.checked = #{@mark ? true : false};});"
6
+ end
@@ -0,0 +1,13 @@
1
+ <%if controller.send :successful?%>
2
+ ActiveScaffold.replace_html('<%=active_scaffold_messages_id%>','<%=escape_javascript(render(:partial => 'messages'))%>');
3
+ <%if @record%>
4
+ ActiveScaffold.update_row('<%=element_row_id(:action => :list, :id => @record.id)%>','<%=escape_javascript(render(:partial => 'list_record', :locals => {:record => @record}))%>');
5
+ <%end%>
6
+ <% if active_scaffold_config.list.columns.any? {|c| c.calculation?}%>
7
+ ActiveScaffold.replace('<%=active_scaffold_calculations_id%>', '<%=escape_javascript(render(:partial => 'list_calculations'))%>');
8
+ <% end %>
9
+ <%else%>
10
+ <%flash[:error] = active_scaffold_error_messages_for(@record, :object_name => "#{@record.class.model_name.human.downcase}#{@record.new_record? ? '' : ": #{@record.to_label}"}", :header_message => '', :message => "#{@record.class.model_name.human.downcase}#{@record.new_record? ? '' : ": #{@record.to_label}"}", :container_tag => nil, :list_type => :br)%>
11
+ ActiveScaffold.replace_html('<%=active_scaffold_messages_id%>','<%=escape_javascript(render(:partial => 'messages'))%>');
12
+ ActiveScaffold.scroll_to('<%=active_scaffold_messages_id%>');
13
+ <%end%>
@@ -0,0 +1,12 @@
1
+ <%options = {:checked => mark_all,
2
+ :include_mark_all => true}%>
3
+ ActiveScaffold.mark_records('<%=active_scaffold_tbody_id%>',<%=options.to_json.html_safe%>);
4
+ <%if active_scaffold_config.model.marked.length>0 then %>
5
+ <%if active_scaffold_config.model.marked.length < @page.pager.count then%>
6
+ ActiveScaffold.replace_html('<%=active_scaffold_messages_id%>','<%="#{active_scaffold_config.model.marked.length.to_s} records marked. Press <a href=\"#{url_for(:action=>"mark_all",:mark_target=>"scope")}\">here</a> to select all #{@page.pager.count} records.".html_safe%>');
7
+ <%else%>
8
+ ActiveScaffold.replace_html('<%=active_scaffold_messages_id%>','<%="All #{@page.pager.count} records marked".html_safe%>');
9
+ <%end%>
10
+ <%else%>
11
+ ActiveScaffold.replace_html('<%=active_scaffold_messages_id%>','');
12
+ <%end%>
@@ -0,0 +1 @@
1
+ <%= render :partial => "render_field", :collection => @columns, :locals => {:source_id => @source_id, :scope => @scope} %>
@@ -2,4 +2,4 @@
2
2
  <div class="search-view <%= "#{params[:controller]}-view" %> view">
3
3
  <%= render :partial => 'search' -%>
4
4
  </div>
5
- </div>
5
+ </div>
@@ -1,14 +1,14 @@
1
- <% @column_span_id ||= element_cell_id(:id => @record.id.to_s, :action => 'update_column', :name => params[:column]) %>
1
+ <% column_span_id ||= element_cell_id(:id => @record.id.to_s, :action => 'update_column', :name => params[:column])%>
2
2
  <% unless controller.send :successful?%>
3
3
  alert('<%= escape_javascript(@record.errors.full_messages.join("\n"))%>');
4
4
  <% @record.reload%>
5
5
  <% end%>
6
6
  <% column = active_scaffold_config.columns[params[:column]]%>
7
7
  <% if column.inplace_edit%>
8
- ActiveScaffold.replace_html('<%=@column_span_id%>','<%=escape_javascript(format_inplace_edit_column(@record, column))%>');
8
+ ActiveScaffold.replace_html('<%=column_span_id%>','<%=escape_javascript(format_inplace_edit_column(@record, column))%>');
9
9
  <% else%>
10
10
  <% formatted_value = get_column_value(@record, column)%>
11
- ActiveScaffold.replace_html('<%=@column_span_id%>','<%=escape_javascript(formatted_value)%>');
11
+ ActiveScaffold.replace_html('<%=column_span_id%>','<%=escape_javascript(formatted_value)%>');
12
12
  <% end%>
13
13
  <% if column.calculation?%>
14
14
  ActiveScaffold.replace_html('<%=active_scaffold_calculations_id(column)%>', '<%=escape_javascript(render_column_calculation(column))%>');
@@ -0,0 +1 @@
1
+ ActiveScaffold.update_row('<%=element_row_id(:action => 'list', :id => @record.id)%>','<%=escape_javascript(render(:partial => 'list_record', :locals => {:record => @record}))%>');
@@ -1,22 +1,18 @@
1
- unless Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR >= 0
2
- raise "This version of ActiveScaffold requires Rails 3.0 or higher. Please use an earlier version."
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
3
  end
4
4
 
5
5
  begin
6
6
  require 'render_component'
7
7
  rescue LoadError
8
8
  end
9
- begin
10
- require 'verification'
11
- rescue LoadError
12
- end
13
9
 
14
- require 'active_scaffold_assets'
15
10
  require 'active_scaffold/active_record_permissions'
16
11
  require 'active_scaffold/paginator'
17
12
  require 'active_scaffold/responds_to_parent'
18
13
 
19
14
  require 'active_scaffold/version'
15
+ require 'active_scaffold/engine' unless defined? ACTIVE_SCAFFOLD_PLUGIN
20
16
 
21
17
  module ActiveScaffold
22
18
  autoload :AttributeParams, 'active_scaffold/attribute_params'
@@ -24,6 +20,12 @@ module ActiveScaffold
24
20
  autoload :Constraints, 'active_scaffold/constraints'
25
21
  autoload :Finder, 'active_scaffold/finder'
26
22
  autoload :MarkedModel, 'active_scaffold/marked_model'
23
+ autoload :Bridges, 'active_scaffold/bridges'
24
+
25
+ mattr_accessor :stylesheets
26
+ self.stylesheets = []
27
+ mattr_accessor :javascripts
28
+ self.javascripts = []
27
29
 
28
30
  def self.autoload_subdir(dir, mod=self, root = File.dirname(__FILE__))
29
31
  Dir["#{root}/active_scaffold/#{dir}/*.rb"].each { |file|
@@ -38,10 +40,6 @@ module ActiveScaffold
38
40
  ActiveScaffold.autoload_subdir('actions', self)
39
41
  end
40
42
 
41
- module Bridges
42
- autoload :Bridge, 'active_scaffold/bridges/bridge'
43
- end
44
-
45
43
  module Config
46
44
  ActiveScaffold.autoload_subdir('config', self)
47
45
  end
@@ -126,7 +124,11 @@ module ActiveScaffold
126
124
  end
127
125
 
128
126
  def self.js_framework
129
- @@js_framework ||= :prototype
127
+ @@js_framework ||= if defined? Jquery
128
+ :jquery
129
+ elsif defined? PrototypeRails
130
+ :prototype
131
+ end
130
132
  end
131
133
 
132
134
  # exclude bridges you do not need
@@ -150,7 +152,7 @@ module ActiveScaffold
150
152
  module ClassMethods
151
153
  def active_scaffold(model_id = nil, &block)
152
154
  # initialize bridges here
153
- ActiveScaffold::Bridges::Bridge.run_all
155
+ ActiveScaffold::Bridges.run_all
154
156
 
155
157
  # converts Foo::BarController to 'bar' and FooBarsController to 'foo_bar' and AddressController to 'address'
156
158
  model_id = self.to_s.split('::').last.sub(/Controller$/, '').pluralize.singularize.underscore unless model_id
@@ -160,12 +162,6 @@ module ActiveScaffold
160
162
  @active_scaffold_config_block = block
161
163
  self.links_for_associations
162
164
 
163
- @active_scaffold_overrides = []
164
- ActionController::Base.view_paths.each do |dir|
165
- active_scaffold_overrides_dir = File.join(dir.to_s,"active_scaffold_overrides")
166
- @active_scaffold_overrides << active_scaffold_overrides_dir if File.exists?(active_scaffold_overrides_dir)
167
- end
168
- @active_scaffold_overrides.uniq! # Fix rails duplicating some view_paths
169
165
  @active_scaffold_frontends = []
170
166
  if active_scaffold_config.frontend.to_sym != :default
171
167
  active_scaffold_custom_frontend_path = File.join(ActiveScaffold::Config::Core.plugin_directory, 'frontends', active_scaffold_config.frontend.to_s , 'views')
@@ -204,12 +200,14 @@ module ActiveScaffold
204
200
  end
205
201
  end
206
202
  end
207
- active_scaffold_paths.each do |path|
208
- self.append_view_path(ActionView::ActiveScaffoldResolver.new(path))
209
- end
203
+ self.append_view_path active_scaffold_paths
210
204
  self._add_sti_create_links if self.active_scaffold_config.add_sti_create_links?
211
205
  end
212
206
 
207
+ def parent_prefixes
208
+ @parent_prefixes ||= super << 'active_scaffold_overrides' << ''
209
+ end
210
+
213
211
  # To be called after include action modules
214
212
  def _add_sti_create_links
215
213
  new_action_link = active_scaffold_config.action_links.collection['new']
@@ -268,7 +266,7 @@ module ActiveScaffold
268
266
  column.actions_for_association_links.delete :new unless actions.include? :create
269
267
  column.actions_for_association_links.delete :edit unless actions.include? :update
270
268
  column.actions_for_association_links.delete :show unless actions.include? :show
271
- ActiveScaffold::DataStructures::ActionLink.new(nil, options.merge(:html_options => {:class => column.name}))
269
+ ActiveScaffold::DataStructures::ActionLink.new(:none, options.merge({:crud_type => nil, :html_options => {:class => column.name}}))
272
270
  end
273
271
  end
274
272
  end
@@ -285,17 +283,10 @@ module ActiveScaffold
285
283
  @active_scaffold_custom_paths << path
286
284
  end
287
285
 
288
- def add_active_scaffold_override_path(path)
289
- @active_scaffold_paths = nil # Force active_scaffold_paths to rebuild
290
- @active_scaffold_overrides.unshift path
291
- end
292
-
293
286
  def active_scaffold_paths
294
287
  return @active_scaffold_paths unless @active_scaffold_paths.nil?
295
288
 
296
- #@active_scaffold_paths = ActionView::PathSet.new
297
289
  @active_scaffold_paths = []
298
- @active_scaffold_paths.concat @active_scaffold_overrides unless @active_scaffold_overrides.nil?
299
290
  @active_scaffold_paths.concat @active_scaffold_custom_paths unless @active_scaffold_custom_paths.nil?
300
291
  @active_scaffold_paths.concat @active_scaffold_frontends unless @active_scaffold_frontends.nil?
301
292
  @active_scaffold_paths
@@ -341,7 +332,6 @@ module ActiveScaffold
341
332
  def active_scaffold_controller_for(klass)
342
333
  controller_namespace = self.to_s.split('::')[0...-1].join('::') + '::'
343
334
  error_message = []
344
- klass = klass.to_s.singularize.camelize.constantize unless klass.is_a? Class
345
335
  [controller_namespace, ''].each do |namespace|
346
336
  ["#{klass.to_s.underscore.pluralize}", "#{klass.to_s.underscore.pluralize.singularize}"].each do |controller_name|
347
337
  begin
@@ -356,7 +346,7 @@ module ActiveScaffold
356
346
  end
357
347
  end
358
348
  raise ActiveScaffold::ControllerNotFound, "#{controller} missing ActiveScaffold", caller unless controller.uses_active_scaffold?
359
- raise ActiveScaffold::ControllerNotFound, "ActiveScaffold on #{controller} is not for #{klass} model.", caller unless controller.active_scaffold_config.model == klass
349
+ raise ActiveScaffold::ControllerNotFound, "ActiveScaffold on #{controller} is not for #{klass} model.", caller unless controller.active_scaffold_config.model.to_s == klass.to_s
360
350
  return controller
361
351
  end
362
352
  end
@@ -370,17 +360,3 @@ module ActiveScaffold
370
360
  end
371
361
 
372
362
  require 'active_scaffold_env'
373
-
374
- ##
375
- ## Run the install assets script, too, just to make sure
376
- ## But at least rescue the action in production
377
- ##
378
-
379
- Rails::Application.initializer("active_scaffold.install_assets") do
380
- begin
381
- ActiveScaffoldAssets.copy_to_public(ActiveScaffold.root, {:clean_up_destination => true})
382
- rescue
383
- raise $! unless Rails.env == 'production'
384
- end
385
- end
386
-
@@ -30,24 +30,28 @@ module ActiveScaffold::Actions
30
30
 
31
31
  def render_field_for_update_columns
32
32
  column = active_scaffold_config.columns[params[:column]]
33
- @record = params[:id] && column.send_form_on_update_column ? find_if_allowed(params[:id], :update) : new_model
34
33
  unless column.nil?
34
+ @source_id = params.delete(:source_id)
35
+ @columns = column.update_columns
36
+ @scope = params[:scope]
37
+
35
38
  if column.send_form_on_update_column
36
- hash = if params[:scope]
37
- hash = params[:scope].gsub('[','').split(']').inject(params[:record]) do |hash, index|
39
+ hash = if @scope
40
+ @scope.gsub('[','').split(']').inject(params[:record]) do |hash, index|
38
41
  hash[index]
39
42
  end
40
43
  else
41
44
  params[:record]
42
45
  end
43
- @record = update_record_from_params(@record, active_scaffold_config.send(params[:id] ? :update : :create).columns, hash)
46
+ @record = hash[:id] ? find_if_allowed(hash[:id], :update) : new_model
47
+ @record = update_record_from_params(@record, active_scaffold_config.send(@scope ? :subform : (params[:id] ? :update : :create)).columns, hash)
44
48
  else
49
+ @record = new_model
45
50
  value = column_value_from_param_value(@record, column, params[:value])
46
51
  @record.send "#{column.name}=", value
47
52
  end
53
+
48
54
  after_render_field(@record, column)
49
- source_id = params.delete(:source_id)
50
- render :locals => {:source_id => source_id, :columns => column.update_columns, :scope => params[:scope]}
51
55
  end
52
56
  end
53
57
 
@@ -66,6 +70,10 @@ module ActiveScaffold::Actions
66
70
  end
67
71
  end
68
72
 
73
+ def marked_records
74
+ active_scaffold_session_storage[:marked_records] ||= Set.new
75
+ end
76
+
69
77
  def default_formats
70
78
  [:html, :js, :json, :xml, :yaml]
71
79
  end
@@ -36,8 +36,8 @@ module ActiveScaffold::Actions
36
36
  @scope = params[:scope]
37
37
 
38
38
  if column.send_form_on_update_column
39
- hash = if @scope
40
- @scope.gsub('[','').split(']').inject(params[:record]) do |hash, index|
39
+ hash = if params[:scope]
40
+ params[:scope].gsub('[','').split(']').inject(params[:record]) do |hash, index|
41
41
  hash[index]
42
42
  end
43
43
  else
@@ -165,7 +165,7 @@ module ActiveScaffold::Actions
165
165
  params = params[:record] || {} unless params[model.inheritance_column] # in create action must be inside record key
166
166
  model = params.delete(model.inheritance_column).camelize.constantize if params[model.inheritance_column]
167
167
  end
168
- model.new(build_options || {})
168
+ model.respond_to?(:build) ? model.build(build_options || {}) : model.new
169
169
  end
170
170
 
171
171
  private
@@ -2,9 +2,6 @@ module ActiveScaffold::Actions
2
2
  module Create
3
3
  def self.included(base)
4
4
  base.before_filter :create_authorized_filter, :only => [:new, :create]
5
- base.verify :method => :post,
6
- :only => :create,
7
- :redirect_to => { :action => :index }
8
5
  end
9
6
 
10
7
  def new
@@ -42,8 +39,8 @@ module ActiveScaffold::Actions
42
39
  else
43
40
  if successful?
44
41
  flash[:info] = as_(:created_model, :model => @record.to_label)
45
- if active_scaffold_config.create.action_after_create
46
- redirect_to params_for(:action => "edit", :id => @record.id)
42
+ if action = active_scaffold_config.create.action_after_create
43
+ redirect_to params_for(:action => action, :id => @record.id)
47
44
  elsif active_scaffold_config.create.persistent
48
45
  redirect_to params_for(:action => "new")
49
46
  else
@@ -2,6 +2,9 @@ module ActiveScaffold::Actions
2
2
  module Create
3
3
  def self.included(base)
4
4
  base.before_filter :create_authorized_filter, :only => [:new, :create]
5
+ base.verify :method => :post,
6
+ :only => :create,
7
+ :redirect_to => { :action => :index }
5
8
  end
6
9
 
7
10
  def new
@@ -103,8 +106,6 @@ module ActiveScaffold::Actions
103
106
  create_save
104
107
  end
105
108
  rescue ActiveRecord::RecordInvalid
106
- self.successful = false
107
- flash[:error] = $!.messages
108
109
  end
109
110
  end
110
111
 
@@ -52,6 +52,7 @@ module ActiveScaffold::Actions
52
52
  @record ||= destroy_find_record
53
53
  begin
54
54
  self.successful = @record.destroy
55
+ marked_records.delete @record.id.to_s if successful?
55
56
  rescue
56
57
  flash[:warning] = as_(:cant_destroy_record, :record => @record.to_label)
57
58
  self.successful = false
@@ -42,7 +42,7 @@ module ActiveScaffold::Actions
42
42
  end
43
43
 
44
44
  def do_search
45
- unless search_params.nil?
45
+ unless search_params.blank?
46
46
  text_search = active_scaffold_config.field_search.text_search
47
47
  search_conditions = []
48
48
  human_condition_columns = [] if active_scaffold_config.field_search.human_conditions
@@ -55,14 +55,15 @@ module ActiveScaffold::Actions
55
55
  render(:partial => 'row', :locals => {:record => @record})
56
56
  end
57
57
 
58
- def row_respond_to_js
59
- render(:partial => 'row', :locals => {:record => @record})
58
+ # The actual algorithm to prepare for the list view
59
+ def set_includes_for_list_columns
60
+ includes_for_list_columns = active_scaffold_config.list.columns.collect{ |c| c.includes }.flatten.uniq.compact
61
+ self.active_scaffold_includes.concat includes_for_list_columns
60
62
  end
61
63
 
62
64
  # The actual algorithm to prepare for the list view
63
65
  def do_list
64
- includes_for_list_columns = active_scaffold_config.list.columns.collect{ |c| c.includes }.flatten.uniq.compact
65
- self.active_scaffold_includes.concat includes_for_list_columns
66
+ set_includes_for_list_columns
66
67
 
67
68
  options = { :sorting => active_scaffold_config.list.user.sorting,
68
69
  :count_includes => active_scaffold_config.list.user.count_includes }
@@ -75,7 +76,7 @@ module ActiveScaffold::Actions
75
76
  })
76
77
  end
77
78
 
78
- page = find_page(options);
79
+ page = find_page(options)
79
80
  if page.items.blank? && !page.pager.infinite?
80
81
  page = page.pager.last
81
82
  active_scaffold_config.list.user.page = page.number
@@ -173,7 +174,10 @@ module ActiveScaffold::Actions
173
174
  (default_formats + active_scaffold_config.formats + active_scaffold_config.list.formats).uniq
174
175
  end
175
176
  alias_method :index_formats, :list_formats
176
- alias_method :row_formats, :list_formats
177
+
178
+ def row_formats
179
+ ([:html] + active_scaffold_config.formats + active_scaffold_config.list.formats).uniq
180
+ end
177
181
 
178
182
  def action_update_formats
179
183
  (default_formats + active_scaffold_config.formats).uniq