wice_grid 3.6.2 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +41 -0
- data/.circleci/run-build-locally.sh +7 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +32 -0
- data/.gitignore +5 -2
- data/Appraisals +11 -0
- data/CHANGELOG.md +38 -1
- data/Gemfile.lock +299 -0
- data/README.md +77 -34
- data/config/locales/ja.yml +3 -3
- data/gemfiles/rails_5.0.gemfile +7 -0
- data/gemfiles/rails_5.0.gemfile.lock +291 -0
- data/gemfiles/rails_5.1.gemfile +7 -0
- data/gemfiles/rails_5.1.gemfile.lock +291 -0
- data/gemfiles/rails_5.2.gemfile +7 -0
- data/gemfiles/rails_5.2.gemfile.lock +299 -0
- data/lib/wice/columns.rb +13 -6
- data/lib/wice/columns/column_integer.rb +11 -1
- data/lib/wice/columns/column_rails_datetime_helper.rb +3 -2
- data/lib/wice/columns/column_range.rb +6 -4
- data/lib/wice/grid_renderer.rb +23 -7
- data/lib/wice/helpers/bs_calendar_helpers.rb +9 -1
- data/lib/wice/helpers/wice_grid_view_helpers.rb +6 -6
- data/lib/wice/wice_grid_controller.rb +7 -5
- data/lib/wice/wice_grid_core_ext.rb +5 -1
- data/lib/wice/wice_grid_misc.rb +1 -1
- data/lib/wice_grid.rb +86 -59
- data/spec/acceptance_helper.rb +58 -0
- data/spec/features/action_column_request_spec.rb +280 -0
- data/spec/features/adding_rows_request_spec.rb +21 -0
- data/spec/features/all_records_request_spec.rb +18 -0
- data/spec/features/auto_reloads2_request_spec.rb +349 -0
- data/spec/features/auto_reloads3_request_spec.rb +130 -0
- data/spec/features/auto_reloads_request_spec.rb +348 -0
- data/spec/features/basics1_request_spec.rb +11 -0
- data/spec/features/basics2_request_spec.rb +10 -0
- data/spec/features/basics3_request_spec.rb +29 -0
- data/spec/features/basics4_request_spec.rb +19 -0
- data/spec/features/basics5_request_spec.rb +13 -0
- data/spec/features/basics6_request_spec.rb +22 -0
- data/spec/features/blockless_column_definition_spec.rb +27 -0
- data/spec/features/buttons_request_spec.rb +172 -0
- data/spec/features/csv_and_detached_filters_spec.rb +10 -0
- data/spec/features/csv_export_request_spec.rb +13 -0
- data/spec/features/custom_filter_params_request_spec.rb +29 -0
- data/spec/features/custom_filters1_request_spec.rb +155 -0
- data/spec/features/custom_filters2_request_spec.rb +53 -0
- data/spec/features/custom_filters3_request_spec.rb +50 -0
- data/spec/features/custom_filters4_request_spec.rb +13 -0
- data/spec/features/custom_ordering_on_calculated_request_spec.rb +30 -0
- data/spec/features/custom_ordering_request_spec.rb +36 -0
- data/spec/features/custom_ordering_with_arel_request_spec.rb +36 -0
- data/spec/features/custom_ordering_with_proc_request_spec.rb +44 -0
- data/spec/features/custom_ordering_with_ruby_request_spec.rb +30 -0
- data/spec/features/dates_request_spec.rb +56 -0
- data/spec/features/detached_filters_spec.rb +10 -0
- data/spec/features/detached_filters_two_grids_spec.rb +127 -0
- data/spec/features/disable_all_filters_spec.rb +22 -0
- data/spec/features/hiding_checkboxes_in_action_column_request_spec.rb +294 -0
- data/spec/features/integration_with_application_view_request_spec.rb +43 -0
- data/spec/features/integration_with_forms_request_spec.rb +141 -0
- data/spec/features/joining_tables_spec.rb +40 -0
- data/spec/features/localization_request_spec.rb +24 -0
- data/spec/features/many_grids_on_page_request_spec.rb +104 -0
- data/spec/features/negation_request_spec.rb +25 -0
- data/spec/features/no_records_request_spec.rb +26 -0
- data/spec/features/numeric_filters_request_spec.rb +10 -0
- data/spec/features/resultset_processings2_request_spec.rb +27 -0
- data/spec/features/resultset_processings_request_spec.rb +30 -0
- data/spec/features/saved_queries_request_spec.rb +120 -0
- data/spec/features/shared.rb +1005 -0
- data/spec/features/shared_detached_filters.rb +158 -0
- data/spec/features/styling_spec.rb +15 -0
- data/spec/features/two_associations_spec.rb +48 -0
- data/spec/features/upper_pagination_panel_request_spec.rb +23 -0
- data/spec/features/when_filtered_spec.rb +209 -0
- data/spec/fixtures/.gitkeep +0 -0
- data/spec/fixtures/companies.yml +21 -0
- data/spec/fixtures/priorities.yml +31 -0
- data/spec/fixtures/project_roles.yml +25 -0
- data/spec/fixtures/projects.yml +22 -0
- data/spec/fixtures/statuses.yml +55 -0
- data/spec/fixtures/tasks.yml +751 -0
- data/spec/fixtures/tasks_users.yml +2089 -0
- data/spec/fixtures/users.yml +61 -0
- data/spec/fixtures/versions.yml +78 -0
- data/spec/models/company_spec.rb +6 -0
- data/spec/models/priority_spec.rb +6 -0
- data/spec/models/project_spec.rb +11 -0
- data/spec/models/status_spec.rb +6 -0
- data/spec/models/task_spec.rb +12 -0
- data/spec/models/user_project_participation_spec.rb +7 -0
- data/spec/models/user_spec.rb +12 -0
- data/spec/models/version_spec.rb +5 -0
- data/spec/rails_helper.rb +15 -0
- data/spec/spec_helper.rb +10 -9
- data/spec/support/test_app/Rakefile +3 -0
- data/spec/support/test_app/app/assets/javascripts/application.js +20 -0
- data/spec/support/test_app/app/assets/javascripts/common.js.coffee +6 -0
- data/spec/support/test_app/app/assets/javascripts/jquery.ui.datepicker.locales.js +56 -0
- data/spec/support/test_app/app/assets/stylesheets/adding_rows.scss +3 -0
- data/spec/support/test_app/app/assets/stylesheets/application.scss +46 -0
- data/spec/support/test_app/app/assets/stylesheets/csv_and_detached_filters.scss +3 -0
- data/spec/support/test_app/app/assets/stylesheets/many_grids_on_page.scss +3 -0
- data/spec/support/test_app/app/controllers/action_column_controller.rb +15 -0
- data/spec/support/test_app/app/controllers/adding_rows_controller.rb +14 -0
- data/spec/support/test_app/app/controllers/all_records_controller.rb +14 -0
- data/spec/support/test_app/app/controllers/application_controller.rb +99 -0
- data/spec/support/test_app/app/controllers/auto_reloads2_controller.rb +14 -0
- data/spec/support/test_app/app/controllers/auto_reloads3_controller.rb +20 -0
- data/spec/support/test_app/app/controllers/auto_reloads_controller.rb +14 -0
- data/spec/support/test_app/app/controllers/basics1_controller.rb +6 -0
- data/spec/support/test_app/app/controllers/basics2_controller.rb +6 -0
- data/spec/support/test_app/app/controllers/basics3_controller.rb +6 -0
- data/spec/support/test_app/app/controllers/basics4_controller.rb +6 -0
- data/spec/support/test_app/app/controllers/basics5_controller.rb +6 -0
- data/spec/support/test_app/app/controllers/basics6_controller.rb +11 -0
- data/spec/support/test_app/app/controllers/blockless_column_definition_controller.rb +6 -0
- data/spec/support/test_app/app/controllers/buttons_controller.rb +6 -0
- data/spec/support/test_app/app/controllers/csv_and_detached_filters_controller.rb +13 -0
- data/spec/support/test_app/app/controllers/csv_export_controller.rb +28 -0
- data/spec/support/test_app/app/controllers/custom_filter_params_controller.rb +6 -0
- data/spec/support/test_app/app/controllers/custom_filters1_controller.rb +9 -0
- data/spec/support/test_app/app/controllers/custom_filters2_controller.rb +14 -0
- data/spec/support/test_app/app/controllers/custom_filters3_controller.rb +12 -0
- data/spec/support/test_app/app/controllers/custom_filters4_controller.rb +12 -0
- data/spec/support/test_app/app/controllers/custom_ordering_controller.rb +18 -0
- data/spec/support/test_app/app/controllers/custom_ordering_on_calculated_controller.rb +6 -0
- data/spec/support/test_app/app/controllers/custom_ordering_with_arel_controller.rb +18 -0
- data/spec/support/test_app/app/controllers/custom_ordering_with_proc_controller.rb +11 -0
- data/spec/support/test_app/app/controllers/custom_ordering_with_ruby_controller.rb +6 -0
- data/spec/support/test_app/app/controllers/dates_controller.rb +8 -0
- data/spec/support/test_app/app/controllers/detached_filters_controller.rb +6 -0
- data/spec/support/test_app/app/controllers/detached_filters_two_grids_controller.rb +7 -0
- data/spec/support/test_app/app/controllers/disable_all_filters_controller.rb +6 -0
- data/spec/support/test_app/app/controllers/hiding_checkboxes_in_action_column_controller.rb +13 -0
- data/spec/support/test_app/app/controllers/home_controller.rb +3 -0
- data/spec/support/test_app/app/controllers/integration_with_application_view_controller.rb +16 -0
- data/spec/support/test_app/app/controllers/integration_with_forms_controller.rb +11 -0
- data/spec/support/test_app/app/controllers/joining_tables_controller.rb +11 -0
- data/spec/support/test_app/app/controllers/localization_controller.rb +26 -0
- data/spec/support/test_app/app/controllers/many_grids_on_page_controller.rb +7 -0
- data/spec/support/test_app/app/controllers/negation_controller.rb +14 -0
- data/spec/support/test_app/app/controllers/no_records_controller.rb +8 -0
- data/spec/support/test_app/app/controllers/null_values_controller.rb +10 -0
- data/spec/support/test_app/app/controllers/numeric_filters_controller.rb +6 -0
- data/spec/support/test_app/app/controllers/queries_controller.rb +4 -0
- data/spec/support/test_app/app/controllers/resultset_processings2_controller.rb +29 -0
- data/spec/support/test_app/app/controllers/resultset_processings_controller.rb +30 -0
- data/spec/support/test_app/app/controllers/saved_queries_controller.rb +14 -0
- data/spec/support/test_app/app/controllers/styling_controller.rb +7 -0
- data/spec/support/test_app/app/controllers/tasks_controller.rb +14 -0
- data/spec/support/test_app/app/controllers/two_associations_controller.rb +6 -0
- data/spec/support/test_app/app/controllers/upper_pagination_panel_controller.rb +6 -0
- data/spec/support/test_app/app/controllers/when_filtered_controller.rb +6 -0
- data/spec/support/test_app/app/helpers/application_helper.rb +82 -0
- data/spec/support/test_app/app/mailers/.gitkeep +0 -0
- data/spec/support/test_app/app/models/.gitkeep +0 -0
- data/spec/support/test_app/app/models/company.rb +5 -0
- data/spec/support/test_app/app/models/populate.rb +84 -0
- data/spec/support/test_app/app/models/priority.rb +10 -0
- data/spec/support/test_app/app/models/project.rb +14 -0
- data/spec/support/test_app/app/models/project_role.rb +3 -0
- data/spec/support/test_app/app/models/status.rb +10 -0
- data/spec/support/test_app/app/models/task.rb +11 -0
- data/spec/support/test_app/app/models/to_dropdown_mixin.rb +16 -0
- data/spec/support/test_app/app/models/user.rb +8 -0
- data/spec/support/test_app/app/models/user_project_participation.rb +6 -0
- data/spec/support/test_app/app/models/version.rb +6 -0
- data/spec/support/test_app/app/views/action_column/_grid.html.erb +35 -0
- data/spec/support/test_app/app/views/action_column/index.html.haml +45 -0
- data/spec/support/test_app/app/views/adding_rows/_grid.html.erb +58 -0
- data/spec/support/test_app/app/views/adding_rows/index.html.haml +37 -0
- data/spec/support/test_app/app/views/all_records/_grid.html.erb +30 -0
- data/spec/support/test_app/app/views/all_records/index.html.haml +12 -0
- data/spec/support/test_app/app/views/auto_reloads/_grid.html.erb +32 -0
- data/spec/support/test_app/app/views/auto_reloads/index.html.haml +15 -0
- data/spec/support/test_app/app/views/auto_reloads2/_grid.html.erb +32 -0
- data/spec/support/test_app/app/views/auto_reloads2/index.html.haml +65 -0
- data/spec/support/test_app/app/views/auto_reloads3/_grid.html.erb +25 -0
- data/spec/support/test_app/app/views/auto_reloads3/index.html.haml +78 -0
- data/spec/support/test_app/app/views/basics1/_grid.html.erb +26 -0
- data/spec/support/test_app/app/views/basics1/index.html.haml +13 -0
- data/spec/support/test_app/app/views/basics2/_grid.html.erb +27 -0
- data/spec/support/test_app/app/views/basics2/index.html.haml +12 -0
- data/spec/support/test_app/app/views/basics3/_grid.html.erb +28 -0
- data/spec/support/test_app/app/views/basics3/index.html.haml +13 -0
- data/spec/support/test_app/app/views/basics4/_grid.html.erb +21 -0
- data/spec/support/test_app/app/views/basics4/index.html.haml +12 -0
- data/spec/support/test_app/app/views/basics5/_grid.html.erb +19 -0
- data/spec/support/test_app/app/views/basics5/index.html.haml +12 -0
- data/spec/support/test_app/app/views/basics6/_grid.html.erb +19 -0
- data/spec/support/test_app/app/views/basics6/index.html.haml +23 -0
- data/spec/support/test_app/app/views/blockless_column_definition/_grid.html.erb +19 -0
- data/spec/support/test_app/app/views/blockless_column_definition/index.html.haml +15 -0
- data/spec/support/test_app/app/views/buttons/_grid.html.erb +20 -0
- data/spec/support/test_app/app/views/buttons/index.html.haml +30 -0
- data/spec/support/test_app/app/views/csv_and_detached_filters/_grid.html.erb +23 -0
- data/spec/support/test_app/app/views/csv_and_detached_filters/index.html.haml +58 -0
- data/spec/support/test_app/app/views/csv_export/_projects_grid.html.erb +17 -0
- data/spec/support/test_app/app/views/csv_export/_tasks_grid.html.erb +43 -0
- data/spec/support/test_app/app/views/csv_export/index.html.haml +90 -0
- data/spec/support/test_app/app/views/custom_filter_params/_grid.html.erb +12 -0
- data/spec/support/test_app/app/views/custom_filter_params/index.html.haml +12 -0
- data/spec/support/test_app/app/views/custom_filters1/_g1.html.erb +8 -0
- data/spec/support/test_app/app/views/custom_filters1/_g2.html.erb +9 -0
- data/spec/support/test_app/app/views/custom_filters1/_g3.html.erb +9 -0
- data/spec/support/test_app/app/views/custom_filters1/_g4.html.erb +8 -0
- data/spec/support/test_app/app/views/custom_filters1/index.html.haml +30 -0
- data/spec/support/test_app/app/views/custom_filters2/_grid.html.erb +30 -0
- data/spec/support/test_app/app/views/custom_filters2/index.html.haml +41 -0
- data/spec/support/test_app/app/views/custom_filters3/_grid.html.erb +18 -0
- data/spec/support/test_app/app/views/custom_filters3/index.html.haml +16 -0
- data/spec/support/test_app/app/views/custom_filters4/_grid.html.erb +20 -0
- data/spec/support/test_app/app/views/custom_filters4/index.html.haml +12 -0
- data/spec/support/test_app/app/views/custom_ordering/_grid.html.erb +10 -0
- data/spec/support/test_app/app/views/custom_ordering/index.html.haml +24 -0
- data/spec/support/test_app/app/views/custom_ordering_on_calculated/_grid.html.erb +14 -0
- data/spec/support/test_app/app/views/custom_ordering_on_calculated/index.html.haml +23 -0
- data/spec/support/test_app/app/views/custom_ordering_with_arel/_grid.html.erb +10 -0
- data/spec/support/test_app/app/views/custom_ordering_with_arel/index.html.haml +24 -0
- data/spec/support/test_app/app/views/custom_ordering_with_proc/_grid.html.erb +10 -0
- data/spec/support/test_app/app/views/custom_ordering_with_proc/index.html.haml +21 -0
- data/spec/support/test_app/app/views/custom_ordering_with_ruby/_grid.html.erb +10 -0
- data/spec/support/test_app/app/views/custom_ordering_with_ruby/index.html.haml +23 -0
- data/spec/support/test_app/app/views/dates/_grid.html.erb +25 -0
- data/spec/support/test_app/app/views/dates/index.html.haml +52 -0
- data/spec/support/test_app/app/views/detached_filters/_grid.html.erb +23 -0
- data/spec/support/test_app/app/views/detached_filters/index.html.haml +79 -0
- data/spec/support/test_app/app/views/detached_filters_two_grids/_grid.html.erb +23 -0
- data/spec/support/test_app/app/views/detached_filters_two_grids/index.html.haml +85 -0
- data/spec/support/test_app/app/views/disable_all_filters/_grid.html.erb +21 -0
- data/spec/support/test_app/app/views/disable_all_filters/index.html.haml +14 -0
- data/spec/support/test_app/app/views/hiding_checkboxes_in_action_column/_grid.html.erb +34 -0
- data/spec/support/test_app/app/views/hiding_checkboxes_in_action_column/index.html.haml +32 -0
- data/spec/support/test_app/app/views/integration_with_application_view/_grid.html.erb +27 -0
- data/spec/support/test_app/app/views/integration_with_application_view/index.html.haml +33 -0
- data/spec/support/test_app/app/views/integration_with_forms/_grid.html.erb +23 -0
- data/spec/support/test_app/app/views/integration_with_forms/index.html.haml +18 -0
- data/spec/support/test_app/app/views/joining_tables/_grid.html.erb +23 -0
- data/spec/support/test_app/app/views/joining_tables/index.html.haml +26 -0
- data/spec/support/test_app/app/views/layouts/application.html.haml +61 -0
- data/spec/support/test_app/app/views/localization/_grid.html.erb +36 -0
- data/spec/support/test_app/app/views/localization/index.html.haml +20 -0
- data/spec/support/test_app/app/views/many_grids_on_page/_tasks_grid1.html.erb +12 -0
- data/spec/support/test_app/app/views/many_grids_on_page/_tasks_grid2.html.erb +12 -0
- data/spec/support/test_app/app/views/many_grids_on_page/index.html.haml +26 -0
- data/spec/support/test_app/app/views/negation/_grid.html.erb +30 -0
- data/spec/support/test_app/app/views/negation/index.html.haml +15 -0
- data/spec/support/test_app/app/views/no_records/_empty_grid.html.haml +1 -0
- data/spec/support/test_app/app/views/no_records/_grid1.html.erb +11 -0
- data/spec/support/test_app/app/views/no_records/_grid2.html.erb +9 -0
- data/spec/support/test_app/app/views/no_records/_grid3.html.erb +9 -0
- data/spec/support/test_app/app/views/no_records/index.html.haml +24 -0
- data/spec/support/test_app/app/views/null_values/_grid.html.erb +17 -0
- data/spec/support/test_app/app/views/null_values/index.html.haml +21 -0
- data/spec/support/test_app/app/views/numeric_filters/_grid.html.erb +19 -0
- data/spec/support/test_app/app/views/numeric_filters/index.html.haml +12 -0
- data/spec/support/test_app/app/views/resultset_processings/_grid.html.erb +27 -0
- data/spec/support/test_app/app/views/resultset_processings/index.html.haml +50 -0
- data/spec/support/test_app/app/views/resultset_processings2/_grid.html.erb +27 -0
- data/spec/support/test_app/app/views/resultset_processings2/index.html.haml +48 -0
- data/spec/support/test_app/app/views/saved_queries/_grid.html.erb +30 -0
- data/spec/support/test_app/app/views/saved_queries/index.html.haml +15 -0
- data/spec/support/test_app/app/views/styling/_grid1.html.erb +12 -0
- data/spec/support/test_app/app/views/styling/_grid2.html.erb +31 -0
- data/spec/support/test_app/app/views/styling/index.html.haml +65 -0
- data/spec/support/test_app/app/views/tasks/_grid.html.erb +19 -0
- data/spec/support/test_app/app/views/tasks/index.html.haml +1 -0
- data/spec/support/test_app/app/views/two_associations/_grid.html.erb +13 -0
- data/spec/support/test_app/app/views/two_associations/index.html.haml +13 -0
- data/spec/support/test_app/app/views/upper_pagination_panel/_grid.html.erb +27 -0
- data/spec/support/test_app/app/views/upper_pagination_panel/index.html.haml +14 -0
- data/spec/support/test_app/app/views/when_filtered/_grid.html.erb +19 -0
- data/spec/support/test_app/app/views/when_filtered/index.html.haml +15 -0
- data/spec/support/test_app/bin/rails +4 -0
- data/spec/support/test_app/bin/rake +4 -0
- data/spec/support/test_app/config.ru +5 -0
- data/spec/support/test_app/config/application.rb +70 -0
- data/spec/support/test_app/config/boot.rb +7 -0
- data/spec/support/test_app/config/database.travis.yml +27 -0
- data/spec/support/test_app/config/database.yml +16 -0
- data/spec/support/test_app/config/database.yml.mysql +19 -0
- data/spec/support/test_app/config/database.yml.postgresql +18 -0
- data/spec/support/test_app/config/environment.rb +6 -0
- data/spec/support/test_app/config/environments/development.rb +34 -0
- data/spec/support/test_app/config/environments/production.rb +66 -0
- data/spec/support/test_app/config/environments/test.rb +34 -0
- data/spec/support/test_app/config/initializers/backtrace_silencers.rb +8 -0
- data/spec/support/test_app/config/initializers/inflections.rb +16 -0
- data/spec/support/test_app/config/initializers/mime_types.rb +6 -0
- data/spec/support/test_app/config/initializers/secret_token.rb +12 -0
- data/spec/support/test_app/config/initializers/session_store.rb +9 -0
- data/spec/support/test_app/config/initializers/wice_grid_config.rb +163 -0
- data/spec/support/test_app/config/initializers/wrap_parameters.rb +15 -0
- data/spec/support/test_app/config/locales/en.yml +5 -0
- data/spec/support/test_app/config/locales/wice_grid.yml +550 -0
- data/spec/support/test_app/config/puma.rb +15 -0
- data/spec/support/test_app/config/routes.rb +125 -0
- data/spec/support/test_app/db/migrate/20120224193505_create_tasks.rb +27 -0
- data/spec/support/test_app/db/migrate/20120224193517_create_users.rb +12 -0
- data/spec/support/test_app/db/migrate/20120224193522_create_projects.rb +14 -0
- data/spec/support/test_app/db/migrate/20120224193529_create_priorities.rb +13 -0
- data/spec/support/test_app/db/migrate/20120224193537_create_statuses.rb +13 -0
- data/spec/support/test_app/db/migrate/20120224193543_create_versions.rb +15 -0
- data/spec/support/test_app/db/migrate/20120224193550_create_project_roles.rb +12 -0
- data/spec/support/test_app/db/migrate/20120224193610_create_companies.rb +12 -0
- data/spec/support/test_app/db/migrate/20120224195351_create_user_project_participations.rb +16 -0
- data/spec/support/test_app/db/migrate/20120224195521_add_tasks_users.rb +11 -0
- data/spec/support/test_app/db/migrate/20120610091944_create_wice_grid_serialized_queries.rb +14 -0
- data/spec/support/test_app/db/schema.rb +139 -0
- data/spec/support/test_app/db/seeds.rb +10 -0
- data/spec/support/test_app/lib/ar_fixtures.rb +100 -0
- data/spec/support/test_app/lib/assets/.gitkeep +0 -0
- data/spec/support/test_app/lib/tasks/.gitkeep +0 -0
- data/spec/support/test_app/lib/tasks/ar_fixtures.rake +45 -0
- data/spec/support/test_app/public/404.html +26 -0
- data/spec/support/test_app/public/422.html +26 -0
- data/spec/support/test_app/public/500.html +25 -0
- data/spec/support/test_app/public/favicon.ico +0 -0
- data/spec/support/test_app/public/robots.txt +5 -0
- data/spec/wice/grid_output_buffer_spec.rb +2 -2
- data/spec/wice/table_column_matrix_spec.rb +1 -1
- data/vendor/assets/javascripts/wice_grid_init.js.coffee +16 -4
- data/vendor/assets/javascripts/wice_grid_saved_queries_init.js.coffee +1 -0
- data/wice_grid.gemspec +29 -9
- metadata +606 -62
- data/release_notes/RELEASE_NOTES_3.2.pre1.rdoc +0 -81
- data/release_notes/RELEASE_NOTES_3.2.pre2.rdoc +0 -6
- data/release_notes/RELEASE_NOTES_3.3.0.rdoc +0 -21
- data/spec/support/wice_grid_test_config.rb +0 -173
- data/test/readme.txt +0 -1
data/lib/wice/columns.rb
CHANGED
@@ -99,7 +99,8 @@ module Wice #:nodoc:
|
|
99
99
|
|
100
100
|
# fields defined from the options parameter
|
101
101
|
FIELDS = [:attribute, :name, :html, :filter, :model, :allow_multiple_selection,
|
102
|
-
:in_html, :in_csv, :table_alias, :custom_order, :detach_with_id, :ordering, :auto_reload
|
102
|
+
:in_html, :in_csv, :table_alias, :custom_order, :detach_with_id, :ordering, :auto_reload,
|
103
|
+
:filter_control_options, :sort_by]
|
103
104
|
|
104
105
|
attr_accessor(*FIELDS)
|
105
106
|
|
@@ -124,6 +125,9 @@ module Wice #:nodoc:
|
|
124
125
|
# A boolean flag: whether a column has a text input or not
|
125
126
|
attr_reader :contains_a_text_input
|
126
127
|
|
128
|
+
# options for rendering filter controls. Supported options are specific to the type.
|
129
|
+
attr_accessor :filter_control_options
|
130
|
+
|
127
131
|
def initialize(block, options, grid_obj, tname, mtable, cfilter, view) #:nodoc:
|
128
132
|
self.cell_rendering_block = block
|
129
133
|
self.grid = grid_obj
|
@@ -199,13 +203,16 @@ module Wice #:nodoc:
|
|
199
203
|
[query, query_without_equals_sign, parameter_name, dom_id.tr('.', '_')]
|
200
204
|
end
|
201
205
|
|
202
|
-
#
|
203
|
-
|
204
|
-
|
206
|
+
# Returns a reference to the column in the form: "table_name.column_name", unless it is a column in the main
|
207
|
+
# table, in which case it will return just "column_name",
|
208
|
+
def attribute_name_fully_qualified_for_all_but_main_table_columns
|
209
|
+
return attribute if main_table
|
210
|
+
return fully_qualified_attribute_name
|
205
211
|
end
|
206
212
|
|
207
|
-
|
208
|
-
|
213
|
+
# Returns a reference to the column in the form: "table_name.column_name".
|
214
|
+
def fully_qualified_attribute_name
|
215
|
+
table_alias_or_table_name ? (table_alias_or_table_name + '.' + attribute) : nil
|
209
216
|
end
|
210
217
|
|
211
218
|
def filter_shown? #:nodoc:
|
@@ -30,6 +30,16 @@ module Wice
|
|
30
30
|
end
|
31
31
|
|
32
32
|
class ConditionsGeneratorColumnInteger < ConditionsGeneratorColumn #:nodoc:
|
33
|
+
# Note: also used in ColumnRange, hence class method
|
34
|
+
def self.get_value(val) #:nodoc:
|
35
|
+
# Try to determine localized separator using I18n and replace it with default one
|
36
|
+
separator = I18n.t!('number.format.separator') rescue nil
|
37
|
+
val = val.sub(separator, '.') if val.respond_to?(:sub) && separator
|
38
|
+
|
39
|
+
# Parse as float
|
40
|
+
Float(val) rescue nil
|
41
|
+
end
|
42
|
+
|
33
43
|
def get_op_and_value(val) #:nodoc:
|
34
44
|
num = nil
|
35
45
|
op = nil
|
@@ -41,7 +51,7 @@ module Wice
|
|
41
51
|
if start_of_num
|
42
52
|
op = val[0...start_of_num]
|
43
53
|
op = '=' if op == ''
|
44
|
-
num =
|
54
|
+
num = ConditionsGeneratorColumnInteger.get_value(val[start_of_num..-1])
|
45
55
|
|
46
56
|
op = nil unless ['<', '>', '<=', '>=', '='].include?(op)
|
47
57
|
end
|
@@ -11,9 +11,10 @@ module Wice
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def do_render(params) #:nodoc:
|
14
|
+
datetime_options = filter_control_options ? filter_control_options.slice(:start_year, :end_year, :max_year_allowed) : {}
|
14
15
|
'<div class="date-filter">' +
|
15
|
-
select_datetime(params[:fr], include_blank: true, prefix: @name1) + '<br/>' +
|
16
|
-
select_datetime(params[:to], include_blank: true, prefix: @name2) +
|
16
|
+
select_datetime(params[:fr], datetime_options.merge(include_blank: true, prefix: @name1)) + '<br/>' +
|
17
|
+
select_datetime(params[:to], datetime_options.merge(include_blank: true, prefix: @name2)) +
|
17
18
|
'</div>'
|
18
19
|
end
|
19
20
|
|
@@ -41,18 +41,20 @@ module Wice
|
|
41
41
|
end
|
42
42
|
conditions = [[]]
|
43
43
|
if opts[:fr]
|
44
|
-
|
44
|
+
fr_num = ConditionsGeneratorColumnInteger.get_value(opts[:fr])
|
45
|
+
if fr_num
|
45
46
|
conditions[0] << " #{@column_wrapper.alias_or_table_name(table_alias)}.#{@column_wrapper.name} >= ? "
|
46
|
-
conditions <<
|
47
|
+
conditions << fr_num
|
47
48
|
else
|
48
49
|
opts.delete(:fr)
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
52
53
|
if opts[:to]
|
53
|
-
|
54
|
+
to_num = ConditionsGeneratorColumnInteger.get_value(opts[:to])
|
55
|
+
if to_num
|
54
56
|
conditions[0] << " #{@column_wrapper.alias_or_table_name(table_alias)}.#{@column_wrapper.name} <= ? "
|
55
|
-
conditions <<
|
57
|
+
conditions << to_num
|
56
58
|
else
|
57
59
|
opts.delete(:to)
|
58
60
|
end
|
data/lib/wice/grid_renderer.rb
CHANGED
@@ -215,6 +215,9 @@ module Wice
|
|
215
215
|
# * <tt>:filter_type</tt> - Using a column filter different from the default filter chosen automatically based on the
|
216
216
|
# data type or the <tt>:custom_filter</tt> argument. See <tt>lib/columns/column_processor_index.rb</tt> for the
|
217
217
|
# list of available filters.
|
218
|
+
# * <tt>:filter_control_options</tt> - Additional options to pass to the filter class to change the filter control
|
219
|
+
# behaviour. Supported options are dependent on the filter used.
|
220
|
+
# This is needed if sorting is required while filters are not.
|
218
221
|
# * <tt>:ordering</tt> - Enable/disable ordering links in the column titles. The default is +true+
|
219
222
|
# (i.e. if <tt>:attribute</tt> is defined, ordering is enabled)
|
220
223
|
# * <tt>:assoc</tt> - Name of the model association. <tt>:attribute</tt> belongs to the table joined via this association.
|
@@ -259,6 +262,12 @@ module Wice
|
|
259
262
|
# However, if the retuned value is a two element array, the first element is used for the option label and the
|
260
263
|
# second - for the value.
|
261
264
|
# Read more in README, section 'Custom dropdown filters'
|
265
|
+
# * <tt>:sort_by</tt> - allows arbitrary sorting of the results. This option takes a Proc which returns a value to
|
266
|
+
# sort by. When this option is used and sorting on this column is activated, the entire resultset is loaded and
|
267
|
+
# the Proc is passed to Enumerable#sort_by. This can also be used with calculated columns, but an arbitrary
|
268
|
+
# <tt>:attribute</tt> option must be included to provide a request parameter key. Because this option will load
|
269
|
+
# the entire resultset, it should only be used with small resultsets. The <tt>:custom_order</tt> option on grid
|
270
|
+
# initialization should be preferred if possible, as it will perform the sorting in SQL.
|
262
271
|
# * <tt>:boolean_filter_true_label</tt> - overrides the label for <tt>true</tt> in the boolean filter (<tt>wice_grid.boolean_filter_true_label</tt> in <tt>wice_grid.yml</tt>).
|
263
272
|
# * <tt>:boolean_filter_false_label</tt> - overrides the label for <tt>false</tt> in the boolean filter (<tt>wice_grid.boolean_filter_false_label</tt> in <tt>wice_grid.yml</tt>).
|
264
273
|
# * <tt>:allow_multiple_selection</tt> - enables or disables switching between single and multiple selection modes for
|
@@ -305,6 +314,7 @@ module Wice
|
|
305
314
|
detach_with_id: nil,
|
306
315
|
filter: true,
|
307
316
|
filter_all_label: ConfigurationProvider.value_for(:CUSTOM_FILTER_ALL_LABEL),
|
317
|
+
filter_control_options: {},
|
308
318
|
filter_type: nil,
|
309
319
|
html: {},
|
310
320
|
in_csv: true,
|
@@ -313,7 +323,8 @@ module Wice
|
|
313
323
|
name: '',
|
314
324
|
negation: ConfigurationProvider.value_for(:NEGATION_IN_STRING_FILTERS),
|
315
325
|
ordering: true,
|
316
|
-
table_alias: nil
|
326
|
+
table_alias: nil,
|
327
|
+
sort_by: nil,
|
317
328
|
}
|
318
329
|
|
319
330
|
opts.assert_valid_keys(options.keys)
|
@@ -375,7 +386,8 @@ module Wice
|
|
375
386
|
custom_filter_active: options[:custom_filter],
|
376
387
|
table_alias: options[:table_alias],
|
377
388
|
filter_type: options[:filter_type],
|
378
|
-
assocs: assocs
|
389
|
+
assocs: assocs,
|
390
|
+
sort_by: options[:sort_by],
|
379
391
|
)
|
380
392
|
|
381
393
|
# [ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter::Column, String, Boolean]
|
@@ -536,7 +548,7 @@ module Wice
|
|
536
548
|
end
|
537
549
|
|
538
550
|
def base_link_for_filter(controller, extra_parameters = {}) #:nodoc:
|
539
|
-
new_params = Wice::WgHash.deep_clone controller.params
|
551
|
+
new_params = Wice::WgHash.deep_clone controller.params.to_unsafe_h
|
540
552
|
new_params.merge!(extra_parameters)
|
541
553
|
|
542
554
|
if new_params[@grid.name]
|
@@ -556,7 +568,7 @@ module Wice
|
|
556
568
|
end
|
557
569
|
|
558
570
|
def link_for_export(controller, format, extra_parameters = {}) #:nodoc:
|
559
|
-
new_params = Wice::WgHash.deep_clone controller.params
|
571
|
+
new_params = Wice::WgHash.deep_clone controller.params.to_unsafe_h
|
560
572
|
new_params.merge!(extra_parameters)
|
561
573
|
|
562
574
|
new_params[@grid.name] = {} unless new_params[@grid.name]
|
@@ -567,7 +579,7 @@ module Wice
|
|
567
579
|
end
|
568
580
|
|
569
581
|
def column_link(column, direction, params, extra_parameters = {}) #:nodoc:
|
570
|
-
column_attribute_name = if column.attribute.index('.') || column.main_table
|
582
|
+
column_attribute_name = if column.attribute.index('.') || column.main_table || column.table_alias_or_table_name.nil?
|
571
583
|
column.attribute
|
572
584
|
else
|
573
585
|
column.table_alias_or_table_name + '.' + column.attribute
|
@@ -578,7 +590,7 @@ module Wice
|
|
578
590
|
ORDER_DIRECTION_PARAMETER_NAME => direction
|
579
591
|
} }
|
580
592
|
|
581
|
-
cleaned_params = Wice::WgHash.deep_clone params
|
593
|
+
cleaned_params = Wice::WgHash.deep_clone params.to_unsafe_h
|
582
594
|
cleaned_params.merge!(extra_parameters)
|
583
595
|
|
584
596
|
cleaned_params.delete(:controller)
|
@@ -586,7 +598,11 @@ module Wice
|
|
586
598
|
|
587
599
|
query_params = Wice::WgHash.rec_merge(cleaned_params, query_params)
|
588
600
|
|
589
|
-
|
601
|
+
if Rails.version.to_i >= 5
|
602
|
+
'?' + query_params.to_h.to_query
|
603
|
+
else
|
604
|
+
'?' + query_params.to_query
|
605
|
+
end
|
590
606
|
end
|
591
607
|
|
592
608
|
protected
|
@@ -17,12 +17,20 @@ module Wice #:nodoc:
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def date_calendar_bs(calendar_data) #:nodoc:
|
20
|
+
placeholder =
|
21
|
+
if calendar_data.the_other_datepicker_id_to
|
22
|
+
I18n.t("wice_grid.date_selector_tooltip_from")
|
23
|
+
else
|
24
|
+
I18n.t("wice_grid.date_selector_tooltip_to")
|
25
|
+
end
|
26
|
+
|
20
27
|
text_field_tag_options = {
|
21
28
|
:id => calendar_data.dom_id,
|
22
29
|
'data-provide' => 'datepicker',
|
23
30
|
'data-date-language' => I18n.locale,
|
24
31
|
'data-date-autoclose' => true,
|
25
|
-
'data-date-format' => Wice::ConfigurationProvider.value_for(:DATE_FORMAT_BOOTSTRAP)
|
32
|
+
'data-date-format' => Wice::ConfigurationProvider.value_for(:DATE_FORMAT_BOOTSTRAP),
|
33
|
+
'placeholder' => placeholder
|
26
34
|
}
|
27
35
|
|
28
36
|
text_field_tag_options['class'] = 'form-control input-sm'
|
@@ -294,7 +294,7 @@ module Wice
|
|
294
294
|
|
295
295
|
Wice::WgHash.add_or_append_class_value!(opts, column.css_class)
|
296
296
|
|
297
|
-
if column.attribute && column.ordering
|
297
|
+
if column.attribute && (column.ordering || column.sort_by)
|
298
298
|
|
299
299
|
column.add_css_class('active-filter') if grid.filtered_by?(column)
|
300
300
|
|
@@ -505,14 +505,14 @@ module Wice
|
|
505
505
|
grid.output_buffer << '</div>'
|
506
506
|
|
507
507
|
if Rails.env.development?
|
508
|
-
grid.output_buffer << javascript_tag(%/
|
508
|
+
grid.output_buffer << javascript_tag(%/ document.ready = function(){ \n/ +
|
509
509
|
%$ if (typeof(WiceGridProcessor) == "undefined"){\n$ +
|
510
510
|
%$ alert("wice_grid.js not loaded, WiceGrid cannot proceed!\\n" +\n$ +
|
511
511
|
%( "Make sure that you have loaded wice_grid.js.\\n" + ) +
|
512
512
|
%( "Add line //= require wice_grid.js " + ) +
|
513
513
|
%$ "to app/assets/javascripts/application.js")\n$ +
|
514
514
|
%( } ) +
|
515
|
-
%$ }
|
515
|
+
%$ } $)
|
516
516
|
end
|
517
517
|
|
518
518
|
grid.output_buffer
|
@@ -667,7 +667,7 @@ module Wice
|
|
667
667
|
first = 1
|
668
668
|
last = collection.size
|
669
669
|
|
670
|
-
|
670
|
+
total_pages = 1
|
671
671
|
|
672
672
|
class << collection
|
673
673
|
def current_page
|
@@ -685,12 +685,12 @@ module Wice
|
|
685
685
|
first = collection.offset_value + 1
|
686
686
|
last = collection.last_page? ? collection.total_count : collection.offset_value + collection.limit_value
|
687
687
|
|
688
|
-
|
688
|
+
total_pages = collection.total_pages
|
689
689
|
end
|
690
690
|
|
691
691
|
parameters = grid.get_state_as_parameter_value_pairs
|
692
692
|
|
693
|
-
if
|
693
|
+
if total_pages < 2 && collection.length == 0
|
694
694
|
'0'
|
695
695
|
else
|
696
696
|
parameters << ["#{grid.name}[pp]", collection_total_entries]
|
@@ -40,10 +40,12 @@ module Wice
|
|
40
40
|
# * <tt>:enable_export_to_csv</tt> - <Enable export of the table to CSV. Read the How-To to learn what else is needed to enable CSV export.
|
41
41
|
# * <tt>:csv_file_name</tt> - Name of the exported CSV file. If the parameter is missing, the name of the grid will be used instead.
|
42
42
|
# * <tt>:csv_field_separator</tt> - field separator for CSV files. The default is defined in +CSV_FIELD_SEPARATOR+ in the config file.
|
43
|
-
# * <tt>:custom_order</tt> - used for overriding the ORDER BY clause with custom sql code (for example,
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
43
|
+
# * <tt>:custom_order</tt> - used for overriding the ORDER BY clause with custom sql code (for example, using an SQL
|
44
|
+
# function). A Hash with keys of the fully qualified names of database columns and with values that specify the
|
45
|
+
# ordering to be used, without specifying the direction (no ASC or DESC). The values of this Hash can any String
|
46
|
+
# of SQL that can be passed to the ActiveRecord order clause, an instance of Arel::Attributes::Attribute, or a
|
47
|
+
# Proc that receives the fully qualified column name and returns a String or Arel::Attributes::Attribute. See
|
48
|
+
# section 'Custom Ordering' in the README.
|
47
49
|
# * <tt>:saved_query</tt> - id of the saved query or the query object itself to load initially.
|
48
50
|
# Read section "Saving Queries How-To" in README for more details.
|
49
51
|
# * <tt>:after</tt> - defined a name of a controller method which would be called by the grid after all user input has been processed,
|
@@ -179,7 +181,7 @@ module Wice
|
|
179
181
|
@performed_render = false
|
180
182
|
|
181
183
|
logger.info "Sending file #{path}" unless logger.nil?
|
182
|
-
File.open(path, 'rb') { |file| render status: options[:status],
|
184
|
+
File.open(path, 'rb') { |file| render status: options[:status], plain: file.read }
|
183
185
|
end
|
184
186
|
|
185
187
|
DEFAULT_SEND_FILE_OPTIONS_RAILS2 = { #:nodoc:
|
@@ -113,7 +113,11 @@ module ActionView #:nodoc:
|
|
113
113
|
module Helpers #:nodoc:
|
114
114
|
module TagHelper #:nodoc:
|
115
115
|
def public_tag_options(options, escape = true) #:nodoc:
|
116
|
-
tag_options
|
116
|
+
if respond_to?(:tag_options, true)
|
117
|
+
tag_options(options, escape)
|
118
|
+
else
|
119
|
+
tag_builder.tag_options(options, escape)
|
120
|
+
end
|
117
121
|
end
|
118
122
|
end
|
119
123
|
end
|
data/lib/wice/wice_grid_misc.rb
CHANGED
data/lib/wice_grid.rb
CHANGED
@@ -95,7 +95,7 @@ module Wice
|
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
|
-
opts[:order_direction].downcase
|
98
|
+
opts[:order_direction] = opts[:order_direction].downcase if opts[:order_direction].is_a?(String)
|
99
99
|
|
100
100
|
# validate :order_direction
|
101
101
|
if opts[:order_direction] && ! (opts[:order_direction] == 'asc' || opts[:order_direction] == :asc || opts[:order_direction] == 'desc' ||
|
@@ -228,7 +228,8 @@ module Wice
|
|
228
228
|
custom_filter_active: nil,
|
229
229
|
table_alias: nil,
|
230
230
|
filter_type: nil,
|
231
|
-
assocs: []
|
231
|
+
assocs: [],
|
232
|
+
sort_by: nil) #:nodoc:
|
232
233
|
|
233
234
|
|
234
235
|
@options[:include] = Wice.build_includes(@options[:include], assocs)
|
@@ -240,7 +241,8 @@ module Wice
|
|
240
241
|
table_name = model.table_name
|
241
242
|
else
|
242
243
|
column = @table_column_matrix.get_column_in_default_model_class_by_column_name(column_name)
|
243
|
-
if
|
244
|
+
# Allow the column to not exist if we're doing a custom sort (calculated field)
|
245
|
+
if column.nil? && !sort_by
|
244
246
|
raise WiceGridArgumentError.new("Column '#{column_name}' is not found in table '#{@klass.table_name}'! " \
|
245
247
|
"If '#{column_name}' belongs to another table you should declare it in :include or :join when initialising " \
|
246
248
|
'the grid, and specify :model in column declaration.')
|
@@ -296,9 +298,21 @@ module Wice
|
|
296
298
|
# conditions processed
|
297
299
|
|
298
300
|
if (!opts[:skip_ordering]) && ! @status[:order].blank?
|
299
|
-
|
300
|
-
|
301
|
-
|
301
|
+
custom_order = get_custom_order_reference
|
302
|
+
if custom_order
|
303
|
+
@ar_options[:order] = custom_order
|
304
|
+
else
|
305
|
+
@ar_options[:order] = arel_column_reference(@status[:order])
|
306
|
+
end
|
307
|
+
if @ar_options[:order].is_a?(Arel::Attributes::Attribute)
|
308
|
+
if @status[:order_direction] == 'desc'
|
309
|
+
@ar_options[:order] = @ar_options[:order].desc
|
310
|
+
else
|
311
|
+
@ar_options[:order] = @ar_options[:order].asc
|
312
|
+
end
|
313
|
+
else
|
314
|
+
@ar_options[:order] += " #{@status[:order_direction]}"
|
315
|
+
end
|
302
316
|
end
|
303
317
|
|
304
318
|
@ar_options[:joins] = @options[:joins]
|
@@ -326,36 +340,49 @@ module Wice
|
|
326
340
|
relation
|
327
341
|
end
|
328
342
|
|
343
|
+
# Apply the sort_by option to the results.
|
344
|
+
def apply_sort_by(relation)
|
345
|
+
active_sort_by = nil
|
346
|
+
@renderer.find_one_for(->(c) {c.attribute == @status[:order]}) {|r| active_sort_by = r.sort_by}
|
347
|
+
return relation if !active_sort_by
|
348
|
+
relation = relation.sort_by(&active_sort_by)
|
349
|
+
relation = relation.reverse if @status[:order_direction] == 'desc'
|
350
|
+
return relation
|
351
|
+
end
|
352
|
+
|
329
353
|
# TO DO: what to do with other @ar_options values?
|
330
354
|
def read #:nodoc:
|
331
355
|
form_ar_options
|
332
356
|
use_default_or_unscoped do
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
relation
|
357
|
+
relation = @relation
|
358
|
+
.includes(@ar_options[:include])
|
359
|
+
.joins(@ar_options[:joins])
|
360
|
+
.group(@ar_options[:group])
|
361
|
+
.merge(@ar_options[:conditions])
|
362
|
+
relation = add_references relation
|
363
|
+
relation = apply_sort_by relation
|
364
|
+
|
365
|
+
# If relation is an Array, it got the sort from apply_sort_by.
|
366
|
+
relation = relation.order(@ar_options[:order]) if !relation.is_a?(Array)
|
367
|
+
|
368
|
+
if !output_csv? && !all_record_mode?
|
369
|
+
if relation.is_a?(Array)
|
370
|
+
relation = Kaminari.paginate_array(relation, limit: @ar_options[:per_page], offset: @ar_options[:per_page].to_i * (@ar_options[:page].to_i - 1))
|
371
|
+
else
|
372
|
+
relation = relation
|
373
|
+
.send(@options[:page_method_name], @ar_options[:page])
|
374
|
+
.per(@ar_options[:per_page])
|
375
|
+
end
|
376
|
+
end
|
377
|
+
|
378
|
+
if all_record_mode? && relation.is_a?(Array)
|
379
|
+
# This still needs to be a Kaminari object as the paginator will read limit_value.
|
380
|
+
relation = Kaminari.paginate_array(relation, limit: relation.count)
|
357
381
|
end
|
382
|
+
|
383
|
+
@resultset = relation
|
358
384
|
end
|
385
|
+
|
359
386
|
invoke_resultset_callbacks
|
360
387
|
end
|
361
388
|
|
@@ -384,9 +411,10 @@ module Wice
|
|
384
411
|
end
|
385
412
|
end
|
386
413
|
|
387
|
-
|
414
|
+
# Returns true if the current results are ordered by the passed column.
|
415
|
+
def ordered_by?(column)
|
388
416
|
return nil if @status[:order].blank?
|
389
|
-
if column.main_table && ! @status[:order].index('.')
|
417
|
+
if column.main_table && ! @status[:order].index('.') || column.table_alias_or_table_name.nil?
|
390
418
|
@status[:order] == column.attribute
|
391
419
|
else
|
392
420
|
@status[:order] == column.table_alias_or_table_name + '.' + column.attribute
|
@@ -449,11 +477,11 @@ module Wice
|
|
449
477
|
def do_count #:nodoc:
|
450
478
|
@relation
|
451
479
|
.all
|
452
|
-
.
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
480
|
+
.joins(@ar_options[:joins])
|
481
|
+
.includes(@ar_options[:include])
|
482
|
+
.group(@ar_options[:group])
|
483
|
+
.where(@options[:conditions])
|
484
|
+
.count
|
457
485
|
end
|
458
486
|
|
459
487
|
alias_method :size, :count
|
@@ -533,7 +561,11 @@ module Wice
|
|
533
561
|
invoke_resultset_callback(@options[:with_resultset], self.active_relation_for_resultset_without_paging_with_user_filters)
|
534
562
|
end
|
535
563
|
|
536
|
-
|
564
|
+
# If a custom order has been configured, gets the column/function to be ordered by. If no custom order, returns nil.
|
565
|
+
def get_custom_order_reference
|
566
|
+
# TODO Do we need to distinguish between no custom order and a custom order that defines no ordering? Both return nil.
|
567
|
+
|
568
|
+
fully_qualified_column_name = complete_column_name(@status[:order])
|
537
569
|
custom_order = if @options[:custom_order].key?(fully_qualified_column_name)
|
538
570
|
@options[:custom_order][fully_qualified_column_name]
|
539
571
|
else
|
@@ -542,39 +574,34 @@ module Wice
|
|
542
574
|
end
|
543
575
|
end
|
544
576
|
|
545
|
-
if custom_order.
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
fully_qualified_column_name.strip.split('.').map { |chunk| ActiveRecord::Base.connection.quote_table_name(chunk) }.join('.')
|
550
|
-
else
|
551
|
-
ActiveRecord::Base.connection.quote_table_name(fully_qualified_column_name.strip)
|
552
|
-
end
|
553
|
-
else
|
554
|
-
if custom_order.is_a? String
|
555
|
-
custom_order.gsub(/\?/, fully_qualified_column_name)
|
556
|
-
elsif custom_order.is_a? Proc
|
557
|
-
custom_order.call(fully_qualified_column_name)
|
558
|
-
else
|
559
|
-
raise WiceGridArgumentError.new("invalid custom order #{custom_order.inspect}")
|
560
|
-
end
|
561
|
-
end
|
577
|
+
return custom_order if custom_order.nil? || custom_order.is_a?(Arel::Attributes::Attribute)
|
578
|
+
return custom_order.gsub(/\?/, fully_qualified_column_name) if custom_order.is_a?(String)
|
579
|
+
return custom_order.call(fully_qualified_column_name) if custom_order.is_a?(Proc)
|
580
|
+
raise WiceGridArgumentError.new("invalid custom order #{custom_order.inspect}")
|
562
581
|
end
|
563
582
|
|
564
|
-
|
583
|
+
# Returns an Arel::Attributes::Attribute for the passed column reference.
|
584
|
+
def arel_column_reference(col_name) #:nodoc:
|
565
585
|
if col_name.index('.') # already has a table name
|
566
|
-
col_name
|
586
|
+
table_name, col_name = col_name.split('.', 2)
|
587
|
+
Arel::Table.new(table_name)[col_name]
|
567
588
|
else # add the default table
|
568
|
-
|
589
|
+
@klass.arel_table[col_name]
|
569
590
|
end
|
570
591
|
end
|
571
592
|
|
593
|
+
# Returns tablename.columnname for the passed column reference.
|
594
|
+
def complete_column_name(col_name)
|
595
|
+
return col_name if col_name.index('.') # already has a table name
|
596
|
+
return "#{@klass.table_name}.#{col_name}"
|
597
|
+
end
|
598
|
+
|
572
599
|
def params #:nodoc:
|
573
600
|
@controller.params
|
574
601
|
end
|
575
602
|
|
576
603
|
def this_grid_params #:nodoc:
|
577
|
-
params[name]
|
604
|
+
params[name].try(:to_unsafe_h) || params[name]
|
578
605
|
end
|
579
606
|
|
580
607
|
def resultset_without_paging_without_user_filters #:nodoc:
|