brisk-bills 0.7.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (396) hide show
  1. data/CHANGELOG +7 -0
  2. data/Gemfile +11 -0
  3. data/Gemfile.lock +55 -0
  4. data/TODO.txt +36 -67
  5. data/app/controllers/admin/activities_controller.rb +4 -3
  6. data/app/controllers/admin/activities_with_prices_controller.rb +28 -14
  7. data/app/controllers/admin/client_accounting_controller.rb +11 -8
  8. data/app/controllers/admin/client_representatives_controller.rb +34 -5
  9. data/app/controllers/admin/clients_controller.rb +1 -1
  10. data/app/controllers/admin/draft_invoices_controller.rb +92 -0
  11. data/app/controllers/admin/{employee_client_labor_rate_controller.rb → employee_client_labor_rates_controller.rb} +1 -1
  12. data/app/controllers/admin/employees_controller.rb +3 -4
  13. data/app/controllers/admin/invoices_controller.rb +111 -53
  14. data/app/controllers/admin/payments_controller.rb +168 -41
  15. data/app/controllers/authentication_controller.rb +3 -3
  16. data/app/helpers/admin/activities_helper.rb +16 -13
  17. data/app/helpers/admin/activities_helper/labor_helper.rb +4 -4
  18. data/app/helpers/admin/activities_helper/proposal_helper.rb +1 -1
  19. data/app/helpers/admin/activities_helper/slimtimer_helper.rb +1 -1
  20. data/app/helpers/admin/activities_with_prices_helper.rb +2 -2
  21. data/app/helpers/admin/activity_type_controller_helper.rb +6 -0
  22. data/app/helpers/admin/activity_type_field_helper.rb +9 -9
  23. data/app/helpers/admin/adjustments_helper.rb +9 -1
  24. data/app/helpers/admin/client_accounting_helper.rb +2 -2
  25. data/app/helpers/admin/client_financial_transactions_helper.rb +1 -1
  26. data/app/helpers/admin/client_representatives_helper.rb +16 -12
  27. data/app/helpers/admin/clients_helper.rb +2 -0
  28. data/app/helpers/admin/draft_invoices_helper.rb +24 -0
  29. data/app/helpers/admin/{employee_client_labor_rate_helper.rb → employee_client_labor_rates_helper.rb} +8 -8
  30. data/app/helpers/admin/employees_helper.rb +6 -0
  31. data/app/helpers/admin/has_credential_column_helper.rb +8 -8
  32. data/app/helpers/admin/invoices_helper.rb +71 -16
  33. data/app/helpers/admin/is_active_column_helper.rb +2 -2
  34. data/app/helpers/admin/labors_helper.rb +12 -1
  35. data/app/helpers/admin/labors_helper/slimtimer_helper.rb +1 -1
  36. data/app/helpers/admin/materials_helper.rb +11 -0
  37. data/app/helpers/admin/payments_helper.rb +204 -29
  38. data/app/helpers/admin/proposals_helper.rb +10 -0
  39. data/app/helpers/admin/settings_helper.rb +1 -1
  40. data/app/helpers/admin_layout_helper.rb +3 -6
  41. data/app/helpers/authentication_helper.rb +7 -10
  42. data/app/helpers/money_model_helper.rb +1 -2
  43. data/app/models/activity.rb +17 -7
  44. data/app/models/client.rb +35 -8
  45. data/app/{model_views → models}/client_financial_transaction.rb +0 -0
  46. data/app/models/client_representative.rb +6 -14
  47. data/app/models/credential.rb +1 -1
  48. data/app/models/employee.rb +9 -11
  49. data/app/models/invoice.rb +13 -9
  50. data/app/models/invoice_payment.rb +1 -1
  51. data/app/models/notifier.rb +2 -2
  52. data/app/models/payment.rb +51 -7
  53. data/app/models/setting.rb +3 -1
  54. data/app/views/active_scaffold_overrides/add_existing.js.rjs +25 -0
  55. data/app/views/admin/activities/_adjustment_column.html.erb +10 -0
  56. data/app/views/admin/activities/{_form.rhtml → _form.html.erb} +0 -0
  57. data/app/views/admin/activities/{_form_attribute.rhtml → _form_attribute.html.erb} +0 -0
  58. data/app/views/admin/activities/{_labor_column.rhtml → _labor_column.html.erb} +0 -0
  59. data/app/views/admin/activities/{_material_column.rhtml → _material_column.html.erb} +0 -0
  60. data/app/views/admin/activities/{_proposal_column.rhtml → _proposal_column.html.erb} +0 -0
  61. data/app/views/admin/activities_with_prices/{move_to_invoice.rhtml → move_to_invoice.html.erb} +2 -2
  62. data/app/views/admin/activities_with_prices/move_to_invoice.js.rjs +5 -0
  63. data/app/views/admin/draft_invoices/batch_create.html.erb +73 -0
  64. data/app/views/admin/draft_invoices/batch_create.js.rjs +5 -0
  65. data/app/views/admin/invoices/confirm_publish_modal.html.erb +48 -0
  66. data/app/views/admin/payments/commit_payment_warning.html.erb +8 -0
  67. data/app/views/admin/payments/observation_error.js.rjs +28 -0
  68. data/app/views/admin/payments/on_assignment_observation.js.rjs +28 -0
  69. data/app/views/authentication/{email.rjs → email.js.rjs} +0 -0
  70. data/app/views/authentication/{login.rhtml → login.html.erb} +21 -26
  71. data/app/views/authentication/{login.rjs → login.js.rjs} +0 -0
  72. data/app/views/authentication/{reset_password_via_token.rhtml → reset_password_via_token.html.erb} +0 -0
  73. data/app/views/authentication/{reset_password_via_token.rjs → reset_password_via_token.js.rjs} +0 -0
  74. data/app/views/authentication/{sign_in_error.rjs → sign_in_error.js.rjs} +0 -0
  75. data/app/views/layouts/{_navigation_tree.rhtml → _navigation_tree.html.erb} +0 -0
  76. data/app/views/layouts/{admin.rhtml → admin.html.erb} +0 -0
  77. data/app/views/layouts/{public.rhtml → public.html.erb} +0 -0
  78. data/app/views/notifier/{_email_footer.html.rhtml → _email_footer.html.erb} +0 -0
  79. data/app/views/notifier/{_email_footer.plain.rhtml → _email_footer.plain.erb} +0 -0
  80. data/app/views/notifier/{_email_header.html.rhtml → _email_header.html.erb} +0 -0
  81. data/app/views/notifier/invoice_available.html.erb +5 -0
  82. data/app/views/notifier/{invoice_available.plain.rhtml → invoice_available.plain.erb} +1 -1
  83. data/app/views/notifier/{reset_password_requested.html.rhtml → reset_password_requested.html.erb} +2 -2
  84. data/app/views/notifier/{reset_password_requested.plain.rhtml → reset_password_requested.plain.erb} +1 -1
  85. data/config/environment.rb +6 -5
  86. data/config/locale/en.rb +9 -0
  87. data/db/migrate/001_create_employees.rb +1 -1
  88. data/db/migrate/002_create_employee_slimtimers.rb +1 -1
  89. data/db/migrate/003_create_slimtimer_tasks.rb +1 -1
  90. data/db/migrate/004_create_slimtimer_time_entries.rb +1 -1
  91. data/db/migrate/005_create_clients.rb +1 -1
  92. data/db/migrate/006_create_client_representatives.rb +1 -1
  93. data/db/migrate/008_create_activities.rb +1 -1
  94. data/db/migrate/009_create_activity_labors.rb +1 -1
  95. data/db/migrate/010_create_employee_client_labor_rates.rb +1 -1
  96. data/db/migrate/011_create_activity_adjustments.rb +1 -1
  97. data/db/migrate/012_create_activity_materials.rb +1 -1
  98. data/db/migrate/013_create_activity_proposals.rb +1 -1
  99. data/db/migrate/014_create_invoices.rb +1 -1
  100. data/db/migrate/015_create_payments.rb +1 -1
  101. data/db/migrate/016_create_payment_methods.rb +1 -1
  102. data/db/migrate/017_create_invoice_payments.rb +1 -1
  103. data/db/migrate/018_create_activity_types.rb +2 -2
  104. data/db/migrate/019_create_settings.rb +1 -1
  105. data/db/migrate/023_create_credentials_migrate_representatives.rb +2 -2
  106. data/db/migrate/028_money_to_cents.rb +2 -2
  107. data/db/schema.rb +10 -10
  108. data/lib/brisk-bills.rb +2 -2
  109. data/lib/brisk-bills/initializer.rb +2 -2
  110. data/lib/generators/instance/templates/instance_environment.rb +1 -1
  111. data/lib/libpptable.rb +48 -0
  112. data/lib/tasks/create_last_months_invoices.rake +1 -14
  113. data/lib/tasks/first_time_setup.rake +2 -2
  114. data/lib/tasks/package.rake +2 -1
  115. data/lib/tasks/payment_assignment_consistency_check.rake +110 -0
  116. data/lib/utilities.rb +4 -4
  117. data/public/images/page-new.gif +0 -0
  118. data/public/javascripts/active_scaffold/default/active_scaffold.js +532 -430
  119. data/public/javascripts/active_scaffold/default/dhtml_history.js +1 -1
  120. data/public/javascripts/active_scaffold/default/form_enhancements.js +7 -4
  121. data/public/stylesheets/active_scaffold/default/stylesheet-ie.css +5 -5
  122. data/public/stylesheets/active_scaffold/default/stylesheet.css +54 -18
  123. data/public/stylesheets/admin/global.css +1 -1
  124. data/public/stylesheets/admin/pages.css +29 -0
  125. data/test/unit/activity/adjustment_test.rb +1 -1
  126. data/test/unit/activity/labor_test.rb +1 -1
  127. data/test/unit/activity/material_test.rb +1 -1
  128. data/test/unit/activity/proposal_test.rb +1 -1
  129. data/test/unit/activity_test.rb +1 -1
  130. data/test/unit/activity_type_test.rb +1 -1
  131. data/test/unit/client_eventlog_test.rb +1 -1
  132. data/test/unit/client_financial_transaction_test.rb +1 -1
  133. data/test/unit/client_representative_test.rb +1 -1
  134. data/test/unit/client_test.rb +37 -6
  135. data/test/unit/credential_test.rb +1 -1
  136. data/test/unit/employee/slimtimer_test.rb +1 -1
  137. data/test/unit/employee_client_labor_rate_test.rb +1 -1
  138. data/test/unit/employee_test.rb +1 -1
  139. data/test/unit/helpers/admin/draft_invoices_helper_test.rb +4 -0
  140. data/test/unit/invoice_payment_test.rb +90 -50
  141. data/test/unit/invoice_test.rb +48 -8
  142. data/test/unit/notifier_test.rb +1 -1
  143. data/test/unit/payment_method_test.rb +1 -1
  144. data/test/unit/payment_test.rb +7 -7
  145. data/test/unit/setting_test.rb +1 -1
  146. data/test/unit/slimtimer_task_test.rb +1 -1
  147. data/test/unit/slimtimer_time_entry_test.rb +1 -1
  148. data/vendor/plugins/active_scaffold/CHANGELOG +3 -1
  149. data/vendor/plugins/active_scaffold/README +18 -5
  150. data/vendor/plugins/active_scaffold/environment.rb +1 -1
  151. data/vendor/plugins/active_scaffold/frontends/default/javascripts/active_scaffold.js +532 -430
  152. data/vendor/plugins/active_scaffold/frontends/default/javascripts/dhtml_history.js +1 -1
  153. data/vendor/plugins/active_scaffold/frontends/default/javascripts/form_enhancements.js +7 -4
  154. data/vendor/plugins/active_scaffold/frontends/default/stylesheets/stylesheet-ie.css +5 -5
  155. data/vendor/plugins/active_scaffold/frontends/default/stylesheets/stylesheet.css +54 -18
  156. data/vendor/plugins/active_scaffold/frontends/default/views/_add_existing_form.html.erb +3 -7
  157. data/vendor/plugins/active_scaffold/frontends/default/views/_create_form.html.erb +10 -7
  158. data/vendor/plugins/active_scaffold/frontends/default/views/_field_search.html.erb +7 -12
  159. data/vendor/plugins/active_scaffold/frontends/default/views/_form.html.erb +3 -3
  160. data/vendor/plugins/active_scaffold/frontends/default/views/_form_association.html.erb +15 -20
  161. data/vendor/plugins/active_scaffold/frontends/default/views/_form_association_footer.html.erb +8 -10
  162. data/vendor/plugins/active_scaffold/frontends/default/views/_form_attribute.html.erb +5 -2
  163. data/vendor/plugins/active_scaffold/frontends/default/views/_form_hidden_attribute.html.erb +2 -1
  164. data/vendor/plugins/active_scaffold/frontends/default/views/_horizontal_subform.html.erb +19 -21
  165. data/vendor/plugins/active_scaffold/frontends/default/views/{_form_association_header.html.erb → _horizontal_subform_header.html.erb} +2 -2
  166. data/vendor/plugins/active_scaffold/frontends/default/views/_horizontal_subform_record.html.erb +31 -0
  167. data/vendor/plugins/active_scaffold/frontends/default/views/_list.html.erb +4 -18
  168. data/vendor/plugins/active_scaffold/frontends/default/views/_list_actions.html.erb +18 -5
  169. data/vendor/plugins/active_scaffold/frontends/default/views/_list_calculations.html.erb +2 -9
  170. data/vendor/plugins/active_scaffold/frontends/default/views/_list_column_headings.html.erb +4 -4
  171. data/vendor/plugins/active_scaffold/frontends/default/views/_list_header.html.erb +6 -6
  172. data/vendor/plugins/active_scaffold/frontends/default/views/_list_inline_adapter.html.erb +2 -1
  173. data/vendor/plugins/active_scaffold/frontends/default/views/_list_messages.html.erb +20 -0
  174. data/vendor/plugins/active_scaffold/frontends/default/views/_list_pagination.html.erb +11 -0
  175. data/vendor/plugins/active_scaffold/frontends/default/views/_list_pagination_links.html.erb +3 -5
  176. data/vendor/plugins/active_scaffold/frontends/default/views/_list_record.html.erb +2 -26
  177. data/vendor/plugins/active_scaffold/frontends/default/views/_list_record_columns.html.erb +9 -0
  178. data/vendor/plugins/active_scaffold/frontends/default/views/_nested.html.erb +3 -12
  179. data/vendor/plugins/active_scaffold/frontends/default/views/_render_fields.js.rjs +11 -0
  180. data/vendor/plugins/active_scaffold/frontends/default/views/_search.html.erb +17 -11
  181. data/vendor/plugins/active_scaffold/frontends/default/views/_show.html.erb +3 -3
  182. data/vendor/plugins/active_scaffold/frontends/default/views/_show_columns.html.erb +8 -7
  183. data/vendor/plugins/active_scaffold/frontends/default/views/_update_actions.html.erb +3 -3
  184. data/vendor/plugins/active_scaffold/frontends/default/views/_update_form.html.erb +9 -6
  185. data/vendor/plugins/active_scaffold/frontends/default/views/_vertical_subform.html.erb +7 -0
  186. data/vendor/plugins/active_scaffold/frontends/default/views/_vertical_subform_record.html.erb +38 -0
  187. data/vendor/plugins/active_scaffold/frontends/default/views/add_existing.js.rjs +2 -1
  188. data/vendor/plugins/active_scaffold/frontends/default/views/delete.html.erb +1 -1
  189. data/vendor/plugins/active_scaffold/frontends/default/views/destroy.js.rjs +2 -2
  190. data/vendor/plugins/active_scaffold/frontends/default/views/edit_associated.js.rjs +20 -15
  191. data/vendor/plugins/active_scaffold/frontends/default/views/list.html.erb +12 -8
  192. data/vendor/plugins/active_scaffold/frontends/default/views/list.js.rjs +1 -0
  193. data/vendor/plugins/active_scaffold/frontends/default/views/mark.js.rjs +6 -0
  194. data/vendor/plugins/active_scaffold/frontends/default/views/on_create.js.rjs +12 -8
  195. data/vendor/plugins/active_scaffold/frontends/default/views/on_update.js.rjs +13 -6
  196. data/vendor/plugins/active_scaffold/frontends/default/views/render_field.js.rjs +1 -0
  197. data/vendor/plugins/active_scaffold/frontends/default/views/search.html.erb +2 -2
  198. data/vendor/plugins/active_scaffold/frontends/default/views/update.html.erb +2 -2
  199. data/vendor/plugins/active_scaffold/frontends/default/views/update_column.js.rjs +4 -3
  200. data/vendor/plugins/active_scaffold/frontends/default/views/update_row.js.rjs +2 -0
  201. data/vendor/plugins/active_scaffold/init.rb +2 -2
  202. data/vendor/plugins/active_scaffold/install.rb +1 -2
  203. data/vendor/plugins/active_scaffold/install_assets.rb +1 -1
  204. data/vendor/plugins/active_scaffold/lib/active_record_permissions.rb +53 -42
  205. data/vendor/plugins/active_scaffold/lib/active_scaffold.rb +96 -23
  206. data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/common_search.rb +18 -0
  207. data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/core.rb +152 -102
  208. data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/create.rb +81 -49
  209. data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/delete.rb +44 -17
  210. data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/field_search.rb +60 -46
  211. data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/list.rb +42 -37
  212. data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/mark.rb +72 -0
  213. data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/nested.rb +94 -92
  214. data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/search.rb +54 -40
  215. data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/show.rb +30 -10
  216. data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/update.rb +62 -47
  217. data/vendor/plugins/active_scaffold/lib/active_scaffold/attribute_params.rb +187 -185
  218. data/vendor/plugins/active_scaffold/lib/active_scaffold/config/base.rb +28 -3
  219. data/vendor/plugins/active_scaffold/lib/active_scaffold/config/core.rb +43 -3
  220. data/vendor/plugins/active_scaffold/lib/active_scaffold/config/create.rb +8 -15
  221. data/vendor/plugins/active_scaffold/lib/active_scaffold/config/delete.rb +3 -4
  222. data/vendor/plugins/active_scaffold/lib/active_scaffold/config/field_search.rb +19 -17
  223. data/vendor/plugins/active_scaffold/lib/active_scaffold/config/form.rb +2 -9
  224. data/vendor/plugins/active_scaffold/lib/active_scaffold/config/list.rb +46 -9
  225. data/vendor/plugins/active_scaffold/lib/active_scaffold/config/nested.rb +17 -7
  226. data/vendor/plugins/active_scaffold/lib/active_scaffold/config/search.rb +36 -16
  227. data/vendor/plugins/active_scaffold/lib/active_scaffold/config/show.rb +5 -12
  228. data/vendor/plugins/active_scaffold/lib/active_scaffold/config/subform.rb +8 -6
  229. data/vendor/plugins/active_scaffold/lib/active_scaffold/config/update.rb +12 -8
  230. data/vendor/plugins/active_scaffold/lib/active_scaffold/configurable.rb +2 -2
  231. data/vendor/plugins/active_scaffold/lib/active_scaffold/constraints.rb +173 -178
  232. data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_columns.rb +101 -97
  233. data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_link.rb +29 -19
  234. data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/column.rb +74 -34
  235. data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/columns.rb +74 -74
  236. data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/set.rb +57 -62
  237. data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/sorting.rb +73 -3
  238. data/vendor/plugins/active_scaffold/lib/active_scaffold/finder.rb +304 -234
  239. data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/association_helpers.rb +40 -40
  240. data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/controller_helpers.rb +39 -24
  241. data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/country_helpers.rb +32 -28
  242. data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb +157 -86
  243. data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/id_helpers.rb +7 -7
  244. data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb +278 -85
  245. data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/pagination_helpers.rb +38 -12
  246. data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/search_column_helpers.rb +74 -35
  247. data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/show_column_helpers.rb +53 -46
  248. data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/view_helpers.rb +51 -17
  249. data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/de.yml +69 -0
  250. data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/en.yml +72 -0
  251. data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/es.yml +23 -13
  252. data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/fr.yml +68 -0
  253. data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/hu.yml +24 -14
  254. data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/ja.yml +69 -0
  255. data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/ru.yml +72 -0
  256. data/vendor/plugins/active_scaffold/lib/active_scaffold/marked_model.rb +38 -0
  257. data/vendor/plugins/active_scaffold/lib/bridges/calendar_date_select/lib/as_cds_bridge.rb +47 -13
  258. data/vendor/plugins/active_scaffold/lib/bridges/dependent_protect/bridge.rb +10 -0
  259. data/vendor/plugins/active_scaffold/lib/bridges/dependent_protect/lib/dependent_protect_bridge.rb +11 -0
  260. data/vendor/plugins/active_scaffold/lib/bridges/file_column/lib/as_file_column_bridge.rb +3 -6
  261. data/vendor/plugins/active_scaffold/lib/bridges/file_column/lib/form_ui.rb +10 -2
  262. data/vendor/plugins/active_scaffold/lib/bridges/paperclip/bridge.rb +13 -0
  263. data/vendor/plugins/active_scaffold/lib/bridges/paperclip/lib/form_ui.rb +20 -0
  264. data/vendor/plugins/active_scaffold/lib/bridges/paperclip/lib/list_ui.rb +16 -0
  265. data/vendor/plugins/active_scaffold/lib/bridges/paperclip/lib/paperclip_bridge.rb +32 -0
  266. data/vendor/plugins/active_scaffold/lib/bridges/paperclip/lib/paperclip_bridge_helpers.rb +18 -0
  267. data/vendor/plugins/active_scaffold/lib/bridges/record_select/bridge.rb +5 -0
  268. data/vendor/plugins/active_scaffold/lib/bridges/record_select/lib/record_select_bridge.rb +79 -0
  269. data/vendor/plugins/active_scaffold/lib/bridges/semantic_attributes/bridge.rb +5 -0
  270. data/vendor/plugins/active_scaffold/lib/bridges/semantic_attributes/lib/semantic_attributes_bridge.rb +20 -0
  271. data/vendor/plugins/active_scaffold/lib/bridges/tiny_mce/bridge.rb +5 -0
  272. data/vendor/plugins/active_scaffold/lib/bridges/tiny_mce/lib/tiny_mce_bridge.rb +57 -0
  273. data/vendor/plugins/active_scaffold/lib/bridges/unobtrusive_date_picker/bridge.rb +9 -0
  274. data/vendor/plugins/active_scaffold/lib/bridges/unobtrusive_date_picker/lib/form_ui.rb +14 -0
  275. data/vendor/plugins/active_scaffold/lib/bridges/unobtrusive_date_picker/lib/unobtrusive_date_picker_bridge.rb +15 -0
  276. data/vendor/plugins/active_scaffold/lib/bridges/unobtrusive_date_picker/lib/view_helpers.rb +16 -0
  277. data/vendor/plugins/active_scaffold/lib/bridges/validation_reflection/bridge.rb +9 -0
  278. data/vendor/plugins/active_scaffold/lib/bridges/validation_reflection/lib/validation_reflection_bridge.rb +19 -0
  279. data/vendor/plugins/active_scaffold/lib/extensions/action_view_rendering.rb +20 -8
  280. data/vendor/plugins/active_scaffold/lib/extensions/generic_view_paths.rb +2 -2
  281. data/vendor/plugins/active_scaffold/lib/extensions/paginator_extensions.rb +26 -0
  282. data/vendor/plugins/active_scaffold/lib/extensions/resources.rb +6 -5
  283. data/vendor/plugins/active_scaffold/lib/extensions/reverse_associations.rb +26 -20
  284. data/vendor/plugins/active_scaffold/lib/extensions/unsaved_associated.rb +1 -1
  285. data/vendor/plugins/active_scaffold/lib/paginator.rb +1 -1
  286. data/vendor/plugins/active_scaffold/lib/responds_to_parent.rb +1 -1
  287. data/vendor/plugins/active_scaffold/shoulda_macros/macros.rb +136 -0
  288. data/vendor/plugins/active_scaffold/test/bridges/active_scaffold_dependent_protect_test.rb +34 -0
  289. data/vendor/plugins/active_scaffold/test/bridges/bridge_test.rb +43 -0
  290. data/vendor/plugins/active_scaffold/test/bridges/company.rb +81 -0
  291. data/vendor/plugins/active_scaffold/test/bridges/paperclip_test.rb +68 -0
  292. data/vendor/plugins/active_scaffold/test/bridges/tiny_mce_test.rb +27 -0
  293. data/vendor/plugins/active_scaffold/test/bridges/unobtrusive_date_picker_test.rb +49 -0
  294. data/vendor/plugins/active_scaffold/test/bridges/validation_reflection_test.rb +57 -0
  295. data/vendor/plugins/active_scaffold/test/config/base_test.rb +15 -0
  296. data/vendor/plugins/active_scaffold/test/config/core_test.rb +58 -0
  297. data/vendor/plugins/active_scaffold/test/config/create_test.rb +9 -6
  298. data/vendor/plugins/active_scaffold/test/config/delete_test.rb +33 -0
  299. data/vendor/plugins/active_scaffold/test/config/field_search_test.rb +47 -0
  300. data/vendor/plugins/active_scaffold/test/config/list_test.rb +66 -11
  301. data/vendor/plugins/active_scaffold/test/config/nested_test.rb +62 -0
  302. data/vendor/plugins/active_scaffold/test/config/search_test.rb +60 -0
  303. data/vendor/plugins/active_scaffold/test/config/show_test.rb +43 -0
  304. data/vendor/plugins/active_scaffold/test/config/subform_test.rb +17 -0
  305. data/vendor/plugins/active_scaffold/test/config/update_test.rb +27 -4
  306. data/vendor/plugins/active_scaffold/test/data_structures/action_columns_test.rb +2 -8
  307. data/vendor/plugins/active_scaffold/test/data_structures/action_link_test.rb +11 -11
  308. data/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb +5 -5
  309. data/vendor/plugins/active_scaffold/test/data_structures/association_column_test.rb +4 -3
  310. data/vendor/plugins/active_scaffold/test/data_structures/column_test.rb +29 -5
  311. data/vendor/plugins/active_scaffold/test/data_structures/sorting_test.rb +31 -1
  312. data/vendor/plugins/active_scaffold/test/data_structures/standard_column_test.rb +3 -13
  313. data/vendor/plugins/active_scaffold/test/data_structures/virtual_column_test.rb +0 -11
  314. data/vendor/plugins/active_scaffold/test/extensions/{array.rb → array_test.rb} +0 -0
  315. data/vendor/plugins/active_scaffold/test/helpers/form_column_helpers_test.rb +31 -0
  316. data/vendor/plugins/active_scaffold/test/helpers/list_column_helpers_test.rb +42 -0
  317. data/vendor/plugins/active_scaffold/test/helpers/pagination_helpers_test.rb +59 -0
  318. data/vendor/plugins/active_scaffold/test/misc/active_record_permissions_test.rb +154 -0
  319. data/vendor/plugins/active_scaffold/test/misc/attribute_params_test.rb +146 -0
  320. data/vendor/plugins/active_scaffold/test/misc/configurable_test.rb +2 -2
  321. data/vendor/plugins/active_scaffold/test/misc/constraints_test.rb +26 -8
  322. data/vendor/plugins/active_scaffold/test/misc/finder_test.rb +41 -19
  323. data/vendor/plugins/active_scaffold/test/misc/lang_test.rb +5 -6
  324. data/vendor/plugins/active_scaffold/test/mock_app/app/controllers/application_controller.rb +10 -0
  325. data/vendor/plugins/active_scaffold/test/mock_app/app/helpers/application_helper.rb +3 -0
  326. data/vendor/plugins/active_scaffold/test/mock_app/config/boot.rb +110 -0
  327. data/vendor/plugins/active_scaffold/test/mock_app/config/environment.rb +43 -0
  328. data/vendor/plugins/active_scaffold/test/mock_app/config/environments/development.rb +17 -0
  329. data/vendor/plugins/active_scaffold/test/mock_app/config/environments/production.rb +28 -0
  330. data/vendor/plugins/active_scaffold/test/mock_app/config/environments/test.rb +28 -0
  331. data/vendor/plugins/active_scaffold/test/mock_app/config/initializers/backtrace_silencers.rb +7 -0
  332. data/vendor/plugins/active_scaffold/test/mock_app/config/initializers/inflections.rb +10 -0
  333. data/vendor/plugins/active_scaffold/test/mock_app/config/initializers/mime_types.rb +5 -0
  334. data/vendor/plugins/active_scaffold/test/mock_app/config/initializers/new_rails_defaults.rb +19 -0
  335. data/vendor/plugins/active_scaffold/test/mock_app/config/initializers/session_store.rb +15 -0
  336. data/vendor/plugins/active_scaffold/test/mock_app/config/locales/en.yml +5 -0
  337. data/vendor/plugins/active_scaffold/test/mock_app/config/routes.rb +43 -0
  338. data/vendor/plugins/active_scaffold/test/mock_app/db/test.sqlite3 +1 -0
  339. data/vendor/plugins/active_scaffold/test/mock_app/public/blank.html +33 -0
  340. data/vendor/plugins/active_scaffold/test/mock_app/public/images/active_scaffold/DO_NOT_EDIT +2 -0
  341. data/vendor/plugins/active_scaffold/test/mock_app/public/images/active_scaffold/default/add.gif +0 -0
  342. data/vendor/plugins/active_scaffold/test/mock_app/public/images/active_scaffold/default/arrow_down.gif +0 -0
  343. data/vendor/plugins/active_scaffold/test/mock_app/public/images/active_scaffold/default/arrow_up.gif +0 -0
  344. data/vendor/plugins/active_scaffold/test/mock_app/public/images/active_scaffold/default/close.gif +0 -0
  345. data/vendor/plugins/active_scaffold/test/mock_app/public/images/active_scaffold/default/cross.png +0 -0
  346. data/vendor/plugins/active_scaffold/test/mock_app/public/images/active_scaffold/default/indicator-small.gif +0 -0
  347. data/vendor/plugins/active_scaffold/test/mock_app/public/images/active_scaffold/default/indicator.gif +0 -0
  348. data/vendor/plugins/active_scaffold/test/mock_app/public/images/active_scaffold/default/magnifier.png +0 -0
  349. data/vendor/plugins/active_scaffold/test/mock_app/public/javascripts/active_scaffold/DO_NOT_EDIT +2 -0
  350. data/vendor/plugins/active_scaffold/test/mock_app/public/javascripts/active_scaffold/default/active_scaffold.js +532 -0
  351. data/vendor/plugins/active_scaffold/test/mock_app/public/javascripts/active_scaffold/default/dhtml_history.js +867 -0
  352. data/vendor/plugins/active_scaffold/test/mock_app/public/javascripts/active_scaffold/default/form_enhancements.js +117 -0
  353. data/vendor/plugins/active_scaffold/test/mock_app/public/javascripts/active_scaffold/default/rico_corner.js +370 -0
  354. data/vendor/plugins/active_scaffold/test/mock_app/public/stylesheets/active_scaffold/DO_NOT_EDIT +2 -0
  355. data/vendor/plugins/active_scaffold/test/mock_app/public/stylesheets/active_scaffold/default/stylesheet-ie.css +35 -0
  356. data/vendor/plugins/active_scaffold/test/mock_app/public/stylesheets/active_scaffold/default/stylesheet.css +845 -0
  357. data/vendor/plugins/active_scaffold/test/model_stub.rb +17 -1
  358. data/vendor/plugins/active_scaffold/test/test_helper.rb +31 -5
  359. data/vendor/plugins/active_scaffold/uninstall.rb +2 -1
  360. data/vendor/plugins/active_scaffold_form_observation/init.rb +1 -1
  361. data/vendor/plugins/active_scaffold_form_observation/lib/active_scaffold_form_observation.rb +1 -2
  362. data/vendor/plugins/active_scaffold_full_refresh/init.rb +2 -0
  363. data/vendor/plugins/active_scaffold_full_refresh/lib/active_scaffold_full_refresh.rb +29 -0
  364. data/vendor/plugins/acts_as_money/{tasks → lib/tasks}/money_tasks.rake +0 -0
  365. metadata +668 -563
  366. data/app/model_views/client_accounting.rb +0 -5
  367. data/app/model_views/invoices_with_total.rb +0 -41
  368. data/app/views/admin/activities/_adjustment_column.rhtml +0 -23
  369. data/app/views/admin/activities_with_prices/move_to_invoice.rjs +0 -9
  370. data/app/views/notifier/invoice_available.html.rhtml +0 -5
  371. data/public/javascripts/prototype.js-1.6.0.3 +0 -4320
  372. data/test/functional/admin/activities_controller_test.rb +0 -8
  373. data/test/functional/admin/adjustments_controller_test.rb +0 -8
  374. data/test/functional/admin/client_accounting_controller_test.rb +0 -8
  375. data/test/functional/admin/client_financial_transactions_controller_test.rb +0 -8
  376. data/test/functional/admin/client_representatives_controller_test.rb +0 -8
  377. data/test/functional/admin/clients_controller_test.rb +0 -8
  378. data/test/functional/admin/employee_client_labor_rate_controller_test.rb +0 -8
  379. data/test/functional/admin/employees/slimtimer_controller_test.rb +0 -8
  380. data/test/functional/admin/employees_controller_test.rb +0 -8
  381. data/test/functional/admin/invoices_controller_test.rb +0 -8
  382. data/test/functional/admin/labors_controller_test.rb +0 -8
  383. data/test/functional/admin/materials_controller_test.rb +0 -8
  384. data/test/functional/admin/payments_controller_test.rb +0 -8
  385. data/test/functional/admin/proposals_controller_test.rb +0 -8
  386. data/test/functional/admin/settings_controller_test.rb +0 -8
  387. data/test/functional/authentication_controller_test.rb +0 -8
  388. data/vendor/plugins/active_scaffold/frontends/default/views/_form_association_record.html.erb +0 -27
  389. data/vendor/plugins/active_scaffold/frontends/default/views/_live_search.html.erb +0 -25
  390. data/vendor/plugins/active_scaffold/frontends/default/views/form_messages_on_create.js.rjs +0 -2
  391. data/vendor/plugins/active_scaffold/frontends/default/views/form_messages_on_update.js.rjs +0 -2
  392. data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/live_search.rb +0 -46
  393. data/vendor/plugins/active_scaffold/lib/active_scaffold/config/live_search.rb +0 -52
  394. data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/en.rb +0 -66
  395. data/vendor/plugins/active_scaffold/lib/extensions/name_option_for_datetime.rb +0 -12
  396. data/vendor/plugins/active_scaffold/test/misc/active_record_permissions.rb +0 -154
