Class: InnerPlan::Lists::CompletedTasksComponent
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- InnerPlan::Lists::CompletedTasksComponent
- Defined in:
- app/components/inner_plan/lists/completed_tasks_component.rb
Instance Method Summary collapse
-
#initialize(list, limit: 3, context: nil) ⇒ CompletedTasksComponent
constructor
A new instance of CompletedTasksComponent.
- #template ⇒ Object
Constructor Details
#initialize(list, limit: 3, context: nil) ⇒ CompletedTasksComponent
Returns a new instance of CompletedTasksComponent.
3 4 5 6 7 |
# File 'app/components/inner_plan/lists/completed_tasks_component.rb', line 3 def initialize(list, limit: 3, context: nil) @list = list @limit = limit @context = context end |
Instance Method Details
#template ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/components/inner_plan/lists/completed_tasks_component.rb', line 9 def template truncate = @limit.positive? scope = @list.root? ? @list.tasks_including_groups : @list.tasks scope = scope.completed scope = truncate ? scope.limit(@limit) : scope render InnerPlan::Tasks::RowsComponent.new(scope, list: @list, context: context, id_key: :completed_tasks) do if truncate completed_tasks_count = @list.tasks.completed.count if (completed_tasks_count - @limit).positive? div(class: "mt-2 ms-tasks-element") { a(href: helpers.list_path(@list, anchor: :completed), class: "text-body-tertiary") { plain "And #{completed_tasks_count - @limit} more completed to-dos..." } } end end end end |