From 0dd432f286bfe8897a20f668049346f5640c2929 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 23 Aug 2024 13:34:36 +0100 Subject: [PATCH] Add support for old views in new view nav bar --- .../[tableId]/_components/ViewNavBar.svelte | 46 +++++++++++++++--- .../[tableId]}/v1/[viewName]/_layout.svelte | 0 .../[tableId]}/v1/[viewName]/index.svelte | 47 ++++++++++--------- .../{view => table/[tableId]}/v1/index.svelte | 0 .../app/[application]/data/view/index.svelte | 19 -------- packages/client/src/constants.js | 3 +- 6 files changed, 68 insertions(+), 47 deletions(-) rename packages/builder/src/pages/builder/app/[application]/data/{view => table/[tableId]}/v1/[viewName]/_layout.svelte (100%) rename packages/builder/src/pages/builder/app/[application]/data/{view => table/[tableId]}/v1/[viewName]/index.svelte (75%) rename packages/builder/src/pages/builder/app/[application]/data/{view => table/[tableId]}/v1/index.svelte (100%) delete mode 100644 packages/builder/src/pages/builder/app/[application]/data/view/index.svelte 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 cc62eb78d5..5d3f3ac5b4 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 @@ -48,12 +48,18 @@ $: datasource = $datasources.list.find(ds => ds._id === table?.sourceId) $: tableSelectedBy = $userSelectedResourceMap[table?._id] $: tableEditable = table?._id !== TableNames.USERS - $: activeId = $params.viewId ?? $params.tableId + $: activeId = $params.viewName ?? $params.viewId ?? $params.tableId $: views = Object.values(table?.views || {}) .filter(x => x.version === 2) .slice() .sort(alphabetical) + $: v1Views = Object.values(table?.views || {}) + .filter(x => x.version !== 2) + .slice() + .sort(alphabetical) $: setUpObserver(views) + $: hasViews = v1Views.length || views.length + $: overflowedViews = views.filter(view => !viewVisibiltyMap[view.id]) $: viewHidden = viewVisibiltyMap[activeId] === false @@ -61,6 +67,10 @@ return $url(`../${$params.tableId}/${encodeURIComponent(viewId)}`) }) + const viewV1Url = derived([url, params], ([$url, $params]) => viewName => { + return $url(`../${$params.tableId}/v1/${encodeURIComponent(viewName)}`) + }) + const tableUrl = derived(url, $url => tableId => $url(`../${tableId}`)) const openTableContextMenu = e => { @@ -176,8 +186,8 @@