-
Notifications
You must be signed in to change notification settings - Fork 16
/
queue_tab.rb
75 lines (56 loc) · 1.52 KB
/
queue_tab.rb
1
2
3
4
5
6
7
8
9
10
11
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
# frozen_string_literal: true
class QueueTab
include ActiveModel::Model
validate :assignee_is_organization
attr_accessor :assignee, :show_regional_office_column
def initialize(args)
super
fail(Caseflow::Error::MissingRequiredProperty, message: errors.full_messages.join(", ")) unless valid?
end
def self.from_name(tab_name)
tab = subclasses.find { |subclass| subclass.tab_name == tab_name }
fail(Caseflow::Error::InvalidTaskTableTab, tab_name: tab_name) unless tab
tab
end
def to_hash
{
label: label,
name: name,
description: format(description, assignee.name),
columns: columns,
allow_bulk_assign: allow_bulk_assign?
}
end
def label; end
def self.tab_name; end
def tasks; end
def description; end
def columns; end
def name
self.class.tab_name
end
def allow_bulk_assign?
false
end
private
def on_hold_tasks
Task.includes(*task_includes).visible_in_queue_table_view.where(assigned_to: assignee).on_hold
end
def task_includes
[
{ appeal: [:available_hearing_locations, :claimants] },
:assigned_by,
:assigned_to,
:children,
:parent
]
end
def assignee_is_organization
errors.add(:assignee, COPY::TASK_PAGE_INVALID_ASSIGNEE_MESSAGE) unless assignee&.is_a?(Organization)
end
end
require_dependency "assigned_tasks_tab"
require_dependency "completed_tasks_tab"
require_dependency "on_hold_tasks_tab"
require_dependency "tracking_tasks_tab"
require_dependency "unassigned_tasks_tab"