<div class="input-group-text" i18n>of {{previewNumPages}}</div>
</div>
- <button type="button" class="btn btn-sm btn-outline-danger me-2 ms-auto" (click)="delete()" [disabled]="!userIsOwner">
+ <button type="button" class="btn btn-sm btn-outline-danger me-2 ms-auto" (click)="delete()" [disabled]="!userIsOwner" *appIfPermissions="{ action: PermissionAction.Delete, type: PermissionType.Document }">
<svg class="buttonicon" fill="currentColor">
<use xlink:href="assets/bootstrap-icons.svg#trash" />
</svg><span class="d-none d-lg-inline ps-1" i18n>Delete</span>
this.toastService.showError(
$localize`Error saving document` +
': ' +
- (error.message ?? error.toString())
+ (error.error?.detail ?? error.message ?? JSON.stringify(error))
)
}
},
this.toastService.showError(
$localize`Error saving document` +
': ' +
- (error.message ?? error.toString())
+ (error.error?.detail ?? error.message ?? JSON.stringify(error))
)
},
})
modal.componentInstance.message = $localize`The files for this document will be deleted permanently. This operation cannot be undone.`
modal.componentInstance.btnClass = 'btn-danger'
modal.componentInstance.btnCaption = $localize`Delete document`
+ this.subscribeModalDelete(modal) // so can be re-subscribed if error
+ }
+
+ subscribeModalDelete(modal) {
modal.componentInstance.confirmClicked
.pipe(
switchMap(() => {
})
)
.pipe(takeUntil(this.unsubscribeNotifier))
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
modal.close()
this.close()
},
- (error) => {
+ error: (error) => {
this.toastService.showError(
- $localize`Error deleting document: ${JSON.stringify(error)}`
+ $localize`Error deleting document: ${
+ error.error?.detail ?? error.message ?? JSON.stringify(error)
+ }`
)
modal.componentInstance.buttonsEnabled = true
- }
- )
+ this.subscribeModalDelete(modal)
+ },
+ })
}
moreLike() {