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
- #authorized_create_modal_button(type, html_options) ⇒ Object
- #authorized_vote_modal_button(initiative, html_options) ⇒ Object
- #can_edit_custom_signature_end_date?(initiative) ⇒ Boolean
- #hero_background_path(initiative) ⇒ Object
-
#humanize_admin_state(state) ⇒ Object
Public: The state of an initiative from an administration perspective in a way that a human can understand.
- #metadata_badge_css_class(initiative) ⇒ Object
- #render_committee_tooltip ⇒ Object
Instance Method Details
#authorized_create_modal_button(type, html_options) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/helpers/decidim/initiatives/initiative_helper.rb', line 33 def (type, , &) tag = "button" ||= {} if current_user if ("create", permissions_holder: type).ok? ["data-dialog-open"] = "not-authorized-modal" else ["data-dialog-open"] = "authorizationModal" ["data-dialog-remote-url"] = (type) end else ["data-dialog-open"] = "loginModal" end ["onclick"] = "event.preventDefault();" send("#{tag}_to", "/", , &) end |
#authorized_vote_modal_button(initiative, html_options) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/helpers/decidim/initiatives/initiative_helper.rb', line 53 def (initiative, , &) return if current_user && ("vote", resource: initiative, permissions_holder: initiative.type).ok? tag = "button" ||= {} if current_user ["data-dialog-open"] = "authorizationModal" ["data-dialog-remote-url"] = (initiative) else ["data-dialog-open"] = "loginModal" end ["onclick"] = "event.preventDefault();" send("#{tag}_to", "/", , &) end |
#can_edit_custom_signature_end_date?(initiative) ⇒ Boolean
71 72 73 74 75 |
# File 'app/helpers/decidim/initiatives/initiative_helper.rb', line 71 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
83 84 85 |
# File 'app/helpers/decidim/initiatives/initiative_helper.rb', line 83 def hero_background_path(initiative) initiative..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", "published" "success" when "rejected", "discarded" "alert" when "validating" "warning" else "muted" end end |
#render_committee_tooltip ⇒ Object
77 78 79 80 81 |
# File 'app/helpers/decidim/initiatives/initiative_helper.rb', line 77 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 |