From 9b294be6a8280609781729ecbfb85f90ae9469f7 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 18 Dec 2018 10:50:26 -0500 Subject: [PATCH] LP1807764 Angular grid gets datePlusTime option Adds a new boolean datePlusTime option to the Angular grid column configuration, informing the grid to display both date and time in the cell for a datetype=timestamp column. Includes sandbox example. Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg --- .../src/eg2/src/app/share/grid/grid-column.component.ts | 4 ++++ Open-ILS/src/eg2/src/app/share/grid/grid.ts | 8 +++++++- .../src/eg2/src/app/staff/sandbox/sandbox.component.html | 2 ++ .../src/eg2/src/app/staff/sandbox/sandbox.component.ts | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) 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 dffede14b7..4cebd48211 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 @@ -24,6 +24,9 @@ export class GridColumnComponent implements OnInit { @Input() datatype: string; @Input() multiSortable: boolean; + // Display date and time when datatype = timestamp + @Input() datePlusTime: boolean; + // Used in conjunction with cellTemplate @Input() cellContext: any; @Input() cellTemplate: TemplateRef; @@ -50,6 +53,7 @@ export class GridColumnComponent implements OnInit { col.isSortable = this.sortable; col.isMultiSortable = this.multiSortable; col.datatype = this.datatype; + col.datePlusTime = this.datePlusTime; col.isAuto = false; this.grid.context.columnSet.add(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 e04940dd1a..a352c0c4ef 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid.ts +++ b/Open-ILS/src/eg2/src/app/share/grid/grid.ts @@ -24,6 +24,7 @@ export class GridColumn { idlClass: string; idlFieldDef: any; datatype: string; + datePlusTime: boolean; cellTemplate: TemplateRef; cellContext: any; isIndex: boolean; @@ -630,7 +631,12 @@ export class GridContext { val = this.nestedItemFieldValue(row, col); } } - return this.format.transform({value: val, datatype: col.datatype}); + + return this.format.transform({ + value: val, + datatype: col.datatype, + datePlusTime: Boolean(col.datePlusTime) + }); } getObjectFieldValue(obj: any, name: string): any { 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 289ed50268..cd003ffe20 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 @@ -126,6 +126,8 @@ HERasdfE [cellContext]="btGridTestContext" [sortable]="false"> +

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 92b18dc9a9..617896919a 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 @@ -103,6 +103,7 @@ export class SandboxComponent implements OnInit { }).pipe(map(cbt => { // example of inline fleshing cbt.owner(this.org.get(cbt.owner())); + cbt.datetime_test = new Date(); this.oneBtype = cbt; return cbt; })); -- 2.43.2