Linting.
This commit is contained in:
parent
478a851956
commit
568128479f
|
@ -1,6 +1,13 @@
|
||||||
<script>
|
<script>
|
||||||
import { RelationshipTypes } from "constants/backend"
|
import { RelationshipTypes } from "constants/backend"
|
||||||
import { Button, Input, ModalContent, Select, Detail, Body } from "@budibase/bbui"
|
import {
|
||||||
|
Button,
|
||||||
|
Input,
|
||||||
|
ModalContent,
|
||||||
|
Select,
|
||||||
|
Detail,
|
||||||
|
Body,
|
||||||
|
} from "@budibase/bbui"
|
||||||
import { tables } from "stores/backend"
|
import { tables } from "stores/backend"
|
||||||
import { uuid } from "builderStore/uuid"
|
import { uuid } from "builderStore/uuid"
|
||||||
import { writable } from "svelte/store"
|
import { writable } from "svelte/store"
|
||||||
|
@ -25,8 +32,15 @@
|
||||||
|
|
||||||
const touched = writable({})
|
const touched = writable({})
|
||||||
|
|
||||||
function checkForErrors(fromTable, toTable, throughTable, fromRelate, toRelate) {
|
function checkForErrors(
|
||||||
const isMany = fromRelate.relationshipType === RelationshipTypes.MANY_TO_MANY
|
fromTable,
|
||||||
|
toTable,
|
||||||
|
throughTable,
|
||||||
|
fromRelate,
|
||||||
|
toRelate
|
||||||
|
) {
|
||||||
|
const isMany =
|
||||||
|
fromRelate.relationshipType === RelationshipTypes.MANY_TO_MANY
|
||||||
const tableNotSet = "Please specify a table"
|
const tableNotSet = "Please specify a table"
|
||||||
const errors = {}
|
const errors = {}
|
||||||
if ($touched.from && !fromTable) {
|
if ($touched.from && !fromTable) {
|
||||||
|
@ -55,7 +69,10 @@
|
||||||
if (toTable && (toTable === fromTable || toTable === throughTable)) {
|
if (toTable && (toTable === fromTable || toTable === throughTable)) {
|
||||||
errors.to = tableError
|
errors.to = tableError
|
||||||
}
|
}
|
||||||
if (throughTable && (throughTable === fromTable || throughTable === toTable)) {
|
if (
|
||||||
|
throughTable &&
|
||||||
|
(throughTable === fromTable || throughTable === toTable)
|
||||||
|
) {
|
||||||
errors.through = tableError
|
errors.through = tableError
|
||||||
}
|
}
|
||||||
const colError = "Column name cannot be an existing column"
|
const colError = "Column name cannot be an existing column"
|
||||||
|
@ -75,8 +92,15 @@
|
||||||
$: fromTable = plusTables.find(table => table._id === toRelationship?.tableId)
|
$: fromTable = plusTables.find(table => table._id === toRelationship?.tableId)
|
||||||
$: toTable = plusTables.find(table => table._id === fromRelationship?.tableId)
|
$: toTable = plusTables.find(table => table._id === fromRelationship?.tableId)
|
||||||
$: through = plusTables.find(table => table._id === fromRelationship?.through)
|
$: through = plusTables.find(table => table._id === fromRelationship?.through)
|
||||||
$: errors = checkForErrors(fromTable, toTable, through, fromRelationship, toRelationship)
|
$: errors = checkForErrors(
|
||||||
$: valid = Object.keys(errors).length === 0 && Object.keys($touched).length !== 0
|
fromTable,
|
||||||
|
toTable,
|
||||||
|
through,
|
||||||
|
fromRelationship,
|
||||||
|
toRelationship
|
||||||
|
)
|
||||||
|
$: valid =
|
||||||
|
Object.keys(errors).length === 0 && Object.keys($touched).length !== 0
|
||||||
$: linkTable = through || toTable
|
$: linkTable = through || toTable
|
||||||
$: relationshipTypes = [
|
$: relationshipTypes = [
|
||||||
{
|
{
|
||||||
|
@ -230,12 +254,22 @@
|
||||||
<Detail>Column names</Detail>
|
<Detail>Column names</Detail>
|
||||||
</div>
|
</div>
|
||||||
<Body>
|
<Body>
|
||||||
Budibase manages SQL relationships as a new column in the table, please provide a name for these columns.
|
Budibase manages SQL relationships as a new column in the table, please
|
||||||
|
provide a name for these columns.
|
||||||
</Body>
|
</Body>
|
||||||
<Input on:blur={() => ($touched.fromCol = true)} bind:error={errors.fromCol} label="From table column" bind:value={fromRelationship.name} />
|
<Input
|
||||||
<Input on:blur={() => ($touched.toCol = true)} bind:error={errors.toCol} label="To table column" bind:value={toRelationship.name} />
|
on:blur={() => ($touched.fromCol = true)}
|
||||||
|
bind:error={errors.fromCol}
|
||||||
|
label="From table column"
|
||||||
|
bind:value={fromRelationship.name}
|
||||||
|
/>
|
||||||
|
<Input
|
||||||
|
on:blur={() => ($touched.toCol = true)}
|
||||||
|
bind:error={errors.toCol}
|
||||||
|
label="To table column"
|
||||||
|
bind:value={toRelationship.name}
|
||||||
|
/>
|
||||||
<div slot="footer">
|
<div slot="footer">
|
||||||
|
|
||||||
{#if originalFromName != null}
|
{#if originalFromName != null}
|
||||||
<Button warning text on:click={deleteRelationship}>Delete</Button>
|
<Button warning text on:click={deleteRelationship}>Delete</Button>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
Loading…
Reference in New Issue