Fix: accidentally retained confirm button for management lists

This commit is contained in:
shamoon
2024-02-21 15:27:15 -08:00
parent 8039ce3c2b
commit ebc9ce17b5
4 changed files with 104 additions and 79 deletions

View File

@@ -15,7 +15,10 @@ import {
MATCH_NONE,
} from 'src/app/data/matching-model'
import { ObjectWithId } from 'src/app/data/object-with-id'
import { ObjectWithPermissions } from 'src/app/data/object-with-permissions'
import {
ObjectWithPermissions,
PermissionsObject,
} from 'src/app/data/object-with-permissions'
import {
SortableDirective,
SortEvent,
@@ -194,21 +197,34 @@ export abstract class ManagementListComponent<T extends ObjectWithId>
])
}
deleteObject(object: T) {
this.service
.delete(object)
.pipe(takeUntil(this.unsubscribeNotifier))
.subscribe({
next: () => {
this.reloadData()
},
error: (error) => {
this.toastService.showError(
$localize`Error while deleting element`,
error
)
},
})
openDeleteDialog(object: T) {
var activeModal = this.modalService.open(ConfirmDialogComponent, {
backdrop: 'static',
})
activeModal.componentInstance.title = $localize`Confirm delete`
activeModal.componentInstance.messageBold = this.getDeleteMessage(object)
activeModal.componentInstance.message = $localize`Associated documents will not be deleted.`
activeModal.componentInstance.btnClass = 'btn-danger'
activeModal.componentInstance.btnCaption = $localize`Delete`
activeModal.componentInstance.confirmClicked.subscribe(() => {
activeModal.componentInstance.buttonsEnabled = false
this.service
.delete(object)
.pipe(takeUntil(this.unsubscribeNotifier))
.subscribe({
next: () => {
activeModal.close()
this.reloadData()
},
error: (error) => {
activeModal.componentInstance.buttonsEnabled = true
this.toastService.showError(
$localize`Error while deleting element`,
error
)
},
})
})
}
get nameFilter() {