more refactoring of screen wizard

This commit is contained in:
Peter Clement 2021-11-17 10:24:14 +00:00
parent f3cddaaf08
commit 776e4e2d20
4 changed files with 36 additions and 34 deletions

View File

@ -5,11 +5,10 @@
import sanitizeUrl from "builderStore/store/screenTemplates/utils/sanitizeUrl"
import { onDestroy } from "svelte"
export let screenNameModal
export let selectedScreens
export let modal
export let screenName
export let url
export let chooseModal
let roleId = $selectedAccessRole || "BASIC"
@ -99,7 +98,7 @@
<ModalContent
title="Select navigation"
cancelText="Back"
onCancel={() => (blankSelected ? screenNameModal.show() : modal.show())}
onCancel={() => (blankSelected ? chooseModal(1) : chooseModal(0))}
size="M"
onConfirm={() => {
save(createdScreens)

View File

@ -4,13 +4,13 @@
import { ModalContent, Body, Detail, Layout, Icon } from "@budibase/bbui"
import getTemplates from "builderStore/store/screenTemplates"
export let screenNameModal
export let navigationSelectionModal
export let selectedScreens = []
export let chooseModal
const blankScreen = "createFromScratch"
$: blankSelected = selectedScreens.length === 1
$: autoSelected = selectedScreens.length > 0 && !blankSelected
$: blankSelected = selectedScreens?.length === 1
$: autoSelected = selectedScreens?.length > 0 && !blankSelected
$: templates = getTemplates($store, $tables.list)
const toggleScreenSelection = table => {
@ -19,7 +19,7 @@
screen => !screen.name.includes(table.name)
)
} else {
const templates = templates.filter(template =>
templates = templates.filter(template =>
template.name.includes(table.name)
)
selectedScreens = [...templates, ...selectedScreens]
@ -31,8 +31,7 @@
title="Add screens"
confirmText="Add Screens"
cancelText="Cancel"
onConfirm={() =>
autoSelected ? navigationSelectionModal.show() : screenNameModal.show()}
onConfirm={() => (autoSelected ? chooseModal(2) : chooseModal(1))}
disabled={!selectedScreens.length}
size="L"
>

View File

@ -3,10 +3,9 @@
import sanitizeUrl from "builderStore/store/screenTemplates/utils/sanitizeUrl"
import { selectedAccessRole, allScreens } from "builderStore"
export let modal
export let navigationSelectionModal
export let screenName
export let url
export let chooseModal
let routeError
let roleId = $selectedAccessRole || "BASIC"
@ -37,8 +36,8 @@
size="M"
title={"Enter details"}
confirmText={"Continue"}
onCancel={() => modal.show()}
onConfirm={() => navigationSelectionModal.show()}
onCancel={() => chooseModal(0)}
onConfirm={() => chooseModal(2)}
cancelText={"Back"}
disabled={!screenName || !url || routeError}
>

View File

@ -1,43 +1,48 @@
<script>
import NavigationSelectionModal from "components/design/NavigationPanel/NavigationSelectionModal.svelte"
import ScreenNameModal from "components/design/NavigationPanel/ScreenNameModal.svelte"
import ScreenDetailsModal from "components/design/NavigationPanel/ScreenDetailsModal.svelte"
import NewScreenModal from "components/design/NavigationPanel/NewScreenModal.svelte"
import { Modal } from "@budibase/bbui"
let modal
let newScreenModal
let navigationSelectionModal
let screenNameModal
let screenDetailsModal
let screenName = ""
let url = ""
let selectedScreens = []
export function showModal() {
modal.show()
export const showModal = () => {
newScreenModal.show()
}
const chooseModal = index => {
/*
0 = newScreenModal
1 = screenDetailsModal
2 = navigationSelectionModal
*/
if (index === 0) {
newScreenModal.show()
} else if (index === 1) {
screenDetailsModal.show()
} else if (index === 2) {
navigationSelectionModal.show()
}
}
</script>
<Modal bind:this={modal}>
<NewScreenModal
{screenNameModal}
{navigationSelectionModal}
bind:selectedScreens
/>
<Modal bind:this={newScreenModal}>
<NewScreenModal bind:selectedScreens {chooseModal} />
</Modal>
<Modal bind:this={screenNameModal}>
<ScreenNameModal
bind:screenName
bind:url
{modal}
{navigationSelectionModal}
/>
<Modal bind:this={screenDetailsModal}>
<ScreenDetailsModal bind:screenName bind:url {chooseModal} />
</Modal>
<Modal bind:this={navigationSelectionModal}>
<NavigationSelectionModal
bind:url
bind:screenName
{modal}
bind:selectedScreens
{screenNameModal}
{chooseModal}
/>
</Modal>