From 6e36e5d06aca836494f5f56edaca7fd98dd88a6b Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Tue, 29 Jun 2021 19:57:26 +0100 Subject: [PATCH] listing relationships in UI --- .../TableNavigator/TableNavigator.svelte | 8 +++++-- .../[selectedDatasource]/index.svelte | 24 +++++++++++++++---- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/packages/builder/src/components/backend/TableNavigator/TableNavigator.svelte b/packages/builder/src/components/backend/TableNavigator/TableNavigator.svelte index 4291738d3d..323d484fab 100644 --- a/packages/builder/src/components/backend/TableNavigator/TableNavigator.svelte +++ b/packages/builder/src/components/backend/TableNavigator/TableNavigator.svelte @@ -6,9 +6,13 @@ import EditViewPopover from "./popovers/EditViewPopover.svelte" import NavItem from "components/common/NavItem.svelte" + const alphabetical = (a, b) => a.name?.toLowerCase() > b.name?.toLowerCase() + export let sourceId + $: selectedView = $views.selected && $views.selected.name + $: sortedTables = $tables.list.filter(table => table.sourceId === sourceId).sort(alphabetical) function selectTable(table) { tables.select(table) @@ -33,7 +37,7 @@ {#if $database?._id}
- {#each $tables.list.filter(table => table.sourceId === sourceId) as table, idx} + {#each sortedTables as table, idx} 0} @@ -46,7 +50,7 @@ {/if} - {#each Object.keys(table.views || {}) as viewName, idx (idx)} + {#each [...Object.keys(table.views || {})].sort() as viewName, idx (idx)}
{#each plusTables as table} - {#each Object.keys(table) as column} - {#if table[column].type === "link"} + {#each Object.keys(table.schema) as column} + {#if table.schema[column].type === "link"}
onClickTable(table[column])} + on:click={() => onClickTable(table.schema[column])} > -

{table[column].name}

-

Primary Key: {table[column].primary}

+

{table.schema[column].name}

+

{buildRelationshipDisplayString(table, table.schema[column])}

+

{/if}