Module: Models::RepSearchable::ClassMethods
- Defined in:
- app/concerns/models/rep_searchable.rb
Overview
Class methods added to the including model.
Instance Method Summary collapse
-
#grouped_local_sales_reps_for_select(_include_unassigned_search: true) ⇒ Hash{String => Array<Array(String, Integer)>}
Grouped rep options limited to active local sales reps.
-
#grouped_primary_sales_reps_for_select(_include_unassigned_search: true) ⇒ Hash{String => Array<Array(String, Integer)>}
Grouped rep options limited to active primary sales reps.
-
#grouped_rep_for_select(active_reps: [], label: 'Reps - Active', include_unassigned_search: true) ⇒ Hash{String => Array<Array(String, Integer)>}
Builds a grouped rep option hash for a select input.
-
#grouped_secondary_sales_reps_for_select(_include_unassigned_search: true) ⇒ Hash{String => Array<Array(String, Integer)>}
Grouped rep options limited to active secondary sales reps.
-
#grouped_service_reps_for_select(_include_unassigned_search: true) ⇒ Hash{String => Array<Array(String, Integer)>}
Grouped rep options limited to active service reps.
-
#grouped_technical_reps_for_select(_include_unassigned_search: true) ⇒ Hash{String => Array<Array(String, Integer)>}
Grouped rep options limited to technical support reps.
Instance Method Details
#grouped_local_sales_reps_for_select(_include_unassigned_search: true) ⇒ Hash{String => Array<Array(String, Integer)>}
Grouped rep options limited to active local sales reps.
61 62 63 64 |
# File 'app/concerns/models/rep_searchable.rb', line 61 def grouped_local_sales_reps_for_select(_include_unassigned_search: true) active_reps = Employee.local_sales_reps.sorted.pluck(:full_name, :id) grouped_rep_for_select(active_reps: active_reps, label: 'Local Reps - Active') end |
#grouped_primary_sales_reps_for_select(_include_unassigned_search: true) ⇒ Hash{String => Array<Array(String, Integer)>}
Grouped rep options limited to active primary sales reps.
39 40 41 42 |
# File 'app/concerns/models/rep_searchable.rb', line 39 def grouped_primary_sales_reps_for_select(_include_unassigned_search: true) active_reps = Employee.primary_sales_reps.active_employees.sorted.pluck(:full_name, :id) grouped_rep_for_select(active_reps: active_reps, label: 'Primary Reps - Active') end |
#grouped_rep_for_select(active_reps: [], label: 'Reps - Active', include_unassigned_search: true) ⇒ Hash{String => Array<Array(String, Integer)>}
Builds a grouped rep option hash for a select input.
24 25 26 27 28 29 30 31 |
# File 'app/concerns/models/rep_searchable.rb', line 24 def grouped_rep_for_select(active_reps: [], label: 'Reps - Active', include_unassigned_search: true) all_reps = Employee.(active_only: false, exclude_ids: active_reps.filter_map(&:last)) res = {} res['Special Search'] = [%w[Unassigned Unassigned]] if include_unassigned_search res[label] = active_reps if active_reps.present? res['All Reps Past and Present'] = all_reps res end |
#grouped_secondary_sales_reps_for_select(_include_unassigned_search: true) ⇒ Hash{String => Array<Array(String, Integer)>}
Grouped rep options limited to active secondary sales reps.
50 51 52 53 |
# File 'app/concerns/models/rep_searchable.rb', line 50 def grouped_secondary_sales_reps_for_select(_include_unassigned_search: true) active_reps = Employee.secondary_sales_reps.sorted.pluck(:full_name, :id) grouped_rep_for_select(active_reps: active_reps, label: 'Secondary Reps - Active') end |
#grouped_service_reps_for_select(_include_unassigned_search: true) ⇒ Hash{String => Array<Array(String, Integer)>}
Grouped rep options limited to active service reps.
72 73 74 75 |
# File 'app/concerns/models/rep_searchable.rb', line 72 def grouped_service_reps_for_select(_include_unassigned_search: true) active_reps = Employee.(active_only: true) grouped_rep_for_select(active_reps: active_reps, label: 'Service Reps - Active') end |
#grouped_technical_reps_for_select(_include_unassigned_search: true) ⇒ Hash{String => Array<Array(String, Integer)>}
Grouped rep options limited to technical support reps.
83 84 85 86 |
# File 'app/concerns/models/rep_searchable.rb', line 83 def grouped_technical_reps_for_select(_include_unassigned_search: true) active_reps = Employee. grouped_rep_for_select(active_reps: active_reps, label: 'Technical Reps - Active') end |