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.
- data/CHANGELOG +7 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +55 -0
- data/TODO.txt +36 -67
- data/app/controllers/admin/activities_controller.rb +4 -3
- data/app/controllers/admin/activities_with_prices_controller.rb +28 -14
- data/app/controllers/admin/client_accounting_controller.rb +11 -8
- data/app/controllers/admin/client_representatives_controller.rb +34 -5
- data/app/controllers/admin/clients_controller.rb +1 -1
- data/app/controllers/admin/draft_invoices_controller.rb +92 -0
- data/app/controllers/admin/{employee_client_labor_rate_controller.rb → employee_client_labor_rates_controller.rb} +1 -1
- data/app/controllers/admin/employees_controller.rb +3 -4
- data/app/controllers/admin/invoices_controller.rb +111 -53
- data/app/controllers/admin/payments_controller.rb +168 -41
- data/app/controllers/authentication_controller.rb +3 -3
- data/app/helpers/admin/activities_helper.rb +16 -13
- data/app/helpers/admin/activities_helper/labor_helper.rb +4 -4
- data/app/helpers/admin/activities_helper/proposal_helper.rb +1 -1
- data/app/helpers/admin/activities_helper/slimtimer_helper.rb +1 -1
- data/app/helpers/admin/activities_with_prices_helper.rb +2 -2
- data/app/helpers/admin/activity_type_controller_helper.rb +6 -0
- data/app/helpers/admin/activity_type_field_helper.rb +9 -9
- data/app/helpers/admin/adjustments_helper.rb +9 -1
- data/app/helpers/admin/client_accounting_helper.rb +2 -2
- data/app/helpers/admin/client_financial_transactions_helper.rb +1 -1
- data/app/helpers/admin/client_representatives_helper.rb +16 -12
- data/app/helpers/admin/clients_helper.rb +2 -0
- data/app/helpers/admin/draft_invoices_helper.rb +24 -0
- data/app/helpers/admin/{employee_client_labor_rate_helper.rb → employee_client_labor_rates_helper.rb} +8 -8
- data/app/helpers/admin/employees_helper.rb +6 -0
- data/app/helpers/admin/has_credential_column_helper.rb +8 -8
- data/app/helpers/admin/invoices_helper.rb +71 -16
- data/app/helpers/admin/is_active_column_helper.rb +2 -2
- data/app/helpers/admin/labors_helper.rb +12 -1
- data/app/helpers/admin/labors_helper/slimtimer_helper.rb +1 -1
- data/app/helpers/admin/materials_helper.rb +11 -0
- data/app/helpers/admin/payments_helper.rb +204 -29
- data/app/helpers/admin/proposals_helper.rb +10 -0
- data/app/helpers/admin/settings_helper.rb +1 -1
- data/app/helpers/admin_layout_helper.rb +3 -6
- data/app/helpers/authentication_helper.rb +7 -10
- data/app/helpers/money_model_helper.rb +1 -2
- data/app/models/activity.rb +17 -7
- data/app/models/client.rb +35 -8
- data/app/{model_views → models}/client_financial_transaction.rb +0 -0
- data/app/models/client_representative.rb +6 -14
- data/app/models/credential.rb +1 -1
- data/app/models/employee.rb +9 -11
- data/app/models/invoice.rb +13 -9
- data/app/models/invoice_payment.rb +1 -1
- data/app/models/notifier.rb +2 -2
- data/app/models/payment.rb +51 -7
- data/app/models/setting.rb +3 -1
- data/app/views/active_scaffold_overrides/add_existing.js.rjs +25 -0
- data/app/views/admin/activities/_adjustment_column.html.erb +10 -0
- data/app/views/admin/activities/{_form.rhtml → _form.html.erb} +0 -0
- data/app/views/admin/activities/{_form_attribute.rhtml → _form_attribute.html.erb} +0 -0
- data/app/views/admin/activities/{_labor_column.rhtml → _labor_column.html.erb} +0 -0
- data/app/views/admin/activities/{_material_column.rhtml → _material_column.html.erb} +0 -0
- data/app/views/admin/activities/{_proposal_column.rhtml → _proposal_column.html.erb} +0 -0
- data/app/views/admin/activities_with_prices/{move_to_invoice.rhtml → move_to_invoice.html.erb} +2 -2
- data/app/views/admin/activities_with_prices/move_to_invoice.js.rjs +5 -0
- data/app/views/admin/draft_invoices/batch_create.html.erb +73 -0
- data/app/views/admin/draft_invoices/batch_create.js.rjs +5 -0
- data/app/views/admin/invoices/confirm_publish_modal.html.erb +48 -0
- data/app/views/admin/payments/commit_payment_warning.html.erb +8 -0
- data/app/views/admin/payments/observation_error.js.rjs +28 -0
- data/app/views/admin/payments/on_assignment_observation.js.rjs +28 -0
- data/app/views/authentication/{email.rjs → email.js.rjs} +0 -0
- data/app/views/authentication/{login.rhtml → login.html.erb} +21 -26
- data/app/views/authentication/{login.rjs → login.js.rjs} +0 -0
- data/app/views/authentication/{reset_password_via_token.rhtml → reset_password_via_token.html.erb} +0 -0
- data/app/views/authentication/{reset_password_via_token.rjs → reset_password_via_token.js.rjs} +0 -0
- data/app/views/authentication/{sign_in_error.rjs → sign_in_error.js.rjs} +0 -0
- data/app/views/layouts/{_navigation_tree.rhtml → _navigation_tree.html.erb} +0 -0
- data/app/views/layouts/{admin.rhtml → admin.html.erb} +0 -0
- data/app/views/layouts/{public.rhtml → public.html.erb} +0 -0
- data/app/views/notifier/{_email_footer.html.rhtml → _email_footer.html.erb} +0 -0
- data/app/views/notifier/{_email_footer.plain.rhtml → _email_footer.plain.erb} +0 -0
- data/app/views/notifier/{_email_header.html.rhtml → _email_header.html.erb} +0 -0
- data/app/views/notifier/invoice_available.html.erb +5 -0
- data/app/views/notifier/{invoice_available.plain.rhtml → invoice_available.plain.erb} +1 -1
- data/app/views/notifier/{reset_password_requested.html.rhtml → reset_password_requested.html.erb} +2 -2
- data/app/views/notifier/{reset_password_requested.plain.rhtml → reset_password_requested.plain.erb} +1 -1
- data/config/environment.rb +6 -5
- data/config/locale/en.rb +9 -0
- data/db/migrate/001_create_employees.rb +1 -1
- data/db/migrate/002_create_employee_slimtimers.rb +1 -1
- data/db/migrate/003_create_slimtimer_tasks.rb +1 -1
- data/db/migrate/004_create_slimtimer_time_entries.rb +1 -1
- data/db/migrate/005_create_clients.rb +1 -1
- data/db/migrate/006_create_client_representatives.rb +1 -1
- data/db/migrate/008_create_activities.rb +1 -1
- data/db/migrate/009_create_activity_labors.rb +1 -1
- data/db/migrate/010_create_employee_client_labor_rates.rb +1 -1
- data/db/migrate/011_create_activity_adjustments.rb +1 -1
- data/db/migrate/012_create_activity_materials.rb +1 -1
- data/db/migrate/013_create_activity_proposals.rb +1 -1
- data/db/migrate/014_create_invoices.rb +1 -1
- data/db/migrate/015_create_payments.rb +1 -1
- data/db/migrate/016_create_payment_methods.rb +1 -1
- data/db/migrate/017_create_invoice_payments.rb +1 -1
- data/db/migrate/018_create_activity_types.rb +2 -2
- data/db/migrate/019_create_settings.rb +1 -1
- data/db/migrate/023_create_credentials_migrate_representatives.rb +2 -2
- data/db/migrate/028_money_to_cents.rb +2 -2
- data/db/schema.rb +10 -10
- data/lib/brisk-bills.rb +2 -2
- data/lib/brisk-bills/initializer.rb +2 -2
- data/lib/generators/instance/templates/instance_environment.rb +1 -1
- data/lib/libpptable.rb +48 -0
- data/lib/tasks/create_last_months_invoices.rake +1 -14
- data/lib/tasks/first_time_setup.rake +2 -2
- data/lib/tasks/package.rake +2 -1
- data/lib/tasks/payment_assignment_consistency_check.rake +110 -0
- data/lib/utilities.rb +4 -4
- data/public/images/page-new.gif +0 -0
- data/public/javascripts/active_scaffold/default/active_scaffold.js +532 -430
- data/public/javascripts/active_scaffold/default/dhtml_history.js +1 -1
- data/public/javascripts/active_scaffold/default/form_enhancements.js +7 -4
- data/public/stylesheets/active_scaffold/default/stylesheet-ie.css +5 -5
- data/public/stylesheets/active_scaffold/default/stylesheet.css +54 -18
- data/public/stylesheets/admin/global.css +1 -1
- data/public/stylesheets/admin/pages.css +29 -0
- data/test/unit/activity/adjustment_test.rb +1 -1
- data/test/unit/activity/labor_test.rb +1 -1
- data/test/unit/activity/material_test.rb +1 -1
- data/test/unit/activity/proposal_test.rb +1 -1
- data/test/unit/activity_test.rb +1 -1
- data/test/unit/activity_type_test.rb +1 -1
- data/test/unit/client_eventlog_test.rb +1 -1
- data/test/unit/client_financial_transaction_test.rb +1 -1
- data/test/unit/client_representative_test.rb +1 -1
- data/test/unit/client_test.rb +37 -6
- data/test/unit/credential_test.rb +1 -1
- data/test/unit/employee/slimtimer_test.rb +1 -1
- data/test/unit/employee_client_labor_rate_test.rb +1 -1
- data/test/unit/employee_test.rb +1 -1
- data/test/unit/helpers/admin/draft_invoices_helper_test.rb +4 -0
- data/test/unit/invoice_payment_test.rb +90 -50
- data/test/unit/invoice_test.rb +48 -8
- data/test/unit/notifier_test.rb +1 -1
- data/test/unit/payment_method_test.rb +1 -1
- data/test/unit/payment_test.rb +7 -7
- data/test/unit/setting_test.rb +1 -1
- data/test/unit/slimtimer_task_test.rb +1 -1
- data/test/unit/slimtimer_time_entry_test.rb +1 -1
- data/vendor/plugins/active_scaffold/CHANGELOG +3 -1
- data/vendor/plugins/active_scaffold/README +18 -5
- data/vendor/plugins/active_scaffold/environment.rb +1 -1
- data/vendor/plugins/active_scaffold/frontends/default/javascripts/active_scaffold.js +532 -430
- data/vendor/plugins/active_scaffold/frontends/default/javascripts/dhtml_history.js +1 -1
- data/vendor/plugins/active_scaffold/frontends/default/javascripts/form_enhancements.js +7 -4
- data/vendor/plugins/active_scaffold/frontends/default/stylesheets/stylesheet-ie.css +5 -5
- data/vendor/plugins/active_scaffold/frontends/default/stylesheets/stylesheet.css +54 -18
- data/vendor/plugins/active_scaffold/frontends/default/views/_add_existing_form.html.erb +3 -7
- data/vendor/plugins/active_scaffold/frontends/default/views/_create_form.html.erb +10 -7
- data/vendor/plugins/active_scaffold/frontends/default/views/_field_search.html.erb +7 -12
- data/vendor/plugins/active_scaffold/frontends/default/views/_form.html.erb +3 -3
- data/vendor/plugins/active_scaffold/frontends/default/views/_form_association.html.erb +15 -20
- data/vendor/plugins/active_scaffold/frontends/default/views/_form_association_footer.html.erb +8 -10
- data/vendor/plugins/active_scaffold/frontends/default/views/_form_attribute.html.erb +5 -2
- data/vendor/plugins/active_scaffold/frontends/default/views/_form_hidden_attribute.html.erb +2 -1
- data/vendor/plugins/active_scaffold/frontends/default/views/_horizontal_subform.html.erb +19 -21
- data/vendor/plugins/active_scaffold/frontends/default/views/{_form_association_header.html.erb → _horizontal_subform_header.html.erb} +2 -2
- data/vendor/plugins/active_scaffold/frontends/default/views/_horizontal_subform_record.html.erb +31 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_list.html.erb +4 -18
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_actions.html.erb +18 -5
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_calculations.html.erb +2 -9
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_column_headings.html.erb +4 -4
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_header.html.erb +6 -6
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_inline_adapter.html.erb +2 -1
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_messages.html.erb +20 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_pagination.html.erb +11 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_pagination_links.html.erb +3 -5
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_record.html.erb +2 -26
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_record_columns.html.erb +9 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_nested.html.erb +3 -12
- data/vendor/plugins/active_scaffold/frontends/default/views/_render_fields.js.rjs +11 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_search.html.erb +17 -11
- data/vendor/plugins/active_scaffold/frontends/default/views/_show.html.erb +3 -3
- data/vendor/plugins/active_scaffold/frontends/default/views/_show_columns.html.erb +8 -7
- data/vendor/plugins/active_scaffold/frontends/default/views/_update_actions.html.erb +3 -3
- data/vendor/plugins/active_scaffold/frontends/default/views/_update_form.html.erb +9 -6
- data/vendor/plugins/active_scaffold/frontends/default/views/_vertical_subform.html.erb +7 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_vertical_subform_record.html.erb +38 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/add_existing.js.rjs +2 -1
- data/vendor/plugins/active_scaffold/frontends/default/views/delete.html.erb +1 -1
- data/vendor/plugins/active_scaffold/frontends/default/views/destroy.js.rjs +2 -2
- data/vendor/plugins/active_scaffold/frontends/default/views/edit_associated.js.rjs +20 -15
- data/vendor/plugins/active_scaffold/frontends/default/views/list.html.erb +12 -8
- data/vendor/plugins/active_scaffold/frontends/default/views/list.js.rjs +1 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/mark.js.rjs +6 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/on_create.js.rjs +12 -8
- data/vendor/plugins/active_scaffold/frontends/default/views/on_update.js.rjs +13 -6
- data/vendor/plugins/active_scaffold/frontends/default/views/render_field.js.rjs +1 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/search.html.erb +2 -2
- data/vendor/plugins/active_scaffold/frontends/default/views/update.html.erb +2 -2
- data/vendor/plugins/active_scaffold/frontends/default/views/update_column.js.rjs +4 -3
- data/vendor/plugins/active_scaffold/frontends/default/views/update_row.js.rjs +2 -0
- data/vendor/plugins/active_scaffold/init.rb +2 -2
- data/vendor/plugins/active_scaffold/install.rb +1 -2
- data/vendor/plugins/active_scaffold/install_assets.rb +1 -1
- data/vendor/plugins/active_scaffold/lib/active_record_permissions.rb +53 -42
- data/vendor/plugins/active_scaffold/lib/active_scaffold.rb +96 -23
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/common_search.rb +18 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/core.rb +152 -102
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/create.rb +81 -49
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/delete.rb +44 -17
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/field_search.rb +60 -46
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/list.rb +42 -37
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/mark.rb +72 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/nested.rb +94 -92
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/search.rb +54 -40
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/show.rb +30 -10
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/update.rb +62 -47
- data/vendor/plugins/active_scaffold/lib/active_scaffold/attribute_params.rb +187 -185
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/base.rb +28 -3
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/core.rb +43 -3
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/create.rb +8 -15
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/delete.rb +3 -4
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/field_search.rb +19 -17
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/form.rb +2 -9
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/list.rb +46 -9
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/nested.rb +17 -7
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/search.rb +36 -16
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/show.rb +5 -12
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/subform.rb +8 -6
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/update.rb +12 -8
- data/vendor/plugins/active_scaffold/lib/active_scaffold/configurable.rb +2 -2
- data/vendor/plugins/active_scaffold/lib/active_scaffold/constraints.rb +173 -178
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_columns.rb +101 -97
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_link.rb +29 -19
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/column.rb +74 -34
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/columns.rb +74 -74
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/set.rb +57 -62
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/sorting.rb +73 -3
- data/vendor/plugins/active_scaffold/lib/active_scaffold/finder.rb +304 -234
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/association_helpers.rb +40 -40
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/controller_helpers.rb +39 -24
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/country_helpers.rb +32 -28
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb +157 -86
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/id_helpers.rb +7 -7
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb +278 -85
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/pagination_helpers.rb +38 -12
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/search_column_helpers.rb +74 -35
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/show_column_helpers.rb +53 -46
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/view_helpers.rb +51 -17
- data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/de.yml +69 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/en.yml +72 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/es.yml +23 -13
- data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/fr.yml +68 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/hu.yml +24 -14
- data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/ja.yml +69 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/ru.yml +72 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/marked_model.rb +38 -0
- data/vendor/plugins/active_scaffold/lib/bridges/calendar_date_select/lib/as_cds_bridge.rb +47 -13
- data/vendor/plugins/active_scaffold/lib/bridges/dependent_protect/bridge.rb +10 -0
- data/vendor/plugins/active_scaffold/lib/bridges/dependent_protect/lib/dependent_protect_bridge.rb +11 -0
- data/vendor/plugins/active_scaffold/lib/bridges/file_column/lib/as_file_column_bridge.rb +3 -6
- data/vendor/plugins/active_scaffold/lib/bridges/file_column/lib/form_ui.rb +10 -2
- data/vendor/plugins/active_scaffold/lib/bridges/paperclip/bridge.rb +13 -0
- data/vendor/plugins/active_scaffold/lib/bridges/paperclip/lib/form_ui.rb +20 -0
- data/vendor/plugins/active_scaffold/lib/bridges/paperclip/lib/list_ui.rb +16 -0
- data/vendor/plugins/active_scaffold/lib/bridges/paperclip/lib/paperclip_bridge.rb +32 -0
- data/vendor/plugins/active_scaffold/lib/bridges/paperclip/lib/paperclip_bridge_helpers.rb +18 -0
- data/vendor/plugins/active_scaffold/lib/bridges/record_select/bridge.rb +5 -0
- data/vendor/plugins/active_scaffold/lib/bridges/record_select/lib/record_select_bridge.rb +79 -0
- data/vendor/plugins/active_scaffold/lib/bridges/semantic_attributes/bridge.rb +5 -0
- data/vendor/plugins/active_scaffold/lib/bridges/semantic_attributes/lib/semantic_attributes_bridge.rb +20 -0
- data/vendor/plugins/active_scaffold/lib/bridges/tiny_mce/bridge.rb +5 -0
- data/vendor/plugins/active_scaffold/lib/bridges/tiny_mce/lib/tiny_mce_bridge.rb +57 -0
- data/vendor/plugins/active_scaffold/lib/bridges/unobtrusive_date_picker/bridge.rb +9 -0
- data/vendor/plugins/active_scaffold/lib/bridges/unobtrusive_date_picker/lib/form_ui.rb +14 -0
- data/vendor/plugins/active_scaffold/lib/bridges/unobtrusive_date_picker/lib/unobtrusive_date_picker_bridge.rb +15 -0
- data/vendor/plugins/active_scaffold/lib/bridges/unobtrusive_date_picker/lib/view_helpers.rb +16 -0
- data/vendor/plugins/active_scaffold/lib/bridges/validation_reflection/bridge.rb +9 -0
- data/vendor/plugins/active_scaffold/lib/bridges/validation_reflection/lib/validation_reflection_bridge.rb +19 -0
- data/vendor/plugins/active_scaffold/lib/extensions/action_view_rendering.rb +20 -8
- data/vendor/plugins/active_scaffold/lib/extensions/generic_view_paths.rb +2 -2
- data/vendor/plugins/active_scaffold/lib/extensions/paginator_extensions.rb +26 -0
- data/vendor/plugins/active_scaffold/lib/extensions/resources.rb +6 -5
- data/vendor/plugins/active_scaffold/lib/extensions/reverse_associations.rb +26 -20
- data/vendor/plugins/active_scaffold/lib/extensions/unsaved_associated.rb +1 -1
- data/vendor/plugins/active_scaffold/lib/paginator.rb +1 -1
- data/vendor/plugins/active_scaffold/lib/responds_to_parent.rb +1 -1
- data/vendor/plugins/active_scaffold/shoulda_macros/macros.rb +136 -0
- data/vendor/plugins/active_scaffold/test/bridges/active_scaffold_dependent_protect_test.rb +34 -0
- data/vendor/plugins/active_scaffold/test/bridges/bridge_test.rb +43 -0
- data/vendor/plugins/active_scaffold/test/bridges/company.rb +81 -0
- data/vendor/plugins/active_scaffold/test/bridges/paperclip_test.rb +68 -0
- data/vendor/plugins/active_scaffold/test/bridges/tiny_mce_test.rb +27 -0
- data/vendor/plugins/active_scaffold/test/bridges/unobtrusive_date_picker_test.rb +49 -0
- data/vendor/plugins/active_scaffold/test/bridges/validation_reflection_test.rb +57 -0
- data/vendor/plugins/active_scaffold/test/config/base_test.rb +15 -0
- data/vendor/plugins/active_scaffold/test/config/core_test.rb +58 -0
- data/vendor/plugins/active_scaffold/test/config/create_test.rb +9 -6
- data/vendor/plugins/active_scaffold/test/config/delete_test.rb +33 -0
- data/vendor/plugins/active_scaffold/test/config/field_search_test.rb +47 -0
- data/vendor/plugins/active_scaffold/test/config/list_test.rb +66 -11
- data/vendor/plugins/active_scaffold/test/config/nested_test.rb +62 -0
- data/vendor/plugins/active_scaffold/test/config/search_test.rb +60 -0
- data/vendor/plugins/active_scaffold/test/config/show_test.rb +43 -0
- data/vendor/plugins/active_scaffold/test/config/subform_test.rb +17 -0
- data/vendor/plugins/active_scaffold/test/config/update_test.rb +27 -4
- data/vendor/plugins/active_scaffold/test/data_structures/action_columns_test.rb +2 -8
- data/vendor/plugins/active_scaffold/test/data_structures/action_link_test.rb +11 -11
- data/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb +5 -5
- data/vendor/plugins/active_scaffold/test/data_structures/association_column_test.rb +4 -3
- data/vendor/plugins/active_scaffold/test/data_structures/column_test.rb +29 -5
- data/vendor/plugins/active_scaffold/test/data_structures/sorting_test.rb +31 -1
- data/vendor/plugins/active_scaffold/test/data_structures/standard_column_test.rb +3 -13
- data/vendor/plugins/active_scaffold/test/data_structures/virtual_column_test.rb +0 -11
- data/vendor/plugins/active_scaffold/test/extensions/{array.rb → array_test.rb} +0 -0
- data/vendor/plugins/active_scaffold/test/helpers/form_column_helpers_test.rb +31 -0
- data/vendor/plugins/active_scaffold/test/helpers/list_column_helpers_test.rb +42 -0
- data/vendor/plugins/active_scaffold/test/helpers/pagination_helpers_test.rb +59 -0
- data/vendor/plugins/active_scaffold/test/misc/active_record_permissions_test.rb +154 -0
- data/vendor/plugins/active_scaffold/test/misc/attribute_params_test.rb +146 -0
- data/vendor/plugins/active_scaffold/test/misc/configurable_test.rb +2 -2
- data/vendor/plugins/active_scaffold/test/misc/constraints_test.rb +26 -8
- data/vendor/plugins/active_scaffold/test/misc/finder_test.rb +41 -19
- data/vendor/plugins/active_scaffold/test/misc/lang_test.rb +5 -6
- data/vendor/plugins/active_scaffold/test/mock_app/app/controllers/application_controller.rb +10 -0
- data/vendor/plugins/active_scaffold/test/mock_app/app/helpers/application_helper.rb +3 -0
- data/vendor/plugins/active_scaffold/test/mock_app/config/boot.rb +110 -0
- data/vendor/plugins/active_scaffold/test/mock_app/config/environment.rb +43 -0
- data/vendor/plugins/active_scaffold/test/mock_app/config/environments/development.rb +17 -0
- data/vendor/plugins/active_scaffold/test/mock_app/config/environments/production.rb +28 -0
- data/vendor/plugins/active_scaffold/test/mock_app/config/environments/test.rb +28 -0
- data/vendor/plugins/active_scaffold/test/mock_app/config/initializers/backtrace_silencers.rb +7 -0
- data/vendor/plugins/active_scaffold/test/mock_app/config/initializers/inflections.rb +10 -0
- data/vendor/plugins/active_scaffold/test/mock_app/config/initializers/mime_types.rb +5 -0
- data/vendor/plugins/active_scaffold/test/mock_app/config/initializers/new_rails_defaults.rb +19 -0
- data/vendor/plugins/active_scaffold/test/mock_app/config/initializers/session_store.rb +15 -0
- data/vendor/plugins/active_scaffold/test/mock_app/config/locales/en.yml +5 -0
- data/vendor/plugins/active_scaffold/test/mock_app/config/routes.rb +43 -0
- data/vendor/plugins/active_scaffold/test/mock_app/db/test.sqlite3 +1 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/blank.html +33 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/images/active_scaffold/DO_NOT_EDIT +2 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/images/active_scaffold/default/add.gif +0 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/images/active_scaffold/default/arrow_down.gif +0 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/images/active_scaffold/default/arrow_up.gif +0 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/images/active_scaffold/default/close.gif +0 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/images/active_scaffold/default/cross.png +0 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/images/active_scaffold/default/indicator-small.gif +0 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/images/active_scaffold/default/indicator.gif +0 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/images/active_scaffold/default/magnifier.png +0 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/javascripts/active_scaffold/DO_NOT_EDIT +2 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/javascripts/active_scaffold/default/active_scaffold.js +532 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/javascripts/active_scaffold/default/dhtml_history.js +867 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/javascripts/active_scaffold/default/form_enhancements.js +117 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/javascripts/active_scaffold/default/rico_corner.js +370 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/stylesheets/active_scaffold/DO_NOT_EDIT +2 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/stylesheets/active_scaffold/default/stylesheet-ie.css +35 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/stylesheets/active_scaffold/default/stylesheet.css +845 -0
- data/vendor/plugins/active_scaffold/test/model_stub.rb +17 -1
- data/vendor/plugins/active_scaffold/test/test_helper.rb +31 -5
- data/vendor/plugins/active_scaffold/uninstall.rb +2 -1
- data/vendor/plugins/active_scaffold_form_observation/init.rb +1 -1
- data/vendor/plugins/active_scaffold_form_observation/lib/active_scaffold_form_observation.rb +1 -2
- data/vendor/plugins/active_scaffold_full_refresh/init.rb +2 -0
- data/vendor/plugins/active_scaffold_full_refresh/lib/active_scaffold_full_refresh.rb +29 -0
- data/vendor/plugins/acts_as_money/{tasks → lib/tasks}/money_tasks.rake +0 -0
- metadata +668 -563
- data/app/model_views/client_accounting.rb +0 -5
- data/app/model_views/invoices_with_total.rb +0 -41
- data/app/views/admin/activities/_adjustment_column.rhtml +0 -23
- data/app/views/admin/activities_with_prices/move_to_invoice.rjs +0 -9
- data/app/views/notifier/invoice_available.html.rhtml +0 -5
- data/public/javascripts/prototype.js-1.6.0.3 +0 -4320
- data/test/functional/admin/activities_controller_test.rb +0 -8
- data/test/functional/admin/adjustments_controller_test.rb +0 -8
- data/test/functional/admin/client_accounting_controller_test.rb +0 -8
- data/test/functional/admin/client_financial_transactions_controller_test.rb +0 -8
- data/test/functional/admin/client_representatives_controller_test.rb +0 -8
- data/test/functional/admin/clients_controller_test.rb +0 -8
- data/test/functional/admin/employee_client_labor_rate_controller_test.rb +0 -8
- data/test/functional/admin/employees/slimtimer_controller_test.rb +0 -8
- data/test/functional/admin/employees_controller_test.rb +0 -8
- data/test/functional/admin/invoices_controller_test.rb +0 -8
- data/test/functional/admin/labors_controller_test.rb +0 -8
- data/test/functional/admin/materials_controller_test.rb +0 -8
- data/test/functional/admin/payments_controller_test.rb +0 -8
- data/test/functional/admin/proposals_controller_test.rb +0 -8
- data/test/functional/admin/settings_controller_test.rb +0 -8
- data/test/functional/authentication_controller_test.rb +0 -8
- data/vendor/plugins/active_scaffold/frontends/default/views/_form_association_record.html.erb +0 -27
- data/vendor/plugins/active_scaffold/frontends/default/views/_live_search.html.erb +0 -25
- data/vendor/plugins/active_scaffold/frontends/default/views/form_messages_on_create.js.rjs +0 -2
- data/vendor/plugins/active_scaffold/frontends/default/views/form_messages_on_update.js.rjs +0 -2
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/live_search.rb +0 -46
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/live_search.rb +0 -52
- data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/en.rb +0 -66
- data/vendor/plugins/active_scaffold/lib/extensions/name_option_for_datetime.rb +0 -12
- data/vendor/plugins/active_scaffold/test/misc/active_record_permissions.rb +0 -154
@@ -0,0 +1,38 @@
|
|
1
|
+
module ActiveScaffold
|
2
|
+
module MarkedModel
|
3
|
+
# This is a module aimed at making the make session_stored marked_records available to ActiveRecord models
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.extend ClassMethods
|
7
|
+
base.named_scope :marked, lambda {{:conditions => {:id => base.marked_records.to_a}}}
|
8
|
+
end
|
9
|
+
|
10
|
+
def marked
|
11
|
+
marked_records.include?(self.id)
|
12
|
+
end
|
13
|
+
|
14
|
+
def marked=(value)
|
15
|
+
value = (value.downcase == 'true') if value.is_a? String
|
16
|
+
if value == true
|
17
|
+
marked_records << self.id if !marked
|
18
|
+
else
|
19
|
+
marked_records.delete(self.id)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
module ClassMethods
|
24
|
+
# The proc to call that retrieves the marked_records from the ApplicationController.
|
25
|
+
attr_accessor :marked_records_proc
|
26
|
+
|
27
|
+
# Class-level access to the marked_records
|
28
|
+
def marked_records
|
29
|
+
(marked_records_proc.call || Set.new) if marked_records_proc
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Instance-level access to the marked_records
|
34
|
+
def marked_records
|
35
|
+
self.class.marked_records
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -21,7 +21,7 @@ end
|
|
21
21
|
|
22
22
|
|
23
23
|
module ActiveScaffold
|
24
|
-
module
|
24
|
+
module CalendarDateSelectBridge
|
25
25
|
# Helpers that assist with the rendering of a Form Column
|
26
26
|
module FormColumnHelpers
|
27
27
|
def active_scaffold_input_calendar_date_select(column, options)
|
@@ -29,25 +29,59 @@ module ActiveScaffold
|
|
29
29
|
calendar_date_select("record", column.name, options.merge(column.options))
|
30
30
|
end
|
31
31
|
end
|
32
|
-
end
|
33
|
-
end
|
34
32
|
|
35
|
-
module
|
36
|
-
|
37
|
-
|
33
|
+
module SearchColumnHelpers
|
34
|
+
def active_scaffold_search_calendar_date_select(column, options)
|
35
|
+
opt_value, from_value, to_value = field_search_params_range_values(column)
|
36
|
+
options = column.options.merge(options).except!(:include_blank)
|
37
|
+
helper = "select_#{'date' unless options[:discard_date]}#{'time' unless options[:discard_time]}"
|
38
|
+
html = []
|
39
|
+
html << calendar_date_select("record", column.name, options.merge(:name => "#{options[:name]}[from]", :id => "#{options[:id]}_from", :value => from_value))
|
40
|
+
html << calendar_date_select("record", column.name, options.merge(:name => "#{options[:name]}[to]", :id => "#{options[:id]}_to", :value => to_value))
|
41
|
+
html * ' - '
|
42
|
+
end
|
43
|
+
end
|
38
44
|
|
45
|
+
module ViewHelpers
|
39
46
|
# Provides stylesheets to include with +stylesheet_link_tag+
|
40
|
-
def
|
41
|
-
|
47
|
+
def active_scaffold_stylesheets(frontend = :default)
|
48
|
+
super + [calendar_date_select_stylesheets]
|
42
49
|
end
|
43
|
-
alias_method_chain :active_scaffold_stylesheets, :calendar_date_select
|
44
50
|
|
45
51
|
# Provides stylesheets to include with +stylesheet_link_tag+
|
46
|
-
def
|
47
|
-
|
52
|
+
def active_scaffold_javascripts(frontend = :default)
|
53
|
+
super + [calendar_date_select_javascripts]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
module Finder
|
58
|
+
module ClassMethods
|
59
|
+
def condition_for_calendar_date_select_type(column, value, like_pattern)
|
60
|
+
conversion = column.column.type == :date ? 'to_date' : 'to_time'
|
61
|
+
from_value, to_value = ['from', 'to'].collect do |field|
|
62
|
+
Time.zone.parse(value[field]) rescue nil
|
63
|
+
end
|
64
|
+
|
65
|
+
if from_value.nil? and to_value.nil?
|
66
|
+
nil
|
67
|
+
elsif !from_value
|
68
|
+
["#{column.search_sql} <= ?", to_value.send(conversion).to_s(:db)]
|
69
|
+
elsif !to_value
|
70
|
+
["#{column.search_sql} >= ?", from_value.send(conversion).to_s(:db)]
|
71
|
+
else
|
72
|
+
["#{column.search_sql} BETWEEN ? AND ?", from_value.send(conversion).to_s(:db), to_value.send(conversion).to_s(:db)]
|
73
|
+
end
|
74
|
+
end
|
48
75
|
end
|
49
|
-
alias_method_chain :active_scaffold_javascripts, :calendar_date_select
|
50
|
-
|
51
76
|
end
|
52
77
|
end
|
53
78
|
end
|
79
|
+
|
80
|
+
ActionView::Base.class_eval do
|
81
|
+
include ActiveScaffold::CalendarDateSelectBridge::FormColumnHelpers
|
82
|
+
include ActiveScaffold::CalendarDateSelectBridge::SearchColumnHelpers
|
83
|
+
include ActiveScaffold::CalendarDateSelectBridge::ViewHelpers
|
84
|
+
end
|
85
|
+
ActiveScaffold::Finder::ClassMethods.module_eval do
|
86
|
+
include ActiveScaffold::CalendarDateSelectBridge::Finder::ClassMethods
|
87
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
ActiveScaffold.bridge "DependentProtect" do
|
2
|
+
install do
|
3
|
+
# check to see if the old bridge was installed. If so, warn them
|
4
|
+
# we can detect this by checking to see if the bridge was installed before calling this code
|
5
|
+
if ActiveRecord::Base.instance_methods.include?("authorized_for_delete?")
|
6
|
+
raise RuntimeError, "We've detected that you have active_scaffold_dependent_protect installed. This plugin has been moved to core. Please remove active_scaffold_dependent_protect to prevent any conflicts"
|
7
|
+
end
|
8
|
+
require File.join(File.dirname(__FILE__), "lib/dependent_protect_bridge.rb")
|
9
|
+
end
|
10
|
+
end
|
data/vendor/plugins/active_scaffold/lib/bridges/dependent_protect/lib/dependent_protect_bridge.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
module DependentProtectSecurity
|
2
|
+
def self.included(base)
|
3
|
+
base.class_inheritable_accessor :dependent_associations
|
4
|
+
end
|
5
|
+
protected
|
6
|
+
def authorized_for_delete?
|
7
|
+
self.class.dependent_associations ||= self.class.reflect_on_all_associations.select {|assoc| assoc.options[:dependent] == :protect}
|
8
|
+
self.class.dependent_associations.all? {|assoc| self.send(assoc.name).blank?}
|
9
|
+
end
|
10
|
+
end
|
11
|
+
ActiveRecord::Base.class_eval { include DependentProtectSecurity }
|
@@ -1,8 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
class Column
|
4
|
-
attr_accessor :file_column_display
|
5
|
-
end
|
1
|
+
ActiveScaffold::DataStructures::Column.class_eval do
|
2
|
+
attr_accessor :file_column_display
|
6
3
|
end
|
7
4
|
|
8
5
|
module ActiveScaffold::Config
|
@@ -46,4 +43,4 @@ module ActiveScaffold::Config
|
|
46
43
|
end
|
47
44
|
|
48
45
|
end
|
49
|
-
end
|
46
|
+
end
|
@@ -5,12 +5,20 @@ module ActiveScaffold
|
|
5
5
|
def active_scaffold_input_file_column(column, options)
|
6
6
|
if @record.send(column.name)
|
7
7
|
# we already have a value? display the form for deletion.
|
8
|
+
|
9
|
+
# generate hidden field tag
|
10
|
+
hidden_options = options.dup
|
11
|
+
hidden_options[:id] += '_delete'
|
12
|
+
hidden_options[:name].sub!("[#{column.name}]", "[delete_#{column.name}]")
|
13
|
+
hidden_options[:value] = 'false'
|
14
|
+
custom_hidden_field_tag = hidden_field(:record, column.name, hidden_options)
|
15
|
+
|
8
16
|
content_tag(
|
9
17
|
:div,
|
10
18
|
content_tag(
|
11
19
|
:div,
|
12
20
|
get_column_value(@record, column) + " " +
|
13
|
-
|
21
|
+
custom_hidden_field_tag +
|
14
22
|
" | " +
|
15
23
|
link_to_function(as_(:remove_file), "$(this).previous().value='true'; p=$(this).up(); p.hide(); p.next().show();"),
|
16
24
|
{}
|
@@ -29,4 +37,4 @@ module ActiveScaffold
|
|
29
37
|
end
|
30
38
|
end
|
31
39
|
end
|
32
|
-
end
|
40
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "lib/paperclip_bridge_helpers")
|
2
|
+
ActiveScaffold.bridge "Paperclip" do
|
3
|
+
install do
|
4
|
+
if ActiveScaffold::Config::Core.instance_methods.include?("initialize_with_paperclip")
|
5
|
+
raise RuntimeError, "We've detected that you have active_scaffold_paperclip_bridge installed. This plugin has been moved to core. Please remove active_scaffold_paperclip_bridge to prevent any conflicts"
|
6
|
+
end
|
7
|
+
|
8
|
+
require File.join(File.dirname(__FILE__), "lib/paperclip_bridge")
|
9
|
+
require File.join(File.dirname(__FILE__), "lib/form_ui")
|
10
|
+
require File.join(File.dirname(__FILE__), "lib/list_ui")
|
11
|
+
ActiveScaffold::Config::Core.send :include, ActiveScaffold::PaperclipBridge
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module ActiveScaffold
|
2
|
+
module Helpers
|
3
|
+
module FormColumnHelpers
|
4
|
+
def active_scaffold_input_paperclip(column, options)
|
5
|
+
input = file_field(:record, column.name, options)
|
6
|
+
paperclip = @record.send("#{column.name}")
|
7
|
+
if paperclip.file?
|
8
|
+
content = active_scaffold_column_paperclip(column, @record)
|
9
|
+
content_tag(:div,
|
10
|
+
content + " | " +
|
11
|
+
link_to_function(as_(:remove_file), "$(this).next().value='true'; $(this).up().hide().next().show()") +
|
12
|
+
hidden_field(:record, "delete_#{column.name}", :value => "false")
|
13
|
+
) + content_tag(:div, input, :style => "display: none")
|
14
|
+
else
|
15
|
+
input
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module ActiveScaffold
|
2
|
+
module Helpers
|
3
|
+
module ListColumnHelpers
|
4
|
+
def active_scaffold_column_paperclip(column, record)
|
5
|
+
paperclip = record.send("#{column.name}")
|
6
|
+
return nil unless paperclip.file?
|
7
|
+
content = if paperclip.styles.include?(PaperclipBridgeHelpers.thumbnail_style)
|
8
|
+
image_tag(paperclip.url(PaperclipBridgeHelpers.thumbnail_style), :border => 0)
|
9
|
+
else
|
10
|
+
paperclip.original_filename
|
11
|
+
end
|
12
|
+
link_to(content, paperclip.url, :popup => true)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module ActiveScaffold
|
2
|
+
module PaperclipBridge
|
3
|
+
def initialize_with_paperclip(model_id)
|
4
|
+
initialize_without_paperclip(model_id)
|
5
|
+
return if self.model.attachment_definitions.nil?
|
6
|
+
|
7
|
+
self.update.multipart = true
|
8
|
+
self.create.multipart = true
|
9
|
+
|
10
|
+
self.model.attachment_definitions.keys.each do |field|
|
11
|
+
configure_paperclip_field(field.to_sym)
|
12
|
+
# define the "delete" helper for use with active scaffold, unless it's already defined
|
13
|
+
PaperclipBridgeHelpers.generate_delete_helper(self.model, field)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.included(base)
|
18
|
+
base.alias_method_chain :initialize, :paperclip
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
def configure_paperclip_field(field)
|
23
|
+
self.columns << field
|
24
|
+
self.columns[field].form_ui ||= :paperclip
|
25
|
+
self.columns[field].params.add "delete_#{field}"
|
26
|
+
|
27
|
+
[:file_name, :content_type, :file_size, :updated_at].each do |f|
|
28
|
+
self.columns.exclude("#{field}_#{f}".to_sym)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module PaperclipBridgeHelpers
|
2
|
+
mattr_accessor :thumbnail_style
|
3
|
+
self.thumbnail_style = :thumbnail
|
4
|
+
|
5
|
+
def self.generate_delete_helper(klass, field)
|
6
|
+
klass.class_eval <<-EOF, __FILE__, __LINE__ + 1 unless klass.methods.include?("delete_#{field}=")
|
7
|
+
attr_reader :delete_#{field}
|
8
|
+
|
9
|
+
def delete_#{field}=(value)
|
10
|
+
value = (value == "true") if String === value
|
11
|
+
return unless value
|
12
|
+
|
13
|
+
# passing nil to the file column causes the file to be deleted. Don't delete if we just uploaded a file!
|
14
|
+
self.#{field} = nil unless self.#{field}.dirty?
|
15
|
+
end
|
16
|
+
EOF
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module ActiveScaffold
|
2
|
+
module RecordSelectBridge
|
3
|
+
def self.included(base)
|
4
|
+
base.class_eval do
|
5
|
+
include FormColumnHelpers
|
6
|
+
include SearchColumnHelpers
|
7
|
+
include ViewHelpers
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module ViewHelpers
|
12
|
+
def self.included(base)
|
13
|
+
base.alias_method_chain :active_scaffold_includes, :record_select
|
14
|
+
end
|
15
|
+
|
16
|
+
def active_scaffold_includes_with_record_select(*args)
|
17
|
+
active_scaffold_includes_without_record_select(*args) + record_select_includes
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
module FormColumnHelpers
|
22
|
+
# requires RecordSelect plugin to be installed and configured.
|
23
|
+
def active_scaffold_input_record_select(column, options)
|
24
|
+
if column.singular_association?
|
25
|
+
active_scaffold_record_select(column, options, @record.send(column.name), false)
|
26
|
+
elsif column.plural_association?
|
27
|
+
active_scaffold_record_select(column, options, @record.send(column.name), true)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def active_scaffold_record_select(column, options, value, multiple)
|
32
|
+
unless column.association
|
33
|
+
raise ArgumentError, "record_select can only work against associations (and #{column.name} is not). A common mistake is to specify the foreign key field (like :user_id), instead of the association (:user)."
|
34
|
+
end
|
35
|
+
remote_controller = active_scaffold_controller_for(column.association.klass).controller_path
|
36
|
+
|
37
|
+
# if the opposite association is a :belongs_to (in that case association in this class must be has_one or has_many)
|
38
|
+
# then only show records that have not been associated yet
|
39
|
+
if [:has_one, :has_many].include?(column.association.macro)
|
40
|
+
params.merge!({column.association.primary_key_name => ''})
|
41
|
+
end
|
42
|
+
|
43
|
+
record_select_options = {:controller => remote_controller, :id => options[:id]}
|
44
|
+
record_select_options.merge!(options)
|
45
|
+
record_select_options.merge!(active_scaffold_input_text_options)
|
46
|
+
record_select_options.merge!(column.options)
|
47
|
+
record_select_options[:onchange] = "function(id, label) { this.value = id; #{record_select_options[:onchange]} }" if record_select_options[:onchange]
|
48
|
+
|
49
|
+
if multiple
|
50
|
+
record_multi_select_field(options[:name], value || [], record_select_options)
|
51
|
+
else
|
52
|
+
record_select_field(options[:name], value || column.association.klass.new, record_select_options)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
module SearchColumnHelpers
|
58
|
+
def active_scaffold_search_record_select(column, options)
|
59
|
+
begin
|
60
|
+
value = field_search_params[column.name]
|
61
|
+
value = unless value.blank?
|
62
|
+
if column.options[:multiple]
|
63
|
+
column.association.klass.find value.collect!(&:to_i)
|
64
|
+
else
|
65
|
+
column.association.klass.find(value.to_i)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
rescue Exception => e
|
69
|
+
logger.error Time.now.to_s + "Sorry, we are not that smart yet. Attempted to restore search values to search fields but instead got -- #{e.inspect} -- on the ActiveScaffold column = :#{column.name} in #{@controller.class}"
|
70
|
+
raise e
|
71
|
+
end
|
72
|
+
|
73
|
+
active_scaffold_record_select(column, options, value, column.options[:multiple])
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
ActionView::Base.class_eval { include ActiveScaffold::RecordSelectBridge }
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module ActiveScaffold
|
2
|
+
module SemanticAttributesBridge
|
3
|
+
def self.included(base)
|
4
|
+
base.class_eval { alias_method_chain :initialize, :semantic_attributes }
|
5
|
+
end
|
6
|
+
|
7
|
+
def initialize_with_semantic_attributes(name, active_record_class)
|
8
|
+
initialize_without_semantic_attributes(name, active_record_class)
|
9
|
+
self.required = !active_record_class.semantic_attributes[self.name].predicates.find {|p| p.allow_empty? == false }.nil?
|
10
|
+
active_record_class.semantic_attributes[self.name].predicates.find do |p|
|
11
|
+
sem_type = p.class.to_s.split('::')[1].underscore.to_sym
|
12
|
+
next if [:required, :association].include?(sem_type)
|
13
|
+
@form_ui = sem_type
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
ActiveScaffold::DataStructures::Column.class_eval do
|
19
|
+
include ActiveScaffold::SemanticAttributesBridge
|
20
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module ActiveScaffold
|
2
|
+
module TinyMceBridge
|
3
|
+
def self.included(base)
|
4
|
+
base.class_eval do
|
5
|
+
include FormColumnHelpers
|
6
|
+
include SearchColumnHelpers
|
7
|
+
include ViewHelpers
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module ViewHelpers
|
12
|
+
def self.included(base)
|
13
|
+
base.alias_method_chain :active_scaffold_includes, :tiny_mce
|
14
|
+
end
|
15
|
+
|
16
|
+
def active_scaffold_includes_with_tiny_mce(*args)
|
17
|
+
tiny_mce_js = javascript_tag(%|
|
18
|
+
var action_link_close = ActiveScaffold.ActionLink.Abstract.prototype.close;
|
19
|
+
ActiveScaffold.ActionLink.Abstract.prototype.close = function() {
|
20
|
+
this.adapter.select('textarea.mceEditor').each(function(elem) {
|
21
|
+
tinyMCE.execCommand('mceRemoveControl', false, elem.id);
|
22
|
+
});
|
23
|
+
action_link_close.apply(this);
|
24
|
+
};
|
25
|
+
|) if using_tiny_mce?
|
26
|
+
active_scaffold_includes_without_tiny_mce(*args) + (include_tiny_mce_if_needed || '') + (tiny_mce_js || '')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
module FormColumnHelpers
|
31
|
+
def self.included(base)
|
32
|
+
base.alias_method_chain :onsubmit, :tiny_mce
|
33
|
+
end
|
34
|
+
|
35
|
+
def active_scaffold_input_text_editor(column, options)
|
36
|
+
options[:class] = "#{options[:class]} mceEditor #{column.options[:class]}".strip
|
37
|
+
html = []
|
38
|
+
html << send(override_input(:textarea), column, options)
|
39
|
+
html << javascript_tag("tinyMCE.execCommand('mceAddControl', false, '#{options[:id]}');") if request.xhr? || params[:iframe]
|
40
|
+
html.join "\n"
|
41
|
+
end
|
42
|
+
|
43
|
+
def onsubmit_with_tiny_mce
|
44
|
+
submit_js = 'tinyMCE.triggerSave();this.select("textarea.mceEditor").each(function(elem) { tinyMCE.execCommand("mceRemoveControl", false, elem.id); });' if using_tiny_mce?
|
45
|
+
[onsubmit_without_tiny_mce, submit_js].compact.join ';'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
module SearchColumnHelpers
|
50
|
+
def self.included(base)
|
51
|
+
base.class_eval { alias_method :active_scaffold_search_text_editor, :active_scaffold_search_text }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
ActionView::Base.class_eval { include ActiveScaffold::TinyMceBridge }
|