Validation improvements
This commit is contained in:
parent
d7ae20ce21
commit
dfd6575aea
|
@ -84,10 +84,10 @@
|
||||||
errObj.foreign = "Please pick the foreign key"
|
errObj.foreign = "Please pick the foreign key"
|
||||||
}
|
}
|
||||||
const colNotSet = "Please specify a column name"
|
const colNotSet = "Please specify a column name"
|
||||||
if ($touched.fromCol && !fromRelate.name) {
|
if ($touched.fromCol && !toRelate.name) {
|
||||||
errObj.fromCol = colNotSet
|
errObj.fromCol = colNotSet
|
||||||
}
|
}
|
||||||
if ($touched.toCol && !toRelate.name) {
|
if ($touched.toCol && !fromRelate.name) {
|
||||||
errObj.toCol = colNotSet
|
errObj.toCol = colNotSet
|
||||||
}
|
}
|
||||||
if ($touched.primary && !fromPrimary) {
|
if ($touched.primary && !fromPrimary) {
|
||||||
|
@ -143,7 +143,10 @@
|
||||||
$: through = plusTables.find(table => table._id === fromRelationship?.through)
|
$: through = plusTables.find(table => table._id === fromRelationship?.through)
|
||||||
$: checkForErrors(fromRelationship, toRelationship)
|
$: checkForErrors(fromRelationship, toRelationship)
|
||||||
$: valid =
|
$: 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
|
$: linkTable = through || toTable
|
||||||
$: relationshipTypes = [
|
$: relationshipTypes = [
|
||||||
{
|
{
|
||||||
|
@ -293,7 +296,10 @@
|
||||||
label="Select from table"
|
label="Select from table"
|
||||||
options={tableOptions}
|
options={tableOptions}
|
||||||
disabled={!!selectedFromTable}
|
disabled={!!selectedFromTable}
|
||||||
on:change={() => ($touched.from = true)}
|
on:change={() => {
|
||||||
|
$touched.from = true
|
||||||
|
$touched.primary = true
|
||||||
|
}}
|
||||||
bind:error={errors.from}
|
bind:error={errors.from}
|
||||||
bind:value={toRelationship.tableId}
|
bind:value={toRelationship.tableId}
|
||||||
/>
|
/>
|
||||||
|
@ -309,7 +315,10 @@
|
||||||
<Select
|
<Select
|
||||||
label={"Select to table"}
|
label={"Select to table"}
|
||||||
options={tableOptions}
|
options={tableOptions}
|
||||||
on:change={() => ($touched.to = true)}
|
on:change={() => {
|
||||||
|
$touched.to = true
|
||||||
|
$touched.foreign = true
|
||||||
|
}}
|
||||||
bind:error={errors.to}
|
bind:error={errors.to}
|
||||||
bind:value={fromRelationship.tableId}
|
bind:value={fromRelationship.tableId}
|
||||||
/>
|
/>
|
||||||
|
@ -317,7 +326,11 @@
|
||||||
<Select
|
<Select
|
||||||
label={"Through"}
|
label={"Through"}
|
||||||
options={tableOptions}
|
options={tableOptions}
|
||||||
on:change={() => ($touched.through = true)}
|
on:change={() => {
|
||||||
|
$touched.through = true
|
||||||
|
$touched.fromForeign = true
|
||||||
|
$touched.toForeign = true
|
||||||
|
}}
|
||||||
bind:error={errors.through}
|
bind:error={errors.through}
|
||||||
bind:value={fromRelationship.through}
|
bind:value={fromRelationship.through}
|
||||||
/>
|
/>
|
||||||
|
@ -355,15 +368,17 @@
|
||||||
</Body>
|
</Body>
|
||||||
<Input
|
<Input
|
||||||
on:blur={() => ($touched.fromCol = true)}
|
on:blur={() => ($touched.fromCol = true)}
|
||||||
|
on:change={() => ($touched.fromCol = true)}
|
||||||
bind:error={errors.fromCol}
|
bind:error={errors.fromCol}
|
||||||
label="From table column"
|
label="From table column"
|
||||||
bind:value={fromRelationship.name}
|
bind:value={toRelationship.name}
|
||||||
/>
|
/>
|
||||||
<Input
|
<Input
|
||||||
on:blur={() => ($touched.toCol = true)}
|
on:blur={() => ($touched.toCol = true)}
|
||||||
|
on:change={() => ($touched.toCol = true)}
|
||||||
bind:error={errors.toCol}
|
bind:error={errors.toCol}
|
||||||
label="To table column"
|
label="To table column"
|
||||||
bind:value={toRelationship.name}
|
bind:value={fromRelationship.name}
|
||||||
/>
|
/>
|
||||||
<div slot="footer">
|
<div slot="footer">
|
||||||
{#if originalFromName != null}
|
{#if originalFromName != null}
|
||||||
|
|
Loading…
Reference in New Issue