LP1816475: Various cleanup
authorJane Sandberg <sandbej@linnbenton.edu>
Mon, 8 Apr 2019 06:41:41 +0000 (23:41 -0700)
committerJane Sandberg <sandbej@linnbenton.edu>
Wed, 17 Apr 2019 20:41:53 +0000 (13:41 -0700)
Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu>
Open-ILS/src/eg2/src/app/staff/booking/create-reservation.component.ts
Open-ILS/src/eg2/src/app/staff/booking/manage-reservations.component.ts
Open-ILS/src/eg2/src/app/staff/booking/pickup.component.ts
Open-ILS/src/eg2/src/app/staff/booking/pull-list.component.ts
Open-ILS/src/eg2/src/app/staff/booking/reservations-grid.component.ts
Open-ILS/src/eg2/src/app/staff/booking/resource-type-combobox.component.ts
Open-ILS/src/eg2/src/app/staff/booking/return.component.ts

index 2bd472d..bbaee00 100644 (file)
@@ -113,8 +113,7 @@ export class CreateReservationComponent implements OnInit, AfterViewInit {
         };
 
         this.store.getItem('eg.booking.create.multiday').then(multiday => {
-            if (multiday) { this.multiday = multiday; }
-        }
+            if (multiday) { this.multiday = multiday; }});
 
         this.route.paramMap.subscribe((params: ParamMap) => {
             this.patronId = +params.get('patron_id');
@@ -206,11 +205,11 @@ export class CreateReservationComponent implements OnInit, AfterViewInit {
             this.fetchData();
         };
 
-       this.handlePickupLibChange = ($event) => {
+        this.handlePickupLibChange = ($event) => {
             this.newDialog.record.pickup_lib($event);
             this.org.settings('lib.timezone', $event.id()).then((tz) => {
                 if (tz['lib.timezone'] && (this.format.wsOrgTimezone !== tz['lib.timezone'])) {
-                    this.pickupLibUsesDifferentTz = tz['lib.timezone']
+                    this.pickupLibUsesDifferentTz = tz['lib.timezone'];
                 } else {
                     this.pickupLibUsesDifferentTz = null;
                 }
@@ -222,13 +221,14 @@ export class CreateReservationComponent implements OnInit, AfterViewInit {
                 this.newDialog.record.current_resource($event);
                 this.newDialog.record.target_resource($event);
             }
-        }
+        };
 
         this.useCurrentResourceBarcode = () => {
             if (this.resourceBarcode) {
                 this.router.navigate(['/staff', 'booking', 'create_reservation', 'for_resource', this.resourceBarcode]);
             }
         };
+
         this.findPatronByBarcode = () => {
             if (this.patronBarcode) {
                 this.patron.bcSearch(this.patronBarcode).pipe(single()).subscribe(
@@ -237,9 +237,10 @@ export class CreateReservationComponent implements OnInit, AfterViewInit {
                 );
             }
         };
+
         this.minuteStep = () => {
             return (this.granularity < 60) ? this.granularity : 15;
-        }
+        };
 
     }
 
@@ -248,7 +249,7 @@ export class CreateReservationComponent implements OnInit, AfterViewInit {
         this.setGranularity();
         this.fetchData();
 
-       this.openTheDialog = (rows: IdlObject[]) => {
+        this.openTheDialog = (rows: IdlObject[]) => {
             return this.newDialog.open({size: 'lg'}).then(
                 response => {
                     this.toast.success('Reservation successfully created'); // TODO: needs i18n, pluralization
@@ -257,9 +258,9 @@ export class CreateReservationComponent implements OnInit, AfterViewInit {
                 },
                 err => {}
             );
-        }
+        };
 
-       this.openCreateDialog = (rows: IdlObject[]) => {
+        this.openCreateDialog = (rows: IdlObject[]) => {
             if (rows.length) {
                 if (this.multiday) {
                     this.defaultTimes['start_time'] = this.format.momentizeDateString(rows[0]['time'], this.format.wsOrgTimezone);
@@ -268,7 +269,8 @@ export class CreateReservationComponent implements OnInit, AfterViewInit {
                         .add(this.granularity, 'minutes');
                 } else {
                     this.defaultTimes['start_time'] = Moment.tz(rows[0]['time'], 'LT', this.format.wsOrgTimezone);
-                    this.defaultTimes['end_time'] = Moment.tz(rows[rows.length - 1]['time'], 'LT', this.format.wsOrgTimezone).add(this.granularity, 'minutes');
+                    this.defaultTimes['end_time'] =
+                        Moment.tz(rows[rows.length - 1]['time'], 'LT', this.format.wsOrgTimezone).add(this.granularity, 'minutes');
                 }
             } else {
                 if (this.multiday) { this.defaultTimes['end_time'] = this.defaultTimes['start_time'].clone().add(1, 'days'); }
@@ -290,7 +292,7 @@ export class CreateReservationComponent implements OnInit, AfterViewInit {
                     this.transferable = t.transferable();
                     this.openTheDialog(rows).then(newId => {
                         if (this.selectedAttributes.length) {
-                            let creates$ = [];
+                            const creates$ = [];
                             this.selectedAttributes.forEach(attrValue => {
                                 if (attrValue) {
                                     const bravm = this.idl.create('bravm');
@@ -305,9 +307,9 @@ export class CreateReservationComponent implements OnInit, AfterViewInit {
                             this.net.request('open-ils.storage', 'open-ils.storage.booking.reservation.resource_targeter', [newId]);
                         }
                     });
-                })
+                });
             }
-        }
+        };
     }
     handleResourceTypeChange($event: ComboboxEntry) {
         this.resourceBarcode = null;
@@ -335,7 +337,7 @@ export class CreateReservationComponent implements OnInit, AfterViewInit {
         let select = {};
         let where = {};
 
-       if (this.resourceId) {
+        if (this.resourceId) {
             where = {id: this.resourceId};
         } else if (this.resourceTypeId) {
             where = {type: this.resourceTypeId};
@@ -344,16 +346,20 @@ export class CreateReservationComponent implements OnInit, AfterViewInit {
         }
 
         if (this.multiday) {
-            this.dateRangeLimiters.forEach((drl) => {
-                select = {'curr_rsrcs': {'end_time': {'>' : Moment.tz([drl.fromDate.year, drl.fromDate.month - 1, drl.fromDate.day], this.format.wsOrgTimezone).startOf('day').toISOString()},
-                    'start_time': { '<': Moment.tz([drl.toDate.year, drl.toDate.month - 1, drl.toDate.day], this.format.wsOrgTimezone).endOf('day').toISOString() }}}
+            this.dateRangeLimiters.forEach((drl) => { select = {
+                'curr_rsrcs': {'end_time': {'>' : Moment.tz([drl.fromDate.year, drl.fromDate.month - 1, drl.fromDate.day],
+                    this.format.wsOrgTimezone).startOf('day').toISOString()},
+                'start_time': { '<': Moment.tz([drl.toDate.year, drl.toDate.month - 1, drl.toDate.day],
+                    this.format.wsOrgTimezone).endOf('day').toISOString() }}};
             });
-        } else {
-            select = {'curr_rsrcs': {'end_time': {'>' : Moment.tz([this.idealDate.getFullYear(), this.idealDate.getMonth(), this.idealDate.getDate()], this.format.wsOrgTimezone).startOf('day').toISOString()},
-                'start_time': { '<': Moment.tz([this.idealDate.getFullYear(), this.idealDate.getMonth(), this.idealDate.getDate()], this.format.wsOrgTimezone).add(1, 'days').endOf('day').toISOString() }}}
+        } else { select = { 'curr_rsrcs': {
+            'end_time': {'>' : Moment.tz([this.idealDate.getFullYear(), this.idealDate.getMonth(), this.idealDate.getDate()],
+                this.format.wsOrgTimezone).startOf('day').toISOString()},
+            'start_time': { '<': Moment.tz([this.idealDate.getFullYear(), this.idealDate.getMonth(), this.idealDate.getDate()],
+                this.format.wsOrgTimezone).add(1, 'days').endOf('day').toISOString() }}};
         }
         if (this.selectedAttributes.length) {
-            where['id'] = {"in": {"from": "bram", "select": {"bram": ["resource"]}, "where": {"value":  this.selectedAttributes.filter((a) => (a !== null))}}};
+            where['id'] = {'in': {'from': 'bram', 'select': {'bram': ['resource']}, 'where': {'value':  this.selectedAttributes.filter((a) => (a !== null))}}};
         }
         this.scheduleSource.data = [];
         this.pcrud.search('brsrc', where, {
@@ -369,8 +375,10 @@ export class CreateReservationComponent implements OnInit, AfterViewInit {
                 let endTime = Moment();
                 if (this.multiday) {
                    this.dateRangeLimiters.forEach((drl) => {
-                       startTime = Moment.tz([drl.fromDate.year, drl.fromDate.month - 1, drl.fromDate.day], this.format.wsOrgTimezone).startOf('day');
-                       endTime = Moment.tz([drl.toDate.year, drl.toDate.month - 1, drl.toDate.day], this.format.wsOrgTimezone).endOf('day');
+                       startTime = Moment.tz([drl.fromDate.year, drl.fromDate.month - 1, drl.fromDate.day],
+                           this.format.wsOrgTimezone).startOf('day');
+                       endTime = Moment.tz([drl.toDate.year, drl.toDate.month - 1, drl.toDate.day],
+                           this.format.wsOrgTimezone).endOf('day');
                    });
                 } else {
                     this.dateLimiters.forEach((dl) => {
@@ -390,22 +398,27 @@ export class CreateReservationComponent implements OnInit, AfterViewInit {
                             this.format.wsOrgTimezone);
                     });
                 }
-                let currentTime = startTime;
+                const currentTime = startTime;
                 while (currentTime < endTime) {
                     let idx: number;
                     let existingRow: number;
                     if (this.multiday) {
-                        existingRow = this.scheduleSource.data.findIndex((row) => row['time'] === this.format.transform({value: currentTime, datatype: 'timestamp'}));
-                        idx = (existingRow > -1) ? existingRow : (this.scheduleSource.data.push({'time': this.format.transform({value: currentTime, datatype: 'timestamp'})}) - 1);
+                        existingRow = this.scheduleSource.data.findIndex(
+                            (row) => row['time'] === this.format.transform({value: currentTime, datatype: 'timestamp'}));
+                        idx = (existingRow > -1) ? existingRow :
+                            (this.scheduleSource.data.push(
+                                {'time': this.format.transform({value: currentTime, datatype: 'timestamp'})}) - 1);
                     } else {
                         existingRow = this.scheduleSource.data.findIndex((row) => row['time'] === currentTime.format('LT')) ;
                         idx = (existingRow > -1) ? existingRow : (this.scheduleSource.data.push({'time': currentTime.format('LT')}) - 1);
                     }
                     r.curr_rsrcs().forEach((reservation) => {
-                        if ((Moment(reservation.start_time(), this.format.wsOrgTimezone) < (currentTime.clone().add(this.granularity, 'minutes'))) &&
+                        if ((Moment(reservation.start_time(), this.format.wsOrgTimezone) <
+                            (currentTime.clone().add(this.granularity, 'minutes'))) &&
                             (Moment(reservation.end_time(), this.format.wsOrgTimezone) > currentTime)) {
                             if (!this.scheduleSource.data[idx][r.barcode()]) { this.scheduleSource.data[idx][r.barcode()] = []; }
-                            this.scheduleSource.data[idx][r.barcode()].push({'patronLabel': reservation.usr().usrname(), 'patronId': reservation.usr().id()});
+                            this.scheduleSource.data[idx][r.barcode()].push(
+                                {'patronLabel': reservation.usr().usrname(), 'patronId': reservation.usr().id()});
                         }
                     });
                     currentTime.add(this.granularity, 'minutes');
index fa2d2bd..da39573 100644 (file)
@@ -1,7 +1,7 @@
 import {Component, OnInit, ViewChild} from '@angular/core';
 import {Router, ActivatedRoute, ParamMap} from '@angular/router';
 import {single} from 'rxjs/operators';
-import { NgbTabChangeEvent } from '@ng-bootstrap/ng-bootstrap';
+import {NgbTabChangeEvent} from '@ng-bootstrap/ng-bootstrap';
 import {ComboboxEntry} from '@eg/share/combobox/combobox.component';
 import {GridComponent} from '@eg/share/grid/grid.component';
 import {PatronService} from '@eg/staff/share/patron.service';
index 610b2b7..1ec9da7 100644 (file)
@@ -1,12 +1,11 @@
-import { Component, Input, OnInit, ViewChild } from '@angular/core';
-import { Pager } from '@eg/share/util/pager';
+import {Component, Input, OnInit, ViewChild} from '@angular/core';
+import {single, tap} from 'rxjs/operators';
+import {Pager} from '@eg/share/util/pager';
 import {PatronService} from '@eg/staff/share/patron.service';
 import {PcrudService} from '@eg/core/pcrud.service';
 import {AuthService} from '@eg/core/auth.service';
 import {IdlObject} from '@eg/core/idl.service';
 import {NetService} from '@eg/core/net.service';
-import {Observable} from 'rxjs';
-import {single, tap} from 'rxjs/operators';
 import {ReservationsGridComponent} from './reservations-grid.component';
 import {Router, ActivatedRoute, ParamMap} from '@angular/router';
 import {ServerStoreService} from '@eg/core/server-store.service';
index c242a51..4e454bd 100644 (file)
@@ -1,11 +1,10 @@
-import { Component, Input, OnInit } from '@angular/core';
-import { Observable } from 'rxjs'
-import { AuthService } from '@eg/core/auth.service';
-import { GridColumn, GridDataSource } from '@eg/share/grid/grid';
+import {Component, Input, OnInit} from '@angular/core';
+import {AuthService} from '@eg/core/auth.service';
+import {GridColumn, GridDataSource} from '@eg/share/grid/grid';
 import {IdlObject} from '@eg/core/idl.service';
-import { NetRequest, NetService } from '@eg/core/net.service';
+import {NetRequest, NetService} from '@eg/core/net.service';
 import {OrgService} from '@eg/core/org.service';
-import { Pager } from '@eg/share/util/pager';
+import {Pager} from '@eg/share/util/pager';
 import {PcrudService} from '@eg/core/pcrud.service';
 
 
@@ -29,7 +28,7 @@ export class PullListComponent implements OnInit {
 
 
     ngOnInit() {
-        this.disableOrgs = () => { return this.org.filterList( { canHaveVolumes : false }, true); };
+        this.disableOrgs = () => this.org.filterList( { canHaveVolumes : false }, true);
 
         this.fill_grid = (orgId = this.auth.user().ws_ou()) => {
             this.net.request(
index 5e6b4b2..26af5c3 100644 (file)
@@ -96,7 +96,7 @@ export class ReservationsGridComponent implements OnInit {
 
         this.gridSource.getRows = (pager: Pager, sort: any[]) => {
             const orderBy: any = {};
-            let where = {
+            const where = {
                 'usr' : (this.patron ? this.patron : {'>' : 0}),
                 'target_resource_type' : (this.resourceType ? this.resourceType : {'>' : 0}),
                 'cancel_time' : null,
@@ -174,8 +174,10 @@ export class ReservationsGridComponent implements OnInit {
 
         this.noSelectedRows = (rows: IdlObject[]) => (rows.length === 0);
         this.notOnePatronSelected = (rows: IdlObject[]) => (new Set(rows.map(row => row.usr().id())).size !== 1);
-        this.notOneResourceSelected = (rows: IdlObject[]) => (new Set(rows.map(row => {if (row.current_resource()) {return row.current_resource().id();}})).size !== 1);
-        this.cancelNotAppropriate = (rows: IdlObject[]) => (this.noSelectedRows(rows) || ['pickedUp', 'returnReady', 'returnedToday'].includes(this.status));
+        this.notOneResourceSelected = (rows: IdlObject[]) =>
+            (new Set(rows.map(row => { if (row.current_resource()) { return row.current_resource().id(); }})).size !== 1);
+        this.cancelNotAppropriate = (rows: IdlObject[]) =>
+            (this.noSelectedRows(rows) || ['pickedUp', 'returnReady', 'returnedToday'].includes(this.status));
         this.pickupNotAppropriate = (rows: IdlObject[]) => (this.noSelectedRows(rows) || ('pickupReady' !== this.status));
         this.editNotAppropriate = (rows: IdlObject[]) => (this.noSelectedRows(rows) || ('returnedToday' === this.status));
         this.returnNotAppropriate = (rows: IdlObject[]) => {
index b2080ea..54d87ad 100644 (file)
@@ -35,7 +35,7 @@ export class ResourceTypeComboboxComponent implements OnInit {
             if (!this.resourceTypes) { this.resourceTypes = []; }
             this.resourceTypes.push({id: type.id(), label: type.name()});
         }, (err) => {},
-            () => {this.resourceTypes.sort((a, b) => a.label.localeCompare(b.label));});
+            () => {this.resourceTypes.sort((a, b) => a.label.localeCompare(b.label)); });
         this.clear = () => {
             this.resourceTypeCombobox.selected = {id: '', label: ''};
         };
index 51054e2..9fb508e 100644 (file)
@@ -1,10 +1,9 @@
-import { Component, Input, OnInit, QueryList, ViewChildren } from '@angular/core';
+import {Component, Input, OnInit, QueryList, ViewChildren} from '@angular/core';
 import {Router, ActivatedRoute, ParamMap} from '@angular/router';
-import { NgbTabChangeEvent } from '@ng-bootstrap/ng-bootstrap';
-import {Observable} from 'rxjs';
+import {NgbTabChangeEvent} from '@ng-bootstrap/ng-bootstrap';
 import {single} from 'rxjs/operators';
-import { GridDataSource } from '@eg/share/grid/grid';
-import { Pager } from '@eg/share/util/pager';
+import {GridDataSource} from '@eg/share/grid/grid';
+import {Pager} from '@eg/share/util/pager';
 import {PatronService} from '@eg/staff/share/patron.service';
 import {PcrudService} from '@eg/core/pcrud.service';
 import {AuthService} from '@eg/core/auth.service';