From: Bill Erickson Date: Fri, 25 May 2018 21:21:11 +0000 (-0400) Subject: LP#1775466 Grid custom field templates X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=0ee5f3374736c23bd37ae8f7ecae36ff89043c71;p=working%2FEvergreen.git LP#1775466 Grid custom field templates Signed-off-by: Bill Erickson --- 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;