active_scaffold_vho 3.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (279) hide show
  1. data/.autotest +27 -0
  2. data/.document +5 -0
  3. data/CHANGELOG +179 -0
  4. data/Gemfile +13 -0
  5. data/Gemfile.lock +20 -0
  6. data/MIT-LICENSE +20 -0
  7. data/README +63 -0
  8. data/Rakefile +53 -0
  9. data/frontends/default/images/add.gif +0 -0
  10. data/frontends/default/images/arrow_down.gif +0 -0
  11. data/frontends/default/images/arrow_up.gif +0 -0
  12. data/frontends/default/images/close.gif +0 -0
  13. data/frontends/default/images/config.png +0 -0
  14. data/frontends/default/images/cross.png +0 -0
  15. data/frontends/default/images/gears.png +0 -0
  16. data/frontends/default/images/indicator-small.gif +0 -0
  17. data/frontends/default/images/indicator.gif +0 -0
  18. data/frontends/default/images/magnifier.png +0 -0
  19. data/frontends/default/javascripts/jquery/active_scaffold.js +957 -0
  20. data/frontends/default/javascripts/jquery/jquery.editinplace.js +743 -0
  21. data/frontends/default/javascripts/prototype/active_scaffold.js +957 -0
  22. data/frontends/default/javascripts/prototype/dhtml_history.js +867 -0
  23. data/frontends/default/javascripts/prototype/form_enhancements.js +117 -0
  24. data/frontends/default/javascripts/prototype/rico_corner.js +370 -0
  25. data/frontends/default/stylesheets/stylesheet-ie.css +35 -0
  26. data/frontends/default/stylesheets/stylesheet.css +964 -0
  27. data/frontends/default/views/_action_group.html.erb +20 -0
  28. data/frontends/default/views/_add_existing_form.html.erb +30 -0
  29. data/frontends/default/views/_base_form.html.erb +45 -0
  30. data/frontends/default/views/_create_form.html.erb +8 -0
  31. data/frontends/default/views/_create_form_on_list.html.erb +6 -0
  32. data/frontends/default/views/_field_search.html.erb +32 -0
  33. data/frontends/default/views/_form.html.erb +24 -0
  34. data/frontends/default/views/_form_association.html.erb +14 -0
  35. data/frontends/default/views/_form_association_footer.html.erb +40 -0
  36. data/frontends/default/views/_form_attribute.html.erb +15 -0
  37. data/frontends/default/views/_form_hidden_attribute.html.erb +2 -0
  38. data/frontends/default/views/_form_messages.html.erb +5 -0
  39. data/frontends/default/views/_horizontal_subform.html.erb +19 -0
  40. data/frontends/default/views/_horizontal_subform_header.html.erb +10 -0
  41. data/frontends/default/views/_horizontal_subform_record.html.erb +37 -0
  42. data/frontends/default/views/_human_conditions.html.erb +1 -0
  43. data/frontends/default/views/_list.html.erb +18 -0
  44. data/frontends/default/views/_list_actions.html.erb +15 -0
  45. data/frontends/default/views/_list_calculations.html.erb +16 -0
  46. data/frontends/default/views/_list_column_headings.html.erb +12 -0
  47. data/frontends/default/views/_list_header.html.erb +10 -0
  48. data/frontends/default/views/_list_inline_adapter.html.erb +10 -0
  49. data/frontends/default/views/_list_messages.html.erb +32 -0
  50. data/frontends/default/views/_list_pagination.html.erb +11 -0
  51. data/frontends/default/views/_list_pagination_links.html.erb +9 -0
  52. data/frontends/default/views/_list_record.html.erb +14 -0
  53. data/frontends/default/views/_list_record_columns.html.erb +8 -0
  54. data/frontends/default/views/_list_with_header.html.erb +32 -0
  55. data/frontends/default/views/_messages.html.erb +10 -0
  56. data/frontends/default/views/_render_field.js.rjs +13 -0
  57. data/frontends/default/views/_row.html.erb +12 -0
  58. data/frontends/default/views/_search.html.erb +34 -0
  59. data/frontends/default/views/_search_attribute.html.erb +10 -0
  60. data/frontends/default/views/_show.html.erb +8 -0
  61. data/frontends/default/views/_show_columns.html.erb +15 -0
  62. data/frontends/default/views/_update_actions.html.erb +9 -0
  63. data/frontends/default/views/_update_form.html.erb +6 -0
  64. data/frontends/default/views/_vertical_subform.html.erb +12 -0
  65. data/frontends/default/views/_vertical_subform_record.html.erb +38 -0
  66. data/frontends/default/views/action_confirmation.html.erb +13 -0
  67. data/frontends/default/views/add_existing.js.rjs +17 -0
  68. data/frontends/default/views/add_existing_form.html.erb +5 -0
  69. data/frontends/default/views/create.html.erb +5 -0
  70. data/frontends/default/views/delete.html.erb +13 -0
  71. data/frontends/default/views/destroy.js.rjs +11 -0
  72. data/frontends/default/views/edit_associated.js.rjs +11 -0
  73. data/frontends/default/views/field_search.html.erb +5 -0
  74. data/frontends/default/views/form_messages.js.rjs +1 -0
  75. data/frontends/default/views/list.html.erb +1 -0
  76. data/frontends/default/views/list.js.rjs +1 -0
  77. data/frontends/default/views/on_action_update.js.rjs +8 -0
  78. data/frontends/default/views/on_create.js.rjs +41 -0
  79. data/frontends/default/views/on_update.js.rjs +28 -0
  80. data/frontends/default/views/search.html.erb +5 -0
  81. data/frontends/default/views/show.html.erb +5 -0
  82. data/frontends/default/views/update.html.erb +8 -0
  83. data/frontends/default/views/update_column.js.rjs +13 -0
  84. data/frontends/default/views/update_row.js.rjs +1 -0
  85. data/init.rb +9 -0
  86. data/lib/active_record_permissions.rb +134 -0
  87. data/lib/active_scaffold/actions/common_search.rb +22 -0
  88. data/lib/active_scaffold/actions/core.rb +170 -0
  89. data/lib/active_scaffold/actions/create.rb +145 -0
  90. data/lib/active_scaffold/actions/delete.rb +75 -0
  91. data/lib/active_scaffold/actions/field_search.rb +82 -0
  92. data/lib/active_scaffold/actions/list.rb +184 -0
  93. data/lib/active_scaffold/actions/mark.rb +50 -0
  94. data/lib/active_scaffold/actions/nested.rb +250 -0
  95. data/lib/active_scaffold/actions/search.rb +47 -0
  96. data/lib/active_scaffold/actions/show.rb +61 -0
  97. data/lib/active_scaffold/actions/subform.rb +17 -0
  98. data/lib/active_scaffold/actions/update.rb +141 -0
  99. data/lib/active_scaffold/attribute_params.rb +207 -0
  100. data/lib/active_scaffold/bridges/ancestry/bridge.rb +5 -0
  101. data/lib/active_scaffold/bridges/ancestry/lib/ancestry_bridge.rb +39 -0
  102. data/lib/active_scaffold/bridges/bridge.rb +52 -0
  103. data/lib/active_scaffold/bridges/calendar_date_select/bridge.rb +16 -0
  104. data/lib/active_scaffold/bridges/calendar_date_select/lib/as_cds_bridge.rb +79 -0
  105. data/lib/active_scaffold/bridges/carrierwave/bridge.rb +7 -0
  106. data/lib/active_scaffold/bridges/carrierwave/lib/carrierwave_bridge.rb +38 -0
  107. data/lib/active_scaffold/bridges/carrierwave/lib/carrierwave_bridge_helpers.rb +26 -0
  108. data/lib/active_scaffold/bridges/carrierwave/lib/form_ui.rb +35 -0
  109. data/lib/active_scaffold/bridges/carrierwave/lib/list_ui.rb +17 -0
  110. data/lib/active_scaffold/bridges/date_picker/bridge.rb +22 -0
  111. data/lib/active_scaffold/bridges/date_picker/lib/datepicker_bridge.rb +225 -0
  112. data/lib/active_scaffold/bridges/date_picker/public/javascripts/date_picker_bridge.js +22 -0
  113. data/lib/active_scaffold/bridges/file_column/bridge.rb +11 -0
  114. data/lib/active_scaffold/bridges/file_column/lib/as_file_column_bridge.rb +46 -0
  115. data/lib/active_scaffold/bridges/file_column/lib/file_column_helpers.rb +59 -0
  116. data/lib/active_scaffold/bridges/file_column/lib/form_ui.rb +37 -0
  117. data/lib/active_scaffold/bridges/file_column/lib/list_ui.rb +26 -0
  118. data/lib/active_scaffold/bridges/file_column/test/functional/file_column_keep_test.rb +43 -0
  119. data/lib/active_scaffold/bridges/file_column/test/mock_model.rb +9 -0
  120. data/lib/active_scaffold/bridges/file_column/test/test_helper.rb +15 -0
  121. data/lib/active_scaffold/bridges/paperclip/bridge.rb +10 -0
  122. data/lib/active_scaffold/bridges/paperclip/lib/form_ui.rb +27 -0
  123. data/lib/active_scaffold/bridges/paperclip/lib/list_ui.rb +16 -0
  124. data/lib/active_scaffold/bridges/paperclip/lib/paperclip_bridge.rb +38 -0
  125. data/lib/active_scaffold/bridges/paperclip/lib/paperclip_bridge_helpers.rb +26 -0
  126. data/lib/active_scaffold/bridges/semantic_attributes/bridge.rb +5 -0
  127. data/lib/active_scaffold/bridges/semantic_attributes/lib/semantic_attributes_bridge.rb +20 -0
  128. data/lib/active_scaffold/bridges/shared/date_bridge.rb +187 -0
  129. data/lib/active_scaffold/bridges/tiny_mce/bridge.rb +5 -0
  130. data/lib/active_scaffold/bridges/tiny_mce/lib/tiny_mce_bridge.rb +45 -0
  131. data/lib/active_scaffold/bridges/validation_reflection/bridge.rb +8 -0
  132. data/lib/active_scaffold/bridges/validation_reflection/lib/validation_reflection_bridge.rb +21 -0
  133. data/lib/active_scaffold/config/base.rb +62 -0
  134. data/lib/active_scaffold/config/core.rb +220 -0
  135. data/lib/active_scaffold/config/create.rb +51 -0
  136. data/lib/active_scaffold/config/delete.rb +34 -0
  137. data/lib/active_scaffold/config/field_search.rb +75 -0
  138. data/lib/active_scaffold/config/form.rb +47 -0
  139. data/lib/active_scaffold/config/list.rb +174 -0
  140. data/lib/active_scaffold/config/mark.rb +22 -0
  141. data/lib/active_scaffold/config/nested.rb +44 -0
  142. data/lib/active_scaffold/config/search.rb +69 -0
  143. data/lib/active_scaffold/config/show.rb +35 -0
  144. data/lib/active_scaffold/config/subform.rb +35 -0
  145. data/lib/active_scaffold/config/update.rb +46 -0
  146. data/lib/active_scaffold/configurable.rb +29 -0
  147. data/lib/active_scaffold/constraints.rb +184 -0
  148. data/lib/active_scaffold/data_structures/action_columns.rb +133 -0
  149. data/lib/active_scaffold/data_structures/action_link.rb +171 -0
  150. data/lib/active_scaffold/data_structures/action_links.rb +175 -0
  151. data/lib/active_scaffold/data_structures/actions.rb +45 -0
  152. data/lib/active_scaffold/data_structures/column.rb +351 -0
  153. data/lib/active_scaffold/data_structures/columns.rb +75 -0
  154. data/lib/active_scaffold/data_structures/error_message.rb +24 -0
  155. data/lib/active_scaffold/data_structures/nested_info.rb +123 -0
  156. data/lib/active_scaffold/data_structures/set.rb +62 -0
  157. data/lib/active_scaffold/data_structures/sorting.rb +168 -0
  158. data/lib/active_scaffold/finder.rb +333 -0
  159. data/lib/active_scaffold/helpers/association_helpers.rb +40 -0
  160. data/lib/active_scaffold/helpers/controller_helpers.rb +82 -0
  161. data/lib/active_scaffold/helpers/country_helpers.rb +352 -0
  162. data/lib/active_scaffold/helpers/form_column_helpers.rb +347 -0
  163. data/lib/active_scaffold/helpers/human_condition_helpers.rb +59 -0
  164. data/lib/active_scaffold/helpers/id_helpers.rb +127 -0
  165. data/lib/active_scaffold/helpers/list_column_helpers.rb +361 -0
  166. data/lib/active_scaffold/helpers/pagination_helpers.rb +55 -0
  167. data/lib/active_scaffold/helpers/search_column_helpers.rb +243 -0
  168. data/lib/active_scaffold/helpers/show_column_helpers.rb +46 -0
  169. data/lib/active_scaffold/helpers/view_helpers.rb +356 -0
  170. data/lib/active_scaffold/locale/de.rb +120 -0
  171. data/lib/active_scaffold/locale/en.rb +119 -0
  172. data/lib/active_scaffold/locale/es.yml +115 -0
  173. data/lib/active_scaffold/locale/fr.rb +116 -0
  174. data/lib/active_scaffold/locale/hu.yml +63 -0
  175. data/lib/active_scaffold/locale/ja.yml +64 -0
  176. data/lib/active_scaffold/locale/ru.yml +119 -0
  177. data/lib/active_scaffold/marked_model.rb +38 -0
  178. data/lib/active_scaffold/version.rb +9 -0
  179. data/lib/active_scaffold.rb +345 -0
  180. data/lib/active_scaffold_assets.rb +45 -0
  181. data/lib/dhtml_confirm.rb +54 -0
  182. data/lib/environment.rb +14 -0
  183. data/lib/extensions/action_controller_rendering.rb +20 -0
  184. data/lib/extensions/action_view_rendering.rb +113 -0
  185. data/lib/extensions/action_view_resolver.rb +7 -0
  186. data/lib/extensions/active_association_reflection.rb +13 -0
  187. data/lib/extensions/active_record_offset.rb +12 -0
  188. data/lib/extensions/array.rb +7 -0
  189. data/lib/extensions/localize.rb +10 -0
  190. data/lib/extensions/name_option_for_datetime.rb +12 -0
  191. data/lib/extensions/nil_id_in_url_params.rb +7 -0
  192. data/lib/extensions/paginator_extensions.rb +26 -0
  193. data/lib/extensions/reverse_associations.rb +62 -0
  194. data/lib/extensions/routing_mapper.rb +34 -0
  195. data/lib/extensions/to_label.rb +8 -0
  196. data/lib/extensions/unsaved_associated.rb +61 -0
  197. data/lib/extensions/unsaved_record.rb +20 -0
  198. data/lib/extensions/usa_state.rb +46 -0
  199. data/lib/generators/active_scaffold/USAGE +29 -0
  200. data/lib/generators/active_scaffold/active_scaffold_generator.rb +20 -0
  201. data/lib/generators/active_scaffold_controller/USAGE +19 -0
  202. data/lib/generators/active_scaffold_controller/active_scaffold_controller_generator.rb +28 -0
  203. data/lib/generators/active_scaffold_controller/templates/controller.rb +4 -0
  204. data/lib/generators/active_scaffold_setup/USAGE +10 -0
  205. data/lib/generators/active_scaffold_setup/active_scaffold_setup_generator.rb +53 -0
  206. data/lib/paginator.rb +136 -0
  207. data/lib/responds_to_parent.rb +70 -0
  208. data/public/blank.html +33 -0
  209. data/shoulda_macros/macros.rb +136 -0
  210. data/test/bridges/bridge_test.rb +47 -0
  211. data/test/config/base_test.rb +15 -0
  212. data/test/config/create_test.rb +55 -0
  213. data/test/config/list_test.rb +74 -0
  214. data/test/config/show_test.rb +43 -0
  215. data/test/config/update_test.rb +17 -0
  216. data/test/const_mocker.rb +36 -0
  217. data/test/data_structures/action_columns_test.rb +113 -0
  218. data/test/data_structures/action_link_test.rb +78 -0
  219. data/test/data_structures/action_links_test.rb +78 -0
  220. data/test/data_structures/actions_test.rb +25 -0
  221. data/test/data_structures/association_column_test.rb +42 -0
  222. data/test/data_structures/column_test.rb +185 -0
  223. data/test/data_structures/columns_test.rb +69 -0
  224. data/test/data_structures/error_message_test.rb +28 -0
  225. data/test/data_structures/set_test.rb +86 -0
  226. data/test/data_structures/sorting_test.rb +126 -0
  227. data/test/data_structures/standard_column_test.rb +24 -0
  228. data/test/data_structures/virtual_column_test.rb +23 -0
  229. data/test/extensions/active_record_test.rb +45 -0
  230. data/test/extensions/array_test.rb +12 -0
  231. data/test/helpers/form_column_helpers_test.rb +31 -0
  232. data/test/helpers/list_column_helpers_test.rb +31 -0
  233. data/test/helpers/pagination_helpers_test.rb +55 -0
  234. data/test/misc/active_record_permissions_test.rb +154 -0
  235. data/test/misc/attribute_params_test.rb +110 -0
  236. data/test/misc/configurable_test.rb +96 -0
  237. data/test/misc/constraints_test.rb +193 -0
  238. data/test/misc/finder_test.rb +93 -0
  239. data/test/misc/lang_test.rb +12 -0
  240. data/test/mock_app/.gitignore +2 -0
  241. data/test/mock_app/app/controllers/application_controller.rb +10 -0
  242. data/test/mock_app/app/helpers/application_helper.rb +3 -0
  243. data/test/mock_app/config/boot.rb +110 -0
  244. data/test/mock_app/config/database.yml +16 -0
  245. data/test/mock_app/config/environment.rb +43 -0
  246. data/test/mock_app/config/environments/development.rb +17 -0
  247. data/test/mock_app/config/environments/production.rb +28 -0
  248. data/test/mock_app/config/environments/test.rb +28 -0
  249. data/test/mock_app/config/initializers/backtrace_silencers.rb +7 -0
  250. data/test/mock_app/config/initializers/inflections.rb +10 -0
  251. data/test/mock_app/config/initializers/mime_types.rb +5 -0
  252. data/test/mock_app/config/initializers/new_rails_defaults.rb +19 -0
  253. data/test/mock_app/config/initializers/session_store.rb +15 -0
  254. data/test/mock_app/config/locales/en.yml +5 -0
  255. data/test/mock_app/config/routes.rb +43 -0
  256. data/test/mock_app/db/test.sqlite3 +1 -0
  257. data/test/mock_app/public/blank.html +33 -0
  258. data/test/mock_app/public/images/active_scaffold/DO_NOT_EDIT +2 -0
  259. data/test/mock_app/public/images/active_scaffold/default/add.gif +0 -0
  260. data/test/mock_app/public/images/active_scaffold/default/arrow_down.gif +0 -0
  261. data/test/mock_app/public/images/active_scaffold/default/arrow_up.gif +0 -0
  262. data/test/mock_app/public/images/active_scaffold/default/close.gif +0 -0
  263. data/test/mock_app/public/images/active_scaffold/default/cross.png +0 -0
  264. data/test/mock_app/public/images/active_scaffold/default/indicator-small.gif +0 -0
  265. data/test/mock_app/public/images/active_scaffold/default/indicator.gif +0 -0
  266. data/test/mock_app/public/images/active_scaffold/default/magnifier.png +0 -0
  267. data/test/mock_app/public/javascripts/active_scaffold/DO_NOT_EDIT +2 -0
  268. data/test/mock_app/public/javascripts/active_scaffold/default/active_scaffold.js +532 -0
  269. data/test/mock_app/public/javascripts/active_scaffold/default/dhtml_history.js +867 -0
  270. data/test/mock_app/public/javascripts/active_scaffold/default/form_enhancements.js +117 -0
  271. data/test/mock_app/public/javascripts/active_scaffold/default/rico_corner.js +370 -0
  272. data/test/mock_app/public/stylesheets/active_scaffold/DO_NOT_EDIT +2 -0
  273. data/test/mock_app/public/stylesheets/active_scaffold/default/stylesheet-ie.css +35 -0
  274. data/test/mock_app/public/stylesheets/active_scaffold/default/stylesheet.css +839 -0
  275. data/test/model_stub.rb +55 -0
  276. data/test/run_all.rb +8 -0
  277. data/test/test_helper.rb +39 -0
  278. data/uninstall.rb +13 -0
  279. metadata +492 -0
