From 143177a0d5bb51bcc683df2617a343bafa74d6c9 Mon Sep 17 00:00:00 2001 From: Michael Shanks Date: Fri, 16 Oct 2020 21:50:58 +0100 Subject: [PATCH] Primary display column is always required --- .../popovers/CreateEditColumnPopover.svelte | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/builder/src/components/backend/DataTable/popovers/CreateEditColumnPopover.svelte b/packages/builder/src/components/backend/DataTable/popovers/CreateEditColumnPopover.svelte index e803ca21cf..9549041a18 100644 --- a/packages/builder/src/components/backend/DataTable/popovers/CreateEditColumnPopover.svelte +++ b/packages/builder/src/components/backend/DataTable/popovers/CreateEditColumnPopover.svelte @@ -40,7 +40,7 @@ $: tableOptions = $backendUiStore.tables.filter( table => table._id !== $backendUiStore.draftTable._id ) - $: required = !!field?.constraints?.presence + $: required = !!field?.constraints?.presence || primaryDisplay async function saveColumn() { backendUiStore.update(state => { @@ -67,6 +67,14 @@ field.constraints.presence = req ? { allowEmpty: false } : false required = req } + + function onChangePrimaryDisplay(e) { + const isPrimary = e.target.checked + // primary display is always required + if (isPrimary) { + field.constraints.presence = { allowEmpty: false } + } + }
@@ -88,6 +96,7 @@ {/if} @@ -95,6 +104,7 @@ {#if field.type !== 'link'} {/if}