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