diff --git a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte index 643d7710f5..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" @@ -29,7 +33,11 @@ import ModalBindableInput from "components/common/bindings/ModalBindableInput.svelte" import { getBindings } from "components/backend/DataTable/formula" import JSONSchemaModal from "./JSONSchemaModal.svelte" - import { FieldType, SourceName } from "@budibase/types" + import { + BBReferenceFieldSubType, + FieldType, + SourceName, + } from "@budibase/types" import RelationshipSelector from "components/common/RelationshipSelector.svelte" import { RowUtils } from "@budibase/frontend-core" import ServerBindingPanel from "components/common/bindings/ServerBindingPanel.svelte" @@ -356,9 +364,29 @@ function getAllowedTypes(datasource) { if (originalName) { - const possibleTypes = SWITCHABLE_TYPES[field.type] || [ - editableColumn.type, - ] + let possibleTypes = SWITCHABLE_TYPES[field.type] || [editableColumn.type] + if (helpers.schema.isDeprecatedSingleUserColumn(editableColumn)) { + // This will handle old single users columns + return [ + { + ...FIELDS.USER, + type: FieldType.BB_REFERENCE, + subtype: BBReferenceFieldSubType.USER, + }, + ] + } else if ( + editableColumn.type === FieldType.BB_REFERENCE && + editableColumn.subtype === BBReferenceFieldSubType.USERS + ) { + // This will handle old multi users columns + return [ + { + ...FIELDS.USERS, + subtype: BBReferenceFieldSubType.USERS, + }, + ] + } + return Object.entries(FIELDS) .filter(([_, field]) => possibleTypes.includes(field.type)) .map(([_, fieldDefinition]) => fieldDefinition) diff --git a/packages/builder/src/components/backend/TableNavigator/ExistingTableDataImport.svelte b/packages/builder/src/components/backend/TableNavigator/ExistingTableDataImport.svelte index e79725c447..318f459f46 100644 --- a/packages/builder/src/components/backend/TableNavigator/ExistingTableDataImport.svelte +++ b/packages/builder/src/components/backend/TableNavigator/ExistingTableDataImport.svelte @@ -59,7 +59,7 @@ value: FieldType.ATTACHMENTS, }, { - label: "User", + label: "Users", value: `${FieldType.BB_REFERENCE}${BBReferenceFieldSubType.USER}`, }, { diff --git a/packages/builder/src/constants/backend/index.js b/packages/builder/src/constants/backend/index.js index 491d7f0e99..75f6a053b5 100644 --- a/packages/builder/src/constants/backend/index.js +++ b/packages/builder/src/constants/backend/index.js @@ -165,20 +165,11 @@ export const FIELDS = { BBReferenceFieldSubType.USER ], }, - // Used for display of editing existing columns - DEPRECATED_USER: { - name: "User", - type: FieldType.BB_REFERENCE, - subtype: BBReferenceFieldSubType.USER, - icon: TypeIconMap[FieldType.BB_REFERENCE_SINGLE][ - BBReferenceFieldSubType.USER - ], - }, USERS: { name: "User List", type: FieldType.BB_REFERENCE, - subtype: BBReferenceFieldSubType.USERS, - icon: TypeIconMap[FieldType.BB_REFERENCE][BBReferenceFieldSubType.USERS], + subtype: BBReferenceFieldSubType.USER, + icon: TypeIconMap[FieldType.BB_REFERENCE][BBReferenceFieldSubType.USER], constraints: { type: "array", }, diff --git a/packages/client/src/components/app/forms/RelationshipField.svelte b/packages/client/src/components/app/forms/RelationshipField.svelte index f8a84a00cb..a6d0564f7f 100644 --- a/packages/client/src/components/app/forms/RelationshipField.svelte +++ b/packages/client/src/components/app/forms/RelationshipField.svelte @@ -60,7 +60,7 @@ // Persist the initial values as options, allowing them to be present in the dropdown, // even if they are not in the inital fetch results let valueAsSafeArray = fieldState.value || [] - if (!Array.isArray(fieldState.value)) { + if (!Array.isArray(valueAsSafeArray)) { valueAsSafeArray = [fieldState.value] } optionsObj = valueAsSafeArray.reduce((accumulator, value) => { diff --git a/packages/frontend-core/src/components/grid/cells/BBReferenceCell.svelte b/packages/frontend-core/src/components/grid/cells/BBReferenceCell.svelte index ebfb33d884..5d98ba903b 100644 --- a/packages/frontend-core/src/components/grid/cells/BBReferenceCell.svelte +++ b/packages/frontend-core/src/components/grid/cells/BBReferenceCell.svelte @@ -1,20 +1,27 @@