active_scaffold 3.4.43 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG +39 -0
- data/{LICENSE → LICENSE.md} +1 -1
- data/README.md +27 -19
- data/app/assets/javascripts/active_scaffold.js.erb +1 -1
- data/app/assets/javascripts/jquery/active_scaffold.js +95 -43
- data/app/assets/javascripts/jquery/tiny_mce_bridge.js +30 -6
- data/app/assets/javascripts/prototype/tiny_mce_bridge.js +11 -1
- data/app/assets/stylesheets/active_scaffold_colors.scss +2 -2
- data/app/assets/stylesheets/active_scaffold_layout.css +36 -28
- data/app/views/active_scaffold_overrides/_base_form.html.erb +2 -3
- data/app/views/active_scaffold_overrides/_field_search.html.erb +8 -7
- data/app/views/active_scaffold_overrides/_form_association.html.erb +9 -9
- data/app/views/active_scaffold_overrides/_form_association_footer.html.erb +6 -6
- data/app/views/active_scaffold_overrides/_form_association_record.html.erb +52 -50
- data/app/views/active_scaffold_overrides/_horizontal_subform.html.erb +1 -1
- data/app/views/active_scaffold_overrides/_horizontal_subform_header.html.erb +1 -1
- data/app/views/active_scaffold_overrides/_human_conditions.html.erb +3 -1
- data/app/views/active_scaffold_overrides/_list_calculations.html.erb +1 -1
- data/app/views/active_scaffold_overrides/_list_column_headings.html.erb +2 -0
- data/app/views/active_scaffold_overrides/_list_messages.html.erb +5 -3
- data/app/views/active_scaffold_overrides/_list_record.html.erb +3 -1
- data/app/views/active_scaffold_overrides/_list_with_header.html.erb +9 -9
- data/app/views/active_scaffold_overrides/_messages.html.erb +1 -1
- data/app/views/active_scaffold_overrides/_refresh_list.js.erb +18 -10
- data/app/views/active_scaffold_overrides/_render_field.js.erb +3 -3
- data/app/views/active_scaffold_overrides/_search.html.erb +7 -6
- data/app/views/active_scaffold_overrides/_show_actions.html.erb +14 -0
- data/app/views/active_scaffold_overrides/_show_association.html.erb +1 -1
- data/app/views/active_scaffold_overrides/_update_actions.html.erb +6 -2
- data/app/views/active_scaffold_overrides/_update_column.js.erb +1 -1
- data/app/views/active_scaffold_overrides/_update_form.html.erb +1 -1
- data/app/views/active_scaffold_overrides/destroy.js.erb +2 -3
- data/app/views/active_scaffold_overrides/edit_associated.js.erb +4 -3
- data/app/views/active_scaffold_overrides/on_action_update.js.erb +5 -3
- data/app/views/active_scaffold_overrides/on_create.js.erb +4 -4
- data/app/views/active_scaffold_overrides/on_update.js.erb +6 -6
- data/app/views/active_scaffold_overrides/show.html.erb +6 -0
- data/app/views/active_scaffold_overrides/update.html.erb +1 -1
- data/app/views/active_scaffold_overrides/update_column.js.erb +1 -1
- data/config/brakeman.ignore +26 -0
- data/config/brakeman.yml +3 -0
- data/config/i18n-tasks.yml +121 -0
- data/config/locales/de.yml +81 -70
- data/config/locales/en.yml +83 -74
- data/config/locales/es.yml +82 -73
- data/config/locales/fr.yml +86 -75
- data/config/locales/hu.yml +81 -70
- data/config/locales/ja.yml +71 -60
- data/config/locales/ru.yml +85 -74
- data/lib/active_scaffold.rb +3 -0
- data/lib/active_scaffold/actions/common_search.rb +11 -7
- data/lib/active_scaffold/actions/core.rb +119 -47
- data/lib/active_scaffold/actions/create.rb +1 -1
- data/lib/active_scaffold/actions/delete.rb +11 -8
- data/lib/active_scaffold/actions/field_search.rb +104 -6
- data/lib/active_scaffold/actions/list.rb +25 -21
- data/lib/active_scaffold/actions/mark.rb +12 -4
- data/lib/active_scaffold/actions/nested.rb +26 -26
- data/lib/active_scaffold/actions/search.rb +2 -2
- data/lib/active_scaffold/actions/show.rb +4 -5
- data/lib/active_scaffold/actions/subform.rb +9 -7
- data/lib/active_scaffold/actions/update.rb +20 -13
- data/lib/active_scaffold/active_record_permissions.rb +24 -5
- data/lib/active_scaffold/attribute_params.rb +68 -49
- data/lib/active_scaffold/bridges.rb +1 -1
- data/lib/active_scaffold/bridges/ancestry/ancestry_bridge.rb +15 -19
- data/lib/active_scaffold/bridges/bitfields.rb +1 -1
- data/lib/active_scaffold/bridges/bitfields/bitfields_bridge.rb +10 -14
- data/lib/active_scaffold/bridges/calendar_date_select.rb +0 -7
- data/lib/active_scaffold/bridges/calendar_date_select/as_cds_bridge.rb +19 -22
- data/lib/active_scaffold/bridges/cancan.rb +4 -3
- data/lib/active_scaffold/bridges/cancan/cancan_bridge.rb +11 -21
- data/lib/active_scaffold/bridges/carrierwave.rb +2 -1
- data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge.rb +2 -6
- data/lib/active_scaffold/bridges/carrierwave/form_ui.rb +6 -39
- data/lib/active_scaffold/bridges/carrierwave/list_ui.rb +1 -1
- data/lib/active_scaffold/bridges/chosen.rb +4 -1
- data/lib/active_scaffold/bridges/chosen/helpers.rb +3 -2
- data/lib/active_scaffold/bridges/country_select/country_select_bridge_helper.rb +2 -2
- data/lib/active_scaffold/bridges/date_picker.rb +3 -0
- data/lib/active_scaffold/bridges/date_picker/ext.rb +43 -38
- data/lib/active_scaffold/bridges/date_picker/helper.rb +24 -23
- data/lib/active_scaffold/bridges/dragonfly.rb +1 -1
- data/lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb +3 -7
- data/lib/active_scaffold/bridges/dragonfly/form_ui.rb +3 -25
- data/lib/active_scaffold/bridges/dragonfly/list_ui.rb +2 -2
- data/lib/active_scaffold/bridges/file_column/as_file_column_bridge.rb +6 -8
- data/lib/active_scaffold/bridges/file_column/file_column_helpers.rb +1 -1
- data/lib/active_scaffold/bridges/file_column/form_ui.rb +0 -2
- data/lib/active_scaffold/bridges/file_column/list_ui.rb +2 -1
- data/lib/active_scaffold/bridges/file_column/test/test_helper.rb +1 -1
- data/lib/active_scaffold/bridges/paper_trail/actions.rb +1 -1
- data/lib/active_scaffold/bridges/paper_trail/helper.rb +1 -2
- data/lib/active_scaffold/bridges/paper_trail/paper_trail_bridge.rb +3 -7
- data/lib/active_scaffold/bridges/paperclip.rb +1 -1
- data/lib/active_scaffold/bridges/paperclip/form_ui.rb +3 -28
- data/lib/active_scaffold/bridges/paperclip/list_ui.rb +1 -1
- data/lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb +3 -7
- data/lib/active_scaffold/bridges/record_select.rb +2 -0
- data/lib/active_scaffold/bridges/record_select/helpers.rb +14 -18
- data/lib/active_scaffold/bridges/semantic_attributes/column.rb +4 -8
- data/lib/active_scaffold/bridges/shared/date_bridge.rb +20 -20
- data/lib/active_scaffold/bridges/tiny_mce/helpers.rb +7 -22
- data/lib/active_scaffold/bridges/usa_state_select/usa_state_select_helper.rb +14 -14
- data/lib/active_scaffold/config/base.rb +9 -6
- data/lib/active_scaffold/config/core.rb +30 -21
- data/lib/active_scaffold/config/create.rb +2 -1
- data/lib/active_scaffold/config/delete.rb +2 -2
- data/lib/active_scaffold/config/field_search.rb +9 -3
- data/lib/active_scaffold/config/form.rb +4 -4
- data/lib/active_scaffold/config/list.rb +27 -23
- data/lib/active_scaffold/config/nested.rb +4 -4
- data/lib/active_scaffold/config/search.rb +6 -6
- data/lib/active_scaffold/config/show.rb +11 -1
- data/lib/active_scaffold/config/subform.rb +1 -1
- data/lib/active_scaffold/config/update.rb +4 -2
- data/lib/active_scaffold/constraints.rb +39 -36
- data/lib/active_scaffold/core.rb +36 -15
- data/lib/active_scaffold/data_structures/action_columns.rb +14 -9
- data/lib/active_scaffold/data_structures/action_link.rb +4 -5
- data/lib/active_scaffold/data_structures/action_links.rb +5 -4
- data/lib/active_scaffold/data_structures/actions.rb +2 -2
- data/lib/active_scaffold/data_structures/association.rb +8 -0
- data/lib/active_scaffold/data_structures/association/abstract.rb +147 -0
- data/lib/active_scaffold/data_structures/association/active_mongoid.rb +42 -0
- data/lib/active_scaffold/data_structures/association/active_record.rb +94 -0
- data/lib/active_scaffold/data_structures/association/mongoid.rb +45 -0
- data/lib/active_scaffold/data_structures/bridge.rb +3 -6
- data/lib/active_scaffold/data_structures/column.rb +100 -82
- data/lib/active_scaffold/data_structures/columns.rb +21 -3
- data/lib/active_scaffold/data_structures/nested_info.rb +22 -37
- data/lib/active_scaffold/data_structures/set.rb +4 -4
- data/lib/active_scaffold/data_structures/sorting.rb +29 -15
- data/lib/active_scaffold/engine.rb +3 -1
- data/lib/active_scaffold/extensions/action_controller_rendering.rb +10 -5
- data/lib/active_scaffold/extensions/action_view_rendering.rb +65 -59
- data/lib/active_scaffold/extensions/left_outer_joins.rb +48 -53
- data/lib/active_scaffold/extensions/localize.rb +3 -4
- data/lib/active_scaffold/extensions/name_option_for_datetime.rb +7 -11
- data/lib/active_scaffold/extensions/paginator_extensions.rb +20 -18
- data/lib/active_scaffold/extensions/routing_mapper.rb +104 -40
- data/lib/active_scaffold/extensions/to_label.rb +1 -1
- data/lib/active_scaffold/extensions/unsaved_associated.rb +4 -13
- data/lib/active_scaffold/extensions/unsaved_record.rb +12 -1
- data/lib/active_scaffold/finder.rb +200 -134
- data/lib/active_scaffold/helpers/action_link_helpers.rb +398 -0
- data/lib/active_scaffold/helpers/association_helpers.rb +12 -30
- data/lib/active_scaffold/helpers/controller_helpers.rb +74 -24
- data/lib/active_scaffold/helpers/form_column_helpers.rb +205 -112
- data/lib/active_scaffold/helpers/human_condition_helpers.rb +21 -11
- data/lib/active_scaffold/helpers/id_helpers.rb +1 -1
- data/lib/active_scaffold/helpers/list_column_helpers.rb +117 -39
- data/lib/active_scaffold/helpers/pagination_helpers.rb +11 -14
- data/lib/active_scaffold/helpers/search_column_helpers.rb +69 -32
- data/lib/active_scaffold/helpers/show_column_helpers.rb +9 -3
- data/lib/active_scaffold/helpers/view_helpers.rb +41 -426
- data/lib/active_scaffold/orm_checks.rb +109 -0
- data/lib/active_scaffold/paginator.rb +1 -1
- data/lib/active_scaffold/responds_to_parent.rb +12 -10
- data/lib/active_scaffold/tableless.rb +81 -43
- data/lib/active_scaffold/version.rb +2 -2
- data/lib/generators/active_scaffold/controller_generator.rb +49 -0
- data/lib/generators/active_scaffold/install_generator.rb +45 -0
- data/lib/generators/active_scaffold/resource_generator.rb +56 -0
- data/lib/generators/{active_scaffold_controller/templates → templates}/controller.rb +0 -0
- data/lib/generators/{active_scaffold_controller/templates → templates}/helper.rb +0 -0
- data/shoulda_macros/macros.rb +3 -3
- data/test/active_scaffold_config_mock.rb +33 -0
- data/test/bridges/bridge_test.rb +9 -9
- data/test/bridges/date_picker_test.rb +3 -1
- data/test/bridges/paper_trail_test.rb +2 -3
- data/test/bridges/paperclip_test.rb +21 -10
- data/test/bridges/tiny_mce_test.rb +20 -21
- data/test/class_with_finder.rb +42 -0
- data/test/company.rb +6 -4
- data/test/config/core_test.rb +1 -1
- data/test/config/create_test.rb +1 -1
- data/test/config/list_test.rb +3 -3
- data/test/config/update_test.rb +3 -3
- data/test/data_structures/action_columns_test.rb +3 -3
- data/test/data_structures/association_column_test.rb +5 -5
- data/test/data_structures/column_test.rb +14 -14
- data/test/data_structures/columns_test.rb +2 -2
- data/test/data_structures/set_test.rb +2 -2
- data/test/data_structures/sorting_test.rb +6 -4
- data/test/extensions/active_record_test.rb +1 -1
- data/test/extensions/routing_mapper_test.rb +64 -13
- data/test/helpers/form_column_helpers_test.rb +6 -6
- data/test/helpers/list_column_helpers_test.rb +9 -5
- data/test/helpers/pagination_helpers_test.rb +1 -0
- data/test/misc/active_record_permissions_test.rb +18 -1
- data/test/misc/attribute_params_test.rb +26 -17
- data/test/misc/calculation_test.rb +8 -31
- data/test/misc/configurable_test.rb +3 -2
- data/test/misc/constraints_test.rb +33 -22
- data/test/misc/convert_numbers_format_test.rb +28 -10
- data/test/misc/finder_test.rb +6 -29
- data/test/misc/parse_datetime_test.rb +160 -0
- data/test/misc/render_test.rb +1 -1
- data/test/misc/tableless_test.rb +24 -0
- data/test/mock_app/app/models/building.rb +2 -1
- data/test/mock_app/config.ru +1 -1
- data/test/mock_app/config/environments/test.rb +1 -1
- data/test/mock_app/config/routes.rb +11 -3
- data/test/model_stub.rb +11 -6
- data/test/run_all.rb +1 -1
- data/test/test_helper.rb +19 -4
- metadata +42 -23
- data/lib/active_scaffold/data_structures/error_message.rb +0 -22
- data/lib/active_scaffold/extensions/reverse_associations.rb +0 -119
- data/lib/generators/active_scaffold/USAGE +0 -29
- data/lib/generators/active_scaffold/active_scaffold_generator.rb +0 -21
- data/lib/generators/active_scaffold_controller/USAGE +0 -19
- data/lib/generators/active_scaffold_controller/active_scaffold_controller_generator.rb +0 -29
- data/test/data_structures/error_message_test.rb +0 -25
| @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            module ActiveScaffold::Actions
         | 
