From: Galen Charlton Date: Tue, 7 Dec 2021 21:51:09 +0000 (-0500) Subject: LP#1942220: format fund labels correctly in the batch copy form X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=5340e6d788aa2144249c9c7c0d3e390ed5346e1e;p=working%2FEvergreen.git LP#1942220: format fund labels correctly in the batch copy form While caching the selected funds is good to reduce unnecessary pcrud queries, doing so breaks formatting the fund label in the comboboxes consistently without this patch. Signed-off-by: Galen Charlton --- 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 4c12012e7f..d6b5aaab7d 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 @@ -4,6 +4,7 @@ import {Pager} from '@eg/share/util/pager'; import {IdlObject, IdlService} from '@eg/core/idl.service'; import {NetService} from '@eg/core/net.service'; import {AuthService} from '@eg/core/auth.service'; +import {OrgService} from '@eg/core/org.service'; import {LineitemService, COPY_ORDER_DISPOSITION} from './lineitem.service'; import {ComboboxComponent, ComboboxEntry} from '@eg/share/combobox/combobox.component'; import {ItemLocationService} from '@eg/share/item-location-select/item-location-select.service'; @@ -62,6 +63,7 @@ export class LineitemCopyAttrsComponent implements OnInit { private idl: IdlService, private net: NetService, private auth: AuthService, + private org: OrgService, private loc: ItemLocationService, private liService: LineitemService ) {} @@ -127,13 +129,31 @@ export class LineitemCopyAttrsComponent implements OnInit { } } + // copied from combobox to get the label right for funds + getOrgShortname(ou: any) { + if (typeof ou === 'object') { + return ou.shortname(); + } else { + return this.org.get(ou).shortname(); + } + } + // Tell our inputs about the values we know we need // Values will be pre-cached in the liService + // + // TODO: figure out a better way to do this so that we + // don't need to duplicate the code to format + // the display labels for funds correctly setInitialOptions(copy: IdlObject) { if (copy.fund()) { const fund = this.liService.fundCache[copy.fund()]; - this.fundEntries = [{id: fund.id(), label: fund.code(), fm: fund}]; + this.fundEntries = [{ + id: fund.id(), + label: fund.code() + ' (' + fund.year() + ')' + + ' (' + this.getOrgShortname(fund.org()) + ')', + fm: fund + }]; } if (copy.circ_modifier()) {