Skip to content

Commit

Permalink
Added delete button to case detail screen (#1283)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivo-ritense authored Nov 27, 2024
1 parent bca8d5e commit 15617a5
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 6 deletions.
5 changes: 5 additions & 0 deletions projects/valtimo/config/assets/core/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@
"cancel": "Absagen",
"delete": "Löschen"
},
"delete": {
"delete": "Case löschen",
"description": "Möchten Sie diesen Case und alle zugehörigen Informationen wirklich löschen? Diese Aktion kann nicht rückgängig gemacht werden.",
"confirm": "Löschen"
},
"formio": {
"noFormSpecified": "Für diese Registerkarte wurde keine Formulardefinition angegeben.",
"formNotFound": "Die Formulardefinition '{{formDefinitionName}}' konnte nicht gefunden werden."
Expand Down
5 changes: 5 additions & 0 deletions projects/valtimo/config/assets/core/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@
"cancel": "Cancel",
"delete": "Delete"
},
"delete": {
"delete": "Delete case",
"description": "Are you sure you want to delete this case and all related information? This action cannot be undone.",
"confirm": "Delete"
},
"formio": {
"noFormSpecified": "No form definition has been specified for this tab.",
"formNotFound": "The form definition '{{formDefinitionName}}' could not be found."
Expand Down
5 changes: 5 additions & 0 deletions projects/valtimo/config/assets/core/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@
"cancel": "Annuleren",
"delete": "Verwijderen"
},
"delete": {
"delete": "Dossier verwijderen",
"description": "Weet u zeker dat u dit dossier en alle gerelateerde informatie wilt verwijderen? Deze actie kan niet ongedaan worden gemaakt.",
"confirm": "Verwijderen"
},
"formio": {
"noFormSpecified": "Voor dit tabblad is geen formulierdefinitie opgegeven.",
"formNotFound": "De formulierdefinitie '{{formDefinitionName}}' kan niet worden gevonden."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,10 @@ export class DocumentService {
return this.http.put<DocumentResult>(`${this.valtimoEndpointUri}v1/document`, document);
}

public deleteDocument(documentId: string): Observable<void> {
return this.http.delete<void>(`${this.valtimoEndpointUri}v1/document/${documentId}`);
}

// ProcessDocument-calls
public getProcessDocumentDefinitions(): Observable<ProcessDocumentDefinition> {
return this.http.get<ProcessDocumentDefinition>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,28 @@
[disabled]="(isAssigning$ | async) || (isAssignedToCurrentUser$ | async)"
(click)="claimAssignee()"
>
<span>{{ 'dossier.claimAssigneeCase' | translate }}</span>
{{ 'dossier.claimAssigneeCase' | translate }}
</cds-overflow-menu-option>
</ng-template>

<ng-template #unassignButton let-canHaveAssignee="canHaveAssignee" let-assigneeId="assigneeId">
<cds-overflow-menu-option
*ngIf="canHaveAssignee"
[disabled]="!assigneeId"
(selected)="unassignAssignee()"
>
{{ 'assignDocument.remove' | translate }}
</cds-overflow-menu-option>
</ng-template>

<ng-template #deleteButton let-canDelete="canDelete">
<cds-overflow-menu-option
*ngIf="canDelete"
[disabled]="(isDeleting$ | async)"
(click)="deleteDocument()"
type="danger"
>
{{ 'dossier.delete.delete' | translate }}
</cds-overflow-menu-option>
</ng-template>

Expand All @@ -204,6 +225,15 @@
</button>
</ng-template>

<valtimo-confirmation-modal
confirmButtonTextTranslationKey="dossier.delete.confirm"
confirmButtonType="danger"
contentTranslationKey="dossier.delete.description"
[showModalSubject$]="showDeleteModal$"
titleTranslationKey="dossier.delete.delete"
(confirmEvent)="onConfirmDelete()"
></valtimo-confirmation-modal>

<ng-container renderInPageHeader [fullWidth]="true">
<ng-template>
<div
Expand All @@ -214,6 +244,7 @@
canAssign: canAssign$ | async,
canClaim: canClaim$ | async,
canHaveAssignee: canHaveAssignee$ | async,
canDelete: canDelete$ | async,
document: document$ | async,
caseStatus: caseStatus$ | async,
} as obs"
Expand Down Expand Up @@ -245,7 +276,7 @@
<div class="buttons-container">
<cds-overflow-menu
[ngClass]="{'--compact': compactMode$ | async}"
*ngIf="obs.canHaveAssignee"
*ngIf="obs.canHaveAssignee || obs.canDelete"
flip="true"
[offset]="(compactMode$ | async) ? {y: 48, x: -4} : {y: 48, x: 4}"
class="overflow-button assign-overflow"
Expand All @@ -257,9 +288,20 @@
"
>
</ng-container>
<cds-overflow-menu-option (selected)="unassignAssignee()" [disabled]="!obs.assigneeId">
{{ 'assignDocument.remove' | translate }}
</cds-overflow-menu-option>
<ng-container
*ngTemplateOutlet="
unassignButton;
context: {canHaveAssignee: obs.canHaveAssignee, assigneeId: obs.assigneeId}
"
>
</ng-container>
<ng-container
*ngTemplateOutlet="
deleteButton;
context: {canDelete: obs.canDelete}
"
>
</ng-container>
</cds-overflow-menu>

<cds-overflow-menu
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ import {
CAN_ASSIGN_CASE_PERMISSION,
CAN_CLAIM_CASE_PERMISSION,
CAN_VIEW_CASE_PERMISSION,
CAN_DELETE_CASE_PERMISSION,
DOSSIER_DETAIL_PERMISSION_RESOURCE,
} from '../../permissions';
import {DossierDetailLayoutService, DossierService, DossierTabService} from '../../services';
Expand Down Expand Up @@ -129,6 +130,8 @@ export class DossierDetailComponent
filter(key => !!key)
);