| 2 2 | 
             
              module Delete
         | 
| 3 3 | 
             
                def self.included(base)
         | 
| 4 | 
            -
                  base. | 
| 4 | 
            +
                  base.before_action :delete_authorized_filter, :only => [:destroy]
         | 
| 5 5 | 
             
                end
         | 
| 6 6 |  | 
| 7 7 | 
             
                def destroy
         | 
| @@ -14,7 +14,7 @@ module ActiveScaffold::Actions | |
| 14 14 | 
             
                protected
         | 
| 15 15 |  | 
| 16 16 | 
             
                def destroy_respond_to_html
         | 
| 17 | 
            -
                  flash[:info] = as_(:deleted_model, :model => ERB::Util.h(@record.to_label)) if  | 
| 17 | 
            +
                  flash[:info] = as_(:deleted_model, :model => ERB::Util.h(@record.to_label)) if successful?
         | 
| 18 18 | 
             
                  return_to_main
         | 
| 19 19 | 
             
                end
         | 
| 20 20 |  | 
| @@ -41,29 +41,32 @@ module ActiveScaffold::Actions | |
| 41 41 | 
             
                  record ||= destroy_find_record
         | 
| 42 42 | 
             
                  begin
         | 
| 43 43 | 
             
                    self.successful = record.destroy
         | 
