Selaa lähdekoodia

fix(admin-ui): Fix late creation of forms

Michael Bromley 7 vuotta sitten
vanhempi
sitoutus
33bd8cd444

+ 6 - 6
admin-ui/src/app/catalog/components/facet-detail/facet-detail.component.ts

@@ -42,14 +42,8 @@ export class FacetDetailComponent extends BaseDetailComponent<FacetWithValues> i
         private notificationService: NotificationService,
     ) {
         super(route, router);
-    }
-
-    ngOnInit() {
-        this.init();
         this.customFields = this.getCustomFieldConfig('Facet');
         this.customValueFields = this.getCustomFieldConfig('FacetValue');
-        this.facet$ = this.entity$;
-        this.values$ = this.facet$.pipe(map(facet => facet.values));
         this.facetForm = this.formBuilder.group({
             facet: this.formBuilder.group({
                 code: ['', Validators.required],
@@ -62,6 +56,12 @@ export class FacetDetailComponent extends BaseDetailComponent<FacetWithValues> i
         });
     }
 
+    ngOnInit() {
+        this.init();
+        this.facet$ = this.entity$;
+        this.values$ = this.facet$.pipe(map(facet => facet.values));
+    }
+
     ngOnDestroy() {
         this.destroy();
     }

+ 6 - 6
admin-ui/src/app/catalog/components/product-detail/product-detail.component.ts

@@ -45,14 +45,8 @@ export class ProductDetailComponent extends BaseDetailComponent<ProductWithVaria
         private notificationService: NotificationService,
     ) {
         super(route, router);
-    }
-
-    ngOnInit() {
-        this.init();
         this.customFields = this.getCustomFieldConfig('Product');
         this.customVariantFields = this.getCustomFieldConfig('ProductVariant');
-        this.product$ = this.entity$;
-        this.variants$ = this.product$.pipe(map(product => product.variants));
         this.productForm = this.formBuilder.group({
             product: this.formBuilder.group({
                 name: ['', Validators.required],
@@ -66,6 +60,12 @@ export class ProductDetailComponent extends BaseDetailComponent<ProductWithVaria
         });
     }
 
+    ngOnInit() {
+        this.init();
+        this.product$ = this.entity$;
+        this.variants$ = this.product$.pipe(map(product => product.variants));
+    }
+
     ngOnDestroy() {
         this.destroy();
     }