This commit is contained in:
@ -5,7 +5,7 @@ import { Async as AsyncSelect } from 'react-select';
|
||||
import { find, isEmpty, last, debounce, get, uniqBy } from 'lodash';
|
||||
import { List, Map, fromJS } from 'immutable';
|
||||
import { reactSelectStyles } from 'netlify-cms-ui-default';
|
||||
import { stringTemplate } from 'netlify-cms-lib-widgets';
|
||||
import { stringTemplate, validations } from 'netlify-cms-lib-widgets';
|
||||
import { FixedSizeList } from 'react-window';
|
||||
|
||||
function Option({ index, style, data }) {
|
||||
@ -97,6 +97,26 @@ export default class RelationControl extends React.Component {
|
||||
setInactiveStyle: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
isValid = () => {
|
||||
const { field, value, t } = this.props;
|
||||
const min = field.get('min');
|
||||
const max = field.get('max');
|
||||
|
||||
if (!this.isMultiple()) {
|
||||
return { error: false };
|
||||
}
|
||||
|
||||
const error = validations.validateMinMax(
|
||||
t,
|
||||
field.get('label', field.get('name')),
|
||||
value,
|
||||
min,
|
||||
max,
|
||||
);
|
||||
|
||||
return error ? { error } : { error: false };
|
||||
};
|
||||
|
||||
shouldComponentUpdate(nextProps) {
|
||||
return (
|
||||
this.props.value !== nextProps.value ||
|
||||
|
@ -133,7 +133,6 @@ const numberFieldsHits = [
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
class RelationController extends React.Component {
|
||||
state = {
|
||||
value: this.props.value,
|
||||
|
@ -5,6 +5,8 @@ export default {
|
||||
search_fields: { type: 'array', minItems: 1, items: { type: 'string' } },
|
||||
file: { type: 'string' },
|
||||
multiple: { type: 'boolean' },
|
||||
min: { type: 'integer' },
|
||||
max: { type: 'integer' },
|
||||
display_fields: { type: 'array', minItems: 1, items: { type: 'string' } },
|
||||
options_length: { type: 'integer' },
|
||||
},
|
||||
|
Reference in New Issue
Block a user