Sha256: f4632db1dc579e0be4e9c801abf81de12de1c4626227f395fc1335b6d1886ff6

Contents?: true

Size: 1.35 KB

Versions: 20

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true

require "active_support/concern"

module Decidim
  module Moderations
    module Admin
      module Filterable
        extend ActiveSupport::Concern

        included do
          include Decidim::Admin::Filterable

          private

          def base_query
            collection
          end

          def filters
            [
              :reportable_type_string_eq
            ]
          end

          def filters_with_values
            {
              reportable_type_string_eq: reportable_types
            }
          end

          def dynamically_translated_filters
            [:reportable_type_string_eq]
          end

          def translated_reportable_type_string_eq(value)
            value.constantize.name.demodulize
          end

          # Private: the predicate used by `Ransack` to perform a search. We used `reported` instead
          #          of `reportable` because otherwise `Ransack` try to traverse the polymorphic
          #          association automatically and it fails.
          def search_field_predicate
            :reported_id_string_or_reported_content_cont
          end

          def reportable_types
            collection.pluck(:decidim_reportable_type).uniq.sort
          end

          def extra_allowed_params
            [:hidden]
          end
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
decidim-admin-0.29.1 app/controllers/concerns/decidim/moderations/admin/filterable.rb
decidim-admin-0.28.4 app/controllers/concerns/decidim/moderations/admin/filterable.rb
decidim-admin-0.27.9 app/controllers/concerns/decidim/moderations/admin/filterable.rb
decidim-admin-0.29.0 app/controllers/concerns/decidim/moderations/admin/filterable.rb
decidim-admin-0.28.3 app/controllers/concerns/decidim/moderations/admin/filterable.rb
decidim-admin-0.27.8 app/controllers/concerns/decidim/moderations/admin/filterable.rb
decidim-admin-0.29.0.rc4 app/controllers/concerns/decidim/moderations/admin/filterable.rb
decidim-admin-0.29.0.rc3 app/controllers/concerns/decidim/moderations/admin/filterable.rb
decidim-admin-0.29.0.rc2 app/controllers/concerns/decidim/moderations/admin/filterable.rb
decidim-admin-0.29.0.rc1 app/controllers/concerns/decidim/moderations/admin/filterable.rb
decidim-admin-0.28.2 app/controllers/concerns/decidim/moderations/admin/filterable.rb
decidim-admin-0.27.7 app/controllers/concerns/decidim/moderations/admin/filterable.rb
decidim-admin-0.28.1 app/controllers/concerns/decidim/moderations/admin/filterable.rb
decidim-admin-0.27.6 app/controllers/concerns/decidim/moderations/admin/filterable.rb
decidim-admin-0.26.10 app/controllers/concerns/decidim/moderations/admin/filterable.rb
decidim-admin-0.26.9 app/controllers/concerns/decidim/moderations/admin/filterable.rb
decidim-admin-0.28.0 app/controllers/concerns/decidim/moderations/admin/filterable.rb
decidim-admin-0.27.5 app/controllers/concerns/decidim/moderations/admin/filterable.rb
decidim-admin-0.28.0.rc5 app/controllers/concerns/decidim/moderations/admin/filterable.rb
decidim-admin-0.28.0.rc4 app/controllers/concerns/decidim/moderations/admin/filterable.rb