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.
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);
+ }
}
<!-- header, pager, and list of records -->
<div id="staff-catalog-browse-results-container" *ngIf="browseHasResults()">
- <div class="row mb-2">
- <div class="col-lg-3">
+ <div class="row mb-2 d-flex">
+ <div class="flex-1"></div>
+ <div>
<button class="btn btn-primary" (click)="prevPage()">Back</button>
<button class="btn btn-primary ml-3" (click)="nextPage()">Next</button>
</div>
{{callNumber.suffix().label()}}
@ {{orgName(callNumber.owning_lib())}}
</div>
- <div>{{callNumber._bibSummary.display.title}}</div>
- <div>{{callNumber._bibSummary.display.author}}</div>
+ <div>
+ <a queryParamsHandling="merge"
+ routerLink="/staff/catalog/record/{{callNumber._bibSummary.id}}">
+ {{callNumber._bibSummary.display.title}}
+ </a>
+ </div>
+ <div>
+ <a routerLink="/staff/catalog/search"
+ [queryParams]="getAuthorSearchParams(callNumber._bibSummary)">
+ {{callNumber._bibSummary.display.author}}
+ </a>
+ </div>
</div>
<div class="ml-2">
<img src="/opac/extras/ac/jacket/small/r/{{callNumber._bibSummary.id}}"/>
</div>
</ng-container>
-
- <div class="row mb-2">
- <div class="col-lg-3">
+ <div class="row mb-2 d-flex">
+ <div class="flex-1"></div>
+ <div>
<button class="btn btn-primary" (click)="prevPage()">Back</button>
<button class="btn btn-primary ml-3" (click)="nextPage()">Next</button>
</div>
</div>
-
</div>
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';
})
export class CnBrowseResultsComponent implements OnInit, OnDestroy {
+ // If set, this is a bib-focused browse
+ @Input() bibSummary: BibRecordSummary;
+
@Input() rowCount = 5;
rowIndexList: number[] = [];
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,
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<any> {
+ 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)
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();
+ }
}
/**
orgName(orgId: number): string {
return this.org.get(orgId).shortname();
}
+
+ getAuthorSearchParams(summary: BibRecordSummary): any {
+ return this.staffCat.getAuthorSearchParams(summary);
+ }
}