Class: InnerPlan::Lists::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/lists/new_view.rb

Instance Method Summary collapse

Constructor Details

#initialize(list:) ⇒ NewView

Returns a new instance of NewView.



9
10
11
# File 'app/components/inner_plan/lists/new_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
# File 'app/components/inner_plan/lists/new_view.rb', line 13

def template
  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
    end
    div(class: "row") { div(class: "col-6") { h1(class: "h2") { "New list" } } }
    render(InnerPlan::ProgressBarSeparatorComponent.new)
  end

  form_with model: @list do |f|
    plain f.object.errors.full_messages.to_sentence
    div(class: "mb-3") do
      plain f.text_field :title,
                        class: "form-control form-control-lg",
                        placeholder: "Name this list...",
                        autofocus: true
    end

    div(class: "mb-3") do
      plain f.text_area :description,
                        class: 'form-control',
                        placeholder: "Add extra details or attach a file..."
    end

    plain f.submit "Create list", class: "btn btn-success btn-sm me-2"
    link_to "Cancel", helpers.lists_path, class: "btn btn-outline-secondary btn-sm"
  end
end