| 44 | 
            -
                  rescue StandardError =>  | 
| 44 | 
            +
                  rescue StandardError => exception
         | 
| 45 45 | 
             
                    flash[:warning] = as_(:cant_destroy_record, :record => ERB::Util.h(record.to_label))
         | 
| 46 46 | 
             
                    self.successful = false
         | 
| 47 | 
            -
                    logger. | 
| 48 | 
            -
             | 
| 47 | 
            +
                    logger.warn do
         | 
| 48 | 
            +
                      "\n\n#{exception.class} (#{exception.message}):\n    " +
         | 
| 49 | 
            +
                        Rails.backtrace_cleaner.clean(exception.backtrace).join("\n    ") +
         | 
| 50 | 
            +
                        "\n\n"
         | 
| 51 | 
            +
                    end
         | 
| 49 52 | 
             
                  end
         | 
| 50 53 | 
             
                end
         | 
| 51 54 |  | 
| 52 55 | 
             
                # The default security delegates to ActiveRecordPermissions.
         | 
| 53 56 | 
             
                # You may override the method to customize.
         | 
| 54 57 | 
             
                def delete_authorized?(record = nil)
         | 
| 55 | 
            -
                  (!nested? || !nested.readonly?) && (record || self).authorized_for?(: | 
| 58 | 
            +
                  (!nested? || !nested.readonly?) && (record || self).authorized_for?(crud_type: :delete, reason: true)
         | 
| 56 59 | 
             
                end
         | 
| 57 60 |  | 
| 58 61 | 
             
                def delete_ignore?(record = nil)
         | 
| 59 | 
            -
                  (nested? && nested.readonly?) || ! | 
| 62 | 
            +
                  (nested? && nested.readonly?) || !authorized_for?(:crud_type => :delete)
         | 
| 60 63 | 
             
                end
         | 
| 61 64 |  | 
| 62 65 | 
             
                private
         | 
| 63 66 |  | 
| 64 67 | 
             
                def delete_authorized_filter
         | 
| 65 68 | 
             
                  link = active_scaffold_config.delete.link || active_scaffold_config.delete.class.link
         | 
| 66 | 
            -
                  raise ActiveScaffold::ActionNotAllowed unless send(link.security_method)
         | 
| 69 | 
            +
                  raise ActiveScaffold::ActionNotAllowed unless Array(send(link.security_method))[0]
         | 
| 67 70 | 
             
                end
         | 
| 68 71 |  | 
| 69 72 | 
             
                def destroy_formats
         | 
| @@ -1,9 +1,11 @@ | |
| 1 1 | 
             
            module ActiveScaffold::Actions
         | 
| 2 2 | 
             
              module FieldSearch
         | 
| 3 3 | 
             
                def self.included(base)
         | 
| 4 | 
            -
                  base. | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 4 | 
            +
                  base.class_eval do
         | 
| 5 | 
            +
                    helper_method :field_search_params, :grouped_search?, :search_group_column, :search_group_function
         | 
| 6 | 
            +
                    include ActiveScaffold::Actions::CommonSearch
         | 
| 7 | 
            +
                    include InstanceMethods
         | 
| 8 | 
            +
                  end
         | 
| 7 9 | 
             
                end
         | 
| 8 10 |  | 
| 9 11 | 
             
                module InstanceMethods
         | 
| @@ -30,6 +32,102 @@ module ActiveScaffold::Actions | |
| 30 32 | 
             
                    params[:search] = default_params.is_a?(Proc) ? instance_eval(&default_params) : default_params
         | 
| 31 33 | 
             
                  end
         | 
| 32 34 |  | 
| 35 | 
            +
                  def grouped_search?
         | 
| 36 | 
            +
                    field_search_params.present? && field_search_params['active_scaffold_group'].present?
         | 
| 37 | 
            +
                  end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                  def setup_search_group
         | 
| 40 | 
            +
                    @_search_group_name, @_search_group_function = field_search_params['active_scaffold_group'].to_s.split('#')
         | 
| 41 | 
            +
                  end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                  def search_group_function
         | 
| 44 | 
            +
                    setup_search_group unless defined? @_search_group_function
         | 
| 45 | 
            +
                    @_search_group_function
         | 
| 46 | 
            +
                  end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                  def search_group_name
         | 
| 49 | 
            +
                    setup_search_group unless defined? @_search_group_name
         | 
| 50 | 
            +
                    @_search_group_name
         | 
| 51 | 
            +
                  end
         | 
| 52 | 
            +
             | 
| 53 | 
            +
                  def search_group_column
         | 
| 54 | 
            +
                    active_scaffold_config.columns[search_group_name] if search_group_name
         | 
| 55 | 
            +
                  end
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                  def custom_finder_options
         | 
| 58 | 
            +
                    if grouped_search?
         | 
| 59 | 
            +
                      group_sql = calculation_for_group_by(search_group_column.try(:field) || search_group_name)
         | 
| 60 | 
            +
                      group_by = group_sql.respond_to?(:to_sql) ? group_sql.to_sql : group_sql
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                      select_query = quoted_select_columns(search_group_column.try(:select_columns))
         | 
| 63 | 
            +
                      select_query << group_sql.as(search_group_column.name.to_s) if search_group_column && group_sql.respond_to?(:to_sql)
         | 
| 64 | 
            +
                      if active_scaffold_config.model.columns_hash.include?(active_scaffold_config.model.inheritance_column)
         | 
| 65 | 
            +
                        select_query << active_scaffold_config.columns[active_scaffold_config.model.inheritance_column].field
         | 
| 66 | 
            +
                      end
         | 
| 67 | 
            +
                      grouped_columns_calculations.each do |name, part|
         | 
| 68 | 
            +
                        select_query << (part.respond_to?(:as) ? part : Arel::Nodes::SqlLiteral.new(part)).as(name.to_s)
         | 
| 69 | 
            +
                      end
         | 
| 70 | 
            +
             | 
| 71 | 
            +
                      {group: group_by, select: select_query}
         | 
| 72 | 
            +
                    else
         | 
| 73 | 
            +
                      super
         | 
| 74 | 
            +
                    end
         | 
| 75 | 
            +
                  end
         | 
| 76 | 
            +
             | 
| 77 | 
            +
                  def grouped_columns_calculations
         | 
| 78 | 
            +
                    @grouped_columns_calculations ||= list_columns[1..-1].each_with_object({}) do |c, h|
         | 
| 79 | 
            +
                      h[c.name] = calculation_for_group_search(c)
         | 
| 80 | 
            +
                    end
         | 
| 81 | 
            +
                  end
         | 
| 82 | 
            +
             | 
| 83 | 
            +
                  def calculation_for_group_search(column)
         | 
| 84 | 
            +
                    sql_function column.calculate.to_s, column.active_record_class.arel_table[column.name]
         | 
| 85 | 
            +
                  end
         | 
| 86 | 
            +
             | 
| 87 | 
            +
                  def calculation_for_group_by(group_sql)
         | 
| 88 | 
            +
                    return group_sql unless search_group_function
         | 
| 89 | 
            +
                    group_sql = Arel::Nodes::SqlLiteral.new(group_sql)
         | 
| 90 | 
            +
                    case search_group_function
         | 
| 91 | 
            +
                    when 'year', 'month', 'quarter'
         | 
| 92 | 
            +
                      sql_function(search_group_function, group_sql)
         | 
| 93 | 
            +
                    when 'year_month'
         | 
| 94 | 
            +
                      sql_function('extract', sql_operator(Arel::Nodes::SqlLiteral.new('YEAR_MONTH'), 'FROM', group_sql))
         | 
| 95 | 
            +
                    when 'year_quarter'
         | 
| 96 | 
            +
                      sql_operator(sql_operator(sql_function('year', group_sql), '*', 10), '+', sql_function('quarter', group_sql))
         | 
| 97 | 
            +
                    else
         | 
| 98 | 
            +
                      raise "#{search_group_function} unsupported, override calculation_for_group_by in #{self.class.name}"
         | 
| 99 | 
            +
                    end
         | 
| 100 | 
            +
                  end
         | 
| 101 | 
            +
             | 
| 102 | 
            +
                  def sql_function(function, *args)
         | 
| 103 | 
            +
                    args.map! { |arg| quoted_arel_value(arg) }
         | 
| 104 | 
            +
                    Arel::Nodes::NamedFunction.new(function, args)
         | 
| 105 | 
            +
                  end
         | 
| 106 | 
            +
             | 
| 107 | 
            +
                  def sql_operator(arg1, operator, arg2)
         | 
| 108 | 
            +
                    Arel::Nodes::InfixOperation.new(operator, quoted_arel_value(arg1), quoted_arel_value(arg2))
         | 
| 109 | 
            +
                  end
         | 
| 110 | 
            +
             | 
| 111 | 
            +
                  def quoted_arel_value(value)
         | 
| 112 | 
            +
                    value.is_a?(Arel::Predications) ? value : Arel::Nodes::Quoted.new(value)
         | 
| 113 | 
            +
                  end
         | 
| 114 | 
            +
             | 
| 115 | 
            +
                  def list_columns
         | 
| 116 | 
            +
                    @list_columns ||= if grouped_search?
         | 
| 117 | 
            +
                                        columns = grouped_columns || super.select(&:calculation?)
         | 
| 118 | 
            +
                                        [search_group_column || search_group_name].concat columns
         | 
| 119 | 
            +
                    else
         | 
| 120 | 
            +
                      super
         | 
| 121 | 
            +
                    end
         | 
| 122 | 
            +
                  end
         | 
| 123 | 
            +
             | 
| 124 | 
            +
                  def grouped_columns
         | 
| 125 | 
            +
                    return if active_scaffold_config.field_search.grouped_columns.blank?
         | 
| 126 | 
            +
                    active_scaffold_config.field_search.grouped_columns.map do |col|
         | 
| 127 | 
            +
                      active_scaffold_config.columns[col]
         | 
| 128 | 
            +
                    end.compact
         | 
| 129 | 
            +
                  end
         | 
| 130 | 
            +
             | 
| 33 131 | 
             
                  def field_search_params
         | 
| 34 132 | 
             
                    search_params.is_a?(Hash) ? search_params : {}
         | 
| 35 133 | 
             
                  end
         | 
| @@ -43,7 +141,7 @@ module ActiveScaffold::Actions | |
| 43 141 | 
             
                  end
         | 
| 44 142 |  | 
| 45 143 | 
             
                  def do_search
         | 
| 46 | 
            -
                    if  | 
| 144 | 
            +
                    if field_search_params.present?
         | 
| 47 145 | 
             
                      filtered_columns = []
         | 
| 48 146 | 
             
                      text_search = active_scaffold_config.field_search.text_search
         | 
| 49 147 | 
             
                      columns = active_scaffold_config.field_search.columns
         | 
| @@ -54,7 +152,7 @@ module ActiveScaffold::Actions | |
| 54 152 | 
             
                        search_condition = self.class.condition_for_column(column, value, text_search)
         | 
| 55 153 | 
             
                        next if search_condition.blank?
         | 
| 56 154 |  | 
| 57 | 
            -
                        if count_includes.nil? && column.includes.present? && list_columns.include?(column)
         | 
| 155 | 
            +
                        if count_includes.nil? && column.includes.present? && list_columns.include?(column) && !grouped_search?
         | 
| 58 156 | 
             
                          active_scaffold_references << column.includes
         | 
| 59 157 | 
             
                        elsif column.search_joins.present?
         | 
| 60 158 | 
             
                          active_scaffold_outer_joins << column.search_joins
         | 
| @@ -62,7 +160,7 @@ module ActiveScaffold::Actions | |
| 62 160 | 
             
                        active_scaffold_conditions << search_condition
         | 
| 63 161 | 
             
                        filtered_columns << column
         | 
| 64 162 | 
             
                      end
         | 
| 65 | 
            -
                       | 
| 163 | 
            +
                      if filtered_columns.present? || grouped_search?
         | 
| 66 164 | 
             
                        @filtered = active_scaffold_config.field_search.human_conditions ? filtered_columns : true
         | 
| 67 165 | 
             
                      end
         | 
| 68 166 |  | 
| @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            module ActiveScaffold::Actions
         | 
| 2 2 | 
             
              module List
         | 
| 3 3 | 
             
                def self.included(base)
         | 
| 4 | 
            -
                  base. | 
| 4 | 
            +
                  base.before_action :list_authorized_filter, :only => :index
         | 
| 5 5 | 
             
                  base.helper_method :list_columns
         | 
| 6 6 | 
             
                end
         | 
| 7 7 |  | 
| @@ -22,7 +22,7 @@ module ActiveScaffold::Actions | |
| 22 22 | 
             
                end
         | 
| 23 23 |  | 
| 24 24 | 
             
                def list
         | 
| 25 | 
            -
                  if %w | 
| 25 | 
            +
                  if %w[index list].include? action_name
         | 
| 26 26 | 
             
                    do_list
         | 
| 27 27 | 
             
                  else
         | 
| 28 28 | 
             
                    do_refresh_list
         | 
| @@ -43,6 +43,7 @@ module ActiveScaffold::Actions | |
| 43 43 | 
             
                    render(:partial => 'list_with_header')
         | 
| 44 44 | 
             
                  else
         | 
| 45 45 | 
             
                    @auto_pagination = params[:auto_pagination]
         | 
| 46 | 
            +
                    @popstate = params.delete(:_popstate)
         | 
| 46 47 | 
             
                    render :partial => 'refresh_list', :formats => [:js]
         | 
| 47 48 | 
             
                  end
         | 
| 48 49 | 
             
                end
         | 
| @@ -73,21 +74,20 @@ module ActiveScaffold::Actions | |
| 73 74 | 
             
                      active_scaffold_config.send(action).columns.collect_visible(:flatten => true)
         | 
| 74 75 | 
             
                    end
         | 
| 75 76 | 
             
                  joins_cols, preload_cols = columns.select { |c| c.includes.present? }.partition do |col|
         | 
| 76 | 
            -
                    includes_need_join?(col, sorting)
         | 
| 77 | 
            +
                    includes_need_join?(col, sorting) && !grouped_search?
         | 
| 77 78 | 
             
                  end
         | 
| 78 79 | 
             
                  active_scaffold_references.concat joins_cols.map(&:includes).flatten.uniq
         | 
| 79 80 | 
             
                  active_scaffold_preload.concat preload_cols.map(&:includes).flatten.uniq
         | 
| 80 | 
            -
                  set_includes_for_sorting(columns, sorting) if  | 
| 81 | 
            +
                  set_includes_for_sorting(columns, sorting) if sorting.sorts_by_sql?
         | 
| 81 82 | 
             
                end
         | 
| 82 83 |  | 
| 83 84 | 
             
                def set_includes_for_sorting(columns, sorting)
         | 
| 84 85 | 
             
                  sorting.each do |col, _|
         | 
| 85 | 
            -
                     | 
| 86 | 
            -
             | 
| 87 | 
            -
             | 
| 88 | 
            -
             | 
| 89 | 
            -
             | 
| 90 | 
            -
                      end
         | 
| 86 | 
            +
                    next unless col.includes.present? && !columns.include?(col)
         | 
| 87 | 
            +
                    if active_scaffold_config.model.connection.needs_order_expressions_in_select?
         | 
| 88 | 
            +
                      active_scaffold_references << col.includes
         | 
| 89 | 
            +
                    else
         | 
| 90 | 
            +
                      active_scaffold_outer_joins << col.includes
         | 
| 91 91 | 
             
                    end
         | 
| 92 92 | 
             
                  end
         | 
| 93 93 | 
             
                end
         | 
| @@ -97,8 +97,8 @@ module ActiveScaffold::Actions | |
| 97 97 | 
             
                end
         | 
| 98 98 |  | 
| 99 99 | 
             
                def scoped_habtm?(column)
         | 
| 100 | 
            -
                  assoc = column.association if column. | 
| 101 | 
            -
                  assoc && assoc. | 
| 100 | 
            +
                  assoc = column.association if column.association.try :collection?
         | 
| 101 | 
            +
                  assoc && assoc.habtm? && assoc.scope
         | 
| 102 102 | 
             
                end
         | 
| 103 103 |  | 
| 104 104 | 
             
                def get_row(crud_type_or_security_options = :read)
         | 
| @@ -108,17 +108,18 @@ module ActiveScaffold::Actions | |
| 108 108 |  | 
| 109 109 | 
             
                # The actual algorithm to prepare for the list view
         | 
| 110 110 | 
             
                def do_list
         | 
| 111 | 
            +
                  # id: nil needed in params_for because rails reuse it even
         | 
| 112 | 
            +
                  # if it was deleted from params (like do_refresh_list does)
         | 
| 113 | 
            +
                  @remove_id_from_list_links = params[:id].blank?
         | 
| 111 114 | 
             
                  set_includes_for_columns
         | 
| 112 115 |  | 
| 113 116 | 
             
                  options = {:sorting => active_scaffold_config.list.user.sorting,
         | 
| 114 117 | 
             
                             :count_includes => active_scaffold_config.list.user.count_includes}
         | 
| 115 | 
            -
                  paginate =  | 
| 118 | 
            +
                  paginate = params[:format].nil? ? (accepts? :html, :js) : %w[html js].include?(params[:format])
         | 
| 116 119 | 
             
                  options[:pagination] = active_scaffold_config.list.pagination if paginate
         | 
| 117 120 | 
             
                  if options[:pagination]
         | 
| 118 | 
            -
                    options. | 
| 119 | 
            -
             | 
| 120 | 
            -
                      :page => active_scaffold_config.list.user.page
         | 
| 121 | 
            -
                    )
         | 
