mirror of
https://github.com/strapi/strapi.git
synced 2025-10-14 09:34:32 +00:00
Merge branch 'master' into ctb/improve-stepper
This commit is contained in:
commit
860c2e0789
@ -27,7 +27,9 @@ const RepeatableComponent = ({
|
|||||||
const [, drop] = useDrop({ accept: ItemTypes.COMPONENT });
|
const [, drop] = useDrop({ accept: ItemTypes.COMPONENT });
|
||||||
|
|
||||||
const componentErrorKeys = Object.keys(formErrors)
|
const componentErrorKeys = Object.keys(formErrors)
|
||||||
.filter(errorKey => errorKey.includes(name))
|
.filter(errorKey => {
|
||||||
|
return errorKey.split('.')[0] === name;
|
||||||
|
})
|
||||||
.map(errorKey => {
|
.map(errorKey => {
|
||||||
return errorKey
|
return errorKey
|
||||||
.split('.')
|
.split('.')
|
||||||
@ -123,6 +125,7 @@ const RepeatableComponent = ({
|
|||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (componentValueLength < max) {
|
if (componentValueLength < max) {
|
||||||
const shouldCheckErrors = hasMinError;
|
const shouldCheckErrors = hasMinError;
|
||||||
|
|
||||||
addRepeatableComponentToField(
|
addRepeatableComponentToField(
|
||||||
name,
|
name,
|
||||||
componentUid,
|
componentUid,
|
||||||
|
@ -22,7 +22,6 @@ const cleanData = (retrievedData, currentSchema, componentsSchema) => {
|
|||||||
try {
|
try {
|
||||||
cleanedData = JSON.parse(value);
|
cleanedData = JSON.parse(value);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
|
||||||
cleanedData = value;
|
cleanedData = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,45 +95,26 @@ const createYupSchema = (model, { components }) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (attribute.repeatable === true) {
|
if (attribute.repeatable === true) {
|
||||||
const { min, max } = attribute;
|
const { min, max, required } = attribute;
|
||||||
|
let componentSchema = yup.lazy(value => {
|
||||||
|
let baseSchema = yup.array().of(componentFieldSchema);
|
||||||
|
|
||||||
let componentSchema =
|
if (min) {
|
||||||
attribute.required === true
|
if (required) {
|
||||||
? yup
|
baseSchema = baseSchema.min(min, errorsTrads.min);
|
||||||
.array()
|
} else if (required !== true && isEmpty(value)) {
|
||||||
.of(componentFieldSchema)
|
baseSchema = baseSchema.nullable();
|
||||||
.defined()
|
} else {
|
||||||
: yup
|
baseSchema = baseSchema.min(min, errorsTrads.min);
|
||||||
.array()
|
|
||||||
.of(componentFieldSchema)
|
|
||||||
.nullable();
|
|
||||||
|
|
||||||
if (min) {
|
|
||||||
componentSchema = yup.lazy(array => {
|
|
||||||
if (attribute.required) {
|
|
||||||
return yup
|
|
||||||
.array()
|
|
||||||
.of(componentFieldSchema)
|
|
||||||
.defined()
|
|
||||||
.min(min, errorsTrads.min);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let schema = yup
|
if (max) {
|
||||||
.array()
|
baseSchema = baseSchema.max(max, errorsTrads.max);
|
||||||
.of(componentFieldSchema)
|
}
|
||||||
.nullable();
|
|
||||||
|
|
||||||
if (array && !isEmpty(array)) {
|
return baseSchema;
|
||||||
schema = schema.min(min, errorsTrads.min);
|
});
|
||||||
}
|
|
||||||
|
|
||||||
return schema;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (max) {
|
|
||||||
componentSchema = componentSchema.max(max, errorsTrads.max);
|
|
||||||
}
|
|
||||||
|
|
||||||
acc[current] = componentSchema;
|
acc[current] = componentSchema;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user