fix saving of blank screen
This commit is contained in:
parent
39a66e2a49
commit
2ab72610f8
|
@ -2,11 +2,12 @@
|
||||||
import { ModalContent, Body, Detail } from "@budibase/bbui"
|
import { ModalContent, Body, Detail } from "@budibase/bbui"
|
||||||
import { store, selectedAccessRole, allScreens } from "builderStore"
|
import { store, selectedAccessRole, allScreens } from "builderStore"
|
||||||
import { cloneDeep } from "lodash/fp"
|
import { cloneDeep } from "lodash/fp"
|
||||||
|
import sanitizeUrl from "builderStore/store/screenTemplates/utils/sanitizeUrl"
|
||||||
|
|
||||||
export let screenNameModal
|
export let screenNameModal
|
||||||
export let selectedScreens
|
export let selectedScreens
|
||||||
export let modal
|
export let modal
|
||||||
|
export let screenName
|
||||||
let roleId = $selectedAccessRole || "BASIC"
|
let roleId = $selectedAccessRole || "BASIC"
|
||||||
|
|
||||||
let routeError
|
let routeError
|
||||||
|
@ -35,18 +36,24 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const saveScreens = async draftScreen => {
|
const saveScreens = async draftScreen => {
|
||||||
|
let route = screenName
|
||||||
|
? sanitizeUrl(`/${screenName}`)
|
||||||
|
: draftScreen.routing.route
|
||||||
|
console.log(sanitizeUrl(`/${screenName}`))
|
||||||
if (draftScreen) {
|
if (draftScreen) {
|
||||||
if (!draftScreen.routing.route) {
|
if (!route) {
|
||||||
routeError = "URL is required"
|
routeError = "URL is required"
|
||||||
} else {
|
} else {
|
||||||
if (routeExists(draftScreen.routing.route, roleId)) {
|
if (routeExists(route, roleId)) {
|
||||||
routeError = "This URL is already taken for this access role"
|
routeError = "This URL is already taken for this access role"
|
||||||
} else {
|
} else {
|
||||||
routeError = ""
|
routeError = ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log(routeError)
|
||||||
if (routeError) return false
|
if (routeError) return false
|
||||||
|
|
||||||
|
draftScreen.routing.route = route
|
||||||
await store.actions.screens.create(draftScreen)
|
await store.actions.screens.create(draftScreen)
|
||||||
if (createLink) {
|
if (createLink) {
|
||||||
await store.actions.components.links.save(
|
await store.actions.components.links.save(
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
|
|
||||||
export let modal
|
export let modal
|
||||||
export let navigationSelectionModal
|
export let navigationSelectionModal
|
||||||
export let name
|
export let screenName
|
||||||
|
$: console.log(name)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ModalContent
|
<ModalContent
|
||||||
|
@ -13,7 +14,7 @@
|
||||||
onCancel={() => modal.show()}
|
onCancel={() => modal.show()}
|
||||||
onConfirm={() => navigationSelectionModal.show()}
|
onConfirm={() => navigationSelectionModal.show()}
|
||||||
cancelText={"Back"}
|
cancelText={"Back"}
|
||||||
disabled={!name.length}
|
disabled={!screenName}
|
||||||
>
|
>
|
||||||
<Input label="Name" bind:value={name} />
|
<Input label="Name" bind:value={screenName} />
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
|
|
|
@ -32,9 +32,9 @@
|
||||||
let modal
|
let modal
|
||||||
let navigationSelectionModal
|
let navigationSelectionModal
|
||||||
let screenNameModal
|
let screenNameModal
|
||||||
let screenName
|
let screenName = ""
|
||||||
let selectedScreens = []
|
let selectedScreens = []
|
||||||
|
$: console.log(screenName)
|
||||||
// Hydrate state from URL params
|
// Hydrate state from URL params
|
||||||
$: hydrateStateFromURL($params, $leftover)
|
$: hydrateStateFromURL($params, $leftover)
|
||||||
|
|
||||||
|
@ -220,7 +220,12 @@
|
||||||
<ScreenNameModal bind:screenName {modal} {navigationSelectionModal} />
|
<ScreenNameModal bind:screenName {modal} {navigationSelectionModal} />
|
||||||
</Modal>
|
</Modal>
|
||||||
<Modal bind:this={navigationSelectionModal}>
|
<Modal bind:this={navigationSelectionModal}>
|
||||||
<NavigationSelectionModal {modal} {selectedScreens} {screenNameModal} />
|
<NavigationSelectionModal
|
||||||
|
{screenName}
|
||||||
|
{modal}
|
||||||
|
{selectedScreens}
|
||||||
|
{screenNameModal}
|
||||||
|
/>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
Loading…
Reference in New Issue