Sha256: 1d29d5eaa6fd96385ba61ca4f9ca08c5beec86948413d57fefd2aa5dcd0aa422

Contents?: true

Size: 1.39 KB

Versions: 6

Compression:

Stored size: 1.39 KB

Contents

# frozen_string_literal: true

module Decidim
  module Meetings
    # This cell renders metadata for an instance of a Meeting
    class MeetingCardMetadataCell < Decidim::CardMetadataCell
      alias meeting model

      delegate :type_of_meeting, :start_time, :end_time, :category, :withdrawn?, to: :meeting

      alias start_date start_time
      alias end_date end_time

      def initialize(*)
        super

        @items.prepend(*meeting_items)
      end

      private

      def meeting_items
        [start_date_item, type, comments_count_item, category_item, withdrawn_item]
      end

      def meeting_items_for_map
        [dates_item, type].compact_blank.map do |item|
          {
            text: item[:text],
            icon: icon(item[:icon]).html_safe
          }
        end
      end

      def type
        {
          text: t(type_of_meeting, scope: "decidim.meetings.meetings.filters.type_values"),
          icon: resource_type_icon_key(type_of_meeting)
        }
      end

      def official
        return unless official?

        {
          text: t("decidim.meetings.models.meeting.fields.official_meeting"),
          icon: "information-line"
        }
      end

      def withdrawn_item
        return unless withdrawn?

        {
          text: t("withdraw", scope: "decidim.meetings.types"),
          icon: resource_type_icon_key("withdrawn")
        }
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-meetings-0.29.1 app/cells/decidim/meetings/meeting_card_metadata_cell.rb
decidim-meetings-0.29.0 app/cells/decidim/meetings/meeting_card_metadata_cell.rb
decidim-meetings-0.29.0.rc4 app/cells/decidim/meetings/meeting_card_metadata_cell.rb
decidim-meetings-0.29.0.rc3 app/cells/decidim/meetings/meeting_card_metadata_cell.rb
decidim-meetings-0.29.0.rc2 app/cells/decidim/meetings/meeting_card_metadata_cell.rb
decidim-meetings-0.29.0.rc1 app/cells/decidim/meetings/meeting_card_metadata_cell.rb