lpxxx Angular catalog record tab next/prev
authorBill Erickson <berickxx@gmail.com>
Tue, 19 Mar 2019 17:34:39 +0000 (13:34 -0400)
committerBill Erickson <berickxx@gmail.com>
Tue, 19 Mar 2019 17:34:42 +0000 (13:34 -0400)
Navigation through results on the record detail page stays on same tab.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/staff/catalog/record/pagination.component.ts
Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.html

index 793767b..3c63af0 100644 (file)
@@ -18,6 +18,14 @@ export class RecordPaginationComponent implements OnInit {
     initDone = false;
     searchContext: CatalogSearchContext;
 
+    _recordTab: string;
+    @Input() set recordTab(tab: string) {
+        this._recordTab = tab;
+    }
+    get recordTab(): string {
+        return this._recordTab;
+    }
+
     @Input() set recordId(id: number) {
         this.id = id;
         // Only apply new record data after the initial load
@@ -38,41 +46,33 @@ export class RecordPaginationComponent implements OnInit {
         this.setIndex();
     }
 
+    routeToRecord(id: number) {
+        let url = '/staff/catalog/record/' + id;
+        if (this.recordTab) { url += '/' + this.recordTab; }
+        const params = this.catUrl.toUrlParams(this.searchContext);
+        this.router.navigate([url], params);
+    }
+
     firstRecord(): void {
-        this.findRecordAtIndex(0).then(id => {
-            const params = this.catUrl.toUrlParams(this.searchContext);
-            this.router.navigate(
-                ['/staff/catalog/record/' + id], {queryParams: params});
-        });
+        this.findRecordAtIndex(0)
+        .then(id => this.routeToRecord(id));
     }
 
     lastRecord(): void {
-        this.findRecordAtIndex(
-            this.searchContext.result.count - 1
-        ).then(id => {
-            const params = this.catUrl.toUrlParams(this.searchContext);
-            this.router.navigate(
-                ['/staff/catalog/record/' + id], {queryParams: params});
-        });
+        this.findRecordAtIndex(this.searchContext.result.count - 1)
+        .then(id => this.routeToRecord(id));
     }
 
     nextRecord(): void {
-        this.findRecordAtIndex(this.index + 1).then(id => {
-            const params = this.catUrl.toUrlParams(this.searchContext);
-            this.router.navigate(
-                ['/staff/catalog/record/' + id], {queryParams: params});
-        });
+        this.findRecordAtIndex(this.index + 1)
+        .then(id => this.routeToRecord(id));
     }
 
     prevRecord(): void {
-        this.findRecordAtIndex(this.index - 1).then(id => {
-            const params = this.catUrl.toUrlParams(this.searchContext);
-            this.router.navigate(
-                ['/staff/catalog/record/' + id], {queryParams: params});
-        });
+        this.findRecordAtIndex(this.index - 1)
+        .then(id => this.routeToRecord(id));
     }
 
-
     // Returns the offset of the record within the search results as a whole.
     searchIndex(idx: number): number {
         return idx + this.searchContext.pager.offset;
index b583cf7..4508870 100644 (file)
@@ -3,7 +3,7 @@
   <div class="row ml-0 mr-0">
     <div id='staff-catalog-bib-navigation'>
       <div *ngIf="searchContext.isSearchable()">
-        <eg-catalog-record-pagination [recordId]="recordId">
+        <eg-catalog-record-pagination [recordId]="recordId" [recordTab]="recordTab">
         </eg-catalog-record-pagination>
       </div>
     </div>