Class: InnerPlan::Lists::RowComponent

Inherits:
Phlex::HTML
  • Object
show all
Includes:
Phlex::Rails::Helpers::DOMID, Phlex::Rails::Helpers::LinkTo
Defined in:
app/components/inner_plan/lists/row_component.rb

Instance Method Summary collapse

Constructor Details

#initialize(list, context: nil) ⇒ RowComponent

Returns a new instance of RowComponent.



6
7
8
9
# File 'app/components/inner_plan/lists/row_component.rb', line 6

def initialize(list, context: nil)
  @list = list
  @context = context
end

Instance Method Details

#templateObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/components/inner_plan/lists/row_component.rb', line 11

def template
  lists = list.lists.ordered_by_position

  div(data: { update_url: helpers.update_position_list_path(list), id: list.id }, class: "mb-5") {
    div(class: "d-flex w-100 mb-1") {
      render(InnerPlan::Lists::Row::HandleComponent.new(list))

      div(class: "ms-1 w-100") {
        small(class: "text-body-tertiary") {
          plain("#{list.tasks.completed.count}/#{list.tasks.count} completed")
        }

        h3(class: "h5") {
          link_to list.title, list, class: 'text-reset'
        }

        if list.description.present?
          div(class: "mb-2") {
            list.description
          }
        end
      }
    }

    # Ongoing tasks
    render(InnerPlan::Lists::OngoingTasksComponent.new(list, context: context))

    # Groups
    render(InnerPlan::Groups::RowsComponent.new(lists, list: list, context: context))

    # Add new task form
    last_group = lists.to_a.last || list
    div(class: "mt-2 mb-4", id: dom_id(last_group, :add_task)) {
      render InnerPlan::Tasks::InlineFormView.new(list: last_group)
    }

    render(InnerPlan::Lists::CompletedTasksComponent.new(list, context: context))
  }
end