Sha256: 0e1056febf67d0dade537d0bd83115e20e6d44bf30fd1252b2c5ae04ab262e32

Contents?: true

Size: 1.61 KB

Versions: 1

Compression:

Stored size: 1.61 KB

Contents

# frozen_string_literal: true

module Decidim
  module Calendar
    module CalendarHelper
      include Decidim::ApplicationHelper
      include Decidim::TranslationsHelper
      include Decidim::ResourceHelper
      def calendar_resource(name)
        %({
          "id": "#{name}",
          "title": "#{I18n.t(name, scope: "decidim.calendar.index.filters")}"
        })
      end
      def calendar_event(event)
        %({
          "title": "#{translated_attribute event.full_title}",
          "start": "#{event.start.strftime("%FT%R")}",
          "end": "#{event.finish.strftime("%FT%R")}",
          "color": "#{event.color}",
          "url": "#{event.link}",
          "resourceId": "#{event.type}",
          "allDay": #{event.all_day?}
        })
      end

      def participatory_gantt(event)
        %({
          "id": "#{event.full_id}",
          "name": "#{translated_attribute event.full_title}",
          "start": "#{event.start.strftime("%FT%R")}",
          "dependencies": "#{event.parent}",
          "end": "#{event.finish.strftime("%FT%R")}"
        })
      end

      def participatory_space_wrapper(&block)
        content_tag :main, class: "wrapper" do
          concat(capture(&block))
        end
      end

      def extended_navigation_bar(items, max_items: 5)
        return unless items.any?
        extra_items = []
        active_item = items.find { |item| item[:active] }

        render partial: "decidim/shared/extended_navigation_bar", locals: {
          items: items,
          extra_items: extra_items,
          active_item: active_item,
          max_items: 5
        }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
decidim-calendar-0.13.1.3 app/helpers/decidim/calendar/calendar_helper.rb