return obj.map(item => this.toHash(item));
}
- const fieldNames = obj._isfieldmapper ?
+ const fieldNames = obj._isfieldmapper ?
Object.keys(this.classes[obj.classname].field_map) :
Object.keys(obj);
const hash: any = {};
fieldNames.forEach(field => {
- var val = this.toHash(
- typeof obj[field] === 'function' ? obj[field]() : obj[field],
+ const val = this.toHash(
+ typeof obj[field] === 'function' ? obj[field]() : obj[field],
flatten
);
if (val === undefined) { return; }
- if (flatten && val !== null &&
+ if (flatten && val !== null &&
typeof val === 'object' && !Array.isArray(val)) {
Object.keys(val).forEach(key => {
- let fname = field + '.' + key;
+ const fname = field + '.' + key;
hash[fname] = val[key];
});
* <!-- see also <eg-combobox-entry> -->
* </eg-combobox>
*/
-import {Component, OnInit, Input, Output, ViewChild,
+import {Component, OnInit, Input, Output, ViewChild,
TemplateRef, EventEmitter, ElementRef} from '@angular/core';
import {Observable, of, Subject} from 'rxjs';
import {map, tap, reduce, mergeMap, mapTo, debounceTime, distinctUntilChanged, merge, filter} from 'rxjs/operators';
this.template = printReq.template;
this.context = {$implicit: printReq.contextData};
return Promise.resolve();
- }
+ }
let promise;
printReq.contentType = response.contentType;
},
err => {
- console.error("Error compiling template", printReq);
+ console.error('Error compiling template', printReq);
return Promise.reject(new Error(
'Error compiling server-hosted print template'));
}
);
} else {
- console.error("Cannot find template", printReq);
- return Promise.reject(new Error("Cannot find print template"));
+ console.error('Cannot find template', printReq);
+ return Promise.reject(new Error('Cannot find print template'));
}
return promise.then(() => {
{barcode: '208897239009'}
],
mwde: [
- {title: "Sinidos sinfónicos : an orchestral sampler"},
- {title: "Piano concerto, op. 38"},
- {title: "Critical entertainments : music old and new"},
- {title: "Piano concerto in C major, op. 39"},
- {title: "Double concerto in A minor, op. 102 ; Variations on a theme by Haydn, op. 56a ; Tragic overture, op. 81"},
- {title: "Trombone concerto (1991) subject: american"},
- {title: "Violin concerto no. 2 ; Six duos (from 44 Duos)"},
- {title: "Piano concerto no. 1 (1926) ; Rhapsody, op. 1 (1904)"},
- {title: "Piano concertos 2 & 3 & the devil makes me?"},
- {title: "Composition student recital, April 6, 2000, Huntington University / composition students of Daniel Bédard"},
+ {title: 'Sinidos sinfónicos : an orchestral sampler'},
+ {title: 'Piano concerto, op. 38'},
+ {title: 'Critical entertainments : music old and new'},
+ {title: 'Piano concerto in C major, op. 39'},
+ {title: 'Double concerto in A minor, op. 102 ; Variations on a theme by Haydn, op. 56a ; Tragic overture, op. 81'},
+ {title: 'Trombone concerto (1991) subject: american'},
+ {title: 'Violin concerto no. 2 ; Six duos (from 44 Duos)'},
+ {title: 'Piano concerto no. 1 (1926) ; Rhapsody, op. 1 (1904)'},
+ {title: 'Piano concertos 2 & 3 & the devil makes me?'},
+ {title: 'Composition student recital, April 6, 2000, Huntington University / composition students of Daniel Bédard'},
]
};
listOfThings(idlClass: string, count: number = 1): IdlObject[] {
if (!(idlClass in DATA)) {
- throw new Error(`No sample data for class ${idlClass}"`);
+ throw new Error(`No sample data for class ${idlClass}'`);
}
const things: IdlObject[] = [];
sampleData: any = {
patron_address: {},
holds_for_bib: {}
- }
+ };
constructor(
private route: ActivatedRoute,
// Classes for which sample data exists
const classes = ['au', 'ac', 'aua', 'ahr', 'acp', 'mwde'];
const samples: any = {};
- classes.forEach(class_ => samples[class_] =
- this.idl.toHash(this.samples.listOfThings(class_, 10)))
+ classes.forEach(class_ => samples[class_] =
+ this.idl.toHash(this.samples.listOfThings(class_, 10)));
// Wide holds are hashes instead of IDL objects.
// Add fields as needed.
return document.getElementById('template-preview-pane');
}
- //orgOnChange(org: IdlObject) {
+ // TODO should the ngModelChange handler fire for org-family-select
+ // even whn no values have changed?
orgOnChange(family: OrgFamily) {
if (!this.arrayEquals(this.selectedOrgs, family.orgIds)) {
this.selectedOrgs = family.orgIds;
}
}
+ // TODO move to shared utility
arrayEquals(arr1: any[], arr2: any[]): boolean {
if (arr1.length !== arr2.length) {
return false;
}
- for (var i = 0; i < arr1.length; i++) {
+ for (let i = 0; i < arr1.length; i++) {
if (arr1[i] !== arr2[i]) {
return false;
}
this.templateSelector.applyEntryId(null);
this.compiledContent = '';
- return this.pcrud.search('cpt',
+ return this.pcrud.search('cpt',
{
owner: this.selectedOrgs,
locale: this.localeCode
}, {
- select: {cpt: ['id', 'label', 'owner']},
+ select: {cpt: ['id', 'label', 'owner']},
order_by: {cpt: 'label'}
}
).pipe(map(tmpl => {
this.templateCache[tmpl.id()] = tmpl;
- this.entries.push({id: tmpl.id(), label: tmpl.label()})
+ this.entries.push({id: tmpl.id(), label: tmpl.label()});
return tmpl;
}));
}
}
refreshPreview() {
- if (!this.sampleJson) return;
+ if (!this.sampleJson) { return; }
this.compiledContent = '';
let data;
try {
- data = JSON.parse(this.sampleJson);
+ data = JSON.parse(this.sampleJson);
this.invalidJson = false;
} catch (E) {
this.invalidJson = true;
printContext: 'default' // required, has no impact here
}).then(response => {
-
+
this.compiledContent = response.content;
if (response.contentType === 'text/html') {
this.container().innerHTML = response.content;
applyChanges() {
this.container().innerHTML = '';
this.pcrud.update(this.template).toPromise()
- .then(() =>this.refreshPreview());
+ .then(() => this.refreshPreview());
}
openEditDialog() {
tmpl.id(null);
this.editDialog.setRecord(tmpl);
this.editDialog.mode = 'create';
- this.editDialog.open({size: 'lg'}).toPromise().then(tmpl => {
+ this.editDialog.open({size: 'lg'}).toPromise().then(newTmpl => {
this.setTemplateInfo().toPromise()
- .then(_ => this.selectTemplate(tmpl.id()));
+ .then(_ => this.selectTemplate(newTmpl.id()));
});
}
if (!confirmed) { return; }
this.pcrud.remove(this.template).toPromise().then(_ => {
this.setTemplateInfo().toPromise()
- .then(_ => this.selectTemplate(null));
+ .then(x => this.selectTemplate(null));
});
});
}
const templateData = {
patron: this.samples.listOfThings('au')[0],
address: this.samples.listOfThings('aua')[0]
- }
+ };
// NOTE: eventually this will be baked into the print service.
this.printer.print({
pager.offset = 0;
pager.limit = null;
- if (this.gridDataSource.sort.length == 0) {
+ if (this.gridDataSource.sort.length === 0) {
this.gridDataSource.sort = this.defaultSort;
}