Class: Decidim::Calendar::EventPresenter
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Decidim::Calendar::EventPresenter
- Defined in:
- app/presenters/decidim/calendar/event_presenter.rb
Instance Method Summary collapse
- #all_day? ⇒ Boolean
- #color ⇒ Object
- #finish ⇒ Object
- #full_id ⇒ Object
- #full_title ⇒ Object
- #link ⇒ Object
- #parent ⇒ Object
- #start ⇒ Object
- #type ⇒ Object
Instance Method Details
#all_day? ⇒ Boolean
99 100 101 |
# File 'app/presenters/decidim/calendar/event_presenter.rb', line 99 def all_day? (start.to_date..finish.to_date).count > 1 end |
#color ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/presenters/decidim/calendar/event_presenter.rb', line 6 def color case __getobj__.class.name when "Decidim::ParticipatoryProcessStep" "#238ff7" when "Decidim::Meetings::Meeting" "#fabc6c" when "Decidim::Calendar::ExternalEvent" "#5fbd4c" when "Decidim::Debates::Debate" "#d87537" when "Decidim::Consultation" "#A854BD" end end |
#finish ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 |
# File 'app/presenters/decidim/calendar/event_presenter.rb', line 76 def finish @finish ||= if respond_to?(:end_date) end_date elsif respond_to?(:end_at) end_at elsif respond_to?(:end_voting_date) end_voting_date else end_time end end |
#full_id ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'app/presenters/decidim/calendar/event_presenter.rb', line 36 def full_id case __getobj__.class.name when "Decidim::ParticipatoryProcessStep" "#{participatory_process.id}-#{id}" else id end end |
#full_title ⇒ Object
88 89 90 91 92 93 94 95 96 97 |
# File 'app/presenters/decidim/calendar/event_presenter.rb', line 88 def full_title @full_title ||= case __getobj__.class.name when "Decidim::ParticipatoryProcessStep" participatory_process.title.merge(title) do |_k, v, o| "#{v} - #{o}" end else title end end |
#link ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'app/presenters/decidim/calendar/event_presenter.rb', line 52 def link return url if respond_to?(:url) @link ||= case __getobj__.class.name when "Decidim::ParticipatoryProcessStep" Decidim::ResourceLocatorPresenter.new(participatory_process).url else Decidim::ResourceLocatorPresenter.new(__getobj__).url end end |
#parent ⇒ Object
45 46 47 48 49 50 |
# File 'app/presenters/decidim/calendar/event_presenter.rb', line 45 def parent case __getobj__.class.name when "Decidim::ParticipatoryProcessStep" "#{participatory_process.id}-#{participatory_process.steps.find_by(position: position - 1).id}" if position.positive? end end |
#start ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'app/presenters/decidim/calendar/event_presenter.rb', line 63 def start # byebug @start ||= if respond_to?(:start_date) start_date elsif respond_to?(:start_at) start_at elsif respond_to?(:start_voting_date) start_voting_date else start_time end end |
#type ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/presenters/decidim/calendar/event_presenter.rb', line 21 def type case __getobj__.class.name when "Decidim::ParticipatoryProcessStep" "participatory_step" when "Decidim::Meetings::Meeting" "meeting" when "Decidim::Calendar::ExternalEvent" "external_event" when "Decidim::Debates::Debate" "debate" when "Decidim::Consultation" "consultation" end end |