| 121 | 
            +
                    options[:per_page] = active_scaffold_config.list.user.per_page
         | 
| 122 | 
            +
                    options[:page] = active_scaffold_config.list.user.page
         | 
| 122 123 | 
             
                  end
         | 
| 123 124 | 
             
                  if active_scaffold_config.list.auto_select_columns
         | 
| 124 125 | 
             
                    auto_select_columns = list_columns + [active_scaffold_config.columns[active_scaffold_config.model.primary_key]]
         | 
| @@ -140,7 +141,10 @@ module ActiveScaffold::Actions | |
| 140 141 |  | 
| 141 142 | 
             
                def do_refresh_list
         | 
| 142 143 | 
             
                  params.delete(:id)
         | 
| 143 | 
            -
                   | 
| 144 | 
            +
                  if respond_to? :do_search, true
         | 
| 145 | 
            +
                    store_search_params_into_session if search_params.blank?
         | 
| 146 | 
            +
                    do_search
         | 
| 147 | 
            +
                  end
         | 
| 144 148 | 
             
                  do_list
         | 
| 145 149 | 
             
                end
         | 
| 146 150 |  | 
| @@ -172,7 +176,7 @@ module ActiveScaffold::Actions | |
| 172 176 | 
             
                end
         | 
| 173 177 |  | 
| 174 178 | 
             
                def action_update_respond_to_js
         | 
