From 97881d848f4e028139dd03cf98bf61e3a579789c Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Wed, 13 Jul 2022 02:17:15 +0000 Subject: [PATCH] LP#1942220: (follow-up) add color coding of funds in copy attrs drop-down To reflect balance warning and stop. Signed-off-by: Galen Charlton --- .../staff/acq/lineitem/copy-attrs.component.html | 5 ++++ .../app/staff/acq/lineitem/copy-attrs.component.ts | 27 ++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/copy-attrs.component.html b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/copy-attrs.component.html index f0a170d0a6..aeb04cd9fb 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/copy-attrs.component.html +++ b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/copy-attrs.component.html @@ -39,6 +39,7 @@ [readOnly]="fieldIsDisabled('fund')" [asyncSupportsEmptyTermClick]="true" #fundSelector [entries]="fundEntries" + [displayTemplate]="fundTmpl" [selectedId]="copy.fund()" (onChange)="valueChange('fund', $event)" [idlQuerySort]="{acqf: 'year DESC, code'}" [idlQueryAnd]="{active: 't'}"> @@ -122,3 +123,7 @@ + + {{r.label}} + diff --git a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/copy-attrs.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/copy-attrs.component.ts index b7359d2a4f..aca110d66d 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/copy-attrs.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/copy-attrs.component.ts @@ -12,6 +12,7 @@ import {ItemLocationSelectComponent} from '@eg/share/item-location-select/item-l @Component({ templateUrl: 'copy-attrs.component.html', + styleUrls: ['copy-attrs.component.css'], selector: 'eg-lineitem-copy-attrs' }) export class LineitemCopyAttrsComponent implements OnInit { @@ -23,6 +24,8 @@ export class LineitemCopyAttrsComponent implements OnInit { @Output() becameDirty = new EventEmitter(); fundEntries: ComboboxEntry[]; + _fundBalanceCache: string[] = []; + _inflight: Promise[] = []; circModEntries: ComboboxEntry[]; private _copy: IdlObject; @@ -178,6 +181,30 @@ export class LineitemCopyAttrsComponent implements OnInit { } } + checkFundBalance(fundId: number): string { + if (this._fundBalanceCache[fundId]) { + return this._fundBalanceCache[fundId]; + } + if (this._inflight[fundId]) { + return 'ok'; + } + this._inflight[fundId] = this.net.request( + 'open-ils.acq', + 'open-ils.acq.fund.check_balance_percentages', + this.auth.token(), fundId + ).toPromise().then(r => { + if (r[0]) { + this._fundBalanceCache[fundId] = 'stop'; + } else if (r[1]) { + this._fundBalanceCache[fundId] = 'warning'; + } else { + this._fundBalanceCache[fundId] = 'ok'; + } + delete this._inflight[fundId]; + return this._fundBalanceCache[fundId]; + }); + } + fieldIsDisabled(field: string) { if (this.batchMode) { return false; } -- 2.11.0