diff --git a/frontend/src/app/components/objective/objective.component.html b/frontend/src/app/components/objective/objective.component.html index 5cfa23b459..0fb9423609 100644 --- a/frontend/src/app/components/objective/objective.component.html +++ b/frontend/src/app/components/objective/objective.component.html @@ -50,7 +50,7 @@

{{ objective.title }}

color="primary" class="fw-bold px-0 pe-2 ms-2" [attr.data-testId]="'add-keyResult'" - (click)="openAddKeyResultDialog(); $event.stopPropagation()" + (click)="openAddKeyResultDialog(objective); $event.stopPropagation()" (keydown.enter)="$event.stopPropagation()" > diff --git a/frontend/src/app/components/objective/objective.component.ts b/frontend/src/app/components/objective/objective.component.ts index c2206dd24e..644bcd1ca5 100644 --- a/frontend/src/app/components/objective/objective.component.ts +++ b/frontend/src/app/components/objective/objective.component.ts @@ -57,9 +57,10 @@ export class ObjectiveComponent implements OnInit { } redirect(menuEntry: ObjectiveMenuEntry) { - console.log('test'); - console.log(menuEntry.action); const matDialogRef = menuEntry.action(); + matDialogRef.afterClosed().subscribe((result) => { + menuEntry.afterAction(result); + }); } handleDialogResult(menuEntry: MenuEntry, result: { endState: string; comment: string | null; objective: any }) { @@ -134,18 +135,18 @@ export class ObjectiveComponent implements OnInit { this.router.navigate(['details/objective', objectiveId]); } - openAddKeyResultDialog() { + openAddKeyResultDialog(objective: ObjectiveMin) { this.dialogService .open(KeyresultDialogComponent, { data: { - objective: this.objective$.value, + objective: objective, keyResult: null, }, }) .afterClosed() .subscribe((result) => { if (result?.openNew) { - this.openAddKeyResultDialog(); + this.openAddKeyResultDialog(objective); } this.refreshDataService.markDataRefresh(); }); diff --git a/frontend/src/app/services/objective-menu-actions.service.ts b/frontend/src/app/services/objective-menu-actions.service.ts index e47ee600da..8789bcf551 100644 --- a/frontend/src/app/services/objective-menu-actions.service.ts +++ b/frontend/src/app/services/objective-menu-actions.service.ts @@ -12,7 +12,7 @@ export type ObjectiveMenuAction = () => MatDialogRef; export interface ObjectiveMenuEntry { displayName: string; action: ObjectiveMenuAction; - afterAction?: (arg1: any, arg2: any) => any; + afterAction: (arg?: any) => any; } @Injectable({ @@ -54,25 +54,29 @@ export class ObjectiveMenuActionsService { private releaseFromDraftAction(objective: ObjectiveMin): ObjectiveMenuEntry { const action = () => this.dialogService.openConfirmDialog('CONFIRMATION.RELEASE'); - return { displayName: 'Objective veröffentlichen', action: action }; + const afterAction = () => {}; + return { displayName: 'Objective veröffentlichen', action: action, afterAction: afterAction }; } private releaseFromDraftInBacklogAction(objective: ObjectiveMin): ObjectiveMenuEntry { const config = { data: { objective: { objectiveId: objective }, action: 'releaseBacklog' } }; const action: ObjectiveMenuAction = () => this.dialogService.open(ObjectiveFormComponent, config); - return { displayName: 'Objective veröffentlichen', action: action }; + const afterAction = () => {}; + return { displayName: 'Objective veröffentlichen', action: action, afterAction }; } private editObjectiveAction(objective: ObjectiveMin): ObjectiveMenuEntry { const config = { data: { objective: { objectiveId: objective.id } } }; const action: ObjectiveMenuAction = () => this.dialogService.open(ObjectiveFormComponent, config); - return { displayName: 'Objective bearbeiten', action: action }; + const afterAction = () => {}; + return { displayName: 'Objective bearbeiten', action: action, afterAction: afterAction }; } private duplicateObjectiveAction(objective: ObjectiveMin): ObjectiveMenuEntry { const config = { data: { objective: { objectiveId: objective.id } } }; const action = () => this.dialogService.open(ObjectiveFormComponent, config); - return { displayName: 'Objective duplizieren', action: action }; + const afterAction = () => {}; + return { displayName: 'Objective duplizieren', action: action, afterAction: afterAction }; } private completeObjectiveAction(objective: ObjectiveMin): ObjectiveMenuEntry { @@ -80,12 +84,16 @@ export class ObjectiveMenuActionsService { data: { objectiveTitle: objective.title }, }; const action = () => this.dialogService.open(CompleteDialogComponent, config); - return { displayName: 'Objective abschliessen', action: action }; + const afterAction = () => {}; + + return { displayName: 'Objective abschliessen', action: action, afterAction: afterAction }; } private saveObjectiveAsDraftAction(): ObjectiveMenuEntry { const action = () => this.dialogService.openConfirmDialog('CONFIRMATION.DRAFT_CREATE'); - return { displayName: 'Objective als Draft speicherns', action: action }; + const afterAction = () => {}; + + return { displayName: 'Objective als Draft speicherns', action: action, afterAction: afterAction }; } private getCompletedMenuActions(objective: ObjectiveMin): ObjectiveMenuEntry[] {