Wip
This commit is contained in:
parent
a008f60a0b
commit
d90123e8de
|
@ -2,6 +2,7 @@
|
||||||
import ScreenDetailsModal from "components/design/ScreenDetailsModal.svelte"
|
import ScreenDetailsModal from "components/design/ScreenDetailsModal.svelte"
|
||||||
import DatasourceModal from "./DatasourceModal.svelte"
|
import DatasourceModal from "./DatasourceModal.svelte"
|
||||||
import ScreenRoleModal from "./ScreenRoleModal.svelte"
|
import ScreenRoleModal from "./ScreenRoleModal.svelte"
|
||||||
|
import FormTypeModal from "./FormTypeModal.svelte"
|
||||||
import sanitizeUrl from "builderStore/store/screenTemplates/utils/sanitizeUrl"
|
import sanitizeUrl from "builderStore/store/screenTemplates/utils/sanitizeUrl"
|
||||||
import { Modal, notifications } from "@budibase/bbui"
|
import { Modal, notifications } from "@budibase/bbui"
|
||||||
import { store } from "builderStore"
|
import { store } from "builderStore"
|
||||||
|
@ -19,12 +20,17 @@
|
||||||
let screenDetailsModal
|
let screenDetailsModal
|
||||||
let datasourceModal
|
let datasourceModal
|
||||||
let screenAccessRoleModal
|
let screenAccessRoleModal
|
||||||
|
let formTypeModal
|
||||||
|
|
||||||
// Cache variables for workflow
|
// Cache variables for workflow
|
||||||
let screenAccessRole = Roles.BASIC
|
let screenAccessRole = Roles.BASIC
|
||||||
|
|
||||||
let selectedTemplates = null
|
let selectedTemplates = null
|
||||||
|
|
||||||
|
let selectedDatasources = null
|
||||||
let blankScreenUrl = null
|
let blankScreenUrl = null
|
||||||
let screenMode = null
|
let screenMode = null
|
||||||
|
let formType = null
|
||||||
|
|
||||||
// Creates an array of screens, checking and sanitising their URLs
|
// Creates an array of screens, checking and sanitising their URLs
|
||||||
const createScreens = async ({ screens, screenAccessRole }) => {
|
const createScreens = async ({ screens, screenAccessRole }) => {
|
||||||
|
@ -56,20 +62,21 @@
|
||||||
screen.routing.roleId = screenAccessRole
|
screen.routing.roleId = screenAccessRole
|
||||||
|
|
||||||
// Create the screen
|
// Create the screen
|
||||||
const response = await store.actions.screens.save(screen)
|
// const response = await store.actions.screens.save(screen)
|
||||||
screenId = response._id
|
// screenId = response._id
|
||||||
|
|
||||||
// Add link in layout. We only ever actually create 1 screen now, even
|
// Add link in layout. We only ever actually create 1 screen now, even
|
||||||
// for autoscreens, so it's always safe to do this.
|
// for autoscreens, so it's always safe to do this.
|
||||||
await store.actions.links.save(
|
// await store.actions.links.save(
|
||||||
screen.routing.route,
|
// screen.routing.route,
|
||||||
capitalise(screen.routing.route.split("/")[1])
|
// capitalise(screen.routing.route.split("/")[1])
|
||||||
)
|
// )
|
||||||
|
console.log(screen)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Go to new screen
|
// Go to new screen
|
||||||
$goto(`./${screenId}`)
|
//$goto(`./${screenId}`)
|
||||||
store.actions.screens.select(screenId)
|
//store.actions.screens.select(screenId)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
notifications.error("Error creating screens")
|
notifications.error("Error creating screens")
|
||||||
|
@ -103,13 +110,15 @@
|
||||||
// Handler for NewScreenModal
|
// Handler for NewScreenModal
|
||||||
export const show = newMode => {
|
export const show = newMode => {
|
||||||
mode = newMode
|
mode = newMode
|
||||||
selectedTemplates = null
|
// selectedTemplates = null
|
||||||
|
selectedDatasources = null
|
||||||
blankScreenUrl = null
|
blankScreenUrl = null
|
||||||
screenMode = mode
|
screenMode = mode
|
||||||
pendingScreen = null
|
pendingScreen = null
|
||||||
screenAccessRole = Roles.BASIC
|
screenAccessRole = Roles.BASIC
|
||||||
|
formType = null
|
||||||
|
|
||||||
if (mode === "table" || mode === "grid") {
|
if (mode === "table" || mode === "grid" || mode === "form") {
|
||||||
datasourceModal.show()
|
datasourceModal.show()
|
||||||
} else if (mode === "blank") {
|
} else if (mode === "blank") {
|
||||||
let templates = getTemplates($tables.list)
|
let templates = getTemplates($tables.list)
|
||||||
|
@ -124,8 +133,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handler for DatasourceModal confirmation, move to screen access select
|
// Handler for DatasourceModal confirmation, move to screen access select
|
||||||
const confirmScreenDatasources = async ({ templates }) => {
|
const confirmScreenDatasources = async ({ datasources }) => {
|
||||||
selectedTemplates = templates
|
selectedDatasources = datasources
|
||||||
|
console.log("confirmScreenDatasources ", datasources)
|
||||||
screenAccessRoleModal.show()
|
screenAccessRoleModal.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,6 +146,14 @@
|
||||||
screenTemplate.autoTableId = template.resourceId
|
screenTemplate.autoTableId = template.resourceId
|
||||||
return screenTemplate
|
return screenTemplate
|
||||||
})
|
})
|
||||||
|
console.log("selectedTemplates ", selectedTemplates)
|
||||||
|
/*
|
||||||
|
|
||||||
|
id : "ROW_LIST_TEMPLATE"
|
||||||
|
name : "Employees - List"
|
||||||
|
resourceId : "ta_bb_employee"
|
||||||
|
|
||||||
|
*/
|
||||||
await createScreens({ screens, screenAccessRole })
|
await createScreens({ screens, screenAccessRole })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,8 +193,14 @@
|
||||||
datasourceModal.show()
|
datasourceModal.show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
window.test = () => {
|
||||||
|
formTypeModal.show()
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
returns templates, should return selected resources for use elsewhere
|
||||||
|
-->
|
||||||
<Modal bind:this={datasourceModal} autoFocus={false}>
|
<Modal bind:this={datasourceModal} autoFocus={false}>
|
||||||
<DatasourceModal
|
<DatasourceModal
|
||||||
{mode}
|
{mode}
|
||||||
|
@ -187,10 +211,17 @@
|
||||||
|
|
||||||
<Modal bind:this={screenAccessRoleModal}>
|
<Modal bind:this={screenAccessRoleModal}>
|
||||||
<ScreenRoleModal
|
<ScreenRoleModal
|
||||||
onConfirm={confirmScreenCreation}
|
onConfirm={() => {
|
||||||
onCancel={roleSelectBack}
|
if (screenMode === "form") {
|
||||||
|
formTypeModal.show()
|
||||||
|
} else {
|
||||||
|
confirmScreenCreation()
|
||||||
|
}
|
||||||
|
}}
|
||||||
bind:screenAccessRole
|
bind:screenAccessRole
|
||||||
|
onCancel={roleSelectBack}
|
||||||
screenUrl={blankScreenUrl}
|
screenUrl={blankScreenUrl}
|
||||||
|
confirmText={screenMode === "form" ? "Confirm" : "Done"}
|
||||||
/>
|
/>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
|
@ -200,3 +231,27 @@
|
||||||
initialUrl={blankScreenUrl}
|
initialUrl={blankScreenUrl}
|
||||||
/>
|
/>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
|
<Modal
|
||||||
|
bind:this={formTypeModal}
|
||||||
|
on:hide={() => {
|
||||||
|
console.log("hide")
|
||||||
|
//formType = null
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<FormTypeModal
|
||||||
|
onConfirm={() => {
|
||||||
|
console.log("test confirm")
|
||||||
|
}}
|
||||||
|
onCancel={() => {
|
||||||
|
console.log("cancel")
|
||||||
|
formTypeModal.hide()
|
||||||
|
screenAccessRoleModal.show()
|
||||||
|
}}
|
||||||
|
on:select={e => {
|
||||||
|
console.log("form type selection ", e.detail)
|
||||||
|
formType = e.detail
|
||||||
|
}}
|
||||||
|
type={formType}
|
||||||
|
/>
|
||||||
|
</Modal>
|
||||||
|
|
Loading…
Reference in New Issue