소스 검색

fix(admin-ui): Fix configurable arg forms becoming unresponsive

Michael Bromley 4 년 전
부모
커밋
6039f0c27b

+ 12 - 13
packages/admin-ui/src/lib/settings/src/components/payment-method-detail/payment-method-detail.component.ts

@@ -92,11 +92,6 @@ export class PaymentMethodDetailComponent
         }
     }
 
-    getArgDef(paymentMethod: PaymentMethod.Fragment, argName: string): ConfigArgDefinition | undefined {
-        // return paymentMethod.handler.args.find(a => a.name === argName);
-        return;
-    }
-
     configArgsIsPopulated(): boolean {
         const configArgsGroup = this.detailForm.get('configArgs') as FormGroup | undefined;
         if (!configArgsGroup) {
@@ -230,13 +225,17 @@ export class PaymentMethodDetailComponent
             checker: paymentMethod.checker || {},
             handler: paymentMethod.handler || {},
         });
-        this.selectedChecker = paymentMethod.checker && {
-            code: paymentMethod.checker.code,
-            args: paymentMethod.checker.args.map(a => ({ ...a, value: getConfigArgValue(a.value) })),
-        };
-        this.selectedHandler = paymentMethod.handler && {
-            code: paymentMethod.handler.code,
-            args: paymentMethod.handler.args.map(a => ({ ...a, value: getConfigArgValue(a.value) })),
-        };
+        if (!this.selectedChecker) {
+            this.selectedChecker = paymentMethod.checker && {
+                code: paymentMethod.checker.code,
+                args: paymentMethod.checker.args.map(a => ({ ...a, value: getConfigArgValue(a.value) })),
+            };
+        }
+        if (!this.selectedHandler) {
+            this.selectedHandler = paymentMethod.handler && {
+                code: paymentMethod.handler.code,
+                args: paymentMethod.handler.args.map(a => ({ ...a, value: getConfigArgValue(a.value) })),
+            };
+        }
     }
 }

+ 12 - 8
packages/admin-ui/src/lib/settings/src/components/shipping-method-detail/shipping-method-detail.component.ts

@@ -310,14 +310,18 @@ export class ShippingMethodDetailComponent
             checker: shippingMethod.checker || {},
             calculator: shippingMethod.calculator || {},
         });
-        this.selectedChecker = shippingMethod.checker && {
-            code: shippingMethod.checker.code,
-            args: shippingMethod.checker.args.map(a => ({ ...a, value: getConfigArgValue(a.value) })),
-        };
-        this.selectedCalculator = shippingMethod.calculator && {
-            code: shippingMethod.calculator?.code,
-            args: shippingMethod.calculator?.args.map(a => ({ ...a, value: getConfigArgValue(a.value) })),
-        };
+        if (!this.selectedChecker) {
+            this.selectedChecker = shippingMethod.checker && {
+                code: shippingMethod.checker.code,
+                args: shippingMethod.checker.args.map(a => ({ ...a, value: getConfigArgValue(a.value) })),
+            };
+        }
+        if (!this.selectedCalculator) {
+            this.selectedCalculator = shippingMethod.calculator && {
+                code: shippingMethod.calculator?.code,
+                args: shippingMethod.calculator?.args.map(a => ({ ...a, value: getConfigArgValue(a.value) })),
+            };
+        }
         if (this.customFields.length) {
             const customFieldsGroup = this.detailForm.get('customFields') as FormGroup;