Skip to content

Commit de8c6c7

Browse files
Limit Milestone Team Options #231
1 parent b55f119 commit de8c6c7

File tree

2 files changed

+75
-20
lines changed

2 files changed

+75
-20
lines changed

client/src/app/pages/poam-processing/poam-details/poam-details.component.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,10 @@
394394
</p-accordion>
395395
</div>
396396
<div class="stepper-buttons">
397-
<div></div>
398397
<p-button styleClass="p-button-outlined p-button-rounded p-button-text p-button-raised p-button-primary"
399398
icon="pi pi-arrow-right"
400399
iconPos="right"
400+
class="ml-auto"
401401
(onClick)="activateCallback(2)"></p-button>
402402
</div>
403403
</div>
@@ -669,7 +669,7 @@
669669
<cpat-poam-milestones [poam]="poam"
670670
[accessLevel]="accessLevel()"
671671
[poamMilestones]="poamMilestones"
672-
[assignedTeamOptions]="assignedTeamOptions"
672+
[assignedTeamOptions]="milestoneTeamOptions"
673673
(milestonesChanged)="handleMilestonesChanged($event)">
674674
</cpat-poam-milestones>
675675
</div>

client/src/app/pages/poam-processing/poam-details/poam-details.component.ts

+73-18
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ export class PoamDetailsComponent implements OnInit, OnDestroy {
139139
user: any;
140140
payload: any;
141141
teamMitigations: any[] = [];
142+
milestoneTeamOptions: any[] = [];
142143
activeTabIndex: number = 0;
143144
mitigationSaving: boolean = false;
144145
isGlobalFinding: boolean;
@@ -237,7 +238,6 @@ export class PoamDetailsComponent implements OnInit, OnDestroy {
237238

238239
return items;
239240
});
240-
241241
constructor(
242242
private assignedTeamService: AssignedTeamService,
243243
private confirmationService: ConfirmationService,
@@ -270,7 +270,7 @@ export class PoamDetailsComponent implements OnInit, OnDestroy {
270270
this.setPayload();
271271
}
272272

273-
async setPayload() {
273+
setPayload() {
274274
this.setPayloadService.setPayload();
275275
this.subs.add(
276276
this.setPayloadService.user$.subscribe(user => {
@@ -284,6 +284,18 @@ export class PoamDetailsComponent implements OnInit, OnDestroy {
284284
if (this.accessLevel() > 0) {
285285
this.obtainCollectionData(true);
286286
this.getData();
287+
if (this.selectedCollection) {
288+
this.getLabelData();
289+
}
290+
}
291+
})
292+
);
293+
294+
this.subs.add(
295+
this.sharedService.selectedCollection.subscribe(collectionId => {
296+
this.selectedCollection = collectionId;
297+
if (this.selectedCollection) {
298+
this.getLabelData();
287299
}
288300
})
289301
);
@@ -292,7 +304,6 @@ export class PoamDetailsComponent implements OnInit, OnDestroy {
292304
async getData() {
293305
this.loadAAPackages();
294306
this.loadAssetDeltaList();
295-
this.getLabelData();
296307

297308
if (this.poamId === undefined || !this.poamId) {
298309
return;
@@ -423,6 +434,7 @@ export class PoamDetailsComponent implements OnInit, OnDestroy {
423434
this.poamAssets = result.poamAssets;
424435
}
425436
this.loadingTeams.set(false);
437+
this.updateMilestoneTeamOptions();
426438
},
427439
error: (error) => {
428440
console.error('Error loading assets:', error);
@@ -455,7 +467,7 @@ export class PoamDetailsComponent implements OnInit, OnDestroy {
455467
this.poamAssignedTeams
456468
);
457469
this.poamAssignedTeams = updatedTeams;
458-
470+
this.updateMilestoneTeamOptions();
459471
if (this.poam?.poamId && this.poam.poamId !== 'ADDPOAM') {
460472
this.syncTeamMitigations();
461473
}
@@ -634,7 +646,7 @@ export class PoamDetailsComponent implements OnInit, OnDestroy {
634646

635647
savePoam(saveState: boolean = false): Promise<boolean> {
636648
return new Promise((resolve) => {
637-
if (!this.validateData(saveState)) {
649+
if (!this.validateData()) {
638650
resolve(false);
639651
return;
640652
}
@@ -880,27 +892,35 @@ export class PoamDetailsComponent implements OnInit, OnDestroy {
880892
});
881893
}
882894

883-
verifySubmitPoam() {
884-
const validationResult = this.poamValidationService.validateMilestones(this.poamMilestones);
885-
if (!validationResult.valid) {
895+
verifySubmitPoam(showDialog: boolean = true): boolean {
896+
const milestoneValidation = this.poamValidationService.validateMilestones(this.poamMilestones);
897+
if (!milestoneValidation.valid) {
886898
this.messageService.add({
887899
severity: 'error',
888900
summary: 'Information',
889-
detail: validationResult.message
901+
detail: milestoneValidation.message
890902
});
891-
} else {
892-
this.submitDialogVisible = true;
903+
return false;
893904
}
894-
}
895905

896-
async confirmSubmit() {
897-
const validationResult = this.poamValidationService.validateMilestones(this.poamMilestones);
898-
if (!validationResult.valid) {
906+
const submissionValidation = this.poamValidationService.validateSubmissionRequirements(this.poam, this.teamMitigations, this.dates);
907+
if (!submissionValidation.valid) {
899908
this.messageService.add({
900909
severity: 'error',
901910
summary: 'Information',
902-
detail: validationResult.message
911+
detail: submissionValidation.message
903912
});
913+
return false;
914+
}
915+
916+
if (showDialog) {
917+
this.submitDialogVisible = true;
918+
}
919+
return true;
920+
}
921+
922+
async confirmSubmit() {
923+
if (!this.verifySubmitPoam(false)) {
904924
return;
905925
}
906926

@@ -923,8 +943,8 @@ export class PoamDetailsComponent implements OnInit, OnDestroy {
923943
this.submitDialogVisible = false;
924944
}
925945

926-
validateData(saveState: boolean): boolean {
927-
const result = this.poamValidationService.validateData(this.poam, this.dates, saveState);
946+
validateData(): boolean {
947+
const result = this.poamValidationService.validateData(this.poam);
928948
if (!result.valid) {
929949
this.messageService.add({
930950
severity: 'error',
@@ -970,6 +990,25 @@ export class PoamDetailsComponent implements OnInit, OnDestroy {
970990

971991
handleTeamsChanged(event: { teams: any[], action: string, team?: any }) {
972992
this.poamAssignedTeams = event.teams;
993+
this.updateMilestoneTeamOptions();
994+
995+
if (event.action === 'added' && event.team?.assignedTeamId) {
996+
const hasTeamMitigation = this.teamMitigations.some(
997+
m => m.assignedTeamId === event.team.assignedTeamId
998+
);
999+
1000+
if (!hasTeamMitigation) {
1001+
this.teamMitigations.push({
1002+
assignedTeamId: event.team.assignedTeamId,
1003+
assignedTeamName: event.team.assignedTeamName,
1004+
mitigationText: '',
1005+
isActive: true
1006+
});
1007+
}
1008+
1009+
this.updateMilestoneTeamOptions();
1010+
}
1011+
9731012
if (this.poam && event.action !== 'save-request') {
9741013
this.poam.assignedTeams = this.poamAssignedTeams
9751014
.filter(team => team.assignedTeamId)
@@ -1017,6 +1056,22 @@ export class PoamDetailsComponent implements OnInit, OnDestroy {
10171056
}
10181057
}
10191058

1059+
updateMilestoneTeamOptions() {
1060+
if (!this.poamAssignedTeams || !this.assignedTeamOptions) {
1061+
this.milestoneTeamOptions = [];
1062+
return;
1063+
}
1064+
1065+
const activeTeamIds = this.poamAssignedTeams
1066+
.filter(team => team.isActive !== false)
1067+
.map(team => team.assignedTeamId);
1068+
1069+
const filteredTeams = this.assignedTeamOptions
1070+
.filter(team => activeTeamIds.includes(team.assignedTeamId));
1071+
1072+
this.milestoneTeamOptions = [...filteredTeams];
1073+
}
1074+
10201075
loadTeamMitigations() {
10211076
if (!this.poam?.poamId || this.poam.poamId === 'ADDPOAM') {
10221077
return;

0 commit comments

Comments
 (0)