Class: InnerPlan::Lists::ShowView

Inherits:
ApplicationView show all
Includes:
Phlex::Rails::Helpers::ContentTag, Phlex::Rails::Helpers::DOMID, Phlex::Rails::Helpers::LinkTo, Phlex::Rails::Helpers::Routes
Defined in:
app/components/inner_plan/lists/show_view.rb

Instance Method Summary collapse

Constructor Details

#initialize(list:) ⇒ ShowView

Returns a new instance of ShowView.



8
9
10
# File 'app/components/inner_plan/lists/show_view.rb', line 8

def initialize(list:)
  @list = list
end

Instance Method Details

#templateObject



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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'app/components/inner_plan/lists/show_view.rb', line 12

def template
  lists = @list.lists.ordered_by_position

  (:turbo_frame, id: (dom_id(@list, :header))) do
    header do
      render(InnerPlan::BreadcrumbsComponent.new) do |c|
        c.with_breadcrumb do
          link_to "Home", helpers.root_path, class: "text-reset", data: { turbo_frame: :_top }
        end
        c.with_breadcrumb(active: true) { "List ##{@list.id}" }
      end
      div(class: "row") do
        div(class: "col-10") do
          h1(class: "h2") do
            link_to @list.title, helpers.edit_list_path(@list), class: "text-reset text-decoration-none"
            small(class: "fs-6 text-body-tertiary ms-2") do
              plain @list.tasks.completed.count
              plain "/"
              plain @list.tasks.count
            end
          end
        end
        div(class: "col-2 text-end") do
          render(InnerPlan::Lists::ShowMenuComponent.new(@list))
        end
      end
      render(
        InnerPlan::ProgressBarSeparatorComponent.new(
          completed: @list.tasks.completed.count,
          total: @list.tasks.count
        )
      )

      div(class: "mb-4 mt-3") { @list.description }
    end
  end

  render(
  InnerPlan::Lists::OngoingTasksComponent.new(@list, context: :lists_show)
)

render(
  InnerPlan::Groups::RowsComponent.new(
    lists.ordered_by_position,
    list: @list,
    context: :lists_show
  )
)

last_group = lists.to_a.last || @list

(:div, class: "mt-2 mb-4", id: dom_id(last_group, :add_task)) do
  render InnerPlan::Tasks::InlineFormView.new(list: last_group)
end

render(
  InnerPlan::Lists::CompletedTasksComponent.new(
    @list,
    context: :lists_show,
    limit: 0
  )
)
end