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.
-
#plans ⇒ Object
readonly
Returns the value of attribute plans.
-
#start_date ⇒ Object
readonly
Returns the value of attribute start_date.
Instance Method Summary collapse
-
#initialize(plans:, calendar_events: Collavre::CalendarEvent.none) ⇒ PlansTimelineComponent
constructor
Accepts pre-filtered plans and calendar_events 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) ⇒ PlansTimelineComponent
Accepts pre-filtered plans and calendar_events from the controller
4 5 6 7 8 9 |
# File 'app/components/collavre/plans_timeline_component.rb', line 4 def initialize(plans:, calendar_events: Collavre::CalendarEvent.none) @start_date = Date.current - 30 @end_date = Date.current + 30 @plans = plans @calendar_events = calendar_events end |
Instance Attribute Details
#calendar_events ⇒ Object (readonly)
Returns the value of attribute calendar_events.
11 12 13 |
# File 'app/components/collavre/plans_timeline_component.rb', line 11 def calendar_events @calendar_events end |
#end_date ⇒ Object (readonly)
Returns the value of attribute end_date.
11 12 13 |
# File 'app/components/collavre/plans_timeline_component.rb', line 11 def end_date @end_date end |
#plans ⇒ Object (readonly)
Returns the value of attribute plans.
11 12 13 |
# File 'app/components/collavre/plans_timeline_component.rb', line 11 def plans @plans end |
#start_date ⇒ Object (readonly)
Returns the value of attribute start_date.
11 12 13 |
# File 'app/components/collavre/plans_timeline_component.rb', line 11 def start_date @start_date end |
Instance Method Details
#plan_data ⇒ Object
Called after component enters render context - safe to use helpers here
14 15 16 |
# File 'app/components/collavre/plans_timeline_component.rb', line 14 def plan_data @plan_data ||= @plans.map { |plan| plan_item(plan) } + @calendar_events.map { |event| calendar_item(event) } end |