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