From 4682b34f05356f80ca15d42b2a19d16f2343c7f2 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 8 Oct 2020 10:41:20 +0100 Subject: [PATCH] Improve relationship datatable title when no primary display is selected for a model --- .../backend/DataTable/RelationshipDataTable.svelte | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/builder/src/components/backend/DataTable/RelationshipDataTable.svelte b/packages/builder/src/components/backend/DataTable/RelationshipDataTable.svelte index 7a1ebbed78..6712b8cf68 100644 --- a/packages/builder/src/components/backend/DataTable/RelationshipDataTable.svelte +++ b/packages/builder/src/components/backend/DataTable/RelationshipDataTable.svelte @@ -9,6 +9,7 @@ export let fieldName let record + let title $: data = record?.[fieldName] ?? [] $: linkedModelId = data?.length ? data[0].modelId : null @@ -17,8 +18,15 @@ ) $: schema = linkedModel?.schema $: model = $backendUiStore.models.find(model => model._id === modelId) - $: title = `${record?.[model?.primaryDisplay]} - ${fieldName}` $: fetchData(modelId, recordId) + $: { + let recordLabel = record?.[model?.primaryDisplay] + if (recordLabel) { + title = `${recordLabel} - ${fieldName}` + } else { + title = fieldName + } + } async function fetchData(modelId, recordId) { const QUERY_VIEW_URL = `/api/${modelId}/${recordId}/enrich`