Class: InnerPlan::Tasks::InlineFormView

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/tasks/inline_form_view.rb

Instance Method Summary collapse

Constructor Details

#initialize(task: InnerPlan::Task.new, list:, form_visible: false) ⇒ InlineFormView

Returns a new instance of InlineFormView.



9
10
11
12
13
# File 'app/components/inner_plan/tasks/inline_form_view.rb', line 9

def initialize(task: InnerPlan::Task.new, list:, form_visible: false)
  @task = task
  @list = list
  @form_visible = form_visible
end

Instance Method Details

#templateObject



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/tasks/inline_form_view.rb', line 15

def template
  div(
    data_controller: "task-inline-form",
    data_task_inline_form_form_visible_value:
      (@form_visible == true)
  ) do
    form_with model: @task,
              url: helpers.list_tasks_path(@list),
              class: ("d-none" if @form_visible != true),
              data: {
                task_inline_form_target: :form
              } do |f|
      div(class: "d-flex w-100 mb-1") do
        div(
          class: "align-top me-2 text-muted invisible",
          style: "margin-top:-.05 rem"
        ) do
          render(Phlex::Icons::Tabler::GripVertical.new(width: 20, height: 20))
        end
        div(
          class: "align-top me-2",
          style: "width:2 rem;height:2 rem;margin-top:-.12 rem"
        ) do
          button(class: "btn p-0 opacity-50") do
            render(Phlex::Icons::Tabler::SquareRounded.new(width: 24, height: 24))
          end
        end
        div(class: "form-check-label ms-1 w-100") do
          plain f.text_field :title,
                            autocomplete: "off",
                            class: "form-control w-100",
                            data: {
                              task_inline_form_target: :defaultInput,
                              action: "keydown.esc->task-inline-form#escPressed"
                            }
        end
      end
    end
    a(
      href: "#",
      data_action: "task-inline-form#togglerClicked",
      data_task_inline_form_target: "toggler",
      class: "btn btn-outline-secondary btn-sm ms-tasks-element"
    ) { " Add a task " }
  end
end