LP#1626157 ng-lint updates
authorBill Erickson <berickxx@gmail.com>
Fri, 18 May 2018 14:35:48 +0000 (10:35 -0400)
committerBill Erickson <berickxx@gmail.com>
Fri, 18 May 2018 14:35:48 +0000 (10:35 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
13 files changed:
Open-ILS/src/eg2/angular.json
Open-ILS/src/eg2/src/app/app.module.ts
Open-ILS/src/eg2/src/app/common.module.ts
Open-ILS/src/eg2/src/app/core/org.service.ts
Open-ILS/src/eg2/src/app/core/perm.service.ts
Open-ILS/src/eg2/src/app/resolver.service.ts
Open-ILS/src/eg2/src/app/routing.module.ts
Open-ILS/src/eg2/src/app/share/print/print.component.ts
Open-ILS/src/eg2/src/app/share/print/print.service.ts
Open-ILS/src/eg2/src/app/share/util/audio.service.ts
Open-ILS/src/eg2/src/app/share/util/format.service.ts
Open-ILS/src/eg2/src/app/welcome.component.ts
Open-ILS/src/eg2/tslint.json

index ad2ee9d..d3cc725 100644 (file)
   "defaultProject": "eg",
   "schematics": {
     "@schematics/angular:component": {
-      "prefix": "app",
+      "prefix": "eg",
       "styleext": "css"
     },
     "@schematics/angular:directive": {
-      "prefix": "app"
+      "prefix": "eg"
     }
   }
-}
\ No newline at end of file
+}
index 8998b01..b452305 100644 (file)
@@ -31,4 +31,4 @@ import {WelcomeComponent} from './welcome.component';
 })
 
 export class EgBaseModule {}
-    
+
index 3844c07..c999a22 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * Modules, services, and components used by all apps.
- */ 
+ */
 import {CommonModule, DatePipe, CurrencyPipe} from '@angular/common';
 import {NgModule, ModuleWithProviders} from '@angular/core';
 import {RouterModule} from '@angular/router';
