LP#1775466 make grid onRowActivate/onRowClick proper Outputs
authorBill Erickson <berickxx@gmail.com>
Thu, 5 Jul 2018 18:12:50 +0000 (14:12 -0400)
committerBill Erickson <berickxx@gmail.com>
Mon, 9 Jul 2018 16:32:15 +0000 (12:32 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/share/grid/grid-body.component.ts
Open-ILS/src/eg2/src/app/share/grid/grid.component.ts
Open-ILS/src/eg2/src/app/share/grid/grid.ts
Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.ts

index 6246c44..e4829ce 100644 (file)
@@ -39,7 +39,7 @@ export class GridBodyComponent implements OnInit {
                 break;
             case 'Enter':
                 if (this.context.lastSelectedIndex) {
-                    this.grid.onRowActivate$.emit(
+                    this.grid.onRowActivate.emit(
                         this.context.getRowByIndex(
                             this.context.lastSelectedIndex)
                     );
@@ -66,11 +66,11 @@ export class GridBodyComponent implements OnInit {
             this.context.selectOneRow(index);
         }
 
-        this.grid.onRowClick$.emit(row);
+        this.grid.onRowClick.emit(row);
     }
 
     onRowDblClick(row: any) {
-        this.grid.onRowActivate$.emit(row);
+        this.grid.onRowActivate.emit(row);
     }
 
 }
index dc04134..83d2435 100644 (file)
@@ -1,5 +1,5 @@
-import {Component, Input, OnInit, AfterViewInit, EventEmitter, OnDestroy,
-    HostListener, ViewEncapsulation} from '@angular/core';
+import {Component, Input, Output, OnInit, AfterViewInit, EventEmitter, 
+    OnDestroy, HostListener, ViewEncapsulation} from '@angular/core';
 import {Subscription} from 'rxjs/Subscription';
 import {IdlService} from '@eg/core/idl.service';
 import {OrgService} from '@eg/core/org.service';
@@ -67,8 +67,8 @@ export class GridComponent implements OnInit, AfterViewInit, OnDestroy {
 
     // These events are emitted from our grid-body component.
     // They are defined here for ease of access to the caller.
-    onRowActivate$: EventEmitter<any>;
-    onRowClick$: EventEmitter<any>;
+    @Output() onRowActivate: EventEmitter<any>;
+    @Output() onRowClick: EventEmitter<any>;
 
     constructor(
         private idl: IdlService,
@@ -78,8 +78,8 @@ export class GridComponent implements OnInit, AfterViewInit, OnDestroy {
     ) {
         this.context =
             new GridContext(this.idl, this.org, this.store, this.format);
-        this.onRowActivate$ = new EventEmitter<any>();
-        this.onRowClick$ = new EventEmitter<any>();
+        this.onRowActivate = new EventEmitter<any>();
+        this.onRowClick = new EventEmitter<any>();
     }
 
     ngOnInit() {
index c395687..33d7203 100644 (file)
@@ -376,15 +376,11 @@ export class GridContext {
         this.columnSet.isSortable = this.isSortable === true;
         this.columnSet.isMultiSortable = this.isMultiSortable === true;
         this.columnSet.defaultHiddenFields = this.defaultHiddenFields;
+        this.generateColumns();
     }
 
     // Load initial settings and data.
     initData() {
-
-        // run in timeout because we are modifying the state of the 
-        // grid column header component mid-digest
-        setTimeout(() => this.generateColumns());
-
         this.applyColumnsConfig()
         .then(ok => this.dataSource.requestPage(this.pager))
         .then(ok => this.listenToPager());
index c4e6001..2713c78 100644 (file)
@@ -108,7 +108,8 @@ export class AdminPageComponent implements OnInit {
             this.initDataSource();
         }
 
-        this.grid.onRowActivate$.subscribe(
+        // TODO: pass the row activate handler via the grid markup
+        this.grid.onRowActivate.subscribe(
             (idlThing: IdlObject) => {
                 this.editDialog.mode = 'update';
                 this.editDialog.recId = idlThing[this.pkeyField]();