@@ -1,46 +1,73 @@
1
1
  module ActiveScaffold::Actions
2
2
  module Delete
3
3
  def self.included(base)
4
- base.before_filter :delete_authorized?, :only => [:delete, :destroy]
4
+ base.before_filter :delete_authorized_filter, :only => [:delete, :destroy]
5
5
  end
6
6
 
7
7
  # this method is for html mode. it provides "the missing action" (http://thelucid.com/articles/2006/07/26/simply-restful-the-missing-action).
8
8
  # it also gives us delete confirmation for html mode. woo!
9
9
  def delete
10
- @record = find_if_allowed(params[:id], :destroy)
10
+ destroy_find_record
11
11
  render :action => 'delete'
12
12
  end
13
13
 
14
14
  def destroy
15
15
  return redirect_to(params.merge(:action => :delete)) if request.get?
16
-
17
16
  do_destroy
18
-
19
- respond_to do |type|
20
- type.html do
21
- flash[:info] = as_(:deleted_model, :model => @record.to_label)
22
- return_to_main
23
- end
24
- type.js { render(:action => 'destroy') }
25
- type.xml { render :xml => successful? ? "" : response_object.to_xml, :content_type => Mime::XML, :status => response_status }
26
- type.json { render :text => successful? ? "" : response_object.to_json, :content_type => Mime::JSON, :status => response_status }
27
- type.yaml { render :text => successful? ? "" : response_object.to_yaml, :content_type => Mime::YAML, :status => response_status }
28
- end
17
+ respond_to_action(:destroy)
29
18
  end
