]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/eg2/src/app/staff/catalog/resolver.service.ts
LP2061136 - Stamping 1405 DB upgrade script
[Evergreen.git] / Open-ILS / src / eg2 / src / app / staff / catalog / resolver.service.ts
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';
12
13
14 @Injectable()
15 export class CatalogResolver implements Resolve<Promise<any[]>> {
16
17     constructor(
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
26     ) {}
27
28     resolve(
29         route: ActivatedRouteSnapshot,
30         state: RouterStateSnapshot): Promise<any[]> {
31
32         console.debug('CatalogResolver:resolve()');
33
34         return Promise.all([
35             this.cat.fetchCcvms(),
36             this.cat.fetchCmfs(),
37             this.fetchSettings(),
38             this.basket.getRecordIds()
39         ]);
40     }
41
42     fetchSettings(): Promise<any> {
43
44         return this.store.getItemBatch([
45             'eg.search.search_lib',
46             'eg.search.pref_lib',
47             'eg.search.adv_pane',
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             'opac.staff_saved_search.size',
56             'eg.catalog.search_templates',
57             'opac.staff_saved_search.size',
58             'opac.search.enable_bookplate_search',
59             'eg.staffcat.exclude_electronic',
60             'eg.catalog.search.form.open',
61             'eg.staff.catalog.results.show_more',
62             'circ.staff_placed_holds_fallback_to_ws_ou',
63             'circ.staff_placed_holds_default_to_ws_ou',
64             'opac.staff.jump_to_details_on_single_hit',
65             'eg.staffcat.search_filters'
66         ]).then(settings => {
67             this.staffCat.defaultSearchOrg =
68                 this.org.get(settings['eg.search.search_lib']);
69             this.staffCat.prefOrg =
70                 this.org.get(settings['eg.search.pref_lib']);
71             this.staffCat.defaultTab = settings['eg.search.adv_pane'];
72             if (settings['eg.catalog.results.count']) {
73                this.staffCat.defaultSearchLimit =
74                   Number(settings['eg.catalog.results.count']);
75             }
76             this.staffCat.enableBookplates =
77                 settings['opac.search.enable_bookplate_search'];
78             this.staffCat.showExcludeElectronic =
79                 settings['eg.staffcat.exclude_electronic'] === true;
80             this.staffCat.jumpOnSingleHit =
81                 settings['opac.staff.jump_to_details_on_single_hit'] === true;
82             this.staffCat.searchFilters =
83                 settings['eg.staffcat.search_filters'] || CATALOG_CCVM_FILTERS;
84         });
85     }
86 }
87