From c2a6508e4a9d6e9c3d2b406e507264e264f9fa3a Mon Sep 17 00:00:00 2001 From: Jane Sandberg Date: Sun, 7 Apr 2019 14:53:45 -0700 Subject: [PATCH] LP1816475: improvements to create reservations UI Signed-off-by: Jane Sandberg --- .../booking/create-reservation.component.html | 34 +++++++---- .../staff/booking/create-reservation.component.ts | 64 +++++++++++++++----- .../staff/booking/reservations-grid.component.ts | 2 +- .../booking/resource-type-combobox.component.ts | 3 +- Open-ILS/src/eg2/src/app/staff/nav.component.html | 2 +- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 6 ++ .../upgrade/XXXX.data.booking-sticky-settings.sql | 6 ++ Open-ILS/src/templates/staff/circ/patron/index.tt2 | 5 ++ Open-ILS/src/templates/staff/navbar.tt2 | 2 +- .../web/js/ui/default/staff/cat/catalog/app.js | 69 +--------------------- Open-ILS/web/js/ui/default/staff/cat/item/app.js | 9 ++- .../web/js/ui/default/staff/circ/services/item.js | 68 +-------------------- 12 files changed, 101 insertions(+), 169 deletions(-) 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 af736ba1d7..575baf76c7 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 @@ -1,7 +1,3 @@ -

Resources

-{{resources | json}} -

Grid

