describe('EgEventService', () => {
let service: EgEventService;
- beforeEach(() => {service = new EgEventService();});
+ beforeEach(() => {
+ service = new EgEventService();
+ });
const evt = {
- ilsevent: "12345",
- pid: "12345",
- desc: "Test Event Description",
+ ilsevent: '12345',
+ pid: '12345',
+ desc: 'Test Event Description',
payload: {test : 'xyz'},
- textcode: "TEST_EVENT",
- servertime: "Wed Nov 6 16:05:50 2013"
+ textcode: 'TEST_EVENT',
+ servertime: 'Wed Nov 6 16:05:50 2013'
};
it('should parse an event object', () => {
it('should stringify an event', () => {
expect(service.parse(evt).toString()).toBe(
- 'Event: 12345:TEST_EVENT -> Test Event Description')
+ 'Event: 12345:TEST_EVENT -> Test Event Description');
});
});
describe('EgIdlService', () => {
let service: EgIdlService;
- beforeEach(() => {service = new EgIdlService();});
+ beforeEach(() => {
+ service = new EgIdlService();
+ });
it('should parse the IDL', () => {
service.parseIdl();
it('should create an aou object', () => {
service.parseIdl();
- let org = service.create('aou');
+ const org = service.create('aou');
expect(typeof org.id).toBe('function');
});
it('should create an aou object with accessor/mutators', () => {
service.parseIdl();
- let org = service.create('aou');
+ const org = service.create('aou');
org.name('AN ORG');
expect(org.name()).toBe('AN ORG');
});
*/
translateBibSummary(xmlDoc: XMLDocument): any { // TODO: bib summary interface
- const response = {
+ const response: any = {
copyCounts : [],
ccvms : {}
};
resolver, XPathResult.ANY_TYPE, null);
while (node = result.iterateNext()) {
- const counts = {};
- ['type', 'depth', 'org_unit', 'transcendant',
+ const counts = {type : node.getAttribute('type')};
+ ['depth', 'org_unit', 'transcendant',
'available', 'count', 'unshadow'].forEach(field => {
- counts[field] = node.getAttribute(field);
+ counts[field] = Number(node.getAttribute(field));
});
response.copyCounts.push(counts);
}
+ response.creator = Number(response.creator);
+ response.editor = Number(response.editor);
+
// console.log(response);
return response;
}
limit: pager.limit,
order_by: orderBy
});
- }
+ };
}
}
limit: pager.limit,
order_by: orderBy
});
- }
+ };
}
}
-import {NgModule} from '@angular/core';
+import {NgModule} from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
import {AdminServerSplashComponent} from './admin-server-splash.component';
-import {NgModule} from '@angular/core';
+import {NgModule} from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
const routes: Routes = [{
-import {NgModule} from '@angular/core';
+import {NgModule} from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
import {WorkstationsComponent} from './workstations.component';
.then(noop => this.store.getItem('eg.workstation.default'))
.then(defWs => {
this.defaultName = defWs;
- this.selectedName = this.auth.workstation() || defWs
+ this.selectedName = this.auth.workstation() || defWs;
})
.then(noop => {
- let rm = this.route.snapshot.paramMap.get('remove');
- if (rm) this.removeSelected(this.removeWorkstation = rm)
- })
+ const rm = this.route.snapshot.paramMap.get('remove');
+ if (rm) {
+ this.removeSelected(this.removeWorkstation = rm);
+ }
+ });
this.perm.hasWorkPermAt(['REGISTER_WORKSTATION'], true)
.then(perms => {
selected(): Workstation {
return this.workstations.filter(
- ws => {return ws.name == this.selectedName})[0];
+ ws => ws.name === this.selectedName)[0];
}
useNow(): void {
- if (!this.selected()) return;
- this.router.navigate(['/staff/login'],
- {queryParams: {workstation: this.selected().name}});
+ if (this.selected()) {
+ this.router.navigate(['/staff/login'],
+ {queryParams: {workstation: this.selected().name}});
+ }
}
setDefault(): void {
- if (!this.selected()) return;
- this.defaultName = this.selected().name;
- this.store.setItem('eg.workstation.default', this.defaultName);
+ if (this.selected()) {
+ this.defaultName = this.selected().name;
+ this.store.setItem('eg.workstation.default', this.defaultName);
+ }
}
removeSelected(name?: string): void {
- if (!name) name = this.selected().name;
+ if (!name) {
+ name = this.selected().name;
+ }
- this.workstations = this.workstations.filter(w => w.name != name);
+ this.workstations = this.workstations.filter(w => w.name !== name);
this.store.setItem('eg.workstation.all', this.workstations);
- if (this.defaultName == name) {
+ if (this.defaultName === name) {
this.defaultName = null;
this.store.removeItem('eg.workstation.default');
}
this.registerWorkstationApi(true).then(
wsId => resolve(wsId),
notOk => reject(notOk)
- )
+ );
},
dismissed => reject(dismissed)
- )
+ );
});
}
private registerWorkstationApi(override?: boolean): Promise<number> {
let method = 'open-ils.actor.workstation.register';
- if (override) method += '.override';
+ if (override) {
+ method += '.override';
+ }
return new Promise((resolve, reject) => {
this.net.request(
'open-ils.actor', method,
this.auth.token(), this.newName, this.newOwner.id()
).subscribe(wsId => {
- let evt = this.evt.parse(wsId);
+ const evt = this.evt.parse(wsId);
if (evt) {
- if (evt.textcode == 'WORKSTATION_NAME_EXISTS') {
+ if (evt.textcode === 'WORKSTATION_NAME_EXISTS') {
this.handleCollision().then(
id => resolve(id),
notOk => reject(notOk)
- )
+ );
} else {
console.error(`Registration failed ${evt}`);
reject();
}
private registerWorkstationLocal(wsId: number) {
- let ws: Workstation = {
+ const ws: Workstation = {
id: wsId,
name: this.newName,
owning_lib: this.newOwner.id()
this.newName = '';
// when registering our first workstation, mark it as the
// default and show it as selected in the ws selector.
- if (this.workstations.length == 1) {
+ if (this.workstations.length === 1) {
this.selectedName = ws.name;
this.setDefault();
}
export class StaffCatalogService {
searchContext: CatalogSearchContext;
- routeIndex: number = 0;
+ routeIndex = 0;
defaultSearchOrg: EgIdlObject;
defaultSearchLimit: number;
* execute the actual search.
*/
search(): void {
- if (!this.searchContext.isSearchable()) return;
+ if (!this.searchContext.isSearchable()) { return; }
- let params = this.catUrl.toUrlParams(this.searchContext);
+ const params = this.catUrl.toUrlParams(this.searchContext);
// Force a new search every time this method is called, even if
// it's the same as the active search. Since router navigation
// versions of a query param fail to cause a route navigation.
// (E.g. going from two query= params to one). Investigation
// pending.
- params.ridx=''+this.routeIndex++;
+ params.ridx = '' + this.routeIndex++;
this.router.navigate(
['/staff/catalog/search'], {queryParams: params});
export class CopiesComponent implements OnInit {
pager: Pager;
- copies: any[]
+ copies: any[];
recId: number;
- initDone: boolean = false;
+ initDone = false;
@Input() set recordId(id: number) {
this.recId = id;
// Only force new data collection when recordId()
// is invoked after ngInit() has already run.
- if (this.initDone) this.collectData();
+ if (this.initDone) {
+ this.collectData();
+ }
}
constructor(
}
collectData() {
- if (!this.recId) return;
+ if (!this.recId) { return; }
this.pager = new Pager();
this.pager.limit = 10; // TODO UI
this.fetchCopies();
// "Show Result from All Libraries" i.e. global search displays
// copies from all branches, sorted by search/pref libs.
- let copy_depth = this.staffCat.searchContext.global ?
+ const copy_depth = this.staffCat.searchContext.global ?
this.org.root().ou_type().depth() :
this.staffCat.searchContext.searchOrg.ou_type().depth();
}
holdable(copy: any): boolean {
- return copy.holdable == 't'
- && copy.location_holdable == 't'
- && copy.status_holdable == 't';
+ return copy.holdable === 't'
+ && copy.location_holdable === 't'
+ && copy.status_holdable === 't';
}
firstPage(): void {
id: number;
index: number;
- initDone: boolean = false;
+ initDone = false;
searchContext: CatalogSearchContext;
@Input() set recordId(id: number) {
this.id = id;
// Only apply new record data after the initial load
- if (this.initDone) this.setIndex();
+ if (this.initDone) {
+ this.setIndex();
+ }
}
constructor(
firstRecord(): void {
this.findRecordAtIndex(0).then(id => {
- let params = this.catUrl.toUrlParams(this.searchContext);
+ const params = this.catUrl.toUrlParams(this.searchContext);
this.router.navigate(
['/staff/catalog/record/' + id], {queryParams: params});
});
this.findRecordAtIndex(
this.searchContext.result.count - 1
).then(id => {
- let params = this.catUrl.toUrlParams(this.searchContext);
+ const params = this.catUrl.toUrlParams(this.searchContext);
this.router.navigate(
['/staff/catalog/record/' + id], {queryParams: params});
});
nextRecord(): void {
this.findRecordAtIndex(this.index + 1).then(id => {
- let params = this.catUrl.toUrlParams(this.searchContext);
+ const params = this.catUrl.toUrlParams(this.searchContext);
this.router.navigate(
['/staff/catalog/record/' + id], {queryParams: params});
});
prevRecord(): void {
this.findRecordAtIndex(this.index - 1).then(id => {
- let params = this.catUrl.toUrlParams(this.searchContext);
+ const params = this.catUrl.toUrlParams(this.searchContext);
this.router.navigate(
['/staff/catalog/record/' + id], {queryParams: params});
});
return new Promise((resolve, reject) => {
this.index = this.searchContext.indexForResult(this.id);
- if (this.index !== null) return resolve();
+ if (this.index !== null) {
+ return resolve();
+ }
return this.refreshSearch().then(ok => {
this.index = this.searchContext.indexForResult(this.id);
- if (this.index === null) console.warn(
- 'No search results found containing the focused record.');
+ if (this.index === null) {
+ console.warn(
+ 'No search results found containing the focused record.');
+ }
resolve();
});
});
// First see if the selected record sits in the current page
// of search results.
return new Promise((resolve, reject) => {
- let id = this.searchContext.resultIdAt(index);
- if (id) return resolve(id);
+ const id = this.searchContext.resultIdAt(index);
+ if (id) { return resolve(id); }
console.debug(
'Record paginator unable to find record at index ' + index);
// requested record plus one more.
return this.refreshSearch(index + 2).then(
ok => {
- let id = this.searchContext.resultIdAt(index);
- if (id) {
- resolve(id);
+ const rid = this.searchContext.resultIdAt(index);
+ if (rid) {
+ resolve(rid);
} else {
reject('no record found');
}
});
}
- refreshSearch(limit?: number): Promise<void> {
+ refreshSearch(limit?: number): Promise<any> {
console.debug('paginator refreshing search');
- if (!this.searchContext.isSearchable())
+ if (!this.searchContext.isSearchable()) {
return Promise.resolve();
+ }
- let origPager = this.searchContext.pager;
- let tmpPager = new Pager();
+ const origPager = this.searchContext.pager;
+ const tmpPager = new Pager();
tmpPager.limit = limit || 1000;
this.searchContext.pager = tmpPager;
return this.cat.search(this.searchContext)
.then(
- ok => { this.searchContext.pager = origPager; },
- notOk => { this.searchContext.pager = origPager }
+ ok => this.searchContext.pager = origPager,
+ notOk => this.searchContext.pager = origPager
);
}
import {ActivatedRoute, ParamMap} from '@angular/router';
import {EgPcrudService} from '@eg/core/pcrud.service';
import {EgIdlObject} from '@eg/core/idl.service';
-import {CatalogSearchContext, CatalogSearchState}
- from '@eg/share/catalog/search-context';
+import {CatalogSearchContext, CatalogSearchState} from '@eg/share/catalog/search-context';
import {EgCatalogService} from '@eg/share/catalog/catalog.service';
import {StaffCatalogService} from '../catalog.service';
import {EgBibSummaryComponent} from '@eg/staff/share/bib-summary/bib-summary.component';
this.route.paramMap.subscribe((params: ParamMap) => {
this.recordId = +params.get('id');
this.loadRecord();
- })
+ });
}
loadRecord(): void {
this.bibSummary = summary;
this.pcrud.search('au', {id: [summary.creator, summary.editor]})
.subscribe(user => {
- if (user.id() == summary.creator)
+ if (user.id() === summary.creator) {
summary.creator = user;
- if (user.id() == summary.editor)
+ }
+ if (user.id() === summary.editor) {
summary.editor = user;
- })
+ }
+ });
});
}
}
}
fetchSettings(): Promise<any> {
- let promises = [];
+ const promises = [];
promises.push(
this.store.getItem('eg.search.search_lib').then(
}
setPage(page: number): void {
- if (this.searchContext.pager.currentPage() == page) return;
+ if (this.searchContext.pager.currentPage() === page) { return; }
this.searchContext.pager.setPage(page);
this.staffCat.search();
}
<span i18n>Place Hold</span>
</button>
</span>
- <span>
+ <span class="pl-1">
<button (click)="addToList()"
class="btn btn-sm btn-info label-with-material-icon small-text-1">
<span class="material-icons">playlist_add_check</span>
* Propagate the search params along when navigating to each record.
*/
navigatToRecord(id: number) {
- let params = this.catUrl.toUrlParams(this.searchContext);
+ const params = this.catUrl.toUrlParams(this.searchContext);
this.router.navigate(
['/staff/catalog/record/' + id], {queryParams: params});
import {ActivatedRoute, ParamMap} from '@angular/router';
import {EgCatalogService} from '@eg/share/catalog/catalog.service';
import {EgCatalogUrlService} from '@eg/share/catalog/catalog-url.service';
-import {CatalogSearchContext, CatalogSearchState}
- from '@eg/share/catalog/search-context';
+import {CatalogSearchContext, CatalogSearchState} from '@eg/share/catalog/search-context';
import {EgPcrudService} from '@eg/core/pcrud.service';
import {StaffCatalogService} from '../catalog.service';
import {EgIdlObject} from '@eg/core/idl.service';
// Cache record creator/editor since this will likely be a
// reasonably small set of data w/ lots of repitition.
- userCache: {[id:number] : EgIdlObject} = {};
+ userCache: {[id: number]: EgIdlObject} = {};
constructor(
private route: ActivatedRoute,
// params and running through .distinctUntilChanged(), but
// .map() is not firing either. I'm missing something.
this.searchByUrl(params);
- })
+ });
}
searchByUrl(params: ParamMap): void {
this.catUrl.applyUrlParams(this.searchContext, params);
- // A query string is required at minimum.
- if (!this.searchContext.isSearchable()) return;
+ if (this.searchContext.isSearchable()) {
- this.cat.search(this.searchContext)
- .then(ok => {
- this.cat.fetchFacets(this.searchContext);
- this.cat.fetchBibSummaries(this.searchContext)
- .then(ok2 => this.fleshSearchResults());
- });
+ this.cat.search(this.searchContext)
+ .then(ok => {
+ this.cat.fetchFacets(this.searchContext);
+ this.cat.fetchBibSummaries(this.searchContext)
+ .then(ok2 => this.fleshSearchResults());
+ });
+ }
}
fleshSearchResults(): void {
- let records = this.searchContext.result.records;
- if (records.length == 0) return;
+ const records = this.searchContext.result.records;
+ if (records.length === 0) { return; }
// Flesh the creator / editor fields with the user object.
// Handle the user fleshing here (instead of record.component so
// we only need to grab one copy of each user.
- let userIds: {[id:number]: boolean} = {};
+ const userIds: {[id: number]: boolean} = {};
records.forEach(recSum => {
if (this.userCache[recSum.creator]) {
recSum.creator = this.userCache[recSum.creator];
}
});
- if (!Object.keys(userIds).length) return;
+ if (!Object.keys(userIds).length) { return; }
this.pcrud.search('au', {id : Object.keys(userIds)})
.subscribe(usr => {
this.userCache[usr.id()] = usr;
records.forEach(recSum => {
- if (recSum.creator == usr.id()) recSum.creator = usr;
- if (recSum.editor == usr.id()) recSum.editor = usr;
+ if (recSum.creator === usr.id()) {
+ recSum.creator = usr;
+ }
+ if (recSum.editor === usr.id()) {
+ recSum.editor = usr;
+ }
});
});
}
searchIsDone(): boolean {
- return this.searchContext.searchState == CatalogSearchState.COMPLETE;
+ return this.searchContext.searchState === CatalogSearchState.COMPLETE;
}
}
import {Component, OnInit, AfterViewInit, Renderer2} from '@angular/core';
import {EgIdlObject} from '@eg/core/idl.service';
import {EgOrgService} from '@eg/core/org.service';
-import {EgCatalogService,} from '@eg/share/catalog/catalog.service';
-import {CatalogSearchContext, CatalogSearchState}
- from '@eg/share/catalog/search-context';
+import {EgCatalogService} from '@eg/share/catalog/catalog.service';
+import {CatalogSearchContext, CatalogSearchState} from '@eg/share/catalog/search-context';
import {StaffCatalogService} from './catalog.service';
@Component({
export class SearchFormComponent implements OnInit, AfterViewInit {
searchContext: CatalogSearchContext;
- ccvmMap: {[ccvm:string] : EgIdlObject[]} = {};
- cmfMap: {[cmf:string] : EgIdlObject} = {};
- showAdvancedSearch: boolean = false;
+ ccvmMap: {[ccvm: string]: EgIdlObject[]} = {};
+ cmfMap: {[cmf: string]: EgIdlObject} = {};
+ showAdvancedSearch = false;
constructor(
private renderer: Renderer2,
// e.g. if filters were applied then removed.
let show = false;
Object.keys(this.searchContext.ccvmFilters).forEach(ccvm => {
- if (this.searchContext.ccvmFilters[ccvm][0] != '')
+ if (this.searchContext.ccvmFilters[ccvm][0] !== '') {
show = true;
+ }
});
return show;
}
searchIsActive(): boolean {
- return this.searchContext.searchState == CatalogSearchState.SEARCHING;
+ return this.searchContext.searchState === CatalogSearchState.SEARCHING;
}
}
export class EgBcSearchComponent implements OnInit {
- barcode: string = '';
+ barcode = '';
constructor(
private route: ActivatedRoute,
-import {NgModule} from '@angular/core';
-import {EgStaffCommonModule} from '@eg/staff/common.module';
+import {NgModule} from '@angular/core';
+import {EgStaffCommonModule} from '@eg/staff/common.module';
import {EgBcSearchRoutingModule} from './routing.module';
-import {EgBcSearchComponent} from './bcsearch.component';
+import {EgBcSearchComponent} from './bcsearch.component';
@NgModule({
declarations: [
-import {NgModule} from '@angular/core';
+import {NgModule} from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
-import {EgBcSearchComponent} from './bcsearch.component';
+import {EgBcSearchComponent} from './bcsearch.component';
const routes: Routes = [
{ path: '',
-import {NgModule} from '@angular/core';
+import {NgModule} from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
const routes: Routes = [
-import { NgModule } from '@angular/core';
-import { RouterModule, Routes } from '@angular/router';
+import {NgModule} from '@angular/core';
+import {RouterModule, Routes} from '@angular/router';
const routes: Routes = [
{ path: 'patron',
@ViewChild('printTemplate')
private printTemplate: TemplateRef<any>;
-
- //@ViewChild('helloStr') private helloStr: EgStringComponent;
+ // @ViewChild('helloStr') private helloStr: EgStringComponent;
gridDataSource: EgGridDataSource = new EgGridDataSource();
this.testStr = str;
}
- name: string = 'Jane';
+ name = 'Jane';
constructor(
private idl: EgIdlService,
limit: pager.limit,
order_by: {cbt: 'name'}
});
- }
+ };
}
doPrint() {
},
err => {}
);
- }
+ };
this.deleteSelected = (idlThings: EgIdlObject[]) => {
idlThings.forEach(idlThing => idlThing.isdeleted(true));
err => {},
() => this.grid.reload()
);
- }
+ };
}
initDataSource() {
this.dataSource = new EgGridDataSource();
this.dataSource.getRows = (pager: Pager, sort: any[]) => {
-
const orderBy: any = {};
if (sort.length) {
orderBy[this.idlClass] = sort[0].name + ' ' + sort[0].dir;
limit: pager.limit,
order_by: orderBy
});
- }
+ };
}
}
})
export class EgBibSummaryComponent implements OnInit {
- initDone: boolean = false;
+ initDone = false;
+ expandDisplay = true;
// If provided, the record will be fetched by the component.
@Input() recordId: number;
summary: any;
@Input() set bibSummary(s: any) {
this.summary = s;
- if (this.initDone) this.fetchBibCallNumber();
+ if (this.initDone) {
+ this.fetchBibCallNumber();
+ }
}
- expandDisplay: boolean = true;
-
constructor(
private cat: EgCatalogService,
private net: EgNetService,
if (this.summary) {
this.fetchBibCallNumber();
} else {
- if (this.recordId) this.loadSummary();
+ if (this.recordId) {
+ this.loadSummary();
+ }
}
}
// Flesh the user data
this.pcrud.search('au', {id: [summary.creator, summary.editor]})
.subscribe(user => {
- if (user.id() == summary.creator)
+ if (user.id() === summary.creator) {
summary.creator = user;
- if (user.id() == summary.editor)
+ }
+ if (user.id() === summary.editor) {
summary.editor = user;
- })
+ }
+ });
});
}
fetchBibCallNumber(): void {
- if (!this.summary || this.summary.callNumber) return;
+ if (!this.summary || this.summary.callNumber) {
+ return;
+ }
// TODO labelClass = cat.default_classification_scheme YAOUS
- let labelClass = 1;
+ const labelClass = 1;
this.net.request(
'open-ils.cat',
this.summary.id, labelClass
).subscribe(cnArray => {
if (cnArray && cnArray.length > 0) {
- let key1 = Object.keys(cnArray[0])[0];
+ const key1 = Object.keys(cnArray[0])[0];
this.summary.callNumber = cnArray[0][key1];
}
});