From 95caee66a75f0d3b7d6596feee4b2d6df0948315 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 10 Oct 2023 11:22:59 +0100 Subject: [PATCH] PR comments. --- .../app/forms/BBReferenceField.svelte | 26 ++++++++++++++----- .../app/forms/RelationshipField.svelte | 7 ++--- .../shared-core/src/sdk/documents/users.ts | 7 +++++ 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/packages/client/src/components/app/forms/BBReferenceField.svelte b/packages/client/src/components/app/forms/BBReferenceField.svelte index 4573452973..f93c955be2 100644 --- a/packages/client/src/components/app/forms/BBReferenceField.svelte +++ b/packages/client/src/components/app/forms/BBReferenceField.svelte @@ -1,17 +1,31 @@ { - if (Array.isArray(value)) { - return value.map(val => sdk.users.getGlobalUserID(val)) - } else { - return sdk.users.getGlobalUserID(value) - } + defaultValue={updateReferences(defaultValue)} + onChange={value => { + return updateReferences(value) }} /> diff --git a/packages/client/src/components/app/forms/RelationshipField.svelte b/packages/client/src/components/app/forms/RelationshipField.svelte index c114a51f87..52faf46615 100644 --- a/packages/client/src/components/app/forms/RelationshipField.svelte +++ b/packages/client/src/components/app/forms/RelationshipField.svelte @@ -18,7 +18,6 @@ export let filter export let datasourceType = "table" export let primaryDisplay - export let valueConversion let fieldState let fieldApi @@ -162,7 +161,7 @@ const changed = fieldApi.setValue(value) if (onChange && changed) { onChange({ - value: valueConversion ? valueConversion(value) : value, + value, }) } } @@ -179,9 +178,7 @@ {field} {disabled} {validation} - defaultValue={valueConversion - ? valueConversion(expandedDefaultValue) - : expandedDefaultValue} + defaultValue={expandedDefaultValue} {type} bind:fieldState bind:fieldApi diff --git a/packages/shared-core/src/sdk/documents/users.ts b/packages/shared-core/src/sdk/documents/users.ts index cb171cfd5b..03d86daa85 100644 --- a/packages/shared-core/src/sdk/documents/users.ts +++ b/packages/shared-core/src/sdk/documents/users.ts @@ -84,3 +84,10 @@ export function getGlobalUserID(userId?: string): string | undefined { } return userId.split(prefix)[1] } + +export function containsUserID(value: string | undefined): boolean { + if (typeof value !== "string") { + return false + } + return value.includes(`${DocumentType.USER}${SEPARATOR}`) +}