Module: Decidim::Initiatives::InitiativeHelper

Includes:
ResourceVersionsHelper, SanitizeHelper
Included in:
CreateInitiativeController, InitiativeMetadataGCell
Defined in:
app/helpers/decidim/initiatives/initiative_helper.rb

Overview

Helper method related to initiative object and its internal state.

Instance Method Summary collapse

Instance Method Details

#can_edit_custom_signature_end_date?(initiative) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
36
37
# File 'app/helpers/decidim/initiatives/initiative_helper.rb', line 33

def can_edit_custom_signature_end_date?(initiative)
  return false unless initiative.custom_signature_end_date_enabled?

  initiative.created? || initiative.validating?
end

#hero_background_path(initiative) ⇒ Object



45
46
47
# File 'app/helpers/decidim/initiatives/initiative_helper.rb', line 45

def hero_background_path(initiative)
  initiative.attachments.find(&:image?)&.url
end

#humanize_admin_state(state) ⇒ Object

Public: The state of an initiative from an administration perspective in a way that a human can understand.

state - String

Returns a String



29
30
31
# File 'app/helpers/decidim/initiatives/initiative_helper.rb', line 29

def humanize_admin_state(state)
  I18n.t(state, scope: "decidim.initiatives.admin_states", default: :created)
end

#metadata_badge_css_class(initiative) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/helpers/decidim/initiatives/initiative_helper.rb', line 10

def (initiative)
  case initiative
  when "accepted", "open"
    "success"
  when "rejected", "discarded"
    "alert"
  when "validating"
    "warning"
  else
    "muted"
  end
end

#render_committee_tooltipObject



39
40
41
42
43
# File 'app/helpers/decidim/initiatives/initiative_helper.rb', line 39

def render_committee_tooltip
  with_tooltip t("decidim.initiatives.create_initiative.share_committee_link.invite_to_committee_help"), class: "left" do
    icon "file-copy-line"
  end
end