diff --git a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.html b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.html index 3f004cb7e..2ea56d4c4 100644 --- a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.html +++ b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.html @@ -103,13 +103,13 @@ class="btn btn-sm btn-outline-primary" id="dropdownSend" ngbDropdownToggle - [disabled]="disabled || !list.hasSelection || list.allSelected" + [disabled]="disabled || !canSendSelection" >
Send
- @if (emailEnabled) { - } diff --git a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.spec.ts b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.spec.ts index 041eed976..40d21f39b 100644 --- a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.spec.ts +++ b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.spec.ts @@ -208,6 +208,50 @@ describe('BulkEditorComponent', () => { expect(component.tagSelectionModel.selectionSize()).toEqual(1) }) + it('should allow sending an all-filtered selection that fits on the current page', () => { + jest + .spyOn(documentListViewService, 'hasSelection', 'get') + .mockReturnValue(true) + jest + .spyOn(documentListViewService, 'allSelected', 'get') + .mockReturnValue(true) + jest + .spyOn(documentListViewService, 'selectedCount', 'get') + .mockReturnValue(5) + jest + .spyOn(documentListViewService, 'selected', 'get') + .mockReturnValue(new Set([1, 2, 3, 4, 5])) + + fixture.detectChanges() + + expect(component.canSendSelection).toBe(true) + expect( + fixture.debugElement.query(By.css('#dropdownSend')).nativeElement.disabled + ).toBe(false) + }) + + it('should prevent sending an all-filtered selection spanning multiple pages', () => { + jest + .spyOn(documentListViewService, 'hasSelection', 'get') + .mockReturnValue(true) + jest + .spyOn(documentListViewService, 'allSelected', 'get') + .mockReturnValue(true) + jest + .spyOn(documentListViewService, 'selectedCount', 'get') + .mockReturnValue(6) + jest + .spyOn(documentListViewService, 'selected', 'get') + .mockReturnValue(new Set([1, 2, 3, 4, 5])) + + fixture.detectChanges() + + expect(component.canSendSelection).toBe(false) + expect( + fixture.debugElement.query(By.css('#dropdownSend')).nativeElement.disabled + ).toBe(true) + }) + it('should apply selection data to correspondents menu', () => { jest.spyOn(permissionsService, 'currentUserCan').mockReturnValue(true) fixture.detectChanges() @@ -1597,6 +1641,7 @@ describe('BulkEditorComponent', () => { expect(modal.componentInstance.customFields.length).toEqual(2) expect(modal.componentInstance.fieldsToAddIds).toEqual([1, 2]) expect(modal.componentInstance.selection).toEqual({ documents: [3, 4] }) + expect(modal.componentInstance.selectionCount).toEqual(2) expect(modal.componentInstance.documents).toEqual([3, 4]) modal.componentInstance.failed.emit() diff --git a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts index 60f478670..67b2e04ae 100644 --- a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts +++ b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts @@ -1041,6 +1041,14 @@ export class BulkEditorComponent return this.settings.get(SETTINGS_KEYS.EMAIL_ENABLED) } + public get canSendSelection(): boolean { + return ( + this.list.hasSelection && + (!this.list.allSelected || + this.list.selectedCount === this.list.selected.size) + ) + } + createShareLinkBundle() { const modal = this.modalService.open(ShareLinkBundleDialogComponent, { backdrop: 'static',