From 95faefcb87d9a6fd7a214abd30a9a760407348bd Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 9 May 2024 12:28:44 +0200 Subject: [PATCH] DRY --- .../DataTable/modals/CreateEditColumn.svelte | 12 +++++----- .../grid/cells/BBReferenceCell.svelte | 22 ++++++------------- .../src/components/grid/lib/utils.js | 11 +++------- .../src/api/controllers/row/utils/basic.ts | 10 +++------ packages/shared-core/src/helpers/index.ts | 1 + packages/shared-core/src/helpers/schema.ts | 13 +++++++++++ 6 files changed, 33 insertions(+), 36 deletions(-) create mode 100644 packages/shared-core/src/helpers/schema.ts diff --git a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte index b06e62613d..69aaa4cd88 100644 --- a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte +++ b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte @@ -13,7 +13,11 @@ Layout, AbsTooltip, } from "@budibase/bbui" - import { SWITCHABLE_TYPES, ValidColumnNameRegex } from "@budibase/shared-core" + import { + SWITCHABLE_TYPES, + ValidColumnNameRegex, + helpers, + } from "@budibase/shared-core" import { createEventDispatcher, getContext, onMount } from "svelte" import { cloneDeep } from "lodash/fp" import { tables, datasources } from "stores/builder" @@ -361,11 +365,7 @@ function getAllowedTypes(datasource) { if (originalName) { let possibleTypes = SWITCHABLE_TYPES[field.type] || [editableColumn.type] - if ( - editableColumn.type === FieldType.BB_REFERENCE && - editableColumn.subtype === BBReferenceFieldSubType.USER && - editableColumn.constraints?.type !== "array" - ) { + if (helpers.schema.isDeprecatedSingleUserColumn(editableColumn)) { // This will handle old single users columns return [ { diff --git a/packages/frontend-core/src/components/grid/cells/BBReferenceCell.svelte b/packages/frontend-core/src/components/grid/cells/BBReferenceCell.svelte index 138ad68834..5d98ba903b 100644 --- a/packages/frontend-core/src/components/grid/cells/BBReferenceCell.svelte +++ b/packages/frontend-core/src/components/grid/cells/BBReferenceCell.svelte @@ -1,5 +1,6 @@