Class: InnerPlan::Lists::EditView

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

Instance Method Summary collapse

Constructor Details

#initialize(list:) ⇒ EditView



9
10
11
# File 'app/components/inner_plan/lists/edit_view.rb', line 9

def initialize(list:)
  @list = list
end

Instance Method Details

#templateObject



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
# File 'app/components/inner_plan/lists/edit_view.rb', line 13

def template
  (:turbo_frame, id: dom_id(@list, :header)) do
    form_with model: @list do |f|
      header(class: "mb-3") do
        nav(aria_label: "breadcrumb", style: "--bs-breadcrumb-divider: '›';") do
          ol(class: "breadcrumb mb-0") do
            li(class: "breadcrumb-item text-body-tertiary") do
              a(href: helpers.root_path, class: "text-reset", data_turbo_frame: "_top") do
                "Home"
              end
            end
            li(
              class: "breadcrumb-item text-body-tertiary",
              aria_current: "page"
            ) { link_to "List ##{@list.id}", @list, class: "text-reset" }
            li(
              class: "breadcrumb-item active text-body-tertiary",
              aria_current: "page"
            ) { "Edit" }
          end
        end
        div(class: "row") do
          div(class: "col-6") do
            h1(class: "h2") do
              plain f.text_field :title,
                                class: "form-control form-control-lg mt-2"
            end
          end
        end
        render(
          InnerPlan::ProgressBarSeparatorComponent.new(
            completed: @list.tasks.completed.count,
            total: @list.tasks.count
          )
        )
      end
      div(class: "mb-2") do
        plain f.text_area :description,
                          class: 'form-control',
                          placeholder: "Add extra details or attach a file..."
      end
      div(class: "mb-5") do
        plain f.submit "Save changes", class: "btn btn-success btn-sm"
        link_to "Cancel", @list, class: "btn btn-outline-secondary btn-sm"
      end
    end
  end
end