From 776e4e2d2078c9de1974ed752cb35997be19e704 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Wed, 17 Nov 2021 10:24:14 +0000 Subject: [PATCH] more refactoring of screen wizard --- .../NavigationSelectionModal.svelte | 5 +-- .../NavigationPanel/NewScreenModal.svelte | 13 +++--- ...Modal.svelte => ScreenDetailsModal.svelte} | 7 ++- .../NavigationPanel/ScreenWizard.svelte | 45 ++++++++++--------- 4 files changed, 36 insertions(+), 34 deletions(-) rename packages/builder/src/components/design/NavigationPanel/{ScreenNameModal.svelte => ScreenDetailsModal.svelte} (88%) diff --git a/packages/builder/src/components/design/NavigationPanel/NavigationSelectionModal.svelte b/packages/builder/src/components/design/NavigationPanel/NavigationSelectionModal.svelte index ec3d11683e..8035281193 100644 --- a/packages/builder/src/components/design/NavigationPanel/NavigationSelectionModal.svelte +++ b/packages/builder/src/components/design/NavigationPanel/NavigationSelectionModal.svelte @@ -5,11 +5,10 @@ import sanitizeUrl from "builderStore/store/screenTemplates/utils/sanitizeUrl" import { onDestroy } from "svelte" - export let screenNameModal export let selectedScreens - export let modal export let screenName export let url + export let chooseModal let roleId = $selectedAccessRole || "BASIC" @@ -99,7 +98,7 @@ (blankSelected ? screenNameModal.show() : modal.show())} + onCancel={() => (blankSelected ? chooseModal(1) : chooseModal(0))} size="M" onConfirm={() => { save(createdScreens) diff --git a/packages/builder/src/components/design/NavigationPanel/NewScreenModal.svelte b/packages/builder/src/components/design/NavigationPanel/NewScreenModal.svelte index 297f6c1d02..cfbcd444c2 100644 --- a/packages/builder/src/components/design/NavigationPanel/NewScreenModal.svelte +++ b/packages/builder/src/components/design/NavigationPanel/NewScreenModal.svelte @@ -4,13 +4,13 @@ import { ModalContent, Body, Detail, Layout, Icon } from "@budibase/bbui" import getTemplates from "builderStore/store/screenTemplates" - export let screenNameModal - export let navigationSelectionModal export let selectedScreens = [] + export let chooseModal const blankScreen = "createFromScratch" - $: blankSelected = selectedScreens.length === 1 - $: autoSelected = selectedScreens.length > 0 && !blankSelected + + $: blankSelected = selectedScreens?.length === 1 + $: autoSelected = selectedScreens?.length > 0 && !blankSelected $: templates = getTemplates($store, $tables.list) const toggleScreenSelection = table => { @@ -19,7 +19,7 @@ screen => !screen.name.includes(table.name) ) } else { - const templates = templates.filter(template => + templates = templates.filter(template => template.name.includes(table.name) ) selectedScreens = [...templates, ...selectedScreens] @@ -31,8 +31,7 @@ title="Add screens" confirmText="Add Screens" cancelText="Cancel" - onConfirm={() => - autoSelected ? navigationSelectionModal.show() : screenNameModal.show()} + onConfirm={() => (autoSelected ? chooseModal(2) : chooseModal(1))} disabled={!selectedScreens.length} size="L" > diff --git a/packages/builder/src/components/design/NavigationPanel/ScreenNameModal.svelte b/packages/builder/src/components/design/NavigationPanel/ScreenDetailsModal.svelte similarity index 88% rename from packages/builder/src/components/design/NavigationPanel/ScreenNameModal.svelte rename to packages/builder/src/components/design/NavigationPanel/ScreenDetailsModal.svelte index e237a93502..f353da1a4b 100644 --- a/packages/builder/src/components/design/NavigationPanel/ScreenNameModal.svelte +++ b/packages/builder/src/components/design/NavigationPanel/ScreenDetailsModal.svelte @@ -3,10 +3,9 @@ import sanitizeUrl from "builderStore/store/screenTemplates/utils/sanitizeUrl" import { selectedAccessRole, allScreens } from "builderStore" - export let modal - export let navigationSelectionModal export let screenName export let url + export let chooseModal let routeError let roleId = $selectedAccessRole || "BASIC" @@ -37,8 +36,8 @@ size="M" title={"Enter details"} confirmText={"Continue"} - onCancel={() => modal.show()} - onConfirm={() => navigationSelectionModal.show()} + onCancel={() => chooseModal(0)} + onConfirm={() => chooseModal(2)} cancelText={"Back"} disabled={!screenName || !url || routeError} > diff --git a/packages/builder/src/components/design/NavigationPanel/ScreenWizard.svelte b/packages/builder/src/components/design/NavigationPanel/ScreenWizard.svelte index cfe908894b..33d3cbb4aa 100644 --- a/packages/builder/src/components/design/NavigationPanel/ScreenWizard.svelte +++ b/packages/builder/src/components/design/NavigationPanel/ScreenWizard.svelte @@ -1,43 +1,48 @@ - - + + - - + +