diff --git a/packages/builder/src/builderStore/store/backend.js b/packages/builder/src/builderStore/store/backend.js
index d89796f9cc..bd993b5af0 100644
--- a/packages/builder/src/builderStore/store/backend.js
+++ b/packages/builder/src/builderStore/store/backend.js
@@ -91,7 +91,7 @@ export const getBackendUiStore = () => {
return state
})
},
- saveField: ({ originalName, field }) => {
+ saveField: ({ originalName, field, primaryDisplay = false }) => {
store.update(state => {
// delete the original if renaming
if (originalName) {
@@ -102,8 +102,12 @@ export const getBackendUiStore = () => {
}
}
- state.draftTable.schema[field.name] = cloneDeep(field)
+ // Optionally set primary display
+ if (primaryDisplay) {
+ state.draftTable.primaryDisplay = field.name
+ }
+ state.draftTable.schema[field.name] = cloneDeep(field)
store.actions.tables.save(state.draftTable)
return state
})
diff --git a/packages/builder/src/components/backend/DataTable/popovers/CreateEditColumnPopover.svelte b/packages/builder/src/components/backend/DataTable/popovers/CreateEditColumnPopover.svelte
index 14755ce6fe..3748e4ed98 100644
--- a/packages/builder/src/components/backend/DataTable/popovers/CreateEditColumnPopover.svelte
+++ b/packages/builder/src/components/backend/DataTable/popovers/CreateEditColumnPopover.svelte
@@ -28,9 +28,15 @@
export let field = {
type: "string",
constraints: fieldDefinitions.STRING.constraints,
+
+ // Initial value for column name in other table for linked records
+ fieldName: $backendUiStore.selectedTable.name,
}
let originalName = field.name
+ let primaryDisplay =
+ $backendUiStore.selectedTable.primaryDisplay == null ||
+ $backendUiStore.selectedTable.primaryDisplay === field.name
$: tableOptions = $backendUiStore.tables.filter(
table => table._id !== $backendUiStore.draftTable._id
)
@@ -41,6 +47,7 @@
backendUiStore.actions.tables.saveField({
originalName,
field,
+ primaryDisplay,
})
return state
})
@@ -86,6 +93,13 @@
text="Required" />
{/if}
+ {#if field.type !== 'link'}
+
+ {/if}
+
{#if field.type === 'string'}
-