]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Enhancement: save & next / close shortcut key (#8243)
authorshamoon <4887959+shamoon@users.noreply.github.com>
Wed, 13 Nov 2024 00:21:10 +0000 (16:21 -0800)
committerGitHub <noreply@github.com>
Wed, 13 Nov 2024 00:21:10 +0000 (16:21 -0800)
src-ui/src/app/components/document-detail/document-detail.component.spec.ts
src-ui/src/app/components/document-detail/document-detail.component.ts

index efd7e8191a682b4624ef9e1107401f195036c1df..41a576f01f4c5942ca09fd325ee024a7e769ce5c 100644 (file)
@@ -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()
index 3bd725c45dc26e77e09d971be187c4a3278319eb..9a9afadb8627863eae848414e3c5d0d5ff3d7e16 100644 (file)
@@ -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 {