From e6f6573918dfaa808880f617ec48a62bd0390118 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 5 Jul 2018 14:12:50 -0400 Subject: [PATCH] LP#1775466 make grid onRowActivate/onRowClick proper Outputs Signed-off-by: Bill Erickson --- Open-ILS/src/eg2/src/app/share/grid/grid-body.component.ts | 6 +++--- Open-ILS/src/eg2/src/app/share/grid/grid.component.ts | 12 ++++++------ Open-ILS/src/eg2/src/app/share/grid/grid.ts | 6 +----- .../src/app/staff/share/admin-page/admin-page.component.ts | 3 ++- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid-body.component.ts b/Open-ILS/src/eg2/src/app/share/grid/grid-body.component.ts index 6246c440c5..e4829cee01 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid-body.component.ts +++ b/Open-ILS/src/eg2/src/app/share/grid/grid-body.component.ts @@ -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); } } diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid.component.ts b/Open-ILS/src/eg2/src/app/share/grid/grid.component.ts index dc041349be..83d2435499 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid.component.ts +++ b/Open-ILS/src/eg2/src/app/share/grid/grid.component.ts @@ -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; - onRowClick$: EventEmitter; + @Output() onRowActivate: EventEmitter; + @Output() onRowClick: EventEmitter; 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(); - this.onRowClick$ = new EventEmitter(); + this.onRowActivate = new EventEmitter(); + this.onRowClick = new EventEmitter(); } ngOnInit() { diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid.ts b/Open-ILS/src/eg2/src/app/share/grid/grid.ts index c395687379..33d720325d 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid.ts +++ b/Open-ILS/src/eg2/src/app/share/grid/grid.ts @@ -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()); diff --git a/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.ts b/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.ts index c4e6001414..2713c786d4 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.ts @@ -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](); -- 2.11.0