Class: InnerPlan::Tasks::ShowView

Inherits:
ApplicationView show all
Includes:
Phlex::Rails::Helpers::ClassNames, Phlex::Rails::Helpers::LinkTo, Phlex::Rails::Helpers::Routes
Defined in:
app/components/inner_plan/tasks/show_view.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(task:) ⇒ ShowView

Returns a new instance of ShowView.



9
10
11
# File 'app/components/inner_plan/tasks/show_view.rb', line 9

def initialize(task:)
  @task = task
end

Instance Attribute Details

#taskObject (readonly)

Returns the value of attribute task.



7
8
9
# File 'app/components/inner_plan/tasks/show_view.rb', line 7

def task
  @task
end

Instance Method Details

#descriptionObject



72
73
74
# File 'app/components/inner_plan/tasks/show_view.rb', line 72

def description
  InnerPlan::Tasks::DescriptionRenderer.call(task: @task)[:description]
end

#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/tasks/show_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

      if @task.list.list.present?
        c.with_breadcrumb do
          link_to @task.list.list.title, @task.list.list, class: "text-reset"
        end
        c.with_breadcrumb do
          link_to @task.list.title, helpers.group_path(@task.list), class: "text-reset"
        end
      else
        c.with_breadcrumb do
          link_to @task.list.title, @task.list, class: "text-reset"
        end
      end

      c.with_breadcrumb(active: true) { "Task ##{@task.id}" }
    end
  end

  div(class: "d-flex mb-2") do
    div(class: "text-end me-2") do
      div(style: "display:block;margin-top:-0.25rem;margin-left:-0.8rem") do
        render(
          InnerPlan::Tasks::CompletedTogglerComponent.new(
            @task,
            context: :tasks_show,
            size: 39
          )
        )
      end
    end
    div(class: "w-100") do
      h1(class: "h3") do
        link_to @task.title,
                helpers.edit_task_path(@task, focus: :title),
                class: "text-reset text-decoration-none"
      end
    end
    div(class: "text-end") do
      render(InnerPlan::Tasks::ShowMenuComponent.new(@task))
    end
  end

  InnerPlan.configuration.task_show_view_rows.each do |row|
    render InnerPlan::Tasks::Form::RowComponent.new do |component|
      row.content.each do |item|
        component.with_column(span: item.options[:span]) do
          render(item.content.call(context: self))
        end
      end
    end
  end
end