mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
Enhancement: next / previous shortcuts for document list (#8309)
This commit is contained in:
parent
e4578b4589
commit
f0e71330ac
@ -7405,18 +7405,32 @@
|
|||||||
<context context-type="linenumber">264</context>
|
<context context-type="linenumber">264</context>
|
||||||
</context-group>
|
</context-group>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="3629960544875360046" datatype="html">
|
||||||
|
<source>Previous page</source>
|
||||||
|
<context-group purpose="location">
|
||||||
|
<context context-type="sourcefile">src/app/components/document-list/document-list.component.ts</context>
|
||||||
|
<context context-type="linenumber">280</context>
|
||||||
|
</context-group>
|
||||||
|
</trans-unit>
|
||||||
|
<trans-unit id="3337301694210287595" datatype="html">
|
||||||
|
<source>Next page</source>
|
||||||
|
<context-group purpose="location">
|
||||||
|
<context context-type="sourcefile">src/app/components/document-list/document-list.component.ts</context>
|
||||||
|
<context context-type="linenumber">292</context>
|
||||||
|
</context-group>
|
||||||
|
</trans-unit>
|
||||||
<trans-unit id="2155249406916744630" datatype="html">
|
<trans-unit id="2155249406916744630" datatype="html">
|
||||||
<source>View "<x id="PH" equiv-text="this.list.activeSavedViewTitle"/>" saved successfully.</source>
|
<source>View "<x id="PH" equiv-text="this.list.activeSavedViewTitle"/>" saved successfully.</source>
|
||||||
<context-group purpose="location">
|
<context-group purpose="location">
|
||||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.ts</context>
|
<context context-type="sourcefile">src/app/components/document-list/document-list.component.ts</context>
|
||||||
<context context-type="linenumber">300</context>
|
<context context-type="linenumber">324</context>
|
||||||
</context-group>
|
</context-group>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="6837554170707123455" datatype="html">
|
<trans-unit id="6837554170707123455" datatype="html">
|
||||||
<source>View "<x id="PH" equiv-text="savedView.name"/>" created successfully.</source>
|
<source>View "<x id="PH" equiv-text="savedView.name"/>" created successfully.</source>
|
||||||
<context-group purpose="location">
|
<context-group purpose="location">
|
||||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.ts</context>
|
<context context-type="sourcefile">src/app/components/document-list/document-list.component.ts</context>
|
||||||
<context context-type="linenumber">343</context>
|
<context context-type="linenumber">367</context>
|
||||||
</context-group>
|
</context-group>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="739880801667335279" datatype="html">
|
<trans-unit id="739880801667335279" datatype="html">
|
||||||
|
@ -698,5 +698,31 @@ describe('DocumentListComponent', () => {
|
|||||||
fixture.detectChanges()
|
fixture.detectChanges()
|
||||||
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'o' }))
|
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'o' }))
|
||||||
expect(detailSpy).toHaveBeenCalledWith(docs[1].id)
|
expect(detailSpy).toHaveBeenCalledWith(docs[1].id)
|
||||||
|
|
||||||
|
const lotsOfDocs: Document[] = Array.from({ length: 100 }, (_, i) => ({
|
||||||
|
id: i + 1,
|
||||||
|
title: `Doc${i + 1}`,
|
||||||
|
notes: [],
|
||||||
|
tags$: new Subject(),
|
||||||
|
content: `document content ${i + 1}`,
|
||||||
|
}))
|
||||||
|
jest
|
||||||
|
.spyOn(documentListService, 'documents', 'get')
|
||||||
|
.mockReturnValue(lotsOfDocs)
|
||||||
|
jest
|
||||||
|
.spyOn(documentService, 'listAllFilteredIds')
|
||||||
|
.mockReturnValue(of(lotsOfDocs.map((d) => d.id)))
|
||||||
|
jest.spyOn(documentListService, 'getLastPage').mockReturnValue(4)
|
||||||
|
fixture.detectChanges()
|
||||||
|
|
||||||
|
expect(component.list.currentPage).toEqual(1)
|
||||||
|
document.dispatchEvent(
|
||||||
|
new KeyboardEvent('keydown', { key: 'ArrowRight', ctrlKey: true })
|
||||||
|
)
|
||||||
|
expect(component.list.currentPage).toEqual(2)
|
||||||
|
document.dispatchEvent(
|
||||||
|
new KeyboardEvent('keydown', { key: 'ArrowLeft', ctrlKey: true })
|
||||||
|
)
|
||||||
|
expect(component.list.currentPage).toEqual(1)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -273,6 +273,30 @@ export class DocumentListComponent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.hotKeyService
|
||||||
|
.addShortcut({
|
||||||
|
keys: 'control.arrowleft',
|
||||||
|
description: $localize`Previous page`,
|
||||||
|
})
|
||||||
|
.pipe(takeUntil(this.unsubscribeNotifier))
|
||||||
|
.subscribe(() => {
|
||||||
|
if (this.list.currentPage > 1) {
|
||||||
|
this.list.currentPage--
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
this.hotKeyService
|
||||||
|
.addShortcut({
|
||||||
|
keys: 'control.arrowright',
|
||||||
|
description: $localize`Next page`,
|
||||||
|
})
|
||||||
|
.pipe(takeUntil(this.unsubscribeNotifier))
|
||||||
|
.subscribe(() => {
|
||||||
|
if (this.list.currentPage < this.list.getLastPage()) {
|
||||||
|
this.list.currentPage++
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user