Sha256: 8b06e1f8a417674b1fba7ed802e13cd85fa04be40d00d06b0014fce0cd0be84e

Contents?: true

Size: 1.4 KB

Versions: 13

Compression:

Stored size: 1.4 KB

Contents

# frozen_string_literal: true

require "active_support/concern"

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

        included do
          include Decidim::Admin::Filterable

          helper Decidim::Accountability::Admin::FilterableHelper

          private

          def base_query
            collection
          end

          def search_field_predicate
            :id_string_or_title_cont
          end

          def filters
            [
              :scope_id_eq,
              :category_id_eq,
              :status_id_eq
            ]
          end

          def filters_with_values
            {
              scope_id_eq: scope_ids_hash(scopes.top_level),
              category_id_eq: category_ids_hash(categories.first_class),
              status_id_eq: status_ids_hash(statuses)
            }
          end

          # Cannot user `super` here, because it does not belong to a superclass
          # but to a concern.
          def dynamically_translated_filters
            [:scope_id_eq, :category_id_eq, :status_id_eq]
          end

          def status_ids_hash(statuses)
            statuses.each_with_object({}) { |status, hash| hash[status.id] = status.id }
          end

          def translated_status_id_eq(id)
            translated_attribute(statuses.find_by(id:).name)
          end
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-accountability-0.29.1 app/controllers/concerns/decidim/accountability/admin/filterable.rb
decidim-accountability-0.28.4 app/controllers/concerns/decidim/accountability/admin/filterable.rb
decidim-accountability-0.29.0 app/controllers/concerns/decidim/accountability/admin/filterable.rb
decidim-accountability-0.28.3 app/controllers/concerns/decidim/accountability/admin/filterable.rb
decidim-accountability-0.29.0.rc4 app/controllers/concerns/decidim/accountability/admin/filterable.rb
decidim-accountability-0.29.0.rc3 app/controllers/concerns/decidim/accountability/admin/filterable.rb
decidim-accountability-0.29.0.rc2 app/controllers/concerns/decidim/accountability/admin/filterable.rb
decidim-accountability-0.29.0.rc1 app/controllers/concerns/decidim/accountability/admin/filterable.rb
decidim-accountability-0.28.2 app/controllers/concerns/decidim/accountability/admin/filterable.rb
decidim-accountability-0.28.1 app/controllers/concerns/decidim/accountability/admin/filterable.rb
decidim-accountability-0.28.0 app/controllers/concerns/decidim/accountability/admin/filterable.rb
decidim-accountability-0.28.0.rc5 app/controllers/concerns/decidim/accountability/admin/filterable.rb
decidim-accountability-0.28.0.rc4 app/controllers/concerns/decidim/accountability/admin/filterable.rb