Sha256: 493eea1a5bff339469497e27b424b63a424ac595d6cb2891e42840bfa2d0f58c

Contents?: true

Size: 1010 Bytes

Versions: 9

Compression:

Stored size: 1010 Bytes

Contents

# frozen_string_literal: true

module Decidim
  class SearchesController < Decidim::ApplicationController
    include Rectify::ControllerHelpers
    include FormFactory
    include FilterResource
    include Paginable

    helper Decidim::FiltersHelper
    helper_method :term

    def index
      Search.call(term, current_organization, filters, page_params) do
        on(:ok) do |results|
          # results.page(params[:page]).per(params[:per_page])
          results_count = results.sum { |results_by_type| results_by_type.last[:count] }
          expose(sections: results, results_count: results_count)
        end
      end
    end

    private

    def default_filter_params
      {
        term: params[:term],
        resource_type: nil,
        decidim_scope_id: nil
      }
    end

    def term
      @term ||= filter_params[:term]
    end

    def filters
      filter_params
    end

    def page_params
      {
        per_page: per_page,
        page: params[:page]
      }
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
decidim-core-0.19.1 app/controllers/decidim/searches_controller.rb
decidim-core-0.18.1 app/controllers/decidim/searches_controller.rb
decidim-core-0.19.0 app/controllers/decidim/searches_controller.rb
decidim-core-0.17.2 app/controllers/decidim/searches_controller.rb
decidim-core-0.18.0 app/controllers/decidim/searches_controller.rb
decidim-core-0.17.1 app/controllers/decidim/searches_controller.rb
decidim-core-0.16.1 app/controllers/decidim/searches_controller.rb
decidim-core-0.17.0 app/controllers/decidim/searches_controller.rb
decidim-core-0.16.0 app/controllers/decidim/searches_controller.rb