Skip to content

Commit

Permalink
fix(admin-ui): Fix customField product error: handle undef. case
Browse files Browse the repository at this point in the history
  • Loading branch information
Lorenzo Simone committed Sep 15, 2019
1 parent 4ed2ce3 commit 8265359
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -399,15 +399,13 @@ export class ProductDetailComponent extends BaseDetailComponent<ProductWithVaria

if (this.customFields.length) {
const customFieldsGroup = this.detailForm.get(['product', 'customFields']) as FormGroup;
const cfCurrentTranslation =
(currentTranslation && (currentTranslation as any).customFields) || {};
const cfProduct = (product as any).customFields || {};

for (const fieldDef of this.customFields) {
const key = fieldDef.name;
const value =
fieldDef.type === 'localeString'
? currentTranslation
? (currentTranslation as any).customFields[key]
: null
: (product as any).customFields[key];
const value = fieldDef.type === 'localeString' ? cfCurrentTranslation[key] : cfProduct[key];
const control = customFieldsGroup.get(key);
if (control) {
control.patchValue(value);
Expand Down

0 comments on commit 8265359

Please sign in to comment.