Class: InnerPlan::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/inner_plan/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



12
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/inner_plan/configuration.rb', line 12

def initialize
  @user_class_name = 'User'
  @current_user_method = :current_user
  @additional_importmap_modules = []

  # Tasks::EditView rows
  due_on_item = proc { |context:, form:|
    InnerPlan::Tasks::Form::ItemComponent.new(icon: Phlex::Icons::Tabler::CalendarDue, title: 'Due on') do
      context.plain form.date_field :due_on,
                                    class: "form-control",
                                    autofocus: (context.focus == :due_on)
    end
  }

  description_item = proc { |context:, form:|
    InnerPlan::Tasks::Form::ItemComponent.new(icon: Phlex::Icons::Tabler::FileText, title: 'Description') do
      context.plain form.text_area(:description, class: 'form-control', autofocus: (context.focus == :description))
    end
  }

  @task_edit_view_rows = InnerPlan::SmartArray.new([
    InnerPlan::SmartArray::Item.new(:primary_row, {}, InnerPlan::SmartArray.new([
      InnerPlan::SmartArray::Item.new(:due_on, { span: 6 }, due_on_item),
    ])),

    InnerPlan::SmartArray::Item.new(:secondary_row, {}, InnerPlan::SmartArray.new([
      InnerPlan::SmartArray::Item.new(:description, { span: 12 }, description_item)
    ]))
  ])

  # Tasks::ShowView rows
  due_on_item = proc { |context:|
    InnerPlan::Tasks::Show::ItemComponent.new(icon: Phlex::Icons::Tabler::CalendarDue, title: 'Due on') do
      context.a(
        href: (context.helpers.edit_task_path(context.task, focus: :due_on)),
        class:
          (
            context.class_names(
              "text-decoration-none",
              "text-body-tertiary" => context.task.due_on.blank?,
              "text-reset" => context.task.due_on.present?
            )
          )
      ) do
        if context.task.due_on
          context.plain context.task.due_on.strftime("%a, %b %e, %Y")
        else
          context.plain " Select a date... "
        end
      end
    end
  }

  description_item = proc { |context:|
    InnerPlan::Tasks::Show::ItemComponent.new(icon: Phlex::Icons::Tabler::FileText, title: 'Description') do
      if context.task.description.present?
        context.plain context.description.to_s
      else
        context.a(
          href: (context.helpers.edit_task_path(context.task, focus: :description)),
          class:
            (
              context.class_names(
                "text-decoration-none",
                "text-body-tertiary" => context.task.description.blank?,
                "text-reset" => context.task.description.present?
              )
            )
        ) { " Click to add description... " }
      end
    end
  }

  created_by_item = proc { |context:|
    InnerPlan::Tasks::Show::ItemComponent.new(icon: Phlex::Icons::Tabler::CirclePlus, title: 'Created By') do
      context.div(class: "text-body-tertiary") do
        context.render(InnerPlan::UserWithAvatarComponent.new(context.task.user))
        context.plain " on "
        context.plain context.task.created_at.strftime("%a, %b %e, %Y")
      end
    end
  }

  @task_show_view_rows = InnerPlan::SmartArray.new([
    InnerPlan::SmartArray::Item.new(:primary_row, {}, InnerPlan::SmartArray.new([
      InnerPlan::SmartArray::Item.new(:due_on, { span: 6 }, due_on_item),
    ])),

    InnerPlan::SmartArray::Item.new(:secondary_row, {}, InnerPlan::SmartArray.new([
      InnerPlan::SmartArray::Item.new(:description, { span: 12 }, description_item)
    ])),

    InnerPlan::SmartArray::Item.new(:tertiary_row, {}, InnerPlan::SmartArray.new([
      InnerPlan::SmartArray::Item.new(:created_by, { span: 12 }, created_by_item)
    ]))
  ])

  @task_row_addons = InnerPlan::SmartArray.new([
    ::InnerPlan::SmartArray::Item.new(:group, {}, 'InnerPlan::Tasks::Row::GroupAddonComponent'),
    ::InnerPlan::SmartArray::Item.new(:description, {}, 'InnerPlan::Tasks::Row::DescriptionAddonComponent'),
    ::InnerPlan::SmartArray::Item.new(:due_on, {}, 'InnerPlan::Tasks::Row::DueOnAddonComponent'),
  ])
end

Instance Attribute Details

#additional_importmap_modulesObject

Returns the value of attribute additional_importmap_modules.



5
6
7
# File 'lib/inner_plan/configuration.rb', line 5

def additional_importmap_modules
  @additional_importmap_modules
end

#current_user_methodObject

Returns the value of attribute current_user_method.



5
6
7
# File 'lib/inner_plan/configuration.rb', line 5

def current_user_method
  @current_user_method
end

#task_edit_view_rowsObject

Returns the value of attribute task_edit_view_rows.



5
6
7
# File 'lib/inner_plan/configuration.rb', line 5

def task_edit_view_rows
  @task_edit_view_rows
end

#task_row_addonsObject

Returns the value of attribute task_row_addons.



5
6
7
# File 'lib/inner_plan/configuration.rb', line 5

def task_row_addons
  @task_row_addons
end

#task_show_view_rowsObject

Returns the value of attribute task_show_view_rows.



5
6
7
# File 'lib/inner_plan/configuration.rb', line 5

def task_show_view_rows
  @task_show_view_rows
end

#user_class_nameObject

Returns the value of attribute user_class_name.



5
6
7
# File 'lib/inner_plan/configuration.rb', line 5

def user_class_name
  @user_class_name
end