Class: InnerPlan::Groups::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/groups/edit_view.rb

Instance Method Summary collapse

Constructor Details

#initialize(group:) ⇒ EditView

Returns a new instance of EditView.



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

def initialize(group:)
  @group = group
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
61
62
63
64
65
66
67
68
69
70
# File 'app/components/inner_plan/groups/edit_view.rb', line 13

def template
  (:turbo_frame, id: (dom_id(@group, :header))) do
    form_with model: @group, url: helpers.group_path(@group) do |f|
      header(class: "mb-3") 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 do
            link_to @group.list.title,
                    @group.list,
                    class: "text-reset",
                    data: {
                      turbo_frame: :_top
                    }
          end
          c.with_breadcrumb do
            link_to @group.title,
                    helpers.group_path(@group),
                    class: "text-reset",
                    data: {
                      turbo_frame: :_top
                    }
          end
          c.with_breadcrumb(active: true) { plain " Edit sub " }
        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: @group.tasks.completed.count,
            total: @group.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 me-2"
        link_to "Cancel", @list, class: "btn btn-outline-secondary btn-sm"
      end
    end
    end
end