Module: EmployeeWatchList

Extended by:
ActiveSupport::Concern
Included in:
Employee
Defined in:
app/models/concerns/employee_watch_list.rb

Overview

Watch-list and monitoring-group management for Employee.

Instance Method Summary collapse

Instance Method Details

#effective_watch_list_ids(include_role_list: true) ⇒ Object



27
28
29
30
31
32
33
# File 'app/models/concerns/employee_watch_list.rb', line 27

def effective_watch_list_ids(include_role_list: true)
  list = []
  list += selected_watch_list_roles_employees.pluck(:id) if include_role_list && selected_watch_list_role_ids.present?
  list += selected_watch_list_employee_ids
  list << id if list.empty?
  list.uniq
end

#monitor_group_sms_numbers=(val) ⇒ Object



35
36
37
# File 'app/models/concerns/employee_watch_list.rb', line 35

def monitor_group_sms_numbers=(val)
  employee_record.monitor_group_sms_numbers = val || false
end

#monitor_unlinked_extensions=(val) ⇒ Object



39
40
41
# File 'app/models/concerns/employee_watch_list.rb', line 39

def monitor_unlinked_extensions=(val)
  employee_record.monitor_unlinked_extensions = val || false
end

#selected_watch_list_employee_idsObject



19
20
21
# File 'app/models/concerns/employee_watch_list.rb', line 19

def selected_watch_list_employee_ids
  employee_record&.watch_list_ids || []
end

#selected_watch_list_employee_ids=(val) ⇒ Object



23
24
25
# File 'app/models/concerns/employee_watch_list.rb', line 23

def selected_watch_list_employee_ids=(val)
  employee_record.watch_list_ids = (val || []).compact.uniq
end

#selected_watch_list_role_idsObject



7
8
9
# File 'app/models/concerns/employee_watch_list.rb', line 7

def selected_watch_list_role_ids
  employee_record&.watch_list_role_ids || []
end

#selected_watch_list_role_ids=(val) ⇒ Object



11
12
13
# File 'app/models/concerns/employee_watch_list.rb', line 11

def selected_watch_list_role_ids=(val)
  employee_record.watch_list_role_ids = (val || []).compact.uniq
end

#selected_watch_list_roles_employeesObject



15
16
17
# File 'app/models/concerns/employee_watch_list.rb', line 15

def selected_watch_list_roles_employees
  Employee.active_employees.joins(account: :roles).where(roles: { id: selected_watch_list_role_ids })
end

#watch_listObject



43
44
45
# File 'app/models/concerns/employee_watch_list.rb', line 43

def watch_list
  Employee.active_employees.sorted
end