From 52f535a3e815eb7de1a53fedff1bc5f76cc1a24c Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 17 Nov 2020 17:55:20 -0500 Subject: [PATCH] LPXXX Staff cat browse results paging WIP Signed-off-by: Bill Erickson --- .../app/staff/catalog/browse/results.component.ts | 4 +- .../staff/catalog/result/results.component.html | 4 ++ .../app/staff/catalog/result/results.component.ts | 45 +++++++++++++++++++++- .../src/app/staff/catalog/search-form.component.ts | 8 +++- 4 files changed, 55 insertions(+), 6 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/browse/results.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/browse/results.component.ts index 3aeaf6b32c..3ae935a59f 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/browse/results.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/browse/results.component.ts @@ -119,9 +119,7 @@ export class BrowseResultsComponent implements OnInit, OnDestroy { searchByBrowseEntryParams(result) { const ctx = this.searchContext.clone(); - ctx.browseSearch.reset(); // we're done browsing - ctx.termSearch.hasBrowseEntry = - result.browse_entry + ',' + result.fields; + ctx.termSearch.hasBrowseEntry = result.browse_entry + ',' + result.fields; return this.catUrl.toUrlParams(ctx); } diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/result/results.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/result/results.component.html index 515a376dd9..fbcfe99266 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/result/results.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/result/results.component.html @@ -35,6 +35,10 @@

Results for browse "{{searchContext.termSearch.browseEntry.value()}}"

+
+ + +

Search Results ({{searchContext.result.count}})

diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/result/results.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/result/results.component.ts index edcb381044..bd80f38434 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/result/results.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/result/results.component.ts @@ -28,6 +28,8 @@ export class ResultsComponent implements OnInit, OnDestroy { searchSub: Subscription; routeSub: Subscription; basketSub: Subscription; + prevBrowseResult: any; + nextBrowseResult: any; constructor( private route: ActivatedRoute, @@ -62,12 +64,17 @@ export class ResultsComponent implements OnInit, OnDestroy { }); // After each completed search, update the record selector. - this.searchSub = this.cat.onSearchComplete.subscribe( - ctx => this.applyRecordSelection()); + this.searchSub = this.cat.onSearchComplete.subscribe(ctx => { + this.applyRecordSelection(); + }); // Watch for basket changes applied by other components. this.basketSub = this.basket.onChange.subscribe( () => this.applyRecordSelection()); + + + // Load browse data to support browse paging. + this.loadBrowsePaging(); } ngOnDestroy() { @@ -126,6 +133,40 @@ export class ResultsComponent implements OnInit, OnDestroy { this.basket.removeRecordIds(ids); } } + + loadBrowsePaging() { + if (!this.searchContext.termSearch.hasBrowseEntry || + !this.searchContext.browseSearch.value) { return; } + + const mbeId = Number( // for this page + this.searchContext.termSearch.hasBrowseEntry.split(',')[0]); + + const ctx = this.searchContext.clone(); + // force a browse search + ctx.termSearch.hasBrowseEntry = null; + + let previous: any; + + this.cat.browse(ctx).subscribe(result => { + if (!this.prevBrowseResult && result.browse_entry === mbeId) { + console.log('setting previous to ', previous.browse_entry); + this.prevBrowseResult = previous; + } else if (previous && previous.browse_entry === mbeId) { + console.log('setting next to ', result.browse_entry); + this.nextBrowseResult = result; + } + previous = result; + }); + } + + browseNav(prev?: boolean) { + const ctx = this.searchContext; + const res = prev ? this.prevBrowseResult : this.nextBrowseResult + console.log('res is ', res); + ctx.termSearch.hasBrowseEntry = res.browse_entry + ',' + res.fields; + this.staffCat.search(); + this.loadBrowsePaging(); + } } diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.ts index 9dcca68570..2b4faadad3 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.ts @@ -93,7 +93,13 @@ export class SearchFormComponent implements OnInit, AfterViewInit { this.searchTab = 'marc'; } else if (this.context.identSearch.isSearchable()) { this.searchTab = 'ident'; - } else if (this.context.browseSearch.isSearchable()) { + + // Browse search may remain 'searchable' even though we + // are displaying bibs linked to a browse entry. + // This is so browse search paging can be added to + // the record list page. + } else if (this.context.browseSearch.isSearchable() + && !this.context.termSearch.hasBrowseEntry) { this.searchTab = 'browse'; } else if (this.context.termSearch.isSearchable()) { this.searchTab = 'term'; -- 2.11.0