From: Jane Sandberg Date: Sat, 6 Apr 2019 20:47:22 +0000 (-0700) Subject: LP1816475: more intuitive behavior of date and time pickers X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=45ba25a8096d6626377537763e625a92bf8860ad;p=working%2FEvergreen.git LP1816475: more intuitive behavior of date and time pickers Signed-off-by: Jane Sandberg --- 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 9e74df388a..873a41f429 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 @@ -42,7 +42,7 @@
- + @@ -59,7 +59,7 @@
- + @@ -84,7 +84,7 @@ - +
  • @@ -92,7 +92,7 @@ - +
  • 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 ab9cbf6678..d454ea19c8 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 @@ -13,6 +13,7 @@ import {GridDataSource, GridRowFlairEntry} from '@eg/share/grid/grid'; import {IdlObject} from '@eg/core/idl.service'; import {NetService} from '@eg/core/net.service'; import {PcrudService} from '@eg/core/pcrud.service'; +import {ResourceTypeComboboxComponent} from './resource-type-combobox.component'; import {ServerStoreService} from '@eg/core/server-store.service'; import {ToastService} from '@eg/share/toast/toast.service'; @@ -35,6 +36,7 @@ export class CreateReservationComponent implements OnInit, AfterViewInit { patronId: number; resourceBarcode: string; resourceId: number; + resourceTypeId: number; startOfDay: NgbTimeStruct = {hour: 9, minute: 0, second: 0}; endOfDay: NgbTimeStruct = {hour: 17, minute: 0, second: 0}; @@ -57,6 +59,9 @@ export class CreateReservationComponent implements OnInit, AfterViewInit { @ViewChildren('dateRangeLimiter') dateRangeLimiters: QueryList; @ViewChildren('scheduleGrid') scheduleGrids: QueryList; @ViewChild('newDialog') newDialog: FmRecordEditorComponent; + @ViewChild('rt') rt: ResourceTypeComboboxComponent; + + today = new Date(); constructor( private auth: AuthService, @@ -93,7 +98,7 @@ export class CreateReservationComponent implements OnInit, AfterViewInit { .pipe(single()) .subscribe((res) => { this.resourceId = res.id(); - this.fetchData('resource', this.resourceId); + this.fetchData(); }, (err) => { this.pcrud.search('acp', {'barcode' : this.resourceBarcode}, {'limit': 1}) @@ -104,7 +109,7 @@ export class CreateReservationComponent implements OnInit, AfterViewInit { this.auth.token(), [item.id()]) .subscribe((response) => { this.toast.info('Made this barcode bookable'); - this.resourceId = response['id']; + this.resourceId = response['brsrc'][0][0]; }, (error) => { this.toast.danger('Cannot make this barcode bookable'); }) @@ -136,7 +141,7 @@ export class CreateReservationComponent implements OnInit, AfterViewInit { if (granularity != null) { this.granularity = granularity; } }); } - this.scheduleGrids.forEach((g) => g.reload()); + this.fetchData(); }; this.handleDateChange = ($event: Date) => { @@ -152,7 +157,7 @@ export class CreateReservationComponent implements OnInit, AfterViewInit { hour: ('00' === endArray[0]) ? 17 : +endArray[0], minute: +endArray[1], second: 0}; - this.scheduleGrids.forEach((g) => g.reload()); + this.fetchData(); }); }; @@ -189,17 +194,18 @@ export class CreateReservationComponent implements OnInit, AfterViewInit { return this.newDialog.open({size: 'lg'}).then( ok => { this.toast.success('Reservation successfully created'); // TODO: needs i18n, pluralization - this.scheduleGrids.forEach((g) => g.reload()); + this.fetchData(); }, err => {} ); } - handleResourceTypeChange(event: ComboboxEntry) { + handleResourceTypeChange($event: ComboboxEntry) { this.resourceBarcode = null; this.resourceId = null; + this.resourceTypeId = $event.id; this.attributes = []; - if (event.id) { - this.pcrud.search('bra', {resource_type : event.id}, { + if (this.resourceTypeId) { + this.pcrud.search('bra', {resource_type : this.resourceTypeId}, { order_by: 'name ASC', flesh: 1, flesh_fields: {'bra' : ['valid_values']} @@ -208,18 +214,20 @@ export class CreateReservationComponent implements OnInit, AfterViewInit { }, err => { console.debug(err); }, () => { - this.fetchData('type', event.id); + this.fetchData(); }); } } - fetchData (limiter: 'resource' | 'type', id: number) { + fetchData () { this.resources = []; let where = {}; - if ('type' === limiter) { - where = {type: id}; - } else if ('resource' === limiter) { + if (this.resourceId) { where = {id: this.resourceId}; + } else if (this.resourceTypeId) { + where = {type: this.resourceTypeId}; + } else { + return; } this.scheduleSource.data = []; this.pcrud.search('brsrc', where, { @@ -265,3 +273,4 @@ export class CreateReservationComponent implements OnInit, AfterViewInit { } + diff --git a/Open-ILS/src/eg2/src/app/staff/booking/resource-type-combobox.component.ts b/Open-ILS/src/eg2/src/app/staff/booking/resource-type-combobox.component.ts index fe12178370..b3d63c0810 100644 --- a/Open-ILS/src/eg2/src/app/staff/booking/resource-type-combobox.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/booking/resource-type-combobox.component.ts @@ -1,10 +1,12 @@ -import { Component, EventEmitter, OnInit, Input, Output } from '@angular/core'; +import {Component, EventEmitter, OnInit, Input, Output, ViewChild} from '@angular/core'; import {PcrudService} from '@eg/core/pcrud.service'; +import {ComboboxComponent} from '@eg/share/combobox/combobox.component'; import {ComboboxEntry} from '@eg/share/combobox/combobox.component'; @Component({ selector: 'eg-resource-type-combobox', template: ` void; + @Input() domId = ''; @Input() startId: number; @Output() typeChanged: EventEmitter; + @ViewChild('resourceTypeCombobox') resourceTypeCombobox: ComboboxComponent; + constructor(private pcrud: PcrudService) { this.typeChanged = new EventEmitter(); } @@ -29,6 +35,10 @@ export class ResourceTypeComboboxComponent implements OnInit { if (!this.resourceTypes) { this.resourceTypes = []; } this.resourceTypes.push({id: type.id(), label: type.name()}); }); + this.clear = () => { + this.resourceTypeCombobox.selected = {id: '', label: ''}; + }; } } +