From dfd6575aeab8cb2febfc80e96d331f704a4ac9b6 Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Fri, 13 Jan 2023 15:01:21 +0000 Subject: [PATCH] Validation improvements --- .../Datasources/CreateEditRelationship.svelte | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/packages/builder/src/components/backend/Datasources/CreateEditRelationship.svelte b/packages/builder/src/components/backend/Datasources/CreateEditRelationship.svelte index 74bba33baa..b18809e980 100644 --- a/packages/builder/src/components/backend/Datasources/CreateEditRelationship.svelte +++ b/packages/builder/src/components/backend/Datasources/CreateEditRelationship.svelte @@ -84,10 +84,10 @@ errObj.foreign = "Please pick the foreign key" } const colNotSet = "Please specify a column name" - if ($touched.fromCol && !fromRelate.name) { + if ($touched.fromCol && !toRelate.name) { errObj.fromCol = colNotSet } - if ($touched.toCol && !toRelate.name) { + if ($touched.toCol && !fromRelate.name) { errObj.toCol = colNotSet } if ($touched.primary && !fromPrimary) { @@ -143,7 +143,10 @@ $: through = plusTables.find(table => table._id === fromRelationship?.through) $: checkForErrors(fromRelationship, toRelationship) $: valid = - Object.keys(errors).length === 0 && Object.keys($touched).length !== 0 + Object.keys(errors).length === 0 && + Object.keys($touched).length !== 0 && + fromTable && + toTable $: linkTable = through || toTable $: relationshipTypes = [ { @@ -293,7 +296,10 @@ label="Select from table" options={tableOptions} disabled={!!selectedFromTable} - on:change={() => ($touched.from = true)} + on:change={() => { + $touched.from = true + $touched.primary = true + }} bind:error={errors.from} bind:value={toRelationship.tableId} /> @@ -309,7 +315,10 @@ ($touched.through = true)} + on:change={() => { + $touched.through = true + $touched.fromForeign = true + $touched.toForeign = true + }} bind:error={errors.through} bind:value={fromRelationship.through} /> @@ -355,15 +368,17 @@ ($touched.fromCol = true)} + on:change={() => ($touched.fromCol = true)} bind:error={errors.fromCol} label="From table column" - bind:value={fromRelationship.name} + bind:value={toRelationship.name} /> ($touched.toCol = true)} + on:change={() => ($touched.toCol = true)} bind:error={errors.toCol} label="To table column" - bind:value={toRelationship.name} + bind:value={fromRelationship.name} />
{#if originalFromName != null}