diff --git a/src-ui/e2e/document-detail/document-detail.spec.ts b/src-ui/e2e/document-detail/document-detail.spec.ts index a3083f521..d96a02f37 100644 --- a/src-ui/e2e/document-detail/document-detail.spec.ts +++ b/src-ui/e2e/document-detail/document-detail.spec.ts @@ -12,9 +12,13 @@ test('should activate / deactivate save button when changes are saved', async ({ await expect(page.getByTitle('Storage path', { exact: true })).toHaveText( /\w+/ ) - await expect(page.getByRole('button', { name: 'Save' })).toBeDisabled() + await expect( + page.getByRole('button', { name: 'Save', exact: true }) + ).toBeDisabled() await page.getByTitle('Storage path').getByTitle('Clear all').click() - await expect(page.getByRole('button', { name: 'Save' })).toBeEnabled() + await expect( + page.getByRole('button', { name: 'Save', exact: true }) + ).toBeEnabled() }) test('should warn on unsaved changes', async ({ page }) => { @@ -23,13 +27,17 @@ test('should warn on unsaved changes', async ({ page }) => { await expect(page.getByTitle('Correspondent', { exact: true })).toHaveText( /\w+/ ) - await expect(page.getByRole('button', { name: 'Save' })).toBeDisabled() + await expect( + page.getByRole('button', { name: 'Save', exact: true }) + ).toBeDisabled() await page .getByTitle('Storage path', { exact: true }) .getByTitle('Clear all') .click() - await expect(page.getByRole('button', { name: 'Save' })).toBeEnabled() - await page.getByRole('button', { name: 'Close' }).click() + await expect( + page.getByRole('button', { name: 'Save', exact: true }) + ).toBeEnabled() + await page.getByRole('button', { name: 'Close', exact: true }).click() await expect(page.getByRole('dialog')).toHaveText(/unsaved changes/) await page.getByRole('button', { name: 'Cancel' }).click() await page.getByRole('link', { name: 'Close all' }).click() diff --git a/src-ui/messages.xlf b/src-ui/messages.xlf index b52c8e702..f8f7e0bbb 100644 --- a/src-ui/messages.xlf +++ b/src-ui/messages.xlf @@ -723,7 +723,7 @@ src/app/components/manage/settings/settings.component.ts - 593 + 594 @@ -814,28 +814,28 @@ Last 7 days src/app/components/common/date-dropdown/date-dropdown.component.ts - 43 + 42 Last month src/app/components/common/date-dropdown/date-dropdown.component.ts - 48 + 47 Last 3 months src/app/components/common/date-dropdown/date-dropdown.component.ts - 53 + 52 Last year src/app/components/common/date-dropdown/date-dropdown.component.ts - 58 + 57 @@ -1073,7 +1073,7 @@ src/app/components/document-detail/document-detail.component.html - 196 + 198 src/app/components/document-list/save-view-config-dialog/save-view-config-dialog.component.html @@ -1116,21 +1116,14 @@ Create new item src/app/components/common/edit-dialog/edit-dialog.component.ts - 83 + 88 Edit item src/app/components/common/edit-dialog/edit-dialog.component.ts - 87 - - - - Could not save element: - - src/app/components/common/edit-dialog/edit-dialog.component.ts - 91 + 92 @@ -1594,7 +1587,7 @@ src/app/components/manage/management-list/management-list.component.ts - 193 + 194 src/app/components/manage/settings/settings.component.html @@ -2303,7 +2296,7 @@ src/app/components/document-list/filter-editor/filter-editor.component.ts - 191 + 202 src/app/services/rest/document.service.ts @@ -2758,7 +2751,7 @@ src/app/components/document-detail/document-detail.component.html - 215 + 218 @@ -2779,96 +2772,103 @@ Save & next src/app/components/document-detail/document-detail.component.html - 195 + 196 + + + + Save & close + + src/app/components/document-detail/document-detail.component.html + 197 An error occurred loading content: src/app/components/document-detail/document-detail.component.ts - 254,256 + 252,254 Error retrieving metadata src/app/components/document-detail/document-detail.component.ts - 397 + 395 Error retrieving suggestions. src/app/components/document-detail/document-detail.component.ts - 419 + 417 Document saved successfully. src/app/components/document-detail/document-detail.component.ts - 531 + 529 src/app/components/document-detail/document-detail.component.ts - 539 + 537 Error saving document src/app/components/document-detail/document-detail.component.ts - 544 + 542 src/app/components/document-detail/document-detail.component.ts - 589 + 587 Confirm delete src/app/components/document-detail/document-detail.component.ts - 618 + 616 src/app/components/manage/management-list/management-list.component.ts - 189 + 190 Do you really want to delete document ""? src/app/components/document-detail/document-detail.component.ts - 619 + 617 The files for this document will be deleted permanently. This operation cannot be undone. src/app/components/document-detail/document-detail.component.ts - 620 + 618 Delete document src/app/components/document-detail/document-detail.component.ts - 622 + 620 Error deleting document: src/app/components/document-detail/document-detail.component.ts - 642,644 + 640,642 Redo OCR confirm src/app/components/document-detail/document-detail.component.ts - 665 + 663 src/app/components/document-list/bulk-editor/bulk-editor.component.ts @@ -2879,14 +2879,14 @@ This operation will permanently redo OCR for this document. src/app/components/document-detail/document-detail.component.ts - 666 + 664 This operation cannot be undone. src/app/components/document-detail/document-detail.component.ts - 667 + 665 src/app/components/document-list/bulk-editor/bulk-editor.component.ts @@ -2898,26 +2898,26 @@ src/app/components/manage/settings/settings.component.ts - 691 + 694 src/app/components/manage/settings/settings.component.ts - 749 + 754 src/app/components/manage/settings/settings.component.ts - 814 + 821 src/app/components/manage/settings/settings.component.ts - 875 + 884 Proceed src/app/components/document-detail/document-detail.component.ts - 669 + 667 src/app/components/document-list/bulk-editor/bulk-editor.component.ts @@ -2925,26 +2925,26 @@ src/app/components/manage/settings/settings.component.ts - 693 + 696 src/app/components/manage/settings/settings.component.ts - 751 + 756 src/app/components/manage/settings/settings.component.ts - 816 + 823 src/app/components/manage/settings/settings.component.ts - 877 + 886 Redo OCR operation will begin in the background. Close and re-open or reload this document after the operation has completed to see new content. src/app/components/document-detail/document-detail.component.ts - 677 + 675 @@ -2953,7 +2953,7 @@ )"/> src/app/components/document-detail/document-detail.component.ts - 688,690 + 686,688 @@ -3499,7 +3499,7 @@ src/app/components/document-list/filter-editor/filter-editor.component.ts - 196 + 207 src/app/services/rest/document.service.ts @@ -3628,133 +3628,147 @@ Correspondent: src/app/components/document-list/filter-editor/filter-editor.component.ts - 117,119 + 118,120 Without correspondent src/app/components/document-list/filter-editor/filter-editor.component.ts - 121 + 122 - - Type: + + Document type: src/app/components/document-list/filter-editor/filter-editor.component.ts - 126,128 + 128,130 Without document type src/app/components/document-list/filter-editor/filter-editor.component.ts - 130 + 132 + + + + Storage path: + + src/app/components/document-list/filter-editor/filter-editor.component.ts + 138,140 + + + + Without storage path + + src/app/components/document-list/filter-editor/filter-editor.component.ts + 142 Tag: src/app/components/document-list/filter-editor/filter-editor.component.ts - 134,136 + 146,148 Without any tag src/app/components/document-list/filter-editor/filter-editor.component.ts - 140 + 152 Title: src/app/components/document-list/filter-editor/filter-editor.component.ts - 144 + 156 ASN: src/app/components/document-list/filter-editor/filter-editor.component.ts - 147 + 159 Owner: src/app/components/document-list/filter-editor/filter-editor.component.ts - 150 + 162 Owner not in: src/app/components/document-list/filter-editor/filter-editor.component.ts - 153 + 165 Without an owner src/app/components/document-list/filter-editor/filter-editor.component.ts - 156 + 168 Title & content src/app/components/document-list/filter-editor/filter-editor.component.ts - 194 + 205 Advanced search src/app/components/document-list/filter-editor/filter-editor.component.ts - 199 + 210 More like src/app/components/document-list/filter-editor/filter-editor.component.ts - 205 + 216 equals src/app/components/document-list/filter-editor/filter-editor.component.ts - 224 + 235 is empty src/app/components/document-list/filter-editor/filter-editor.component.ts - 228 + 239 is not empty src/app/components/document-list/filter-editor/filter-editor.component.ts - 232 + 243 greater than src/app/components/document-list/filter-editor/filter-editor.component.ts - 236 + 247 less than src/app/components/document-list/filter-editor/filter-editor.component.ts - 240 + 251 @@ -3836,14 +3850,14 @@ Error saving note: src/app/components/document-notes/document-notes.component.ts - 65 + 64 Error deleting note: src/app/components/document-notes/document-notes.component.ts - 81 + 80 @@ -4013,7 +4027,7 @@ Automatic src/app/components/manage/management-list/management-list.component.ts - 100 + 103 src/app/data/matching-model.ts @@ -4024,7 +4038,7 @@ None src/app/components/manage/management-list/management-list.component.ts - 102 + 105 src/app/data/matching-model.ts @@ -4035,42 +4049,35 @@ Successfully created . src/app/components/manage/management-list/management-list.component.ts - 142 + 145 Error occurred while creating . src/app/components/manage/management-list/management-list.component.ts - 147 + 150 Successfully updated . src/app/components/manage/management-list/management-list.component.ts - 163 + 166 Error occurred while saving . src/app/components/manage/management-list/management-list.component.ts - 168 - - - - Do you really want to delete the ? - - src/app/components/manage/management-list/management-list.component.ts - 176 + 171 Associated documents will not be deleted. src/app/components/manage/management-list/management-list.component.ts - 191 + 192 @@ -4079,7 +4086,7 @@ )"/> src/app/components/manage/management-list/management-list.component.ts - 204,206 + 205,207 @@ -4464,231 +4471,231 @@ Saved view "" deleted. src/app/components/manage/settings/settings.component.ts - 475 + 476 Settings saved src/app/components/manage/settings/settings.component.ts - 577 + 578 Settings were saved successfully. src/app/components/manage/settings/settings.component.ts - 578 + 579 Settings were saved successfully. Reload is required to apply some changes. src/app/components/manage/settings/settings.component.ts - 582 + 583 Reload now src/app/components/manage/settings/settings.component.ts - 583 + 584 Use system language src/app/components/manage/settings/settings.component.ts - 602 + 603 Use date format of display language src/app/components/manage/settings/settings.component.ts - 609 + 610 Error while storing settings on server. src/app/components/manage/settings/settings.component.ts - 629 + 630 Password has been changed, you will be logged out momentarily. src/app/components/manage/settings/settings.component.ts - 659 + 662 Saved user "". src/app/components/manage/settings/settings.component.ts - 666 + 669 Error saving user. src/app/components/manage/settings/settings.component.ts - 678 + 681 Confirm delete user account src/app/components/manage/settings/settings.component.ts - 689 + 692 This operation will permanently delete this user account. src/app/components/manage/settings/settings.component.ts - 690 + 693 Deleted user src/app/components/manage/settings/settings.component.ts - 699 + 702 Error deleting user. src/app/components/manage/settings/settings.component.ts - 707 + 710 Saved group "". src/app/components/manage/settings/settings.component.ts - 726 + 731 Error saving group. src/app/components/manage/settings/settings.component.ts - 736 + 741 Confirm delete user group src/app/components/manage/settings/settings.component.ts - 747 + 752 This operation will permanently delete this user group. src/app/components/manage/settings/settings.component.ts - 748 + 753 Deleted group src/app/components/manage/settings/settings.component.ts - 757 + 762 Error deleting group. src/app/components/manage/settings/settings.component.ts - 765 + 770 Saved account "". src/app/components/manage/settings/settings.component.ts - 789 + 796 Error saving account. src/app/components/manage/settings/settings.component.ts - 801 + 808 Confirm delete mail account src/app/components/manage/settings/settings.component.ts - 812 + 819 This operation will permanently delete this mail account. src/app/components/manage/settings/settings.component.ts - 813 + 820 Deleted mail account src/app/components/manage/settings/settings.component.ts - 822 + 829 Error deleting mail account. src/app/components/manage/settings/settings.component.ts - 831 + 838 Saved rule "". src/app/components/manage/settings/settings.component.ts - 850 + 859 Error saving rule. src/app/components/manage/settings/settings.component.ts - 862 + 871 Confirm delete mail rule src/app/components/manage/settings/settings.component.ts - 873 + 882 This operation will permanently delete this mail rule. src/app/components/manage/settings/settings.component.ts - 874 + 883 Deleted mail rule src/app/components/manage/settings/settings.component.ts - 883 + 892 Error deleting mail rule. src/app/components/manage/settings/settings.component.ts - 892 + 901 @@ -4786,29 +4793,29 @@ 103 - - Failed  + + Failed src/app/components/manage/tasks/tasks.component.html 110 - - Complete  + + Complete src/app/components/manage/tasks/tasks.component.html 116 - - Started  + + Started src/app/components/manage/tasks/tasks.component.html 122 - - Queued  + + Queued src/app/components/manage/tasks/tasks.component.html 128 @@ -5200,196 +5207,196 @@ English (US) src/app/services/settings.service.ts - 159 + 163 Arabic src/app/services/settings.service.ts - 165 + 169 Belarusian src/app/services/settings.service.ts - 171 + 175 Catalan src/app/services/settings.service.ts - 177 + 181 Czech src/app/services/settings.service.ts - 183 + 187 Danish src/app/services/settings.service.ts - 189 + 193 German src/app/services/settings.service.ts - 195 + 199 English (GB) src/app/services/settings.service.ts - 201 + 205 Spanish src/app/services/settings.service.ts - 207 + 211 Finnish src/app/services/settings.service.ts - 213 + 217 French src/app/services/settings.service.ts - 219 + 223 Italian src/app/services/settings.service.ts - 225 + 229 Luxembourgish src/app/services/settings.service.ts - 231 + 235 Dutch src/app/services/settings.service.ts - 237 + 241 Polish src/app/services/settings.service.ts - 243 + 247 Portuguese (Brazil) src/app/services/settings.service.ts - 249 + 253 Portuguese src/app/services/settings.service.ts - 255 + 259 Romanian src/app/services/settings.service.ts - 261 + 265 Russian src/app/services/settings.service.ts - 267 + 271 Slovenian src/app/services/settings.service.ts - 273 + 277 Serbian src/app/services/settings.service.ts - 279 + 283 Swedish src/app/services/settings.service.ts - 285 + 289 Turkish src/app/services/settings.service.ts - 291 + 295 Chinese Simplified src/app/services/settings.service.ts - 297 + 301 ISO 8601 src/app/services/settings.service.ts - 314 + 318 Successfully completed one-time migratration of settings to the database! src/app/services/settings.service.ts - 425 + 429 Unable to migrate settings to the database, please try saving manually. src/app/services/settings.service.ts - 426 + 430 You can restart the tour from the settings page. src/app/services/settings.service.ts - 500 + 504 @@ -5403,28 +5410,28 @@ Connecting... src/app/services/upload-documents.service.ts - 33 + 31 Uploading... src/app/services/upload-documents.service.ts - 45 + 43 Upload complete, waiting... src/app/services/upload-documents.service.ts - 48 + 46 HTTP error: src/app/services/upload-documents.service.ts - 64 + 62 diff --git a/src-ui/src/app/components/document-detail/document-detail.component.html b/src-ui/src/app/components/document-detail/document-detail.component.html index 1fa9ecb20..6b42fade8 100644 --- a/src-ui/src/app/components/document-detail/document-detail.component.html +++ b/src-ui/src/app/components/document-detail/document-detail.component.html @@ -191,9 +191,12 @@
-   -   -   + + + + + + diff --git a/src-ui/src/app/components/document-detail/document-detail.component.spec.ts b/src-ui/src/app/components/document-detail/document-detail.component.spec.ts index 0e6a99d89..6ca99803c 100644 --- a/src-ui/src/app/components/document-detail/document-detail.component.spec.ts +++ b/src-ui/src/app/components/document-detail/document-detail.component.spec.ts @@ -372,12 +372,25 @@ describe('DocumentDetailComponent', () => { const updateSpy = jest.spyOn(documentService, 'update') const toastSpy = jest.spyOn(toastService, 'showInfo') updateSpy.mockImplementation((o) => of(doc)) - component.save() + component.save(true) expect(updateSpy).toHaveBeenCalled() expect(closeSpy).toHaveBeenCalled() expect(toastSpy).toHaveBeenCalledWith('Document saved successfully.') }) + it('should support save without close and show success toast', () => { + initNormally() + component.title = 'Foo Bar' + const closeSpy = jest.spyOn(component, 'close') + const updateSpy = jest.spyOn(documentService, 'update') + const toastSpy = jest.spyOn(toastService, 'showInfo') + updateSpy.mockImplementation((o) => of(doc)) + component.save() + expect(updateSpy).toHaveBeenCalled() + expect(closeSpy).not.toHaveBeenCalled() + expect(toastSpy).toHaveBeenCalledWith('Document saved successfully.') + }) + it('should show toast error on save if error occurs', () => { currentUserHasObjectPermissions = true initNormally() @@ -406,7 +419,7 @@ describe('DocumentDetailComponent', () => { updateSpy.mockImplementation(() => throwError(() => new Error('failed to save')) ) - component.save() + component.save(true) expect(updateSpy).toHaveBeenCalled() expect(closeSpy).toHaveBeenCalled() expect(toastSpy).toHaveBeenCalledWith('Document saved successfully.') @@ -430,7 +443,7 @@ describe('DocumentDetailComponent', () => { expect }) - it('should show toast error on saveAll if error occurs', () => { + it('should show toast error on save & next if error occurs', () => { currentUserHasObjectPermissions = true initNormally() component.title = 'Foo Bar' @@ -448,6 +461,39 @@ describe('DocumentDetailComponent', () => { ) }) + it('should show save button and save & close or save & next', () => { + const nextSpy = jest.spyOn(component, 'hasNext') + nextSpy.mockReturnValueOnce(false) + fixture.detectChanges() + expect( + fixture.debugElement + .queryAll(By.css('button')) + .find((b) => b.nativeElement.textContent === 'Save') + ).not.toBeUndefined() + expect( + fixture.debugElement + .queryAll(By.css('button')) + .find((b) => b.nativeElement.textContent === 'Save & close') + ).not.toBeUndefined() + expect( + fixture.debugElement + .queryAll(By.css('button')) + .find((b) => b.nativeElement.textContent === 'Save & next') + ).toBeUndefined() + nextSpy.mockReturnValue(true) + fixture.detectChanges() + expect( + fixture.debugElement + .queryAll(By.css('button')) + .find((b) => b.nativeElement.textContent === 'Save & close') + ).toBeUndefined() + expect( + fixture.debugElement + .queryAll(By.css('button')) + .find((b) => b.nativeElement.textContent === 'Save & next') + ).not.toBeUndefined() + }) + it('should allow close and navigate to documents by default', () => { initNormally() const navigateSpy = jest.spyOn(router, 'navigate') diff --git a/src-ui/src/app/components/document-detail/document-detail.component.ts b/src-ui/src/app/components/document-detail/document-detail.component.ts index 654f68a50..cd402817a 100644 --- a/src-ui/src/app/components/document-detail/document-detail.component.ts +++ b/src-ui/src/app/components/document-detail/document-detail.component.ts @@ -518,7 +518,7 @@ export class DocumentDetailComponent }) } - save() { + save(close: boolean = false) { this.networkActive = true this.documentsService .update(this.document) @@ -527,7 +527,7 @@ export class DocumentDetailComponent next: () => { this.store.next(this.documentForm.value) this.toastService.showInfo($localize`Document saved successfully.`) - this.close() + close && this.close() this.networkActive = false this.error = null }, @@ -535,7 +535,7 @@ export class DocumentDetailComponent this.networkActive = false if (!this.userCanEdit) { this.toastService.showInfo($localize`Document saved successfully.`) - this.close() + close && this.close() } else { this.error = error.error this.toastService.showError(