Quick fixes for UI, making sure relationships UI not displayed unless tables exist and fixing issue with through being sent up with one-to-many.

This commit is contained in:
mike12345567 2021-07-05 11:03:54 +01:00
parent dcd4774693
commit 8254880fa8
2 changed files with 24 additions and 19 deletions

View File

@ -61,6 +61,10 @@
fromRelationship.relationshipType === RelationshipTypes.MANY_TO_MANY fromRelationship.relationshipType === RelationshipTypes.MANY_TO_MANY
// main is simply used to know this is the side the user configured it from // main is simply used to know this is the side the user configured it from
const id = uuid() const id = uuid()
if (!manyToMany) {
delete fromRelationship.through
delete toRelationship.through
}
let relateFrom = { let relateFrom = {
...fromRelationship, ...fromRelationship,
type: "link", type: "link",
@ -154,21 +158,21 @@
bind:value={toRelationship.tableId} bind:value={toRelationship.tableId}
/> />
<Select <Select
label={"Select to table"} label={"Select to table"}
options={tableOptions} options={tableOptions}
bind:value={fromRelationship.tableId} bind:value={fromRelationship.tableId}
/> />
{#if fromRelationship?.relationshipType === RelationshipTypes.MANY_TO_MANY} {#if fromRelationship?.relationshipType === RelationshipTypes.MANY_TO_MANY}
<Select <Select
label={"Through"} label={"Through"}
options={tableOptions} options={tableOptions}
bind:value={fromRelationship.through} bind:value={fromRelationship.through}
/> />
{:else if toTable} {:else if toTable}
<Select <Select
label={`Foreign Key (${toTable?.name})`} label={`Foreign Key (${toTable?.name})`}
options={Object.keys(toTable?.schema)} options={Object.keys(toTable?.schema)}
bind:value={fromRelationship.fieldName} bind:value={fromRelationship.fieldName}
/> />
{/if} {/if}
<div class="headings"> <div class="headings">

View File

@ -198,18 +198,19 @@
</div> </div>
{/each} {/each}
</div> </div>
{#if plusTables?.length !== 0}
<Divider /> <Divider />
<div class="query-header"> <div class="query-header">
<Heading size="S">Relationships</Heading> <Heading size="S">Relationships</Heading>
<Button primary on:click={() => openRelationshipModal()} <Button primary on:click={() => openRelationshipModal()}
>Create Relationship</Button >Create Relationship</Button
> >
</div> </div>
<Body> <Body>
Tell budibase how your tables are related to get even more smart Tell budibase how your tables are related to get even more smart
features. features.
</Body> </Body>
{/if}
<div class="query-list"> <div class="query-list">
{#each Object.values(relationships) as relationship} {#each Object.values(relationships) as relationship}
<div <div