Class: Collavre::PlansTimelineComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Collavre::PlansTimelineComponent
- Defined in:
- app/components/collavre/plans_timeline_component.rb
Instance Attribute Summary collapse
-
#calendar_events ⇒ Object
readonly
Returns the value of attribute calendar_events.
-
#end_date ⇒ Object
readonly
Returns the value of attribute end_date.
-
#modifications ⇒ Object
readonly
Returns the value of attribute modifications.
-
#plans ⇒ Object
readonly
Returns the value of attribute plans.
-
#registrations ⇒ Object
readonly
Returns the value of attribute registrations.
-
#show_modifications ⇒ Object
readonly
Returns the value of attribute show_modifications.
-
#show_registrations ⇒ Object
readonly
Returns the value of attribute show_registrations.
-
#start_date ⇒ Object
readonly
Returns the value of attribute start_date.
Instance Method Summary collapse
-
#initialize(plans:, calendar_events: Collavre::CalendarEvent.none, registrations: [], show_registrations: false, modifications: [], show_modifications: false) ⇒ PlansTimelineComponent
constructor
Accepts pre-filtered plans, calendar_events, registrations and modifications from the controller.
-
#plan_data ⇒ Object
Called after component enters render context - safe to use helpers here.
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_events ⇒ Object (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_date ⇒ Object (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 |
#modifications ⇒ Object (readonly)
Returns the value of attribute modifications.
15 16 17 |
# File 'app/components/collavre/plans_timeline_component.rb', line 15 def modifications @modifications end |
#plans ⇒ Object (readonly)
Returns the value of attribute plans.
15 16 17 |
# File 'app/components/collavre/plans_timeline_component.rb', line 15 def plans @plans end |
#registrations ⇒ Object (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_modifications ⇒ Object (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_registrations ⇒ Object (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_date ⇒ Object (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_data ⇒ Object
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 |