From a2efc96755ec946b9ddafff105595d9834ced9d5 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Tue, 20 Apr 2021 11:44:33 -0400 Subject: [PATCH] LP#1904244: eg-grid: define style for negative money values This adds a negative-money-amount class when displaying money fields whose value is less than zero. Currently all that the class does is color the text red. Signed-off-by: Galen Charlton Signed-off-by: Ruth Frasur Signed-off-by: Bill Erickson --- Open-ILS/src/eg2/src/app/share/grid/grid.component.ts | 17 ++++++++++++++++- Open-ILS/src/eg2/src/styles.css | 5 +++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid.component.ts b/Open-ILS/src/eg2/src/app/share/grid/grid.component.ts index 4c0885ae3c..23d4261fbe 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid.component.ts +++ b/Open-ILS/src/eg2/src/app/share/grid/grid.component.ts @@ -187,7 +187,22 @@ export class GridComponent implements OnInit, AfterViewInit, OnDestroy { this.context.rowClassCallback = this.rowClassCallback || function () { return ''; }; this.context.cellClassCallback = - this.cellClassCallback || function() { return ''; }; + this.cellClassCallback || + function (row: any, col: GridColumn) { + if (col.datatype === 'money') { + // get raw value + let val; + if (col.path) { + val = this.nestedItemFieldValue(row, col); + } else if (col.name in row) { + val = this.getObjectFieldValue(row, col.name); + } + if (Number(val) < 0) { + return 'negative-money-amount'; + } + } + return ''; + }; if (this.showLinkSelectors) { console.debug( diff --git a/Open-ILS/src/eg2/src/styles.css b/Open-ILS/src/eg2/src/styles.css index 5ff572a608..e27756842f 100644 --- a/Open-ILS/src/eg2/src/styles.css +++ b/Open-ILS/src/eg2/src/styles.css @@ -256,3 +256,8 @@ body>.dropdown-menu {z-index: 2100;} #acq-search-page ngb-tabset .nav.nav-tabs { background-color: rgb(247, 247, 247); } + +/* style for negative monetary values */ +.negative-money-amount { + color: red; +} -- 2.11.0