From 927be235457868cddd5e54eb23c72af2849a4ce2 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Mon, 23 Mar 2020 10:43:34 +0000 Subject: [PATCH] solving initial table load issue --- .../builder/src/database/DatabaseRoot.svelte | 6 +- .../ModelDataTable/ModelDataTable.svelte | 151 +++++++++--------- packages/builder/src/nav/BackendNav.svelte | 2 +- 3 files changed, 79 insertions(+), 80 deletions(-) diff --git a/packages/builder/src/database/DatabaseRoot.svelte b/packages/builder/src/database/DatabaseRoot.svelte index 83d40b7f4e..412e9bf65b 100644 --- a/packages/builder/src/database/DatabaseRoot.svelte +++ b/packages/builder/src/database/DatabaseRoot.svelte @@ -76,7 +76,11 @@ {/if} - + {#if $backendUiStore.selectedDatabase.id} + + {:else} + Please select a database + {/if} diff --git a/packages/builder/src/database/ModelDataTable/ModelDataTable.svelte b/packages/builder/src/database/ModelDataTable/ModelDataTable.svelte index e4996e9883..697926bd3e 100644 --- a/packages/builder/src/database/ModelDataTable/ModelDataTable.svelte +++ b/packages/builder/src/database/ModelDataTable/ModelDataTable.svelte @@ -21,7 +21,7 @@ $: views = $store.hierarchy.indexes $: currentAppInfo = { appname: $store.appname, - instanceId: $backendUiStore.selectedDatabase.id + instanceId: $backendUiStore.selectedDatabase.id, } $: data = $backendUiStore.selectedView.records.slice( currentPage * ITEMS_PER_PAGE, @@ -43,93 +43,88 @@ } onMount(async () => { - if (showTable) { + if (views.length > 0) { await fetchRecordsForView(views[0].name, currentAppInfo) } }) -{#if showTable} -
-
-

{$backendUiStore.selectedDatabase.name || ""}

- fetchRecordsForView(e.target.value)}> + {#each views as view} + + {/each} + +
+ + + + + {#each headers as header} + {/each} - - -
Edit{header}
- - - - {#each headers as header} - - {/each} - - - - {#if data.length === 0} -
No Data.
- {/if} - {#each data as row} - - + {#if data.length === 0} +
No Data.
+ {/if} + {#each data as row} + + - {#each headers as header} - - {/each} - - {/each} - -
Edit{header}
-
- -
-
    -
  • -
    { - // fetch the child records for that particular row - }}> - View -
    -
  • -
  • + +
+
+ +
+
    +
  • +
    {}}>View
    +
  • +
  • { + selectRecord(row) + backendUiStore.actions.modals.show('RECORD') + }}> +
    Edit
    +
  • +
  • +
    { selectRecord(row) - backendUiStore.actions.modals.show('RECORD') + backendUiStore.actions.modals.show('DELETE_RECORD') }}> -
    Edit
    -
  • -
  • -
    { - selectRecord(row) - backendUiStore.actions.modals.show('DELETE_RECORD') - }}> - Delete -
    -
  • -
  • -
    { - const response = await api.saveRecord(row) - }}> - Duplicate -
    -
  • -
-
+ Delete +
+ +
  • +
    { + const response = await api.saveRecord(row) + }}> + Duplicate +
    +
  • + -
    {row[header]}
    - -
    -{:else} - Please select a database. -{/if} - + + + {#each headers as header} + {row[header]} + {/each} + + {/each} + + + +