From: Bill Erickson Date: Fri, 18 May 2018 21:16:19 +0000 (-0400) Subject: LP#1775466 ng-lint updates X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=5e6b8d19573986ad6c80bf1403a0fdb1a59c16b8;p=working%2FEvergreen.git LP#1775466 ng-lint updates Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/src/app/share/catalog/catalog-url.service.ts b/Open-ILS/src/eg2/src/app/share/catalog/catalog-url.service.ts index a71b87413d..a4cdff4ca5 100644 --- a/Open-ILS/src/eg2/src/app/share/catalog/catalog-url.service.ts +++ b/Open-ILS/src/eg2/src/app/share/catalog/catalog-url.service.ts @@ -19,7 +19,7 @@ export class EgCatalogUrlService { toUrlParams(context: CatalogSearchContext): {[key: string]: string | string[]} { - let params = { + const params = { query: [], fieldClass: [], joinOp: [], @@ -31,11 +31,12 @@ export class EgCatalogUrlService { }; params.limit = context.pager.limit; - if (context.pager.offset) + if (context.pager.offset) { params.offset = context.pager.offset; + } // These fields can be copied directly into place - ['format','sort','available','global'] + ['format', 'sort', 'available', 'global'] .forEach(field => { if (context[field]) { // Only propagate applied values to the URL. @@ -44,7 +45,7 @@ export class EgCatalogUrlService { }); context.query.forEach((q, idx) => { - ['query', 'fieldClass','joinOp','matchOp'].forEach(field => { + ['query', 'fieldClass', 'joinOp', 'matchOp'].forEach(field => { // Propagate all array-based fields regardless of // whether a value is applied to ensure correct // correlation between values. @@ -55,7 +56,7 @@ export class EgCatalogUrlService { // CCVM filters are encoded as comma-separated lists Object.keys(context.ccvmFilters).forEach(code => { if (context.ccvmFilters[code] && - context.ccvmFilters[code][0] != '') { + context.ccvmFilters[code][0] !== '') { params[code] = context.ccvmFilters[code].join(','); } }); @@ -78,7 +79,7 @@ export class EgCatalogUrlService { * Creates a new search context from the active route params. */ fromUrlParams(params: ParamMap): CatalogSearchContext { - let context = new CatalogSearchContext(); + const context = new CatalogSearchContext(); this.applyUrlParams(context, params); @@ -91,25 +92,31 @@ export class EgCatalogUrlService { context.reset(); // These fields can be copied directly into place - ['format','sort','available','global'] + ['format', 'sort', 'available', 'global'] .forEach(field => { - let val = params.get(field); - if (val !== null) context[field] = val; + const val = params.get(field); + if (val !== null) { + context[field] = val; + } }); - if (params.get('limit')) + if (params.get('limit')) { context.pager.limit = +params.get('limit'); + } - if (params.get('offset')) + if (params.get('offset')) { context.pager.offset = +params.get('offset'); + } - ['query','fieldClass','joinOp','matchOp'].forEach(field => { - let arr = params.getAll(field); - if (arr && arr.length) context[field] = arr; + ['query', 'fieldClass', 'joinOp', 'matchOp'].forEach(field => { + const arr = params.getAll(field); + if (arr && arr.length) { + context[field] = arr; + } }); CATALOG_CCVM_FILTERS.forEach(code => { - let val = params.get(code); + const val = params.get(code); if (val) { context.ccvmFilters[code] = val.split(/,/); } else { @@ -118,11 +125,12 @@ export class EgCatalogUrlService { }); params.getAll('facets').forEach(blob => { - let facet = JSON.parse(blob); + const facet = JSON.parse(blob); context.addFacet(new FacetFilter(facet.c, facet.n, facet.v)); }); - if (params.get('org')) + if (params.get('org')) { context.searchOrg = this.org.get(+params.get('org')); + } } } diff --git a/Open-ILS/src/eg2/src/app/share/date-select/date-select.component.ts b/Open-ILS/src/eg2/src/app/share/date-select/date-select.component.ts index 67db0af783..8d6434eb2a 100644 --- a/Open-ILS/src/eg2/src/app/share/date-select/date-select.component.ts +++ b/Open-ILS/src/eg2/src/app/share/date-select/date-select.component.ts @@ -40,8 +40,9 @@ export class EgDateSelectComponent implements OnInit { this.initialDate = new Date(this.initialIso); } - if (!this.initialDate) + if (!this.initialDate) { this.initialDate = new Date(); + } this.current = { year: this.initialDate.getFullYear(), @@ -51,9 +52,9 @@ export class EgDateSelectComponent implements OnInit { } onDateSelect(evt) { - let ymd = `${evt.year}-${evt.month}-${evt.day}`; - let date = this.localDateFromYmd(ymd); - let iso = date.toISOString(); + const ymd = `${evt.year}-${evt.month}-${evt.day}`; + const date = this.localDateFromYmd(ymd); + const iso = date.toISOString(); this.onChangeAsDate.emit(date); this.onChangeAsYmd.emit(ymd); this.onChangeAsIso.emit(iso); @@ -62,7 +63,7 @@ export class EgDateSelectComponent implements OnInit { // Create a date in the local time zone with selected YMD values. // TODO: Consider moving this to a date service... localDateFromYmd(ymd: string): Date { - var parts = ymd.split('-'); + const parts = ymd.split('-'); return new Date( Number(parts[0]), Number(parts[1]) - 1, Number(parts[2])); } diff --git a/Open-ILS/src/eg2/src/app/share/dialog/progress.component.ts b/Open-ILS/src/eg2/src/app/share/dialog/progress.component.ts index d9cc60a7a5..e0aead3cc6 100644 --- a/Open-ILS/src/eg2/src/app/share/dialog/progress.component.ts +++ b/Open-ILS/src/eg2/src/app/share/dialog/progress.component.ts @@ -63,27 +63,31 @@ export class EgProgressDialogComponent extends EgDialogComponent { if (this.hasValue() && this.hasMax() && this.max > 0 && - this.value <= this.max) + this.value <= this.max) { return Math.floor((this.value / this.max) * 100); + } return 100; } // Set the current state of the progress bar. - update(args: {[key:string] : number}) { - if (args.max != undefined) + update(args: {[key: string]: number}) { + if (args.max !== undefined) { this.max = args.max; - if (args.value != undefined) + } + if (args.value !== undefined) { this.value = args.value; + } } // Increment the current value. If no amount is specified, // it increments by 1. Calling increment() on an indetermite // progress bar will force it to be a (semi-)determinate bar. increment(amt: number) { - if (!Number.isInteger(amt)) amt = 1; + if (!Number.isInteger(amt)) { amt = 1; } - if (!this.hasValue()) + if (!this.hasValue()) { this.value = 0; + } this.value += amt; } diff --git a/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.ts b/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.ts index 6e696d2bc8..e80d9f02b8 100644 --- a/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.ts +++ b/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.ts @@ -7,27 +7,27 @@ import {EgDialogComponent} from '@eg/share/dialog/dialog.component'; import {NgbModal, NgbModalOptions} from '@ng-bootstrap/ng-bootstrap'; interface CustomFieldTemplate { - template: TemplateRef, + template: TemplateRef; // Allow the caller to pass in a free-form context blob to // be addedto the caller's custom template context, along // with our stock context. - context?: {[fields: string]: any} + context?: {[fields: string]: any}; } interface CustomFieldContext { // Current create/edit/view record - record: EgIdlObject, + record: EgIdlObject; // IDL field definition blob - field: any, + field: any; // additional context values passed via CustomFieldTemplate [fields: string]: any; } @Component({ - selector: 'fm-record-editor', + selector: 'eg-fm-record-editor', templateUrl: './fm-editor.component.html' }) export class FmRecordEditorComponent @@ -40,23 +40,13 @@ export class FmRecordEditorComponent // 'update' for editing an existing record // 'view' for viewing an existing record without editing mode: 'create' | 'update' | 'view' = 'create'; - @Input() editMode(mode: 'create' | 'update' | 'view') { - this.mode = mode; - } - - // Record ID to view/update. Value is dynamic. Records are not - // fetched until .open() is called. recId: any; - @Input() set recordId(id: any) { - if (id) this.recId = id; - } - // IDL record we are editing // TODO: allow this to be update in real time by the caller? record: EgIdlObject; @Input() customFieldTemplates: - {[fieldName:string] : CustomFieldTemplate} = {}; + {[fieldName: string]: CustomFieldTemplate} = {}; // list of fields that should not be displayed @Input() hiddenFieldsList: string[] = []; @@ -82,7 +72,7 @@ export class FmRecordEditorComponent // supports cases where whether a field is required or not depends // on the current value of another field. @Input() isRequiredOverride: - {[field: string] : (field: string, record: EgIdlObject) => boolean}; + {[field: string]: (field: string, record: EgIdlObject) => boolean}; // IDL record display label. Defaults to the IDL label. @Input() recordLabel: string; @@ -100,18 +90,28 @@ export class FmRecordEditorComponent idlDef: any; // Can we edit the primary key? - pkeyIsEditable: boolean = false; + pkeyIsEditable = false; // List of IDL field definitions. This is a subset of the full // list of fields on the IDL, since some are hidden, virtual, etc. fields: any[]; + @Input() editMode(mode: 'create' | 'update' | 'view') { + this.mode = mode; + } + + // Record ID to view/update. Value is dynamic. Records are not + // fetched until .open() is called. + @Input() set recordId(id: any) { + if (id) { this.recId = id; } + } + constructor( private modal: NgbModal, // required for passing to parent private idl: EgIdlService, private auth: EgAuthService, private pcrud: EgPcrudService) { - super(modal) + super(modal); } // Avoid fetching data on init since that may lead to unnecessary @@ -133,19 +133,23 @@ export class FmRecordEditorComponent // Translate comma-separated string versions of various inputs // to arrays. private listifyInputs() { - if (this.hiddenFields) + if (this.hiddenFields) { this.hiddenFieldsList = this.hiddenFields.split(/,/); - if (this.readonlyFields) + } + if (this.readonlyFields) { this.readonlyFieldsList = this.readonlyFields.split(/,/); - if (this.requiredFields) + } + if (this.requiredFields) { this.requiredFieldsList = this.requiredFields.split(/,/); - if (this.orgDefaultAllowed) + } + if (this.orgDefaultAllowed) { this.orgDefaultAllowedList = this.orgDefaultAllowed.split(/,/); + } } private initRecord(): Promise { - if (this.mode == 'update' || this.mode == 'view') { + if (this.mode === 'update' || this.mode === 'view') { return this.pcrud.retrieve(this.idlClass, this.recId) .toPromise().then(rec => { @@ -170,10 +174,10 @@ export class FmRecordEditorComponent // with native JS values. private convertDatatypesToJs() { this.idlDef.fields.forEach(field => { - if (field.datatype == 'bool') { - if (this.record[field.name]() == 't') { + if (field.datatype === 'bool') { + if (this.record[field.name]() === 't') { this.record[field.name](true); - } else if (this.record[field.name]() == 'f') { + } else if (this.record[field.name]() === 'f') { this.record[field.name](false); } } @@ -183,18 +187,18 @@ export class FmRecordEditorComponent // Modifies the provided FM record in place, replacing JS values // with IDL-compatible values. convertDatatypesToIdl(rec: EgIdlObject) { - var fields = this.idlDef.fields; + const fields = this.idlDef.fields; fields.forEach(field => { - if (field.datatype == 'bool') { - if (rec[field.name]() == true) { + if (field.datatype === 'bool') { + if (rec[field.name]() === true) { rec[field.name]('t'); - //} else if (rec[field.name]() == false) { + // } else if (rec[field.name]() === false) { } else { // TODO: some bools can be NULL rec[field.name]('f'); } - } else if (field.datatype == 'org_unit') { - let org = rec[field.name](); - if (org && typeof org == 'object') { + } else if (field.datatype === 'org_unit') { + const org = rec[field.name](); + if (org && typeof org === 'object') { rec[field.name](org.id()); } } @@ -203,41 +207,41 @@ export class FmRecordEditorComponent private flattenLinkedValues(cls: string, list: EgIdlObject[]): any[] { - let idField = this.idl.classes[cls].pkey; - let selector = + const idField = this.idl.classes[cls].pkey; + const selector = this.idl.classes[cls].field_map[idField].selector || idField; return list.map(item => { - return {id: item[idField](), name: item[selector]()} + return {id: item[idField](), name: item[selector]()}; }); } private getFieldList(): Promise { this.fields = this.idlDef.fields.filter(f => - f.virtual != 'true' && + f.virtual !== 'true' && !this.hiddenFieldsList.includes(f.name) ); - let promises = []; + const promises = []; this.fields.forEach(field => { - field.readOnly = this.mode == 'view' + field.readOnly = this.mode === 'view' || this.readonlyFieldsList.includes(field.name); if (this.isRequiredOverride && field.name in this.isRequiredOverride) { field.isRequired = () => { return this.isRequiredOverride[field.name](field.name, this.record); - } + }; } else { field.isRequired = () => { return field.required || this.requiredFieldsList.includes(field.name); - } + }; } - if (field.datatype == 'link') { + if (field.datatype === 'link') { promises.push( this.pcrud.retrieveAll(field.class, {}, {atomic : true}) .toPromise().then(list => { @@ -245,7 +249,7 @@ export class FmRecordEditorComponent this.flattenLinkedValues(field.class, list); }) ); - } else if (field.datatype == 'org_unit') { + } else if (field.datatype === 'org_unit') { field.orgDefaultAllowed = this.orgDefaultAllowedList.includes(field.name); } @@ -272,7 +276,7 @@ export class FmRecordEditorComponent } save() { - let recToSave = this.idl.clone(this.record); + const recToSave = this.idl.clone(this.record); this.convertDatatypesToIdl(recToSave); this.pcrud[this.mode]([recToSave]).toPromise().then( result => this.close(result), diff --git a/Open-ILS/src/eg2/src/app/staff/admin/server/config/billing_type.component.html b/Open-ILS/src/eg2/src/app/staff/admin/server/config/billing_type.component.html index d102c31cdc..8409d23728 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/server/config/billing_type.component.html +++ b/Open-ILS/src/eg2/src/app/staff/admin/server/config/billing_type.component.html @@ -24,8 +24,8 @@ - - + + Billing Type Update Succeeded diff --git a/Open-ILS/src/eg2/src/app/staff/admin/server/config/hard_due_date.component.html b/Open-ILS/src/eg2/src/app/staff/admin/server/config/hard_due_date.component.html index 4b31604953..da10d0d45e 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/server/config/hard_due_date.component.html +++ b/Open-ILS/src/eg2/src/app/staff/admin/server/config/hard_due_date.component.html @@ -23,8 +23,8 @@ - - + + Hard Due Date Update Succeeded diff --git a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html index b66343436d..d6c600eb42 100644 --- a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html +++ b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html @@ -17,11 +17,11 @@ (ngModelChange)="record[field.name]($event)"> - - +