Module: Decidim::Proposals::ProposalsHelper

Defined in:
app/helpers/decidim/proposals/proposals_helper.rb

Overview

Simple helpers to handle markup variations for proposals

Instance Method Summary collapse

Instance Method Details

#card_size_for_view_mode(view_mode) ⇒ Object



34
35
36
# File 'app/helpers/decidim/proposals/proposals_helper.rb', line 34

def card_size_for_view_mode(view_mode)
  view_mode == "grid" ? :g : nil
end

#proposal_has_costs?Boolean

Returns:

  • (Boolean)


14
15
16
17
18
# File 'app/helpers/decidim/proposals/proposals_helper.rb', line 14

def proposal_has_costs?
  @proposal.cost.present? &&
    translated_attribute(@proposal.cost_report).present? &&
    translated_attribute(@proposal.execution_period).present?
end

#proposal_reason_callout_announcementObject



7
8
9
10
11
12
# File 'app/helpers/decidim/proposals/proposals_helper.rb', line 7

def proposal_reason_callout_announcement
  {
    title: translated_attribute(@proposal.proposal_state&.announcement_title),
    body: decidim_sanitize_editor_admin(translated_attribute(@proposal.answer))
  }
end

#proposals_container_class(view_mode) ⇒ Object



30
31
32
# File 'app/helpers/decidim/proposals/proposals_helper.rb', line 30

def proposals_container_class(view_mode)
  view_mode == "grid" ? "card__grid-grid" : "card__list-list"
end

#resource_version(resource, options = {}) ⇒ Object



38
39
40
41
42
# File 'app/helpers/decidim/proposals/proposals_helper.rb', line 38

def resource_version(resource, options = {})
  return unless resource.respond_to?(:amendable?) && resource.amendable?

  super
end


20
21
22
23
24
25
26
27
28
# File 'app/helpers/decidim/proposals/proposals_helper.rb', line 20

def toggle_view_mode_link(current_mode, target_mode, title, params)
  path = proposals_path(params.permit(:order, filter: {}).merge({ view_mode: target_mode }))
  icon_name = target_mode == "grid" ? "layout-grid-fill" : "list-check"
  icon_class = "view-icon--disabled" unless current_mode == target_mode

  link_to path, remote: true, title: do
    icon(icon_name, class: icon_class, role: "img", "aria-hidden": true)
  end
end