diff --git a/frontend/cypress/e2e/objective-crud.cy.ts b/frontend/cypress/e2e/objective-crud.cy.ts index 8045e09e28..8a6c058b00 100644 --- a/frontend/cypress/e2e/objective-crud.cy.ts +++ b/frontend/cypress/e2e/objective-crud.cy.ts @@ -1,6 +1,7 @@ import * as users from '../fixtures/users.json'; import CyOverviewPage from '../support/helper/dom-helper/pages/overviewPage'; import ObjectiveDialog from '../support/helper/dom-helper/dialogs/objectiveDialog'; +import ConfirmDialog from '../support/helper/dom-helper/dialogs/confirmDialog'; describe('CRUD operations', () => { let op = new CyOverviewPage(); @@ -41,10 +42,9 @@ describe('CRUD operations', () => { }); it(`Delete existing objective`, () => { - cy.get('.objective').first().findByTestId('three-dot-menu').click(); - op.selectFromThreeDotMenu('Objective bearbeiten'); - ObjectiveDialog.do() - .deleteObjective() + op.getObjectiveByState('ongoing').findByTestId('three-dot-menu').click(); + op.selectFromThreeDotMenu('Objective löschen'); + ConfirmDialog.do() .checkTitle('Objective löschen') .checkDescription( 'Möchtest du dieses Objective wirklich löschen? Zugehörige Key Results werden dadurch ebenfalls gelöscht!', diff --git a/frontend/src/app/components/objective/ObjectiveMenuActions.ts b/frontend/src/app/components/objective/ObjectiveMenuActions.ts index 2e36aa7ed6..a18b2a4920 100644 --- a/frontend/src/app/components/objective/ObjectiveMenuActions.ts +++ b/frontend/src/app/components/objective/ObjectiveMenuActions.ts @@ -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 }, diff --git a/frontend/src/app/components/objective/ObjectiveMenuAfterActions.ts b/frontend/src/app/components/objective/ObjectiveMenuAfterActions.ts index 4d0e237e21..8dec478557 100644 --- a/frontend/src/app/components/objective/ObjectiveMenuAfterActions.ts +++ b/frontend/src/app/components/objective/ObjectiveMenuAfterActions.ts @@ -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; diff --git a/frontend/src/app/services/objective-menu-actions.service.ts b/frontend/src/app/services/objective-menu-actions.service.ts index 32d27aac32..2de87653d8 100644 --- a/frontend/src/app/services/objective-menu-actions.service.ts +++ b/frontend/src/app/services/objective-menu-actions.service.ts @@ -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[] { diff --git a/frontend/src/app/shared/dialog/objective-dialog/objective-form.component.html b/frontend/src/app/shared/dialog/objective-dialog/objective-form.component.html index f6a1b30d0e..68f425f669 100644 --- a/frontend/src/app/shared/dialog/objective-dialog/objective-form.component.html +++ b/frontend/src/app/shared/dialog/objective-dialog/objective-form.component.html @@ -95,11 +95,6 @@ - -
- -
+ > diff --git a/frontend/src/app/shared/dialog/objective-dialog/objective-form.component.ts b/frontend/src/app/shared/dialog/objective-dialog/objective-form.component.ts index 8bb93a22bd..f0c4c68bb3 100644 --- a/frontend/src/app/shared/dialog/objective-dialog/objective-form.component.ts +++ b/frontend/src/app/shared/dialog/objective-dialog/objective-form.component.ts @@ -131,23 +131,6 @@ export class ObjectiveFormComponent implements OnInit, OnDestroy { } } - deleteObjective() { - const dialog = this.dialogService.openConfirmDialog('CONFIRMATION.DELETE.OBJECTIVE'); - dialog.afterClosed().subscribe((result) => { - if (result) { - this.objectiveService.deleteObjective(this.data.objective.objectiveId!).subscribe({ - next: () => { - let objectiveDTO: Objective = { id: this.data.objective.objectiveId! } as unknown as Objective; - this.closeDialog(objectiveDTO, true); - }, - error: () => { - this.dialogRef.close(); - }, - }); - } - }); - } - objectiveToObjectiveMin(objectiveDto: Objective): ObjectiveMin { return { ...objectiveDto,