Skip to content

Commit

Permalink
introduce afterAction property
Browse files Browse the repository at this point in the history
  • Loading branch information
kcinay055679 committed Oct 23, 2024
1 parent f9cee52 commit 6bc13ac
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ <h2 class="title fit-content">{{ objective.title }}</h2>
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()"
>
<span class="d-flex align-items-center add-text">
Expand Down
11 changes: 6 additions & 5 deletions frontend/src/app/components/objective/objective.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) {
Expand Down Expand Up @@ -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();
});
Expand Down
22 changes: 15 additions & 7 deletions frontend/src/app/services/objective-menu-actions.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type ObjectiveMenuAction = () => MatDialogRef<any>;
export interface ObjectiveMenuEntry {
displayName: string;
action: ObjectiveMenuAction;
afterAction?: (arg1: any, arg2: any) => any;
afterAction: (arg?: any) => any;
}

@Injectable({
Expand Down Expand Up @@ -54,38 +54,46 @@ 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 {
const config = {
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[] {
Expand Down

0 comments on commit 6bc13ac

Please sign in to comment.