From: Bill Erickson Date: Mon, 6 Jan 2020 16:05:52 +0000 (-0500) Subject: LP1850546 Record detail shelf browse X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=81a018c686c96385d358d378609b200532b51be0;p=evergreen%2Ftadl.git LP1850546 Record detail shelf browse Adds support for browsing call numbers directly from a record detail page, similar to the TPAC's 'Shelf Browser' tab in its detail page. Add support for jumping to a record detail page or a new author search from each shelf browse entry. Signed-off-by: Bill Erickson Signed-off-by: Ruth Frasur --- diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/catalog.service.ts b/Open-ILS/src/eg2/src/app/staff/catalog/catalog.service.ts index 05f58814bf..e46c1b4a1a 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/catalog.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/catalog.service.ts @@ -5,6 +5,7 @@ import {OrgService} from '@eg/core/org.service'; import {CatalogService} from '@eg/share/catalog/catalog.service'; import {CatalogUrlService} from '@eg/share/catalog/catalog-url.service'; import {CatalogSearchContext} from '@eg/share/catalog/search-context'; +import {BibRecordSummary} from '@eg/share/catalog/bib-record.service'; /** * Shared bits needed by the staff version of the catalog. @@ -122,6 +123,16 @@ export class StaffCatalogService { params.ridx = '' + this.routeIndex++; // see comments above this.router.navigate(['/staff/catalog/cnbrowse'], {queryParams: params}); } + + // Params to genreate a new author search based on a reset + // clone of the current page params. + getAuthorSearchParams(summary: BibRecordSummary): any { + const tmpContext = this.cloneContext(this.searchContext); + tmpContext.reset(); + tmpContext.termSearch.fieldClass = ['author']; + tmpContext.termSearch.query = [summary.display.author]; + return this.catUrl.toUrlParams(tmpContext); + } } diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/cnbrowse/results.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/cnbrowse/results.component.html index 4aff584464..4a3da083f9 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/cnbrowse/results.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/cnbrowse/results.component.html @@ -25,8 +25,9 @@
-
-
+
+
+
@@ -44,8 +45,18 @@ {{callNumber.suffix().label()}} @ {{orgName(callNumber.owning_lib())}}
-
{{callNumber._bibSummary.display.title}}
-
{{callNumber._bibSummary.display.author}}
+ +
@@ -56,14 +67,13 @@
- -
-
+
+
+
-
diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/cnbrowse/results.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/cnbrowse/results.component.ts index bddf40efd1..464f443a1f 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/cnbrowse/results.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/cnbrowse/results.component.ts @@ -2,6 +2,7 @@ import {Component, Input, OnInit, OnDestroy} from '@angular/core'; import {ActivatedRoute, Router, ParamMap} from '@angular/router'; import {Subscription} from 'rxjs'; import {IdlObject} from '@eg/core/idl.service'; +import {PcrudService} from '@eg/core/pcrud.service'; import {CatalogService} from '@eg/share/catalog/catalog.service'; import {BibRecordService} from '@eg/share/catalog/bib-record.service'; import {CatalogUrlService} from '@eg/share/catalog/catalog-url.service'; @@ -16,6 +17,9 @@ import {OrgService} from '@eg/core/org.service'; }) export class CnBrowseResultsComponent implements OnInit, OnDestroy { + // If set, this is a bib-focused browse + @Input() bibSummary: BibRecordSummary; + @Input() rowCount = 5; rowIndexList: number[] = []; @@ -23,13 +27,18 @@ export class CnBrowseResultsComponent implements OnInit, OnDestroy { colCount = 3; searchContext: CatalogSearchContext; - results: any[]; + results: any[] = []; routeSub: Subscription; + // When browsing by a specific record, keep tabs on the initial + // browse call number. + browseCn: string; + constructor( private router: Router, private route: ActivatedRoute, private org: OrgService, + private pcrud: PcrudService, private cat: CatalogService, private bib: BibRecordService, private catUrl: CatalogUrlService, @@ -43,20 +52,53 @@ export class CnBrowseResultsComponent implements OnInit, OnDestroy { this.rowIndexList.push(idx); } - this.routeSub = this.route.queryParamMap.subscribe( - (params: ParamMap) => this.browseByUrl(params) - ); + let promise = Promise.resolve(); + if (this.bibSummary) { + promise = this.getBrowseCallnumber(); + } + + promise.then(_ => { + this.routeSub = this.route.queryParamMap.subscribe( + (params: ParamMap) => this.browseByUrl(params) + ); + }); } ngOnDestroy() { this.routeSub.unsubscribe(); } + getBrowseCallnumber(): Promise { + let org = this.searchContext.searchOrg.id(); + + if (this.searchContext.searchOrg.ou_type().can_have_vols() === 'f') { + // If the current search org unit cannot hold volumes, search + // across child org units. + org = this.org.descendants(this.searchContext.searchOrg, true); + } + + return this.pcrud.search('acn', + {record: this.bibSummary.id, owning_lib: org}, + {limit: 1} + ).toPromise().then(cn => + this.browseCn = cn ? cn.label() : this.bibSummary.bibCallNumber + ); + } + browseByUrl(params: ParamMap): void { this.catUrl.applyUrlParams(this.searchContext, params); + this.getBrowseResults(); + } + + getBrowseResults() { const cbs = this.searchContext.cnBrowseSearch; cbs.limit = this.rowCount * this.colCount; + if (this.browseCn) { + // Override any call number browse URL parameters + cbs.value = this.browseCn; + } + if (cbs.isSearchable()) { this.results = []; this.cat.cnBrowse(this.searchContext) @@ -114,12 +156,23 @@ export class CnBrowseResultsComponent implements OnInit, OnDestroy { prevPage() { this.searchContext.cnBrowseSearch.offset--; - this.staffCat.cnBrowse(); + if (this.bibSummary) { + // Browse without navigation + this.getBrowseResults(); + } else { + this.staffCat.cnBrowse(); + } + } nextPage() { this.searchContext.cnBrowseSearch.offset++; - this.staffCat.cnBrowse(); + if (this.bibSummary) { + // Browse without navigation + this.getBrowseResults(); + } else { + this.staffCat.cnBrowse(); + } } /** @@ -145,6 +198,10 @@ export class CnBrowseResultsComponent implements OnInit, OnDestroy { orgName(orgId: number): string { return this.org.get(orgId).shortname(); } + + getAuthorSearchParams(summary: BibRecordSummary): any { + return this.staffCat.getAuthorSearchParams(summary); + } } 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 b82dd74003..a9330c3c2b 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 @@ -83,6 +83,16 @@ + + + +
+ + +
+
+
+
diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.ts index b46e4ca0ba..8cb7f03c6c 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.ts @@ -85,11 +85,7 @@ export class ResultRecordComponent implements OnInit, OnDestroy { // Params to genreate a new author search based on a reset // clone of the current page params. getAuthorSearchParams(summary: BibRecordSummary): any { - const tmpContext = this.staffCat.cloneContext(this.searchContext); - tmpContext.reset(); - tmpContext.termSearch.fieldClass = ['author']; - tmpContext.termSearch.query = [summary.display.author]; - return this.catUrl.toUrlParams(tmpContext); + return this.staffCat.getAuthorSearchParams(summary); } // Returns the URL parameters for the current page plus the