save nav selection
This commit is contained in:
parent
5d687316cb
commit
39a66e2a49
|
@ -1,6 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
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"
|
||||||
|
|
||||||
export let screenNameModal
|
export let screenNameModal
|
||||||
export let selectedScreens
|
export let selectedScreens
|
||||||
|
@ -11,6 +12,8 @@
|
||||||
let routeError
|
let routeError
|
||||||
let selectedNav
|
let selectedNav
|
||||||
let createdScreens = []
|
let createdScreens = []
|
||||||
|
let createLink = true
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
selectedScreens.forEach(screen => {
|
selectedScreens.forEach(screen => {
|
||||||
createdScreens = [...createdScreens, screen.create()]
|
createdScreens = [...createdScreens, screen.create()]
|
||||||
|
@ -19,9 +22,20 @@
|
||||||
|
|
||||||
$: blankSelected = selectedScreens.find(x => x.id === "createFromScratch")
|
$: blankSelected = selectedScreens.find(x => x.id === "createFromScratch")
|
||||||
|
|
||||||
const save = async draftScreen => {
|
const save = async screens => {
|
||||||
|
screens.forEach(screen => {
|
||||||
|
saveScreens(screen)
|
||||||
|
})
|
||||||
|
|
||||||
|
let navLayout = cloneDeep(
|
||||||
|
$store.layouts.find(layout => layout._id === "layout_private_master")
|
||||||
|
)
|
||||||
|
navLayout.props.navigation = selectedNav
|
||||||
|
await store.actions.layouts.save(navLayout)
|
||||||
|
}
|
||||||
|
|
||||||
|
const saveScreens = async draftScreen => {
|
||||||
if (draftScreen) {
|
if (draftScreen) {
|
||||||
console.log(draftScreen)
|
|
||||||
if (!draftScreen.routing.route) {
|
if (!draftScreen.routing.route) {
|
||||||
routeError = "URL is required"
|
routeError = "URL is required"
|
||||||
} else {
|
} else {
|
||||||
|
@ -31,11 +45,15 @@
|
||||||
routeError = ""
|
routeError = ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(routeError)
|
|
||||||
if (routeError) return false
|
if (routeError) return false
|
||||||
|
|
||||||
draftScreen.props.navigation = selectedNav
|
|
||||||
await store.actions.screens.create(draftScreen)
|
await store.actions.screens.create(draftScreen)
|
||||||
|
if (createLink) {
|
||||||
|
await store.actions.components.links.save(
|
||||||
|
draftScreen.routing.route,
|
||||||
|
draftScreen.props._instanceName
|
||||||
|
)
|
||||||
|
}
|
||||||
await store.actions.routing.fetch()
|
await store.actions.routing.fetch()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,7 +73,7 @@
|
||||||
onCancel={() => (blankSelected ? screenNameModal.show() : modal.show())}
|
onCancel={() => (blankSelected ? screenNameModal.show() : modal.show())}
|
||||||
size="M"
|
size="M"
|
||||||
onConfirm={() => {
|
onConfirm={() => {
|
||||||
save(createdScreens.forEach(screen => save(screen)))
|
save(createdScreens)
|
||||||
}}
|
}}
|
||||||
disabled={!selectedNav}
|
disabled={!selectedNav}
|
||||||
>
|
>
|
||||||
|
@ -65,8 +83,8 @@
|
||||||
|
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
<div
|
<div
|
||||||
on:click={() => (selectedNav = "side")}
|
on:click={() => (selectedNav = "Left")}
|
||||||
class:unselected={selectedNav && selectedNav !== "side"}
|
class:unselected={selectedNav && selectedNav !== "Left"}
|
||||||
>
|
>
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="side-nav" />
|
<div class="side-nav" />
|
||||||
|
@ -74,8 +92,8 @@
|
||||||
<div><Detail>Side Nav</Detail></div>
|
<div><Detail>Side Nav</Detail></div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
on:click={() => (selectedNav = "top")}
|
on:click={() => (selectedNav = "Top")}
|
||||||
class:unselected={selectedNav && selectedNav !== "top"}
|
class:unselected={selectedNav && selectedNav !== "Top"}
|
||||||
>
|
>
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="top-nav" />
|
<div class="top-nav" />
|
||||||
|
@ -83,8 +101,8 @@
|
||||||
<div><Detail>Top Nav</Detail></div>
|
<div><Detail>Top Nav</Detail></div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
on:click={() => (selectedNav = "none")}
|
on:click={() => (selectedNav = "None")}
|
||||||
class:unselected={selectedNav && selectedNav !== "none"}
|
class:unselected={selectedNav && selectedNav !== "None"}
|
||||||
>
|
>
|
||||||
<div class="box" />
|
<div class="box" />
|
||||||
<div><Detail>No Nav</Detail></div>
|
<div><Detail>No Nav</Detail></div>
|
||||||
|
|
Loading…
Reference in New Issue