| 175 | 
            -
                  do_refresh_list  | 
| 179 | 
            +
                  do_refresh_list if @record.blank?
         | 
| 176 180 | 
             
                  super
         | 
| 177 181 | 
             
                end
         | 
| 178 182 |  | 
| @@ -197,10 +201,10 @@ module ActiveScaffold::Actions | |
| 197 201 | 
             
                def list_formats
         | 
| 198 202 | 
             
                  (default_formats + active_scaffold_config.formats + active_scaffold_config.list.formats).uniq
         | 
| 199 203 | 
             
                end
         | 
| 200 | 
            -
                 | 
| 204 | 
            +
                alias index_formats list_formats
         | 
| 201 205 |  | 
| 202 206 | 
             
                def row_formats
         | 
| 203 | 
            -
                  ([ | 
| 207 | 
            +
                  (%i[html js] + active_scaffold_config.formats + active_scaffold_config.list.formats).uniq
         | 
| 204 208 | 
             
                end
         | 
| 205 209 |  | 
| 206 210 | 
             
                def action_update_formats
         | 
| @@ -1,8 +1,8 @@ | |
| 1 1 | 
             
            module ActiveScaffold::Actions
         | 
| 2 2 | 
             
              module Mark
         | 
| 3 3 | 
             
                def self.included(base)
         | 
| 4 | 
            -
                  base. | 
| 5 | 
            -
                  base. | 
| 4 | 
            +
                  base.before_action :mark_authorized_filter, :only => :mark
         | 
| 5 | 
            +
                  base.before_action :assign_marked_records_to_model
         | 
| 6 6 | 
             
                  base.helper_method :marked_records
         | 
| 7 7 | 
             
                end
         | 
| 8 8 |  | 
| @@ -45,7 +45,11 @@ module ActiveScaffold::Actions | |
| 45 45 | 
             
                end
         | 
| 46 46 |  | 
| 47 47 | 
             
                def mark?
         | 
| 48 | 
            -
                  @mark ||=  | 
| 48 | 
            +
                  @mark ||= begin
         | 
| 49 | 
            +
                    value = params.delete :value
         | 
| 50 | 
            +
                    value.downcase! if value.is_a? String
         | 
| 51 | 
            +
                    [true, 'true', 1, '1', 't'].include? value
         | 
| 52 | 
            +
                  end
         | 
| 49 53 | 
             
                end
         | 
| 50 54 |  | 
| 51 55 | 
             
                def mark_all_scope_forced?
         | 
| @@ -80,7 +84,11 @@ module ActiveScaffold::Actions | |
| 80 84 | 
             
                # The default security delegates to ActiveRecordPermissions.
         | 
| 81 85 | 
             
                # You may override the method to customize.
         | 
| 82 86 | 
             
                def mark_authorized?
         | 
| 83 | 
            -
                  authorized_for?(: | 
| 87 | 
            +
                  authorized_for?(crud_type: :read)
         | 
| 88 | 
            +
                end
         | 
| 89 | 
            +
             | 
| 90 | 
            +
                def mark_authorized_filter
         | 
| 91 | 
            +
                  raise ActiveScaffold::ActionNotAllowed unless mark_authorized?
         | 
| 84 92 | 
             
                end
         | 
| 85 93 |  | 
| 86 94 | 
             
                def mark_formats
         | 
| @@ -4,11 +4,11 @@ module ActiveScaffold::Actions | |
| 4 4 | 
             
                def self.included(base)
         | 
| 5 5 | 
             
                  super
         | 
| 6 6 | 
             
                  base.module_eval do
         | 
| 7 | 
            -
                     | 
| 8 | 
            -
                     | 
| 7 | 
            +
                    before_action :set_nested
         | 
| 8 | 
            +
                    before_action :configure_nested
         | 
| 9 9 | 
             
                    include ActiveScaffold::Actions::Nested::ChildMethods if active_scaffold_config.model.reflect_on_all_associations.any? { |a| a.macro == :has_and_belongs_to_many }
         | 
| 10 10 | 
             
                  end
         | 
| 11 | 
            -
                  base. | 
| 11 | 
            +
                  base.before_action :include_habtm_actions
         | 
| 12 12 | 
             
                  base.helper_method :nested
         | 
| 13 13 | 
             
                  base.helper_method :nested_parent_record
         | 
| 14 14 | 
             
                end
         | 
| @@ -25,6 +25,7 @@ module ActiveScaffold::Actions | |
| 25 25 | 
             
                end
         | 
| 26 26 |  | 
| 27 27 | 
             
                def set_nested
         | 
| 28 | 
            +
                  @nested = nil
         | 
| 28 29 | 
             
                  return unless params[:parent_scaffold] && (params[:association] || params[:named_scope])
         | 
| 29 30 | 
             
                  @nested = ActiveScaffold::DataStructures::NestedInfo.get(active_scaffold_config.model, params)
         | 
| 30 31 | 
             
                  register_constraints_with_action_columns(@nested.constrained_fields) unless @nested.nil?
         | 
| @@ -33,7 +34,10 @@ module ActiveScaffold::Actions | |
| 33 34 | 
             
                def configure_nested
         | 
| 34 35 | 
             
                  return unless nested?
         | 
| 35 36 | 
             
                  active_scaffold_config.list.user.label = nested_label
         | 
| 36 | 
            -
                   | 
| 37 | 
            +
                  unless active_scaffold_config.nested.ignore_order_from_association
         | 
| 38 | 
            +
                    chain = beginning_of_chain
         | 
| 39 | 
            +
                    active_scaffold_config.list.user.nested_default_sorting = nested_default_sorting(chain) if nested.sorted?(chain)
         | 
| 40 | 
            +
                  end
         | 
| 37 41 | 
             
                end
         | 
| 38 42 |  | 
| 39 43 | 
             
                def nested_label
         | 
| @@ -44,8 +48,8 @@ module ActiveScaffold::Actions | |
| 44 48 | 
             
                  end
         | 
| 45 49 | 
             
                end
         | 
| 46 50 |  | 
| 47 | 
            -
                def nested_default_sorting
         | 
| 48 | 
            -
                  {:table_name => active_scaffold_config. | 
| 51 | 
            +
                def nested_default_sorting(chain)
         | 
| 52 | 
            +
                  {:table_name => active_scaffold_config._table_name, :default_sorting => nested.default_sorting(chain)}
         | 
| 49 53 | 
             
                end
         | 
| 50 54 |  | 
| 51 55 | 
             
                def nested_authorized?(record = nil)
         | 
| @@ -59,7 +63,7 @@ module ActiveScaffold::Actions | |
| 59 63 | 
             
                    if active_scaffold_config.nested.shallow_delete
         | 
| 60 64 | 
             
                      active_scaffold_config.action_links.add('destroy_existing', :label => :remove, :type => :member, :confirm => :are_you_sure_to_delete, :method => :delete, :position => false, :security_method => :delete_existing_authorized?) unless active_scaffold_config.action_links['destroy_existing']
         | 
| 61 65 | 
             
                      if active_scaffold_config.actions.include?(:delete)
         | 
| 62 | 
            -
                        active_scaffold_config.action_links.delete(' | 
| 66 | 
            +
                        active_scaffold_config.action_links.delete('destroy') if active_scaffold_config.action_links['destroy']
         | 
| 63 67 | 
             
                      end
         | 
| 64 68 | 
             
                    end
         | 
| 65 69 | 
             
                  else
         | 
| @@ -69,7 +73,7 @@ module ActiveScaffold::Actions | |
| 69 73 | 
             
                    if active_scaffold_config.nested.shallow_delete
         | 
| 70 74 | 
             
                      active_scaffold_config.action_links.delete('destroy_existing') if active_scaffold_config.action_links['destroy_existing']
         | 
| 71 75 | 
             
                      if active_scaffold_config.actions.include?(:delete) && active_scaffold_config.delete.link
         | 
| 72 | 
            -
                        active_scaffold_config.action_links.add(active_scaffold_config.delete.link) unless active_scaffold_config.action_links[' | 
| 76 | 
            +
                        active_scaffold_config.action_links.add(active_scaffold_config.delete.link) unless active_scaffold_config.action_links['destroy']
         | 
| 73 77 | 
             
                      end
         | 
| 74 78 | 
             
                    end
         | 
| 75 79 | 
             
                  end
         | 
| @@ -79,22 +83,14 @@ module ActiveScaffold::Actions | |
| 79 83 | 
             
                  if nested? && nested.association
         | 
| 80 84 | 
             
                    if nested.association.collection?
         | 
| 81 85 | 
             
                      nested_parent_record.send(nested.association.name)
         | 
| 82 | 
            -
                    elsif nested.association. | 
| 86 | 
            +
                    elsif nested.association.through? # has_one :through
         | 
| 83 87 | 
             
                      active_scaffold_config.model.where(active_scaffold_config.model.primary_key => nested_parent_record.send(nested.association.name).try(:id))
         | 
| 84 | 
            -
                    elsif nested. | 
| 85 | 
            -
                      active_scaffold_config.model
         | 
| 86 | 
            -
                    elsif nested.child_association.belongs_to?
         | 
| 88 | 
            +
                    elsif nested.association.has_one?
         | 
| 87 89 | 
             
                      active_scaffold_config.model.where(nested.child_association.foreign_key => nested_parent_record.send(nested.association.association_primary_key))
         | 
| 88 90 | 
             
                    elsif nested.association.belongs_to?
         | 
| 89 | 
            -
                       | 
| 90 | 
            -
             | 
| 91 | 
            -
             | 
| 92 | 
            -
                          dependency = ActiveRecord::Associations::JoinDependency.new(chain.klass, chain.joins_values, [])
         | 
| 93 | 
            -
                          join_associations = Rails.version >= '4.1.0' ? dependency.join_root.children : dependency.join_associations
         | 
| 94 | 
            -
                          join_associations.find {|join| join.try(:reflection).try(:name) == nested.child_association.name}.try(:table).try(:right)
         | 
| 95 | 
            -
                        end
         | 
| 96 | 
            -
                      table_name ||= nested.association.active_record.table_name
         | 
| 97 | 
            -
                      chain.where(table_name => {nested.association.active_record.primary_key => nested_parent_record}).readonly(false)
         | 
| 91 | 
            +
                      nested_belongs_to_chain
         | 
| 92 | 
            +
                    else # never should get here
         | 
| 93 | 
            +
                      active_scaffold_config.model
         | 
| 98 94 | 
             
                    end
         | 
| 99 95 | 
             
                  elsif nested? && nested.scope
         | 
| 100 96 | 
             
                    nested_parent_record.send(nested.scope)
         | 
| @@ -103,6 +99,11 @@ module ActiveScaffold::Actions | |
| 103 99 | 
             
                  end
         | 
| 104 100 | 
             
                end
         | 
| 105 101 |  | 
| 102 | 
            +
                def nested_belongs_to_chain
         | 
| 103 | 
            +
                  primary_key = active_scaffold_config.mongoid? ? '_id' : active_scaffold_config.model.primary_key
         | 
| 104 | 
            +
                  active_scaffold_config.model.where(primary_key => nested_parent_record.send(nested.association.name))
         | 
| 105 | 
            +
                end
         | 
| 106 | 
            +
             | 
| 106 107 | 
             
                def nested_parent_record(crud = :read)
         | 
| 107 108 | 
             
                  @nested_parent_record ||= find_if_allowed(nested.parent_id, crud, nested.parent_model)
         | 
| 108 109 | 
             
                end
         | 
| @@ -111,11 +112,10 @@ module ActiveScaffold::Actions | |
| 111 112 | 
             
                  # has_many is done by beginning_of_chain and rails
         | 
| 112 113 | 
             
                  return unless (nested.belongs_to? || nested.has_one? || nested.habtm?) && nested.child_association
         | 
| 113 114 | 
             
                  return if (parent = nested_parent_record).nil?
         | 
| 114 | 
            -
                   | 
| 115 | 
            -
                  when :has_one, :belongs_to
         | 
| 115 | 
            +
                  if nested.child_association.singular?
         | 
| 116 116 | 
             
                    record.send("#{nested.child_association.name}=", parent)
         | 
| 117 | 
            -
                   | 
| 118 | 
            -
                    record.send( | 
| 117 | 
            +
                  else
         | 
| 118 | 
            +
                    record.send(nested.child_association.name) << parent
         | 
| 119 119 | 
             
                  end
         | 
| 120 120 | 
             
                end
         | 
| 121 121 |  | 
| @@ -210,7 +210,7 @@ module ActiveScaffold::Actions::Nested | |
| 210 210 | 
             
                end
         | 
| 211 211 |  | 
| 212 212 | 
             
                def delete_existing_authorized?(record = nil)
         | 
| 213 | 
            -
                  nested_parent_record.authorized_for?(:crud_type => :update, :column => nested.association.try(:name))
         | 
| 213 | 
            +
                  nested_parent_record.authorized_for?(:crud_type => :update, :column => nested.association.try(:name), :reason => true)
         | 
| 214 214 | 
             
                end
         | 
| 215 215 |  | 
| 216 216 | 
             
                def after_create_save(record)
         |