Selects for Screens in Events and Settings
This commit is contained in:
parent
b067eee80a
commit
d0f48e3d0e
|
@ -104,6 +104,10 @@ const setPackage = (store, initial) => async pkg => {
|
||||||
initial.pages = pkg.pages
|
initial.pages = pkg.pages
|
||||||
initial.hasAppPackage = true
|
initial.hasAppPackage = true
|
||||||
initial.screens = values(pkg.screens)
|
initial.screens = values(pkg.screens)
|
||||||
|
initial.allScreens = [
|
||||||
|
...Object.values(main_screens),
|
||||||
|
...Object.values(unauth_screens),
|
||||||
|
]
|
||||||
initial.builtins = [getBuiltin("##builtin/screenslot")]
|
initial.builtins = [getBuiltin("##builtin/screenslot")]
|
||||||
initial.appInstances = pkg.application.instances
|
initial.appInstances = pkg.application.instances
|
||||||
initial.appId = pkg.application._id
|
initial.appId = pkg.application._id
|
||||||
|
@ -112,6 +116,18 @@ const setPackage = (store, initial) => async pkg => {
|
||||||
return initial
|
return initial
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// const getAllScreens = store => async pkg => {
|
||||||
|
// const [main_screens, unauth_screens] = await Promise.all([
|
||||||
|
// api
|
||||||
|
// .get(`/_builder/api/${pkg.application._id}/pages/main/screens`)
|
||||||
|
// .then(r => r.json()),
|
||||||
|
// api
|
||||||
|
// .get(`/_builder/api/${pkg.application._id}/pages/unauthenticated/screens`)
|
||||||
|
// .then(r => r.json()),
|
||||||
|
// ])
|
||||||
|
// return { main_screens, unauth_screens }
|
||||||
|
// }
|
||||||
|
|
||||||
const saveScreen = store => screen => {
|
const saveScreen = store => screen => {
|
||||||
store.update(state => {
|
store.update(state => {
|
||||||
return _saveScreen(store, state, screen)
|
return _saveScreen(store, state, screen)
|
||||||
|
@ -132,6 +148,7 @@ const _saveScreen = async (store, s, screen) => {
|
||||||
innerState.pages[s.currentPageName]._screens = screens
|
innerState.pages[s.currentPageName]._screens = screens
|
||||||
innerState.screens = screens
|
innerState.screens = screens
|
||||||
innerState.currentPreviewItem = screen
|
innerState.currentPreviewItem = screen
|
||||||
|
innerState.allScreens = [...innerState.allScreens, screen]
|
||||||
const safeProps = makePropsSafe(
|
const safeProps = makePropsSafe(
|
||||||
innerState.components[screen.props._component],
|
innerState.components[screen.props._component],
|
||||||
screen.props
|
screen.props
|
||||||
|
|
|
@ -28,6 +28,13 @@
|
||||||
<option value={workflow._id}>{workflow.name}</option>
|
<option value={workflow._id}>{workflow.name}</option>
|
||||||
{/each}
|
{/each}
|
||||||
</Select>
|
</Select>
|
||||||
|
{:else if parameter.name === 'url'}
|
||||||
|
<Select on:change bind:value={parameter.value}>
|
||||||
|
<option value="" />
|
||||||
|
{#each $store.allScreens as screen}
|
||||||
|
<option value={screen.route}>{screen.props._instanceName}</option>
|
||||||
|
{/each}
|
||||||
|
</Select>
|
||||||
{:else}
|
{:else}
|
||||||
<Input
|
<Input
|
||||||
name={parameter.name}
|
name={parameter.name}
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
<script>
|
||||||
|
import { createEventDispatcher } from "svelte"
|
||||||
|
import { store } from "builderStore"
|
||||||
|
import OptionSelect from "./OptionSelect.svelte"
|
||||||
|
|
||||||
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
|
export let value = ""
|
||||||
|
|
||||||
|
function handleSelect(selected) {
|
||||||
|
value = selected
|
||||||
|
dispatch("change", value)
|
||||||
|
}
|
||||||
|
|
||||||
|
let options = $store.allScreens.map(s => ({
|
||||||
|
value: s.route,
|
||||||
|
label: s.props._instanceName,
|
||||||
|
}))
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<OptionSelect {options} {value} onChange={handleSelect} />
|
|
@ -5,6 +5,7 @@ import ModelSelect from "components/userInterface/ModelSelect.svelte"
|
||||||
import ModelViewSelect from "components/userInterface/ModelViewSelect.svelte"
|
import ModelViewSelect from "components/userInterface/ModelViewSelect.svelte"
|
||||||
import ModelViewFieldSelect from "components/userInterface/ModelViewFieldSelect.svelte"
|
import ModelViewFieldSelect from "components/userInterface/ModelViewFieldSelect.svelte"
|
||||||
import Event from "components/userInterface/EventsEditor/EventPropertyControl.svelte"
|
import Event from "components/userInterface/EventsEditor/EventPropertyControl.svelte"
|
||||||
|
import ScreenSelect from "components/userInterface/ScreenSelect.svelte"
|
||||||
|
|
||||||
import { all } from "./propertyCategories.js"
|
import { all } from "./propertyCategories.js"
|
||||||
/*
|
/*
|
||||||
|
@ -239,7 +240,7 @@ export default {
|
||||||
design: { ...all },
|
design: { ...all },
|
||||||
settings: [
|
settings: [
|
||||||
{ label: "Text", key: "text", control: Input },
|
{ label: "Text", key: "text", control: Input },
|
||||||
{ label: "Url", key: "url", control: Input },
|
{ label: "Url", key: "url", control: ScreenSelect },
|
||||||
{
|
{
|
||||||
label: "Open New Tab",
|
label: "Open New Tab",
|
||||||
key: "openInNewTab",
|
key: "openInNewTab",
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue