This commit is contained in:
soupette 2019-12-19 15:43:07 +01:00
parent d6a00ccffd
commit c2ee96c355
3 changed files with 31 additions and 3 deletions

View File

@ -121,6 +121,29 @@ function Inputs({ autoFocus, keys, layout, name, onBlur }) {
step = '1';
}
const options = get(attribute, 'enum', []).map(v => {
return (
<option key={v} value={v}>
{v}
</option>
);
});
const isRequired = get(validations, ['required'], false);
const enumOptions = [
<FormattedMessage
id="components.InputSelect.option.placeholder"
key="__enum_option_null"
>
{msg => (
<option disabled={isRequired} hidden={isRequired} value="">
{msg}
</option>
)}
</FormattedMessage>,
...options,
];
return (
<FormattedMessage id={errorId}>
{error => {
@ -147,7 +170,7 @@ function Inputs({ autoFocus, keys, layout, name, onBlur }) {
name={keys}
onBlur={onBlur}
onChange={onChange}
options={get(attribute, 'enum', [])}
options={enumOptions}
step={step}
type={getInputType(type)}
validations={validations}

View File

@ -196,7 +196,8 @@ const EditViewDataManagerProvider = ({
inputValue = null;
}
if (type === 'biginteger' && value === '') {
// Allow to reset enum
if (type === 'select-one' && value === '') {
inputValue = null;
}

View File

@ -42,7 +42,11 @@ yup.addMethod(yup.string, 'unique', function(
yup.addMethod(yup.array, 'hasNotEmptyValues', function(message) {
return this.test('hasNotEmptyValues', message, function(array) {
return !array.some(value => isEmpty(value));
return (
!array.some(value => {
return isEmpty(value);
}) && array.every(value => ENUM_REGEX.test(value))
);
});
});