Class: Decidim::HomepageProposals::ContentBlocks::ProposalsSliderCell
- Inherits:
-
ViewModel
- Object
- ViewModel
- Decidim::HomepageProposals::ContentBlocks::ProposalsSliderCell
- Includes:
- ActionView::Helpers::FormOptionsHelper, Cell::ViewModel::Partial, ComponentPathHelper, FilterResource, FiltersHelper, IconHelper
- Defined in:
- app/cells/decidim/homepage_proposals/content_blocks/proposals_slider_cell.rb
Instance Attribute Summary collapse
-
#glanced_proposals ⇒ Object
Returns the value of attribute glanced_proposals.
Instance Method Summary collapse
- #categories_filter ⇒ Object
- #content_block_settings ⇒ Object
- #default_filter_params ⇒ Object
- #default_linked_component_path ⇒ Object
- #linked_components ⇒ Object
- #options_for_default_component ⇒ Object
- #selected_component_id ⇒ Object
Instance Attribute Details
#glanced_proposals ⇒ Object
Returns the value of attribute glanced_proposals.
7 8 9 |
# File 'app/cells/decidim/homepage_proposals/content_blocks/proposals_slider_cell.rb', line 7 def glanced_proposals @glanced_proposals end |
Instance Method Details
#categories_filter ⇒ Object
50 51 52 |
# File 'app/cells/decidim/homepage_proposals/content_blocks/proposals_slider_cell.rb', line 50 def categories_filter @categories_filter ||= Decidim::Category.where(id: linked_components.map(&:categories).flatten) end |
#content_block_settings ⇒ Object
23 24 25 26 27 28 |
# File 'app/cells/decidim/homepage_proposals/content_blocks/proposals_slider_cell.rb', line 23 def content_block_settings @content_block_settings ||= Decidim::ContentBlock.find_by( manifest_name: "proposals_slider", organization: current_organization ).settings end |
#default_filter_params ⇒ Object
42 43 44 45 46 47 48 |
# File 'app/cells/decidim/homepage_proposals/content_blocks/proposals_slider_cell.rb', line 42 def default_filter_params { scope_id: nil, category_id: nil, component_id: nil } end |
#default_linked_component_path ⇒ Object
17 18 19 20 21 |
# File 'app/cells/decidim/homepage_proposals/content_blocks/proposals_slider_cell.rb', line 17 def default_linked_component_path main_component_path(Decidim::Component.find(selected_component_id)) rescue ActiveRecord::RecordNotFound root_path end |
#linked_components ⇒ Object
38 39 40 |
# File 'app/cells/decidim/homepage_proposals/content_blocks/proposals_slider_cell.rb', line 38 def linked_components @linked_components ||= Decidim::Component.where(id: content_block_settings.linked_components_id.compact) end |
#options_for_default_component ⇒ Object
30 31 32 33 34 35 36 |
# File 'app/cells/decidim/homepage_proposals/content_blocks/proposals_slider_cell.rb', line 30 def = linked_components.map do |component| ["#{translated_attribute(component.name)} (#{translated_attribute(component.participatory_space.title)})", component.id] end (, selected: selected_component_id) end |
#selected_component_id ⇒ Object
54 55 56 |
# File 'app/cells/decidim/homepage_proposals/content_blocks/proposals_slider_cell.rb', line 54 def selected_component_id @selected_component_id ||= params.dig(:filter, :component_id) || content_block_settings.default_linked_component end |