From 8fc9372246d7f87c1ec067221cf17a1ee35cbbd6 Mon Sep 17 00:00:00 2001 From: Sabrina Baggett Date: Thu, 18 Jun 2026 10:36:53 -0700 Subject: [PATCH] add direct report section #127 --- services/app/api/employees.js | 3 ++- .../ucdlib-iam-page-separation-single.js | 19 ++++++++++++++++++- .../ucdlib-iam-page-separation-single.tpl.js | 10 ++++++++++ services/lib/cork/models/EmployeeModel.js | 6 ++++-- services/lib/cork/services/EmployeeService.js | 3 ++- 5 files changed, 36 insertions(+), 5 deletions(-) diff --git a/services/app/api/employees.js b/services/app/api/employees.js index addee00..f0df6f8 100644 --- a/services/app/api/employees.js +++ b/services/app/api/employees.js @@ -8,7 +8,8 @@ export default (api) => { * Returns blank array if no reports */ api.get('/employees/direct-reports', async (req, res) => { - const iamId = req.auth.token.iamId; + const iamId = req.query.iamId || req.auth.token.iamId; + if ( !iamId ) { res.json([]); return; diff --git a/services/app/client/src/elements/pages/ucdlib-iam-page-separation-single.js b/services/app/client/src/elements/pages/ucdlib-iam-page-separation-single.js index e88c485..bc81f99 100644 --- a/services/app/client/src/elements/pages/ucdlib-iam-page-separation-single.js +++ b/services/app/client/src/elements/pages/ucdlib-iam-page-separation-single.js @@ -62,7 +62,7 @@ export default class UcdlibIamPageSeparationSingle extends Mixin(LitElement) appComponent : new AppComponentController(this), } - this._injectModel('AppStateModel', 'SeparationModel', 'RtModel', 'AuthModel'); + this._injectModel('AppStateModel', 'EmployeeModel', 'SeparationModel', 'RtModel', 'AuthModel'); } /** @@ -106,6 +106,7 @@ export default class UcdlibIamPageSeparationSingle extends Mixin(LitElement) this.missingUid = payload.statusId == 9; const ad = payload.additionalData; this.request = payload; + this.iamId = payload.iamId || ''; this.firstName = ad?.employeeFirstName || ''; this.lastName = ad?.employeeLastName || ''; this.employeeId = ad?.employeeId || ''; @@ -119,6 +120,8 @@ export default class UcdlibIamPageSeparationSingle extends Mixin(LitElement) this.isActiveStatus = payload.isActiveStatus; this.status = payload.statusName || ''; this.statusDescription = payload.statusDescription || ''; + this.removedFromSystems = ad?.removedFromSystems || []; + await this.getDirectReports(); this.showDeprovisionButton = this.AuthModel.isAdmin && (Array.isArray(ad?.removedFromSystems) && !ad.removedFromSystems.find(s => s?.value === 'ucdlib-iam-db')); @@ -147,6 +150,20 @@ export default class UcdlibIamPageSeparationSingle extends Mixin(LitElement) ]; } + /** + * @description Get direct reports of separated employee for display if employee is currently in system. + */ + async getDirectReports(){ + if(this.removedFromSystems?.length) return []; + const r = await this.EmployeeModel.getDirectReports(this.iamId); + if ( r.state === 'loaded' ){ + this.directReports = r.payload; + } else if ( r.state === 'error' ){ + this.AppStateModel.showError('Error fetching direct reports'); + this.directReports = []; + } + } + /** * @description Opens the deprovision employee confirmation modal. Attached to button in side panel */ diff --git a/services/app/client/src/elements/pages/ucdlib-iam-page-separation-single.tpl.js b/services/app/client/src/elements/pages/ucdlib-iam-page-separation-single.tpl.js index 89ab237..3a66d40 100644 --- a/services/app/client/src/elements/pages/ucdlib-iam-page-separation-single.tpl.js +++ b/services/app/client/src/elements/pages/ucdlib-iam-page-separation-single.tpl.js @@ -16,6 +16,16 @@ export function render() {
${this.department}
${this.separationDate}
+
+

Current Direct Reports

+
No direct reports found.
+ ${this.directReports?.map(r => html` +
${r.firstName} ${r.lastName}
+
${r.iamId}
+
+ `)} +
+

Supervisor

${this.supervisorName}
diff --git a/services/lib/cork/models/EmployeeModel.js b/services/lib/cork/models/EmployeeModel.js index 7c413a5..f0a2e16 100644 --- a/services/lib/cork/models/EmployeeModel.js +++ b/services/lib/cork/models/EmployeeModel.js @@ -21,9 +21,11 @@ class EmployeeModel extends BaseModel { /** * @description Returns all direct reports for the current user + * @param {String} iamId - optional, defaults to current user + * @returns {Object} {total, results} */ - getDirectReports(){ - return this.service.getDirectReports(); + getDirectReports(iamId=''){ + return this.service.getDirectReports(iamId); } /** diff --git a/services/lib/cork/services/EmployeeService.js b/services/lib/cork/services/EmployeeService.js index 7ef6969..39f2672 100644 --- a/services/lib/cork/services/EmployeeService.js +++ b/services/lib/cork/services/EmployeeService.js @@ -13,7 +13,7 @@ class EmployeeService extends BaseService { return `/api/employees`; } - async getDirectReports(){ + async getDirectReports(iamId=''){ const store = this.store.data.directReports; const id = 'directReports'; @@ -21,6 +21,7 @@ class EmployeeService extends BaseService { id, store, () => this.request({ url : `${this.baseUrl}/direct-reports`, + qs: { iamId }, checkCached : () => store.get(id), onUpdate : resp => this.store.set( {...resp, id},