mirror of
https://github.com/strapi/strapi.git
synced 2025-09-20 14:00:48 +00:00
Add configurable as a valid api option
This commit is contained in:
parent
2fa574b061
commit
fc36055ff6
@ -31,6 +31,7 @@ const createSchema = (types, relations, { modelType } = {}) =>
|
|||||||
.string()
|
.string()
|
||||||
.oneOf(types)
|
.oneOf(types)
|
||||||
.required(),
|
.required(),
|
||||||
|
configurable: yup.boolean().nullable(),
|
||||||
...getTypeShape(attribute, { modelType }),
|
...getTypeShape(attribute, { modelType }),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ module.exports = (obj, validNatures) => {
|
|||||||
.oneOf(validNatures)
|
.oneOf(validNatures)
|
||||||
.required(),
|
.required(),
|
||||||
unique: validators.unique.nullable(),
|
unique: validators.unique.nullable(),
|
||||||
|
configurable: yup.boolean().nullable(),
|
||||||
dominant: yup.boolean().nullable(),
|
dominant: yup.boolean().nullable(),
|
||||||
columnName: yup.string().nullable(),
|
columnName: yup.string().nullable(),
|
||||||
targetAttribute: REVERSE_RELATIONS.includes(obj.nature)
|
targetAttribute: REVERSE_RELATIONS.includes(obj.nature)
|
||||||
|
@ -86,6 +86,8 @@ function createSchemaBuilder({ components, contentTypes }) {
|
|||||||
return Object.keys(attributes).reduce((acc, key) => {
|
return Object.keys(attributes).reduce((acc, key) => {
|
||||||
const attribute = attributes[key];
|
const attribute = attributes[key];
|
||||||
|
|
||||||
|
const { configurable } = attribute;
|
||||||
|
|
||||||
if (_.has(attribute, 'type')) {
|
if (_.has(attribute, 'type')) {
|
||||||
if (attribute.type === 'media') {
|
if (attribute.type === 'media') {
|
||||||
const fileModel = strapi.getModel('file', 'upload');
|
const fileModel = strapi.getModel('file', 'upload');
|
||||||
@ -97,9 +99,13 @@ function createSchemaBuilder({ components, contentTypes }) {
|
|||||||
via,
|
via,
|
||||||
plugin: 'upload',
|
plugin: 'upload',
|
||||||
required: attribute.required ? true : false,
|
required: attribute.required ? true : false,
|
||||||
|
configurable: configurable === false ? false : undefined,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
acc[key] = attribute;
|
acc[key] = {
|
||||||
|
...attribute,
|
||||||
|
configurable: configurable === false ? false : undefined,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return acc;
|
return acc;
|
||||||
@ -118,6 +124,7 @@ function createSchemaBuilder({ components, contentTypes }) {
|
|||||||
const attr = {
|
const attr = {
|
||||||
unique: unique === true ? true : undefined,
|
unique: unique === true ? true : undefined,
|
||||||
columnName: columnName || undefined,
|
columnName: columnName || undefined,
|
||||||
|
configurable: configurable === false ? false : undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!this.contentTypes.has(target)) {
|
if (!this.contentTypes.has(target)) {
|
||||||
|
@ -60,7 +60,7 @@ const formatAttribute = (key, attribute, { model }) => {
|
|||||||
const relation = (model.associations || []).find(
|
const relation = (model.associations || []).find(
|
||||||
assoc => assoc.alias === key
|
assoc => assoc.alias === key
|
||||||
);
|
);
|
||||||
const { plugin } = attribute;
|
const { plugin, configurable } = attribute;
|
||||||
let targetEntity = attribute.model || attribute.collection;
|
let targetEntity = attribute.model || attribute.collection;
|
||||||
|
|
||||||
if (plugin === 'upload' && targetEntity === 'file') {
|
if (plugin === 'upload' && targetEntity === 'file') {
|
||||||
@ -68,6 +68,7 @@ const formatAttribute = (key, attribute, { model }) => {
|
|||||||
type: 'media',
|
type: 'media',
|
||||||
multiple: attribute.collection ? true : false,
|
multiple: attribute.collection ? true : false,
|
||||||
required: attribute.required ? true : false,
|
required: attribute.required ? true : false,
|
||||||
|
configurable: configurable === false ? false : undefined,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
@ -77,6 +78,7 @@ const formatAttribute = (key, attribute, { model }) => {
|
|||||||
dominant: attribute.dominant ? true : false,
|
dominant: attribute.dominant ? true : false,
|
||||||
targetAttribute: attribute.via || undefined,
|
targetAttribute: attribute.via || undefined,
|
||||||
columnName: attribute.columnName || undefined,
|
columnName: attribute.columnName || undefined,
|
||||||
|
configurable: configurable === false ? false : undefined,
|
||||||
targetColumnName: _.get(
|
targetColumnName: _.get(
|
||||||
strapi.getModel(targetEntity, plugin),
|
strapi.getModel(targetEntity, plugin),
|
||||||
['attributes', attribute.via, 'columnName'],
|
['attributes', attribute.via, 'columnName'],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user