Sha256: 7f708a060774fc5e4a679979204f655fd4bd6a182c696f4c020766936bfb13f9

Contents?: true

Size: 782 Bytes

Versions: 7

Compression:

Stored size: 782 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # This cell renders the reuslts of the global search page.
  class SearchResultsCell < Decidim::ViewModel
    include Decidim::SearchesHelper
    include Decidim::CardHelper

    def show
      render :show
    end

    def sections
      model
    end

    def non_empty_sections
      sections.select { |_name, results| results[:count].positive? }
    end

    def sections_to_render
      return non_empty_sections.slice(selected_resource_type) if has_selected_resource_type?
      non_empty_sections
    end

    def params
      options[:params]
    end

    def selected_resource_type
      params.dig(:filter, :resource_type)
    end

    def has_selected_resource_type?
      selected_resource_type.present?
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-core-0.18.1 app/cells/decidim/search_results_cell.rb
decidim-core-0.17.2 app/cells/decidim/search_results_cell.rb
decidim-core-0.18.0 app/cells/decidim/search_results_cell.rb
decidim-core-0.17.1 app/cells/decidim/search_results_cell.rb
decidim-core-0.16.1 app/cells/decidim/search_results_cell.rb
decidim-core-0.17.0 app/cells/decidim/search_results_cell.rb
decidim-core-0.16.0 app/cells/decidim/search_results_cell.rb