Skip to content

Commit

Permalink
add delte option
Browse files Browse the repository at this point in the history
  • Loading branch information
kcinay055679 committed Nov 21, 2024
1 parent e7275df commit 2368900
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
7 changes: 7 additions & 0 deletions frontend/src/app/components/objective/ObjectiveMenuActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ export class ObjectiveMenuActions {
return { displayName: 'Objective duplizieren', action: action, afterAction: afterAction };
}

deleteObjectiveAction(objective: ObjectiveMin): ObjectiveMenuEntry {
const action: ObjectiveMenuAction = () => this.dialogService.openConfirmDialog('CONFIRMATION.DELETE.OBJECTIVE');
const afterAction: ObjectiveMenuAfterAction = (objective, dialogResult) =>
this.afterActions.deleteObjective(objective);
return { displayName: 'Objective löschen', action: action, afterAction: afterAction };
}

completeObjectiveAction(objective: ObjectiveMin): ObjectiveMenuEntry {
const config = {
data: { objectiveTitle: objective.title },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ export class ObjectiveMenuAfterActions {
});
}

deleteObjective(objective: ObjectiveMin) {
this.objectiveService.deleteObjective(objective.id).subscribe(() => {
this.refreshDataService.markDataRefresh();
});
}

objectiveBackToDraft(objectiveMin: ObjectiveMin) {
this.objectiveService.getFullObjective(objectiveMin.id).subscribe((objective: Objective) => {
objective.state = 'DRAFT' as State;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class ObjectiveMenuActionsService {
}

private getDefaultActions(objective: ObjectiveMin): ObjectiveMenuEntry[] {
return [this.actions.duplicateObjectiveAction(objective)];
return [this.actions.duplicateObjectiveAction(objective), this.actions.deleteObjectiveAction(objective)];
}

private getDraftMenuActions(objective: ObjectiveMin): ObjectiveMenuEntry[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,6 @@
</button>
<button color="primary" mat-button mat-dialog-close [attr.data-testId]="'cancel'">Abbrechen</button>
</div>

<div class="col-auto" *ngIf="data.objective.objectiveId && data.action != 'duplicate'">
<button color="primary" type="button" mat-button (click)="deleteObjective()" [attr.data-testId]="'delete'">
Objective Löschen
</button>
</div>
>
</ng-container>
</app-dialog-template-core>

0 comments on commit 2368900

Please sign in to comment.