Skip to content

Commit a9a7f33

Browse files
authored
Merge pull request #1563 from Northeastern-Electric-Racing/#954-editing-workpackage-bug
#954: fixed bug with stage when editing workpackage
2 parents d59b7e1 + d61599d commit a9a7f33

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

src/backend/src/services/work-packages.services.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ export default class WorkPackagesService {
362362
let changes = [];
363363
// get the changes or undefined for each of the fields
364364
const nameChangeJson = createChange('name', originalWorkPackage.wbsElement.name, name, crId, userId, wbsElementId!);
365-
const stageChangeJson = createChange('stage', originalWorkPackage.stage, stage ?? 'None', crId, userId, wbsElementId!);
365+
const stageChangeJson = createChange('stage', originalWorkPackage.stage, stage, crId, userId, wbsElementId!);
366366
const startDateChangeJson = createChange(
367367
'start date',
368368
originalWorkPackage.startDate.toDateString(),

src/backend/src/utils/changes.utils.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,20 @@ export const createChange = (
3939
implementerId: number,
4040
wbsElementId: number
4141
): ChangeCreateArgs | undefined => {
42-
if (oldValue == null) {
42+
if (oldValue == null && newValue !== null) {
4343
return {
4444
changeRequestId: crId,
4545
implementerId,
4646
wbsElementId,
4747
detail: `Added ${nameOfField} "${newValue}"`
4848
};
49+
} else if (oldValue !== null && newValue == null) {
50+
return {
51+
changeRequestId: crId,
52+
implementerId,
53+
wbsElementId,
54+
detail: `Deleted ${nameOfField} "${oldValue}"`
55+
};
4956
} else if (oldValue !== newValue) {
5057
return {
5158
changeRequestId: crId,

0 commit comments

Comments
 (0)