From d313968eaa69f07306db5bf207135d96a8c1c380 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 15 Aug 2024 16:33:39 +0100 Subject: [PATCH] Add view CRUD and table editing via new UI --- .../backend/DataTable/TableDataTable.svelte | 4 -- .../DatasourceNavigator.svelte | 4 +- .../TableNavigator/TableNavigator.svelte | 5 +- .../backend/TableNavigator/utils.js | 4 ++ .../_components/CreateViewModal.svelte} | 54 ++++++++++--------- .../[tableId]/_components/ViewNavBar.svelte | 41 ++++++++++---- 6 files changed, 66 insertions(+), 46 deletions(-) rename packages/builder/src/{components/backend/DataTable/modals/grid/GridCreateViewModal.svelte => pages/builder/app/[application]/data/table/[tableId]/_components/CreateViewModal.svelte} (51%) diff --git a/packages/builder/src/components/backend/DataTable/TableDataTable.svelte b/packages/builder/src/components/backend/DataTable/TableDataTable.svelte index 22a7fabf24..2dd1eec0a8 100644 --- a/packages/builder/src/components/backend/DataTable/TableDataTable.svelte +++ b/packages/builder/src/components/backend/DataTable/TableDataTable.svelte @@ -9,7 +9,6 @@ import GridAddColumnModal from "components/backend/DataTable/modals/grid/GridCreateColumnModal.svelte" import GridCreateEditRowModal from "components/backend/DataTable/modals/grid/GridCreateEditRowModal.svelte" import GridEditUserModal from "components/backend/DataTable/modals/grid/GridEditUserModal.svelte" - import GridCreateViewButton from "components/backend/DataTable/buttons/grid/GridCreateViewButton.svelte" import GridImportButton from "components/backend/DataTable/buttons/grid/GridImportButton.svelte" import GridExportButton from "components/backend/DataTable/buttons/grid/GridExportButton.svelte" import GridFilterButton from "components/backend/DataTable/buttons/grid/GridFilterButton.svelte" @@ -77,9 +76,6 @@ - {#if !isUsersTable} - - {/if} {#if !isUsersTable} diff --git a/packages/builder/src/components/backend/DatasourceNavigator/DatasourceNavigator.svelte b/packages/builder/src/components/backend/DatasourceNavigator/DatasourceNavigator.svelte index e0745c15a1..a6078e38fb 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/DatasourceNavigator.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/DatasourceNavigator.svelte @@ -39,9 +39,7 @@ const selectTable = tableId => { tables.select(tableId) - if (!$isActive("./table/:tableId")) { - $goto(`./table/${tableId}`) - } + $goto(`./table/${tableId}`) } function openNode(datasource) { diff --git a/packages/builder/src/components/backend/TableNavigator/TableNavigator.svelte b/packages/builder/src/components/backend/TableNavigator/TableNavigator.svelte index 6ab500b65d..f97bd2487b 100644 --- a/packages/builder/src/components/backend/TableNavigator/TableNavigator.svelte +++ b/packages/builder/src/components/backend/TableNavigator/TableNavigator.svelte @@ -1,14 +1,11 @@
diff --git a/packages/builder/src/components/backend/TableNavigator/utils.js b/packages/builder/src/components/backend/TableNavigator/utils.js index ae7aaa0f0a..a76a14c1a4 100644 --- a/packages/builder/src/components/backend/TableNavigator/utils.js +++ b/packages/builder/src/components/backend/TableNavigator/utils.js @@ -66,3 +66,7 @@ export const parseFile = e => { reader.readAsText(file) }) } + +export const alphabetical = (a, b) => { + return a.name?.toLowerCase() > b.name?.toLowerCase() ? 1 : -1 +} diff --git a/packages/builder/src/components/backend/DataTable/modals/grid/GridCreateViewModal.svelte b/packages/builder/src/pages/builder/app/[application]/data/table/[tableId]/_components/CreateViewModal.svelte similarity index 51% rename from packages/builder/src/components/backend/DataTable/modals/grid/GridCreateViewModal.svelte rename to packages/builder/src/pages/builder/app/[application]/data/table/[tableId]/_components/CreateViewModal.svelte index eea64a4d9e..77477054b8 100644 --- a/packages/builder/src/components/backend/DataTable/modals/grid/GridCreateViewModal.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/table/[tableId]/_components/CreateViewModal.svelte @@ -1,16 +1,21 @@ - - - + + + + + diff --git a/packages/builder/src/pages/builder/app/[application]/data/table/[tableId]/_components/ViewNavBar.svelte b/packages/builder/src/pages/builder/app/[application]/data/table/[tableId]/_components/ViewNavBar.svelte index 20ecdc3f83..fb7d46f259 100644 --- a/packages/builder/src/pages/builder/app/[application]/data/table/[tableId]/_components/ViewNavBar.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/table/[tableId]/_components/ViewNavBar.svelte @@ -6,7 +6,7 @@ contextMenuStore, } from "stores/builder" import IntegrationIcon from "components/backend/DatasourceNavigator/IntegrationIcon.svelte" - import { Icon } from "@budibase/bbui" + import { Icon, Button } from "@budibase/bbui" import { params, url } from "@roxi/routify" import EditViewModal from "./EditViewModal.svelte" import DeleteViewModal from "./DeleteViewModal.svelte" @@ -16,8 +16,11 @@ import { tick } from "svelte" import { DB_TYPE_EXTERNAL } from "constants/backend" import { TableNames } from "constants" + import { alphabetical } from "components/backend/TableNavigator/utils" + import CreateViewModal from "./CreateViewModal.svelte" // Editing table + let createViewModal let editTableModal let deleteTableModal @@ -101,10 +104,6 @@ } ) } - - const alphabetical = (a, b) => { - return a.name < b.name ? -1 : 1 - }
@@ -126,7 +125,13 @@ {/if} {#if tableEditable} - + {/if} {#each views as view (view.id)} @@ -145,15 +150,33 @@ {/if} openViewContextMenu(e, view)} - s hoverable name="MoreSmallList" + color="var(--spectrum-global-color-gray-600)" + hoverColor="var(--spectrum-global-color-gray-900)" /> {/each} + {#if !views.length && tableEditable} + + + To create subsets of data, control access and more, create a view. + + {/if} + {#if views.length} + + {/if}
-{#if table} +{#if table && tableEditable} + {/if} @@ -183,7 +206,7 @@ align-items: center; gap: var(--spacing-m); transition: background 130ms ease-out, color 130ms ease-out; - color: var(--spectrum-global-color-gray-700); + color: var(--spectrum-global-color-gray-600); } .title { font-size: 16px;