Sha256: e4017d952660441ca9d27dd64b7ea7f6cda788196ea615428676da2bccb1ee35

Contents?: true

Size: 1.1 KB

Versions: 13

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

module Decidim
  # A Helper to render the Call To Action button.
  module CtaButtonHelper
    # Renders the Call To Action button. Link and text can be configured
    # per organization.
    def cta_button_text
      translated_attribute(current_organization.cta_button_text).presence || t("decidim.pages.home.hero.participate")
    end

    def cta_button
      link_to cta_button_text, cta_button_path, class: "hero-cta button expanded large button--sc", title: t("decidim.pages.home.hero.participate_title")
    end

    # Finds the CTA button path to reuse it in other places.
    def cta_button_path
      if current_organization.cta_button_path.present?
        current_organization.cta_button_path
      elsif Decidim::ParticipatoryProcess.where(organization: current_organization).published.any?
        decidim_participatory_processes.participatory_processes_path
      elsif current_user
        decidim.account_path
      elsif current_organization.sign_up_enabled?
        decidim.new_user_registration_path
      else
        decidim.new_user_session_path
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-core-0.29.1 app/helpers/decidim/cta_button_helper.rb
decidim-core-0.28.4 app/helpers/decidim/cta_button_helper.rb
decidim-core-0.29.0 app/helpers/decidim/cta_button_helper.rb
decidim-core-0.28.3 app/helpers/decidim/cta_button_helper.rb
decidim-core-0.29.0.rc4 app/helpers/decidim/cta_button_helper.rb
decidim-core-0.29.0.rc3 app/helpers/decidim/cta_button_helper.rb
decidim-core-0.29.0.rc2 app/helpers/decidim/cta_button_helper.rb
decidim-core-0.29.0.rc1 app/helpers/decidim/cta_button_helper.rb
decidim-core-0.28.2 app/helpers/decidim/cta_button_helper.rb
decidim-core-0.28.1 app/helpers/decidim/cta_button_helper.rb
decidim-core-0.28.0 app/helpers/decidim/cta_button_helper.rb
decidim-core-0.28.0.rc5 app/helpers/decidim/cta_button_helper.rb
decidim-core-0.28.0.rc4 app/helpers/decidim/cta_button_helper.rb