allow editing of screen layout from modal
This commit is contained in:
parent
f9736ec3bc
commit
9b25a61706
|
@ -13,7 +13,7 @@ import {
|
||||||
} from "builderStore"
|
} from "builderStore"
|
||||||
import { fetchComponentLibDefinitions } from "../loadComponentLibraries"
|
import { fetchComponentLibDefinitions } from "../loadComponentLibraries"
|
||||||
import api from "../api"
|
import api from "../api"
|
||||||
import { DEFAULT_LAYOUTS, FrontendTypes } from "../../constants"
|
import { FrontendTypes } from "../../constants"
|
||||||
import getNewComponentName from "../getNewComponentName"
|
import getNewComponentName from "../getNewComponentName"
|
||||||
import analytics from "analytics"
|
import analytics from "analytics"
|
||||||
import {
|
import {
|
||||||
|
@ -27,7 +27,7 @@ const INITIAL_FRONTEND_STATE = {
|
||||||
apps: [],
|
apps: [],
|
||||||
name: "",
|
name: "",
|
||||||
description: "",
|
description: "",
|
||||||
layouts: DEFAULT_LAYOUTS,
|
layouts: [],
|
||||||
screens: [],
|
screens: [],
|
||||||
mainUi: {},
|
mainUi: {},
|
||||||
unauthenticatedUi: {},
|
unauthenticatedUi: {},
|
||||||
|
|
|
@ -2,17 +2,16 @@
|
||||||
import { goto } from "@sveltech/routify"
|
import { goto } from "@sveltech/routify"
|
||||||
import { store } from "builderStore"
|
import { store } from "builderStore"
|
||||||
import { getComponentDefinition } from "builderStore/storeUtils"
|
import { getComponentDefinition } from "builderStore/storeUtils"
|
||||||
import { DropEffect, DropPosition } from "./dragDropStore"
|
import initDragDropStore, { DropEffect, DropPosition } from "./dragDropStore"
|
||||||
import ComponentDropdownMenu from "../ComponentDropdownMenu.svelte"
|
import ComponentDropdownMenu from "../ComponentDropdownMenu.svelte"
|
||||||
import NavItem from "components/common/NavItem.svelte"
|
import NavItem from "components/common/NavItem.svelte"
|
||||||
|
|
||||||
export let layout
|
|
||||||
export let components = []
|
export let components = []
|
||||||
export let currentComponent
|
export let currentComponent
|
||||||
export let onSelect = () => {}
|
export let onSelect = () => {}
|
||||||
export let level = 0
|
export let level = 0
|
||||||
|
|
||||||
export let dragDropStore
|
export let dragDropStore = initDragDropStore()
|
||||||
|
|
||||||
const isScreenslot = name => name === "##builtin/screenslot"
|
const isScreenslot = name => name === "##builtin/screenslot"
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
<script>
|
||||||
|
import { store, currentAsset } from "builderStore"
|
||||||
|
import { Select } from "@budibase/bbui"
|
||||||
|
|
||||||
|
export let layout
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<Select bind:value={layout} extraThin secondary>
|
||||||
|
{#each $store.layouts as layout}
|
||||||
|
<option value={layout._id}>{layout.name}</option>
|
||||||
|
{/each}
|
||||||
|
</Select>
|
||||||
|
</div>
|
|
@ -8,8 +8,6 @@
|
||||||
import NavItem from "components/common/NavItem.svelte"
|
import NavItem from "components/common/NavItem.svelte"
|
||||||
import ScreenDropdownMenu from "./ScreenDropdownMenu.svelte"
|
import ScreenDropdownMenu from "./ScreenDropdownMenu.svelte"
|
||||||
|
|
||||||
const dragDropStore = instantiateStore()
|
|
||||||
|
|
||||||
export let route
|
export let route
|
||||||
export let path
|
export let path
|
||||||
export let indent
|
export let indent
|
||||||
|
@ -39,13 +37,13 @@
|
||||||
text={url === '/' ? 'Home' : url}
|
text={url === '/' ? 'Home' : url}
|
||||||
withArrow={route.subpaths}
|
withArrow={route.subpaths}
|
||||||
on:click={() => changeScreen(screenId)}>
|
on:click={() => changeScreen(screenId)}>
|
||||||
<ScreenDropdownMenu screen={screenId} />
|
<ScreenDropdownMenu screenId={screenId} />
|
||||||
</NavItem>
|
</NavItem>
|
||||||
{#if selectedScreen?._id === screenId}
|
{#if selectedScreen?._id === screenId}
|
||||||
<ComponentsTree
|
<ComponentsTree
|
||||||
components={selectedScreen.props._children}
|
components={selectedScreen.props._children}
|
||||||
currentComponent={$store.currentComponentInfo}
|
currentComponent={$store.currentComponentInfo}
|
||||||
{dragDropStore} />
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
{/each}
|
{/each}
|
||||||
|
|
|
@ -3,21 +3,31 @@
|
||||||
import { store, allScreens } from "builderStore"
|
import { store, allScreens } from "builderStore"
|
||||||
import { notifier } from "builderStore/store/notifications"
|
import { notifier } from "builderStore/store/notifications"
|
||||||
import ConfirmDialog from "components/common/ConfirmDialog.svelte"
|
import ConfirmDialog from "components/common/ConfirmDialog.svelte"
|
||||||
|
import EditScreenLayoutModal from "./EditScreenLayoutModal.svelte"
|
||||||
import { DropdownMenu, Modal, ModalContent } from "@budibase/bbui"
|
import { DropdownMenu, Modal, ModalContent } from "@budibase/bbui"
|
||||||
import { DropdownContainer, DropdownItem } from "components/common/Dropdowns"
|
import { DropdownContainer, DropdownItem } from "components/common/Dropdowns"
|
||||||
|
|
||||||
export let screen
|
export let screenId
|
||||||
|
|
||||||
let confirmDeleteDialog
|
let confirmDeleteDialog
|
||||||
let editLayoutDialog
|
let editLayoutDialog
|
||||||
let dropdown
|
let dropdown
|
||||||
let anchor
|
let anchor
|
||||||
|
|
||||||
|
$: screen = $allScreens.find(screen => screen._id === screenId)
|
||||||
|
|
||||||
const deleteScreen = () => {
|
const deleteScreen = () => {
|
||||||
const screenToDelete = $allScreens.find(scr => scr._id === screen)
|
store.actions.screens.delete(screen)
|
||||||
store.actions.screens.delete(screenToDelete)
|
|
||||||
store.actions.routing.fetch()
|
store.actions.routing.fetch()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function saveScreen() {
|
||||||
|
try {
|
||||||
|
await store.actions.screens.save(screen)
|
||||||
|
} catch (err) {
|
||||||
|
notifier.danger("Error saving page.")
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div bind:this={anchor} on:click|stopPropagation>
|
<div bind:this={anchor} on:click|stopPropagation>
|
||||||
|
@ -45,11 +55,8 @@
|
||||||
onOk={deleteScreen} />
|
onOk={deleteScreen} />
|
||||||
|
|
||||||
<Modal bind:this={editLayoutDialog}>
|
<Modal bind:this={editLayoutDialog}>
|
||||||
<ModalContent
|
<ModalContent onConfirm={saveScreen} title={'Set Layout For Screen'}>
|
||||||
showCancelButton={false}
|
<EditScreenLayoutModal bind:layout={screen.props.layoutId} />
|
||||||
showConfirmButton={false}
|
|
||||||
title={'Set Layout For Screen'}>
|
|
||||||
Choose a layout for your screen
|
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
import { store, allScreens } from "builderStore"
|
import { store, allScreens } from "builderStore"
|
||||||
|
import { FrontendTypes } from "constants"
|
||||||
import ComponentPropertiesPanel from "./ComponentPropertiesPanel.svelte"
|
import ComponentPropertiesPanel from "./ComponentPropertiesPanel.svelte"
|
||||||
import ComponentSelectionList from "./ComponentSelectionList.svelte"
|
import ComponentSelectionList from "./ComponentSelectionList.svelte"
|
||||||
|
|
||||||
|
@ -18,7 +19,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="root">
|
<div class="root">
|
||||||
{#if $store.currentFrontEndType === 'layout' || $allScreens.length}
|
{#if $store.currentFrontEndType === FrontendTypes.LAYOUT || $allScreens.length}
|
||||||
<div class="switcher">
|
<div class="switcher">
|
||||||
<button
|
<button
|
||||||
class:selected={selected === COMPONENT_SELECTION_TAB}
|
class:selected={selected === COMPONENT_SELECTION_TAB}
|
||||||
|
|
|
@ -14,10 +14,6 @@
|
||||||
|
|
||||||
const dragDropStore = writable({})
|
const dragDropStore = writable({})
|
||||||
|
|
||||||
$: console.log({
|
|
||||||
$currentAsset, layout
|
|
||||||
})
|
|
||||||
|
|
||||||
const setCurrentScreenToLayout = () => {
|
const setCurrentScreenToLayout = () => {
|
||||||
store.actions.selectAssetType(FrontendTypes.LAYOUT)
|
store.actions.selectAssetType(FrontendTypes.LAYOUT)
|
||||||
$goto("./layouts")
|
$goto("./layouts")
|
||||||
|
|
|
@ -11,18 +11,3 @@ export const FrontendTypes = {
|
||||||
|
|
||||||
// fields on the user table that cannot be edited
|
// fields on the user table that cannot be edited
|
||||||
export const UNEDITABLE_USER_FIELDS = ["username", "password", "roleId"]
|
export const UNEDITABLE_USER_FIELDS = ["username", "password", "roleId"]
|
||||||
|
|
||||||
export const DEFAULT_LAYOUTS = {
|
|
||||||
main: {
|
|
||||||
props: {
|
|
||||||
_component: "@budibase/standard-components/container",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
unauthenticated: {
|
|
||||||
props: {
|
|
||||||
_component: "@budibase/standard-components/container",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
componentLibraries: [],
|
|
||||||
stylesheets: [],
|
|
||||||
}
|
|
||||||
|
|
|
@ -48,9 +48,8 @@
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<body id="app">
|
<body id="app">
|
||||||
<script src={publicPath('clientFrontendDefinition.js')}>
|
|
||||||
</script>
|
|
||||||
<script src={publicPath('budibase-client.js')}>
|
<script src={publicPath('budibase-client.js')}>
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
loadBudibase()
|
loadBudibase()
|
||||||
|
|
|
@ -35,12 +35,11 @@ const BASE_LAYOUTS = [
|
||||||
className: "",
|
className: "",
|
||||||
onLoad: [],
|
onLoad: [],
|
||||||
type: "div",
|
type: "div",
|
||||||
_appId: "inst_app_80b_f158d4057d2c4bedb0042d42fda8abaf",
|
|
||||||
_instanceName: "Header",
|
_instanceName: "Header",
|
||||||
_children: [
|
_children: [
|
||||||
{
|
{
|
||||||
_id: "49e0e519-9e5e-4127-885a-ee6a0a49e2c1",
|
_id: "49e0e519-9e5e-4127-885a-ee6a0a49e2c1",
|
||||||
_component: "@budibase/standard-components/Navigation",
|
_component: "@budibase/standard-components/navigation",
|
||||||
_styles: {
|
_styles: {
|
||||||
normal: {
|
normal: {
|
||||||
"max-width": "1400px",
|
"max-width": "1400px",
|
||||||
|
@ -65,7 +64,6 @@ const BASE_LAYOUTS = [
|
||||||
borderWidth: "",
|
borderWidth: "",
|
||||||
borderColor: "",
|
borderColor: "",
|
||||||
borderStyle: "",
|
borderStyle: "",
|
||||||
_appId: "inst_cf8ace4_69efc0d72e6f443db2d4c902c14d9394",
|
|
||||||
_instanceName: "Navigation",
|
_instanceName: "Navigation",
|
||||||
_children: [
|
_children: [
|
||||||
{
|
{
|
||||||
|
@ -94,7 +92,6 @@ const BASE_LAYOUTS = [
|
||||||
underline: false,
|
underline: false,
|
||||||
fontSize: "",
|
fontSize: "",
|
||||||
fontFamily: "initial",
|
fontFamily: "initial",
|
||||||
_appId: "inst_cf8ace4_69efc0d72e6f443db2d4c902c14d9394",
|
|
||||||
_instanceName: "Home Link",
|
_instanceName: "Home Link",
|
||||||
_children: [],
|
_children: [],
|
||||||
},
|
},
|
||||||
|
|
|
@ -35,7 +35,6 @@ exports.HOME_SCREEN = {
|
||||||
_code: "",
|
_code: "",
|
||||||
text: "Welcome to your Budibase App 👋",
|
text: "Welcome to your Budibase App 👋",
|
||||||
type: "h2",
|
type: "h2",
|
||||||
_appId: "inst_cf8ace4_69efc0d72e6f443db2d4c902c14d9394",
|
|
||||||
_instanceName: "Heading",
|
_instanceName: "Heading",
|
||||||
_children: [],
|
_children: [],
|
||||||
},
|
},
|
||||||
|
@ -59,7 +58,6 @@ exports.HOME_SCREEN = {
|
||||||
},
|
},
|
||||||
_code: "",
|
_code: "",
|
||||||
type: "div",
|
type: "div",
|
||||||
_appId: "inst_app_2cc_ca3383f896034e9295345c05f7dfca0c",
|
|
||||||
_instanceName: "Video Container",
|
_instanceName: "Video Container",
|
||||||
_children: [
|
_children: [
|
||||||
{
|
{
|
||||||
|
@ -86,7 +84,6 @@ exports.HOME_SCREEN = {
|
||||||
_code: "",
|
_code: "",
|
||||||
embed:
|
embed:
|
||||||
'<iframe width="560" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>',
|
'<iframe width="560" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>',
|
||||||
_appId: "inst_app_2cc_ca3383f896034e9295345c05f7dfca0c",
|
|
||||||
_instanceName: "Rick Astley Video",
|
_instanceName: "Rick Astley Video",
|
||||||
_children: [],
|
_children: [],
|
||||||
},
|
},
|
||||||
|
@ -106,6 +103,24 @@ exports.LOGIN_SCREEN = {
|
||||||
description: "",
|
description: "",
|
||||||
url: "",
|
url: "",
|
||||||
props: {
|
props: {
|
||||||
|
_id: "5beb4c7b-3c8b-49b2-b8b3-d447dc76dda7",
|
||||||
|
_component: "@budibase/standard-components/container",
|
||||||
|
_styles: {
|
||||||
|
normal: {
|
||||||
|
flex: "1 1 auto",
|
||||||
|
display: "flex",
|
||||||
|
"flex-direction": "column",
|
||||||
|
"justify-content": "flex-start",
|
||||||
|
"align-items": "stretch",
|
||||||
|
},
|
||||||
|
hover: {},
|
||||||
|
active: {},
|
||||||
|
selected: {},
|
||||||
|
},
|
||||||
|
_code: "",
|
||||||
|
type: "div",
|
||||||
|
_children: [
|
||||||
|
{
|
||||||
_id: "781e497e-2e7c-11eb-adc1-0242ac120002",
|
_id: "781e497e-2e7c-11eb-adc1-0242ac120002",
|
||||||
_component: "@budibase/standard-components/login",
|
_component: "@budibase/standard-components/login",
|
||||||
_styles: {
|
_styles: {
|
||||||
|
@ -121,6 +136,8 @@ exports.LOGIN_SCREEN = {
|
||||||
_children: [],
|
_children: [],
|
||||||
_instanceName: "Login",
|
_instanceName: "Login",
|
||||||
},
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
routing: {
|
routing: {
|
||||||
route: "/",
|
route: "/",
|
||||||
accessLevelId: BUILTIN_ROLE_IDS.PUBLIC,
|
accessLevelId: BUILTIN_ROLE_IDS.PUBLIC,
|
||||||
|
|
Loading…
Reference in New Issue