From: Bill Erickson Date: Tue, 19 Mar 2019 17:34:39 +0000 (-0400) Subject: lpxxx Angular catalog record tab next/prev X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=d0d601b6cc95bd4e02717d873ee6686237aa306d;p=working%2FEvergreen.git lpxxx Angular catalog record tab next/prev Navigation through results on the record detail page stays on same tab. Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/pagination.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/record/pagination.component.ts index 793767b38f..3c63af030e 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/pagination.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/pagination.component.ts @@ -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; diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.html index b583cf7e71..450887034d 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.html @@ -3,7 +3,7 @@
- +