Fix attribute minLength bug

This commit is contained in:
cyril lopez 2017-10-13 10:19:03 +02:00
parent 2dc7d8009d
commit b1a413becf
3 changed files with 15 additions and 3 deletions

View File

@ -20,6 +20,17 @@ class InputCheckboxWithNestedInputs extends React.Component { // eslint-disable-
}; };
this.props.handleChange({ target }); this.props.handleChange({ target });
if (!target.value) {
const paramsToRemove = {
target: {
type: 'number',
value: '',
name: `${this.props.data.name}Value`,
},
};
this.props.handleChange(paramsToRemove);
}
} }

View File

@ -56,11 +56,11 @@ const hasNestedValue = (attributeData) => {
} }
}); });
if (get(attributeData.params, ['minValue']) > get(attributeData.params, 'maxValue')) { if (isNumber(get(attributeData.params, 'maxValue')) && get(attributeData.params, ['minValue']) > get(attributeData.params, 'maxValue')) {
formErrors.push({ name: 'params.minValue', errors: [{ id: 'content-type-builder.error.validation.minSupMax' } ] }); formErrors.push({ name: 'params.minValue', errors: [{ id: 'content-type-builder.error.validation.minSupMax' } ] });
} }
if (get(attributeData.params, ['minLengthValue']) > get(attributeData.params, 'maxLengthValue')) { if (isNumber(get(attributeData.params, 'maxLengthValue')) && get(attributeData.params, ['minLengthValue']) > get(attributeData.params, 'maxLengthValue')) {
formErrors.push({ name: 'params.minLengthValue', errors: [{ id: 'content-type-builder.error.validation.minSupMax' } ] }); formErrors.push({ name: 'params.minLengthValue', errors: [{ id: 'content-type-builder.error.validation.minSupMax' } ] });
} }

View File

@ -51,7 +51,8 @@ export function* submitChanges(action) {
} }
if (!value) { if (!value) {
unset(body.attributes[index].params, key); const paramsKey = includes(key, 'Value') ? replace(key,'Value', '') : key;
unset(body.attributes[index].params, paramsKey);
} }
}); });
}); });