Skip to content

Commit

Permalink
fix(admin-ui): Fix translation of facet values
Browse files Browse the repository at this point in the history
Closes #636
  • Loading branch information
michaelbromley committed Jan 14, 2021
1 parent 6d1b8c6 commit a6f3083
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export class FacetDetailComponent
valuesFormArray.insert(
valuesFormArray.length,
this.formBuilder.group({
id: '',
name: ['', Validators.required],
code: '',
}),
Expand Down Expand Up @@ -297,7 +298,6 @@ export class FacetDetailComponent
}

const currentValuesFormArray = this.detailForm.get('values') as FormArray;
currentValuesFormArray.clear();
this.values = [...facet.values];
facet.values.forEach((value, i) => {
const valueTranslation = findTranslation(value, languageCode);
Expand All @@ -306,7 +306,12 @@ export class FacetDetailComponent
code: value.code,
name: valueTranslation ? valueTranslation.name : '',
};
currentValuesFormArray.insert(i, this.formBuilder.group(group));
const valueControl = currentValuesFormArray.at(i);
if (valueControl) {
valueControl.setValue(group);
} else {
currentValuesFormArray.insert(i, this.formBuilder.group(group));
}
if (this.customValueFields.length) {
let customValueFieldsGroup = this.detailForm.get(['values', i, 'customFields']) as FormGroup;
if (!customValueFieldsGroup) {
Expand Down

0 comments on commit a6f3083

Please sign in to comment.