funds: apply negative-money-amount styling to fund details dialog
authorGalen Charlton <gmc@equinoxinitiative.org>
Tue, 20 Apr 2021 16:04:59 +0000 (12:04 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Tue, 20 Apr 2021 16:04:59 +0000 (12:04 -0400)
LH#10

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/eg2/src/app/staff/admin/acq/funds/fund-details-dialog.component.html
Open-ILS/src/eg2/src/app/staff/admin/acq/funds/fund-details-dialog.component.ts

index 186903d..4d93d23 100644 (file)
@@ -1,12 +1,12 @@
 <eg-string #successString i18n-text text="Fund Update Succeeded"></eg-string>
 <eg-string #updateFailedString i18n-text text="Fund Update Failed"></eg-string>
 
-<ng-template #summaryField let-field="field" let-value="value">
+<ng-template #summaryField let-field="field" let-value="value" let-rawValue="rawValue">
   <div class="col-2">
     <label style="font-weight: bold" for="fund-{{field}}">{{idlDef.field_map[field].label}}</label>
   </div>
   <div class="col-2">
-    <span id="fund-{{field}}">
+    <span id="fund-{{field}}" [ngClass]="{'negative-money-amount': checkNegativeAmount(rawValue)}">
       {{value}}
     </span>
   </div>
               <ng-container *ngTemplateOutlet="summaryField;context:{value:fund.currency_type().code(),field:'currency_type'}"></ng-container>
             </div>
             <div class="row">
-              <ng-container *ngTemplateOutlet="summaryField;context:{value:formatCurrency(fund.combined_balance()?.amount()),field:'combined_balance'}"></ng-container>
-              <ng-container *ngTemplateOutlet="summaryField;context:{value:formatCurrency(fund.allocation_total()?.amount()),field:'allocation_total'}"></ng-container>
+              <ng-container *ngTemplateOutlet="summaryField;context:{value:formatCurrency(fund.combined_balance()?.amount()),field:'combined_balance',rawValue:fund.combined_balance()?.amount()}"></ng-container>
+              <ng-container *ngTemplateOutlet="summaryField;context:{value:formatCurrency(fund.allocation_total()?.amount()),field:'allocation_total',rawValue:fund.allocation_total()?.amount()}"></ng-container>
             </div>
             <div class="row">
-              <ng-container *ngTemplateOutlet="summaryField;context:{value:formatCurrency(fund.spent_balance()?.amount()),field:'spent_balance'}"></ng-container>
-              <ng-container *ngTemplateOutlet="summaryField;context:{value:formatCurrency(fund.debit_total()?.amount()),field:'debit_total'}"></ng-container>
+              <ng-container *ngTemplateOutlet="summaryField;context:{value:formatCurrency(fund.spent_balance()?.amount()),field:'spent_balance',rawValue:fund.spent_balance()?.amount()}"></ng-container>
+              <ng-container *ngTemplateOutlet="summaryField;context:{value:formatCurrency(fund.debit_total()?.amount()),field:'debit_total',rawValue:fund.debit_total()?.amount()}"></ng-container>
             </div>
             <div class="row">
-              <ng-container *ngTemplateOutlet="summaryField;context:{value:formatCurrency(fund.spent_total()?.amount()),field:'spent_total'}"></ng-container>
-              <ng-container *ngTemplateOutlet="summaryField;context:{value:formatCurrency(fund.encumbrance_total()?.amount()),field:'encumbrance_total'}"></ng-container>
+              <ng-container *ngTemplateOutlet="summaryField;context:{value:formatCurrency(fund.spent_total()?.amount()),field:'spent_total',rawValue:fund.spent_total()?.amount()}"></ng-container>
+              <ng-container *ngTemplateOutlet="summaryField;context:{value:formatCurrency(fund.encumbrance_total()?.amount()),field:'encumbrance_total',rawValue:fund.encumbrance_total()?.amount()}"></ng-container>
             </div>
           </div>
         </ng-template>
index 14ad68d..a04515b 100644 (file)
@@ -252,4 +252,8 @@ export class FundDetailsDialogComponent
             return this.org.get(ou).shortname();
         }
     }
+
+    checkNegativeAmount(val: any) {
+        return Number(val) < 0;
+    }
 }