Sha256: 0838d6a34c16073341235cb6ff2b0bb9fc5325b1daf118a0eab4e00c2f2f0df9

Contents?: true

Size: 783 Bytes

Versions: 39

Compression:

Stored size: 783 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

39 entries across 39 versions & 1 rubygems

Version Path
decidim-core-0.26.10 app/cells/decidim/search_results_cell.rb
decidim-core-0.26.9 app/cells/decidim/search_results_cell.rb
decidim-core-0.26.8 app/cells/decidim/search_results_cell.rb
decidim-core-0.26.7 app/cells/decidim/search_results_cell.rb
decidim-core-0.26.5 app/cells/decidim/search_results_cell.rb
decidim-core-0.26.4 app/cells/decidim/search_results_cell.rb
decidim-core-0.26.3 app/cells/decidim/search_results_cell.rb
decidim-core-0.26.2 app/cells/decidim/search_results_cell.rb
decidim-core-0.26.1 app/cells/decidim/search_results_cell.rb
decidim-core-0.26.0 app/cells/decidim/search_results_cell.rb
decidim-core-0.26.0.rc2 app/cells/decidim/search_results_cell.rb
decidim-core-0.26.0.rc1 app/cells/decidim/search_results_cell.rb
decidim-core-0.25.2 app/cells/decidim/search_results_cell.rb
decidim-core-0.25.1 app/cells/decidim/search_results_cell.rb
decidim-core-0.25.0 app/cells/decidim/search_results_cell.rb
decidim-core-0.25.0.rc4 app/cells/decidim/search_results_cell.rb
decidim-core-0.25.0.rc3 app/cells/decidim/search_results_cell.rb
decidim-core-0.25.0.rc2 app/cells/decidim/search_results_cell.rb
decidim-core-0.25.0.rc1 app/cells/decidim/search_results_cell.rb
decidim-core-0.24.3 app/cells/decidim/search_results_cell.rb