30
19
 
31
20
  protected
21
+ def destroy_respond_to_html
22
+ flash[:info] = as_(:deleted_model, :model => @record.to_label) if self.successful?
23
+ return_to_main
24
+ end
25
+
26
+ def destroy_respond_to_js
27
+ render(:action => 'destroy')
28
+ end
29
+
30
+ def destroy_respond_to_xml
31
+ render :xml => successful? ? "" : response_object.to_xml(:only => active_scaffold_config.list.columns.names), :content_type => Mime::XML, :status => response_status
32
+ end
33
+
34
+ def destroy_respond_to_json
35
+ render :text => successful? ? "" : response_object.to_json(:only => active_scaffold_config.list.columns.names), :content_type => Mime::JSON, :status => response_status
36
+ end
37
+
38
+ def destroy_respond_to_yaml
39
+ render :text => successful? ? "" : Hash.from_xml(response_object.to_xml(:only => active_scaffold_config.list.columns.names)).to_yaml, :content_type => Mime::YAML, :status => response_status
40
+ end
41
+
42
+ def destroy_find_record
43
+ @record = find_if_allowed(params[:id], :delete)
44
+ end
32
45
 
33
46
  # A simple method to handle the actual destroying of a record
34
47
  # May be overridden to customize the behavior
35
48
  def do_destroy