-{{scheduleSource.data | json}} @@ -84,7 +80,7 @@ - +
  • @@ -92,7 +88,7 @@ - +
  • @@ -138,8 +134,7 @@ [rowFlairIsEnabled]="true" [rowFlairCallback]="resourceAvailabilityIcon" [disablePager]="true" - [disableSaveSettings]="true" - [cellClassCallback]="isBooked"> + [disableSaveSettings]="true"> @@ -147,14 +142,13 @@ + [fieldOptions]="{usr:{customTemplate:{template:patronTemplate}},start_time:{customTemplate:{template:datetimeWithDefaults}},end_time:{customTemplate:{template:datetimeWithDefaults}},pickup_lib:{customTemplate:{template:pickupLibrary}},target_resource:{customTemplate:{template:targetResource}}}" + hiddenFields="id,xact_start,request_time,capture_time,pickup_time,return_time,capture_staff,xact_finish,cancel_time,booking_interval,target_resource,unrecovered,request_lib,fine_interval,fine_amount,max_fine,target_resource,target_resource_type"> -
      +
      • {{reservation['patronLabel']}}
      • @@ -191,4 +185,20 @@
        Pickup library uses a different timezone than your library does. Please choose times in the pickup library's timezone.
        + + + + + + + + + + + + + + + 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 dc3d7d5a9c..9c58a3af33 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 @@ -32,7 +32,6 @@ export class CreateReservationComponent implements OnInit, AfterViewInit { attributes: IdlObject[] = []; multiday = false; handleDateChange: ($event: Date) => void; - isBooked: (col: any, row: any) => string; resourceAvailabilityIcon: (row: any) => GridRowFlairEntry; patronBarcode: string; @@ -40,6 +39,8 @@ export class CreateReservationComponent implements OnInit, AfterViewInit { resourceBarcode: string; resourceId: number; resourceTypeId: number; + transferable: boolean; + resourceOwner: number; pickupLibUsesDifferentTz: string; @@ -54,6 +55,7 @@ export class CreateReservationComponent implements OnInit, AfterViewInit { minuteStep: () => number; openCreateDialog: (rows: IdlObject[]) => void; + openTheDialog: (rows: IdlObject[]) => any; resources: IdlObject[] = []; limitByAttr: (attributeId: number, $event: ComboboxEntry) => void; @@ -65,6 +67,7 @@ export class CreateReservationComponent implements OnInit, AfterViewInit { handleSingleDayReservation: () => void; changeGranularity: ($event: ComboboxEntry) => void; handlePickupLibChange: ($event: IdlObject) => void; + handleTargetResourceChange: ($event: string | number) => void; @ViewChildren('dateLimiter') dateLimiters: QueryList; @ViewChildren('dateRangeLimiter') dateRangeLimiters: QueryList; @@ -105,6 +108,11 @@ export class CreateReservationComponent implements OnInit, AfterViewInit { 'start_time': Moment.tz([], this.format.wsOrgTimezone), 'end_time': Moment.tz([], this.format.wsOrgTimezone).add(this.granularity, 'minutes') }; + + this.store.getItem('eg.booking.create.multiday').then(multiday => { + if (multiday) { this.multiday = multiday; } + } + this.route.paramMap.subscribe((params: ParamMap) => { this.patronId = +params.get('patron_id'); this.resourceBarcode = params.get('resource_barcode'); @@ -138,12 +146,6 @@ export class CreateReservationComponent implements OnInit, AfterViewInit { } }); - this.isBooked = (row: any, col: any) => { - if ((col.name !== 'time') && (row[col.name])) { - return 'bg-warning'; - } - }; - this.limitByAttr = (attributeId: number, $event: ComboboxEntry) => { console.log('LIMIT'); console.log('id: ' + attributeId); @@ -184,12 +186,14 @@ export class CreateReservationComponent implements OnInit, AfterViewInit { this.handleMultiDayReservation = () => { this.multiday = true; + this.store.setItem('eg.booking.create.multiday', true); this.setGranularity(); this.fetchData(); }; this.handleSingleDayReservation = () => { this.multiday = false; + this.store.setItem('eg.booking.create.multiday', false); this.setGranularity(); this.handleDateChange(new Date()); }; @@ -211,6 +215,13 @@ export class CreateReservationComponent implements OnInit, AfterViewInit { }); }; + this.handleTargetResourceChange = ($event) => { + if ('any' !== $event) { + 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]); @@ -235,6 +246,17 @@ export class CreateReservationComponent implements OnInit, AfterViewInit { this.setGranularity(); this.fetchData(); + this.openTheDialog = (rows: IdlObject[]) => { + return this.newDialog.open({size: 'lg'}).then( + response => { + this.toast.success('Reservation successfully created'); // TODO: needs i18n, pluralization + this.fetchData(); + return response.id(); + }, + err => {} + ); + } + this.openCreateDialog = (rows: IdlObject[]) => { if (rows.length) { if (this.multiday) { @@ -249,14 +271,26 @@ export class CreateReservationComponent implements OnInit, AfterViewInit { } 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 => {} - ); + if (this.resourceId) { + this.pcrud.search('brsrc', {id: this.resourceId}, { + flesh: 1, + limit: 1, + flesh_fields: {'brsrc': ['type']} + }).subscribe( r => { + this.transferable = r.type().transferable(); + this.resourceTypeId = r.type().id(); + this.resourceOwner = r.owner(); + this.openTheDialog(rows); + }); + } else if (this.resourceTypeId) { + this.pcrud.search('brt', {id: this.resourceTypeId}, { + }).subscribe( t => { + this.transferable = t.transferable(); + this.openTheDialog(rows).then( + newId => { this.net.request('open-ils.storage', 'open-ils.storage.booking.reservation.resource_targeter', [newId]); } + ); + }); + } } } handleResourceTypeChange($event: ComboboxEntry) { diff --git a/Open-ILS/src/eg2/src/app/staff/booking/reservations-grid.component.ts b/Open-ILS/src/eg2/src/app/staff/booking/reservations-grid.component.ts index 85855cae82..5e6b4b2691 100644 --- a/Open-ILS/src/eg2/src/app/staff/booking/reservations-grid.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/booking/reservations-grid.component.ts @@ -174,7 +174,7 @@ 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 => row.current_resource().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.pickupNotAppropriate = (rows: IdlObject[]) => (this.noSelectedRows(rows) || ('pickupReady' !== this.status)); this.editNotAppropriate = (rows: IdlObject[]) => (this.noSelectedRows(rows) || ('returnedToday' === this.status)); 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 b3d63c0810..b2080ea315 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 @@ -34,7 +34,8 @@ export class ResourceTypeComboboxComponent implements OnInit { .subscribe(type => { 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.clear = () => { this.resourceTypeCombobox.selected = {id: '', label: ''}; }; diff --git a/Open-ILS/src/eg2/src/app/staff/nav.component.html b/Open-ILS/src/eg2/src/app/staff/nav.component.html index e710c34523..36610177f8 100644 --- a/Open-ILS/src/eg2/src/app/staff/nav.component.html +++ b/Open-ILS/src/eg2/src/app/staff/nav.component.html @@ -282,7 +282,7 @@ Booking