From 2655cae64f9fa26ff32540b6f37ee4e565c45669 Mon Sep 17 00:00:00 2001 From: Jane Sandberg Date: Sun, 7 Apr 2019 13:46:46 -0700 Subject: [PATCH] LP1816475: fixing lifecycle issue Signed-off-by: Jane Sandberg --- .../staff/booking/create-reservation.component.ts | 42 ++++++++++++---------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/booking/create-reservation.component.ts b/Open-ILS/src/eg2/src/app/staff/booking/create-reservation.component.ts index 75a66a60d7..dc3d7d5a9c 100644 --- a/Open-ILS/src/eg2/src/app/staff/booking/create-reservation.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/booking/create-reservation.component.ts @@ -53,6 +53,8 @@ export class CreateReservationComponent implements OnInit, AfterViewInit { minuteStep: () => number; + openCreateDialog: (rows: IdlObject[]) => void; + resources: IdlObject[] = []; limitByAttr: (attributeId: number, $event: ComboboxEntry) => void; useCurrentResourceBarcode: () => void; @@ -232,26 +234,30 @@ export class CreateReservationComponent implements OnInit, AfterViewInit { this.dateLimiters.forEach((dl) => dl.initialDate = new Date()); this.setGranularity(); this.fetchData(); - } - openCreateDialog(rows: IdlObject[]) { - if (this.multiday) { - this.defaultTimes['start_time'] = this.format.momentizeDateString(rows[0]['time'], this.format.wsOrgTimezone); - this.defaultTimes['end_time'] = this.format.momentizeDateString( - rows[rows.length - 1]['time'], this.format.wsOrgTimezone).clone() - .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.openCreateDialog = (rows: IdlObject[]) => { + if (rows.length) { + if (this.multiday) { + this.defaultTimes['start_time'] = this.format.momentizeDateString(rows[0]['time'], this.format.wsOrgTimezone); + this.defaultTimes['end_time'] = this.format.momentizeDateString( + rows[rows.length - 1]['time'], this.format.wsOrgTimezone).clone() + .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'); + } + } else { + if (this.multiday) { this.defaultTimes['end_time'] = this.defaultTimes['start_time'].clone().add(1, 'days'); } + } + return this.newDialog.open({size: 'lg'}).then( + response => { + console.log(response); + this.toast.success('Reservation successfully created'); // TODO: needs i18n, pluralization + this.fetchData(); + }, + err => {} + ); } - return this.newDialog.open({size: 'lg'}).then( - response => { - console.log(response); - this.toast.success('Reservation successfully created'); // TODO: needs i18n, pluralization - this.fetchData(); - }, - err => {} - ); } handleResourceTypeChange($event: ComboboxEntry) { this.resourceBarcode = null; -- 2.11.0