36
- @record = find_if_allowed(params[:id], :destroy)
37
- self.successful = @record.destroy
49
+ destroy_find_record
50
+ begin
51
+ self.successful = @record.destroy
52
+ marked_records.delete @record.id.to_s if successful?
53
+ rescue
54
+ flash[:warning] = as_(:cant_destroy_record, :record => @record.to_label)
55
+ self.successful = false
56
+ end
38
57
  end
39
58
 
40
59
  # The default security delegates to ActiveRecordPermissions.
41
60
  # You may override the method to customize.
42
61
  def delete_authorized?
43
- authorized_for?(:action => :destroy)
62
+ authorized_for?(:crud_type => :delete)
63
+ end
64
+ private
65
+ def delete_authorized_filter
66
+ link = active_scaffold_config.delete.link || active_scaffold_config.delete.class.link
67
+ raise ActiveScaffold::ActionNotAllowed unless self.send(link.security_method)
68
+ end
69
+ def destroy_formats
70
+ (default_formats + active_scaffold_config.formats + active_scaffold_config.delete.formats).uniq
44
71
  end
45
72
  end
46
73
  end
@@ -1,46 +1,60 @@
1
- module ActiveScaffold::Actions
2
- module FieldSearch
3
- def self.included(base)
4
- base.before_filter :field_search_authorized?, :only => :show_search
5
- base.before_filter :do_search
6
- end
7
-
8
- # FieldSearch uses params[:search] and not @record because search conditions do not always pass the Model's validations.
9
- # This facilitates for example, textual searches against associations via .search_sql
10
- def show_search
11
- params[:search] ||= {}
12
- @record = active_scaffold_config.model.new
13
- respond_to do |type|
14
- type.html { render(:action => "field_search") }
15
- type.js { render(:partial => "field_search") }
16
- end
17
- end
18
-
19
- protected
20
-
21
- def do_search
22
- unless params[:search].nil?
23
- like_pattern = active_scaffold_config.field_search.full_text_search? ? '%?%' : '?%'
24
- search_conditions = []
25
- columns = active_scaffold_config.field_search.columns
26
- columns.each do |column|
27
- search_conditions << self.class.condition_for_column(column, params[:search][column.name], like_pattern)
28
- end
29
- search_conditions.compact!
30
- self.active_scaffold_conditions = merge_conditions(self.active_scaffold_conditions, *search_conditions)
31
- @filtered = !search_conditions.blank?
32
-
33
- includes_for_search_columns = columns.collect{ |column| column.includes}.flatten.uniq.compact
34
- self.active_scaffold_joins.concat includes_for_search_columns
35
-
36
- active_scaffold_config.list.user.page = nil
37
- end
38
- end
39
-
40
- # The default security delegates to ActiveRecordPermissions.
41
- # You may override the method to customize.
42
- def field_search_authorized?
43
- authorized_for?(:action => :read)
44
- end
45
- end
46
- end
1
+ module ActiveScaffold::Actions
2
+ module FieldSearch
3
+ include ActiveScaffold::Actions::CommonSearch
4
+ def self.included(base)
5
+ base.before_filter :search_authorized_filter, :only => :show_search
6
+ base.before_filter :store_search_params_into_session, :only => [:list, :index]
7
+ base.before_filter :do_search, :only => [:list, :index]
8
+ base.helper_method :field_search_params
9
+ end
10
+
11
+ # FieldSearch uses params[:search] and not @record because search conditions do not always pass the Model's validations.
12
+ # This facilitates for example, textual searches against associations via .search_sql
13
+ def show_search
14
+ @record = active_scaffold_config.model.new
15
+ respond_to_action(:field_search)
16
+ end
17
+
18
+ protected
19
+ def field_search_params
20
+ search_params || {}
21
+ end
22
+
23
+ def field_search_respond_to_html
24
+ render(:action => "field_search")
25
+ end
26
+
27
+ def field_search_respond_to_js
28
+ render(:partial => "field_search")
29
+ end
30
+
31
+ def do_search
32
+ unless search_params.blank?
33
+ text_search = active_scaffold_config.field_search.text_search
34
+ search_conditions = []
35
+ columns = active_scaffold_config.field_search.columns
36
+ search_params.each do |key, value|
37
+ next unless columns.include? key
38
+ search_conditions << self.class.condition_for_column(active_scaffold_config.columns[key], value, text_search)
39
+ end
40
+ search_conditions.compact!
41
+ self.active_scaffold_conditions = merge_conditions(self.active_scaffold_conditions, *search_conditions)
42
+ @filtered = !search_conditions.blank?
43
+
44
+ includes_for_search_columns = columns.collect{ |column| column.includes}.flatten.uniq.compact
45
+ self.active_scaffold_includes.concat includes_for_search_columns
46
+
47
+ active_scaffold_config.list.user.page = nil
48
+ end
49
+ end
50
+
51
+ private
52
+ def search_authorized_filter
53
+ link = active_scaffold_config.field_search.link || active_scaffold_config.field_search.class.link
54
+ raise ActiveScaffold::ActionNotAllowed unless self.send(link.security_method)
55
+ end
56
+ def field_search_formats
57
+ (default_formats + active_scaffold_config.formats + active_scaffold_config.field_search.formats).uniq
58
+ end
59
+ end
60
+ end
@@ -1,29 +1,14 @@
1
1
  module ActiveScaffold::Actions
