LP1813806 Grid row activate method handler example user/berick/lp1813806-ang-grid-row-activate-example
authorBill Erickson <berickxx@gmail.com>
Wed, 30 Jan 2019 15:10:57 +0000 (10:10 -0500)
committerBill Erickson <berickxx@gmail.com>
Wed, 30 Jan 2019 15:11:02 +0000 (10:11 -0500)
Move admin page grid row activate handler away from an instance function
to a proper class method.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.html
Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.ts

index 0fc5c44..05081b0 100644 (file)
@@ -42,6 +42,7 @@
 <eg-translate #translator></eg-translate>
 
 <eg-grid #grid idlClass="{{idlClass}}" [dataSource]="dataSource" 
+    (onRowActivate)="onGridRowActivate($event)"
     [sortable]="true" persistKey="{{persistKey}}">
   <eg-grid-toolbar-button [disabled]="!canCreate" 
     label="New {{idlClassDef.label}}" i18n-label [action]="createNew">
index 80fd2fd..ee9f85a 100644 (file)
@@ -151,22 +151,6 @@ export class AdminPageComponent implements OnInit {
             this.initDataSource();
         }
 
-        // 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]();
-                this.editDialog.open({size: this.dialogSize}).then(
-                    ok => {
-                        this.successString.current()
-                            .then(str => this.toast.success(str));
-                        this.grid.reload();
-                    },
-                    err => {}
-                );
-            }
-        );
-
         this.createNew = () => {
             this.editDialog.mode = 'create';
             this.editDialog.open({size: this.dialogSize}).then(
@@ -309,6 +293,18 @@ export class AdminPageComponent implements OnInit {
         return this.contextOrg && this.contextOrg.children().length === 0;
     }
 
+    onGridRowActivate(idlThing: IdlObject) {
+        this.editDialog.mode = 'update';
+        this.editDialog.recId = idlThing[this.pkeyField]();
+        this.editDialog.open({size: this.dialogSize}).then(
+            ok => {
+                this.successString.current()
+                    .then(str => this.toast.success(str));
+                this.grid.reload();
+            },
+            err => {}
+        );
+    }
 }