63669: InputModels array for easier iteration

This commit is contained in:
Kristof De Langhe
2019-07-15 13:56:33 +02:00
parent f45f390c67
commit 9959176575

View File

@@ -122,6 +122,11 @@ export class CollectionSourceComponent extends AbstractTrackableComponent implem
] ]
}); });
/**
* All input models in a simple array for easier iterations
*/
inputModels = [this.providerModel, this.setModel, this.formatModel, this.harvestModel];
/** /**
* The dynamic form fields used for editing the content source of a collection * The dynamic form fields used for editing the content source of a collection
* @type {(DynamicInputModel | DynamicTextAreaModel)[]} * @type {(DynamicInputModel | DynamicTextAreaModel)[]}
@@ -269,16 +274,10 @@ export class CollectionSourceComponent extends AbstractTrackableComponent implem
* Used the update translations of errors and labels on init and on language change * Used the update translations of errors and labels on init and on language change
*/ */
private updateFieldTranslations() { private updateFieldTranslations() {
this.formModel.forEach( this.inputModels.forEach(
(fieldModel: DynamicFormControlModel) => { (fieldModel: DynamicFormControlModel) => {
if (fieldModel instanceof DynamicFormGroupModel) {
fieldModel.group.forEach((childModel: DynamicFormControlModel) => {
this.updateFieldTranslation(childModel);
});
} else {
this.updateFieldTranslation(fieldModel); this.updateFieldTranslation(fieldModel);
} }
}
); );
} }
@@ -347,15 +346,9 @@ export class CollectionSourceComponent extends AbstractTrackableComponent implem
* Loop over all inputs and update the Content Source with their value * Loop over all inputs and update the Content Source with their value
*/ */
updateContentSource() { updateContentSource() {
this.formModel.forEach( this.inputModels.forEach(
(fieldModel: DynamicFormGroupModel | DynamicInputModel) => { (fieldModel: DynamicInputModel) => {
if (fieldModel instanceof DynamicFormGroupModel) { this.updateContentSourceField(fieldModel)
fieldModel.group.forEach((childModel: DynamicInputModel) => {
this.updateContentSourceField(childModel);
});
} else {
this.updateContentSourceField(fieldModel);
}
} }
); );
this.saveFieldUpdate(); this.saveFieldUpdate();