@@ -0,0 +1,8 @@
1
+ <h4><%= active_scaffold_config.show.label -%></h4>
2
+
3
+ <%= render :partial => 'show_columns', :locals => {:columns => active_scaffold_config.show.columns} -%>
4
+
5
+ <p class="form-footer">
6
+ <%= link_to as_(:close), main_path_to_return, :class => 'as_cancel', :remote => request.xhr?, 'data-refresh' => false %>
7
+ <%= loading_indicator_tag(:action => :create, :id => params[:id]) %>
8
+ </p>
@@ -0,0 +1,15 @@
1
+ <dl>
2
+ <% columns.each :for => @record do |column| %>
3
+ <dt><%= column.label -%></dt>
4
+ <% if column.is_a? ActiveScaffold::DataStructures::ActionColumns -%>
5
+ <dd>
6
+ <%= render :partial => 'show_columns', :locals => {:columns => column} %>
7
+ <% else -%>
8
+ <% css_class = "#{column.name}-view"
9
+ css_class.concat(" #{column.css_class}") unless column.css_class.nil? %>
10
+ <dd class="<%= css_class.strip %>">
11
+ <%= show_column_value(@record, column) -%> &nbsp;
12
+ <% end -%>
13
+ </dd>
14
+ <% end -%>
15
+ </dl>
@@ -0,0 +1,9 @@
1
+ <div class="active-scaffold-header">
2
+ <div class="actions">
3
+ <% active_scaffold_config.action_links.member.each do |link| -%>
4
+ <% next unless link.action == 'nested' -%>
5
+ <% next if skip_action_link(link) -%>
6
+ <%= record.authorized_for?(:crud_type => link.crud_type, :action => link.action) ? render_action_link(link, url_options, record) : "<a class='disabled'>#{link.label}</a>" -%>
7
+ <% end -%>
8
+ </div>
9
+ </div>
@@ -0,0 +1,6 @@
1
+ <% cancel_link = true if cancel_link.nil? %>
2
+ <%= render :partial => "base_form", :locals => {:xhr => xhr ||= nil,
3
+ :form_action => form_action ||= :update,
4
+ :method => method ||= :put,
5
+ :cancel_link => cancel_link,
6
+ :headline => headline ||= @record.to_label.nil? ? active_scaffold_config.update.label : as_(:update_model, :model => clean_column_value(@record.to_label))} %>
@@ -0,0 +1,12 @@
1
+ <div id="<%= sub_form_list_id(:association => column.name) %>">
2
+ <% associated.each_index do |index| %>
3
+ <% @record = associated[index] -%>
4
+ <% if @record.errors.count -%>
5
+ <div class="association-record-errors" id="<%= element_messages_id :action => @record.class.name.underscore, :id => "#{parent_record.id}-#{index}" %>">
6
+ <%= active_scaffold_error_messages_for :record, :object_name => @record.class.model_name.human.downcase %>
7
+ </div>
8
+ <% end %>
9
+ <%= render :partial => 'vertical_subform_record', :locals => {:scope => column_scope(column), :parent_record => parent_record, :column => column, :locked => @record.new_record? && @record == associated.last} %>
10
+ <% end -%>
11
+ </div>
12
+ <%= render :partial => 'form_association_footer', :locals => {:parent_record => parent_record, :column => column, :associated => associated} -%>
@@ -0,0 +1,38 @@
1
+ <%
2
+ record_column = column
3
+ readonly = (@record.readonly? or not @record.authorized_for?(:crud_type => :update))
4
+ crud_type = @record.new_record? ? :create : (readonly ? :read : nil)
5
+ show_actions = false
6
+ config = active_scaffold_config_for(@record.class)
7
+ options = active_scaffold_input_options(config.columns[@record.class.primary_key], scope)
8
+ tr_id = "association-#{options[:id]}"
9
+ -%>
10
+ <ol id="<%= tr_id %>" class="association-record <%= 'association-record-new' if @record.new_record? -%> <%= 'locked' if locked -%>">
11
+ <% config.subform.columns.each :for => @record, :crud_type => crud_type, :flatten => true do |column| %>
12
+ <%
13
+ next unless in_subform?(column, parent_record)
14
+ show_actions = true
15
+ column = column.clone
16
+ column.form_ui ||= :select if column.association
17
+ -%>
18
+ <li class="form-element <%= 'required' if column.required? %> <%= column.css_class unless column.css_class.nil? %>">
19
+ <% unless readonly -%>
20
+ <%= render :partial => form_partial_for_column(column), :locals => { :column => column, :scope => scope } -%>
21
+ <% else -%>
22
+ <p><%= get_column_value(@record, column) -%></p>
23
+ <% end -%>
24
+ </li>
25
+ <% end -%>
26
+ <% if show_actions -%>
27
+ <li class="actions">
28
+ <% if record_column.plural_association? and (@record.authorized_for?(:crud_type => :delete) or not [:destroy, :delete_all].include?(record_column.association.options[:dependent])) %>
29
+ <% destroy_id = "#{options[:id]}-destroy" %>
30
+ <%= link_to as_(:remove), '#', :class => 'destroy', :id => destroy_id , :onclick => "ActiveScaffold.remove(\"#{tr_id}\"); return false;", :style=> "display: none;" %>
31
+ <%= javascript_tag("ActiveScaffold.show('#{destroy_id}');") if !locked %>
32
+ <% end %>
33
+ <% unless @record.new_record? %>
34
+ <input type="hidden" name="<%= options[:name] -%>" id="<%= options[:id] -%>" value="<%= @record.id -%>" />
35
+ <% end -%>
36
+ </li>
37
+ <% end -%>
38
+ </ol>
@@ -0,0 +1,13 @@
1
+ <div class="active-scaffold">
2
+ <div class="delete-view view">
3
+ <%= form_tag params_for(:action => link.action, :id => params[:id]), { :method => link.method } %>
4
+ <h4><%= link.confirm(record.try(:to_label)) -%></h4>
5
+
6
+ <p class="form-footer">
7
+ <%= submit_tag as_(link.label), :class => 'submit' %>
8
+ <%= link_to as_(:cancel), main_path_to_return, :class => 'cancel' %>
9
+ </p>
10
+
11
+ </form>
12
+ </div>
13
+ </div>
@@ -0,0 +1,17 @@
1
+ new_row = render :partial => 'list_record', :locals => {:record => @record}
2
+ page << "ActiveScaffold.create_record_row('#{active_scaffold_id}','#{escape_javascript(new_row)}', #{{:insert_at => :top}.to_json});"
3
+ page.call 'ActiveScaffold.replace', active_scaffold_calculations_id, render(:partial => 'list_calculations') if active_scaffold_config.list.columns.any? {|c| c.calculation?}
4
+
5
+ if (form_stays_open = true)
6
+ # why not just re-render the form? that wouldn't utilize a possible do_new override which sets default values.
7
+ page.call 'ActiveScaffold.reset_form', element_form_id
8
+ page.call 'ActiveScaffold.replace_html', element_messages_id(:action => :add_existing), render(:partial => 'form_messages')
9
+ # have to delay the focus, because there's no "firstElement" in prototype until at least one element is not disabled
10
+ if ActiveScaffold.js_framework == :prototype
11
+ page.delay 0.1 do
12
+ page << "ActiveScaffold.focus_first_element_of_form('#{element_form_id}');"
13
+ end
14
+ end
15
+ else
16
+ page << "ActiveScaffold.find_action_link('#{element_form_id(:action => :new_existing)}').close();"
17
+ end
@@ -0,0 +1,5 @@
1
+ <div class="active-scaffold">
2
+ <div class="create-view <%= "#{params[:controller]}-view" %> view">
3
+ <%= render :partial => 'add_existing_form' -%>
4
+ </div>
5
+ </div>
@@ -0,0 +1,5 @@
1
+ <div class="active-scaffold">
2
+ <div class="create-view <%= "#{params[:controller]}-view" %> view">
3
+ <%= render :partial => 'create_form' -%>
4
+ </div>
5
+ </div>
@@ -0,0 +1,13 @@
1
+ <div class="active-scaffold">
2
+ <div class="delete-view view">
3
+ <%= form_tag params_for(:action => :destroy, :id => params[:id]), { :method => :delete } %>
4
+ <h4><%= as_(:are_you_sure_to_delete, :label => @record.try(:to_label)) -%></h4>
5
+
6
+ <p class="form-footer">
7
+ <%= submit_tag as_(:delete), :class => 'submit' %>
8
+ <%= link_to as_(:cancel), main_path_to_return, :class => 'cancel' %>
9
+ </p>
10
+
11
+ </form>
12
+ </div>
13
+ </div>
@@ -0,0 +1,11 @@
1
+ if controller.send(:successful?)
2
+ if (active_scaffold_config.delete.refresh_list)
3
+ page.call 'ActiveScaffold.replace_html', active_scaffold_content_id, render(:partial => 'list', :layout => false)
4
+ else
5
+ page << "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))}');"
6
+ page.call 'ActiveScaffold.replace', active_scaffold_calculations_id, render(:partial => 'list_calculations') if active_scaffold_config.list.columns.any? {|c| c.calculation?}
7
+ end
8
+ else
9
+ 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)
10
+ end
11
+ page.call 'ActiveScaffold.replace_html', active_scaffold_messages_id, render(:partial => 'messages')
@@ -0,0 +1,11 @@
1
+ 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
+ options = {:singular => false}
3
+ if @column.singular_association?
4
+ options[:singular] = true
5
+ else
6
+ unless @record.new_record?
7
+ column = active_scaffold_config_for(@record.class).columns[@record.class.primary_key]
8
+ options[:id] = active_scaffold_input_options(column, @scope)[:id]
9
+ end
10
+ end
11
+ page.call 'ActiveScaffold.create_associated_record_form', sub_form_list_id(:association => @column.name), associated_form, options
@@ -0,0 +1,5 @@
1
+ <div class="active-scaffold">
2
+ <div class="search-view view">
3
+ <%= render :partial => 'field_search' -%>
4
+ </div>
5
+ </div>
@@ -0,0 +1 @@
1
+ page.replace_html element_messages_id, :partial => 'form_messages'
@@ -0,0 +1 @@
1
+ <%= render :partial => 'list_with_header' -%>
@@ -0,0 +1 @@
1
+ page.call 'ActiveScaffold.replace_html', active_scaffold_content_id, render(:partial => 'list', :layout => false)
@@ -0,0 +1,8 @@
1
+ page.call 'ActiveScaffold.replace_html', active_scaffold_messages_id, render(:partial => 'messages')
2
+ if controller.send :successful?
3
+ page.call 'ActiveScaffold.update_row', element_row_id(:action => :list, :id => @record.id), render(:partial => 'list_record', :locals => {:record => @record}) if @record
4
+ page.call 'ActiveScaffold.replace', active_scaffold_calculations_id, render(:partial => 'list_calculations') if active_scaffold_config.list.columns.any? {|c| c.calculation?}
5
+ else
6
+ page.call 'ActiveScaffold.scroll_to', active_scaffold_messages_id
7
+ end
8
+
@@ -0,0 +1,41 @@
1
+ form_selector = "#{element_form_id(:action => :create)}"
2
+ insert_at ||= :top
3
+ page << "var action_link = ActiveScaffold.find_action_link('#{form_selector}');"
4
+ page << "action_link.update_flash_messages('#{escape_javascript(render(:partial => 'messages').strip)}');"
5
+ if controller.send :successful?
6
+ if render_parent? && respond_to?(:render_component)
7
+ parent_rendered = render_component(render_parent_options)
8
+ if nested?
9
+ page << "action_link.close('#{escape_javascript(parent_rendered)}');"
10
+ else
11
+ if render_parent_action == :row
12
+ page << "ActiveScaffold.create_record_row(action_link.scaffold(),'#{escape_javascript(parent_rendered)}', #{{:insert_at => insert_at}.to_json});"
13
+ elsif render_parent_action == :index
14
+ page << parent_rendered
15
+ end
16
+ page << "action_link.close();"
17
+ end
18
+ #page.call 'ActiveScaffold.replace', active_scaffold_calculations_id, render(:partial => 'list_calculations') if active_scaffold_config.list.columns.any? {|c| c.calculation?}
19
+ elsif (active_scaffold_config.create.refresh_list)
20
+ page.call 'ActiveScaffold.replace_html', active_scaffold_content_id, render(:partial => 'list', :layout => false)
21
+ elsif params[:parent_controller].nil?
22
+ new_row = render :partial => 'list_record', :locals => {:record => @record}
23
+ page << "ActiveScaffold.create_record_row(action_link.scaffold(),'#{escape_javascript(new_row)}', #{{:insert_at => insert_at}.to_json});"
24
+ page.call 'ActiveScaffold.replace', active_scaffold_calculations_id, render(:partial => 'list_calculations') if active_scaffold_config.list.columns.any? {|c| c.calculation?}
25
+ end
26
+
27
+ unless render_parent?
28
+ if (active_scaffold_config.create.persistent)
29
+ page << "action_link.reload();"
30
+ else
31
+ page << "action_link.close();"
32
+ end
33
+ if (active_scaffold_config.create.edit_after_create)
34
+ page << "var link = $('#{action_link_id 'edit', @record.id}');"
35
+ page << "if (link) (function() { link.action_link.open() }).defer();"
36
+ end
37
+ end
38
+ else
39
+ page.call 'ActiveScaffold.replace', form_selector, render(:partial => 'create_form', :locals => {:xhr => true})
40
+ page.call 'ActiveScaffold.scroll_to', form_selector
41
+ end
@@ -0,0 +1,28 @@
1
+ form_selector = "#{element_form_id(:action => :update)}"
2
+
3
+ page << "var action_link = ActiveScaffold.find_action_link('#{form_selector}');"
4
+ page << "action_link.update_flash_messages('#{escape_javascript(render(:partial => 'messages').strip)}');"
5
+ if controller.send :successful?
6
+ if render_parent? && respond_to?(:render_component)
7
+ parent_rendered = render_component(render_parent_options)
8
+ if nested?
9
+ page << "action_link.close('#{escape_javascript(parent_rendered)}');"
10
+ else
11
+ if render_parent_action == :row
12
+ page << "action_link.close('#{escape_javascript(parent_rendered)}');"
13
+ elsif render_parent_action == :index
14
+ page << parent_rendered
15
+ end
16
+ end
17
+ #page.call 'ActiveScaffold.replace', active_scaffold_calculations_id, render(:partial => 'list_calculations') if active_scaffold_config.list.columns.any? {|c| c.calculation?}
18
+ elsif (active_scaffold_config.update.refresh_list)
19
+ page.call 'ActiveScaffold.replace_html', active_scaffold_content_id, render(:partial => 'list', :layout => false)
20
+ else
21
+ updated_row = render :partial => 'list_record', :locals => {:record => @record}
22
+ page << "action_link.close('#{escape_javascript(updated_row)}');"
23
+ page.call 'ActiveScaffold.replace', active_scaffold_calculations_id, render(:partial => 'list_calculations') if active_scaffold_config.list.columns.any? {|c| c.calculation?}
24
+ end
25
+ else
26
+ page.call 'ActiveScaffold.replace', form_selector, render(:partial => 'update_form', :locals => {:xhr => true})
27
+ page.call 'ActiveScaffold.scroll_to', form_selector
28
+ end
@@ -0,0 +1,5 @@
1
+ <div class="active-scaffold">
2
+ <div class="search-view <%= "#{params[:controller]}-view" %> view">
3
+ <%= render :partial => 'search' -%>
4
+ </div>
5
+ </div>
@@ -0,0 +1,5 @@
1
+ <div class="active-scaffold">
2
+ <div class="show-view <%= "#{params[:controller]}-view" %> view">
3
+ <%= render :partial => 'show' -%>
4
+ </div>
5
+ </div>
@@ -0,0 +1,8 @@
1
+ <div class="active-scaffold">
2
+ <div class="update-view <%= "#{params[:controller]}-view" %> view">
3
+ <% if active_scaffold_config.update.nested_links and active_scaffold_config.action_links.member.empty? -%>
4
+ <%= render :partial => 'update_actions', :locals => {:record => @record, :url_options => params_for(:action => :list, :id => @record.id)} %>
5
+ <% end -%>
6
+ <%= render :partial => 'update_form' -%>
7
+ </div>
8
+ </div>
@@ -0,0 +1,13 @@
1
+ column_span_id ||= element_cell_id(:id => @record.id.to_s, :action => 'update_column', :name => params[:column])
2
+ unless controller.send :successful?
3
+ page.call 'alert', @record.errors.full_messages(active_scaffold_config).join("\n")
4
+ @record.reload
5
+ end
6
+ column = active_scaffold_config.columns[params[:column]]
7
+ if column.inplace_edit
8
+ page.call 'ActiveScaffold.replace_html', column_span_id, format_inplace_edit_column(@record, column)
9
+ else
10
+ formatted_value = get_column_value(@record, column)
11
+ page.call 'ActiveScaffold.replace_html', column_span_id, formatted_value
12
+ end
13
+ page.call 'ActiveScaffold.replace_html', active_scaffold_calculations_id(column), render_column_calculation(column) if column.calculation?
@@ -0,0 +1 @@
1
+ page.call 'ActiveScaffold.update_row', element_row_id(:action => 'list', :id => @record.id), render(:partial => 'list_record', :locals => {:record => @record})
data/init.rb ADDED
@@ -0,0 +1,9 @@
1
+ ACTIVE_SCAFFOLD_PLUGIN = true
2
+
3
+ require 'active_scaffold'
4
+
5
+ begin
6
+ ActiveScaffoldAssets.copy_to_public(ActiveScaffold.root, {:clean_up_destination => true})
7
+ rescue
8
+ raise $! unless Rails.env == 'production'
9
+ end
@@ -0,0 +1,134 @@
1
+ # This module attempts to create permissions conventions for your ActiveRecord models. It supports english-based
2
+ # methods that let you restrict access per-model, per-record, per-column, per-action, and per-user. All at once.
3
+ #
4
+ # You may define instance methods in the following formats:
5
+ # def #{column}_authorized_for_#{action}?
6
+ # def #{column}_authorized?
7
+ # def authorized_for_#{action}?
8
+ #
9
+ # Your methods should allow for the following special cases:
10
+ # * cron scripts
11
+ # * guest users (or nil current_user objects)
12
+ module ActiveRecordPermissions
13
+ # ActiveRecordPermissions needs to know what method on your ApplicationController will return the current user,
14
+ # if available. This defaults to the :current_user method. You may configure this in your environment.rb if you
15
+ # have a different setup.
16
+ def self.current_user_method=(v); @@current_user_method = v; end
17
+ def self.current_user_method; @@current_user_method; end
18
+ @@current_user_method = :current_user
19
+
20
+ # Whether the default permission is permissive or not
21
+ # If set to true, then everything's allowed until configured otherwise
22
+ def self.default_permission=(v); @@default_permission = v; end
23
+ def self.default_permission; @@default_permission; end
24
+ @@default_permission = true
25
+
26
+ # This is a module aimed at making the current_user available to ActiveRecord models for permissions.
27
+ module ModelUserAccess
28
+ module Controller
29
+ def self.included(base)
30
+ base.prepend_before_filter :assign_current_user_to_models
31
+ end
32
+
33
+ # We need to give the ActiveRecord classes a handle to the current user. We don't want to just pass the object,
34
+ # because the object may change (someone may log in or out). So we give ActiveRecord a proc that ties to the
35
+ # current_user_method on this ApplicationController.
36
+ def assign_current_user_to_models
37
+ ActiveRecord::Base.current_user_proc = proc {send(ActiveRecordPermissions.current_user_method)}
38
+ end
39
+ end
40
+
41
+ module Model
42
+ def self.included(base)
43
+ base.extend ClassMethods
44
+ end
45
+
46
+ module ClassMethods
47
+ # The proc to call that retrieves the current_user from the ApplicationController.
48
+ attr_accessor :current_user_proc
49
+
50
+ # Class-level access to the current user
51
+ def current_user
52
+ ActiveRecord::Base.current_user_proc.call if ActiveRecord::Base.current_user_proc
53
+ end
54
+ end
55
+
56
+ # Instance-level access to the current user
57
+ def current_user
58
+ self.class.current_user
59
+ end
60
+ end
61
+ end
62
+
63
+ module Permissions
64
+ def self.included(base)
65
+ base.extend SecurityMethods
66
+ base.send :include, SecurityMethods
67
+ end
68
+
69
+ # Because any class-level queries get delegated to the instance level via a new record,
70
+ # it's useful to know when the authorization query is meant for a specific record or not.
71
+ # But using new_record? is confusing, even though accurate. So this is basically just a wrapper.
72
+ def existing_record_check?
73
+ !new_record?
74
+ end
75
+
76
+ module SecurityMethods
77
+ # A generic authorization query. This is what will be called programatically, since
78
+ # the actual permission methods can't be guaranteed to exist. And because we want to
79
+ # intelligently combine multiple applicable methods.
80
+ #
81
+ # options[:crud_type] should be a CRUD verb (:create, :read, :update, :destroy)
82
+ # options[:column] should be the name of a model attribute
83
+ # options[:action] is the name of a method
84
+ def authorized_for?(options = {})
85
+ raise ArgumentError, "unknown crud type #{options[:crud_type]}" if options[:crud_type] and ![:create, :read, :update, :delete].include?(options[:crud_type])
86
+
87
+ # column_authorized_for_crud_type? has the highest priority over other methods,
88
+ # you can disable a crud verb and enable that verb for a column
89
+ # (for example, disable update and enable inplace_edit in a column)
90
+ method = column_and_crud_type_security_method(options[:column], options[:crud_type])
91
+ return send(method) if method and respond_to?(method)
92
+
93
+ # authorized_for_action? has higher priority than other methods,
94
+ # you can disable a crud verb and enable an action with that crud verb
95
+ # (for example, disable update and enable an action with update as crud type)
96
+ method = action_security_method(options[:action])
97
+ return send(method) if method and respond_to?(method)
98
+
99
+ # collect other possibly-related methods that actually exist
100
+ methods = [
101
+ column_security_method(options[:column]),
102
+ crud_type_security_method(options[:crud_type]),
103
+ ].compact.select {|m| respond_to?(m)}
104
+
105
+ # if any method returns false, then return false
106
+ return false if methods.any? {|m| !send(m)}
107
+
108
+ # if any method actually exists then it must've returned true, so return true
109
+ return true unless methods.empty?
110
+
111
+ # if no method exists, return the default permission
112
+ return ActiveRecordPermissions.default_permission
113
+ end
114
+
115
+ private
116
+
117
+ def column_security_method(column)
118
+ "#{column}_authorized?" if column
119
+ end
120
+
121
+ def crud_type_security_method(crud_type)
122
+ "authorized_for_#{crud_type}?" if crud_type
123
+ end
124
+
125
+ def action_security_method(action)
126
+ "authorized_for_#{action}?" if action
127
+ end
128
+
129
+ def column_and_crud_type_security_method(column, crud_type)
130
+ "#{column}_authorized_for_#{crud_type}?" if column and crud_type
131
+ end
132
+ end
133
+ end
134
+ end
@@ -0,0 +1,22 @@
1
+ module ActiveScaffold::Actions
2
+ module CommonSearch
3
+ protected
4
+ def store_search_params_into_session
5
+ active_scaffold_session_storage[:search] = params.delete :search if params[:search]
6
+ end
7
+
8
+ def search_params
9
+ active_scaffold_session_storage[:search]
10
+ end
11
+
12
+ def search_ignore?
13
+ active_scaffold_config.list.always_show_search
14
+ end
15
+
16
+ # The default security delegates to ActiveRecordPermissions.
17
+ # You may override the method to customize.
18
+ def search_authorized?
19
+ authorized_for?(:crud_type => :read)
20
+ end
21
+ end
22
+ end