LP1807764 Angular grid gets datePlusTime option
authorBill Erickson <berickxx@gmail.com>
Tue, 18 Dec 2018 15:50:26 +0000 (10:50 -0500)
committerBill Erickson <berickxx@gmail.com>
Fri, 18 Jan 2019 15:11:35 +0000 (10:11 -0500)
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 <berickxx@gmail.com>
Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu>
Open-ILS/src/eg2/src/app/share/grid/grid-column.component.ts
Open-ILS/src/eg2/src/app/share/grid/grid.ts
Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html
Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts

index dffede1..4cebd48 100644 (file)
@@ -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<any>;
@@ -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);
     }
index e04940d..a352c0c 100644 (file)
@@ -24,6 +24,7 @@ export class GridColumn {
     idlClass: string;
     idlFieldDef: any;
     datatype: string;
+    datePlusTime: boolean;
     cellTemplate: TemplateRef<any>;
     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 {
index 289ed50..cd003ff 100644 (file)
@@ -126,6 +126,8 @@ HERasdfE
     [cellContext]="btGridTestContext" [sortable]="false">
   </eg-grid-column>
   <eg-grid-column [sortable]="false" path="owner.name"></eg-grid-column>
+  <eg-grid-column [sortable]="false" path="datetime_test" 
+    datatype="timestamp" [datePlusTime]="true"></eg-grid-column>
 </eg-grid>
 
 <br/><br/>
index 92b18dc..6178969 100644 (file)
@@ -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;
             }));