'eg.staffcat.exclude_electronic',
'eg.catalog.search.form.open',
'eg.staff.catalog.results.show_more',
- 'circ.staff_placed_holds_fallback_to_ws_ou'
+ 'circ.staff_placed_holds_fallback_to_ws_ou',
+ 'opac.staff.jump_to_details_on_single_hit',
]).then(settings => {
this.staffCat.defaultSearchOrg =
this.org.get(settings['eg.search.search_lib']);
settings['opac.search.enable_bookplate_search'];
this.staffCat.showExcludeElectronic =
settings['eg.staffcat.exclude_electronic'] === true;
+ this.staffCat.jumpOnSingleHit =
+ settings['opac.staff.jump_to_details_on_single_hit'] === true;
});
}
}
import {Component, OnInit, OnDestroy, Input} from '@angular/core';
import {Observable, Subscription} from 'rxjs';
import {tap, map, switchMap, distinctUntilChanged} from 'rxjs/operators';
-import {ActivatedRoute, ParamMap} from '@angular/router';
+import {Router, ActivatedRoute, ParamMap} from '@angular/router';
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';
private catUrl: CatalogUrlService,
private staffCat: StaffCatalogService,
private serverStore: ServerStoreService,
- private basket: BasketService
+ private basket: BasketService,
+ private router: Router
) {}
ngOnInit() {
});
// 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.jumpIfNecessary();
+ this.applyRecordSelection();
+ }
+ );
// Watch for basket changes applied by other components.
this.basketSub = this.basket.onChange.subscribe(
}
}
+ // Jump to record page if only a single hit is returned
+ // and the jump is enabled by library setting
+ jumpIfNecessary() {
+ const ids = this.searchContext.currentResultIds();
+ if (this.staffCat.jumpOnSingleHit && ids.length === 1) {
+ // this.router.navigate(['/staff/catalog/record/' + ids[0], { queryParams: this.catUrl.toUrlParams(this.searchContext) }]);
+ this.router.navigate(['/staff/catalog/record/' + ids[0]], {queryParamsHandling: 'merge'});
+ }
+ }
+
// Apply the select-all checkbox when all visible records
// are selected.
applyRecordSelection() {