2
2
  module List
3
3
  def self.included(base)
4
- base.before_filter :list_authorized?, :only => [:index, :table, :update_table, :row, :list]
4
+ base.before_filter :list_authorized_filter, :only => [:index, :row, :list]
5
+ base.send :include, ActiveScaffold::Actions::Mark if base.active_scaffold_config.list.mark_records
5
6
  end
6
7
 
7
8
  def index
8
9
  list
9
10
  end
10
11
 
11
- def table
12
- do_list
13
- render(:action => 'list', :layout => false)
14
- end
15
-
16
- # This is called when changing pages, sorts and search
17
- def update_table
18
- respond_to do |type|
19
- type.js do
20
- do_list
21
- render(:partial => 'list')
22
- end
23
- type.html { return_to_main }
24
- end
25
- end
26
-
27
12
  # get just a single row
28
13
  def row
29
14
  render :partial => 'list_record', :locals => {:record => find_if_allowed(params[:id], :read)}
@@ -31,39 +16,52 @@ module ActiveScaffold::Actions
31
16
 
32
17
  def list
33
18
  do_list
34
- if active_scaffold_config.list.always_show_create
35
- do_new
36
- end
37
- respond_to do |type|
38
- type.html { render :action => 'list' }
39
- type.js { render :action => 'list', :layout => false }
40
- type.xml { render :xml => response_object.to_xml, :content_type => Mime::XML, :status => response_status }
41
- type.json { render :text => response_object.to_json, :content_type => Mime::JSON, :status => response_status }
42
- type.yaml { render :text => response_object.to_yaml, :content_type => Mime::YAML, :status => response_status }
43
- end
19
+ do_new if active_scaffold_config.list.always_show_create
20
+ @record ||= active_scaffold_config.model.new if active_scaffold_config.list.always_show_search
21
+ respond_to_action(:list)
44
22
  end
