}
_deflesh() {
- // unflesh the currency type field so that the record editor
- // can display it
+ // unflesh the currency type and edi_default fields so that the
+ // record editor can display them
// TODO: make fm-editor be able to handle fleshed linked fields
if (this.provider.currency_type()) {
this.provider.currency_type(this.provider.currency_type().code());
}
+ if (this.provider.edi_default()) {
+ this.provider.edi_default(this.provider.edi_default().id());
+ }
}
updateProvider(providerId: any) {
flesh_fields: { acqpro: [
'attributes', 'holdings_subfields', 'contacts',
'addresses', 'provider_notes',
- 'edi_accounts', 'currency_type'
+ 'edi_accounts', 'currency_type', 'edi_default'
],
acqpa: ['provider'],
acqpc: ['provider','addresses'],
return this.currentProvider ? this.currentProvider.record : null;
}
- // FIXME: ultimately, this is needed because eg-fm-record-editor currently can't
- // handle records that have linked fields fleshed; if/when it could,
- // we could just flesh edi_default and be done
- currentEdiDefault(): Promise<any> {
- if (this.currentProviderId) {
- if (this.currentProvider.record.edi_default()) {
- return this.pcrud.retrieve('acqedi', this.currentProvider.record.edi_default()).toPromise();
- } else {
- return Promise.resolve(null);
- }
- } else {
- return Promise.reject();
- }
- }
-
fetch(id: number): Promise<any> {
return new Promise((resolve, reject) => {
this.getProviderRecord(id).subscribe(
this.provider_holding_tag = provider.holding_tag();
this.provider_addresses = provider.addresses();
this.provider_san = provider.san();
- if (provider.edi_default()) {
- this.prov.currentEdiDefault().then(acqedi => {
- this.provider_edi_default = acqedi.label();
- });
- } else {
- this.provider_edi_default = '';
- }
+ this.provider_edi_default = provider.edi_default() ? provider.edi_default().label() : '';
this.provider_active = provider.active();
this.provider_prepayment_required = provider.prepayment_required();
this.provider_url = provider.url();