Class: NavigationConfiguration
Constant Summary
collapse
- ADMIN =
1
- PAYROLL =
14
- PAYROLL_SYSTEM_RECORD =
NavigationConfiguration.find_by(name: 'payroll_system_record')&.id
- EDI =
NavigationConfiguration.find_by(name: 'edi')&.id
- EDI_SYSTEM_RECORD =
NavigationConfiguration.find_by(name: 'edi_system_record')&.id
- EMPLOYEE_PORTAL =
NavigationConfiguration.find_by(name: 'employee_portal')&.id
- AI_PLATFORM_SYSTEM_RECORD =
NavigationConfiguration.find_by(name: 'ai_platform_system_record')&.id
- BLANK_PATH =
'/app/blank'
Instance Method Summary
collapse
define_decrypted_attribute, define_decrypted_attributes, #errors_in_bullet_points, primary_connection, special_connection
Instance Method Details
#allows?(controller, action) ⇒ Boolean
110
111
112
113
114
115
116
117
118
119
120
121
|
# File 'app/models/navigation_configuration.rb', line 110
def allows?(controller, action)
return true
return false unless active
return false unless controller && action
(navigation_group_ids & navigation_record_permission.navigation_group_ids).any? ||
( & navigation_record_permission.).any? ||
(navigation_item_ids & navigation_record_permission.navigation_item_ids).any?
end
|
#associate_from_checkbox_tree_data(modules, allow_system_records = false) ⇒ Object
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
|
# File 'app/models/navigation_configuration.rb', line 67
def associate_from_checkbox_tree_data(modules, allow_system_records = false)
process_node = lambda do |node, depth|
case depth
when 1
return unless node['checked']
group = NavigationGroup.find_by(name: node['name'])
associate_groups([group]) if allow_system_records || !group.system_record?
when 2
return unless node['checked']
= NavigationHeader.find_by(name: node['name'])
([]) if allow_system_records || !.system_record?
when 3
return unless node['checked']
item = NavigationItem.find_by(name: node['name'])
associate_items([item]) if allow_system_records || !item.system_record?
end
end
traverse_and_process = lambda do |nodes, depth|
nodes.each do |node|
if node['children']
traverse_and_process.call(node['children'], depth + 1)
else
process_node.call(node, depth)
end
end
end
clear_associations
traverse_and_process.call(modules['children'], 1) if modules['children']
end
|
#associate_groups(groups) ⇒ Object
59
60
61
62
63
64
65
|
# File 'app/models/navigation_configuration.rb', line 59
def associate_groups(groups)
groups.each do |group|
next if navigation_groups.include?(group)
navigation_groups << group
end
end
|
50
51
52
53
54
55
56
57
|
# File 'app/models/navigation_configuration.rb', line 50
def ()
.each do ||
next if .include?()
<<
associate_groups([.navigation_group])
end
end
|
#associate_items(items) ⇒ Object
41
42
43
44
45
46
47
48
|
# File 'app/models/navigation_configuration.rb', line 41
def associate_items(items)
items.each do |item|
next if navigation_items.include?(item)
navigation_items << item
([item.])
end
end
|
#authorizes_navigation?(name) ⇒ Boolean
102
103
104
105
106
107
108
|
# File 'app/models/navigation_configuration.rb', line 102
def authorizes_navigation?(name)
return false unless name
navigation_items.exists?(name: name) ||
.exists?(name: name) ||
navigation_groups.exists?(name: name)
end
|
#clear_associations ⇒ Object
35
36
37
38
39
|
# File 'app/models/navigation_configuration.rb', line 35
def clear_associations
navigation_items.clear
.clear
navigation_groups.clear
end
|
#home_path ⇒ Object
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
# File 'app/models/navigation_configuration.rb', line 124
def home_path
return BLANK_PATH unless active
navigation_groups.where(system_record: false).order(:order).each do |group|
return group.path if group.path
group.(self).each do ||
return .path if .path
.items_for_configuration(self).each do |item|
return item.path if item.path
end
end
end
BLANK_PATH
end
|
#navigation_data ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'app/models/navigation_configuration.rb', line 18
def navigation_data
navigation_groups.order(:order).map do |group|
group_data = group.attributes
group_data['label'] = I18n.t("navigation.group.#{group.name}")
group_data['navigation_headers'] = group.(self).map do ||
= .attributes
['label'] = I18n.t("navigation.header.#{.name}")
['navigation_items'] = .items_for_configuration(self).map(&:attributes)
['navigation_items'].each do |item|
item['label'] = I18n.t("navigation.item.#{item['name']}")
end
end
group_data
end
end
|