index 3a16708..958d821 100644 (file)
@@ -24,7 +24,7 @@ export class EgOrgService {
 
     private orgList: EgIdlObject[] = [];
     private orgTree: EgIdlObject; // root node + children
-    private orgMap: {[id:number] : EgIdlObject} = {};
+    private orgMap: {[id: number]: EgIdlObject} = {};
     private settingsCache: OrgSettingsBatch = {};
 
     constructor(
@@ -50,26 +50,26 @@ export class EgOrgService {
      * Unset filter options are ignored.
      */
     filterList(filter: OrgFilter, asId?: boolean): any[] {
-        let list = [];
+        const list = [];
         this.list().forEach(org => {
 
-            let chu = filter.canHaveUsers;
+            const chu = filter.canHaveUsers;
             if (chu && !this.canHaveUsers(org)) { return; }
             if (chu === false && this.canHaveUsers(org)) { return; }
 
-            let chv = filter.canHaveVolumes;
+            const chv = filter.canHaveVolumes;
             if (chv && !this.canHaveVolumes(org)) { return; }
             if (chv === false && this.canHaveVolumes(org)) { return; }
 
-            let ov = filter.opacVisible;
+            const ov = filter.opacVisible;
             if (ov && !this.opacVisible(org)) { return; }
             if (ov === false && this.opacVisible(org)) { return; }
 
-            if (filter.inList && filter.inList.indexOf(org.id()) == -1) {
+            if (filter.inList && !filter.inList.includes(org.id())) {
                 return;
             }
 
-            if (filter.notInList && filter.notInList.indexOf(org.id()) > -1) {
+            if (filter.notInList && filter.notInList.includes(org.id())) {
                 return;
             }
 
@@ -93,8 +93,8 @@ export class EgOrgService {
     ancestors(nodeOrId: EgOrgNodeOrId, asId?: boolean): any[] {
         let node = this.get(nodeOrId);
         if (!node) { return []; }
-        let nodes = [node];
-        while( (node = this.get(node.parent_ou()))) {
+        const nodes = [node];
+        while ( (node = this.get(node.parent_ou())) ) {
             nodes.push(node);
         }
         if (asId) {
@@ -122,13 +122,13 @@ export class EgOrgService {
 
     // list of org_unit objects  or IDs for me + descendants
     descendants(nodeOrId: EgOrgNodeOrId, asId?: boolean): any[] {
-        let node = this.get(nodeOrId);
+        const node = this.get(nodeOrId);
         if (!node) { return []; }
-        let nodes = [];
+        const nodes = [];
         const descend = (n) => {
             nodes.push(n);
             n.children().forEach(descend);
-        }
+        };
         descend(node);
         if (asId) {
             return nodes.map(n => n.id());
@@ -138,7 +138,7 @@ export class EgOrgService {
 
     // list of org_unit objects or IDs for ancestors + me + descendants
     fullPath(nodeOrId: EgOrgNodeOrId, asId?: boolean): any[] {
-        let list = this.ancestors(nodeOrId, false).concat(
+        const list = this.ancestors(nodeOrId, false).concat(
           this.descendants(nodeOrId, false).slice(1));
         if (asId) {
             return list.map(n => n.id());
@@ -151,7 +151,7 @@ export class EgOrgService {
         if (!node) { node = this.orgTree; }
         node.children(
             node.children.sort((a, b) => {
-                return a[sortField]() < b[sortField]() ? -1 : 1
+                return a[sortField]() < b[sortField]() ? -1 : 1;
             })
         );
         node.children.forEach(n => this.sortTree(n));
@@ -188,10 +188,10 @@ export class EgOrgService {
      * Return the list of settings /not/ pulled from cache.
      */
     private settingsFromCache(names: string[], target: any) {
-        let cacheKeys = Object.keys(this.settingsCache);
+        const cacheKeys = Object.keys(this.settingsCache);
 
         cacheKeys.forEach(key => {
-            let matchIdx = names.indexOf(key);
+            const matchIdx = names.indexOf(key);
             if (matchIdx > -1) {
                 target[key] = this.settingsCache[key];
                 names.splice(matchIdx, 1);
@@ -208,7 +208,7 @@ export class EgOrgService {
     private settingsFromNet(orgId: number,
         names: string[], auth?: string): Promise<any> {
 
-        let settings = {};
+        const settings = {};
         return new Promise((resolve, reject) => {
             this.net.request(
                 'open-ils.actor',
@@ -217,7 +217,7 @@ export class EgOrgService {
             ).subscribe(
                 blob => {
                     Object.keys(blob).forEach(key => {
-                        let val = blob[key]; // null or hash
+                        const val = blob[key]; // null or hash
                         settings[key] = val ? val.value : null;
                     });
                     resolve(settings);
@@ -234,13 +234,13 @@ export class EgOrgService {
     settings(names: string[],
         orgId?: number, anonymous?: boolean): Promise<OrgSettingsBatch> {
 
-        let settings = {};
+        const settings = {};
         let auth: string = null;
         let useCache = false;
 
         if (this.auth.user()) {
             if (orgId) {
-                useCache = Number(orgId) == Number(this.auth.user().ws_ou());
+                useCache = Number(orgId) === Number(this.auth.user().ws_ou());
             } else {
                 orgId = this.auth.user().ws_ou();
                 useCache = true;
index 2e535d1..8ecba5a 100644 (file)
@@ -27,9 +27,9 @@ export class EgPermService {
             'open-ils.actor.user.has_work_perm_at.batch',
             this.auth.token(), permNames
         ).toPromise().then(resp => {
-            var answer: HasPermAtResult = {};
+            const answer: HasPermAtResult = {};
             permNames.forEach(perm => {
-                var orgs = [];
+                const orgs = [];
                 resp[perm].forEach(oneOrg => {
                     orgs = orgs.concat(this.org.descendants(oneOrg, asId));
                 });
@@ -42,13 +42,14 @@ export class EgPermService {
 
     // workstation required
     hasWorkPermHere(permNames: string[]): Promise<HasPermHereResult> {
-        let wsId: number = +this.auth.user().wsid(); 
+        const wsId: number = +this.auth.user().wsid();
 
-        if (!wsId) 
+        if (!wsId) {
             return Promise.reject('hasWorkPermHere requires a workstation');
+        }
 
         return this.hasWorkPermAt(permNames, true).then(resp => {
-            let answer: HasPermHereResult = {};
+            const answer: HasPermHereResult = {};
             Object.keys(resp).forEach(perm => {
                 answer[perm] = resp[perm].indexOf(wsId) > -1;
             });
index 0049c40..5fad4e4 100644 (file)
@@ -3,23 +3,23 @@ import {Router, Resolve, RouterStateSnapshot,
         ActivatedRouteSnapshot} from '@angular/router';
 import {EgIdlService} from '@eg/core/idl.service';
 import {EgOrgService} from '@eg/core/org.service';
+
 @Injectable()
 export class EgBaseResolver implements Resolve<Promise<void>> {
 
     constructor(
-        private router: Router, 
+        private router: Router,
         private idl: EgIdlService,
         private org: EgOrgService,
     ) {}
 
     /**
      * Loads pre-auth data common to all applications.
-     * No auth token is available at this level.  When needed, auth is 
+     * No auth token is available at this level.  When needed, auth is
      * enforced by application/group-specific resolvers at lower levels.
      */
     resolve(
-        route: ActivatedRouteSnapshot, 
+        route: ActivatedRouteSnapshot,
         state: RouterStateSnapshot): Promise<void> {
 
         console.debug('EgBaseResolver:resolve()');
index 5945213..c60df91 100644 (file)
@@ -1,7 +1,7 @@
-import {NgModule}             from '@angular/core';
+import {NgModule} from '@angular/core';
 import {RouterModule, Routes} from '@angular/router';
-import {EgBaseResolver}       from './resolver.service';
-import {WelcomeComponent}     from './welcome.component';
+import {EgBaseResolver} from './resolver.service';
+import {WelcomeComponent} from './welcome.component';
 
 /**
  * Avoid loading all application JS up front by lazy-loading sub-modules.
@@ -14,7 +14,7 @@ const routes: Routes = [
   { path: '',
     component: WelcomeComponent
   }, {
-    path: 'staff', 
+    path: 'staff',
     resolve : {startup : EgBaseResolver},
     loadChildren: './staff/staff.module#EgStaffModule'
   }
index 1144f3d..ff36bd9 100644 (file)
@@ -15,7 +15,7 @@ export class EgPrintComponent implements OnInit {
         private elm: ElementRef,
         private printer: EgPrintService
     ) {}
-    
+
     ngOnInit() {
         this.printer.onPrintRequest$.subscribe(
             printReq => this.handlePrintRequest(printReq));
@@ -36,7 +36,7 @@ export class EgPrintComponent implements OnInit {
         } else {
         */
             window.print();
-        //}
+        // }
     }
 
     /*
index a983c72..3b18692 100644 (file)
@@ -1,9 +1,9 @@
 import {Injectable, EventEmitter, TemplateRef} from '@angular/core';
 
 export interface EgPrintRequest {
-    template: TemplateRef<any>,
-    contextData: any,
-    printContext: string
+    template: TemplateRef<any>;
+    contextData: any;
+    printContext: string;
 }
 
 @Injectable()
index 971fe7e..85dae69 100644 (file)
@@ -1,6 +1,6 @@
 /**
- * Plays audio files (alerts, generally) by key name.  Each sound uses a 
- * dot-path to indicate  the sound.  
+ * Plays audio files (alerts, generally) by key name.  Each sound uses a
+ * dot-path to indicate  the sound.
  *
  * For example:
  *
@@ -13,7 +13,7 @@
  * /audio/notifications/warning/checkout.wav
  * /audio/notifications/warning.wav
  *
- * Files are only played when sounds are configured to play via 
+ * Files are only played when sounds are configured to play via
  * workstation settings.
  */
 import {Injectable, EventEmitter} from '@angular/core';
@@ -24,7 +24,7 @@ const AUDIO_BASE_URL = '/audio/notifications/';
 export class EgAudioService {
 
     // map of requested audio path to resolved path
-    private urlCache: {[path:string] : string} = {};
+    private urlCache: {[path: string]: string} = {};
 
     constructor(private store: EgStoreService) {}
 
@@ -35,15 +35,15 @@ export class EgAudioService {
     }
 
     playUrl(path: string, origPath: string): void {
-        //console.debug(`audio: playUrl(${path}, ${origPath})`);
+        // console.debug(`audio: playUrl(${path}, ${origPath})`);
 
         this.store.getItem('eg.audio.disable').then(audioDisabled => {
-            if (audioDisabled) return;
-        
-            let url = this.urlCache[path] || 
+            if (audioDisabled) { return; }
+
+            const url = this.urlCache[path] ||
                 AUDIO_BASE_URL + path.replace(/\./g, '/') + '.wav';
 
-            let player = new Audio(url);
+            const player = new Audio(url);
 
             player.onloadeddata = () => {
                 this.urlCache[origPath] = url;
@@ -58,19 +58,19 @@ export class EgAudioService {
 
             player.onerror = () => {
                 // Unable to play path at the requested URL.
-        
+
                 if (!path.match(/\./)) {
                     // all fall-through options have been exhausted.
                     // No path to play.
                     console.warn(
-                        "No suitable URL found for path '" + origPath + "'");
+                        `No suitable URL found for path "${origPath}"`);
                     return;
                 }
 
                 // Fall through to the next (more generic) option
                 path = path.replace(/\.[^\.]+$/, '');
                 this.playUrl(path, origPath);
-            }
+            };
         });
     }
 }
index f1c2b0a..b3d9215 100644 (file)
@@ -17,8 +17,8 @@ export interface EgFormatParams {
 @Injectable()
 export class EgFormatService {
 
-    dateFormat: string = 'shortDate';
-    dateTimeFormat: string = 'short';
+    dateFormat = 'shortDate';
+    dateTimeFormat = 'short';
     wsOrgTimezone: string = OpenSRF.tz;
 
     constructor(
@@ -32,12 +32,14 @@ export class EgFormatService {
      * Create a human-friendly display version of any field type.
      */
     transform(params: EgFormatParams): string {
-        let value = params.value;
+        const value = params.value;
 
-        if (   value === undefined 
-            || value === null 
-            || value === '' 
-            || Number.isNaN(value)) return '';
+        if (   value === undefined
+            || value === null
+            || value === ''
+            || Number.isNaN(value)) {
+            return '';
+        }
 
         let datatype = params.datatype;
 
@@ -51,16 +53,16 @@ export class EgFormatService {
             }
         }
 
-        switch(datatype) {
+        switch (datatype) {
 
             case 'org_unit':
-                let orgField = params.orgField || 'shortname';
-                let org = this.org.get(value);
+                const orgField = params.orgField || 'shortname';
+                const org = this.org.get(value);
                 return org ? org[orgField]() : '';
 
             case 'timestamp':
-                let date = new Date(value);
-                let fmt = this.dateFormat || 'shortDate';
+                const date = new Date(value);
+                const fmt = this.dateFormat || 'shortDate';
                 if (params.datePlusTime) {
                     fmt = this.dateTimeFormat || 'short';
                 }
index 398d127..a588661 100644 (file)
@@ -5,7 +5,6 @@ import { Component, OnInit } from '@angular/core';
 })
 
 export class WelcomeComponent implements OnInit {
-    
     ngOnInit() {
     }
 }
index 450a2a7..127e171 100644 (file)
     "directive-selector": [
       true,
       "attribute",
-      "app",
+      "eg",
       "camelCase"
     ],
     "component-selector": [
       true,
       "element",
-      "app",
+      "eg",
       "kebab-case"
     ],
     "use-input-property-decorator": true,