brisk-bills 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +8 -0
- data/COPYING +674 -0
- data/COPYING.LESSER +165 -0
- data/INSTALL +5 -0
- data/README +22 -0
- data/Rakefile +11 -0
- data/TODO.txt +112 -0
- data/app/controllers/admin/activities_controller.rb +151 -0
- data/app/controllers/admin/activities_controller/adjustment.rb +16 -0
- data/app/controllers/admin/activities_controller/labor.rb +119 -0
- data/app/controllers/admin/activities_controller/labor/slimtimer.rb +28 -0
- data/app/controllers/admin/activities_controller/material.rb +20 -0
- data/app/controllers/admin/activities_controller/proposal.rb +15 -0
- data/app/controllers/admin/activities_with_prices_controller.rb +68 -0
- data/app/controllers/admin/adjustments_controller.rb +22 -0
- data/app/controllers/admin/client_accounting_controller.rb +49 -0
- data/app/controllers/admin/client_financial_transactions_controller.rb +24 -0
- data/app/controllers/admin/client_representatives_controller.rb +31 -0
- data/app/controllers/admin/clients_controller.rb +31 -0
- data/app/controllers/admin/employee_client_labor_rate_controller.rb +30 -0
- data/app/controllers/admin/employees_controller.rb +32 -0
- data/app/controllers/admin/employees_controller/slimtimer.rb +29 -0
- data/app/controllers/admin/invoices_controller.rb +165 -0
- data/app/controllers/admin/labors_controller.rb +103 -0
- data/app/controllers/admin/labors_controller/slimtimer.rb +31 -0
- data/app/controllers/admin/materials_controller.rb +24 -0
- data/app/controllers/admin/payments_controller.rb +75 -0
- data/app/controllers/admin/proposals_controller.rb +22 -0
- data/app/controllers/admin/settings_controller.rb +23 -0
- data/app/controllers/application_controller.rb +22 -0
- data/app/controllers/authentication_controller.rb +131 -0
- data/app/helpers/activity_type_model_helper.rb +194 -0
- data/app/helpers/admin/activities_helper.rb +110 -0
- data/app/helpers/admin/activities_helper/labor_helper.rb +28 -0
- data/app/helpers/admin/activities_helper/proposal_helper.rb +11 -0
- data/app/helpers/admin/activities_helper/slimtimer_helper.rb +13 -0
- data/app/helpers/admin/activities_with_prices_helper.rb +17 -0
- data/app/helpers/admin/activity_tax_controller_helper.rb +48 -0
- data/app/helpers/admin/activity_tax_field_helper.rb +33 -0
- data/app/helpers/admin/activity_type_controller_helper.rb +83 -0
- data/app/helpers/admin/activity_type_field_helper.rb +45 -0
- data/app/helpers/admin/adjustments_helper.rb +5 -0
- data/app/helpers/admin/client_accounting_helper.rb +13 -0
- data/app/helpers/admin/client_financial_transactions_helper.rb +9 -0
- data/app/helpers/admin/client_representatives_helper.rb +26 -0
- data/app/helpers/admin/clients_helper.rb +6 -0
- data/app/helpers/admin/employee_client_labor_rate_helper.rb +77 -0
- data/app/helpers/admin/employees_helper.rb +9 -0
- data/app/helpers/admin/employees_helper/slimtimer_helper.rb +2 -0
- data/app/helpers/admin/has_credential_column_helper.rb +60 -0
- data/app/helpers/admin/invoices_helper.rb +59 -0
- data/app/helpers/admin/is_active_column_helper.rb +46 -0
- data/app/helpers/admin/labors_helper.rb +20 -0
- data/app/helpers/admin/labors_helper/slimtimer_helper.rb +13 -0
- data/app/helpers/admin/materials_helper.rb +5 -0
- data/app/helpers/admin/payments_helper.rb +41 -0
- data/app/helpers/admin/proposals_helper.rb +3 -0
- data/app/helpers/admin/settings_helper.rb +8 -0
- data/app/helpers/admin_layout_helper.rb +91 -0
- data/app/helpers/application_helper.rb +27 -0
- data/app/helpers/authentication_helper.rb +61 -0
- data/app/helpers/extensible_object_helper.rb +28 -0
- data/app/helpers/has_credential_model_helper.rb +39 -0
- data/app/helpers/invoice_pdf_helper.rb +71 -0
- data/app/helpers/is_active_model_helper.rb +40 -0
- data/app/helpers/money_model_helper.rb +21 -0
- data/app/model_views/client_accounting.rb +5 -0
- data/app/model_views/client_financial_transaction.rb +15 -0
- data/app/model_views/invoices_with_total.rb +36 -0
- data/app/models/activity.rb +104 -0
- data/app/models/activity/adjustment.rb +34 -0
- data/app/models/activity/labor.rb +91 -0
- data/app/models/activity/labor/slimtimer.rb +28 -0
- data/app/models/activity/material.rb +16 -0
- data/app/models/activity/proposal.rb +17 -0
- data/app/models/activity_type.rb +2 -0
- data/app/models/client.rb +93 -0
- data/app/models/client_eventlog.rb +5 -0
- data/app/models/client_representative.rb +22 -0
- data/app/models/credential.rb +195 -0
- data/app/models/employee.rb +49 -0
- data/app/models/employee/labor.rb +13 -0
- data/app/models/employee/slimtimer.rb +43 -0
- data/app/models/employee_client_labor_rate.rb +20 -0
- data/app/models/invoice.rb +280 -0
- data/app/models/invoice_payment.rb +8 -0
- data/app/models/notifier.rb +85 -0
- data/app/models/payment.rb +108 -0
- data/app/models/payment_method.rb +7 -0
- data/app/models/setting.rb +39 -0
- data/app/models/slimtimer_task.rb +6 -0
- data/app/models/slimtimer_time_entry.rb +69 -0
- data/app/views/admin/activities/_adjustment_column.rhtml +23 -0
- data/app/views/admin/activities/_form.rhtml +20 -0
- data/app/views/admin/activities/_form_attribute.rhtml +12 -0
- data/app/views/admin/activities/_labor_column.rhtml +17 -0
- data/app/views/admin/activities/_material_column.rhtml +10 -0
- data/app/views/admin/activities/_proposal_column.rhtml +11 -0
- data/app/views/admin/activities_with_prices/move_to_invoice.rhtml +44 -0
- data/app/views/admin/activities_with_prices/move_to_invoice.rjs +9 -0
- data/app/views/admin/invoices/download.rpdf +224 -0
- data/app/views/authentication/email.rjs +9 -0
- data/app/views/authentication/login.rhtml +75 -0
- data/app/views/authentication/login.rjs +14 -0
- data/app/views/authentication/reset_password_via_token.rhtml +16 -0
- data/app/views/authentication/reset_password_via_token.rjs +6 -0
- data/app/views/authentication/sign_in_error.rjs +2 -0
- data/app/views/layouts/_navigation_tree.rhtml +15 -0
- data/app/views/layouts/admin.rhtml +26 -0
- data/app/views/layouts/public.rhtml +18 -0
- data/app/views/notifier/_email_footer.html.rhtml +12 -0
- data/app/views/notifier/_email_footer.plain.rhtml +3 -0
- data/app/views/notifier/_email_header.html.rhtml +53 -0
- data/app/views/notifier/invoice_available.html.rhtml +5 -0
- data/app/views/notifier/invoice_available.plain.rhtml +4 -0
- data/app/views/notifier/reset_password_requested.html.rhtml +15 -0
- data/app/views/notifier/reset_password_requested.plain.rhtml +9 -0
- data/bin/brisk-bills +51 -0
- data/config/boot.rb +164 -0
- data/config/environment.rb +39 -0
- data/config/environments/development.rb +17 -0
- data/config/environments/production.rb +18 -0
- data/config/environments/test.rb +19 -0
- data/config/locale/en.rb +26 -0
- data/config/routes.rb +20 -0
- data/config/secrets.yml +2 -0
- data/db/migrate/001_create_employees.rb +14 -0
- data/db/migrate/002_create_employee_slimtimers.rb +14 -0
- data/db/migrate/003_create_slimtimer_tasks.rb +21 -0
- data/db/migrate/004_create_slimtimer_time_entries.rb +25 -0
- data/db/migrate/005_create_clients.rb +12 -0
- data/db/migrate/006_create_client_representatives.rb +16 -0
- data/db/migrate/007_create_client_eventlogs.rb +13 -0
- data/db/migrate/008_create_activities.rb +17 -0
- data/db/migrate/009_create_activity_labors.rb +16 -0
- data/db/migrate/010_create_employee_client_labor_rates.rb +19 -0
- data/db/migrate/011_create_activity_adjustments.rb +16 -0
- data/db/migrate/012_create_activity_materials.rb +16 -0
- data/db/migrate/013_create_activity_proposals.rb +18 -0
- data/db/migrate/014_create_invoices.rb +16 -0
- data/db/migrate/015_create_payments.rb +18 -0
- data/db/migrate/016_create_payment_methods.rb +18 -0
- data/db/migrate/017_create_invoice_payments.rb +14 -0
- data/db/migrate/018_create_activity_types.rb +37 -0
- data/db/migrate/019_create_settings.rb +45 -0
- data/db/migrate/020_is_active_employees_clients.rb +11 -0
- data/db/migrate/021_create_views_and_indexes.rb +78 -0
- data/db/migrate/022_create_client_financial_transactions.rb +32 -0
- data/db/migrate/023_create_credentials_migrate_representatives.rb +133 -0
- data/db/migrate/024_updates_for_sales_tax.rb +91 -0
- data/db/migrate/025_alter_credentials_for_reset.rb +11 -0
- data/db/migrate/026_create_st_settings.rb +17 -0
- data/db/migrate/027_create_sessions.rb +16 -0
- data/db/migrate/028_money_to_cents.rb +136 -0
- data/db/schema.rb +301 -0
- data/lib/brisk-bills.rb +17 -0
- data/lib/brisk-bills/initializer.rb +100 -0
- data/lib/dti-navigation-menu/lib/dti-navigation-menu.rb +27 -0
- data/lib/generators/generator_base_extension.rb +16 -0
- data/lib/generators/instance/instance_generator.rb +117 -0
- data/lib/generators/instance/templates/databases/mysql.yml +47 -0
- data/lib/generators/instance/templates/instance_boot.rb +166 -0
- data/lib/generators/instance/templates/instance_environment.rb +65 -0
- data/lib/generators/instance/templates/instance_generate +18 -0
- data/lib/generators/instance/templates/instance_rakefile +3 -0
- data/lib/generators/instance/templates/instance_routes.rb +1 -0
- data/lib/tasks/create_last_months_invoices.rake +37 -0
- data/lib/tasks/credential_tasks.rake +47 -0
- data/lib/tasks/first_time_setup.rake +96 -0
- data/lib/tasks/instance.rake +27 -0
- data/lib/tasks/invoice_as_csv.rake +32 -0
- data/lib/tasks/package.rake +120 -0
- data/lib/tasks/slimtimer_import.rake +198 -0
- data/lib/utilities.rb +18 -0
- data/log/.keep +0 -0
- data/public/.htaccess +40 -0
- data/public/404.html +30 -0
- data/public/500.html +30 -0
- data/public/blank.html +33 -0
- data/public/blank_iframe.html +2 -0
- data/public/dispatch.cgi +10 -0
- data/public/dispatch.fcgi +24 -0
- data/public/dispatch.rb +10 -0
- data/public/favicon.ico +0 -0
- data/public/images/active_scaffold/DO_NOT_EDIT +2 -0
- data/public/images/active_scaffold/default/add.gif +0 -0
- data/public/images/active_scaffold/default/arrow_down.gif +0 -0
- data/public/images/active_scaffold/default/arrow_up.gif +0 -0
- data/public/images/active_scaffold/default/close.gif +0 -0
- data/public/images/active_scaffold/default/cross.png +0 -0
- data/public/images/active_scaffold/default/indicator-small.gif +0 -0
- data/public/images/active_scaffold/default/indicator.gif +0 -0
- data/public/images/active_scaffold/default/magnifier.png +0 -0
- data/public/images/background.gif +0 -0
- data/public/images/brisk-bills-logo.gif +0 -0
- data/public/images/calendar_date_select/calendar.gif +0 -0
- data/public/images/dti-logo.gif +0 -0
- data/public/images/dti-logo.jpg +0 -0
- data/public/images/favicon.ico +0 -0
- data/public/images/invoice-background.jpg +0 -0
- data/public/images/login-form-spinner.gif +0 -0
- data/public/images/nav-arrow.gif +0 -0
- data/public/images/notice-error.gif +0 -0
- data/public/images/notice-info.gif +0 -0
- data/public/images/rails.png +0 -0
- data/public/javascripts/active_scaffold/DO_NOT_EDIT +2 -0
- data/public/javascripts/active_scaffold/default/active_scaffold.js +430 -0
- data/public/javascripts/active_scaffold/default/dhtml_history.js +867 -0
- data/public/javascripts/active_scaffold/default/form_enhancements.js +114 -0
- data/public/javascripts/active_scaffold/default/rico_corner.js +370 -0
- data/public/javascripts/application.js +2 -0
- data/public/javascripts/briskbills-quick-helpers.js +9 -0
- data/public/javascripts/builder.js +136 -0
- data/public/javascripts/controls.js +963 -0
- data/public/javascripts/dragdrop.js +973 -0
- data/public/javascripts/effects.js +1128 -0
- data/public/javascripts/modalbox.js +573 -0
- data/public/javascripts/prototype.js +4320 -0
- data/public/javascripts/scriptaculous.js +58 -0
- data/public/javascripts/shadedborder.js +249 -0
- data/public/javascripts/slider.js +275 -0
- data/public/javascripts/sound.js +55 -0
- data/public/javascripts/unittest.js +568 -0
- data/public/robots.txt +1 -0
- data/public/stylesheets/active_scaffold/DO_NOT_EDIT +2 -0
- data/public/stylesheets/active_scaffold/default/stylesheet-ie.css +35 -0
- data/public/stylesheets/active_scaffold/default/stylesheet.css +809 -0
- data/public/stylesheets/admin/global.css +152 -0
- data/public/stylesheets/admin/pages.css +137 -0
- data/public/stylesheets/admin/screen.css +3 -0
- data/public/stylesheets/admin/structure.css +88 -0
- data/public/stylesheets/modalbox.css +95 -0
- data/public/stylesheets/public/global.css +36 -0
- data/public/stylesheets/public/pages.css +105 -0
- data/public/stylesheets/public/screen.css +3 -0
- data/public/stylesheets/public/structure.css +0 -0
- data/public/stylesheets/spinner.gif +0 -0
- data/script/about +3 -0
- data/script/breakpointer +3 -0
- data/script/console +3 -0
- data/script/dbconsole +3 -0
- data/script/destroy +3 -0
- data/script/generate +3 -0
- data/script/performance/benchmarker +3 -0
- data/script/performance/profiler +3 -0
- data/script/performance/request +3 -0
- data/script/plugin +3 -0
- data/script/process/inspector +3 -0
- data/script/process/reaper +3 -0
- data/script/process/spawner +3 -0
- data/script/runner +3 -0
- data/script/server +3 -0
- data/test/fixtures/activities.yml +28 -0
- data/test/fixtures/activity_adjustments.yml +7 -0
- data/test/fixtures/activity_labors.yml +25 -0
- data/test/fixtures/activity_materials.yml +7 -0
- data/test/fixtures/activity_proposals.yml +7 -0
- data/test/fixtures/activity_types.yml +23 -0
- data/test/fixtures/client_eventlogs.yml +5 -0
- data/test/fixtures/client_financial_transactions.yml +7 -0
- data/test/fixtures/client_representatives.yml +56 -0
- data/test/fixtures/clients.yml +172 -0
- data/test/fixtures/credentials.yml +34 -0
- data/test/fixtures/employee_client_labor_rates.yml +365 -0
- data/test/fixtures/employee_slimtimers.yml +19 -0
- data/test/fixtures/employees.yml +22 -0
- data/test/fixtures/invoice_payments.yml +7 -0
- data/test/fixtures/invoices.yml +7 -0
- data/test/fixtures/payment_methods.yml +7 -0
- data/test/fixtures/payments.yml +7 -0
- data/test/fixtures/settings.yml +7 -0
- data/test/fixtures/slimtimer_tasks.yml +5 -0
- data/test/fixtures/slimtimer_time_entries.yml +5 -0
- data/test/functional/admin/activities_controller_test.rb +8 -0
- data/test/functional/admin/adjustments_controller_test.rb +8 -0
- data/test/functional/admin/client_accounting_controller_test.rb +8 -0
- data/test/functional/admin/client_financial_transactions_controller_test.rb +8 -0
- data/test/functional/admin/client_representatives_controller_test.rb +8 -0
- data/test/functional/admin/clients_controller_test.rb +8 -0
- data/test/functional/admin/employee_client_labor_rate_controller_test.rb +8 -0
- data/test/functional/admin/employees/slimtimer_controller_test.rb +8 -0
- data/test/functional/admin/employees_controller_test.rb +8 -0
- data/test/functional/admin/invoices_controller_test.rb +8 -0
- data/test/functional/admin/labors_controller_test.rb +8 -0
- data/test/functional/admin/materials_controller_test.rb +8 -0
- data/test/functional/admin/payments_controller_test.rb +8 -0
- data/test/functional/admin/proposals_controller_test.rb +8 -0
- data/test/functional/admin/settings_controller_test.rb +8 -0
- data/test/functional/authentication_controller_test.rb +8 -0
- data/test/test_helper.rb +30 -0
- data/test/test_unit_factory_helper.rb +154 -0
- data/test/unit/activity/adjustment_test.rb +8 -0
- data/test/unit/activity/labor_test.rb +279 -0
- data/test/unit/activity/material_test.rb +8 -0
- data/test/unit/activity/proposal_test.rb +8 -0
- data/test/unit/activity_test.rb +83 -0
- data/test/unit/activity_type_test.rb +8 -0
- data/test/unit/client_eventlog_test.rb +10 -0
- data/test/unit/client_financial_transaction_test.rb +8 -0
- data/test/unit/client_representative_test.rb +10 -0
- data/test/unit/client_test.rb +24 -0
- data/test/unit/credential_test.rb +217 -0
- data/test/unit/employee/slimtimer_test.rb +10 -0
- data/test/unit/employee_client_labor_rate_test.rb +8 -0
- data/test/unit/employee_test.rb +25 -0
- data/test/unit/invoice_payment_test.rb +8 -0
- data/test/unit/invoice_test.rb +459 -0
- data/test/unit/notifier_test.rb +9 -0
- data/test/unit/payment_method_test.rb +8 -0
- data/test/unit/payment_test.rb +155 -0
- data/test/unit/setting_test.rb +8 -0
- data/test/unit/slimtimer_task_test.rb +10 -0
- data/test/unit/slimtimer_time_entry_test.rb +132 -0
- data/vendor/plugins/InlineAttachment-0.3.0-modified/README +79 -0
- data/vendor/plugins/InlineAttachment-0.3.0-modified/init.rb +2 -0
- data/vendor/plugins/InlineAttachment-0.3.0-modified/lib/inline_attachment.rb +136 -0
- data/vendor/plugins/InlineAttachment-0.3.0-modified/lib/tmail_content_id.rb +40 -0
- data/vendor/plugins/active_scaffold/CHANGELOG +152 -0
- data/vendor/plugins/active_scaffold/MIT-LICENSE +20 -0
- data/vendor/plugins/active_scaffold/README +28 -0
- data/vendor/plugins/active_scaffold/Rakefile +24 -0
- data/vendor/plugins/active_scaffold/environment.rb +17 -0
- data/vendor/plugins/active_scaffold/frontends/default/images/add.gif +0 -0
- data/vendor/plugins/active_scaffold/frontends/default/images/arrow_down.gif +0 -0
- data/vendor/plugins/active_scaffold/frontends/default/images/arrow_up.gif +0 -0
- data/vendor/plugins/active_scaffold/frontends/default/images/close.gif +0 -0
- data/vendor/plugins/active_scaffold/frontends/default/images/cross.png +0 -0
- data/vendor/plugins/active_scaffold/frontends/default/images/indicator-small.gif +0 -0
- data/vendor/plugins/active_scaffold/frontends/default/images/indicator.gif +0 -0
- data/vendor/plugins/active_scaffold/frontends/default/images/magnifier.png +0 -0
- data/vendor/plugins/active_scaffold/frontends/default/javascripts/active_scaffold.js +430 -0
- data/vendor/plugins/active_scaffold/frontends/default/javascripts/dhtml_history.js +867 -0
- data/vendor/plugins/active_scaffold/frontends/default/javascripts/form_enhancements.js +114 -0
- data/vendor/plugins/active_scaffold/frontends/default/javascripts/rico_corner.js +370 -0
- data/vendor/plugins/active_scaffold/frontends/default/stylesheets/stylesheet-ie.css +35 -0
- data/vendor/plugins/active_scaffold/frontends/default/stylesheets/stylesheet.css +809 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_add_existing_form.html.erb +40 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_create_form.html.erb +49 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_create_form_on_list.html.erb +38 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_field_search.html.erb +45 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_form.html.erb +18 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_form_association.html.erb +20 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_form_association_footer.html.erb +42 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_form_association_header.html.erb +10 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_form_association_record.html.erb +27 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_form_attribute.html.erb +12 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_form_hidden_attribute.html.erb +1 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_form_messages.html.erb +5 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_horizontal_subform.html.erb +21 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_list.html.erb +37 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_actions.html.erb +13 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_calculations.html.erb +22 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_column_headings.html.erb +32 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_header.html.erb +14 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_inline_adapter.html.erb +9 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_pagination_links.html.erb +30 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_record.html.erb +35 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_live_search.html.erb +25 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_messages.html.erb +10 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_nested.html.erb +44 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_search.html.erb +21 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_show.html.erb +8 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_show_columns.html.erb +11 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_update_actions.html.erb +9 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_update_form.html.erb +53 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/add_existing.js.rjs +16 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/add_existing_form.html.erb +5 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/create.html.erb +5 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/delete.html.erb +13 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/destroy.js.rjs +10 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/edit_associated.js.rjs +15 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/field_search.html.erb +5 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/form_messages.js.rjs +1 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/form_messages_on_create.js.rjs +2 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/form_messages_on_update.js.rjs +2 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/list.html.erb +44 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/on_create.js.rjs +25 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/on_update.js.rjs +11 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/search.html.erb +5 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/show.html.erb +5 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/update.html.erb +8 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/update_column.js.rjs +12 -0
- data/vendor/plugins/active_scaffold/init.rb +18 -0
- data/vendor/plugins/active_scaffold/install.rb +40 -0
- data/vendor/plugins/active_scaffold/install_assets.rb +36 -0
- data/vendor/plugins/active_scaffold/lib/active_record_permissions.rb +123 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold.rb +144 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/core.rb +102 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/create.rb +120 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/delete.rb +46 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/field_search.rb +46 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/list.rb +77 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/live_search.rb +46 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/nested.rb +215 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/search.rb +40 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/show.rb +34 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/subform.rb +17 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/update.rb +114 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/attribute_params.rb +185 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/base.rb +37 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/core.rb +189 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/create.rb +43 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/delete.rb +25 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/field_search.rb +53 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/form.rb +49 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/list.rb +134 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/live_search.rb +52 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/nested.rb +31 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/search.rb +52 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/show.rb +39 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/subform.rb +33 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/update.rb +32 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/configurable.rb +29 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/constraints.rb +178 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_columns.rb +97 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_link.rb +136 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_links.rb +47 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/actions.rb +45 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/column.rb +297 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/columns.rb +75 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/error_message.rb +24 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/set.rb +62 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/sorting.rb +89 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/finder.rb +234 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/association_helpers.rb +40 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/controller_helpers.rb +25 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/country_helpers.rb +348 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb +267 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/id_helpers.rb +125 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb +178 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/pagination_helpers.rb +37 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/search_column_helpers.rb +172 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/show_column_helpers.rb +46 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/view_helpers.rb +196 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/en.rb +66 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/es.yml +64 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/hu.yml +62 -0
- data/vendor/plugins/active_scaffold/lib/bridges/bridge.rb +52 -0
- data/vendor/plugins/active_scaffold/lib/bridges/calendar_date_select/bridge.rb +11 -0
- data/vendor/plugins/active_scaffold/lib/bridges/calendar_date_select/lib/as_cds_bridge.rb +53 -0
- data/vendor/plugins/active_scaffold/lib/bridges/file_column/bridge.rb +12 -0
- data/vendor/plugins/active_scaffold/lib/bridges/file_column/lib/as_file_column_bridge.rb +49 -0
- data/vendor/plugins/active_scaffold/lib/bridges/file_column/lib/file_column_helpers.rb +51 -0
- data/vendor/plugins/active_scaffold/lib/bridges/file_column/lib/form_ui.rb +32 -0
- data/vendor/plugins/active_scaffold/lib/bridges/file_column/lib/list_ui.rb +26 -0
- data/vendor/plugins/active_scaffold/lib/bridges/file_column/test/functional/file_column_keep_test.rb +43 -0
- data/vendor/plugins/active_scaffold/lib/bridges/file_column/test/mock_model.rb +9 -0
- data/vendor/plugins/active_scaffold/lib/bridges/file_column/test/test_helper.rb +15 -0
- data/vendor/plugins/active_scaffold/lib/dhtml_confirm.rb +54 -0
- data/vendor/plugins/active_scaffold/lib/extensions/action_controller_rendering.rb +20 -0
- data/vendor/plugins/active_scaffold/lib/extensions/action_view_rendering.rb +87 -0
- data/vendor/plugins/active_scaffold/lib/extensions/array.rb +7 -0
- data/vendor/plugins/active_scaffold/lib/extensions/component_response_with_namespacing.rb +17 -0
- data/vendor/plugins/active_scaffold/lib/extensions/generic_view_paths.rb +33 -0
- data/vendor/plugins/active_scaffold/lib/extensions/localize.rb +10 -0
- data/vendor/plugins/active_scaffold/lib/extensions/name_option_for_datetime.rb +12 -0
- data/vendor/plugins/active_scaffold/lib/extensions/nil_id_in_url_params.rb +7 -0
- data/vendor/plugins/active_scaffold/lib/extensions/resources.rb +26 -0
- data/vendor/plugins/active_scaffold/lib/extensions/reverse_associations.rb +56 -0
- data/vendor/plugins/active_scaffold/lib/extensions/to_label.rb +8 -0
- data/vendor/plugins/active_scaffold/lib/extensions/unsaved_associated.rb +61 -0
- data/vendor/plugins/active_scaffold/lib/extensions/unsaved_record.rb +20 -0
- data/vendor/plugins/active_scaffold/lib/extensions/usa_state.rb +46 -0
- data/vendor/plugins/active_scaffold/lib/paginator.rb +136 -0
- data/vendor/plugins/active_scaffold/lib/responds_to_parent.rb +68 -0
- data/vendor/plugins/active_scaffold/public/blank.html +33 -0
- data/vendor/plugins/active_scaffold/test/bridges/bridge_test.rb +47 -0
- data/vendor/plugins/active_scaffold/test/config/create_test.rb +55 -0
- data/vendor/plugins/active_scaffold/test/config/list_test.rb +74 -0
- data/vendor/plugins/active_scaffold/test/config/update_test.rb +17 -0
- data/vendor/plugins/active_scaffold/test/const_mocker.rb +36 -0
- data/vendor/plugins/active_scaffold/test/data_structures/action_columns_test.rb +119 -0
- data/vendor/plugins/active_scaffold/test/data_structures/action_link_test.rb +78 -0
- data/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb +78 -0
- data/vendor/plugins/active_scaffold/test/data_structures/actions_test.rb +25 -0
- data/vendor/plugins/active_scaffold/test/data_structures/association_column_test.rb +41 -0
- data/vendor/plugins/active_scaffold/test/data_structures/column_test.rb +161 -0
- data/vendor/plugins/active_scaffold/test/data_structures/columns_test.rb +69 -0
- data/vendor/plugins/active_scaffold/test/data_structures/error_message_test.rb +28 -0
- data/vendor/plugins/active_scaffold/test/data_structures/set_test.rb +86 -0
- data/vendor/plugins/active_scaffold/test/data_structures/sorting_test.rb +96 -0
- data/vendor/plugins/active_scaffold/test/data_structures/standard_column_test.rb +34 -0
- data/vendor/plugins/active_scaffold/test/data_structures/virtual_column_test.rb +34 -0
- data/vendor/plugins/active_scaffold/test/extensions/active_record_test.rb +45 -0
- data/vendor/plugins/active_scaffold/test/extensions/array.rb +12 -0
- data/vendor/plugins/active_scaffold/test/misc/active_record_permissions.rb +154 -0
- data/vendor/plugins/active_scaffold/test/misc/configurable_test.rb +96 -0
- data/vendor/plugins/active_scaffold/test/misc/constraints_test.rb +175 -0
- data/vendor/plugins/active_scaffold/test/misc/finder_test.rb +70 -0
- data/vendor/plugins/active_scaffold/test/misc/lang_test.rb +12 -0
- data/vendor/plugins/active_scaffold/test/model_stub.rb +39 -0
- data/vendor/plugins/active_scaffold/test/run_all.rb +8 -0
- data/vendor/plugins/active_scaffold/test/test_helper.rb +13 -0
- data/vendor/plugins/active_scaffold/uninstall.rb +12 -0
- data/vendor/plugins/active_scaffold_as_gem/init.rb +21 -0
- data/vendor/plugins/active_scaffold_form_observation/init.rb +4 -0
- data/vendor/plugins/active_scaffold_form_observation/lib/active_scaffold_form_observation.rb +99 -0
- data/vendor/plugins/active_scaffold_full_refresh/init.rb +7 -0
- data/vendor/plugins/active_scaffold_full_refresh/lib/active_scaffold_full_refresh.rb +46 -0
- data/vendor/plugins/active_scaffold_move_column_under/init.rb +17 -0
- data/vendor/plugins/acts_as_money/README +24 -0
- data/vendor/plugins/acts_as_money/Rakefile +22 -0
- data/vendor/plugins/acts_as_money/init.rb +3 -0
- data/vendor/plugins/acts_as_money/install.rb +1 -0
- data/vendor/plugins/acts_as_money/lib/acts_as_money.rb +27 -0
- data/vendor/plugins/acts_as_money/tasks/money_tasks.rake +4 -0
- data/vendor/plugins/acts_as_money/test/money_test.rb +8 -0
- data/vendor/plugins/association_hacks/init.rb +1 -0
- data/vendor/plugins/association_hacks/lib/association_hacks.rb +27 -0
- data/vendor/plugins/railspdf/CHANGELOG +5 -0
- data/vendor/plugins/railspdf/README +88 -0
- data/vendor/plugins/railspdf/Rakefile +22 -0
- data/vendor/plugins/railspdf/TODO +1 -0
- data/vendor/plugins/railspdf/init.rb +3 -0
- data/vendor/plugins/railspdf/lib/railspdf.rb +65 -0
- data/vendor/plugins/railspdf/test/railspdf_test.rb +14 -0
- data/vendor/plugins/railspdf/test/test_helper.rb +9 -0
- data/vendor/plugins/render_component/README +37 -0
- data/vendor/plugins/render_component/Rakefile +22 -0
- data/vendor/plugins/render_component/init.rb +2 -0
- data/vendor/plugins/render_component/lib/components.rb +142 -0
- data/vendor/plugins/render_component/test/abstract_unit.rb +8 -0
- data/vendor/plugins/render_component/test/components_test.rb +140 -0
- metadata +657 -0
@@ -0,0 +1,39 @@
|
|
1
|
+
module ActiveScaffold::Config
|
2
|
+
class Show < Base
|
3
|
+
self.crud_type = :read
|
4
|
+
|
5
|
+
def initialize(core_config)
|
6
|
+
@core = core_config
|
7
|
+
|
8
|
+
# start with the ActionLink defined globally
|
9
|
+
@link = self.class.link.clone
|
10
|
+
end
|
11
|
+
|
12
|
+
# global level configuration
|
13
|
+
# --------------------------
|
14
|
+
cattr_accessor :link
|
15
|
+
@@link = ActiveScaffold::DataStructures::ActionLink.new('show', :label => :show, :type => :record, :security_method => :show_authorized?)
|
16
|
+
|
17
|
+
# instance-level configuration
|
18
|
+
# ----------------------------
|
19
|
+
|
20
|
+
# the ActionLink for this action
|
21
|
+
attr_accessor :link
|
22
|
+
|
23
|
+
# the label for this action. used for the header.
|
24
|
+
attr_writer :label
|
25
|
+
def label
|
26
|
+
@label ? as_(@label) : as_(:show_model, :model => @core.label(:count => 1))
|
27
|
+
end
|
28
|
+
|
29
|
+
# provides access to the list of columns specifically meant for this action to use
|
30
|
+
def columns
|
31
|
+
self.columns = @core.columns._inheritable unless @columns # lazy evaluation
|
32
|
+
@columns
|
33
|
+
end
|
34
|
+
def columns=(val)
|
35
|
+
@columns = ActiveScaffold::DataStructures::ActionColumns.new(*val)
|
36
|
+
@columns.action = self
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module ActiveScaffold::Config
|
2
|
+
class Subform < Base
|
3
|
+
def initialize(core_config)
|
4
|
+
@core = core_config
|
5
|
+
end
|
6
|
+
|
7
|
+
# global level configuration
|
8
|
+
# --------------------------
|
9
|
+
|
10
|
+
# instance-level configuration
|
11
|
+
# ----------------------------
|
12
|
+
|
13
|
+
# provides access to the list of columns specifically meant for the Sub-Form to use
|
14
|
+
def columns
|
15
|
+
# we want to delay initializing to the @core.update.columns set for as long as possible. but we have to eventually clone, or else have a configuration "leak"
|
16
|
+
unless @columns
|
17
|
+
if @core.actions.include? :update
|
18
|
+
@columns = @core.update.columns.clone
|
19
|
+
else
|
20
|
+
self.columns = @core.columns._inheritable
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
@columns
|
25
|
+
end
|
26
|
+
|
27
|
+
def columns=(val)
|
28
|
+
@columns = ActiveScaffold::DataStructures::ActionColumns.new(*val)
|
29
|
+
@columns.action = self
|
30
|
+
return @columns
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module ActiveScaffold::Config
|
2
|
+
class Update < Form
|
3
|
+
self.crud_type = :update
|
4
|
+
def initialize(*args)
|
5
|
+
super
|
6
|
+
self.nested_links = self.class.nested_links
|
7
|
+
end
|
8
|
+
|
9
|
+
# global level configuration
|
10
|
+
# --------------------------
|
11
|
+
# the ActionLink for this action
|
12
|
+
def self.link
|
13
|
+
@@link
|
14
|
+
end
|
15
|
+
def self.link=(val)
|
16
|
+
@@link = val
|
17
|
+
end
|
18
|
+
@@link = ActiveScaffold::DataStructures::ActionLink.new('edit', :label => :edit, :type => :record, :security_method => :update_authorized?)
|
19
|
+
|
20
|
+
# instance-level configuration
|
21
|
+
# ----------------------------
|
22
|
+
|
23
|
+
# the label= method already exists in the Form base class
|
24
|
+
def label
|
25
|
+
@label ? as_(@label) : as_(:update_model, :model => @core.label(:count => 1))
|
26
|
+
end
|
27
|
+
|
28
|
+
attr_accessor :nested_links
|
29
|
+
cattr_accessor :nested_links
|
30
|
+
@@nested_links = false
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module ActiveScaffold
|
2
|
+
# Exposes a +configure+ method that accepts a block and runs all contents of the block in two contexts, as opposed to the normal one. First, everything gets evaluated as part of the object including Configurable. Then, as a failover, missing methods and variables are evaluated in the original binding of the block.
|
3
|
+
#
|
4
|
+
# Note that this only works with "barewords". Constants, instance variables, and class variables are not currently supported in both contexts.
|
5
|
+
#
|
6
|
+
# May add the given functionality at both the class and instance level. For the former, use +extend+, and for the latter, use +include+.
|
7
|
+
module Configurable
|
8
|
+
def configure(&configuration_block)
|
9
|
+
return unless configuration_block
|
10
|
+
@configuration_binding = configuration_block.binding
|
11
|
+
ret = instance_eval &configuration_block
|
12
|
+
@configuration_binding = nil
|
13
|
+
return ret
|
14
|
+
end
|
15
|
+
|
16
|
+
# this method will surely need tweaking. for example, i'm not sure if it should call super before or after it tries to eval with the binding.
|
17
|
+
def method_missing(name, *args)
|
18
|
+
begin
|
19
|
+
super
|
20
|
+
rescue NoMethodError, NameError
|
21
|
+
if @configuration_binding.nil?
|
22
|
+
raise $!
|
23
|
+
else
|
24
|
+
eval("self", @configuration_binding).send(name, *args)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,178 @@
|
|
1
|
+
module ActiveScaffold
|
2
|
+
module Constraints
|
3
|
+
def self.included(base)
|
4
|
+
base.module_eval do
|
5
|
+
before_filter :register_constraints_with_action_columns
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
protected
|
10
|
+
|
11
|
+
# Returns the current constraints
|
12
|
+
def active_scaffold_constraints
|
13
|
+
return active_scaffold_session_storage[:constraints] || {}
|
14
|
+
end
|
15
|
+
|
16
|
+
# For each enabled action, adds the constrained columns to the ActionColumns object (if it exists).
|
17
|
+
# This lets the ActionColumns object skip constrained columns.
|
18
|
+
#
|
19
|
+
# If the constraint value is a Hash, then we assume the constraint is a multi-level association constraint (the reverse of a has_many :through) and we do NOT register the constraint column.
|
20
|
+
def register_constraints_with_action_columns
|
21
|
+
constrained_fields = active_scaffold_constraints.reject{|k, v| v.is_a? Hash}.keys.collect{|k| k.to_sym}
|
22
|
+
|
23
|
+
if self.class.uses_active_scaffold?
|
24
|
+
# we actually want to do this whether constrained_fields exist or not, so that we can reset the array when they don't
|
25
|
+
active_scaffold_config.actions.each do |action_name|
|
26
|
+
action = active_scaffold_config.send(action_name)
|
27
|
+
next unless action.respond_to? :columns
|
28
|
+
action.columns.constraint_columns = constrained_fields
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Returns search conditions based on the current scaffold constraints.
|
34
|
+
#
|
35
|
+
# Supports constraints based on either a column name (in which case it checks for an association
|
36
|
+
# or just uses the search_sql) or a database field name.
|
37
|
+
#
|
38
|
+
# All of this work is primarily to support nested scaffolds in a manner generally useful for other
|
39
|
+
# embedded scaffolds.
|
40
|
+
def conditions_from_constraints
|
41
|
+
conditions = nil
|
42
|
+
active_scaffold_constraints.each do |k, v|
|
43
|
+
column = active_scaffold_config.columns[k]
|
44
|
+
constraint_condition = if column
|
45
|
+
# Assume this is a multi-level association constraint.
|
46
|
+
# example:
|
47
|
+
# data model: Park -> Den -> Bear
|
48
|
+
# constraint: :den => {:park => 5}
|
49
|
+
if v.is_a? Hash
|
50
|
+
far_association = column.association.klass.reflect_on_association(v.keys.first)
|
51
|
+
field = far_association.klass.primary_key
|
52
|
+
table = far_association.table_name
|
53
|
+
|
54
|
+
active_scaffold_joins.concat([{k => v.keys.first}]) # e.g. {:den => :park}
|
55
|
+
constraint_condition_for("#{table}.#{field}", v.values.first)
|
56
|
+
|
57
|
+
# association column constraint
|
58
|
+
elsif column.association
|
59
|
+
if column.association.macro == :has_and_belongs_to_many
|
60
|
+
active_scaffold_habtm_joins.concat column.includes
|
61
|
+
else
|
62
|
+
active_scaffold_joins.concat column.includes
|
63
|
+
end
|
64
|
+
condition_from_association_constraint(column.association, v)
|
65
|
+
|
66
|
+
# regular column constraints
|
67
|
+
elsif column.searchable?
|
68
|
+
active_scaffold_joins.concat column.includes
|
69
|
+
constraint_condition_for(column.search_sql, v)
|
70
|
+
end
|
71
|
+
# unknown-to-activescaffold-but-real-database-column constraint
|
72
|
+
elsif active_scaffold_config.model.column_names.include? k.to_s
|
73
|
+
constraint_condition_for(k.to_s, v)
|
74
|
+
else
|
75
|
+
raise ActiveScaffold::MalformedConstraint, constraint_error(active_scaffold_config.model, k), caller
|
76
|
+
end
|
77
|
+
|
78
|
+
conditions = merge_conditions(conditions, constraint_condition)
|
79
|
+
end
|
80
|
+
|
81
|
+
conditions
|
82
|
+
end
|
83
|
+
|
84
|
+
# We do NOT want to use .search_sql. If anything, search_sql will refer
|
85
|
+
# to a human-searchable value on the associated record.
|
86
|
+
def condition_from_association_constraint(association, value)
|
87
|
+
# when the reverse association is a :belongs_to, the id for the associated object only exists as
|
88
|
+
# the primary_key on the other table. so for :has_one and :has_many (when the reverse is :belongs_to),
|
89
|
+
# we have to use the other model's primary_key.
|
90
|
+
#
|
91
|
+
# please see the relevant tests for concrete examples.
|
92
|
+
field = if [:has_one, :has_many].include?(association.macro)
|
93
|
+
association.klass.primary_key
|
94
|
+
else
|
95
|
+
association.options[:association_foreign_key] || association.options[:foreign_key] || association.association_foreign_key
|
96
|
+
end
|
97
|
+
|
98
|
+
table = case association.macro
|
99
|
+
when :has_and_belongs_to_many
|
100
|
+
association.options[:join_table]
|
101
|
+
|
102
|
+
when :belongs_to
|
103
|
+
active_scaffold_config.model.table_name
|
104
|
+
|
105
|
+
when :has_many
|
106
|
+
association.table_name
|
107
|
+
|
108
|
+
else
|
109
|
+
association.table_name
|
110
|
+
end
|
111
|
+
|
112
|
+
condition = constraint_condition_for("#{table}.#{field}", value)
|
113
|
+
if association.options[:polymorphic]
|
114
|
+
condition = merge_conditions(
|
115
|
+
condition,
|
116
|
+
constraint_condition_for("#{table}.#{association.name}_type", params[:parent_model].to_s)
|
117
|
+
)
|
118
|
+
end
|
119
|
+
|
120
|
+
condition
|
121
|
+
end
|
122
|
+
|
123
|
+
def constraint_error(klass, column_name)
|
124
|
+
"Malformed constraint `#{klass}##{column_name}'. If it's a legitimate column, and you are using a nested scaffold, please specify or double-check the reverse association name."
|
125
|
+
end
|
126
|
+
|
127
|
+
# Applies constraints to the given record.
|
128
|
+
#
|
129
|
+
# Searches through the known columns for association columns. If the given constraint is an association,
|
130
|
+
# it assumes that the constraint value is an id. It then does a association.klass.find with the value
|
131
|
+
# and adds the associated object to the record.
|
132
|
+
#
|
133
|
+
# For some operations ActiveRecord will automatically update the database. That's not always ok.
|
134
|
+
# If it *is* ok (e.g. you're in a transaction), then set :allow_autosave to true.
|
135
|
+
def apply_constraints_to_record(record, options = {})
|
136
|
+
options[:allow_autosave] = false if options[:allow_autosave].nil?
|
137
|
+
|
138
|
+
active_scaffold_constraints.each do |k, v|
|
139
|
+
column = active_scaffold_config.columns[k]
|
140
|
+
if column and column.association
|
141
|
+
if v.is_a? Hash # reverse of a through association ... we need to set the far association
|
142
|
+
# example
|
143
|
+
# data model: Park -> Den -> Bear
|
144
|
+
# constraint: :den => {:park => 5}
|
145
|
+
# remote_klass: Park
|
146
|
+
remote_klass = column.association.klass.reflect_on_association(v.keys.first).klass
|
147
|
+
first_associated = record.send("#{k}")
|
148
|
+
first_associated.send("#{v.keys.first}=", remote_klass.find(v.values.first)) if first_associated
|
149
|
+
elsif column.plural_association?
|
150
|
+
record.send("#{k}").send(:<<, column.association.klass.find(v))
|
151
|
+
elsif column.association.options[:polymorphic]
|
152
|
+
record.send("#{k}=", params[:parent_model].constantize.find(v))
|
153
|
+
else # regular singular association
|
154
|
+
record.send("#{k}=", column.association.klass.find(v))
|
155
|
+
|
156
|
+
# setting the belongs_to side of a has_one isn't safe. if the has_one was already
|
157
|
+
# specified, rails won't automatically clear out the previous associated record.
|
158
|
+
#
|
159
|
+
# note that we can't take the extra step to correct this unless we're permitted to
|
160
|
+
# run operations where activerecord auto-saves the object.
|
161
|
+
reverse = column.association.klass.reflect_on_association(column.association.reverse)
|
162
|
+
if reverse.macro == :has_one and options[:allow_autosave]
|
163
|
+
record.send(k).send("#{column.association.reverse}=", record)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
else
|
167
|
+
record.send("#{k}=", v)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
private
|
173
|
+
|
174
|
+
def constraint_condition_for(sql, value)
|
175
|
+
value.nil? ? "#{sql} IS NULL" : ["#{sql} = ?", value]
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
module ActiveScaffold::DataStructures
|
2
|
+
# A set of columns. These structures can be nested for organization.
|
3
|
+
class ActionColumns < Set
|
4
|
+
include ActiveScaffold::Configurable
|
5
|
+
|
6
|
+
# this lets us refer back to the action responsible for this link, if it exists.
|
7
|
+
# the immediate need here is to get the crud_type so we can dynamically filter columns from the set.
|
8
|
+
attr_accessor :action
|
9
|
+
|
10
|
+
# labels are useful for the Create/Update forms, when we display columns in a grouped fashion and want to name them separately
|
11
|
+
attr_writer :label
|
12
|
+
def label
|
13
|
+
as_(@label) if @label
|
14
|
+
end
|
15
|
+
|
16
|
+
# Whether this column set is collapsed by default in contexts where collapsing is supported
|
17
|
+
attr_accessor :collapsed
|
18
|
+
|
19
|
+
# nests a subgroup in the column set
|
20
|
+
def add_subgroup(label, &proc)
|
21
|
+
columns = ActiveScaffold::DataStructures::ActionColumns.new
|
22
|
+
columns.label = label
|
23
|
+
columns.action = self.action
|
24
|
+
columns.configure &proc
|
25
|
+
self.exclude columns.collect_columns
|
26
|
+
self.add columns
|
27
|
+
end
|
28
|
+
|
29
|
+
def include?(item)
|
30
|
+
@set.each do |c|
|
31
|
+
return true if !c.is_a? Symbol and c.include? item
|
32
|
+
return true if c == item.to_sym
|
33
|
+
end
|
34
|
+
return false
|
35
|
+
end
|
36
|
+
|
37
|
+
protected
|
38
|
+
|
39
|
+
def collect_columns
|
40
|
+
@set.collect {|col| col.is_a?(ActiveScaffold::DataStructures::ActionColumns) ? col.collect_columns : col}
|
41
|
+
end
|
42
|
+
|
43
|
+
# called during clone or dup. makes the clone/dup deeper.
|
44
|
+
def initialize_copy(from)
|
45
|
+
@set = from.instance_variable_get('@set').clone
|
46
|
+
end
|
47
|
+
|
48
|
+
# A package of stuff to add after the configuration block. This is an attempt at making a certain level of functionality inaccessible during configuration, to reduce possible breakage from misuse.
|
49
|
+
# The bulk of the package is a means of connecting the referential column set (ActionColumns) with the actual column objects (Columns). This lets us iterate over the set and yield real column objects.
|
50
|
+
module AfterConfiguration
|
51
|
+
# Redefine the each method to yield actual Column objects.
|
52
|
+
# It will skip constrained and unauthorized columns.
|
53
|
+
#
|
54
|
+
# Options:
|
55
|
+
# * :flatten - whether to recursively iterate on nested sets. default is false.
|
56
|
+
# * :for - the record (or class) being iterated over. used for column-level security. default is the class.
|
57
|
+
def each(options = {}, &proc)
|
58
|
+
options[:for] ||= @columns.active_record_class
|
59
|
+
|
60
|
+
@set.each do |item|
|
61
|
+
unless item.is_a? ActiveScaffold::DataStructures::ActionColumns
|
62
|
+
item = (@columns[item] || ActiveScaffold::DataStructures::Column.new(item.to_sym, @columns.active_record_class))
|
63
|
+
# skip if this matches a constrained column
|
64
|
+
next if constraint_columns.include?(item.name.to_sym)
|
65
|
+
# skip if this matches the field_name of a constrained column
|
66
|
+
next if item.field_name and constraint_columns.include?(item.field_name.to_sym)
|
67
|
+
# skip this field if it's not authorized
|
68
|
+
next unless options[:for].authorized_for?(:action => options[:action] || self.action.crud_type, :column => item.name)
|
69
|
+
end
|
70
|
+
if item.is_a? ActiveScaffold::DataStructures::ActionColumns and options.has_key?(:flatten) and options[:flatten]
|
71
|
+
item.each(options, &proc)
|
72
|
+
else
|
73
|
+
yield item
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# registers a set of column objects (recursively, for all nested ActionColumns)
|
79
|
+
def set_columns(columns)
|
80
|
+
@columns = columns
|
81
|
+
# iterate over @set instead of self to avoid dealing with security queries
|
82
|
+
@set.each do |item|
|
83
|
+
item.set_columns(columns) if item.respond_to? :set_columns
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
attr_writer :constraint_columns
|
88
|
+
def constraint_columns
|
89
|
+
@constraint_columns ||= []
|
90
|
+
end
|
91
|
+
|
92
|
+
def length
|
93
|
+
(@set - self.constraint_columns).length
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
module ActiveScaffold::DataStructures
|
2
|
+
class ActionLink
|
3
|
+
# provides a quick way to set any property of the object from a hash
|
4
|
+
def initialize(action, options = {})
|
5
|
+
# set defaults
|
6
|
+
self.action = action.to_s
|
7
|
+
self.label = action
|
8
|
+
self.confirm = false
|
9
|
+
self.type = :table
|
10
|
+
self.inline = true
|
11
|
+
self.method = :get
|
12
|
+
self.crud_type = :destroy if [:destroy].include?(action.to_sym)
|
13
|
+
self.crud_type = :create if [:create, :new].include?(action.to_sym)
|
14
|
+
self.crud_type = :update if [:edit, :update].include?(action.to_sym)
|
15
|
+
self.crud_type ||= :read
|
16
|
+
self.html_options = {}
|
17
|
+
|
18
|
+
# apply quick properties
|
19
|
+
options.each_pair do |k, v|
|
20
|
+
setter = "#{k}="
|
21
|
+
self.send(setter, v) if self.respond_to? setter
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# the action-path for this link. what page to request? this is required!
|
26
|
+
attr_accessor :action
|
27
|
+
|
28
|
+
# the controller for this action link. if nil, the current controller should be assumed.
|
29
|
+
attr_accessor :controller
|
30
|
+
|
31
|
+
# a hash of request parameters
|
32
|
+
attr_accessor :parameters
|
33
|
+
|
34
|
+
# the RESTful method
|
35
|
+
attr_accessor :method
|
36
|
+
|
37
|
+
# what string to use to represent this action
|
38
|
+
attr_writer :label
|
39
|
+
def label
|
40
|
+
@label.is_a?(Symbol) ? as_(@label) : @label
|
41
|
+
end
|
42
|
+
|
43
|
+
# if the action requires confirmation
|
44
|
+
attr_writer :confirm
|
45
|
+
def confirm
|
46
|
+
@confirm.is_a?(String) ? as_(@confirm) : @confirm
|
47
|
+
end
|
48
|
+
def confirm?
|
49
|
+
@confirm ? true : false
|
50
|
+
end
|
51
|
+
|
52
|
+
# if the action uses a DHTML based (i.e. 2-phase) confirmation
|
53
|
+
attr_writer :dhtml_confirm
|
54
|
+
def dhtml_confirm
|
55
|
+
@dhtml_confirm
|
56
|
+
end
|
57
|
+
def dhtml_confirm?
|
58
|
+
@dhtml_confirm
|
59
|
+
end
|
60
|
+
|
61
|
+
# what method to call on the controller to see if this action_link should be visible
|
62
|
+
# note that this is only the UI part of the security. to prevent URL hax0rz, you also need security on requests (e.g. don't execute update method unless authorized).
|
63
|
+
attr_writer :security_method
|
64
|
+
def security_method
|
65
|
+
@security_method || "#{self.label.underscore.downcase.gsub(/ /, '_')}_authorized?"
|
66
|
+
end
|
67
|
+
|
68
|
+
# the crud type of the (eventual?) action. different than :method, because this crud action may not be imminent.
|
69
|
+
# this is used to determine record-level authorization (e.g. record.authorized_for?(:action => link.crud_type).
|
70
|
+
# options are :create, :read, :update, and :destroy
|
71
|
+
attr_accessor :crud_type
|
72
|
+
|
73
|
+
# an "inline" link is inserted into the existing page
|
74
|
+
# exclusive with popup? and page?
|
75
|
+
def inline=(val)
|
76
|
+
@inline = (val == true)
|
77
|
+
self.popup = self.page = false if @inline
|
78
|
+
end
|
79
|
+
def inline?; @inline end
|
80
|
+
|
81
|
+
# a "popup" link displays in a separate (browser?) window. this will eventually take arguments.
|
82
|
+
# exclusive with inline? and page?
|
83
|
+
def popup=(val)
|
84
|
+
@popup = (val == true)
|
85
|
+
if @popup
|
86
|
+
self.inline = self.page = false
|
87
|
+
|
88
|
+
# the :method parameter doesn't mix with the :popup parameter
|
89
|
+
# when/if we start using DHTML popups, we can bring :method back
|
90
|
+
self.method = nil
|
91
|
+
end
|
92
|
+
end
|
93
|
+
def popup?; @popup end
|
94
|
+
|
95
|
+
# a "page" link displays by reloading the current page
|
96
|
+
# exclusive with inline? and popup?
|
97
|
+
def page=(val)
|
98
|
+
@page = (val == true)
|
99
|
+
if @page
|
100
|
+
self.inline = self.popup = false
|
101
|
+
|
102
|
+
# when :method is defined, ActionView adds an onclick to use a form ...
|
103
|
+
# so it's best to just empty out :method whenever possible.
|
104
|
+
# we only ever need to know @method = :get for things that default to POST.
|
105
|
+
# the only things that default to POST are forms and ajax calls.
|
106
|
+
# when @page = true, we don't use ajax.
|
107
|
+
self.method = nil if method == :get
|
108
|
+
end
|
109
|
+
end
|
110
|
+
def page?; @page end
|
111
|
+
|
112
|
+
# where the result of this action should insert in the display.
|
113
|
+
# for :type => :table, supported values are:
|
114
|
+
# :top
|
115
|
+
# :bottom
|
116
|
+
# :replace (for updating the entire table)
|
117
|
+
# false (no attempt at positioning)
|
118
|
+
# for :type => :record, supported values are:
|
119
|
+
# :before
|
120
|
+
# :replace
|
121
|
+
# :after
|
122
|
+
# false (no attempt at positioning)
|
123
|
+
attr_writer :position
|
124
|
+
def position
|
125
|
+
return @position unless @position.nil? or @position == true
|
126
|
+
return :replace if self.type == :record
|
127
|
+
return :top if self.type == :table
|
128
|
+
raise "what should the default position be for #{self.type}?"
|
129
|
+
end
|
130
|
+
|
131
|
+
# what type of link this is. currently supported values are :table and :record.
|
132
|
+
attr_accessor :type
|
133
|
+
# html options for the link
|
134
|
+
attr_accessor :html_options
|
135
|
+
end
|
136
|
+
end
|