Sep dept head form#140
Open
sbagg wants to merge 6 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for reassigning a department head during an employee separation workflow (UI capture/display plus backend/CLI deprovision handling), and extends “direct reports” fetching to optionally target a specific supervisor IAM ID.
Changes:
- Adds UI for selecting and displaying a “New Department Head” on separation create/single pages.
- Introduces
models.admin.separateDepartmentHead(separationId)and calls it during deprovision (API + CLI). - Updates the direct-reports API/client plumbing to accept an optional
iamIdquery parameter.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| services/lib/models/admin.js | Adds separateDepartmentHead and group head reassignment logic |
| services/lib/cork/services/EmployeeService.js | Adds iamId parameter support for direct reports requests |
| services/lib/cork/models/EmployeeModel.js | Propagates optional iamId argument + updates docs |
| services/cli/lib/employees.js | Calls separateDepartmentHead during CLI separation flow |
| services/app/client/src/elements/pages/ucdlib-iam-page-separation-single.tpl.js | Displays “New Department Head” on separation detail |
| services/app/client/src/elements/pages/ucdlib-iam-page-separation-single.js | Fetches/display data for the new department head |
| services/app/client/src/elements/pages/ucdlib-iam-page-separation-new.tpl.js | Conditionally shows employee search for new dept head |
| services/app/client/src/elements/pages/ucdlib-iam-page-separation-new.js | Captures/validates new dept head selection and persists to additionalData |
| services/app/api/separation.js | Calls separateDepartmentHead during deprovision |
| services/app/api/employees.js | Allows optional query override for direct reports IAM id |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.
Comments suppressed due to low confidence (1)
services/app/client/src/elements/pages/ucdlib-iam-page-separation-new.js:145
- When the selected employee is cleared (or changed),
isDepartmentHead/employeeNewHeadare not reset. This can leave the "New Department Head" field visible (and/or a staleemployeeNewHeadvalue) from a previous selection, which breaks the conditional UI and submit validation.
_onEmployeeStatusChange(e){
if ( e.detail.employee ){
this.employeeRecord = e.detail.employee;
this._isDepartmentHead();
} else {
this.employeeRecord = {};
}
}
Comment on lines
+542
to
+566
| // check if new department head is provided (newDepartmentHead is missing) | ||
| if( !separationRecord.additional_data?.newDepartmentHead ) { | ||
| let message = `No new department head provided; skipping reassignment.`; | ||
| return {error: false, message: message}; | ||
| } | ||
|
|
||
| let newHeadEmployee = await models.employees.getById(separationRecord.additional_data.newDepartmentHead, 'iamId', {returnGroups: true}); | ||
|
|
||
| if( newHeadEmployee.err ) { | ||
| let message = `Error retrieving new department head employee record: ${newHeadEmployee.err.message}`; | ||
| return {error: true, message: message}; | ||
| } | ||
| if ( !newHeadEmployee.res.rows.length ) { | ||
| let message = `No employee record found for new department head with iamId ${separationRecord.additional_data.newDepartmentHead}, skipping reassignment.`; | ||
| return {error: false, message: message}; | ||
| } | ||
|
|
||
| newHeadEmployee = newHeadEmployee.res.rows[0]; | ||
|
|
||
| //check if its the department head | ||
| const isDepartmentHead = separationRecord.additional_data?.groups?.some(g => g.type === 'Department' && g.isHead === true); | ||
|
|
||
| if ( !isDepartmentHead ) { | ||
| return {error: false, message: 'Employee is not a department head; skipping reassignment.'}; | ||
| } |
Comment on lines
+177
to
+183
| async _isDepartmentHead(){ | ||
| const groups = this.employeeRecord.groups; | ||
| if ( !groups || !groups.length ) return false; | ||
|
|
||
| this.isDepartmentHead = groups.some(g => g.type === 'Department' && g.isHead === true); | ||
| return this.isDepartmentHead; | ||
| } |
Comment on lines
+274
to
+283
| // separate department head if applicable | ||
| const departmentSeparationResult = await models.admin.separateDepartmentHead(separationId); | ||
| console.log('departmentSeparationResult', departmentSeparationResult); | ||
| if ( departmentSeparationResult.error ) { | ||
| console.error(departmentSeparationResult.message); | ||
| return res.status(400).json({ | ||
| error: true, | ||
| message: departmentSeparationResult.message | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#138