1 import {Injectable} from '@angular/core';
2 import {Router, Resolve, RouterStateSnapshot,
3 ActivatedRouteSnapshot} from '@angular/router';
4 import {ServerStoreService} from '@eg/core/server-store.service';
5 import {NetService} from '@eg/core/net.service';
6 import {OrgService} from '@eg/core/org.service';
7 import {AuthService} from '@eg/core/auth.service';
8 import {CatalogService} from '@eg/share/catalog/catalog.service';
9 import {StaffCatalogService} from './catalog.service';
10 import {BasketService} from '@eg/share/catalog/basket.service';
11 import {CATALOG_CCVM_FILTERS} from '@eg/share/catalog/search-context';
15 export class CatalogResolver implements Resolve<Promise<any[]>> {
18 private router: Router,
19 private store: ServerStoreService,
20 private org: OrgService,
21 private net: NetService,
22 private auth: AuthService,
23 private cat: CatalogService,
24 private staffCat: StaffCatalogService,
25 private basket: BasketService
29 route: ActivatedRouteSnapshot,
30 state: RouterStateSnapshot): Promise<any[]> {
32 console.debug('CatalogResolver:resolve()');
35 this.cat.fetchCcvms(),
38 this.basket.getRecordIds()
42 fetchSettings(): Promise<any> {
44 return this.store.getItemBatch([
45 'eg.search.search_lib',
48 'eg.catalog.results.count',
49 'cat.holdings_show_empty_org',
50 'cat.holdings_show_empty',
51 'cat.marcedit.stack_subfields',
52 'cat.marcedit.flateditor',
53 'cat.holdings_show_copies',
54 'cat.holdings_show_vols',
55 'cat.patron_view_discovery_layer_url',
56 'opac.staff_saved_search.size',
57 'eg.catalog.search_templates',
58 'opac.staff_saved_search.size',
59 'opac.search.enable_bookplate_search',
60 'eg.staffcat.exclude_electronic',
61 'eg.catalog.search.form.open',
62 'eg.staff.catalog.results.show_more',
63 'circ.staff_placed_holds_fallback_to_ws_ou',
64 'circ.staff_placed_holds_default_to_ws_ou',
65 'opac.staff.jump_to_details_on_single_hit',
66 'eg.staffcat.search_filters'
68 this.staffCat.defaultSearchOrg =
69 this.org.get(settings['eg.search.search_lib']);
70 this.staffCat.prefOrg =
71 this.org.get(settings['eg.search.pref_lib']);
72 this.staffCat.defaultTab = settings['eg.search.adv_pane'];
73 if (settings['eg.catalog.results.count']) {
74 this.staffCat.defaultSearchLimit =
75 Number(settings['eg.catalog.results.count']);
77 this.staffCat.enableBookplates =
78 settings['opac.search.enable_bookplate_search'];
79 this.staffCat.showExcludeElectronic =
80 settings['eg.staffcat.exclude_electronic'] === true;
81 this.staffCat.jumpOnSingleHit =
82 settings['opac.staff.jump_to_details_on_single_hit'] === true;
83 this.staffCat.searchFilters =
84 settings['eg.staffcat.search_filters'] || CATALOG_CCVM_FILTERS;
85 if (settings['cat.patron_view_discovery_layer_url']) {
86 this.staffCat.patronViewUrl =
87 settings['cat.patron_view_discovery_layer_url'];