improve handling of currency type (LH#30)
authorGalen Charlton <gmc@equinoxinitiative.org>
Thu, 9 Jul 2020 16:22:34 +0000 (12:22 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Thu, 9 Jul 2020 16:22:34 +0000 (12:22 -0400)
- display currency label in the summary
- fix ability to edit it in the details fm-editor
- preload the currency drop-down

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/eg2/src/app/staff/acq/provider/provider-details.component.html
Open-ILS/src/eg2/src/app/staff/acq/provider/provider-details.component.ts
Open-ILS/src/eg2/src/app/staff/acq/provider/summary-pane.component.ts

index 97266f7..a8a384e 100644 (file)
@@ -11,6 +11,7 @@
   (recordSaved)="updateProvider($event)"
   readonlyFields="id"
   hiddenFields="holding_tag"
+  [fieldOptions]="{currency_type:{preloadLinkedValues:true}}"
   fieldOrder="active,name,code,id,currency_type,default_claim_policy,default_copy_count,edi_default,owner,phone,fax_phone,email,url,san,prepayment_required"
 >
 </eg-fm-record-editor>
index 3846cf9..e60d121 100644 (file)
@@ -41,9 +41,19 @@ export class ProviderDetailsComponent implements OnInit {
         this.refresh();
     }
 
+    _deflesh() {
+        // unflesh the currency type field so that the record editor
+        // can display it
+        // 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());
+        }
+    }
+
     updateProvider(providerId: any) {
         this.providerRecord.refreshCurrent().then(() => {
             this.provider = this.providerRecord.current();
+            this._deflesh();
             this.summarize.emit(this.provider.id());
         });
     }
@@ -51,6 +61,7 @@ export class ProviderDetailsComponent implements OnInit {
     refresh() {
         this.providerRecord.refreshCurrent().then(() => {
             this.provider = this.providerRecord.current();
+            this._deflesh();
         });
     }
 
index 38de105..e2d6965 100644 (file)
@@ -136,7 +136,7 @@ export class AcqProviderSummaryPaneComponent implements OnInit, AfterViewInit {
                     this.provider_name = provider.name();
                     this.provider_code = provider.code();
                     this.provider_owner = this.org.get(provider.owner()).shortname();
-                    this.provider_currency_type = provider.currency_type();
+                    this.provider_currency_type = provider.currency_type() ? provider.currency_type().label() : '';
                     this.provider_holding_tag = provider.holding_tag();
                     this.provider_addresses = provider.addresses();
                     this.provider_san = provider.san();