Sha256: 8ffa2fdc97a1d53d3569330a7476db2cd1a34258dc907defcf5075805a76b624

Contents?: true

Size: 1.47 KB

Versions: 4

Compression:

Stored size: 1.47 KB

Contents

# frozen_string_literal: true

module Decidim
  module Meetings
    # This cell renders metadata for an instance of a Meeting
    class MeetingCardMetadataCell < Decidim::CardMetadataCell
      include Decidim::LayoutHelper
      include ActionView::Helpers::DateHelper

      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

4 entries across 4 versions & 1 rubygems

Version Path
decidim-meetings-0.28.4 app/cells/decidim/meetings/meeting_card_metadata_cell.rb
decidim-meetings-0.28.3 app/cells/decidim/meetings/meeting_card_metadata_cell.rb
decidim-meetings-0.28.2 app/cells/decidim/meetings/meeting_card_metadata_cell.rb
decidim-meetings-0.28.1 app/cells/decidim/meetings/meeting_card_metadata_cell.rb