LP#1904244: eg-grid: define style for negative money values
authorGalen Charlton <gmc@equinoxOLI.org>
Tue, 20 Apr 2021 15:44:33 +0000 (11:44 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 12 Aug 2021 19:29:26 +0000 (15:29 -0400)
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 <gmc@equinoxOLI.org>
Signed-off-by: Ruth Frasur <rfrasur@library.in.gov>
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/share/grid/grid.component.ts
Open-ILS/src/eg2/src/styles.css

index 4c0885a..23d4261 100644 (file)
@@ -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(
index 5ff572a..e277568 100644 (file)
@@ -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;
+}