fixes to resource filtering
authorJane Sandberg <sandbej@linnbenton.edu>
Tue, 26 Mar 2019 21:42:56 +0000 (14:42 -0700)
committerJane Sandberg <sandbej@linnbenton.edu>
Tue, 26 Mar 2019 21:42:56 +0000 (14:42 -0700)
Open-ILS/src/eg2/src/app/staff/booking/manage-reservations.component.ts

index 2c84add..f346c47 100644 (file)
@@ -1,5 +1,6 @@
 import {Component, OnInit, ViewChild} from '@angular/core';
 import {Router, ActivatedRoute, ParamMap} from '@angular/router';
+import {single} from 'rxjs/operators';
 import { NgbTabChangeEvent } from '@ng-bootstrap/ng-bootstrap';
 import {ComboboxEntry} from '@eg/share/combobox/combobox.component';
 import {GridComponent} from '@eg/share/grid/grid.component';
@@ -77,10 +78,16 @@ export class ManageReservationsComponent implements OnInit {
 
         if (this.resourceBarcode) {
             this.pcrud.search('brsrc',
-            {'barcode' : this.resourceBarcode}, {'limit': 1, 'select': ['id']})
+            {'barcode' : this.resourceBarcode}, {'limit': 1})
+            .pipe(single())
             .subscribe((res) => {
-                this.resourceId = res.id();
-                this.reservationsGrid.reloadGrid();
+                if (res.id()) {
+                    this.resourceId = res.id();
+                    this.reservationsGrid.reloadGrid();
+                } else {
+                    this.resourceId = -1;
+                    this.toast.danger('No resource found with this barcode');
+                }
             });
         }