A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Fix: accidentally retained confirm button for management lists
shamoonebc9ce17b5cb
diff --git a/src-ui/messages.xlf b/src-ui/messages.xlfindex 3a6d6f8df..b102e9567 100644--- a/src-ui/messages.xlf+++ b/src-ui/messages.xlf@@ -1491,6 +1491,10 @@<context context-type="sourcefile">src/app/components/manage/management-list/management-list.component.html</context><context context-type="linenumber">96</context></context-group>+ <context-group purpose="location">+ <context context-type="sourcefile">src/app/components/manage/management-list/management-list.component.ts</context>+ <context context-type="linenumber">208</context>+ </context-group><context-group purpose="location"><context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.html</context><context context-type="linenumber">38</context>@@ -2017,7 +2021,7 @@</context-group><context-group purpose="location"><context context-type="sourcefile">src/app/components/manage/management-list/management-list.component.ts</context>- <context context-type="linenumber">304</context>+ <context context-type="linenumber">320</context></context-group><context-group purpose="location"><context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>@@ -2056,7 +2060,7 @@</context-group><context-group purpose="location"><context context-type="sourcefile">src/app/components/manage/management-list/management-list.component.ts</context>- <context context-type="linenumber">306</context>+ <context context-type="linenumber">322</context></context-group><context-group purpose="location"><context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>@@ -5025,7 +5029,11 @@</context-group><context-group purpose="location"><context context-type="sourcefile">src/app/components/manage/management-list/management-list.component.ts</context>- <context context-type="linenumber">302</context>+ <context context-type="linenumber">204</context>+ </context-group>+ <context-group purpose="location">+ <context context-type="sourcefile">src/app/components/manage/management-list/management-list.component.ts</context>+ <context context-type="linenumber">318</context></context-group></trans-unit><trans-unit id="5382975254277698192" datatype="html">@@ -6219,7 +6227,7 @@</context-group><context-group purpose="location"><context context-type="sourcefile">src/app/components/manage/management-list/management-list.component.ts</context>- <context context-type="linenumber">289</context>+ <context context-type="linenumber">305</context></context-group></trans-unit><trans-unit id="4010735610815226758" datatype="html">@@ -6302,26 +6310,26 @@<source>{VAR_PLURAL, plural, =1 {One <x id="INTERPOLATION"/>} other {<x id="INTERPOLATION_1"/> total <x id="INTERPOLATION_2"/>}}</source><context-group purpose="location"><context context-type="sourcefile">src/app/components/manage/management-list/management-list.component.html</context>- <context context-type="linenumber">116</context>+ <context context-type="linenumber">110</context></context-group><context-group purpose="location"><context context-type="sourcefile">src/app/components/manage/management-list/management-list.component.html</context>- <context context-type="linenumber">116</context>+ <context context-type="linenumber">110</context></context-group><context-group purpose="location"><context context-type="sourcefile">src/app/components/manage/management-list/management-list.component.html</context>- <context context-type="linenumber">116</context>+ <context context-type="linenumber">110</context></context-group><context-group purpose="location"><context context-type="sourcefile">src/app/components/manage/management-list/management-list.component.html</context>- <context context-type="linenumber">116</context>+ <context context-type="linenumber">110</context></context-group></trans-unit><trans-unit id="810888510148304696" datatype="html"><source>Automatic</source><context-group purpose="location"><context context-type="sourcefile">src/app/components/manage/management-list/management-list.component.ts</context>- <context context-type="linenumber">113</context>+ <context context-type="linenumber">116</context></context-group><context-group purpose="location"><context context-type="sourcefile">src/app/data/matching-model.ts</context>@@ -6332,7 +6340,7 @@<source>None</source><context-group purpose="location"><context context-type="sourcefile">src/app/components/manage/management-list/management-list.component.ts</context>- <context context-type="linenumber">115</context>+ <context context-type="linenumber">118</context></context-group><context-group purpose="location"><context context-type="sourcefile">src/app/data/matching-model.ts</context>@@ -6343,63 +6351,70 @@<source>Successfully created <x id="PH" equiv-text="this.typeName"/>.</source><context-group purpose="location"><context context-type="sourcefile">src/app/components/manage/management-list/management-list.component.ts</context>- <context context-type="linenumber">158</context>+ <context context-type="linenumber">161</context></context-group></trans-unit><trans-unit id="3928835053823658072" datatype="html"><source>Error occurred while creating <x id="PH" equiv-text="this.typeName"/>.</source><context-group purpose="location"><context context-type="sourcefile">src/app/components/manage/management-list/management-list.component.ts</context>- <context context-type="linenumber">163</context>+ <context context-type="linenumber">166</context></context-group></trans-unit><trans-unit id="2541368547549828690" datatype="html"><source>Successfully updated <x id="PH" equiv-text="this.typeName"/>.</source><context-group purpose="location"><context context-type="sourcefile">src/app/components/manage/management-list/management-list.component.ts</context>- <context context-type="linenumber">178</context>+ <context context-type="linenumber">181</context></context-group></trans-unit><trans-unit id="6442673774206210733" datatype="html"><source>Error occurred while saving <x id="PH" equiv-text="this.typeName"/>.</source><context-group purpose="location"><context context-type="sourcefile">src/app/components/manage/management-list/management-list.component.ts</context>- <context context-type="linenumber">183</context>+ <context context-type="linenumber">186</context>+ </context-group>+ </trans-unit>+ <trans-unit id="8371896857609524947" datatype="html">+ <source>Associated documents will not be deleted.</source>+ <context-group purpose="location">+ <context context-type="sourcefile">src/app/components/manage/management-list/management-list.component.ts</context>+ <context context-type="linenumber">206</context></context-group></trans-unit><trans-unit id="6639207128255974941" datatype="html"><source>Error while deleting element</source><context-group purpose="location"><context context-type="sourcefile">src/app/components/manage/management-list/management-list.component.ts</context>- <context context-type="linenumber">207</context>+ <context context-type="linenumber">222</context></context-group></trans-unit><trans-unit id="4863024195229581844" datatype="html"><source>Permissions updated successfully</source><context-group purpose="location"><context context-type="sourcefile">src/app/components/manage/management-list/management-list.component.ts</context>- <context context-type="linenumber">282</context>+ <context context-type="linenumber">298</context></context-group></trans-unit><trans-unit id="1464476612812630086" datatype="html"><source>This operation will permanently delete all objects.</source><context-group purpose="location"><context context-type="sourcefile">src/app/components/manage/management-list/management-list.component.ts</context>- <context context-type="linenumber">303</context>+ <context context-type="linenumber">319</context></context-group></trans-unit><trans-unit id="5897787932098828336" datatype="html"><source>Objects deleted successfully</source><context-group purpose="location"><context context-type="sourcefile">src/app/components/manage/management-list/management-list.component.ts</context>- <context context-type="linenumber">317</context>+ <context context-type="linenumber">333</context></context-group></trans-unit><trans-unit id="8273353839648035634" datatype="html"><source>Error deleting objects</source><context-group purpose="location"><context context-type="sourcefile">src/app/components/manage/management-list/management-list.component.ts</context>- <context context-type="linenumber">323</context>+ <context context-type="linenumber">339</context></context-group></trans-unit><trans-unit id="5101757640976222639" datatype="html">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.htmlindex d627a1540..58101c388 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@@ -88,39 +88,33 @@<div class="btn-group d-none d-sm-block"><button class="btn btn-sm btn-outline-secondary" (click)="filterDocuments(object); $event.stopPropagation();" *pngxIfPermissions="{ action: PermissionAction.View, type: PermissionType.Document }"><i-bs width="1em" height="1em" name="filter"></i-bs> <ng-container i18n>Documents</ng-container>- </button>- <button class="btn btn-sm btn-outline-secondary" (click)="openEditDialog(object); $event.stopPropagation();" *pngxIfPermissions="{ action: PermissionAction.Change, type: permissionType }" [disabled]="!userCanEdit(object)">- <i-bs width="1em" height="1em" name="pencil"></i-bs> <ng-container i18n>Edit</ng-container>- </button>- <pngx-confirm-button- label="Delete"- i18n-label- (confirm)="deleteObject(object)"- *pngxIfPermissions="{ action: PermissionAction.Delete, type: permissionType }"- [disabled]="!userCanDelete(object)"- buttonClasses=" btn-sm btn-outline-danger"- iconName="trash">- </pngx-confirm-button>+ </button>+ <button class="btn btn-sm btn-outline-secondary" (click)="openEditDialog(object); $event.stopPropagation();" *pngxIfPermissions="{ action: PermissionAction.Change, type: permissionType }" [disabled]="!userCanEdit(object)">+ <i-bs width="1em" height="1em" name="pencil"></i-bs> <ng-container i18n>Edit</ng-container>+ </button>+ <button class="btn btn-sm btn-outline-danger" (click)="openDeleteDialog(object); $event.stopPropagation();" *pngxIfPermissions="{ action: PermissionAction.Delete, type: permissionType }" [disabled]="!userCanDelete(object)">+ <i-bs width="1em" height="1em" name="trash"></i-bs> <ng-container i18n>Delete</ng-container>+ </button>+ </div>+ </td>+ </tr>+ }+ </tbody>+ </table>+ </div>++ @if (!isLoading) {+ <div class="d-flex mb-2">+ @if (collectionSize > 0) {+ <div>+ <ng-container i18n>{collectionSize, plural, =1 {One {{typeName}}} other {{{collectionSize || 0}} total {{typeNamePlural}}}}</ng-container>+ @if (selectedObjects.size > 0) {+ ({{selectedObjects.size}} selected)+ }</div>- </td>- </tr>+ }+ @if (collectionSize > 20) {+ <ngb-pagination class="ms-auto" [pageSize]="25" [collectionSize]="collectionSize" [(page)]="page" [maxSize]="5" (pageChange)="reloadData()" size="sm" aria-label="Pagination"></ngb-pagination>+ }+ </div>}- </tbody>- </table>- </div>-- @if (!isLoading) {- <div class="d-flex mb-2">- @if (collectionSize > 0) {- <div>- <ng-container i18n>{collectionSize, plural, =1 {One {{typeName}}} other {{{collectionSize || 0}} total {{typeNamePlural}}}}</ng-container>- @if (selectedObjects.size > 0) {- ({{selectedObjects.size}} selected)- }- </div>- }- @if (collectionSize > 20) {- <ngb-pagination class="ms-auto" [pageSize]="25" [collectionSize]="collectionSize" [(page)]="page" [maxSize]="5" (pageChange)="reloadData()" size="sm" aria-label="Pagination"></ngb-pagination>- }- </div>- }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.tsindex 280c40ca8..710d3018a 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,7 +13,6 @@ import {NgbModalModule,NgbModalRef,NgbPaginationModule,- NgbPopoverModule,} from '@ng-bootstrap/ng-bootstrap'import { of, throwError } from 'rxjs'import { Tag } from 'src/app/data/tag'@@ -38,7 +37,6 @@ 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'import { BulkEditObjectOperation } from 'src/app/services/rest/abstract-name-filter-service'const tags: Tag[] = [@@ -78,7 +76,6 @@ describe('ManagementListComponent', () => {SafeHtmlPipe,ConfirmDialogComponent,PermissionsDialogComponent,- ConfirmButtonComponent,],providers: [{@@ -100,7 +97,6 @@ describe('ManagementListComponent', () => {NgbModalModule,RouterTestingModule.withRoutes(routes),NgxBootstrapIconsModule.pick(allIcons),- NgbPopoverModule,],}).compileComponents()@@ -197,23 +193,27 @@ 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.query(- By.directive(ConfirmButtonComponent)- )+ const deleteButton = fixture.debugElement.queryAll(By.css('button'))[8]+ deleteButton.triggerEventHandler('click')++ expect(modal).not.toBeUndefined()+ const editDialog = modal.componentInstance as ConfirmDialogComponent// fail firstdeleteSpy.mockReturnValueOnce(throwError(() => new Error('error deleting')))- deleteButton.nativeElement.dispatchEvent(new Event('confirm'))+ editDialog.confirmClicked.emit()expect(toastErrorSpy).toHaveBeenCalled()expect(reloadSpy).not.toHaveBeenCalled()// succeeddeleteSpy.mockReturnValueOnce(of(true))- deleteButton.nativeElement.dispatchEvent(new Event('confirm'))+ editDialog.confirmClicked.emit()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.tsindex 8f0947f1c..0b0365f06 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,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() {