fix saving of blank screen

This commit is contained in:
Peter Clement 2021-11-11 12:09:36 +00:00
parent 39a66e2a49
commit 2ab72610f8
3 changed files with 22 additions and 9 deletions

View File

@ -2,11 +2,12 @@
import { ModalContent, Body, Detail } from "@budibase/bbui"
import { store, selectedAccessRole, allScreens } from "builderStore"
import { cloneDeep } from "lodash/fp"
import sanitizeUrl from "builderStore/store/screenTemplates/utils/sanitizeUrl"
export let screenNameModal
export let selectedScreens
export let modal
export let screenName
let roleId = $selectedAccessRole || "BASIC"
let routeError
@ -35,18 +36,24 @@
}
const saveScreens = async draftScreen => {
let route = screenName
? sanitizeUrl(`/${screenName}`)
: draftScreen.routing.route
console.log(sanitizeUrl(`/${screenName}`))
if (draftScreen) {
if (!draftScreen.routing.route) {
if (!route) {
routeError = "URL is required"
} else {
if (routeExists(draftScreen.routing.route, roleId)) {
if (routeExists(route, roleId)) {
routeError = "This URL is already taken for this access role"
} else {
routeError = ""
}
}
console.log(routeError)
if (routeError) return false
draftScreen.routing.route = route
await store.actions.screens.create(draftScreen)
if (createLink) {
await store.actions.components.links.save(

View File

@ -3,7 +3,8 @@
export let modal
export let navigationSelectionModal
export let name
export let screenName
$: console.log(name)
</script>
<ModalContent
@ -13,7 +14,7 @@
onCancel={() => modal.show()}
onConfirm={() => navigationSelectionModal.show()}
cancelText={"Back"}
disabled={!name.length}
disabled={!screenName}
>
<Input label="Name" bind:value={name} />
<Input label="Name" bind:value={screenName} />
</ModalContent>

View File

@ -32,9 +32,9 @@
let modal
let navigationSelectionModal
let screenNameModal
let screenName
let screenName = ""
let selectedScreens = []
$: console.log(screenName)
// Hydrate state from URL params
$: hydrateStateFromURL($params, $leftover)
@ -220,7 +220,12 @@
<ScreenNameModal bind:screenName {modal} {navigationSelectionModal} />
</Modal>
<Modal bind:this={navigationSelectionModal}>
<NavigationSelectionModal {modal} {selectedScreens} {screenNameModal} />
<NavigationSelectionModal
{screenName}
{modal}
{selectedScreens}
{screenNameModal}
/>
</Modal>
<style>