From d0ef67dee0e994bf79006de7bf9f6ca21b311396 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 1 Oct 2020 07:19:38 +0100 Subject: [PATCH] Use common Table component across backend UI and add initial empty page for relationships --- .../backend/DataTable/ModelDataTable.svelte | 185 ++---------------- .../components/backend/DataTable/Table.svelte | 55 +++++- .../backend/DataTable/ViewDataTable.svelte | 34 ++-- .../backend/ModelNavigator/EditTable.svelte | 4 +- .../[selectedField]/index.svelte | 18 ++ .../[selectedRecord]/index.svelte | 6 + .../[selectedModel]/relationship/index.svelte | 6 + 7 files changed, 107 insertions(+), 201 deletions(-) create mode 100644 packages/builder/src/pages/[application]/backend/model/[selectedModel]/relationship/[selectedRecord]/[selectedField]/index.svelte create mode 100644 packages/builder/src/pages/[application]/backend/model/[selectedModel]/relationship/[selectedRecord]/index.svelte create mode 100644 packages/builder/src/pages/[application]/backend/model/[selectedModel]/relationship/index.svelte diff --git a/packages/builder/src/components/backend/DataTable/ModelDataTable.svelte b/packages/builder/src/components/backend/DataTable/ModelDataTable.svelte index 01bd9f43fe..6587451462 100644 --- a/packages/builder/src/components/backend/DataTable/ModelDataTable.svelte +++ b/packages/builder/src/components/backend/DataTable/ModelDataTable.svelte @@ -1,187 +1,30 @@ -
-

{$backendUiStore.selectedModel.name}

-
- - {#if Object.keys($backendUiStore.selectedModel.schema).length > 0} - - - {/if} -
- - - - - {#each headers as header} - - {/each} - - - - {#if paginatedData.length === 0} - - {#each headers as header} - - - {#each headers as header} - - {/each} - - {/each} - -
-
Edit
-
- -
No data. - {/each} - {/if} - {#each paginatedData as row} -
- - - {#if schema[header].type === 'link'} - {JSON.stringify(row[header])} - {:else if schema[header].type === 'attachment'} - - {:else}{getOr('', header, row)}{/if} -
- -
- - + + + {#if Object.keys(schema).length > 0} + + + {/if} +
diff --git a/packages/builder/src/components/backend/DataTable/Table.svelte b/packages/builder/src/components/backend/DataTable/Table.svelte index c58ea66ac8..3e5905c17a 100644 --- a/packages/builder/src/components/backend/DataTable/Table.svelte +++ b/packages/builder/src/components/backend/DataTable/Table.svelte @@ -1,4 +1,5 @@
@@ -47,13 +52,25 @@ + {#if allowEditing} + + {/if} {#each columns as header} - + {/each} {#if paginatedData.length === 0} + {#if allowEditing} + + {/if} {#each columns as header, idx} + {#if allowEditing} + + {/if} {#each columns as header} @@ -101,7 +129,6 @@ } thead th { color: var(--ink); - text-transform: capitalize; font-weight: 500; font-size: 14px; text-rendering: optimizeLegibility; @@ -149,4 +176,20 @@ :global(.popovers > div) { margin-right: var(--spacing-m); } + + .edit-header { + width: 60px; + } + .edit-header:hover { + cursor: default; + color: var(--ink); + } + + .link { + text-decoration: underline; + } + .link:hover { + color: var(--grey-6); + cursor: pointer; + } diff --git a/packages/builder/src/components/backend/DataTable/ViewDataTable.svelte b/packages/builder/src/components/backend/DataTable/ViewDataTable.svelte index 2710fdfc66..41ddc734b1 100644 --- a/packages/builder/src/components/backend/DataTable/ViewDataTable.svelte +++ b/packages/builder/src/components/backend/DataTable/ViewDataTable.svelte @@ -1,20 +1,6 @@ + +
hello world!
diff --git a/packages/builder/src/pages/[application]/backend/model/[selectedModel]/relationship/[selectedRecord]/index.svelte b/packages/builder/src/pages/[application]/backend/model/[selectedModel]/relationship/[selectedRecord]/index.svelte new file mode 100644 index 0000000000..0ab07a246b --- /dev/null +++ b/packages/builder/src/pages/[application]/backend/model/[selectedModel]/relationship/[selectedRecord]/index.svelte @@ -0,0 +1,6 @@ + + + diff --git a/packages/builder/src/pages/[application]/backend/model/[selectedModel]/relationship/index.svelte b/packages/builder/src/pages/[application]/backend/model/[selectedModel]/relationship/index.svelte new file mode 100644 index 0000000000..aa3b39f016 --- /dev/null +++ b/packages/builder/src/pages/[application]/backend/model/[selectedModel]/relationship/index.svelte @@ -0,0 +1,6 @@ + + +
+
Edit
+
{header} + {#if allowEditing} + + {:else}{header}{/if} +
No data. {#if idx === 0}No data.{/if} @@ -62,9 +79,20 @@ {/if} {#each paginatedData as row}
+ + - {#if schema[header].type === 'attachment'} + {#if schema[header].type === 'link'} + + {:else if schema[header].type === 'attachment'} {:else}{getOr('', header, row)}{/if}