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
@@ -1,40 +1,40 @@
|
|
1
|
-
module ActiveScaffold
|
2
|
-
module Helpers
|
3
|
-
module AssociationHelpers
|
4
|
-
# Provides a way to honor the :conditions on an association while searching the association's klass
|
5
|
-
def association_options_find(association, conditions = nil)
|
6
|
-
association.klass.find(:all, :conditions => controller.send(:merge_conditions, conditions, association.options[:conditions]))
|
7
|
-
end
|
8
|
-
|
9
|
-
def association_options_count(association, conditions = nil)
|
10
|
-
association.klass.count(:all, :conditions => controller.send(:merge_conditions, conditions, association.options[:conditions]))
|
11
|
-
end
|
12
|
-
|
13
|
-
# returns options for the given association as a collection of [id, label] pairs intended for the +options_for_select+ helper.
|
14
|
-
def options_for_association(association, include_all = false)
|
15
|
-
available_records = association_options_find(association, include_all ? nil : options_for_association_conditions(association))
|
16
|
-
available_records ||= []
|
17
|
-
available_records.sort{|a,b| a.to_label <=> b.to_label}.collect { |model| [ model.to_label, model.id ] }
|
18
|
-
end
|
19
|
-
|
20
|
-
def options_for_association_count(association)
|
21
|
-
association_options_count(association, options_for_association_conditions(association))
|
22
|
-
end
|
23
|
-
|
24
|
-
# A useful override for customizing the records present in an association dropdown.
|
25
|
-
# Should work in both the subform and form_ui=>:select modes.
|
26
|
-
# Check association.name to specialize the conditions per-column.
|
27
|
-
def options_for_association_conditions(association)
|
28
|
-
return nil if association.options[:through]
|
29
|
-
case association.macro
|
30
|
-
when :has_one, :has_many
|
31
|
-
# Find only orphaned objects
|
32
|
-
"#{association.primary_key_name} IS NULL"
|
33
|
-
when :belongs_to, :has_and_belongs_to_many
|
34
|
-
# Find all
|
35
|
-
nil
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
1
|
+
module ActiveScaffold
|
2
|
+
module Helpers
|
3
|
+
module AssociationHelpers
|
4
|
+
# Provides a way to honor the :conditions on an association while searching the association's klass
|
5
|
+
def association_options_find(association, conditions = nil)
|
6
|
+
association.klass.find(:all, :conditions => controller.send(:merge_conditions, conditions, association.options[:conditions]))
|
7
|
+
end
|
8
|
+
|
9
|
+
def association_options_count(association, conditions = nil)
|
10
|
+
association.klass.count(:all, :conditions => controller.send(:merge_conditions, conditions, association.options[:conditions]))
|
11
|
+
end
|
12
|
+
|
13
|
+
# returns options for the given association as a collection of [id, label] pairs intended for the +options_for_select+ helper.
|
14
|
+
def options_for_association(association, include_all = false)
|
15
|
+
available_records = association_options_find(association, include_all ? nil : options_for_association_conditions(association))
|
16
|
+
available_records ||= []
|
17
|
+
available_records.sort{|a,b| a.to_label <=> b.to_label}.collect { |model| [ model.to_label, model.id ] }
|
18
|
+
end
|
19
|
+
|
20
|
+
def options_for_association_count(association)
|
21
|
+
association_options_count(association, options_for_association_conditions(association))
|
22
|
+
end
|
23
|
+
|
24
|
+
# A useful override for customizing the records present in an association dropdown.
|
25
|
+
# Should work in both the subform and form_ui=>:select modes.
|
26
|
+
# Check association.name to specialize the conditions per-column.
|
27
|
+
def options_for_association_conditions(association)
|
28
|
+
return nil if association.options[:through]
|
29
|
+
case association.macro
|
30
|
+
when :has_one, :has_many
|
31
|
+
# Find only orphaned objects
|
32
|
+
"#{association.primary_key_name} IS NULL"
|
33
|
+
when :belongs_to, :has_and_belongs_to_many
|
34
|
+
# Find all
|
35
|
+
nil
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -1,25 +1,40 @@
|
|
1
|
-
module ActiveScaffold
|
2
|
-
module Helpers
|
3
|
-
module ControllerHelpers
|
4
|
-
def self.included(controller)
|
5
|
-
controller.class_eval { helper_method :params_for }
|
6
|
-
end
|
7
|
-
|
8
|
-
include ActiveScaffold::Helpers::IdHelpers
|
9
|
-
|
10
|
-
def params_for(options = {})
|
11
|
-
# :adapter and :position are one-use rendering arguments. they should not propagate.
|
12
|
-
# :sort, :sort_direction, and :page are arguments that stored in the session. they need not propagate.
|
13
|
-
# and wow. no we don't want to propagate :record.
|
14
|
-
# :commit is a special rails variable for form buttons
|
15
|
-
blacklist = [:adapter, :position, :sort, :sort_direction, :page, :record, :commit, :_method]
|
16
|
-
unless @params_for
|
17
|
-
@params_for = params.clone.delete_if { |key, value| blacklist.include? key.to_sym if key }
|
18
|
-
@params_for[:controller] = '/' + @params_for[:controller] unless @params_for[:controller].first(1) == '/' # for namespaced controllers
|
19
|
-
@params_for.delete(:id) if @params_for[:id].nil?
|
20
|
-
end
|
21
|
-
@params_for.merge(options)
|
22
|
-
end
|
23
|
-
|
24
|
-
|
1
|
+
module ActiveScaffold
|
2
|
+
module Helpers
|
3
|
+
module ControllerHelpers
|
4
|
+
def self.included(controller)
|
5
|
+
controller.class_eval { helper_method :params_for, :main_path_to_return }
|
6
|
+
end
|
7
|
+
|
8
|
+
include ActiveScaffold::Helpers::IdHelpers
|
9
|
+
|
10
|
+
def params_for(options = {})
|
11
|
+
# :adapter and :position are one-use rendering arguments. they should not propagate.
|
12
|
+
# :sort, :sort_direction, and :page are arguments that stored in the session. they need not propagate.
|
13
|
+
# and wow. no we don't want to propagate :record.
|
14
|
+
# :commit is a special rails variable for form buttons
|
15
|
+
blacklist = [:adapter, :position, :sort, :sort_direction, :page, :record, :commit, :_method, :authenticity_token, :format]
|
16
|
+
unless @params_for
|
17
|
+
@params_for = params.clone.delete_if { |key, value| blacklist.include? key.to_sym if key }
|
18
|
+
@params_for[:controller] = '/' + @params_for[:controller] unless @params_for[:controller].first(1) == '/' # for namespaced controllers
|
19
|
+
@params_for.delete(:id) if @params_for[:id].nil?
|
20
|
+
end
|
21
|
+
@params_for.merge(options)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Parameters to generate url to the main page (override if the ActiveScaffold is used as a component on another controllers page)
|
25
|
+
def main_path_to_return
|
26
|
+
parameters = {}
|
27
|
+
if params[:parent_controller]
|
28
|
+
parameters[:controller] = params[:parent_controller]
|
29
|
+
parameters[:eid] = params[:parent_controller]
|
30
|
+
end
|
31
|
+
parameters[:nested] = nil
|
32
|
+
parameters[:parent_column] = nil
|
33
|
+
parameters[:parent_id] = nil
|
34
|
+
parameters[:action] = "index"
|
35
|
+
parameters[:id] = nil
|
36
|
+
params_for(parameters)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
25
40
|
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
I18n.load_path << File.dirname(__FILE__) + '/../../../lib/active_scaffold/locale/en-countries.yml'
|
2
|
-
|
3
1
|
module ActiveScaffold
|
4
2
|
module Helpers
|
5
3
|
module CountryHelpers
|
@@ -18,14 +16,13 @@ module ActiveScaffold
|
|
18
16
|
#
|
19
17
|
# NOTE: Only the option tags are returned, you have to wrap this call in a regular HTML select tag.
|
20
18
|
def country_options_for_select(selected = nil, priority_countries = nil)
|
21
|
-
country_options = ""
|
22
|
-
|
23
19
|
if priority_countries
|
24
|
-
country_options
|
25
|
-
|
20
|
+
country_options = options_for_select(priority_countries.collect {|country| [I18n.t("countries.#{country}", :default => country.to_s.titleize), country.to_s]} + [['-------------', '']], :selected => selected, :disabled => '')
|
21
|
+
else
|
22
|
+
country_options = ""
|
26
23
|
end
|
27
24
|
|
28
|
-
return country_options + options_for_select(COUNTRIES.collect {|country| [I18n.t("countries.#{country}"), country]}, selected)
|
25
|
+
return country_options + options_for_select(COUNTRIES.collect {|country| [I18n.t("countries.#{country}", :default => country.to_s.titleize), country.to_s]}, :selected => selected)
|
29
26
|
end
|
30
27
|
|
31
28
|
# Returns a string of option tags for the states in the United States. Supply a state name as +selected to
|
@@ -33,16 +30,16 @@ module ActiveScaffold
|
|
33
30
|
# in case you want to highligh a local area
|
34
31
|
# NOTE: Only the option tags are returned from this method, wrap it in a <select>
|
35
32
|
def usa_state_options_for_select(selected = nil, priority_states = nil)
|
36
|
-
state_options = ""
|
37
33
|
if priority_states
|
38
|
-
state_options
|
39
|
-
|
34
|
+
state_options = options_for_select(priority_states + [['-------------', '']], :selected => selected, :disabled => '')
|
35
|
+
else
|
36
|
+
state_options = ""
|
40
37
|
end
|
41
38
|
|
42
39
|
if priority_states && priority_states.include?(selected)
|
43
|
-
state_options += options_for_select(USASTATES - priority_states, selected)
|
40
|
+
state_options += options_for_select(USASTATES - priority_states, :selected => selected)
|
44
41
|
else
|
45
|
-
state_options += options_for_select(USASTATES, selected)
|
42
|
+
state_options += options_for_select(USASTATES, :selected => selected)
|
46
43
|
end
|
47
44
|
|
48
45
|
return state_options
|
@@ -305,10 +302,11 @@ module ActiveScaffold
|
|
305
302
|
html_options = html_options.stringify_keys
|
306
303
|
add_default_name_and_id(html_options)
|
307
304
|
value = value(object)
|
305
|
+
selected_value = options.has_key?(:selected) ? options[:selected] : value
|
308
306
|
content_tag("select",
|
309
307
|
add_options(
|
310
|
-
country_options_for_select(
|
311
|
-
options,
|
308
|
+
country_options_for_select(selected_value, priority_countries),
|
309
|
+
options, selected_value
|
312
310
|
), html_options
|
313
311
|
)
|
314
312
|
end
|
@@ -316,33 +314,39 @@ module ActiveScaffold
|
|
316
314
|
def to_usa_state_select_tag(priority_states, options, html_options)
|
317
315
|
html_options = html_options.stringify_keys
|
318
316
|
add_default_name_and_id(html_options)
|
319
|
-
value = value(object)
|
320
|
-
|
321
|
-
|
322
|
-
html_options[:multiple] = true
|
323
|
-
options[:include_blank] = true
|
324
|
-
end
|
325
|
-
content_tag("select", add_options(usa_state_options_for_select(value, priority_states), options, value), html_options)
|
317
|
+
value = value(object)
|
318
|
+
selected_value = options.has_key?(:selected) ? options[:selected] : value
|
319
|
+
content_tag("select", add_options(usa_state_options_for_select(selected_value, priority_states), options, selected_value), html_options)
|
326
320
|
end
|
327
321
|
end
|
328
322
|
end
|
329
323
|
|
330
324
|
module FormColumnHelpers
|
331
325
|
def active_scaffold_input_country(column, options)
|
332
|
-
priority = ["United States"]
|
333
326
|
select_options = {:prompt => as_(:_select_)}
|
334
327
|
select_options.merge!(options)
|
335
|
-
|
328
|
+
options.reverse_merge!(column.options).except!(:prompt, :priority)
|
329
|
+
options[:name] += '[]' if options[:multiple]
|
330
|
+
country_select(:record, column.name, column.options[:priority] || [:united_states], select_options, options)
|
336
331
|
end
|
337
332
|
|
338
333
|
def active_scaffold_input_usa_state(column, options)
|
339
334
|
select_options = {:prompt => as_(:_select_)}
|
340
335
|
select_options.merge!(options)
|
341
|
-
|
342
|
-
options
|
343
|
-
|
344
|
-
|
336
|
+
options.reverse_merge!(column.options).except!(:prompt, :priority)
|
337
|
+
options[:name] += '[]' if options[:multiple]
|
338
|
+
usa_state_select(:record, column.name, column.options[:priority], select_options, options)
|
339
|
+
end
|
340
|
+
end
|
341
|
+
|
342
|
+
module SearchColumnHelpers
|
343
|
+
def active_scaffold_search_country(column, options)
|
344
|
+
active_scaffold_input_country(column, options.merge!(:selected => options.delete(:value)))
|
345
|
+
end
|
346
|
+
|
347
|
+
def active_scaffold_search_usa_state(column, options)
|
348
|
+
active_scaffold_input_usa_state(column, options.merge!(:selected => options.delete(:value)))
|
345
349
|
end
|
346
350
|
end
|
347
351
|
end
|
348
|
-
end
|
352
|
+
end
|
@@ -4,37 +4,47 @@ module ActiveScaffold
|
|
4
4
|
module FormColumnHelpers
|
5
5
|
# This method decides which input to use for the given column.
|
6
6
|
# It does not do any rendering. It only decides which method is responsible for rendering.
|
7
|
-
def active_scaffold_input_for(column, scope = nil)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
7
|
+
def active_scaffold_input_for(column, scope = nil, options = {})
|
8
|
+
begin
|
9
|
+
options = active_scaffold_input_options(column, scope, options)
|
10
|
+
options = javascript_for_update_column(column, scope, options)
|
11
|
+
# first, check if the dev has created an override for this specific field
|
12
|
+
if override_form_field?(column)
|
13
|
+
send(override_form_field(column), @record, options)
|
14
|
+
# second, check if the dev has specified a valid form_ui for this column
|
15
|
+
elsif column.form_ui and override_input?(column.form_ui)
|
16
|
+
send(override_input(column.form_ui), column, options)
|
17
|
+
# fallback: we get to make the decision
|
18
|
+
else
|
19
|
+
if column.association
|
20
|
+
# if we get here, it's because the column has a form_ui but not one ActiveScaffold knows about.
|
21
|
+
raise "Unknown form_ui `#{column.form_ui}' for column `#{column.name}'"
|
22
|
+
elsif column.virtual?
|
23
|
+
active_scaffold_input_virtual(column, options)
|
24
|
+
|
25
|
+
else # regular model attribute column
|
26
|
+
# if we (or someone else) have created a custom render option for the column type, use that
|
27
|
+
if override_input?(column.column.type)
|
28
|
+
send(override_input(column.column.type), column, options)
|
29
|
+
# final ultimate fallback: use rails' generic input method
|
30
|
+
else
|
31
|
+
# for textual fields we pass different options
|
32
|
+
text_types = [:text, :string, :integer, :float, :decimal]
|
33
|
+
date_types = [:date, :datetime, :time]
|
34
|
+
options = active_scaffold_input_text_options(options) if text_types.include?(column.column.type)
|
35
|
+
options = active_scaffold_input_date_options(column, options) if date_types.include?(column.column.type)
|
36
|
+
if column.column.type == :string && options[:maxlength].blank?
|
37
|
+
options[:maxlength] = column.column.limit
|
38
|
+
options[:size] ||= ActionView::Helpers::InstanceTag::DEFAULT_FIELD_OPTIONS["size"]
|
39
|
+
end
|
40
|
+
options[:value] = format_number_value(@record.send(column.name), column.options) if column.column.number?
|
41
|
+
input(:record, column.name, options.merge(column.options))
|
42
|
+
end
|
36
43
|
end
|
37
44
|
end
|
45
|
+
rescue Exception => e
|
46
|
+
logger.error Time.now.to_s + "#{e.inspect} -- on the ActiveScaffold column = :#{column.name} in #{@controller.class}"
|
47
|
+
raise e
|
38
48
|
end
|
39
49
|
end
|
40
50
|
|
@@ -47,44 +57,77 @@ module ActiveScaffold
|
|
47
57
|
options
|
48
58
|
end
|
49
59
|
|
60
|
+
# the standard active scaffold options used for date, datetime and time inputs
|
61
|
+
def active_scaffold_input_date_options(column, options = {})
|
62
|
+
options[:include_blank] = true if column.column.null
|
63
|
+
options[:prefix] = options[:name].gsub("[#{column.name}]", '')
|
64
|
+
options
|
65
|
+
end
|
66
|
+
|
50
67
|
# the standard active scaffold options used for class, name and scope
|
51
|
-
def active_scaffold_input_options(column, scope = nil)
|
68
|
+
def active_scaffold_input_options(column, scope = nil, options = {})
|
52
69
|
name = scope ? "record#{scope}[#{column.name}]" : "record[#{column.name}]"
|
53
70
|
|
54
71
|
# Fix for keeping unique IDs in subform
|
55
72
|
id_control = "record_#{column.name}_#{[params[:eid], params[:id]].compact.join '_'}"
|
56
73
|
id_control += scope.gsub(/(\[|\])/, '_').gsub('__', '_').gsub(/_$/, '') if scope
|
57
74
|
|
58
|
-
{ :name => name, :class => "#{column.name}-input", :id => id_control}
|
75
|
+
{ :name => name, :class => "#{column.name}-input", :id => id_control}.merge(options)
|
59
76
|
end
|
60
|
-
|
77
|
+
|
78
|
+
def javascript_for_update_column(column, scope, options)
|
79
|
+
if column.update_column
|
80
|
+
form_action = :create
|
81
|
+
form_action = :update if params[:action] == 'edit'
|
82
|
+
url_params = {
|
83
|
+
:action => 'render_field',
|
84
|
+
:id => params[:id],
|
85
|
+
:column => column.name,
|
86
|
+
:update_column => column.update_column,
|
87
|
+
:eid => params[:eid],
|
88
|
+
:scope => scope
|
89
|
+
}
|
90
|
+
url_params[:controller] = controller.class.active_scaffold_controller_for(@record.class).controller_path if scope
|
91
|
+
ajax_options = {:method => :get,
|
92
|
+
:url => url_for(url_params), :with => column.send_form_on_update_column ? "Form.serialize('#{element_form_id(:action => form_action)}')" : "'value=' + this.value",
|
93
|
+
:after => "$('#{loading_indicator_id(:action => form_action, :id => params[:id])}').style.visibility = 'visible'; Form.disable('#{element_form_id(:action => form_action)}');",
|
94
|
+
:complete => "$('#{loading_indicator_id(:action => form_action, :id => params[:id])}').style.visibility = 'hidden'; Form.enable('#{element_form_id(:action => form_action)}');"}
|
95
|
+
options[:onchange] = "#{remote_function(ajax_options)};#{options[:onchange]}"
|
96
|
+
end
|
97
|
+
options
|
98
|
+
end
|
99
|
+
|
61
100
|
##
|
62
101
|
## Form input methods
|
63
102
|
##
|
64
103
|
|
65
|
-
def active_scaffold_input_singular_association(column,
|
104
|
+
def active_scaffold_input_singular_association(column, html_options)
|
66
105
|
associated = @record.send(column.association.name)
|
67
106
|
|
68
107
|
select_options = options_for_association(column.association)
|
69
108
|
select_options.unshift([ associated.to_label, associated.id ]) unless associated.nil? or select_options.find {|label, id| id == associated.id}
|
70
109
|
|
71
|
-
|
72
|
-
|
73
|
-
options
|
74
|
-
|
110
|
+
method = column.name
|
111
|
+
#html_options[:name] += '[id]'
|
112
|
+
options = {:include_blank => as_(:_select_)}
|
113
|
+
|
114
|
+
html_options.update(column.options[:html_options] || {})
|
115
|
+
options.update(column.options)
|
116
|
+
options[:selected] = associated.id unless associated.nil?
|
117
|
+
select(:record, method, select_options.uniq, options, html_options)
|
75
118
|
end
|
76
119
|
|
77
120
|
def active_scaffold_input_plural_association(column, options)
|
78
121
|
associated_options = @record.send(column.association.name).collect {|r| [r.to_label, r.id]}
|
79
122
|
select_options = associated_options | options_for_association(column.association)
|
80
|
-
return as_(:no_options) if select_options.empty?
|
123
|
+
return content_tag(:span, as_(:no_options), :id => options[:id]) if select_options.empty?
|
81
124
|
|
82
125
|
html = "<ul class=\"checkbox-list\" id=\"#{options[:id]}\">"
|
83
126
|
|
84
127
|
associated_ids = associated_options.collect {|a| a[1]}
|
85
128
|
select_options.each_with_index do |option, i|
|
86
129
|
label, id = option
|
87
|
-
this_name = "#{options[:name]}[
|
130
|
+
this_name = "#{options[:name]}[]"
|
88
131
|
this_id = "#{options[:id]}_#{i}_id"
|
89
132
|
html << "<li>"
|
90
133
|
html << check_box_tag(this_name, id, associated_ids.include?(id), :id => this_id)
|
@@ -96,47 +139,44 @@ module ActiveScaffold
|
|
96
139
|
|
97
140
|
html << '</ul>'
|
98
141
|
html << javascript_tag("new DraggableLists('#{options[:id]}')") if column.options[:draggable_lists]
|
99
|
-
html
|
142
|
+
html.html_safe
|
143
|
+
end
|
144
|
+
|
145
|
+
def active_scaffold_translated_option(column, text, value = nil)
|
146
|
+
value = text if value.nil?
|
147
|
+
[(text.is_a?(Symbol) ? column.active_record_class.human_attribute_name(text) : text), value.to_s]
|
100
148
|
end
|
101
149
|
|
102
|
-
def
|
150
|
+
def active_scaffold_translated_options(column)
|
151
|
+
column.options[:options].collect do |text, value|
|
152
|
+
active_scaffold_translated_option(column, text, value)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def active_scaffold_input_select(column, html_options)
|
103
157
|
if column.singular_association?
|
104
|
-
active_scaffold_input_singular_association(column,
|
158
|
+
active_scaffold_input_singular_association(column, html_options)
|
105
159
|
elsif column.plural_association?
|
106
|
-
active_scaffold_input_plural_association(column,
|
160
|
+
active_scaffold_input_plural_association(column, html_options)
|
107
161
|
else
|
108
|
-
|
162
|
+
options = { :selected => @record.send(column.name).to_s }
|
163
|
+
options_for_select = active_scaffold_translated_options(column)
|
164
|
+
html_options.update(column.options[:html_options] || {})
|
165
|
+
options.update(column.options)
|
166
|
+
select(:record, column.name, options_for_select, options, html_options)
|
109
167
|
end
|
110
168
|
end
|
111
169
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
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)."
|
170
|
+
def active_scaffold_input_radio(column, html_options)
|
171
|
+
html_options.update(column.options[:html_options] || {})
|
172
|
+
column.options[:options].inject('') do |html, (text, value)|
|
173
|
+
text, value = active_scaffold_translated_option(column, text, value)
|
174
|
+
html << content_tag(:label, radio_button(:record, column.name, value, html_options.merge(:id => html_options[:id] + '-' + value.to_s)) + text)
|
118
175
|
end
|
119
|
-
remote_controller = active_scaffold_controller_for(column.association.klass).controller_path
|
120
|
-
|
121
|
-
# if the opposite association is a :belongs_to (in that case association in this class must be has_one or has_many)
|
122
|
-
# then only show records that have not been associated yet
|
123
|
-
if [:has_one, :has_many].include?(column.association.macro)
|
124
|
-
params.merge!({column.association.primary_key_name => ''})
|
125
|
-
end
|
126
|
-
|
127
|
-
record_select_options = {:controller => remote_controller, :id => options[:id]}
|
128
|
-
record_select_options.merge!(active_scaffold_input_text_options)
|
129
|
-
record_select_options.merge!(column.options)
|
130
|
-
|
131
|
-
if column.singular_association?
|
132
|
-
record_select_field(options[:name], (@record.send(column.name) || column.association.klass.new), record_select_options)
|
133
|
-
elsif column.plural_association?
|
134
|
-
record_multi_select_field(options[:name], @record.send(column.name), record_select_options)
|
135
|
-
end
|
136
176
|
end
|
137
177
|
|
138
178
|
def active_scaffold_input_checkbox(column, options)
|
139
|
-
check_box(:record, column.name, options)
|
179
|
+
check_box(:record, column.name, options.merge(column.options))
|
140
180
|
end
|
141
181
|
|
142
182
|
def active_scaffold_input_password(column, options)
|
@@ -145,9 +185,9 @@ module ActiveScaffold
|
|
145
185
|
end
|
146
186
|
|
147
187
|
def active_scaffold_input_textarea(column, options)
|
148
|
-
text_area(:record, column.name, options.merge(:cols => column.options[:cols], :rows => column.options[:rows]))
|
188
|
+
text_area(:record, column.name, options.merge(:cols => column.options[:cols], :rows => column.options[:rows], :size => column.options[:size]))
|
149
189
|
end
|
150
|
-
|
190
|
+
|
151
191
|
def active_scaffold_input_virtual(column, options)
|
152
192
|
options = active_scaffold_input_text_options(options)
|
153
193
|
text_field :record, column.name, options.merge(column.options)
|
@@ -163,7 +203,7 @@ module ActiveScaffold
|
|
163
203
|
select_options << [as_(:true), true]
|
164
204
|
select_options << [as_(:false), false]
|
165
205
|
|
166
|
-
select_tag(options[:name], options_for_select(select_options, @record.send(column.name)))
|
206
|
+
select_tag(options[:name], options_for_select(select_options, @record.send(column.name)), options)
|
167
207
|
end
|
168
208
|
|
169
209
|
def onsubmit
|
@@ -174,32 +214,40 @@ module ActiveScaffold
|
|
174
214
|
##
|
175
215
|
|
176
216
|
# add functionality for overriding subform partials from association class path
|
177
|
-
def override_subform_partial?(column)
|
178
|
-
path, partial_name = partial_pieces(override_subform_partial(column))
|
217
|
+
def override_subform_partial?(column, subform_partial)
|
218
|
+
path, partial_name = partial_pieces(override_subform_partial(column, subform_partial))
|
179
219
|
template_exists?(File.join(path, "_#{partial_name}"))
|
180
220
|
end
|
181
221
|
|
182
|
-
def override_subform_partial(column)
|
183
|
-
File.join(active_scaffold_controller_for(column.association.klass).controller_path,
|
222
|
+
def override_subform_partial(column, subform_partial)
|
223
|
+
File.join(active_scaffold_controller_for(column.association.klass).controller_path, subform_partial) if column_renders_as(column) == :subform
|
184
224
|
end
|
185
225
|
|
186
226
|
def override_form_field_partial?(column)
|
187
227
|
path, partial_name = partial_pieces(override_form_field_partial(column))
|
188
|
-
template_exists?(File.join(path, "_#{partial_name}"))
|
228
|
+
template_exists?(File.join(path, "_#{partial_name}"), true)
|
189
229
|
end
|
190
230
|
|
191
|
-
# the naming convention for overriding form fields with
|
231
|
+
# the naming convention for overriding form fields with helpers
|
192
232
|
def override_form_field_partial(column)
|
193
|
-
|
233
|
+
path = active_scaffold_controller_for(column.active_record_class).controller_path
|
234
|
+
File.join(path, "#{clean_column_name(column.name)}_form_column")
|
194
235
|
end
|
195
236
|
|
196
|
-
def override_form_field
|
197
|
-
|
237
|
+
def override_form_field(column)
|
238
|
+
method = override_form_field_name(column)
|
239
|
+
return method if respond_to?(method)
|
240
|
+
old_method = override_form_field_name(column, true)
|
241
|
+
if respond_to?(old_method)
|
242
|
+
ActiveSupport::Deprecation.warn("You are using an old naming schema for overrides, you should name the helper #{method} instead of #{old_method}")
|
243
|
+
old_method
|
244
|
+
end
|
198
245
|
end
|
246
|
+
alias_method :override_form_field?, :override_form_field
|
199
247
|
|
200
248
|
# the naming convention for overriding form fields with helpers
|
201
|
-
def
|
202
|
-
"#{column.name}_form_column"
|
249
|
+
def override_form_field_name(column, old = false)
|
250
|
+
"#{clean_class_name(column.active_record_class.name) + '_' unless old}#{clean_column_name(column.name)}_form_column"
|
203
251
|
end
|
204
252
|
|
205
253
|
def override_input?(form_ui)
|
@@ -224,10 +272,11 @@ module ActiveScaffold
|
|
224
272
|
end
|
225
273
|
|
226
274
|
def subform_partial_for_column(column)
|
227
|
-
|
228
|
-
|
275
|
+
subform_partial = "#{active_scaffold_config_for(column.association.klass).subform.layout}_subform"
|
276
|
+
if override_subform_partial?(column, subform_partial)
|
277
|
+
override_subform_partial(column, subform_partial)
|
229
278
|
else
|
230
|
-
|
279
|
+
subform_partial
|
231
280
|
end
|
232
281
|
end
|
233
282
|
|
@@ -238,7 +287,7 @@ module ActiveScaffold
|
|
238
287
|
def column_renders_as(column)
|
239
288
|
if column.is_a? ActiveScaffold::DataStructures::ActionColumns
|
240
289
|
return :subsection
|
241
|
-
elsif column.active_record_class.locking_column.to_s == column.name.to_s
|
290
|
+
elsif column.active_record_class.locking_column.to_s == column.name.to_s or column.form_ui == :hidden
|
242
291
|
return :hidden
|
243
292
|
elsif column.association.nil? or column.form_ui or !active_scaffold_config_for(column.association.klass).actions.include?(:subform)
|
244
293
|
return :field
|
@@ -262,6 +311,28 @@ module ActiveScaffold
|
|
262
311
|
"[#{column.name}]"
|
263
312
|
end
|
264
313
|
end
|
314
|
+
|
315
|
+
def active_scaffold_add_existing_input(options)
|
316
|
+
if controller.respond_to?(:record_select_config)
|
317
|
+
remote_controller = active_scaffold_controller_for(record_select_config.model).controller_path
|
318
|
+
options.merge!(:controller => remote_controller)
|
319
|
+
options.merge!(active_scaffold_input_text_options)
|
320
|
+
record_select_field(options[:name], @record, options)
|
321
|
+
else
|
322
|
+
column = active_scaffold_config_for(params[:parent_model]).columns[params[:parent_column]]
|
323
|
+
select_options = options_for_select(options_for_association(column.association)) unless column.through_association?
|
324
|
+
select_options ||= options_for_select(active_scaffold_config.model.find(:all).collect {|c| [h(c.to_label), c.id]})
|
325
|
+
select_tag 'associated_id', '<option value="">' + as_(:_select_) + '</option>' + select_options unless select_options.empty?
|
326
|
+
end
|
327
|
+
end
|
328
|
+
|
329
|
+
def active_scaffold_add_existing_label
|
330
|
+
if controller.respond_to?(:record_select_config)
|
331
|
+
record_select_config.model.human_name
|
332
|
+
else
|
333
|
+
active_scaffold_config.model.human_name
|
334
|
+
end
|
335
|
+
end
|
265
336
|
end
|
266
337
|
end
|
267
338
|
end
|