From df6a72e9c686e0b064309e2419a8115bcfbad267 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 30 Jun 2021 13:46:45 -0400 Subject: [PATCH] LP1934164 Grid context/duration date minor refactoring Move some repeated code into a shared method. Signed-off-by: Bill Erickson --- Open-ILS/src/eg2/src/app/share/grid/grid.ts | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) 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 5f22a4d8bd..6d77f64a37 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid.ts +++ b/Open-ILS/src/eg2/src/app/share/grid/grid.ts @@ -895,14 +895,16 @@ export class GridContext { ).length > 0; } - getRowColumnValue(row: any, col: GridColumn): string { - let val; - + getRowColumnBareValue(row: any, col: GridColumn): any { if (col.name in row) { - val = this.getObjectFieldValue(row, col.name); + return this.getObjectFieldValue(row, col.name); } else if (col.path) { - val = this.nestedItemFieldValue(row, col); + return this.nestedItemFieldValue(row, col); } + } + + getRowColumnValue(row: any, col: GridColumn): any { + const val = this.getRowColumnBareValue(row, col); if (col.datatype === 'bool') { // Avoid string-ifying bools so we can use an @@ -910,18 +912,13 @@ export class GridContext { return val; } - // Get the value of let interval; const intField = col.dateOnlyIntervalField; if (intField) { - if (intField in row) { - interval = this.getObjectFieldValue(row, intField); - } else { - // find the referenced column - const intCol = this.columnSet.columns.filter(c => c.path === intField)[0]; - if (intCol) { - interval = this.nestedItemFieldValue(row, intCol); - } + const intCol = + this.columnSet.columns.filter(c => c.path === intField)[0]; + if (intCol) { + interval = this.getRowColumnBareValue(row, intCol); } } -- 2.11.0