Skip to content

Commit

Permalink
add delete action to 3 dot menu
Browse files Browse the repository at this point in the history
  • Loading branch information
nevio18324 committed Nov 7, 2024
1 parent 8099cd5 commit 4f75641
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 @@ -48,6 +48,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 @@ -32,6 +32,12 @@ export class ObjectiveMenuAfterActions {
});
}

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

objectiveBackToDraft(objective: Objective) {
objective.state = 'DRAFT' as State;
this.objectiveService.updateObjective(objective).subscribe(() => {
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 4f75641

Please sign in to comment.