45
-
23
+
46
24
  protected
25
+ def list_respond_to_html
26
+ render :action => 'list', :layout => !respond_to?(:component_request?) || !component_request?
27
+ end
28
+ def list_respond_to_js
29
+ render :action => 'list.js'
30
+ end
31
+ def list_respond_to_xml
32
+ render :xml => response_object.to_xml(:only => active_scaffold_config.list.columns.names), :content_type => Mime::XML, :status => response_status
33
+ end
34
+ def list_respond_to_json
35
+ render :text => response_object.to_json(:only => active_scaffold_config.list.columns.names), :content_type => Mime::JSON, :status => response_status
36
+ end
37
+ def list_respond_to_yaml
38
+ render :text => Hash.from_xml(response_object.to_xml(:only => active_scaffold_config.list.columns.names)).to_yaml, :content_type => Mime::YAML, :status => response_status
39
+ end
40
+
41
+ def set_includes_for_list_columns
42
+ includes_for_list_columns = active_scaffold_config.list.columns.collect{ |c| c.includes }.flatten.uniq.compact
43
+ self.active_scaffold_includes.concat includes_for_list_columns
44
+ end
47
45
 
48
46
  # The actual algorithm to prepare for the list view
49
47
  def do_list
50
- includes_for_list_columns = active_scaffold_config.list.columns.collect{ |c| c.includes }.flatten.uniq.compact
51
- self.active_scaffold_joins.concat includes_for_list_columns
48
+ set_includes_for_list_columns
52
49
 
