mirror of
https://github.com/strapi/strapi.git
synced 2025-10-16 02:26:30 +00:00
Convert customField type before sending to server
This commit is contained in:
parent
acd1d0640f
commit
39c04410c1
@ -12,16 +12,16 @@
|
|||||||
"strapi": "strapi"
|
"strapi": "strapi"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@strapi/plugin-documentation": "4.3.4",
|
"@strapi/plugin-documentation": "4.3.6",
|
||||||
"@strapi/plugin-graphql": "4.3.4",
|
"@strapi/plugin-graphql": "4.3.6",
|
||||||
"@strapi/plugin-i18n": "4.3.4",
|
"@strapi/plugin-i18n": "4.3.6",
|
||||||
"@strapi/custom-fields": "4.3.4",
|
"@strapi/custom-fields": "4.3.6",
|
||||||
"@strapi/plugin-sentry": "4.3.4",
|
"@strapi/plugin-sentry": "4.3.6",
|
||||||
"@strapi/plugin-users-permissions": "4.3.4",
|
"@strapi/plugin-users-permissions": "4.3.6",
|
||||||
"@strapi/provider-email-mailgun": "4.3.4",
|
"@strapi/provider-email-mailgun": "4.3.6",
|
||||||
"@strapi/provider-upload-aws-s3": "4.3.4",
|
"@strapi/provider-upload-aws-s3": "4.3.6",
|
||||||
"@strapi/provider-upload-cloudinary": "4.3.4",
|
"@strapi/provider-upload-cloudinary": "4.3.6",
|
||||||
"@strapi/strapi": "4.3.4",
|
"@strapi/strapi": "4.3.6",
|
||||||
"@vscode/sqlite3": "5.0.8",
|
"@vscode/sqlite3": "5.0.8",
|
||||||
"better-sqlite3": "7.4.6",
|
"better-sqlite3": "7.4.6",
|
||||||
"lodash": "4.17.21",
|
"lodash": "4.17.21",
|
||||||
|
@ -94,6 +94,11 @@ const formatAttributes = (attributes, mainDataUID) => {
|
|||||||
acc[name] = removeNullKeys(formattedRelationAttribute);
|
acc[name] = removeNullKeys(formattedRelationAttribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (currentAttribute.customField) {
|
||||||
|
const customFieldAttribute = { ...currentAttribute, type: 'customField' };
|
||||||
|
acc[name] = removeNullKeys(customFieldAttribute);
|
||||||
|
}
|
||||||
|
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
};
|
};
|
||||||
|
@ -29,6 +29,7 @@ const DEFAULT_TYPES = [
|
|||||||
'boolean',
|
'boolean',
|
||||||
|
|
||||||
'relation',
|
'relation',
|
||||||
|
'customField',
|
||||||
];
|
];
|
||||||
|
|
||||||
const VALID_UID_TARGETS = ['string', 'text'];
|
const VALID_UID_TARGETS = ['string', 'text'];
|
||||||
|
@ -8,7 +8,6 @@ const { nameToSlug, nameToCollectionName } = require('@strapi/utils');
|
|||||||
const { ApplicationError } = require('@strapi/utils').errors;
|
const { ApplicationError } = require('@strapi/utils').errors;
|
||||||
const { isConfigurable } = require('../../utils/attributes');
|
const { isConfigurable } = require('../../utils/attributes');
|
||||||
const createSchemaHandler = require('./schema-handler');
|
const createSchemaHandler = require('./schema-handler');
|
||||||
const convertCustomFieldType = require('./utils/convert-custom-field-type');
|
|
||||||
|
|
||||||
module.exports = function createComponentBuilder() {
|
module.exports = function createComponentBuilder() {
|
||||||
return {
|
return {
|
||||||
@ -33,15 +32,12 @@ module.exports = function createComponentBuilder() {
|
|||||||
* create a component in the tmpComponent map
|
* create a component in the tmpComponent map
|
||||||
*/
|
*/
|
||||||
createComponent(infos) {
|
createComponent(infos) {
|
||||||
const { attributes } = infos;
|
|
||||||
const uid = this.createComponentUID(infos);
|
const uid = this.createComponentUID(infos);
|
||||||
|
|
||||||
if (this.components.has(uid)) {
|
if (this.components.has(uid)) {
|
||||||
throw new ApplicationError('component.alreadyExists');
|
throw new ApplicationError('component.alreadyExists');
|
||||||
}
|
}
|
||||||
|
|
||||||
convertCustomFieldType(attributes);
|
|
||||||
|
|
||||||
const handler = createSchemaHandler({
|
const handler = createSchemaHandler({
|
||||||
dir: path.join(strapi.dirs.app.components, nameToSlug(infos.category)),
|
dir: path.join(strapi.dirs.app.components, nameToSlug(infos.category)),
|
||||||
filename: `${nameToSlug(infos.displayName)}.json`,
|
filename: `${nameToSlug(infos.displayName)}.json`,
|
||||||
@ -76,13 +72,12 @@ module.exports = function createComponentBuilder() {
|
|||||||
* create a component in the tmpComponent map
|
* create a component in the tmpComponent map
|
||||||
*/
|
*/
|
||||||
editComponent(infos) {
|
editComponent(infos) {
|
||||||
const { uid, attributes } = infos;
|
const { uid } = infos;
|
||||||
|
|
||||||
if (!this.components.has(uid)) {
|
if (!this.components.has(uid)) {
|
||||||
throw new ApplicationError('component.notFound');
|
throw new ApplicationError('component.notFound');
|
||||||
}
|
}
|
||||||
|
|
||||||
convertCustomFieldType(attributes);
|
|
||||||
const component = this.components.get(uid);
|
const component = this.components.get(uid);
|
||||||
|
|
||||||
const [, nameUID] = uid.split('.');
|
const [, nameUID] = uid.split('.');
|
||||||
|
@ -8,7 +8,6 @@ const { ApplicationError } = require('@strapi/utils').errors;
|
|||||||
const { isRelation, isConfigurable } = require('../../utils/attributes');
|
const { isRelation, isConfigurable } = require('../../utils/attributes');
|
||||||
const { typeKinds } = require('../constants');
|
const { typeKinds } = require('../constants');
|
||||||
const createSchemaHandler = require('./schema-handler');
|
const createSchemaHandler = require('./schema-handler');
|
||||||
const convertCustomFieldType = require('./utils/convert-custom-field-type');
|
|
||||||
|
|
||||||
const reuseUnsetPreviousProperties = (newAttribute, oldAttribute) => {
|
const reuseUnsetPreviousProperties = (newAttribute, oldAttribute) => {
|
||||||
_.defaults(
|
_.defaults(
|
||||||
@ -72,15 +71,12 @@ module.exports = function createComponentBuilder() {
|
|||||||
* @returns {object} new content type
|
* @returns {object} new content type
|
||||||
*/
|
*/
|
||||||
createContentType(infos) {
|
createContentType(infos) {
|
||||||
const { attributes } = infos;
|
|
||||||
const uid = createContentTypeUID(infos);
|
const uid = createContentTypeUID(infos);
|
||||||
|
|
||||||
if (this.contentTypes.has(uid)) {
|
if (this.contentTypes.has(uid)) {
|
||||||
throw new ApplicationError('contentType.alreadyExists');
|
throw new ApplicationError('contentType.alreadyExists');
|
||||||
}
|
}
|
||||||
|
|
||||||
convertCustomFieldType(attributes);
|
|
||||||
|
|
||||||
const contentType = createSchemaHandler({
|
const contentType = createSchemaHandler({
|
||||||
modelName: infos.singularName,
|
modelName: infos.singularName,
|
||||||
dir: path.join(
|
dir: path.join(
|
||||||
@ -133,14 +129,12 @@ module.exports = function createComponentBuilder() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
editContentType(infos) {
|
editContentType(infos) {
|
||||||
const { uid, attributes } = infos;
|
const { uid } = infos;
|
||||||
|
|
||||||
if (!this.contentTypes.has(uid)) {
|
if (!this.contentTypes.has(uid)) {
|
||||||
throw new ApplicationError('contentType.notFound');
|
throw new ApplicationError('contentType.notFound');
|
||||||
}
|
}
|
||||||
|
|
||||||
convertCustomFieldType(attributes);
|
|
||||||
|
|
||||||
const contentType = this.contentTypes.get(uid);
|
const contentType = this.contentTypes.get(uid);
|
||||||
|
|
||||||
const oldAttributes = contentType.schema.attributes;
|
const oldAttributes = contentType.schema.attributes;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@strapi/custom-fields",
|
"name": "@strapi/custom-fields",
|
||||||
"version": "4.3.4",
|
"version": "4.3.6",
|
||||||
"description": "Strapi maintained Custom Fields",
|
"description": "Strapi maintained Custom Fields",
|
||||||
"strapi": {
|
"strapi": {
|
||||||
"name": "custom-fields",
|
"name": "custom-fields",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user