Class: InnerPlan::Groups::NewView

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/new_view.rb

Instance Method Summary collapse

Constructor Details

#initialize(group:) ⇒ NewView

Returns a new instance of NewView.



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

def initialize(group:)
  @group = group
  @list = group.list
end

Instance Method Details

#templateObject



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
# File 'app/components/inner_plan/groups/new_view.rb', line 14

def template
  form_with model: @group, url: helpers.list_groups_path(@list) 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(active: true) { plain " New group " }
      end
      div(class: "row") do
        div(class: "col-6") do
          h1(class: "h2") do
            plain f.text_field :title,
                              placeholder: "Name this group...",
                              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"
      link_to "Cancel", @list, class: "btn btn-outline-secondary btn-sm"
    end
  end
end