From 92ef492bd1f86a48b5fdad8cc708f6f107a4707e Mon Sep 17 00:00:00 2001 From: Michael Shanks Date: Tue, 18 Aug 2020 20:59:34 +0100 Subject: [PATCH] NewScreen - use bbui input - use input error message - screen name no longer needs to be unique --- .../components/common/ConfirmDialog.svelte | 3 +- .../components/userInterface/NewScreen.svelte | 35 ++++--------------- 2 files changed, 9 insertions(+), 29 deletions(-) diff --git a/packages/builder/src/components/common/ConfirmDialog.svelte b/packages/builder/src/components/common/ConfirmDialog.svelte index cd3ffb9b79..fbeb848dfc 100644 --- a/packages/builder/src/components/common/ConfirmDialog.svelte +++ b/packages/builder/src/components/common/ConfirmDialog.svelte @@ -29,8 +29,9 @@ } const ok = () => { + const result = onOk() + if (result === false) return hide() - onOk() } diff --git a/packages/builder/src/components/userInterface/NewScreen.svelte b/packages/builder/src/components/userInterface/NewScreen.svelte index 82546978a7..ab2b31b589 100644 --- a/packages/builder/src/components/userInterface/NewScreen.svelte +++ b/packages/builder/src/components/userInterface/NewScreen.svelte @@ -22,11 +22,8 @@ let layoutComponent let screens let name = "" - let nameError = "" let routeError - let saveAttempted = false - $: layoutComponents = Object.values($store.components).filter( componentDefinition => componentDefinition.container ) @@ -40,33 +37,21 @@ $: route = !route && $store.screens.length === 0 ? "*" : route const save = () => { - saveAttempted = true - - if (name.length === 0) { - nameError = "Name is required" - } else { - if (screenNameExists(name)) { - nameError = "This name is already taken" - } else { - nameError = "" - } - } - - if (route.length === 0) { + if (!route) { routeError = "Url is required" } else { - if (routeNameExists(name)) { + if (routeNameExists(route)) { routeError = "This url is already taken" } else { routeError = "" } } - const isValid = !routeError && !nameError - - if (!isValid) return + if (routeError) return false store.createScreen(name, route, layoutComponent._component) + name = "" + route = "" dialog.hide() } @@ -74,12 +59,6 @@ dialog.hide() } - const screenNameExists = name => { - return $store.screens.some( - screen => screen.name.toLowerCase() === name.toLowerCase() - ) - } - const routeNameExists = route => { return $store.screens.some( screen => screen.route.toLowerCase() === route.toLowerCase() @@ -102,7 +81,7 @@
- +
@@ -115,7 +94,7 @@
- {#each layoutComponents as { _component, name }} {/each}