if (context.cnBrowseSearch.isSearchable()) {
params.cnBrowseTerm = context.cnBrowseSearch.value;
params.cnBrowsePage = context.cnBrowseSearch.offset;
+ params.cnBrowsePageSize = context.cnBrowseSearch.limit;
}
return params;
if (params.has('cnBrowseTerm')) {
context.cnBrowseSearch.value = params.get('cnBrowseTerm');
context.cnBrowseSearch.offset = Number(params.get('cnBrowsePage'));
+ context.cnBrowseSearch.limit = Number(params.get('cnBrowsePageSize'));
}
const ts = context.termSearch;
</div>
</div>
- <div class="row" *ngFor="let result of results; let idx = index">
- <div class="col-lg-12" *ngIf="result._bibSummary">
- <eg-catalog-result-record [summary]="result._bibSummary"
- [index]="idx" [callNumber]="result">
- </eg-catalog-result-record>
+ <ng-container *ngIf="results && results.length">
+ <div class="row mb-3" *ngFor="let rowIdx of rowIndexList">
+ <ng-container *ngFor="let callNumber of resultSlice(rowIdx); let colIdx = index">
+ <ng-container *ngIf="callNumber._bibSummary">
+ <div class="col-lg-4 pt-2 d-flex border"
+ [ngClass]="{'border-primary': isCenter(rowIdx, colIdx)}">
+ <div class="flex-1">
+ <div class="font-weight-bold">
+ {{callNumber.prefix().label()}} {{callNumber.label()}}
+ {{callNumber.suffix().label()}}
+ @ {{orgName(callNumber.owning_lib())}}
+ </div>
+ <div>{{callNumber._bibSummary.display.title}}</div>
+ <div>{{callNumber._bibSummary.display.author}}</div>
+ </div>
+ <div class="ml-2">
+ <img src="/opac/extras/ac/jacket/small/r/{{callNumber._bibSummary.id}}"/>
+ </div>
+ </div>
+ </ng-container>
+ </ng-container>
</div>
- </div>
+ </ng-container>
+
<div class="row mb-2">
<div class="col-lg-3">
-import {Component, OnInit, OnDestroy} from '@angular/core';
+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 {CatalogSearchContext, CatalogSearchState} from '@eg/share/catalog/search-context';
import {StaffCatalogService} from '../catalog.service';
import {BibRecordSummary} from '@eg/share/catalog/bib-record.service';
+import {OrgService} from '@eg/core/org.service';
@Component({
selector: 'eg-catalog-cn-browse-results',
})
export class CnBrowseResultsComponent implements OnInit, OnDestroy {
+ @Input() rowCount = 5;
+ rowIndexList: number[] = [];
+
+ // hard-coded because it requires template changes.
+ colCount = 3;
+
searchContext: CatalogSearchContext;
results: any[];
routeSub: Subscription;
constructor(
private router: Router,
private route: ActivatedRoute,
+ private org: OrgService,
private cat: CatalogService,
private bib: BibRecordService,
private catUrl: CatalogUrlService,
ngOnInit() {
this.searchContext = this.staffCat.searchContext;
+
+ for (let idx = 0; idx < this.rowCount; idx++) {
+ this.rowIndexList.push(idx);
+ }
+
this.routeSub = this.route.queryParamMap.subscribe(
(params: ParamMap) => this.browseByUrl(params)
);
browseByUrl(params: ParamMap): void {
this.catUrl.applyUrlParams(this.searchContext, params);
const cbs = this.searchContext.cnBrowseSearch;
+ cbs.limit = this.rowCount * this.colCount;
if (cbs.isSearchable()) {
this.results = [];
this.router.navigate(
['/staff/catalog/record/' + summary.id], {queryParams: params});
}
+
+ resultSlice(rowIdx: number): number[] {
+ const offset = rowIdx * this.colCount;
+ return this.results.slice(offset, offset + this.colCount);
+ }
+
+ isCenter(rowIdx: number, colIdx: number): boolean {
+ const total = this.rowCount * this.colCount;
+ return Math.floor(total / 2) === ((rowIdx * this.colCount) + colIdx);
+ }
+
+ orgName(orgId: number): string {
+ return this.org.get(orgId).shortname();
+ }
}