Add option to create link when creating new screen

This commit is contained in:
Andrew Kingston 2020-10-17 18:20:31 +01:00
parent 73125767b4
commit 0116f12ad5
1 changed files with 16 additions and 3 deletions

View File

@ -1,7 +1,14 @@
<script> <script>
import { goto } from "@sveltech/routify" import { goto } from "@sveltech/routify"
import { store, backendUiStore } from "builderStore" import { store, backendUiStore } from "builderStore"
import { Input, Button, Spacer, Select, ModalContent } from "@budibase/bbui" import {
Input,
Button,
Spacer,
Select,
ModalContent,
Toggle,
} from "@budibase/bbui"
import getTemplates from "builderStore/store/screenTemplates" import getTemplates from "builderStore/store/screenTemplates"
import { some } from "lodash/fp" import { some } from "lodash/fp"
import analytics from "analytics" import analytics from "analytics"
@ -13,6 +20,7 @@
let baseComponent = CONTAINER let baseComponent = CONTAINER
let templateIndex let templateIndex
let draftScreen let draftScreen
let createLink = true
$: templates = getTemplates($store, $backendUiStore.tables) $: templates = getTemplates($store, $backendUiStore.tables)
@ -46,7 +54,7 @@
} }
} }
const save = () => { const save = async () => {
if (!route) { if (!route) {
routeError = "Url is required" routeError = "Url is required"
} else { } else {
@ -63,7 +71,10 @@
draftScreen.props._component = baseComponent draftScreen.props._component = baseComponent
draftScreen.route = route draftScreen.route = route
store.createScreen(draftScreen) await store.createScreen(draftScreen)
if (createLink) {
await store.createLink(route, name)
}
if (templateIndex !== undefined) { if (templateIndex !== undefined) {
const template = templates[templateIndex] const template = templates[templateIndex]
@ -108,4 +119,6 @@
error={routeError} error={routeError}
bind:value={route} bind:value={route}
on:change={routeChanged} /> on:change={routeChanged} />
<Toggle text="Create link in navigation bar" bind:checked={createLink} />
</ModalContent> </ModalContent>