From: Galen Charlton Date: Sun, 28 Mar 2021 17:38:55 +0000 (-0400) Subject: LP#1904244: fm-edit: teach how to format selectors when wiring up comoboxes X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=a4cd115a834fbb5aeab2d10f8f9bdc80cef1c88a;p=evergreen%2Fpines.git LP#1904244: fm-edit: teach how to format selectors when wiring up comoboxes Matches similar functionality in combobox. Signed-off-by: Galen Charlton Signed-off-by: Ruth Frasur Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.ts b/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.ts index 4ac2e2eac9..9d4ae667f0 100644 --- a/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.ts +++ b/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.ts @@ -6,6 +6,7 @@ import {Observable} from 'rxjs'; import {map} from 'rxjs/operators'; import {AuthService} from '@eg/core/auth.service'; import {PcrudService} from '@eg/core/pcrud.service'; +import {OrgService} from '@eg/core/org.service'; import {DialogComponent} from '@eg/share/dialog/dialog.component'; import {ToastService} from '@eg/share/toast/toast.service'; import {StringComponent} from '@eg/share/string/string.component'; @@ -246,6 +247,7 @@ export class FmRecordEditorComponent private auth: AuthService, private toast: ToastService, private format: FormatService, + private org: OrgService, private pcrud: PcrudService) { super(modal); } @@ -432,11 +434,38 @@ export class FmRecordEditorComponent return list.map(item => { if (item !== undefined) { - return {id: item[idField](), label: item[selector]()}; + return {id: item[idField](), label: this.getFmRecordLabel(field, selector, item)}; } }); } + private getFmRecordLabel(field: any, selector: string, fm: IdlObject): string { + // for now, need to keep in sync with getFmRecordLabel in combobox + // alternatively, have fm-edit not wire-up the combobox's data source for it + switch (field.class) { + case 'acmc': + return fm.course_number() + ': ' + fm.name(); + break; + case 'acqf': + return fm.code() + ' (' + fm.year() + ')' + + ' (' + this.getOrgShortname(fm.org()) + ')'; + break; + case 'acpl': + return fm.name() + ' (' + this.getOrgShortname(fm.owning_lib()) + ')'; + break; + default: + // no equivalent of idlIncludeLibraryInLabel yet + return fm[selector](); + } + } + getOrgShortname(ou: any) { + if (typeof ou === 'object') { + return ou.shortname(); + } else { + return this.org.get(ou).shortname(); + } + } + private getFieldList(): Promise { const fields = this.idlDef.fields.filter(f =>