diff --git a/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/CreateEditRelationship.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/CreateEditRelationship.svelte
deleted file mode 100644
index b9f6dbf092..0000000000
--- a/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/CreateEditRelationship.svelte
+++ /dev/null
@@ -1,79 +0,0 @@
-
-
-
- {#if step === 0}
- Select your table
- {:else if step === 1}
-
- Step 2
- {:else if step === 2}
- Step 3
- {/if}
-
-
-
\ No newline at end of file
diff --git a/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/CreateEditRelationship/CreateEditRelationship.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/CreateEditRelationship/CreateEditRelationship.svelte
index cbab467e40..0ed5a93c0a 100644
--- a/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/CreateEditRelationship/CreateEditRelationship.svelte
+++ b/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/CreateEditRelationship/CreateEditRelationship.svelte
@@ -2,33 +2,44 @@
import { RelationshipTypes } from "constants/backend"
import { Menu, MenuItem, MenuSection, Button, Input, Icon, ModalContent, RadioGroup, Heading } from "@budibase/bbui"
+ // "tasks_something": {
+ // "name": "tasks_something",
+ // "type": "link",
+ // "tableId": "whatever/othertable",
+ // "relationshipType": "one-to-many",
+ // },
+
export let save
export let datasource
+ export let from
export let tables
-
- let relationship = {}
+ export let relationship = {}
$: console.log(relationship)
- $: console.log("ds", datasource)
- $: valid = relationship.name && relationship.from && relationship.to && relationship.relationshipType
+ $: valid = relationship.name && relationship.tableId && relationship.relationshipType
+ $: from = tables.find(table => table._id === relationship.source)
+ $: to = tables.find(table => table._id === relationship.tableId)
+ $: through = tables.find(table => table._id === relationship.through)
+ $: linkTable = through || to
- $: relationshipOptions = relationship.from && relationship.to ? [
+ $: relationshipOptions = from && to ? [
{
- name: `Many ${relationship.from.name} rows → many ${relationship.to.name} rows`,
- alt: `Many ${relationship.from.name} rows → many ${relationship.to.name} rows`,
+ name: `Many ${from.name} rows → many ${to.name} rows`,
+ alt: `Many ${from.name} rows → many ${to.name} rows`,
value: RelationshipTypes.MANY_TO_MANY,
},
{
- name: `One ${relationship.from.name} row → many ${relationship.to.name} rows`,
- alt: `One ${relationship.from.name} rows → many ${relationship.to.name} rows`,
+ name: `One ${from.name} row → many ${to.name} rows`,
+ alt: `One ${from.name} rows → many ${to.name} rows`,
value: RelationshipTypes.ONE_TO_MANY,
- },
- {
- name: `One ${relationship.from.name} row → many ${relationship.to.name} rows`,
- alt: `One ${relationship.from.name} row → many ${relationship.to.name} rows`,
- value: RelationshipTypes.MANY_TO_ONE,
- },
+ }
] : []
+
+ function onChangeRelationshipType(evt) {
+ if (evt.detail === RelationshipTypes.ONE_TO_MANY) {
+ relationship.through = null
+ }
+ }
// save the relationship on to the datasource
function saveRelationship() {
@@ -67,9 +78,9 @@