From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Wed, 13 Nov 2024 00:21:10 +0000 (-0800) Subject: Enhancement: save & next / close shortcut key (#8243) X-Git-Tag: v2.14.0~1^2~126 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3633fb382f072e762559da7842f7bd04a3dab4ca;p=thirdparty%2Fpaperless-ngx.git Enhancement: save & next / close shortcut key (#8243) --- 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 efd7e8191a..41a576f01f 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 @@ -1221,6 +1221,14 @@ describe('DocumentDetailComponent', () => { ) expect(saveSpy).toHaveBeenCalled() + jest.spyOn(openDocumentsService, 'isDirty').mockReturnValue(true) + jest.spyOn(component, 'hasNext').mockReturnValue(true) + const saveNextSpy = jest.spyOn(component, 'saveEditNext') + document.dispatchEvent( + new KeyboardEvent('keydown', { key: 's', ctrlKey: true, shiftKey: true }) + ) + expect(saveNextSpy).toHaveBeenCalled() + const closeSpy = jest.spyOn(component, 'close') document.dispatchEvent(new KeyboardEvent('keydown', { key: 'escape' })) expect(closeSpy).toHaveBeenCalled() 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 3bd725c45d..9a9afadb86 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 @@ -509,6 +509,16 @@ export class DocumentDetailComponent .subscribe(() => { if (this.openDocumentService.isDirty(this.document)) this.save() }) + + this.hotKeyService + .addShortcut({ + keys: 'control.shift.s', + description: $localize`Save and close / next`, + }) + .pipe(takeUntil(this.unsubscribeNotifier)) + .subscribe(() => { + if (this.openDocumentService.isDirty(this.document)) this.saveEditNext() + }) } ngOnDestroy(): void {