diff --git a/src-ui/src/app/components/manage/management-list/management-list.component.html b/src-ui/src/app/components/manage/management-list/management-list.component.html index 9d6cf87c5..9a6a6cc35 100644 --- a/src-ui/src/app/components/manage/management-list/management-list.component.html +++ b/src-ui/src/app/components/manage/management-list/management-list.component.html @@ -85,33 +85,39 @@
- - -
- - - } - - - - - @if (!isLoading) { -
- @if (collectionSize > 0) { -
- {collectionSize, plural, =1 {One {{typeName}}} other {{{collectionSize || 0}} total {{typeNamePlural}}}} - @if (selectedObjects.size > 0) { -  ({{selectedObjects.size}} selected) - } + + + +
- } - @if (collectionSize > 20) { - - } -
+ + } + + + + + @if (!isLoading) { +
+ @if (collectionSize > 0) { +
+ {collectionSize, plural, =1 {One {{typeName}}} other {{{collectionSize || 0}} total {{typeNamePlural}}}} + @if (selectedObjects.size > 0) { +  ({{selectedObjects.size}} selected) + } +
+ } + @if (collectionSize > 20) { + + } +
+ } diff --git a/src-ui/src/app/components/manage/management-list/management-list.component.spec.ts b/src-ui/src/app/components/manage/management-list/management-list.component.spec.ts index 6196a3c8a..20f1c3a1d 100644 --- a/src-ui/src/app/components/manage/management-list/management-list.component.spec.ts +++ b/src-ui/src/app/components/manage/management-list/management-list.component.spec.ts @@ -13,6 +13,7 @@ import { NgbModalModule, NgbModalRef, NgbPaginationModule, + NgbPopoverModule, } from '@ng-bootstrap/ng-bootstrap' import { of, throwError } from 'rxjs' import { Tag } from 'src/app/data/tag' @@ -37,6 +38,7 @@ import { MATCH_NONE } from 'src/app/data/matching-model' import { MATCH_LITERAL } from 'src/app/data/matching-model' import { PermissionsDialogComponent } from '../../common/permissions-dialog/permissions-dialog.component' import { NgxBootstrapIconsModule, allIcons } from 'ngx-bootstrap-icons' +import { ConfirmButtonComponent } from '../../common/confirm-button/confirm-button.component' const tags: Tag[] = [ { @@ -75,6 +77,7 @@ describe('ManagementListComponent', () => { SafeHtmlPipe, ConfirmDialogComponent, PermissionsDialogComponent, + ConfirmButtonComponent, ], providers: [ { @@ -96,6 +99,7 @@ describe('ManagementListComponent', () => { NgbModalModule, RouterTestingModule.withRoutes(routes), NgxBootstrapIconsModule.pick(allIcons), + NgbPopoverModule, ], }).compileComponents() @@ -192,27 +196,23 @@ describe('ManagementListComponent', () => { }) it('should support delete, show notification on error / success', () => { - let modal: NgbModalRef - modalService.activeInstances.subscribe((m) => (modal = m[m.length - 1])) const toastErrorSpy = jest.spyOn(toastService, 'showError') const deleteSpy = jest.spyOn(tagService, 'delete') const reloadSpy = jest.spyOn(component, 'reloadData') - const deleteButton = fixture.debugElement.queryAll(By.css('button'))[7] - deleteButton.triggerEventHandler('click') - - expect(modal).not.toBeUndefined() - const editDialog = modal.componentInstance as ConfirmDialogComponent + const deleteButton = fixture.debugElement.query( + By.directive(ConfirmButtonComponent) + ) // fail first deleteSpy.mockReturnValueOnce(throwError(() => new Error('error deleting'))) - editDialog.confirmClicked.emit() + deleteButton.nativeElement.dispatchEvent(new Event('confirm')) expect(toastErrorSpy).toHaveBeenCalled() expect(reloadSpy).not.toHaveBeenCalled() // succeed deleteSpy.mockReturnValueOnce(of(true)) - editDialog.confirmClicked.emit() + deleteButton.nativeElement.dispatchEvent(new Event('confirm')) expect(reloadSpy).toHaveBeenCalled() }) diff --git a/src-ui/src/app/components/manage/management-list/management-list.component.ts b/src-ui/src/app/components/manage/management-list/management-list.component.ts index a89b5e4f6..101436883 100644 --- a/src-ui/src/app/components/manage/management-list/management-list.component.ts +++ b/src-ui/src/app/components/manage/management-list/management-list.component.ts @@ -15,10 +15,7 @@ import { MATCH_NONE, } from 'src/app/data/matching-model' import { ObjectWithId } from 'src/app/data/object-with-id' -import { - ObjectWithPermissions, - PermissionsObject, -} from 'src/app/data/object-with-permissions' +import { ObjectWithPermissions } from 'src/app/data/object-with-permissions' import { SortableDirective, SortEvent, @@ -194,34 +191,21 @@ export abstract class ManagementListComponent ]) } - 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 - ) - }, - }) - }) + 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 + ) + }, + }) } get nameFilter() {