Sha256: 547c154f6ab5904e09e2e24682d1d99cd9385e9dbb2ffde58480e7f559565a80

Contents?: true

Size: 788 Bytes

Versions: 6

Compression:

Stored size: 788 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # This cell renders the results 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, :with_resource_type)
    end

    def has_selected_resource_type?
      selected_resource_type.present?
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-core-0.29.1 app/cells/decidim/search_results_cell.rb
decidim-core-0.29.0 app/cells/decidim/search_results_cell.rb
decidim-core-0.29.0.rc4 app/cells/decidim/search_results_cell.rb
decidim-core-0.29.0.rc3 app/cells/decidim/search_results_cell.rb
decidim-core-0.29.0.rc2 app/cells/decidim/search_results_cell.rb
decidim-core-0.29.0.rc1 app/cells/decidim/search_results_cell.rb