hide hints for repeated models of the same field, fix typo

This commit is contained in:
Art Lowel
2019-12-09 17:10:49 +01:00
parent fa40cac7e7
commit a5047f2f76

View File

@@ -41,7 +41,6 @@ export abstract class FieldParser {
&& (this.configData.input.type !== 'tag') && (this.configData.input.type !== 'tag')
&& (this.configData.input.type !== 'group') && (this.configData.input.type !== 'group')
) { ) {
let hideHints = false;
let arrayCounter = 0; let arrayCounter = 0;
let fieldArrayCounter = 0; let fieldArrayCounter = 0;
@@ -53,33 +52,35 @@ export abstract class FieldParser {
required: isNotEmpty(this.configData.mandatory), required: isNotEmpty(this.configData.mandatory),
groupFactory: () => { groupFactory: () => {
let model; let model;
let isFirstModelInArray = true;
if ((arrayCounter === 0)) { if ((arrayCounter === 0)) {
model = this.modelFactory(); model = this.modelFactory();
arrayCounter++; arrayCounter++;
} else { } else {
const fieldArrayOfValueLenght = this.getInitValueCount(arrayCounter - 1); const fieldArrayOfValueLength = this.getInitValueCount(arrayCounter - 1);
let fieldValue = null; let fieldValue = null;
if (fieldArrayOfValueLenght > 0) { if (fieldArrayOfValueLength > 0) {
if (fieldArrayCounter === 0) { if (fieldArrayCounter === 0) {
fieldValue = ''; fieldValue = '';
} else { } else {
fieldValue = this.getInitFieldValue(arrayCounter - 1, fieldArrayCounter - 1); fieldValue = this.getInitFieldValue(arrayCounter - 1, fieldArrayCounter - 1);
isFirstModelInArray = false;
} }
fieldArrayCounter++; fieldArrayCounter++;
if (fieldArrayCounter === fieldArrayOfValueLenght + 1) { if (fieldArrayCounter === fieldArrayOfValueLength + 1) {
fieldArrayCounter = 0; fieldArrayCounter = 0;
arrayCounter++; arrayCounter++;
} }
} }
model = this.modelFactory(fieldValue, false); model = this.modelFactory(fieldValue, false);
if (!isFirstModelInArray) {
model.hint = undefined;
}
} }
setLayout(model, 'element', 'host', 'col'); setLayout(model, 'element', 'host', 'col');
if (model.hasLanguages) { if (model.hasLanguages) {
setLayout(model, 'grid', 'control', 'col'); setLayout(model, 'grid', 'control', 'col');
} }
if (hideHints) {
model.hint = undefined;
}
return [model]; return [model];
} }
} as DynamicRowArrayModelConfig; } as DynamicRowArrayModelConfig;