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.23.6 app/cells/decidim/search_results_cell.rb
decidim-core-0.24.2 app/cells/decidim/search_results_cell.rb
decidim-core-0.23.5 app/cells/decidim/search_results_cell.rb
decidim-core-0.24.1 app/cells/decidim/search_results_cell.rb
decidim-core-0.24.0 app/cells/decidim/search_results_cell.rb
decidim-core-0.24.0.rc2 app/cells/decidim/search_results_cell.rb
decidim-core-0.23.4 app/cells/decidim/search_results_cell.rb
decidim-core-0.24.0.rc1 app/cells/decidim/search_results_cell.rb
decidim-core-0.23.3 app/cells/decidim/search_results_cell.rb
decidim-core-0.23.2 app/cells/decidim/search_results_cell.rb
decidim-core-0.23.1 app/cells/decidim/search_results_cell.rb
decidim-core-0.23.1.rc1 app/cells/decidim/search_results_cell.rb
decidim-core-0.23.0 app/cells/decidim/search_results_cell.rb
decidim-core-0.22.0 app/cells/decidim/search_results_cell.rb
decidim-core-0.21.0 app/cells/decidim/search_results_cell.rb
decidim-core-0.20.1 app/cells/decidim/search_results_cell.rb
decidim-core-0.20.0 app/cells/decidim/search_results_cell.rb
decidim-core-0.19.1 app/cells/decidim/search_results_cell.rb
decidim-core-0.19.0 app/cells/decidim/search_results_cell.rb