ngOnInit() {
this.route.paramMap.subscribe((params: ParamMap) => {
this.patronId = +params.get('patron_id');
+ if (this.patronId) {
+ this.pcrud.search('au', {
+ 'id': this.patronId,
+ }, {
+ limit: 1,
+ flesh: 1,
+ flesh_fields: {'au': ['card']}
+ }).subscribe(
+ (resp) => { this.patronBarcode = resp.card().barcode(); },
+ (err) => { console.log(err); }
+ );
+ }
this.resourceBarcode = params.get('resource_barcode');
+ if (this.resourceBarcode) {
+ this.pcrud.search('brsrc',
+ {'barcode' : this.resourceBarcode}, {'limit': 1})
+ .pipe(single())
+ .subscribe((res) => {
+ if (res.id()) {
+ this.resourceId = res.id();
+ this.reservationsGrid.reloadGrid();
+ } else {
+ this.resourceId = -1;
+ this.toast.danger('No resource found with this barcode');
+ }
+ });
+ }
this.resourceTypeId = +params.get('resource_type_id');
this.chooseAppropriateFilter();
});
- if (this.patronId) {
- this.pcrud.search('au', {
- 'id': this.patronId,
- }, {
- limit: 1,
- flesh: 1,
- flesh_fields: {'au': ['card']}
- }).subscribe(
- (resp) => { this.patronBarcode = resp.card().barcode(); },
- (err) => { console.log(err); }
- );
- }
-
- if (this.resourceBarcode) {
- this.pcrud.search('brsrc',
- {'barcode' : this.resourceBarcode}, {'limit': 1})
- .pipe(single())
- .subscribe((res) => {
- if (res.id()) {
- this.resourceId = res.id();
- this.reservationsGrid.reloadGrid();
- } else {
- this.resourceId = -1;
- this.toast.danger('No resource found with this barcode');
- }
- });
- }
this.setStickyFilter = ($event: NgbTabChangeEvent) => {
this.store.setItem('eg.booking.manage.filter', $event.nextId);