From 2b8d4d9181d5607bdc5252241aa6347cc2584aab Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Mon, 17 Oct 2022 15:52:58 +0200 Subject: [PATCH 001/161] draft: onboarding --- src/lib/components/card.svelte | 13 +- src/lib/layout/shell.svelte | 12 +- src/lib/layout/wizard.svelte | 7 +- .../project-[project]/overview/+layout.svelte | 392 +++++++++--------- .../project-[project]/overview/onboard.svelte | 109 +++++ .../overview/platforms/+page.svelte | 29 +- src/routes/console/project-[project]/store.ts | 4 + 7 files changed, 355 insertions(+), 211 deletions(-) create mode 100644 src/routes/console/project-[project]/overview/onboard.svelte diff --git a/src/lib/components/card.svelte b/src/lib/components/card.svelte index a9d12f9bc..a1c5c3e90 100644 --- a/src/lib/components/card.svelte +++ b/src/lib/components/card.svelte @@ -1,7 +1,16 @@ -
+ -
+ diff --git a/src/lib/layout/shell.svelte b/src/lib/layout/shell.svelte index 79d720472..77357fa62 100644 --- a/src/lib/layout/shell.svelte +++ b/src/lib/layout/shell.svelte @@ -22,7 +22,7 @@ import { sdkForConsole } from '$lib/stores/sdk'; import { base } from '$app/paths'; import { user } from '$lib/stores/user'; - import { goto } from '$app/navigation'; + import { beforeNavigate, goto } from '$app/navigation'; import { browser } from '$app/environment'; import { wizard } from '$lib/stores/wizard'; @@ -67,6 +67,16 @@ } } }; + + beforeNavigate((n) => { + /** + * Hide wizard when navigation is triggered by popstate. + */ + if (n.type === 'popstate' && $wizard.show) { + wizard.hide(); + n.cancel(); + } + }); diff --git a/src/lib/layout/wizard.svelte b/src/lib/layout/wizard.svelte index ee46327de..97de61a1d 100644 --- a/src/lib/layout/wizard.svelte +++ b/src/lib/layout/wizard.svelte @@ -114,11 +114,12 @@
Users
- -
-
Sessions: XX
-
Date: Fri, 4 Nov 2022 12:16:38 +0100 Subject: [PATCH 092/161] fix: create document --- .../createDocument.svelte | 13 ++--- .../document-[document]/document.svelte | 31 ++++++++-- .../wizard/step1.svelte | 57 +++++++++---------- 3 files changed, 56 insertions(+), 45 deletions(-) diff --git a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/createDocument.svelte b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/createDocument.svelte index 617e3c5c1..259f157b5 100644 --- a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/createDocument.svelte +++ b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/createDocument.svelte @@ -16,11 +16,9 @@ const databaseId = $page.params.database; const collectionId = $page.params.collection; - onMount(async () => { - initializeDocument(); - }); + onMount(initializeDocument); - const initializeDocument = () => { + function initializeDocument() { $createDocument.attributes = $attributes.filter((a) => a.status === 'available'); $attributes.forEach((attr) => { if (attr.array) { @@ -29,9 +27,9 @@ $createDocument.document[attr.key] = null; } }); - }; + } - const create = async () => { + async function create() { try { await sdkForProject.databases.createDocument( databaseId, @@ -52,10 +50,9 @@ type: 'error' }); } - }; + } onDestroy(() => { - initializeDocument(); $createDocument.permissions = []; }); diff --git a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/document-[document]/document.svelte b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/document-[document]/document.svelte index 8468405ea..21d3c6c26 100644 --- a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/document-[document]/document.svelte +++ b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/document-[document]/document.svelte @@ -49,7 +49,7 @@ } } - const updateData = async () => { + async function updateData() { try { await sdkForProject.databases.updateDocument( databaseId, @@ -72,7 +72,26 @@ type: 'error' }); } - }; + } + + function addArrayItem(key: string) { + work.update((n) => { + if (!Array.isArray(n[key])) { + n[key] = []; + } + n[key].push(null); + + return n; + }); + } + + function removeArrayItem(key: string, index: number) { + work.update((n) => { + n[key].splice(index, 1); + + return n; + }); + } @@ -83,7 +102,7 @@ {#each $collection.attributes.filter((a) => a.status === 'available') as attribute} {#if attribute.array}