From 78c5216ee8bc901484fb2da66c5ccebd0a60cc2c Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 14 Sep 2023 16:49:41 +0200 Subject: [PATCH] Merge dev fields to fields --- .../DataTable/modals/CreateEditColumn.svelte | 50 +++++++++---------- .../builder/src/constants/backend/index.js | 3 -- 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte index 3619787a38..eb66d4d995 100644 --- a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte +++ b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte @@ -20,7 +20,6 @@ import { TableNames, UNEDITABLE_USER_FIELDS } from "constants" import { FIELDS, - DEV_FIELDS, RelationshipType, ALLOWABLE_STRING_OPTIONS, ALLOWABLE_NUMBER_OPTIONS, @@ -73,6 +72,30 @@ } const typeMapping = {} + if (!$admin.isDev) { + delete fieldDefinitions.USER + } + + // Handling fields with subtypes + fieldDefinitions = Object.entries(fieldDefinitions).reduce( + (p, [key, field]) => { + if (field.subtype) { + const composedType = `${field.type}_${field.subtype}` + p[key] = { + ...field, + type: composedType, + } + typeMapping[composedType] = { + type: field.type, + subtype: field.subtype, + } + } else { + p[key] = field + } + return p + }, + {} + ) $: if (primaryDisplay) { editableColumn.constraints.presence = { allowEmpty: false } @@ -348,33 +371,9 @@ return ALLOWABLE_NUMBER_OPTIONS } - let devFieldDefinitions = {} - if ($admin.isDev) { - devFieldDefinitions = Object.entries(DEV_FIELDS).reduce( - (p, [key, field]) => { - if (field.subtype) { - const composedType = `${field.type}_${field.subtype}` - p[key] = { - ...field, - type: composedType, - } - typeMapping[composedType] = { - type: field.type, - subtype: field.subtype, - } - } else { - p[key] = field - } - return p - }, - {} - ) - } - if (!external) { return [ ...Object.values(fieldDefinitions), - ...Object.values(devFieldDefinitions), { name: "Auto Column", type: AUTO_TYPE }, ] } else { @@ -393,6 +392,7 @@ if (!external || table.sql) { fields = [...fields, FIELDS.LINK, FIELDS.ARRAY] } + // fields = [...fields, ...Object.values(devFieldDefinitions)] return fields } } diff --git a/packages/builder/src/constants/backend/index.js b/packages/builder/src/constants/backend/index.js index 45cd2d5ed4..ccbc925672 100644 --- a/packages/builder/src/constants/backend/index.js +++ b/packages/builder/src/constants/backend/index.js @@ -120,9 +120,6 @@ export const FIELDS = { presence: false, }, }, -} - -export const DEV_FIELDS = { USER: { name: "User", type: "internal",