Update rxjs imports to work with Angular7. Add ng-lint repairs.
Signed-off-by: Bill Erickson <berickxx@gmail.com>
}
} else if (!anonymous) {
- console.warn('Attempt to fetch org setting(s)',
+ console.warn('Attempt to fetch org setting(s)',
name, 'in non-anonymous mode without an authtoken');
return Promise.resolve({});
}
import {Injectable, EventEmitter} from '@angular/core';
-import {Observable} from 'rxjs/Observable';
+import {Observable} from 'rxjs';
import {StoreService} from '@eg/core/store.service';
import {NetService} from '@eg/core/net.service';
import {PcrudService} from '@eg/core/pcrud.service';
private pcrud: PcrudService,
private store: StoreService,
private anonCache: AnonCacheService
- ) {
- this.idList = [];
+ ) {
+ this.idList = [];
this.onChange = new EventEmitter<number[]>();
}
return this.anonCache.getItem(cacheKey, BASKET_CACHE_ATTR).then(
list => {
- if (!list) {return this.idList};
+ if (!list) { return this.idList; }
this.idList = list.map(id => Number(id));
return this.idList;
}
const cacheKey = this.store.getLoginSessionItem(BASKET_CACHE_KEY_COOKIE);
return this.anonCache.setItem(cacheKey, BASKET_CACHE_ATTR, this.idList)
- .then(cacheKey => {
- this.store.setLoginSessionItem(BASKET_CACHE_KEY_COOKIE, cacheKey);
+ .then(key => {
+ this.store.setLoginSessionItem(BASKET_CACHE_KEY_COOKIE, key);
this.onChange.emit(this.idList);
return this.idList;
});
addRecordIds(ids: number[]): Promise<number[]> {
ids = ids.filter(id => !this.hasRecordId(id)); // avoid dupes
- if (ids.length === 0) {
- return Promise.resolve(this.idList);
+ if (ids.length === 0) {
+ return Promise.resolve(this.idList);
}
return this.setRecordIds(
this.idList.concat(ids.map(id => Number(id))));
}));
}
- // A Metabib Summary is a BibRecordSummary with the lead record as
- // its core bib record plus attributes (e.g. formats) from related
+ // A Metabib Summary is a BibRecordSummary with the lead record as
+ // its core bib record plus attributes (e.g. formats) from related
// records.
- getMetabibSummary(metabibIds: number | number[],
+ getMetabibSummary(metabibIds: number | number[],
orgId?: number, orgDepth?: number): Observable<BibRecordSummary> {
const ids = [].concat(metabibIds);
return from([]);
}
- return this.pcrud.search('mmr', {id: ids},
- {flesh: 1, flesh_fields: {mmr: ['source_maps']}},
+ return this.pcrud.search('mmr', {id: ids},
+ {flesh: 1, flesh_fields: {mmr: ['source_maps']}},
{anonymous: true}
).pipe(mergeMap(mmr => this.compileMetabib(mmr, orgId, orgDepth)));
}
// 'metabib' must have its "source_maps" field fleshed.
- // Get bib summaries for all related bib records so we can
+ // Get bib summaries for all related bib records so we can
// extract data that must be appended to the master record summary.
- compileMetabib(metabib: IdlObject,
+ compileMetabib(metabib: IdlObject,
orgId?: number, orgDepth?: number): Observable<BibRecordSummary> {
// TODO: Create an API similar to the one that builds a combined
// Non-master records
const relatedBibIds = metabib.source_maps()
- .map(map => map.source())
+ .map(m => m.source())
.filter(id => id !== metabib.master_record());
let observer;
this.getBibSummary(metabib.master_record(), orgId, orgDepth)
.subscribe(summary => {
summary.metabibId = metabib.id();
- summary.metabibRecords =
- metabib.source_maps().map(map => Number(map.source()))
+ summary.metabibRecords =
+ metabib.source_maps().map(m => Number(m.source()));
let promise;
import {NgModule} from '@angular/core';
import {EgCommonModule} from '@eg/common.module';
import {CatalogService} from './catalog.service';
-import {AnonCacheService} from '@eg/share/util/anon-cache.service'
+import {AnonCacheService} from '@eg/share/util/anon-cache.service';
import {BasketService} from './basket.service';
import {CatalogUrlService} from './catalog-url.service';
import {BibRecordService} from './bib-record.service';
import {Injectable} from '@angular/core';
import {ParamMap} from '@angular/router';
import {OrgService} from '@eg/core/org.service';
-import {CatalogSearchContext, CatalogBrowseContext, CatalogMarcContext,
+import {CatalogSearchContext, CatalogBrowseContext, CatalogMarcContext,
CatalogTermContext, FacetFilter} from './search-context';
import {CATALOG_CCVM_FILTERS} from './search-context';
params.joinOp = [];
params.matchOp = [];
- ['format', 'available', 'hasBrowseEntry', 'date1',
+ ['format', 'available', 'hasBrowseEntry', 'date1',
'date2', 'dateOp', 'groupByMetarecord', 'fromMetarecord']
.forEach(field => {
if (ts[field]) {
}));
});
}
-
+
if (ts.copyLocations.length && ts.copyLocations[0] !== '') {
params.copyLocations = ts.copyLocations.join(',');
}
} else if (params.has('query')) {
// Scalars
- ['format', 'available', 'date1', 'date2',
+ ['format', 'available', 'date1', 'date2',
'dateOp', 'groupByMetarecord', 'fromMetarecord']
.forEach(field => {
if (params.has(field)) {
['query', 'fieldClass', 'joinOp', 'matchOp'].forEach(field => {
const arr = params.getAll(field);
if (params.has(field)) {
- ts[field] = params.getAll(field);
+ ts[field] = params.getAll(field);
}
});
CATALOG_CCVM_FILTERS.forEach(code => {
- const val = params.get(code);
- if (val) {
- ts.ccvmFilters[code] = val.split(/,/);
+ const ccvmVal = params.get(code);
+ if (ccvmVal) {
+ ts.ccvmFilters[code] = ccvmVal.split(/,/);
} else {
ts.ccvmFilters[code] = [''];
}
private basket: BasketService
) {
this.onSearchComplete = new EventEmitter<CatalogSearchContext>();
-
+
}
search(ctx: CatalogSearchContext): Promise<void> {
return this.basketSearch(ctx);
} else if (ctx.marcSearch.isSearchable()) {
return this.marcSearch(ctx);
- } else if (ctx.identSearch.isSearchable() &&
+ } else if (ctx.identSearch.isSearchable() &&
ctx.identSearch.queryType === 'item_barcode') {
return this.barcodeSearch(ctx);
} else {
} else {
fullQuery = ctx.compileTermSearchQuery();
- if (ctx.termSearch.groupByMetarecord
+ if (ctx.termSearch.groupByMetarecord
&& !ctx.termSearch.fromMetarecord) {
method = 'open-ils.search.metabib.multiclass.query';
}
if (ctx.isStaff) {
method += '.staff';
}
-
+
return new Promise((resolve, reject) => {
this.net.request(
'open-ils.search', method, {
}
- // When showing titles linked to a browse entry, fetch
+ // When showing titles linked to a browse entry, fetch
// the entry data as well so the UI can display it.
fetchBrowseEntry(ctx: CatalogSearchContext) {
const ts = ctx.termSearch;
const isMeta = ctx.termSearch.isMetarecordSearch();
let observable: Observable<BibRecordSummary>;
-
+
if (isMeta) {
observable = this.bibService.getMetabibSummary(
ctx.currentResultIds(), ctx.searchOrg.id(), depth);
format => format.code() === code)[0];
if (ccvm) {
return ccvm.search_label();
- }
- }
- }
+ }
+ }
+ }
fetchCmfs(): Promise<void> {
// At the moment, we only need facet CMFs.
const orgIds = this.org.fullPath(contextOrg, true);
this.copyLocations = [];
- return this.pcrud.search('acpl',
+ return this.pcrud.search('acpl',
{deleted: 'f', opac_visible: 't', owning_lib: orgIds},
{order_by: {acpl: 'name'}},
{anonymous: true}
- ).pipe(tap(loc => this.copyLocations.push(loc))).toPromise()
+ ).pipe(tap(loc => this.copyLocations.push(loc))).toPromise();
}
browse(ctx: CatalogSearchContext): Observable<any> {
export class CatalogIdentContext {
value: string;
- queryType: string;
+ queryType: string;
reset() {
this.value = '';
isSearchable() {
return (
- this.value !== ''
+ this.value !== ''
&& this.queryType !== ''
);
}
// contents of a metarecord.
isMetarecordSearch(): boolean {
return (
- this.isSearchable() &&
- this.groupByMetarecord &&
+ this.isSearchable() &&
+ this.groupByMetarecord &&
this.fromMetarecord === null
);
}
if (this.sort) {
const parts = this.sort.split(/\./);
args.sort = parts[0]; // title, author, etc.
- if (parts[1]) { args.sort_dir = 'descending' };
+ if (parts[1]) { args.sort_dir = 'descending'; }
}
return args;
}
compileIdentSearchQuery(): string {
-
- let str = ' site(' + this.searchOrg.shortname() + ')';
- return str + ' ' +
+ const str = ' site(' + this.searchOrg.shortname() + ')';
+ return str + ' ' +
this.identSearch.queryType + ':' + this.identSearch.value;
}
if (qcount > 1) { str += ')'; }
// -------
- if (ts.hasBrowseEntry) {
+ if (ts.hasBrowseEntry) {
// stored as a comma-separated string of "entryId,fieldId"
str += ` has_browse_entry(${ts.hasBrowseEntry})`;
}
* Service for communicating with the server-side "anonymous" cache.
*/
import {Injectable} from '@angular/core';
-import {Observable} from 'rxjs/Observable';
+import {Observable} from 'rxjs';
import {StoreService} from '@eg/core/store.service';
import {NetService} from '@eg/core/net.service';
'open-ils.actor',
'open-ils.actor.anon_cache.set_value',
cacheKey, attr, value
- ).toPromise().then(cacheKey => {
- if (cacheKey) {
- return cacheKey;
+ ).toPromise().then(key => {
+ if (key) {
+ return key;
} else {
return Promise.reject(
- `Could not apply a value for attr=${attr} cacheKey=${cacheKey}`);
+ `Could not apply a value for attr=${attr} cacheKey=${key}`);
}
- })
+ });
}
removeItem(cacheKey: string, attr: string): Promise<string> {
import {Component, OnInit, ViewChild} from '@angular/core';
import {BasketService} from '@eg/share/catalog/basket.service';
-import {Subscription} from 'rxjs/Subscription';
+import {Subscription} from 'rxjs';
import {Router} from '@angular/router';
import {NetService} from '@eg/core/net.service';
import {AuthService} from '@eg/core/auth.service';
import {PrintService} from '@eg/share/print/print.service';
-import {RecordBucketDialogComponent}
- from '@eg/staff/share/buckets/record-bucket-dialog.component';
+import {RecordBucketDialogComponent
+ } from '@eg/staff/share/buckets/record-bucket-dialog.component';
@Component({
selector: 'eg-catalog-basket-actions',
applyAction() {
console.debug('Performing basket action', this.basketAction);
- switch(this.basketAction) {
+ switch (this.basketAction) {
case 'view':
// This does not propagate search params -- unclear if needed.
- this.router.navigate(['/staff/catalog/search'],
+ this.router.navigate(['/staff/catalog/search'],
{queryParams: {showBasket: true}});
break;
this.router.navigate(['/staff/catalog/hold/T'],
{queryParams: {target: ids}});
});
- break;
+ break;
case 'print':
this.basket.getRecordIds().then(ids => {
import {Component, OnInit, Input} from '@angular/core';
-import {Observable} from 'rxjs/Observable';
-import {Subscription} from 'rxjs/Subscription';
+import {Observable, Subscription} from 'rxjs';
import {map, switchMap, distinctUntilChanged} from 'rxjs/operators';
import {ActivatedRoute, ParamMap} from '@angular/router';
import {CatalogService} from '@eg/share/catalog/catalog.service';
if (bs.isSearchable()) {
this.results = [];
this.cat.browse(this.searchContext)
- .subscribe(result => this.addResult(result))
+ .subscribe(result => this.addResult(result));
}
}
const heading = headingStruct[fieldId][0];
const inList = result.list_authorities.filter(
- id => Number(id) === Number(heading.target))[0]
+ id => Number(id) === Number(heading.target))[0];
- if ( heading.target
+ if ( heading.target
&& heading.main_entry
- && heading.target_count
+ && heading.target_count
&& !inList
&& !seen[heading.target]) {
}
}
- searchByBrowseEntry(result) {
+ searchByBrowseEntry(result) {
// Avoid propagating browse values to term search.
this.searchContext.browseSearch.reset();
- this.searchContext.termSearch.hasBrowseEntry =
+ this.searchContext.termSearch.hasBrowseEntry =
result.browse_entry + ',' + result.fields;
this.staffCat.search();
}
import {Component, OnInit, Input, ViewChild, Renderer2} from '@angular/core';
-import {Observable} from 'rxjs/Observable';
import {Router, ActivatedRoute, ParamMap} from '@angular/router';
-import {tap} from 'rxjs/operators/tap';
+import {Observable} from 'rxjs';
+import {tap} from 'rxjs/operators';
import {EventService} from '@eg/core/event.service';
import {NetService} from '@eg/core/net.service';
import {AuthService} from '@eg/core/auth.service';
import {CatalogSearchContext, CatalogSearchState} from '@eg/share/catalog/search-context';
import {CatalogService} from '@eg/share/catalog/catalog.service';
import {StaffCatalogService} from '../catalog.service';
-import {HoldService, HoldRequest, HoldRequestTarget}
- from '@eg/staff/share/hold.service';
+import {HoldService, HoldRequest,
+ HoldRequestTarget} from '@eg/staff/share/hold.service';
import {ComboboxEntry} from '@eg/share/combobox/combobox.component';
class HoldContext {
// code => selected-boolean
formats: {},
langs: {}
- }
+ };
}
}
templateUrl: 'hold.component.html'
})
export class HoldComponent implements OnInit {
-
+
holdType: string;
holdTargets: number[];
user: IdlObject; //
this.getTargetMeta();
this.org.settings('sms.enable').then(sets => {
- this.smsEnabled = sets['sms.enable']
+ this.smsEnabled = sets['sms.enable'];
if (!this.smsEnabled) { return; }
this.pcrud.search('csc', {active: 't'}, {order_by: {csc: 'name'}})
.subscribe(carrier => {
this.smsCarriers.push({
- id: carrier.id(),
+ id: carrier.id(),
label: carrier.name()
- })
+ });
});
});
// Map the selected metarecord filters optoins to a JSON-encoded
// list of attr filters as required by the API.
- // Compiles a blob of
+ // Compiles a blob of
// {target: JSON({"0": [{_attr: ctype, _val: code}, ...], "1": [...]})}
// TODO: this should live in the hold service, not in the UI code.
mrSelectorsToFilters(ctx: HoldContext): {[target: number]: string} {
}
if (Object.keys(compiled).length > 0) {
- const result = {};
- result[ctx.holdTarget] = JSON.stringify(compiled);
- return result;
+ const res = {};
+ res[ctx.holdTarget] = JSON.stringify(compiled);
+ return res;
}
return null;
userBarcodeChanged() {
// Avoid simultaneous or duplicate lookups
- if (this.userBarcode === this.currentUserBarcode) {
- return;
+ if (this.userBarcode === this.currentUserBarcode) {
+ return;
}
this.resetForm();
- if (!this.userBarcode) {
+ if (!this.userBarcode) {
this.user = null;
- return;
+ return;
}
this.user = null;
this.net.request(
'open-ils.actor',
'open-ils.actor.get_barcodes',
- this.auth.token(), this.auth.user().ws_ou(),
+ this.auth.token(), this.auth.user().ws_ou(),
'actor', this.userBarcode
).subscribe(barcodes => {
if (value === '' || value === null) { return; }
- switch(name) {
+ switch (name) {
case 'opac.hold_notify':
this.notifyPhone = Boolean(value.match(/phone/));
this.notifyEmail = Boolean(value.match(/email/));
break;
case 'opac.default_pickup_location':
- this.pickupLib = value;
+ this.pickupLib = value;
break;
}
});
const target = this.holdTargets[idx];
const ctx = this.holdContexts.filter(
- ctx => ctx.holdTarget === target)[0];
+ c => c.holdTarget === target)[0];
this.placeOneHold(ctx).then(() => this.placeHolds(idx + 1));
}
console.log('hold returned: ', request);
ctx.lastRequest = request;
ctx.processing = false;
-
+
// If this request failed and was not already an override,
// see of this user has permission to override.
- if (!request.override &&
+ if (!request.override &&
!request.result.success && request.result.evt) {
-
+
const txtcode = request.result.evt.textcode;
const perm = txtcode + '.override';
-
+
return this.perm.hasWorkPermHere(perm).then(
permResult => ctx.canOverride = permResult[perm]);
}
}
canOverride(ctx: HoldContext): boolean {
- return ctx.lastRequest &&
+ return ctx.lastRequest &&
!ctx.lastRequest.result.success && ctx.canOverride;
}
order_by: orderBy
};
- return this.pcrud.search('bmp',
+ return this.pcrud.search('bmp',
{record: this.recId, deleted: 'f'}, searchOps);
};
ngOnInit() {
this.searchContext = this.staffCat.searchContext;
- this.defaultTab =
+ this.defaultTab =
this.store.getLocalItem('eg.cat.default_record_tab')
|| 'catalog';
if (this.recordTab in ANGJS_TABS) {
const angjsBase = '/eg/staff/cat/catalog/record';
- window.location.href =
+ window.location.href =
`${angjsBase}/${this.recordId}/${this.recordTab}`;
return;
}
- const url =
+ const url =
`/staff/catalog/record/${this.recordId}/${this.recordTab}`;
// Retain search parameters
fetchSettings(): Promise<any> {
return this.store.getItemBatch([
- 'eg.search.search_lib',
+ 'eg.search.search_lib',
'eg.search.pref_lib'
]).then(settings => {
- this.staffCat.defaultSearchOrg =
+ this.staffCat.defaultSearchOrg =
this.org.get(settings['eg.search.search_lib']);
- this.staffCat.prefOrg =
+ this.staffCat.prefOrg =
this.org.get(settings['eg.search.pref_lib']);
- })
+ });
}
}
import {Component, OnInit, OnDestroy, Input} from '@angular/core';
-import {Subscription} from 'rxjs/Subscription';
+import {Subscription} from 'rxjs';
import {Router} from '@angular/router';
import {OrgService} from '@eg/core/org.service';
import {NetService} from '@eg/core/net.service';
holdTarget = this.summary.metabibId;
}
- this.router.navigate([`/staff/catalog/hold/${holdType}`],
+ this.router.navigate([`/staff/catalog/hold/${holdType}`],
{queryParams: {target: holdTarget}});
}
navigateToRecord(summary: BibRecordSummary) {
const params = this.catUrl.toUrlParams(this.searchContext);
- // Jump to metarecord constituent records page when a
+ // Jump to metarecord constituent records page when a
// MR has more than 1 constituents.
if (summary.metabibId && summary.metabibRecords.length > 1) {
this.searchContext.termSearch.fromMetarecord = summary.metabibId;
// searches.
//
// This will also fire on page load.
- this.routeSub =
+ this.routeSub =
this.route.queryParamMap.subscribe((params: ParamMap) => {
// TODO: Angular docs suggest using switchMap(), but
const ids = this.searchContext.currentResultIds();
let allChecked = true;
ids.forEach(id => {
- if (!this.basket.hasRecordId(id)) {
- allChecked = false;
+ if (!this.basket.hasRecordId(id)) {
+ allChecked = false;
}
});
this.allRecsSelected = allChecked;
private staffCat: StaffCatalogService
) {
this.copyLocations = [];
- //this.searchTab = 'term';
}
ngOnInit() {
// TODO: is this how we avoid displaying too many locations?
const org = this.context.searchOrg;
- if (org.id() === this.org.root().id()) {
+ if (org.id() === this.org.root().id()) {
this.copyLocations = [];
- return;
+ return;
}
this.cat.fetchCopyLocations(org).then(() =>
this.context.pager.offset = 0; // New search
// Form search overrides basket display
- this.context.showBasket = false;
+ this.context.showBasket = false;
switch (this.searchTab) {
this.staffCat.search();
break;
- case 'ident':
+ case 'ident':
this.context.marcSearch.reset();
this.context.browseSearch.reset();
this.context.termSearch.reset();
);
// NOTE: this can eventually go away.
- // Avoid attempts to fetch org settings if the user has not yet
+ // Avoid attempts to fetch org settings if the user has not yet
// logged in (e.g. this is the login page).
if (this.user()) {
this.org.settings('ui.staff.angular_catalog.enabled')
- .then(settings => this.showAngularCatalog =
+ .then(settings => this.showAngularCatalog =
Boolean(settings['ui.staff.angular_catalog.enabled']));
}
}
* Common code for mananging holdings
*/
import {Injectable, EventEmitter} from '@angular/core';
-import {Observable} from 'rxjs/Observable';
-import {map} from 'rxjs/operators/map';
-import {mergeMap} from 'rxjs/operators/mergeMap';
+import {Observable} from 'rxjs';
+import {map, mergeMap} from 'rxjs/operators';
import {IdlObject} from '@eg/core/idl.service';
import {NetService} from '@eg/core/net.service';
import {PcrudService} from '@eg/core/pcrud.service';
import {EventService, EgEvent} from '@eg/core/event.service';
import {AuthService} from '@eg/core/auth.service';
-import {BibRecordService, BibRecordSummary}
- from '@eg/share/catalog/bib-record.service';
+import {BibRecordService,
+ BibRecordSummary} from '@eg/share/catalog/bib-record.service';
// Response from a place-holds API call.
export interface HoldRequestResult {
success: boolean;
holdId?: number;
evt?: EgEvent;
-};
+}
// Values passed to the place-holds API call.
export interface HoldRequest {
thawDate?: string; // ISO date
frozen?: boolean;
holdableFormats?: {[target: number]: string};
- result?: HoldRequestResult
-};
+ result?: HoldRequestResult;
+}
// A fleshed hold request target object containing whatever data is
// available for each hold type / target. E.g. a TITLE hold will
) {}
placeHold(request: HoldRequest): Observable<HoldRequest> {
-
+
let method = 'open-ils.circ.holds.test_and_create.batch';
if (request.override) { method = method + '.override'; }
));
}
- getHoldTargetMeta(holdType: string, holdTarget: number | number[],
+ getHoldTargetMeta(holdType: string, holdTarget: number | number[],
orgId?: number): Observable<HoldRequestTarget> {
const targetIds = [].concat(holdTarget);