From 601897d602f3728308056d0e16d90f14d31351b9 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 12 Jul 2019 15:01:00 -0400 Subject: [PATCH] LP1825851 lint Signed-off-by: Bill Erickson --- Open-ILS/src/eg2/src/app/core/idl.service.ts | 10 +++---- .../src/app/share/combobox/combobox.component.ts | 2 +- .../src/eg2/src/app/share/print/print.component.ts | 8 +++--- .../eg2/src/app/share/util/sample-data.service.ts | 22 +++++++-------- .../staff/admin/server/print-template.component.ts | 32 ++++++++++++---------- .../eg2/src/app/staff/sandbox/sandbox.component.ts | 2 +- .../src/app/staff/share/holds/grid.component.ts | 2 +- 7 files changed, 40 insertions(+), 38 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/core/idl.service.ts b/Open-ILS/src/eg2/src/app/core/idl.service.ts index 468ae2dbe3..21ec24a274 100644 --- a/Open-ILS/src/eg2/src/app/core/idl.service.ts +++ b/Open-ILS/src/eg2/src/app/core/idl.service.ts @@ -167,25 +167,25 @@ export class IdlService { 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]; }); diff --git a/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.ts b/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.ts index 6995043329..84b89d84f1 100644 --- a/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.ts +++ b/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.ts @@ -3,7 +3,7 @@ * * */ -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'; diff --git a/Open-ILS/src/eg2/src/app/share/print/print.component.ts b/Open-ILS/src/eg2/src/app/share/print/print.component.ts index f9238aa628..ff1c3ed1f4 100644 --- a/Open-ILS/src/eg2/src/app/share/print/print.component.ts +++ b/Open-ILS/src/eg2/src/app/share/print/print.component.ts @@ -69,7 +69,7 @@ export class PrintComponent implements OnInit { this.template = printReq.template; this.context = {$implicit: printReq.contextData}; return Promise.resolve(); - } + } let promise; @@ -86,15 +86,15 @@ export class PrintComponent implements OnInit { 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(() => { diff --git a/Open-ILS/src/eg2/src/app/share/util/sample-data.service.ts b/Open-ILS/src/eg2/src/app/share/util/sample-data.service.ts index 66f840c071..d159d6d6ba 100644 --- a/Open-ILS/src/eg2/src/app/share/util/sample-data.service.ts +++ b/Open-ILS/src/eg2/src/app/share/util/sample-data.service.ts @@ -71,16 +71,16 @@ const DATA = { {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'}, ] }; @@ -96,7 +96,7 @@ export class SampleDataService { 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[] = []; diff --git a/Open-ILS/src/eg2/src/app/staff/admin/server/print-template.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/server/print-template.component.ts index f5f793660c..379a1d2a28 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/server/print-template.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/server/print-template.component.ts @@ -48,7 +48,7 @@ export class PrintTemplateComponent implements OnInit { sampleData: any = { patron_address: {}, holds_for_bib: {} - } + }; constructor( private route: ActivatedRoute, @@ -82,8 +82,8 @@ export class PrintTemplateComponent implements OnInit { // 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. @@ -120,7 +120,8 @@ export class PrintTemplateComponent implements OnInit { 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; @@ -128,11 +129,12 @@ export class PrintTemplateComponent implements OnInit { } } + // 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; } @@ -155,17 +157,17 @@ export class PrintTemplateComponent implements OnInit { 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; })); } @@ -193,12 +195,12 @@ export class PrintTemplateComponent implements OnInit { } 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; @@ -210,7 +212,7 @@ export class PrintTemplateComponent implements OnInit { printContext: 'default' // required, has no impact here }).then(response => { - + this.compiledContent = response.content; if (response.contentType === 'text/html') { this.container().innerHTML = response.content; @@ -224,7 +226,7 @@ export class PrintTemplateComponent implements OnInit { applyChanges() { this.container().innerHTML = ''; this.pcrud.update(this.template).toPromise() - .then(() =>this.refreshPreview()); + .then(() => this.refreshPreview()); } openEditDialog() { @@ -243,9 +245,9 @@ export class PrintTemplateComponent implements OnInit { 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())); }); } @@ -255,7 +257,7 @@ export class PrintTemplateComponent implements OnInit { if (!confirmed) { return; } this.pcrud.remove(this.template).toPromise().then(_ => { this.setTemplateInfo().toPromise() - .then(_ => this.selectTemplate(null)); + .then(x => this.selectTemplate(null)); }); }); } diff --git a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts index 505a501080..64397d7451 100644 --- a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts @@ -274,7 +274,7 @@ export class SandboxComponent implements OnInit { 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({ diff --git a/Open-ILS/src/eg2/src/app/staff/share/holds/grid.component.ts b/Open-ILS/src/eg2/src/app/staff/share/holds/grid.component.ts index d6988dc927..eb670d0b70 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/holds/grid.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/holds/grid.component.ts @@ -404,7 +404,7 @@ export class HoldsGridComponent implements OnInit { pager.offset = 0; pager.limit = null; - if (this.gridDataSource.sort.length == 0) { + if (this.gridDataSource.sort.length === 0) { this.gridDataSource.sort = this.defaultSort; } -- 2.11.0