LP#1626157 ng-line updates continued
authorBill Erickson <berickxx@gmail.com>
Thu, 24 May 2018 21:54:14 +0000 (17:54 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 24 May 2018 21:54:14 +0000 (17:54 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
19 files changed:
Open-ILS/src/eg2/src/app/share/grid/grid-column-width.component.ts
Open-ILS/src/eg2/src/app/share/grid/grid-column.component.ts
Open-ILS/src/eg2/src/app/share/grid/grid-header.component.ts
Open-ILS/src/eg2/src/app/share/grid/grid-toolbar-action.component.ts
Open-ILS/src/eg2/src/app/share/grid/grid-toolbar-button.component.ts
Open-ILS/src/eg2/src/app/share/grid/grid-toolbar.component.ts
Open-ILS/src/eg2/src/app/share/grid/grid.component.ts
Open-ILS/src/eg2/src/app/share/org-select/org-select.component.ts
Open-ILS/src/eg2/src/app/share/string/string.component.ts
Open-ILS/src/eg2/src/app/share/string/string.service.ts
Open-ILS/src/eg2/src/app/share/toast/toast.component.ts
Open-ILS/src/eg2/src/app/share/toast/toast.service.ts
Open-ILS/src/eg2/src/app/staff/common.module.ts
Open-ILS/src/eg2/src/app/staff/login.component.ts
Open-ILS/src/eg2/src/app/staff/resolver.service.ts
Open-ILS/src/eg2/src/app/staff/share/link-table/link-table.component.ts
Open-ILS/src/eg2/src/app/staff/share/op-change/op-change.component.ts
Open-ILS/src/eg2/src/app/staff/splash.component.ts
Open-ILS/src/eg2/src/app/staff/staff.component.ts

index 36ffa13..2ff482f 100644 (file)
@@ -25,7 +25,7 @@ export class EgGridColumnWidthComponent implements OnInit {
     }
 
     shrinkColumn(col: EgGridColumn) {
-        if (col.flex > 1) col.flex--;
+        if (col.flex > 1) { col.flex--; }
     }
 
 }
index 3c7101b..09f8432 100644 (file)
@@ -33,7 +33,7 @@ export class EgGridColumnComponent implements OnInit {
             return;
         }
 
-        let col = new EgGridColumn();
+        const col = new EgGridColumn();
         col.name = this.name;
         col.path = this.path;
         col.label = this.label;
index 3d5cd8c..7340633 100644 (file)
@@ -17,8 +17,9 @@ export class EgGridHeaderComponent implements OnInit {
     ngOnInit() {}
 
     onColumnDragEnter($event: any, col: any) {
-        if (this.dragColumn && this.dragColumn.name != col.name)
+        if (this.dragColumn && this.dragColumn.name !== col.name) {
             col.isDragTarget = true;
+        }
         $event.preventDefault();
     }
 
@@ -34,9 +35,9 @@ export class EgGridHeaderComponent implements OnInit {
 
     sortOneColumn(col: EgGridColumn) {
         let dir = 'ASC';
-        let sort = this.gridContext.dataSource.sort;
+        const sort = this.gridContext.dataSource.sort;
 
-        if (sort.length && sort[0].name == col.name && sort[0].dir == 'ASC') {
+        if (sort.length && sort[0].name === col.name && sort[0].dir === 'ASC') {
             dir = 'DESC';
         }
 
@@ -47,8 +48,8 @@ export class EgGridHeaderComponent implements OnInit {
     // Returns true if the provided column is sorting in the
     // specified direction.
     isColumnSorting(col: EgGridColumn, dir: string): boolean {
-        let sort = this.gridContext.dataSource.sort.filter(c => c.name == col.name)[0];
-        return sort && sort.dir == dir;
+        const sort = this.gridContext.dataSource.sort.filter(c => c.name === col.name)[0];
+        return sort && sort.dir === dir;
     }
 
     handleBatchSelect($event) {
@@ -64,14 +65,14 @@ export class EgGridHeaderComponent implements OnInit {
     }
 
     selectAll() {
-        let rows = this.gridContext.dataSource.getPageOfRows(this.gridContext.pager);
-        let indexes = rows.map(r => this.gridContext.getRowIndex(r));
+        const rows = this.gridContext.dataSource.getPageOfRows(this.gridContext.pager);
+        const indexes = rows.map(r => this.gridContext.getRowIndex(r));
         this.gridContext.rowSelector.select(indexes);
     }
 
     allRowsAreSelected(): boolean {
-        let rows = this.gridContext.dataSource.getPageOfRows(this.gridContext.pager);
-        let indexes = rows.map(r => this.gridContext.getRowIndex(r));
+        const rows = this.gridContext.dataSource.getPageOfRows(this.gridContext.pager);
+        const indexes = rows.map(r => this.gridContext.getRowIndex(r));
         return this.gridContext.rowSelector.contains(indexes);
     }
 }
index eb8abc2..c9ba496 100644 (file)
@@ -23,7 +23,7 @@ export class EgGridToolbarActionComponent implements OnInit {
             return;
         }
 
-        let action = new EgGridToolbarAction();
+        const action = new EgGridToolbarAction();
         action.label = this.label;
         action.action = this.action;
 
index 1f5f9d1..7c37d45 100644 (file)
@@ -23,7 +23,7 @@ export class EgGridToolbarButtonComponent implements OnInit {
             return;
         }
 
-        let btn = new EgGridToolbarButton();
+        const btn = new EgGridToolbarButton();
         btn.label = this.label;
         btn.action = this.action;
 
index 68cbd3b..690c14c 100644 (file)
@@ -65,8 +65,8 @@ export class EgGridToolbarComponent implements OnInit {
 
         this.gridContext.gridToCsv().then(csv => {
             console.log(csv);
-            var blob = new Blob([csv], {type : 'text/plain'});
-            let win: any = window;
+            const blob = new Blob([csv], {type : 'text/plain'});
+            const win: any = window; // avoid TS errors
             this.csvExportUrl = this.sanitizer.bypassSecurityTrustUrl(
                 (win.URL || win.webkitURL).createObjectURL(blob)
             );
index 26fc21d..29d5863 100644 (file)
@@ -1,6 +1,6 @@
 import {Component, Input, OnInit, AfterViewInit, EventEmitter, OnDestroy,
     HostListener, ViewEncapsulation} from '@angular/core';
-import {Subscription} from "rxjs/Subscription";
+import {Subscription} from 'rxjs/Subscription';
 import {EgIdlService} from '@eg/core/idl.service';
 import {EgOrgService} from '@eg/core/org.service';
 import {EgStoreService} from '@eg/core/store.service';
@@ -45,7 +45,7 @@ export class EgGridComponent implements OnInit, AfterViewInit, OnDestroy {
         this.context.mainLabel = this.mainLabel;
         this.context.idlClass = this.idlClass;
         this.context.dataSource = this.dataSource;
-        this.context.persistKey = this.persistKey
+        this.context.persistKey = this.persistKey;
         this.context.isSortable = this.isSortable === true;
         this.context.isMultiSortable = this.isMultiSortable === true;
         this.context.disableMultiSelect = this.disableMultiSelect === true;
@@ -62,7 +62,7 @@ export class EgGridComponent implements OnInit, AfterViewInit, OnDestroy {
 
     // Not using @HostListener because it only works globally.
     onGridKeyDown(evt: KeyboardEvent) {
-        switch(evt.key) {
+        switch (evt.key) {
             case 'ArrowUp':
                 this.context.selectPreviousRow();
                 evt.stopPropagation();
@@ -98,13 +98,14 @@ export class EgGridComponent implements OnInit, AfterViewInit, OnDestroy {
     }
 
     onRowClick($event: any, row: any, idx: number) {
-        let index = this.context.getRowIndex(row);
+        const index = this.context.getRowIndex(row);
 
         if (this.context.disableMultiSelect) {
             this.context.selectOneRow(index);
         } else if ($event.ctrlKey || $event.metaKey /* mac command */) {
-            if (this.context.toggleSelectOneRow(index))
+            if (this.context.toggleSelectOneRow(index)) {
                 this.context.lastSelectedIndex = index;
+            }
 
         } else if ($event.shiftKey) {
             // TODO shift range click
index 76a8655..8144023 100644 (file)
@@ -10,12 +10,11 @@ import {EgAuthService} from '@eg/core/auth.service';
 import {EgStoreService} from '@eg/core/store.service';
 import {EgOrgService} from '@eg/core/org.service';
 import {EgIdlObject} from '@eg/core/idl.service';
-import {NgbTypeahead, NgbTypeaheadSelectItemEvent}
-    from '@ng-bootstrap/ng-bootstrap';
+import {NgbTypeahead, NgbTypeaheadSelectItemEvent} from '@ng-bootstrap/ng-bootstrap';
 
 // Use a unicode char for spacing instead of ASCII=32 so the browser
 // won't collapse the nested display entries down to a single space.
-const PAD_SPACE: string = ' '; // U+2007
+const PAD_SPACE = ' '; // U+2007
 
 interface OrgDisplay {
   id: number;
@@ -38,49 +37,53 @@ export class EgOrgSelectComponent implements OnInit {
     @ViewChild('instance') instance: NgbTypeahead;
 
     // Placeholder text for selector input
-    @Input() placeholder: string = '';
+    @Input() placeholder = '';
     @Input() stickySetting: string;
 
     // Org unit field displayed in the selector
-    @Input() displayField: string = 'shortname';
+    @Input() displayField = 'shortname';
 
     // Apply a default org unit value when none is set.
     // First tries workstation org unit, then user home org unit.
     // An onChange event WILL be generated when a default is applied.
-    @Input() applyDefault: boolean = false;
+    @Input() applyDefault = false;
 
     // List of org unit IDs to exclude from the selector
     @Input() set hideOrgs(ids: number[]) {
-        if (ids) this.hidden = ids;
+        if (ids) { this.hidden = ids; }
     }
 
     // List of org unit IDs to disable in the selector
     @Input() set disableOrgs(ids: number[]) {
-        if (ids) this.disabled = ids;
+        if (ids) { this.disabled = ids; }
     }
 
     // Apply an org unit value at load time.
     // This will NOT result in an onChange event.
     @Input() set initialOrg(org: EgIdlObject) {
-        if (org) this.startOrg = org;
+        if (org) { this.startOrg = org; }
     }
 
     // Apply an org unit value by ID at load time.
     // This will NOT result in an onChange event.
     @Input() set initialOrgId(id: number) {
-        if (id) this.startOrg = this.org.get(id);
+        if (id) { this.startOrg = this.org.get(id); }
     }
 
     // Modify the selected org unit via data binding.
     // This WILL result in an onChange event firing.
     @Input() set applyOrg(org: EgIdlObject) {
-        if (org) this.selected = this.formatForDisplay(org);
+        if (org) {
+            this.selected = this.formatForDisplay(org);
+        }
     }
 
     // Modify the selected org unit by ID via data binding.
     // This WILL result in an onChange event firing.
     @Input() set applyOrgId(id: number) {
-      if (id) this.selected = this.formatForDisplay(this.org.get(id));
+        if (id) {
+            this.selected = this.formatForDisplay(this.org.get(id));
+        }
     }
 
     // Emitted when the org unit value is changed via the selector.
@@ -145,13 +148,12 @@ export class EgOrgSelectComponent implements OnInit {
 
                     // Find orgs matching the search term
                     return org[this.displayField]()
-                      .toLowerCase().indexOf(term.toLowerCase()) > -1
+                      .toLowerCase().indexOf(term.toLowerCase()) > -1;
 
                 }).filter(org => { // Exclude hidden orgs
-                    return this.hidden.filter(
-                        id => {return org.id() == id}).length == 0;
+                    return this.hidden.filter(id => org.id() === id).length === 0;
 
-                }).map(org => {return this.formatForDisplay(org)})
+                }).map(org => this.formatForDisplay(org));
             })
         );
     }
index ef34f16..b4cfe5a 100644 (file)
@@ -36,7 +36,7 @@ export class EgStringComponent implements OnInit {
         if (this.key) {
             this.strings.register({
                 key: this.key,
-                resolver: (ctx:any) => this.current(ctx)
+                resolver: (ctx: any) => this.current(ctx)
             });
         }
     }
@@ -48,7 +48,7 @@ export class EgStringComponent implements OnInit {
     // hopefully we can retire the EgString* code entirely once
     // in-code translations are supported (Ang6?)
     current(ctx?: any): Promise<string> {
-        if (ctx) this.ctx = ctx;
+        if (ctx) { this.ctx = ctx; }
         return new Promise(resolve => {
             setTimeout(() => resolve(this.elm.nativeElement.textContent));
         });
index 3d9eed5..5c120e8 100644 (file)
@@ -1,14 +1,14 @@
 import {Injectable} from '@angular/core';
 
 interface EgStringAssignment {
-    key: string,     // keyboard command
-    resolver: (ctx:any) => Promise<string>
-};
+    key: string;     // keyboard command
+    resolver: (ctx: any) => Promise<string>;
+}
 
 @Injectable()
 export class EgStringService {
 
-    strings: {[key:string] : EgStringAssignment} = {};
+    strings: {[key: string]: EgStringAssignment} = {};
 
     constructor() {}
 
@@ -17,8 +17,9 @@ export class EgStringService {
     }
 
     interpolate(key: string, ctx?: any): Promise<string> {
-        if (!this.strings[key])
+        if (!this.strings[key]) {
             return Promise.reject('No Such String');
+        }
         return this.strings[key].resolver(ctx);
     }
 
index bb9cab7..8744c0c 100644 (file)
@@ -15,7 +15,7 @@ export class EgToastComponent implements OnInit {
     // track the most recent timeout event
     timeout: any;
 
-       constructor(private toast: EgToastService) {
+    constructor(private toast: EgToastService) {
     }
 
     ngOnInit() {
index 6c2f9e3..92a1725 100644 (file)
@@ -1,9 +1,9 @@
 import {Injectable, EventEmitter} from '@angular/core';
 
 export interface EgToastMessage {
-    text: string,
-    style: string
-};
+    text: string;
+    style: string;
+}
 
 @Injectable()
 export class EgToastService {
index 86c61ae..09c26bc 100644 (file)
@@ -16,8 +16,7 @@ import {EgStringComponent} from '@eg/share/string/string.component';
 import {EgStringService} from '@eg/share/string/string.service';
 import {FmRecordEditorComponent} from '@eg/share/fm-editor/fm-editor.component';
 import {EgDateSelectComponent} from '@eg/share/date-select/date-select.component';
-import {EgLinkTableComponent, EgLinkTableLinkComponent}
-    from '@eg/staff/share/link-table/link-table.component';
+import {EgLinkTableComponent, EgLinkTableLinkComponent} from '@eg/staff/share/link-table/link-table.component';
 
 /**
  * Imports the EG common modules and adds modules common to all staff UI's.
index 86df59f..733ac8f 100644 (file)
@@ -41,14 +41,14 @@ export class EgStaffLoginComponent implements OnInit {
         .then(list => this.workstations = list || [])
         .then(list => this.store.getItem('eg.workstation.default'))
         .then(defWs => this.args.workstation = defWs)
-        .then(noOp => this.applyWorkstation())
+        .then(noOp => this.applyWorkstation());
     }
 
     applyWorkstation() {
-        let wanted = this.route.snapshot.queryParamMap.get('workstation');
-        if (!wanted) return; // use the default
+        const wanted = this.route.snapshot.queryParamMap.get('workstation');
+        if (!wanted) { return; } // use the default
 
-        let exists = this.workstations.filter(w => w.name == wanted)[0];
+        const exists = this.workstations.filter(w => w.name === wanted)[0];
         if (exists) {
             this.args.workstation = wanted;
         } else {
@@ -59,14 +59,14 @@ export class EgStaffLoginComponent implements OnInit {
     handleSubmit() {
 
         // post-login URL
-        let url: string = this.auth.redirectUrl || '/staff/splash';
-        let workstation: string = this.args.workstation;
+        const url: string = this.auth.redirectUrl || '/staff/splash';
+        const workstation: string = this.args.workstation;
 
         this.auth.login(this.args).then(
             ok => {
                 this.auth.redirectUrl = null;
 
-                if (this.auth.workstationState == EgAuthWsState.NOT_FOUND_SERVER) {
+                if (this.auth.workstationState === EgAuthWsState.NOT_FOUND_SERVER) {
                     // User attempted to login with a workstation that is
                     // unknown to the server. Redirect to the WS admin page.
                     this.router.navigate(
index 8598de5..a80a6cc 100644 (file)
@@ -49,10 +49,12 @@ export class EgStaffResolver implements Resolve<Observable<any>> {
         // ^-- = this.ngLocation.prepareExternalUrl('/staff');
 
         // Not sure how to get the path without params... using this for now.
-        let path = state.url.split('?')[0]
-        if (path == '/staff/login') return Observable.of(true);
+        const path = state.url.split('?')[0];
+        if (path === '/staff/login') {
+            return Observable.of(true);
+        }
 
-        let observable: Observable<any>
+        const observable: Observable<any>
             = Observable.create(o => this.observer = o);
 
         this.auth.testAuthToken().then(
@@ -63,7 +65,7 @@ export class EgStaffResolver implements Resolve<Observable<any>> {
                         this.auth.verifyWorkstation().then(
                             wsOk => {
                                 this.loadStartupData()
-                                .then(ok => this.observer.complete())
+                                .then(ok => this.observer.complete());
                             },
                             wsNotOk => this.handleInvalidWorkstation(path)
                         );
index e290786..dfa5cc2 100644 (file)
@@ -1,9 +1,9 @@
 import {Component, Input, OnInit, AfterViewInit, Host} from '@angular/core';
 
 interface LinkTableLink {
-    label: string,
-    url?: string,
-    routerLink?: string
+    label: string;
+    url?: string;
+    routerLink?: string;
 }
 
 @Component({
@@ -26,11 +26,12 @@ export class EgLinkTableComponent implements AfterViewInit {
 
     ngAfterViewInit() {
         // table-ize the links
-        let rowCount = Math.ceil(this.links.length / this.columnCount);
+        const rowCount = Math.ceil(this.links.length / this.columnCount);
         this.colWidth = Math.floor(12 / this.columnCount); // Bootstrap 12-grid
 
-        for (let col = 0; col < this.columnCount; col++)
+        for (let col = 0; col < this.columnCount; col++) {
             this.colList.push(col);
+        }
 
         // Modifying values in AfterViewInit without other activity
         // happening can result in the modified values not getting
index c4fccb7..abb1559 100644 (file)
@@ -14,12 +14,12 @@ export class EgOpChangeComponent
 
     @Input() username: string;
     @Input() password: string;
-    @Input() loginType: string = 'temp';
+    @Input() loginType = 'temp';
 
     @Input() successMessage: string;
     @Input() failMessage: string;
 
-       constructor(
+    constructor(
         private modal: NgbModal, // required for passing to parent
         private renderer: Renderer2,
         private toast: EgToastService,
@@ -36,8 +36,9 @@ export class EgOpChangeComponent
     }
 
     login(): Promise<any> {
-        if (!(this.username && this.password))
+        if (!(this.username && this.password)) {
             return Promise.reject('Missing Params');
+        }
 
         return this.auth.login(
             {   username    : this.username,
@@ -52,7 +53,7 @@ export class EgOpChangeComponent
 
                 // Fetch the user object
                 this.auth.testAuthToken().then(
-                    ok => {
+                    ok2 => {
                         this.close();
                         this.toast.success(this.successMessage);
                     }
index 0fdb4e7..4f9bffc 100644 (file)
@@ -21,7 +21,7 @@ export class EgStaffSplashComponent implements OnInit {
     }
 
     searchCatalog(): void {
-        if (!this.catSearchQuery) return;
+        if (!this.catSearchQuery) { return; }
 
         this.router.navigate(
             ['/staff/catalog/search'],
index da270e5..4b20130 100644 (file)
@@ -3,8 +3,7 @@ import {Router, ActivatedRoute, NavigationEnd} from '@angular/router';
 import {EgAuthService, EgAuthWsState} from '@eg/core/auth.service';
 import {EgNetService} from '@eg/core/net.service';
 import {EgAccessKeyService} from '@eg/share/accesskey/accesskey.service';
-import {EgAccessKeyInfoComponent}
-    from '@eg/share/accesskey/accesskey-info.component';
+import {EgAccessKeyInfoComponent} from '@eg/share/accesskey/accesskey-info.component';
 
 const LOGIN_PATH = '/staff/login';
 const WS_BASE_PATH = '/staff/admin/workstation/workstations/';
@@ -33,7 +32,7 @@ export class EgStaffComponent implements OnInit {
         // Fires on all in-app router navigation, but not initial page load.
         this.router.events.subscribe(routeEvent => {
             if (routeEvent instanceof NavigationEnd) {
-                //console.debug(`EgStaffComponent routing to ${routeEvent.url}`);
+                // console.debug(`EgStaffComponent routing to ${routeEvent.url}`);
                 this.preventForbiddenNavigation(routeEvent.url);
             }
         });
@@ -43,7 +42,9 @@ export class EgStaffComponent implements OnInit {
 
             // If the expired authtoken was identified locally (i.e.
             // in this browser tab) notify all tabs of imminent logout.
-            if (!expireEvent.viaExternal) this.auth.broadcastLogout();
+            if (!expireEvent.viaExternal) {
+                this.auth.broadcastLogout();
+            }
 
             console.debug('Auth session has expired. Redirecting to login');
             this.auth.redirectUrl = this.router.url;
@@ -59,7 +60,7 @@ export class EgStaffComponent implements OnInit {
             });
         });
 
-        this.route.data.subscribe((data: {staffResolver : any}) => {
+        this.route.data.subscribe((data: {staffResolver: any}) => {
             // Data fetched via EgStaffResolver is available here.
         });
 
@@ -81,17 +82,23 @@ export class EgStaffComponent implements OnInit {
     preventForbiddenNavigation(url: string): void {
 
         // No auth checks needed for login page.
-        if (url.startsWith(LOGIN_PATH)) return;
+        if (url.startsWith(LOGIN_PATH)) {
+            return;
+        }
 
         // We lost our authtoken, go back to the login page.
-        if (!this.auth.token())
+        if (!this.auth.token()) {
             this.router.navigate([LOGIN_PATH]);
+        }
 
         // No workstation checks needed for workstation admin page.
-        if (url.startsWith(WS_BASE_PATH)) return;
+        if (url.startsWith(WS_BASE_PATH)) {
+            return;
+        }
 
-        if (this.auth.workstationState != EgAuthWsState.VALID)
+        if (this.auth.workstationState !== EgAuthWsState.VALID) {
             this.router.navigate([WS_MANAGE_PATH]);
+        }
     }
 
     /**