mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-28 03:46:06 -05:00 
			
		
		
		
	Merge pull request #273 from GruberViktor/dev
Added nav buttons in the document detail view
This commit is contained in:
		| @@ -34,11 +34,25 @@ | |||||||
|         </svg> <span class="d-none d-lg-inline" i18n>More like this</span> |         </svg> <span class="d-none d-lg-inline" i18n>More like this</span> | ||||||
|     </button> |     </button> | ||||||
|  |  | ||||||
|     <button type="button" class="btn btn-sm btn-outline-primary" (click)="close()"> |     <button type="button" class="btn btn-sm btn-outline-primary me-2" i18n-title title="Close" (click)="close()"> | ||||||
|         <svg class="buttonicon" fill="currentColor"> |         <svg class="buttonicon" fill="currentColor"> | ||||||
|             <use xlink:href="assets/bootstrap-icons.svg#x" /> |             <use xlink:href="assets/bootstrap-icons.svg#x" /> | ||||||
|         </svg> <span class="d-none d-lg-inline" i18n>Close</span> |         </svg> | ||||||
|     </button> |     </button> | ||||||
|  |  | ||||||
|  |     <div class="button-group"> | ||||||
|  |         <button type="button" class="btn btn-sm btn-outline-primary me-2" i18n-title title="Previous" (click)="previousDoc()" [disabled]="!hasPrevious()"> | ||||||
|  |             <svg class="buttonicon" fill="currentColor"> | ||||||
|  |                 <use xlink:href="assets/bootstrap-icons.svg#arrow-left" /> | ||||||
|  |             </svg> | ||||||
|  |         </button> | ||||||
|  |         <button type="button" class="btn btn-sm btn-outline-primary"  i18n-title title="Next" (click)="nextDoc()" [disabled]="!hasNext()"> | ||||||
|  |             <svg class="buttonicon" fill="currentColor"> | ||||||
|  |                 <use xlink:href="assets/bootstrap-icons.svg#arrow-right" /> | ||||||
|  |             </svg> | ||||||
|  |         </button> | ||||||
|  |     </div> | ||||||
|  |  | ||||||
| </app-page-header> | </app-page-header> | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -292,6 +292,22 @@ export class DocumentDetailComponent implements OnInit, OnDestroy, DirtyComponen | |||||||
|     return this.documentListViewService.hasNext(this.documentId) |     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]) | ||||||
|  |     }) | ||||||
|  |   } | ||||||
|  |    | ||||||
|  |   previousDoc () { | ||||||
|  |     this.documentListViewService.getPrevious(this.document.id).subscribe((prevDocId: number) => { | ||||||
|  |       this.router.navigate(['documents', prevDocId]) | ||||||
|  |     }) | ||||||
|  |   } | ||||||
|  |  | ||||||
|   pdfPreviewLoaded(pdf: PDFDocumentProxy) { |   pdfPreviewLoaded(pdf: PDFDocumentProxy) { | ||||||
|     this.previewNumPages = pdf.numPages |     this.previewNumPages = pdf.numPages | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -262,6 +262,13 @@ export class DocumentListViewService { | |||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   hasPrevious(doc: number) { | ||||||
|  |     if (this.documents) { | ||||||
|  |       let index = this.documents.findIndex(d => d.id == doc) | ||||||
|  |       return index != -1 && !(index == 0 && this.currentPage == 1) | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |  | ||||||
|   getNext(currentDocId: number): Observable<number> { |   getNext(currentDocId: number): Observable<number> { | ||||||
|     return new Observable(nextDocId => { |     return new Observable(nextDocId => { | ||||||
|       if (this.documents != null) { |       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() { |   updatePageSize() { | ||||||
|     let newPageSize = this.settings.get(SETTINGS_KEYS.DOCUMENT_LIST_SIZE) |     let newPageSize = this.settings.get(SETTINGS_KEYS.DOCUMENT_LIST_SIZE) | ||||||
|     if (newPageSize != this.currentPageSize) { |     if (newPageSize != this.currentPageSize) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 shamoon
					shamoon