From 17df64c588771489715b74bfb3a306085fc958b7 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 4 Oct 2023 14:48:53 +0200 Subject: [PATCH] Allow selecting multiple users --- .../DataTable/modals/CreateEditColumn.svelte | 40 ++++++++++++------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte index 77eed5bdc6..12a693efab 100644 --- a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte +++ b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte @@ -52,14 +52,14 @@ let mounted = false const fieldDefinitions = Object.values(FIELDS).reduce((acc, field) => { - const fieldId = makeFieldId(field) + const fieldId = makeFieldId(field.type, field.subtype) acc[fieldId] = { ...field, fieldId } return acc }, {}) - function makeFieldId(field) { - return `${field.type}${field.subtype || ""}`.toUpperCase() + function makeFieldId(type, subtype) { + return `${type}${subtype || ""}`.toUpperCase() } $: console.warn(fieldDefinitions) @@ -150,7 +150,10 @@ $tables.selected.primaryDisplay == null || $tables.selected.primaryDisplay === editableColumn.name - editableColumn.fieldId = makeFieldId(editableColumn) + editableColumn.fieldId = makeFieldId( + editableColumn.type, + editableColumn.subtype + ) // Here we are setting the relationship values based on the editableColumn // This part of the code is used when viewing an existing field hence the check @@ -181,7 +184,10 @@ editableColumn.name = "Column 01" } - editableColumn.fieldId = makeFieldId(editableColumn) + editableColumn.fieldId = makeFieldId( + editableColumn.type, + editableColumn.subtype + ) } allowedTypes = getAllowedTypes() @@ -326,7 +332,11 @@ } } - function handleTypeChange(event) { + function onHandleTypeChange(event) { + handleTypeChange(event.detail) + } + + function handleTypeChange(type) { // remove any extra fields that may not be related to this type delete editableColumn.autocolumn delete editableColumn.subtype @@ -335,7 +345,7 @@ delete editableColumn.formulaType // Add in defaults and initial definition - const definition = fieldDefinitions[event.detail?.toUpperCase()] + const definition = fieldDefinitions[type?.toUpperCase()] if (definition?.constraints) { editableColumn.constraints = definition.constraints } @@ -404,10 +414,7 @@ fieldDefinitions.FORMULA, fieldDefinitions.JSON, fieldDefinitions[ - makeFieldId({ - type: FieldType.BB_REFERENCE, - subtype: FieldSubtype.USER, - }) + makeFieldId(FieldType.BB_REFERENCE, FieldSubtype.USER) ], { name: "Auto Column", type: AUTO_TYPE }, ] @@ -520,7 +527,7 @@