From 2555a145b26dd1a174824fbc9b9f49cf6066ba4a Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 22 Apr 2024 12:32:51 +0200 Subject: [PATCH] Add user/users column types --- .../backend/DataTable/modals/CreateEditColumn.svelte | 10 ++++------ packages/builder/src/constants/backend/index.js | 11 ++++++++--- packages/frontend-core/src/constants.js | 5 +++-- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte index d271462f3e..a837a9aad8 100644 --- a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte +++ b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte @@ -373,10 +373,6 @@ .map(([_, fieldDefinition]) => fieldDefinition) } - const isUsers = - editableColumn.type === FieldType.BB_REFERENCE && - editableColumn.subtype === FieldSubtype.USERS - if (!externalTable) { return [ FIELDS.STRING, @@ -393,7 +389,8 @@ FIELDS.LINK, FIELDS.FORMULA, FIELDS.JSON, - isUsers ? FIELDS.USERS : FIELDS.USER, + FIELDS.USER, + FIELDS.USERS, FIELDS.AUTO, ] } else { @@ -407,7 +404,8 @@ FIELDS.BOOLEAN, FIELDS.FORMULA, FIELDS.BIGINT, - isUsers ? FIELDS.USERS : FIELDS.USER, + FIELDS.USER, + FIELDS.USERS, ] // no-sql or a spreadsheet if (!externalTable || table.sql) { diff --git a/packages/builder/src/constants/backend/index.js b/packages/builder/src/constants/backend/index.js index 84975d93e2..30f6e20b45 100644 --- a/packages/builder/src/constants/backend/index.js +++ b/packages/builder/src/constants/backend/index.js @@ -4,6 +4,7 @@ import { INTERNAL_TABLE_SOURCE_ID, AutoFieldSubType, Hosting, + FieldTypeSubtypes, } from "@budibase/types" import { Constants } from "@budibase/frontend-core" @@ -159,15 +160,19 @@ export const FIELDS = { }, USER: { name: "User", - type: FieldType.BB_REFERENCE, + type: FieldType.BB_REFERENCE_SINGLE, subtype: FieldSubtype.USER, - icon: TypeIconMap[FieldType.USER], + icon: TypeIconMap[FieldType.BB_REFERENCE_SINGLE][ + FieldTypeSubtypes.BB_REFERENCE.USER + ], }, USERS: { name: "Users", type: FieldType.BB_REFERENCE, subtype: FieldSubtype.USERS, - icon: TypeIconMap[FieldType.USERS], + icon: TypeIconMap[FieldType.BB_REFERENCE][ + FieldTypeSubtypes.BB_REFERENCE.USERS + ], constraints: { type: "array", }, diff --git a/packages/frontend-core/src/constants.js b/packages/frontend-core/src/constants.js index 95228c3bdc..b3b1edac65 100644 --- a/packages/frontend-core/src/constants.js +++ b/packages/frontend-core/src/constants.js @@ -131,10 +131,11 @@ export const TypeIconMap = { [FieldType.JSON]: "Brackets", [FieldType.BIGINT]: "TagBold", [FieldType.AUTO]: "MagicWand", - [FieldType.USER]: "User", - [FieldType.USERS]: "UserGroup", [FieldType.BB_REFERENCE]: { [FieldTypeSubtypes.BB_REFERENCE.USER]: "User", [FieldTypeSubtypes.BB_REFERENCE.USERS]: "UserGroup", }, + [FieldType.BB_REFERENCE_SINGLE]: { + [FieldTypeSubtypes.BB_REFERENCE.USER]: "User", + }, }