From 12599112755c239e999ad65f6295b65d7c4c4396 Mon Sep 17 00:00:00 2001 From: Viktor Date: Fri, 11 Mar 2022 17:35:38 +0100 Subject: [PATCH 1/4] 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. --- .../document-detail.component.html | 16 +++++++++- .../document-detail.component.ts | 18 +++++++++++ .../services/document-list-view.service.ts | 31 +++++++++++++++++++ 3 files changed, 64 insertions(+), 1 deletion(-) 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 b62d805c3..ff2e30d6e 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 @@ -34,11 +34,25 @@  More like this - + +
+ + +
+ 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 e751f59f8..8bb3de79f 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 @@ -292,6 +292,24 @@ export class DocumentDetailComponent implements OnInit, OnDestroy, DirtyComponen return this.documentListViewService.hasNext(this.documentId) } + hasPrevious() { + return this.documentListViewService.hasPrevious(this.documentId) + } + + nextDoc() { + this.documentListViewService.getNext(this.document.id).subscribe((nextDocId: number) => { + this.router.navigate(['documents', nextDocId]) + this.titleInput?.focus() + }) + } + + previousDoc () { + this.documentListViewService.getPrevious(this.document.id).subscribe((prevDocId: number) => { + this.router.navigate(['documents', prevDocId]) + this.titleInput?.focus() + }) + } + pdfPreviewLoaded(pdf: PDFDocumentProxy) { this.previewNumPages = pdf.numPages } diff --git a/src-ui/src/app/services/document-list-view.service.ts b/src-ui/src/app/services/document-list-view.service.ts index 4e1a8aad4..70d8a19df 100644 --- a/src-ui/src/app/services/document-list-view.service.ts +++ b/src-ui/src/app/services/document-list-view.service.ts @@ -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 { return new Observable(nextDocId => { if (this.documents != null) { @@ -286,6 +293,30 @@ export class DocumentListViewService { }) } + getPrevious(currentDocId: number): Observable { + 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) { From 6cbbd0c5150ffdfcb03adaa741f83539cf8f7eff Mon Sep 17 00:00:00 2001 From: GruberViktor <55293739+GruberViktor@users.noreply.github.com> Date: Fri, 11 Mar 2022 20:16:53 +0100 Subject: [PATCH 2/4] Apply suggestions from code review Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com> --- .../document-detail/document-detail.component.html | 10 +++++----- src-ui/src/app/services/document-list-view.service.ts | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) 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 ff2e30d6e..19403b9e4 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 @@ -34,22 +34,22 @@  More like this -
- -
diff --git a/src-ui/src/app/services/document-list-view.service.ts b/src-ui/src/app/services/document-list-view.service.ts index 70d8a19df..4455520f6 100644 --- a/src-ui/src/app/services/document-list-view.service.ts +++ b/src-ui/src/app/services/document-list-view.service.ts @@ -265,7 +265,7 @@ export class DocumentListViewService { hasPrevious(doc: number) { if (this.documents) { let index = this.documents.findIndex(d => d.id == doc) - return !(index == 0 && this.currentPage == 1) + return index != -1 && !(index == 0 && this.currentPage == 1) } } From d02a0b221351ecb470bc44b1bb9c0c9cb531e2b7 Mon Sep 17 00:00:00 2001 From: GruberViktor <55293739+GruberViktor@users.noreply.github.com> Date: Fri, 11 Mar 2022 20:22:39 +0100 Subject: [PATCH 3/4] remove text from close-button in the document-detail view Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com> --- .../components/document-detail/document-detail.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 19403b9e4..5cdaf420d 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 @@ -37,7 +37,7 @@
From 63aafd313335172aa8fb7306eec77eb167f509e7 Mon Sep 17 00:00:00 2001 From: GruberViktor <55293739+GruberViktor@users.noreply.github.com> Date: Fri, 11 Mar 2022 20:54:24 +0100 Subject: [PATCH 4/4] remove automatic focus on title in document-detail view Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com> --- .../app/components/document-detail/document-detail.component.ts | 2 -- 1 file changed, 2 deletions(-) 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 8bb3de79f..052e5cb40 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 @@ -299,14 +299,12 @@ export class DocumentDetailComponent implements OnInit, OnDestroy, DirtyComponen nextDoc() { this.documentListViewService.getNext(this.document.id).subscribe((nextDocId: number) => { this.router.navigate(['documents', nextDocId]) - this.titleInput?.focus() }) } previousDoc () { this.documentListViewService.getPrevious(this.document.id).subscribe((prevDocId: number) => { this.router.navigate(['documents', prevDocId]) - this.titleInput?.focus() }) }