Sha256: 57798a12d218f1d78261dab748d32fdda6ee8aefb61163e5e845d9d53880bd1b

Contents?: true

Size: 1.19 KB

Versions: 3

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

module Decidim
  module Votings
    module ContentBlocks
      class HeroCell < Decidim::ContentBlocks::ParticipatorySpaceHeroCell
        delegate :start_time, :end_time, to: :resource

        def has_hashtag?
          false
        end

        def subtitle
          "#{start_text} — #{end_text}"
        end

        def cta_text
          return unless model

          @cta_text ||= translated_attribute(model.settings.button_text).presence
        end

        def cta_path
          return unless model

          @cta_path ||= translated_attribute(model.settings.button_url).presence
        end

        private

        def start_text
          content_tag :span, title: t("activemodel.attributes.voting.start_time") do
            format_date(start_time)
          end
        end

        def end_text
          content_tag :span, title: t("activemodel.attributes.voting.end_time") do
            format_date(end_time)
          end
        end

        def format_date(time)
          if time
            l(time.to_date, format: :decidim_short)
          else
            t("decidim.votings.votings_m.unspecified")
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-elections-0.28.0 app/cells/decidim/votings/content_blocks/hero_cell.rb
decidim-elections-0.28.0.rc5 app/cells/decidim/votings/content_blocks/hero_cell.rb
decidim-elections-0.28.0.rc4 app/cells/decidim/votings/content_blocks/hero_cell.rb