From 829de97b5acddacb70ef0193bd0bd31ca722d1bc Mon Sep 17 00:00:00 2001 From: Jane Sandberg Date: Sun, 7 Apr 2019 10:10:19 -0700 Subject: [PATCH] LP1816475: adding default values to end/start times Signed-off-by: Jane Sandberg --- .../datetime-select/datetime-select.component.ts | 4 ++- .../booking/create-reservation.component.html | 17 +++++++++--- .../staff/booking/create-reservation.component.ts | 31 +++++++++++++++++----- .../src/app/staff/booking/pull-list.component.ts | 4 +-- 4 files changed, 44 insertions(+), 12 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/share/datetime-select/datetime-select.component.ts b/Open-ILS/src/eg2/src/app/share/datetime-select/datetime-select.component.ts index 28205a87cf..33da14e2a7 100644 --- a/Open-ILS/src/eg2/src/app/share/datetime-select/datetime-select.component.ts +++ b/Open-ILS/src/eg2/src/app/share/datetime-select/datetime-select.component.ts @@ -21,6 +21,7 @@ export class DateTimeSelectComponent implements OnInit { @Input() validatorError = ''; @Input() initialIso: string; + @Input() initialMoment: Moment; @Output() onChangeAsIso = new EventEmitter(); @Output() onChangeAsMoment = new EventEmitter(); @@ -35,7 +36,8 @@ export class DateTimeSelectComponent implements OnInit { } ngOnInit() { - const start = this.initialIso ? Moment.tz(this.initialIso, Moment.ISO_8601, this.timezone) : Moment.tz([], this.timezone); + let start = this.initialIso ? Moment.tz(this.initialIso, Moment.ISO_8601, this.timezone) : Moment.tz([], this.timezone); + if (this.initialMoment) { start = this.initialMoment; } this.stringVersion = this.format.transform({value: start, datatype: 'timestamp', datePlusTime: true}); this.setDatePicker(start); this.setTimePicker(start); diff --git a/Open-ILS/src/eg2/src/app/staff/booking/create-reservation.component.html b/Open-ILS/src/eg2/src/app/staff/booking/create-reservation.component.html index f1c2aac735..3cf0f3f2db 100644 --- a/Open-ILS/src/eg2/src/app/staff/booking/create-reservation.component.html +++ b/Open-ILS/src/eg2/src/app/staff/booking/create-reservation.component.html @@ -133,13 +133,14 @@ + @@ -147,7 +148,7 @@ @@ -160,7 +161,7 @@ - + @@ -172,4 +173,14 @@ + + + + + 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 e96781ab70..91a3ea64b6 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 @@ -44,8 +44,12 @@ export class CreateReservationComponent implements OnInit, AfterViewInit { endOfDay: NgbTimeStruct = {hour: 17, minute: 0, second: 0}; granularity: 15 | 30 | 60 | 1440 = 30; // 1440 minutes = 24 hours + defaultTimes: {start_time: Moment, end_time: Moment}; + scheduleSource: GridDataSource = new GridDataSource(); + minuteStep: () => number; + resources: IdlObject[] = []; limitByAttr: (attributeId: number, $event: ComboboxEntry) => void; useCurrentResourceBarcode: () => void; @@ -90,6 +94,10 @@ export class CreateReservationComponent implements OnInit, AfterViewInit { ngOnInit() { + this.defaultTimes = { + 'start_time': Moment.tz([], this.format.wsOrgTimezone), + 'end_time': Moment.tz([], this.format.wsOrgTimezone).add(this.granularity, 'minutes') + }; this.route.paramMap.subscribe((params: ParamMap) => { this.patronId = +params.get('patron_id'); this.resourceBarcode = params.get('resource_barcode'); @@ -107,14 +115,14 @@ export class CreateReservationComponent implements OnInit, AfterViewInit { .pipe(single()) .subscribe((item) => { this.net.request( 'open-ils.booking', - 'open-ils.booking.resources.create_from_copies', + 'open-ils.booking.resources.create_from_copies', this.auth.token(), [item.id()]) - .subscribe((response) => { + .subscribe((response) => { this.toast.info('Made this barcode bookable'); this.resourceId = response['brsrc'][0][0]; }, (error) => { this.toast.danger('Cannot make this barcode bookable'); - }) + }); }, (acperror) => { this.toast.danger('No resource found with this barcode'); this.resourceId = -1; @@ -140,7 +148,7 @@ export class CreateReservationComponent implements OnInit, AfterViewInit { this.granularity = 1440; } else { this.store.getItem('eg.booking.create.granularity').then(granularity => { - if (granularity) { + if (granularity) { this.granularity = granularity; } else { this.granularity = 30; @@ -198,7 +206,9 @@ export class CreateReservationComponent implements OnInit, AfterViewInit { ); } }; - + this.minuteStep = () => { + return (this.granularity < 60) ? this.granularity : 15; + } } @@ -208,7 +218,16 @@ export class CreateReservationComponent implements OnInit, AfterViewInit { this.fetchData(); } - showNewDialog(idlThing: IdlObject) { + 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'); + } return this.newDialog.open({size: 'lg'}).then( response => { console.log(response); diff --git a/Open-ILS/src/eg2/src/app/staff/booking/pull-list.component.ts b/Open-ILS/src/eg2/src/app/staff/booking/pull-list.component.ts index e8d63e8c4c..c242a51d3b 100644 --- a/Open-ILS/src/eg2/src/app/staff/booking/pull-list.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/booking/pull-list.component.ts @@ -29,7 +29,7 @@ export class PullListComponent implements OnInit { ngOnInit() { - this.disableOrgs = () => {return this.org.filterList({canHaveVolumes : false}, true);} + this.disableOrgs = () => { return this.org.filterList( { canHaveVolumes : false }, true); }; this.fill_grid = (orgId = this.auth.user().ws_ou()) => { this.net.request( @@ -55,7 +55,7 @@ export class PullListComponent implements OnInit { }); this.dataSource.data = data; }); - } + }; this.dataSource = new GridDataSource(); this.fill_grid(this.auth.user().ws_ou()); } -- 2.11.0