Sha256: b4ce4ceca7eff69b01de9fe45640dc939f8e3ef47db6320c2262b50d3839fea3

Contents?: true

Size: 1.1 KB

Versions: 9

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

module Decidim
  module Initiatives
    # This cell renders the Medium (:m) initiative card
    # for an given instance of an Initiative
    class InitiativeMCell < Decidim::CardMCell
      include Decidim::Initiatives::Engine.routes.url_helpers

      property :state

      private

      def title
        decidim_html_escape(translated_attribute(model.title))
      end

      def hashtag
        decidim_html_escape(model.hashtag)
      end

      def has_state?
        true
      end

      def state_classes
        case state
        when "accepted", "published"
          ["success"]
        when "rejected", "discarded"
          ["alert"]
        when "validating"
          ["warning"]
        else
          ["muted"]
        end
      end

      def resource_path
        initiative_path(model)
      end

      def resource_icon
        icon "initiatives", class: "icon--big"
      end

      def authors
        [present(model).author] +
          model.committee_members.approved.non_deleted.excluding_author.map { |member| present(member.user) }
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
decidim-initiatives-0.21.0 app/cells/decidim/initiatives/initiative_m_cell.rb
decidim-initiatives-0.20.1 app/cells/decidim/initiatives/initiative_m_cell.rb
decidim-initiatives-0.20.0 app/cells/decidim/initiatives/initiative_m_cell.rb
decidim-initiatives-0.19.1 app/cells/decidim/initiatives/initiative_m_cell.rb
decidim-initiatives-0.18.1 app/cells/decidim/initiatives/initiative_m_cell.rb
decidim-initiatives-0.19.0 app/cells/decidim/initiatives/initiative_m_cell.rb
decidim-initiatives-0.17.2 app/cells/decidim/initiatives/initiative_m_cell.rb
decidim-initiatives-0.18.0 app/cells/decidim/initiatives/initiative_m_cell.rb
decidim-initiatives-0.17.1 app/cells/decidim/initiatives/initiative_m_cell.rb