public readonly showDeleteModal$: BehaviorSubject<boolean> = new BehaviorSubject(false);

public readonly canView$: Observable<boolean> = this.route.paramMap.pipe(
switchMap((params: ParamMap) =>
this.permissionService.requestPermission(CAN_VIEW_CASE_PERMISSION, {
Expand Down Expand Up @@ -238,6 +241,16 @@ export class DossierDetailComponent
)
);

public readonly isDeleting$ = new BehaviorSubject<boolean>(false);
public readonly canDelete$: Observable<boolean> = this.route.paramMap.pipe(
switchMap((params: ParamMap) =>
this.permissionService.requestPermission(CAN_DELETE_CASE_PERMISSION, {
resource: DOSSIER_DETAIL_PERMISSION_RESOURCE.jsonSchemaDocument,
identifier: params.get('documentId') ?? '',
})
)
);

public readonly loadingTabs$ = new BehaviorSubject<boolean>(true);
public readonly noTabsConfigured$ = new BehaviorSubject<boolean>(false);
public readonly showNoAccess$ = new BehaviorSubject<boolean>(false);
Expand Down Expand Up @@ -388,6 +401,25 @@ export class DossierDetailComponent
});
}

public deleteDocument(): void {
this.showDeleteModal$.next(true);
}

public onConfirmDelete(): void {
this.isDeleting$.next(true);
this.documentService.deleteDocument(this.documentId).subscribe({
next: (): void => {
this.isDeleting$.next(false);
this.showDeleteModal$.next(false);
this.router.navigate([`/dossiers/${this.documentDefinitionName}`]);
},
error: (): void => {
this.isDeleting$.next(false);
this.logger.debug('Something went wrong while deleting the case');
},
});
}

public onTaskClickEvent(taskProcessLinkResult: TaskWithProcessLink): void {
if (!taskProcessLinkResult.processLinkActivityResult) {
this.isAdmin$.pipe(take(1)).subscribe(isAdmin => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ const CAN_CREATE_CASE_PERMISSION: PermissionRequest = {
resource: DOSSIER_DETAIL_PERMISSION_RESOURCE.jsonSchemaDocument,
};

const CAN_DELETE_CASE_PERMISSION: PermissionRequest = {
action: PERMISSION_ACTION.delete,
resource: DOSSIER_DETAIL_PERMISSION_RESOURCE.jsonSchemaDocument,
};

export {
CAN_ADD_NOTE_PERMISSION,
CAN_ASSIGN_CASE_PERMISSION,
Expand All @@ -75,4 +80,5 @@ export {
DOSSIER_DETAIL_PERMISSION_RESOURCE,
CAN_VIEW_CASE_PERMISSION,
CAN_CREATE_CASE_PERMISSION,
CAN_DELETE_CASE_PERMISSION,
};
2 changes: 1 addition & 1 deletion src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ export const environment: ValtimoConfig = {
experimentalDmnEditing: true,
largeLogoMargin: true,
sortFilesByDate: true,
disableCaseCount: false,
disableCaseCount: true,
returnToLastUrlAfterTokenExpiration: true,
useStartEventNameAsStartFormTitle: true,
allowUserThemeSwitching: true,
Expand Down

0 comments on commit 15617a5

Please sign in to comment.