From 70174cdbcb78d29ce549957dc97febd84334d05b Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 25 May 2018 17:21:11 -0400 Subject: [PATCH] LP#1626157 Grid custom field templates Signed-off-by: Bill Erickson --- .../src/eg2/src/app/share/grid/grid-column.component.ts | 4 ++++ Open-ILS/src/eg2/src/app/share/grid/grid.component.html | 9 ++++++++- Open-ILS/src/eg2/src/app/share/grid/grid.ts | 9 +++++++++ .../eg2/src/app/staff/sandbox/sandbox.component.html | 17 +++++++++++------ .../src/eg2/src/app/staff/sandbox/sandbox.component.ts | 1 + 5 files changed, 33 insertions(+), 7 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid-column.component.ts b/Open-ILS/src/eg2/src/app/share/grid/grid-column.component.ts index 09f84322ea..7d34f8e54f 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid-column.component.ts +++ b/Open-ILS/src/eg2/src/app/share/grid/grid-column.component.ts @@ -21,6 +21,9 @@ export class EgGridColumnComponent implements OnInit { @Input() sortable: boolean; @Input() datatype: string; @Input() multiSortable: boolean; + + // Used in conjunction with cellTemplate. + @Input() cellContext: any; @Input() cellTemplate: TemplateRef; // get a reference to our container grid. @@ -41,6 +44,7 @@ export class EgGridColumnComponent implements OnInit { col.hidden = this.hidden === true; col.isIndex = this.index === true; col.cellTemplate = this.cellTemplate; + col.cellContext = this.cellContext; col.isSortable = this.sortable; col.isMultiSortable = this.multiSortable; this.grid.context.columnSet.add(col); diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid.component.html b/Open-ILS/src/eg2/src/app/share/grid/grid.component.html index 6be7e69fb4..84c8dee325 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid.component.html +++ b/Open-ILS/src/eg2/src/app/share/grid/grid.component.html @@ -30,7 +30,14 @@ (dblclick)="onRowDblClick(row)" (click)="onRowClick($event, row, idx)" *ngFor="let col of context.columnSet.displayColumns()"> - {{context.getRowColumnValue(row, col)}} + + {{context.getRowColumnValue(row, col)}} + + + + + 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 2d8af7900f..e6a2defbf4 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid.ts +++ b/Open-ILS/src/eg2/src/app/share/grid/grid.ts @@ -25,10 +25,19 @@ export class EgGridColumn { idlFieldDef: any; datatype: string; cellTemplate: TemplateRef; + cellContext: any; isIndex: boolean; isDragTarget: boolean; isSortable: boolean; isMultiSortable: boolean; + + getCellContext(row: any) { + return { + col: this, + row: row, + userContext: this.cellContext + }; + } } export class EgGridColumnSet { diff --git a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html index d6c600eb42..4430212db8 100644 --- a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html +++ b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html @@ -67,15 +67,20 @@
HERE: {{testDate}}
- - - Hello, {{world}}! + + + HELLO {{userContext.hello}} + + + + + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts index 7820b7bd01..5456d04d53 100644 --- a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts @@ -32,6 +32,7 @@ export class EgSandboxComponent implements OnInit { gridDataSource: EgGridDataSource = new EgGridDataSource(); btSource: EgGridDataSource = new EgGridDataSource(); + btGridTestContext: any = {hello : 'world'}; testDate: any; -- 2.11.0