53
50
  options = { :sorting => active_scaffold_config.list.user.sorting,
54
51
  :count_includes => active_scaffold_config.list.user.count_includes }
55
- paginate = (params[:format].nil?) ? (accepts? :html, :js) : [:html, :js].include?(params[:format])
52
+ paginate = (params[:format].nil?) ? (accepts? :html, :js) : ['html', 'js'].include?(params[:format])
56
53
  if paginate
57
54
  options.merge!({
58
55
  :per_page => active_scaffold_config.list.user.per_page,
59
- :page => active_scaffold_config.list.user.page
56
+ :page => active_scaffold_config.list.user.page,
57
+ :pagination => active_scaffold_config.list.pagination
60
58
  })
61
59
  end
62
60
 
63
- page = find_page(options);
64
- if page.items.empty?
65
- page = page.pager.first
66
- active_scaffold_config.list.user.page = 1
61
+ page = find_page(options)
62
+ if page.items.blank? && !page.pager.infinite?
63
+ page = page.pager.last
64
+ active_scaffold_config.list.user.page = page.number
67
65
  end
68
66
  @page, @records = page, page.items
69
67
  end
@@ -71,7 +69,14 @@ module ActiveScaffold::Actions
71
69
  # The default security delegates to ActiveRecordPermissions.
72
70
  # You may override the method to customize.
73
71
  def list_authorized?
74
- authorized_for?(:action => :read)
72
+ authorized_for?(:crud_type => :read)
73
+ end
74
+ private
75
+ def list_authorized_filter
76
+ raise ActiveScaffold::ActionNotAllowed unless list_authorized?
77
+ end
78
+ def list_formats
79
+ (default_formats + active_scaffold_config.formats + active_scaffold_config.list.formats).uniq
75
80
  end
76
81
  end
77
82
  end
@@ -0,0 +1,72 @@
1
+ module ActiveScaffold::Actions
2
+ module Mark
3
+
4
+ def self.included(base)
5
+ base.before_filter :mark_authorized?, :only => :mark
6
+ #base.prepend_before_filter :assign_marked_records_to_model
7
+ base.helper_method :marked_records
8
+ end
9
+
10
+ def mark
11
+ if mark?
12
+ do_mark
13
+ else
14
+ do_unmark
15
+ end
16
+ mark_respond_to_js
17
+ end
18
+
19
+ protected
20
+ # We need to give the ActiveRecord classes a handle to currently marked records. We don't want to just pass the object,
21
+ # because the object may change. So we give ActiveRecord a proc that ties to the
22
+ # marked_records_method on this ApplicationController.
23
+ def assign_marked_records_to_model
24
+ active_scaffold_config.model.marked_records_proc = proc {send(:marked_records)}
25
+ end
26
+
27
+ def mark?
28
+ params[:value] == 'true'
29
+ end
30
+
31
+ def do_mark
32
+ if params[:id]
33
+ marked_records << params[:id]
34
+ else
35
+ each_record_in_scope {|record| marked_records << record.id.to_s}
36
+ end
37
+ end
38
+
39
+ def do_unmark
40
+ if params[:id]
41
+ marked_records.delete params[:id]
42
+ else
43
+ each_record_in_scope {|record| marked_records.delete(record.id.to_s)}
44
+ end
45
+ end
46
+
47
+ def each_record_in_scope
48
+ do_search if respond_to? :do_search
49
+ set_includes_for_list_columns
50
+ find_options = finder_options
51
+ find_options[:include] = nil if find_options[:conditions].nil?
52
+ beginning_of_chain.all(find_options).each {|record| yield record}
53
+ end
54
+
55
+ def mark_respond_to_js
56
+ if params[:id]
57
+ do_search if respond_to? :do_search
58
+ set_includes_for_list_columns
59
+ count = beginning_of_chain.count(count_options(finder_options, active_scaffold_config.list.user.count_includes))
60
+ @mark = marked_records.length >= count
61
+ else
62
+ @mark = mark?
63
+ end
64
+ end
65
+
66
+ # The default security delegates to ActiveRecordPermissions.
67
+ # You may override the method to customize.
68
+ def mark_authorized?
69
+ authorized_for?(:crud_type => :read)
70
+ end
71
+ end
72
+ end
@@ -8,65 +8,38 @@ module ActiveScaffold::Actions
8
8
  include ActiveScaffold::Actions::Nested::ChildMethods if active_scaffold_config.model.reflect_on_all_associations.any? {|a| a.macro == :has_and_belongs_to_many}
9
9
  end
10
10
  base.before_filter :include_habtm_actions
11
- # TODO: it's a bit wasteful to run this routine every page load.
12
- base.before_filter :links_for_associations
13
11
  base.helper_method :nested_habtm?
14
12
  end
15
13
 
16
14
  def nested
17
15
  do_nested
18
-
19
- respond_to do |type|
20
- type.html { render :partial => 'nested', :layout => true }
21
- type.js { render :partial => 'nested' }
22
- end
16
+ respond_to_action(:nested)
23
17
  end
24
18
 
25
19
  protected
26
-
20
+ def nested_respond_to_html
21
+ render :partial => 'nested', :layout => true
22
+ end
23
+ def nested_respond_to_js
24
+ render :partial => 'nested'
25
+ end
27
26
  # A simple method to find the record we'll be nesting *from*
28
27
  # May be overridden to customize the behavior
29
28
  def do_nested
30
29
  @record = find_if_allowed(params[:id], :read)
31
30
  end
32
31
 
33
- # Create the automatic column links. Note that this has to happen when configuration is *done*, because otherwise the Nested module could be disabled. Actually, it could still be disabled later, couldn't it?
34
- # TODO: This should really be a post-config routine, instead of a before_filter.
35
- def links_for_associations
36
- active_scaffold_config.list.columns.each do |column|
37
- # if column.link == false we won't create a link. that's how a dev can suppress the auto links.
38
- if column.association and column.link.nil?
39
- if column.plural_association?
40
- # note: we can't create nested scaffolds on :through associations because there's no reverse association.
41
- column.set_link('nested', :parameters => {:associations => column.name.to_sym}) #unless column.through_association?
42
- elsif not column.polymorphic_association?
43
- model = column.association.klass
44
- begin
45
- controller = self.class.active_scaffold_controller_for(model)
46
- rescue ActiveScaffold::ControllerNotFound
47
- next
48
- end
49
-
50
- actions = controller.active_scaffold_config.actions
51
- action = nil
52
- if actions.include? :update and column.actions_for_association_links.include? :edit and model.authorized_for? :action => :update
53
- action = 'edit'
54
- elsif actions.include? :show and column.actions_for_association_links.include? :show and model.authorized_for? :action => :read
55
- action = 'show'
56
- end
57
- column.set_link(action, :controller => controller.controller_path, :parameters => {:parent_controller => params[:controller]}) if action
58
- end
59
- end
60
- end
32
+ def nested_authorized?
33
+ true
61
34
  end
62
35
 
63
36
  def include_habtm_actions
64
37
  if nested_habtm?
65
38
  # Production mode is ok with adding a link everytime the scaffold is nested - we ar not ok with that.
66
- active_scaffold_config.action_links.add('new_existing', :label => 'Add Existing', :type => :table, :security_method => :add_existing_authorized?) unless active_scaffold_config.action_links['new_existing']
39
+ active_scaffold_config.action_links.add('new_existing', :label => :add_existing, :type => :collection, :security_method => :add_existing_authorized?) unless active_scaffold_config.action_links['new_existing']
67
40
  if active_scaffold_config.nested.shallow_delete
