Skip to content

Sep dept head form#140

Open
sbagg wants to merge 6 commits into
sandboxfrom
sepDeptHeadForm
Open

Sep dept head form#140
sbagg wants to merge 6 commits into
sandboxfrom
sepDeptHeadForm

Conversation

@sbagg

@sbagg sbagg commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

@sbagg sbagg self-assigned this Jul 13, 2026
@sbagg
sbagg requested a review from Copilot July 13, 2026 07:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 iamId query 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.

Comment thread services/lib/models/admin.js
Comment thread services/lib/models/admin.js
Comment thread services/lib/models/admin.js Outdated
Comment thread services/lib/models/admin.js
Comment thread services/lib/models/admin.js Outdated
Comment thread services/app/api/separation.js
Comment thread services/lib/models/admin.js

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 / employeeNewHead are not reset. This can leave the "New Department Head" field visible (and/or a stale employeeNewHead value) 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 thread services/app/api/separation.js
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
});
}
Comment thread services/lib/cork/models/EmployeeModel.js
Comment thread services/app/api/employees.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants