From 998ad8026a4fe0b901a8537db3806fad31566ce7 Mon Sep 17 00:00:00 2001 From: Jane Sandberg Date: Mon, 1 Apr 2019 20:58:02 -0700 Subject: [PATCH] LP1816475: more improvements to the Create screen Signed-off-by: Jane Sandberg --- .../daterange-select.component.html | 4 -- .../daterange-select/daterange-select.component.ts | 5 +- .../booking/create-reservation.component.html | 17 ++++- .../staff/booking/create-reservation.component.ts | 77 +++++++++++++++++----- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 6 ++ .../upgrade/XXXX.data.booking-sticky-settings.sql | 6 ++ 6 files changed, 91 insertions(+), 24 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/share/daterange-select/daterange-select.component.html b/Open-ILS/src/eg2/src/app/share/daterange-select/daterange-select.component.html index 8dad08557d..66bddcf612 100644 --- a/Open-ILS/src/eg2/src/app/share/daterange-select/daterange-select.component.html +++ b/Open-ILS/src/eg2/src/app/share/daterange-select/daterange-select.component.html @@ -12,7 +12,3 @@ -
- -
From: {{ fromDate | json }} 
-
To: {{ toDate | json }} 
diff --git a/Open-ILS/src/eg2/src/app/share/daterange-select/daterange-select.component.ts b/Open-ILS/src/eg2/src/app/share/daterange-select/daterange-select.component.ts index 72b297ce09..7441d97401 100644 --- a/Open-ILS/src/eg2/src/app/share/daterange-select/daterange-select.component.ts +++ b/Open-ILS/src/eg2/src/app/share/daterange-select/daterange-select.component.ts @@ -1,4 +1,4 @@ -import {Component} from '@angular/core'; +import {Component, Output, EventEmitter} from '@angular/core'; import {NgbDate, NgbCalendar} from '@ng-bootstrap/ng-bootstrap'; @Component({ @@ -31,6 +31,8 @@ export class DateRangeSelectComponent { fromDate: NgbDate; toDate: NgbDate; + @Output() onChange = new EventEmitter<{start: NgbDate, end: NgbDate}>(); + constructor(calendar: NgbCalendar) { this.fromDate = calendar.getToday(); this.toDate = calendar.getNext(calendar.getToday(), 'd', 10); @@ -45,6 +47,7 @@ export class DateRangeSelectComponent { this.toDate = null; this.fromDate = date; } + this.onChange.emit({start: this.fromDate, end: this.toDate}); } isHovered(date: NgbDate) { 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 6a9777f5b7..4cf6b61483 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 @@ -10,6 +10,21 @@
+ +
+ + +
+
+
+
+ + +
+
+
+
+
@@ -85,7 +100,7 @@ - + void; - @ViewChild('dateLimiter') dateLimiter: DateSelectComponent; + setGranularity: () => void; + handleMultiDayReservation: () => void; + handleSingleDayReservation: () => void; + changeGranularity: ($event: ComboboxEntry) => void; + + @ViewChildren('dateLimiter') dateLimiters: QueryList; + @ViewChildren('dateRangeLimiter') dateRangeLimiters: QueryList; + @ViewChildren('scheduleGrid') scheduleGrids: QueryList; @ViewChild('newDialog') newDialog: FmRecordEditorComponent; - @ViewChild('scheduleGrid') scheduleGrid: GridComponent; constructor( private pcrud: PcrudService, + private store: ServerStoreService, private toast: ToastService, ) { this.resourceAvailabilityIcon = (row: any) => { @@ -56,8 +65,6 @@ export class CreateReservationComponent implements OnInit { ngOnInit() { - this.dateLimiter.initialDate = new Date(); - this.isBooked = (row: any, col: any) => { if ((col.name !== 'time') && (row[col.name])) { @@ -71,12 +78,44 @@ export class CreateReservationComponent implements OnInit { console.log('event: ' + JSON.stringify($event)); }; + this.setGranularity = () => { + if (this.multiday) { // multiday reservations always use day granularity + this.granularity = 1440; + } else { + this.store.getItem('eg.booking.create.granularity').then(granularity => { + if (granularity != null) { this.granularity = granularity; } + }); + } + this.scheduleGrids.forEach((g) => g.reload()); + }; + + this.handleMultiDayReservation = () => { + this.multiday = true; + this.setGranularity(); + }; + + this.handleSingleDayReservation = () => { + this.multiday = false; + this.setGranularity(); + }; + + this.changeGranularity = ($event) => { + this.granularity = $event.id; + this.store.setItem('eg.booking.create.granularity', $event.id); + }; + } + + ngAfterViewInit() { + this.dateLimiters.forEach((dl) => dl.initialDate = new Date()); + this.setGranularity(); + } + showNewDialog(idlThing: IdlObject) { return this.newDialog.open({size: 'lg'}).then( ok => { this.toast.success('Reservation successfully created'); // TODO: needs i18n, pluralization - this.scheduleGrid.reload(); + this.scheduleGrids.forEach((g) => g.reload()); }, err => {} ); @@ -117,16 +156,18 @@ export class CreateReservationComponent implements OnInit { r => { this.resources.push(r); - this.startTime = Moment(new Date( - this.dateLimiter.current.year, - this.dateLimiter.current.month - 1, - this.dateLimiter.current.day, - 13, 0, 0), 'Asia/Tokyo'); - this.endTime = Moment(new Date( - this.dateLimiter.current.year, - this.dateLimiter.current.month - 1, - this.dateLimiter.current.day, - 17, 0, 0), 'Asia/Tokyo'); + this.dateLimiters.forEach((dl) => { + this.startTime = Moment.tz([ + dl.current.year, + dl.current.month - 1, + dl.current.day, 9], + 'Asia/Tokyo'); + this.endTime = Moment.tz([ + dl.current.year, + dl.current.month - 1, + dl.current.day, 17], + 'Asia/Tokyo'); + }); let currentTime = this.startTime; while (currentTime < this.endTime) { const existingRow = this.scheduleSource.data.findIndex((row) => row['time'] === currentTime.format('LT')) ; diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index 8c011ea3ee..fba3f0b0d8 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -19951,6 +19951,12 @@ VALUES ( 'Sticky setting for tab in Booking Return', 'cwst', 'label') ), ( + 'eg.booking.create.granularity', 'gui', 'integer', + oils_i18n_gettext( + 'booking.create.granularity', + 'Sticky setting for granularity combobox in Booking Create', + 'cwst', 'label') +), ( 'eg.booking.pickup.ready.only_show_captured', 'gui', 'bool', oils_i18n_gettext( 'booking.pickup.ready.only_show_captured', diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.booking-sticky-settings.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.booking-sticky-settings.sql index e47486e641..e901ba5526 100644 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.booking-sticky-settings.sql +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.booking-sticky-settings.sql @@ -56,6 +56,12 @@ VALUES ( 'Sticky setting for tab in Booking Return', 'cwst', 'label') ), ( + 'eg.booking.create.granularity', 'gui', 'integer', + oils_i18n_gettext( + 'booking.create.granularity', + 'Sticky setting for granularity combobox in Booking Create', + 'cwst', 'label') +), ( 'eg.booking.pickup.ready.only_show_captured', 'gui', 'bool', oils_i18n_gettext( 'booking.pickup.ready.only_show_captured', -- 2.11.0