Class: Collavre::PlansTimelineComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/collavre/plans_timeline_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(plans:, calendar_events: Collavre::CalendarEvent.none, registrations: [], show_registrations: false, modifications: [], show_modifications: false) ⇒ PlansTimelineComponent

Accepts pre-filtered plans, calendar_events, registrations and modifications from the controller



4
5
6
7
8
9
10
11
12
13
# File 'app/components/collavre/plans_timeline_component.rb', line 4

def initialize(plans:, calendar_events: Collavre::CalendarEvent.none, registrations: [], show_registrations: false, modifications: [], show_modifications: false)
  @start_date = Date.current - 30
  @end_date = Date.current + 30
  @plans = plans
  @calendar_events = calendar_events
  @registrations = registrations
  @show_registrations = show_registrations
  @modifications = modifications
  @show_modifications = show_modifications
end

Instance Attribute Details

#calendar_eventsObject (readonly)

Returns the value of attribute calendar_events.



15
16
17
# File 'app/components/collavre/plans_timeline_component.rb', line 15

def calendar_events
  @calendar_events
end

#end_dateObject (readonly)

Returns the value of attribute end_date.



15
16
17
# File 'app/components/collavre/plans_timeline_component.rb', line 15

def end_date
  @end_date
end

#modificationsObject (readonly)

Returns the value of attribute modifications.



15
16
17
# File 'app/components/collavre/plans_timeline_component.rb', line 15

def modifications
  @modifications
end

#plansObject (readonly)

Returns the value of attribute plans.



15
16
17
# File 'app/components/collavre/plans_timeline_component.rb', line 15

def plans
  @plans
end

#registrationsObject (readonly)

Returns the value of attribute registrations.



15
16
17
# File 'app/components/collavre/plans_timeline_component.rb', line 15

def registrations
  @registrations
end

#show_modificationsObject (readonly)

Returns the value of attribute show_modifications.



15
16
17
# File 'app/components/collavre/plans_timeline_component.rb', line 15

def show_modifications
  @show_modifications
end

#show_registrationsObject (readonly)

Returns the value of attribute show_registrations.



15
16
17
# File 'app/components/collavre/plans_timeline_component.rb', line 15

def show_registrations
  @show_registrations
end

#start_dateObject (readonly)

Returns the value of attribute start_date.



15
16
17
# File 'app/components/collavre/plans_timeline_component.rb', line 15

def start_date
  @start_date
end

Instance Method Details

#plan_dataObject

Called after component enters render context - safe to use helpers here



18
19
20
21
22
23
# File 'app/components/collavre/plans_timeline_component.rb', line 18

def plan_data
  @plan_data ||= @plans.map { |plan| plan_item(plan) } +
                 @calendar_events.map { |event| calendar_item(event) } +
                 @registrations.map { |creative| registration_item(creative) } +
                 @modifications.map { |creative| modification_item(creative) }
end