68
- active_scaffold_config.action_links.add('destroy_existing', :label => 'Remove', :type => :record, :confirm => 'are_you_sure', :method => :delete, :position => false, :security_method => :delete_existing_authorized?) unless active_scaffold_config.action_links['destroy_existing']
69
- active_scaffold_config.action_links.delete("destroy") if active_scaffold_config.action_links['destroy']
41
+ active_scaffold_config.action_links.add('destroy_existing', :label => :remove, :type => :member, :confirm => :are_you_sure_to_delete, :method => :delete, :position => false, :security_method => :delete_existing_authorized?) unless active_scaffold_config.action_links['destroy_existing']
42
+ active_scaffold_config.action_links.delete("delete") if active_scaffold_config.action_links['delete']
70
43
  end
71
44
  else
72
45
  # Production mode is caching this link into a non nested scaffold
@@ -74,7 +47,7 @@ module ActiveScaffold::Actions
74
47
 
75
48
  if active_scaffold_config.nested.shallow_delete
76
49
  active_scaffold_config.action_links.delete("destroy_existing") if active_scaffold_config.action_links['destroy_existing']
77
- active_scaffold_config.action_links.add('destroy', :label => 'Delete', :type => :record, :confirm => 'are_you_sure', :method => :delete, :position => false, :security_method => :delete_authorized?) unless active_scaffold_config.action_links['destroy']
50
+ active_scaffold_config.action_links.add(ActiveScaffold::Config::Delete.link) unless active_scaffold_config.action_links['delete']
78
51
  end
79
52
 
80
53
  end
@@ -103,7 +76,10 @@ module ActiveScaffold::Actions
103
76
  return active_scaffold_constraints.values.to_s if nested?
104
77
  nil
105
78
  end
106
-
79
+ private
80
+ def nested_formats
81
+ (default_formats + active_scaffold_config.formats + active_scaffold_config.nested.formats).uniq
82
+ end
107
83
  end
108
84
  end
109
85
 
@@ -112,73 +88,90 @@ module ActiveScaffold::Actions::Nested
112
88
 
113
89
  def self.included(base)
114
90
  super
115
- # This .verify method call is clashing with other non .add_existing actions. How do we do this correctly? Can we make it action specific.
116
- # base.verify :method => :post,
117
- # :only => :add_existing,
118
- # :redirect_to => { :action => :index }
91
+ base.verify :method => :post,
92
+ :only => :add_existing,
93
+ :redirect_to => { :action => :index }
119
94
  end
120
95
 
121
96
  def new_existing
122
97
  do_new
123
-
124
- respond_to do |type|
125
- type.html do
126
- if successful?
127
- render(:action => 'add_existing_form')
128
- else
129
- return_to_main
130
- end
131
- end
132
- type.js do
133
- render(:partial => 'add_existing_form')
134
- end
135
- end
98
+ respond_to_action(:new_existing)
136
99
  end
137
100
 
138
101
  def add_existing
139
102
  do_add_existing
140
-
141
- respond_to do |type|
142
- type.html do
143
- if successful?
144
- flash[:info] = as_(:created_model, :model => @record.to_label)
145
- return_to_main
146
- else
147
- render(:action => 'add_existing_form')
148
- end
149
- end
150
- type.js do
151
- if successful?
152
- render :action => 'add_existing'
153
- else
154
- render :action => 'form_messages'
155
- end
156
- end
157
- type.xml { render :xml => response_object.to_xml, :content_type => Mime::XML, :status => response_status }
158
- type.json { render :text => response_object.to_json, :content_type => Mime::JSON, :status => response_status }
159
- type.yaml { render :text => response_object.to_yaml, :content_type => Mime::YAML, :status => response_status }
160
- end
103
+ respond_to_action(:add_existing)
161
104
  end
162
105
 
163
106
  def destroy_existing
164
107
  return redirect_to(params.merge(:action => :delete)) if request.get?
165
-
166
108
  do_destroy_existing
167
-
168
- respond_to do |type|
169
- type.html do
170
- flash[:info] = as_(:deleted_model, :model => @record.to_label)
171
- return_to_main
172
- end
173
- type.js { render(:action => 'destroy') }
174
- type.xml { render :xml => successful? ? "" : response_object.to_xml, :content_type => Mime::XML, :status => response_status }
175
- type.json { render :text => successful? ? "" : response_object.to_json, :content_type => Mime::JSON, :status => response_status }
176
- type.yaml { render :text => successful? ? "" : response_object.to_yaml, :content_type => Mime::YAML, :status => response_status }
177
- end
109
+ respond_to_action(:destroy_existing)
178
110
  end
179
111
 
180
112
  protected
113
+ def new_existing_respond_to_html
114
+ if successful?
115
+ render(:action => 'add_existing_form')
116
+ else
117
+ return_to_main
118
+ end
119
+ end
120
+ def new_existing_respond_to_js
121
+ render(:partial => 'add_existing_form')
122
+ end
123
+ def add_existing_respond_to_html
124
+ if successful?
125
+ flash[:info] = as_(:created_model, :model => @record.to_label)
126
+ return_to_main
127
+ else
128
+ render(:action => 'add_existing_form')
129
+ end
130
+ end
131
+ def add_existing_respond_to_js
132
+ if successful?
133
+ render :action => 'add_existing'
134
+ else
135
+ render :action => 'form_messages'
136
+ end
137
+ end
138
+ def add_existing_respond_to_xml
139
+ render :xml => response_object.to_xml(:only => active_scaffold_config.list.columns.names), :content_type => Mime::XML, :status => response_status
140
+ end
141
+ def add_existing_respond_to_json
142
+ render :text => response_object.to_json(:only => active_scaffold_config.list.columns.names), :content_type => Mime::JSON, :status => response_status
143
+ end
144
+ def add_existing_respond_to_yaml
145
+ render :text => Hash.from_xml(response_object.to_xml(:only => active_scaffold_config.list.columns.names)).to_yaml, :content_type => Mime::YAML, :status => response_status
146
+ end
147
+ def destroy_existing_respond_to_html
148
+ flash[:info] = as_(:deleted_model, :model => @record.to_label)
149
+ return_to_main
150
+ end
151
+
152
+ def destroy_existing_respond_to_js
153
+ render(:action => 'destroy')
154
+ end
181
155
 
156
+ def destroy_existing_respond_to_xml
157
+ render :xml => successful? ? "" : response_object.to_xml(:only => active_scaffold_config.list.columns.names), :content_type => Mime::XML, :status => response_status
158
+ end
159
+
160
+ def destroy_existing_respond_to_json
161
+ render :text => successful? ? "" : response_object.to_json(:only => active_scaffold_config.list.columns.names), :content_type => Mime::JSON, :status => response_status
162
+ end
163
+
164
+ def destroy_existing_respond_to_yaml
165
+ render :text => successful? ? "" : Hash.from_xml(response_object.to_xml(:only => active_scaffold_config.list.columns.names)).to_yaml, :content_type => Mime::YAML, :status => response_status
166
+ end
167
+
168
+ def add_existing_authorized?
169
+ true
170
+ end
171
+ def delete_existing_authorized?
172
+ true
173
+ end
174
+
182
175
  def after_create_save(record)
183
176
  if params[:association_macro] == :has_and_belongs_to_many
184
177
  params[:associated_id] = record
@@ -210,6 +203,15 @@ module ActiveScaffold::Actions::Nested
210
203
  do_destroy
211
204
  end
212
205
  end
213
-
206
+ private
207
+ def new_existing_formats
208
+ (default_formats + active_scaffold_config.formats).uniq
209
+ end
210
+ def add_existing_formats
211
+ (default_formats + active_scaffold_config.formats).uniq
212
+ end
213
+ def destroy_existing_formats
214
+ (default_formats + active_scaffold_config.formats).uniq
215
+ end
214
216
  end
215
217
  end