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';
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');
+ }
});
}