handle grid population on activated route subscription
authorJane Sandberg <sandbej@linnbenton.edu>
Tue, 26 Mar 2019 22:39:56 +0000 (15:39 -0700)
committerJane Sandberg <sandbej@linnbenton.edu>
Tue, 26 Mar 2019 22:39:56 +0000 (15:39 -0700)
Open-ILS/src/eg2/src/app/staff/booking/manage-reservations.component.ts

index f346c47..df7ba59 100644 (file)
@@ -58,38 +58,37 @@ export class ManageReservationsComponent implements OnInit {
     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);