Fixing name conflict in event emitter
authorJane Sandberg <sandbej@linnbenton.edu>
Wed, 27 Mar 2019 00:10:33 +0000 (17:10 -0700)
committerJane Sandberg <sandbej@linnbenton.edu>
Wed, 27 Mar 2019 00:10:33 +0000 (17:10 -0700)
Open-ILS/src/eg2/src/app/staff/booking/create-reservation.component.html
Open-ILS/src/eg2/src/app/staff/booking/manage-reservations.component.html
Open-ILS/src/eg2/src/app/staff/booking/manage-reservations.component.ts
Open-ILS/src/eg2/src/app/staff/booking/resource-type-combobox.component.ts

index ec53116..dad6540 100644 (file)
@@ -44,7 +44,7 @@
       <div class="input-group-prepend">
         <label class="input-group-text" for="ideal-resource-type" i18n>Resource type</label>
       </div>
-      <eg-resource-type-combobox domId="ideal-resource-type" (onChange)="handleResourceTypeChange($event)"></eg-resource-type-combobox>
+      <eg-resource-type-combobox domId="ideal-resource-type" (typeChanged)="handleResourceTypeChange($event)"></eg-resource-type-combobox>
     </div>
   </div>
 </div>
index c89bd30..42ec2ca 100644 (file)
@@ -72,7 +72,7 @@
                 <div class="input-group-prepend">
                   <label class="input-group-text" for="resource-type-value" i18n>Resource type</label>
                 </div>
-                <eg-resource-type-combobox domId="resource-type-value" (onChange)="filterByResourceType($event)" [startId]="resourceTypeId"></eg-resource-type-combobox>
+                <eg-resource-type-combobox domId="resource-type-value" (typeChanged)="filterByResourceType($event)" [startId]="resourceTypeId"></eg-resource-type-combobox>
                 <div class="input-group-button">
                   <button class="btn btn-warning" (click)="removeFilters()" i18n><span class="material-icons">delete</span> Remove filter</button>
                 </div>
index 3e00b89..2f69592 100644 (file)
@@ -29,7 +29,6 @@ export class ManageReservationsComponent implements OnInit {
     filterByCurrentResourceBarcode: () => void;
     filterByResourceType: (selected: ComboboxEntry) => void;
     removeFilters: () => void;
-    chooseAppropriateFilter: () => void;
     setStickyFilter: ($event: NgbTabChangeEvent) => void;
 
     constructor(
@@ -40,19 +39,6 @@ export class ManageReservationsComponent implements OnInit {
        private store: ServerStoreService,
         private toast: ToastService
     ) {
-        // This is in the constructor, because we need it first thing in ngOnInit
-        this.chooseAppropriateFilter = () => {
-            if (this.resourceBarcode) {
-                this.selectedFilter = 'resource';
-            } else if (this.resourceTypeId) {
-                this.selectedFilter = 'type';
-            } else if (!(this.patronId)) {
-                this.store.getItem('eg.booking.manage.filter').then(filter => {
-                    if (filter) { this.selectedFilter = filter; }
-                });
-            }
-        };
-
     }
 
     ngOnInit() {
@@ -75,6 +61,7 @@ export class ManageReservationsComponent implements OnInit {
                     (err) => { console.log(err); }
                 );
             } else if (this.resourceBarcode) {
+                this.selectedFilter = 'resource';
                 this.pcrud.search('brsrc',
                 {'barcode' : this.resourceBarcode}, {'limit': 1})
                 .pipe(single())
@@ -86,9 +73,15 @@ export class ManageReservationsComponent implements OnInit {
                     this.toast.danger('No resource found with this barcode');
                 });
             } else if (this.resourceTypeId) {
+                this.selectedFilter = 'type';
                 this.reservationsGrid.reloadGrid();
             }
-            this.chooseAppropriateFilter();
+
+            if (!(this.patronId)) {
+                this.store.getItem('eg.booking.manage.filter').then(filter => {
+                    if (filter) { this.selectedFilter = filter; }
+                });
+            }
         });
 
 
index cf13183..fe12178 100644 (file)
@@ -8,7 +8,7 @@ import {ComboboxEntry} from '@eg/share/combobox/combobox.component';
         [attr.id]="domId"
         placeholder="Resource type" i18n-placeholder
         [entries]="resourceTypes"
-        (onChange)="onChange.emit($event)"
+        (onChange)="typeChanged.emit($event)"
         [startId]="startId"></eg-combobox>`
 })
 export class ResourceTypeComboboxComponent implements OnInit {
@@ -17,10 +17,10 @@ export class ResourceTypeComboboxComponent implements OnInit {
 
     @Input() domId = '';
     @Input() startId: number;
-    @Output() onChange: EventEmitter<ComboboxEntry>;
+    @Output() typeChanged: EventEmitter<ComboboxEntry>;
 
     constructor(private pcrud: PcrudService) {
-        this.onChange = new EventEmitter<ComboboxEntry>();
+        this.typeChanged = new EventEmitter<ComboboxEntry>();
     }
 
     ngOnInit() {