Added nav buttons in the document detail view

Sometimes, when you are looking for a document, you need to go into the document-detail view
to read the pdf. To view the next document in the detail view, normally you would go back and
then click on the next.

Here I added two buttons to the toolbar to traverse throught the documents easily.
This commit is contained in:
Viktor
2022-03-11 17:35:38 +01:00
parent 20a76e56f6
commit 0975c02635
3 changed files with 64 additions and 1 deletions

View File

@@ -262,6 +262,13 @@ export class DocumentListViewService {
}
}
hasPrevious(doc: number) {
if (this.documents) {
let index = this.documents.findIndex(d => d.id == doc)
return !(index == 0 && this.currentPage == 1)
}
}
getNext(currentDocId: number): Observable<number> {
return new Observable(nextDocId => {
if (this.documents != null) {
@@ -286,6 +293,30 @@ export class DocumentListViewService {
})
}
getPrevious(currentDocId: number): Observable<number> {
return new Observable(prevDocId => {
if (this.documents != null) {
let index = this.documents.findIndex(d => d.id == currentDocId)
if (index != 0) {
prevDocId.next(this.documents[index-1].id)
prevDocId.complete()
} else if (this.currentPage > 1) {
this.currentPage -= 1
this.reload(() => {
prevDocId.next(this.documents[this.documents.length - 1].id)
prevDocId.complete()
})
} else {
prevDocId.complete()
}
} else {
prevDocId.complete()
}
})
}
updatePageSize() {
let newPageSize = this.settings.get(SETTINGS_KEYS.DOCUMENT_LIST_SIZE)
if (newPageSize != this.currentPageSize) {