adds routing to the frontend part of the builder
This commit is contained in:
commit
ecfef63eff
|
@ -2,7 +2,7 @@
|
||||||
import { filter, cloneDeep, last, concat, isEmpty, values } from "lodash/fp"
|
import { filter, cloneDeep, last, concat, isEmpty, values } from "lodash/fp"
|
||||||
import { pipe, getNode, constructHierarchy } from "components/common/core"
|
import { pipe, getNode, constructHierarchy } from "components/common/core"
|
||||||
import * as backendStoreActions from "./backend"
|
import * as backendStoreActions from "./backend"
|
||||||
import { writable } from "svelte/store"
|
import { writable, get } from "svelte/store"
|
||||||
import { defaultPagesObject } from "components/userInterface/pagesParsing/defaultPagesObject"
|
import { defaultPagesObject } from "components/userInterface/pagesParsing/defaultPagesObject"
|
||||||
import api from "../api"
|
import api from "../api"
|
||||||
import { getExactComponent } from "components/userInterface/pagesParsing/searchComponents"
|
import { getExactComponent } from "components/userInterface/pagesParsing/searchComponents"
|
||||||
|
@ -92,6 +92,7 @@ export const getStore = () => {
|
||||||
store.moveUpComponent = moveUpComponent(store)
|
store.moveUpComponent = moveUpComponent(store)
|
||||||
store.moveDownComponent = moveDownComponent(store)
|
store.moveDownComponent = moveDownComponent(store)
|
||||||
store.copyComponent = copyComponent(store)
|
store.copyComponent = copyComponent(store)
|
||||||
|
store.getPathToComponent = getPathToComponent(store)
|
||||||
store.addTemplatedComponent = addTemplatedComponent(store)
|
store.addTemplatedComponent = addTemplatedComponent(store)
|
||||||
store.setMetadataProp = setMetadataProp(store)
|
store.setMetadataProp = setMetadataProp(store)
|
||||||
return store
|
return store
|
||||||
|
@ -667,6 +668,38 @@ const copyComponent = store => component => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getPathToComponent = store => component => {
|
||||||
|
|
||||||
|
// Gets all the components to needed to construct a path.
|
||||||
|
const tempStore = get(store)
|
||||||
|
let pathComponents = []
|
||||||
|
let parent = component;
|
||||||
|
let root = false
|
||||||
|
while (!root) {
|
||||||
|
parent = getParent(tempStore.currentPreviewItem.props, parent)
|
||||||
|
if (!parent) {
|
||||||
|
root = true
|
||||||
|
} else {
|
||||||
|
pathComponents.push(parent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove root entry since it's the screen or page layout.
|
||||||
|
// Reverse array since we need the correct order of the IDs
|
||||||
|
const reversedComponents = pathComponents.reverse().slice(1)
|
||||||
|
|
||||||
|
// Add component
|
||||||
|
const allComponents = [...reversedComponents, component]
|
||||||
|
|
||||||
|
// Map IDs
|
||||||
|
const IdList = allComponents.map(c => c._id)
|
||||||
|
|
||||||
|
// Construct ID Path:
|
||||||
|
const path = IdList.join('/')
|
||||||
|
|
||||||
|
return path
|
||||||
|
}
|
||||||
|
|
||||||
const getParent = (rootProps, child) => {
|
const getParent = (rootProps, child) => {
|
||||||
let parent
|
let parent
|
||||||
walkProps(rootProps, (p, breakWalk) => {
|
walkProps(rootProps, (p, breakWalk) => {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
|
import { params, goto } from "@sveltech/routify"
|
||||||
import ComponentsHierarchyChildren from "./ComponentsHierarchyChildren.svelte"
|
import ComponentsHierarchyChildren from "./ComponentsHierarchyChildren.svelte"
|
||||||
|
|
||||||
import { last, sortBy, map, trimCharsStart, trimChars, join } from "lodash/fp"
|
import { last, sortBy, map, trimCharsStart, trimChars, join } from "lodash/fp"
|
||||||
|
@ -15,15 +16,12 @@
|
||||||
const joinPath = join("/")
|
const joinPath = join("/")
|
||||||
|
|
||||||
const normalizedName = name =>
|
const normalizedName = name =>
|
||||||
pipe(
|
pipe(name, [
|
||||||
name,
|
trimCharsStart("./"),
|
||||||
[
|
trimCharsStart("~/"),
|
||||||
trimCharsStart("./"),
|
trimCharsStart("../"),
|
||||||
trimCharsStart("~/"),
|
trimChars(" "),
|
||||||
trimCharsStart("../"),
|
])
|
||||||
trimChars(" "),
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
const lastPartOfName = c => {
|
const lastPartOfName = c => {
|
||||||
if (!c) return ""
|
if (!c) return ""
|
||||||
|
@ -35,10 +33,10 @@
|
||||||
|
|
||||||
const isFolderSelected = (current, folder) => isInSubfolder(current, folder)
|
const isFolderSelected = (current, folder) => isInSubfolder(current, folder)
|
||||||
|
|
||||||
$: _screens = pipe(
|
$: _screens = pipe(screens, [
|
||||||
screens,
|
map(c => ({ component: c, title: lastPartOfName(c) })),
|
||||||
[map(c => ({ component: c, title: lastPartOfName(c) })), sortBy("title")]
|
sortBy("title"),
|
||||||
)
|
])
|
||||||
|
|
||||||
const isScreenSelected = component =>
|
const isScreenSelected = component =>
|
||||||
component.component &&
|
component.component &&
|
||||||
|
@ -49,6 +47,11 @@
|
||||||
componentToDelete = component
|
componentToDelete = component
|
||||||
confirmDeleteDialog.show()
|
confirmDeleteDialog.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const changeScreen = screen => {
|
||||||
|
store.setCurrentScreen(screen.title)
|
||||||
|
$goto(`./:page/${screen.title}`)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="root">
|
<div class="root">
|
||||||
|
@ -57,7 +60,7 @@
|
||||||
<div
|
<div
|
||||||
class="budibase__nav-item component"
|
class="budibase__nav-item component"
|
||||||
class:selected={$store.currentComponentInfo._id === screen.component.props._id}
|
class:selected={$store.currentComponentInfo._id === screen.component.props._id}
|
||||||
on:click|stopPropagation={() => store.setCurrentScreen(screen.title)}>
|
on:click|stopPropagation={() => changeScreen(screen)}>
|
||||||
|
|
||||||
<span
|
<span
|
||||||
class="icon"
|
class="icon"
|
||||||
|
@ -78,7 +81,6 @@
|
||||||
<ComponentsHierarchyChildren
|
<ComponentsHierarchyChildren
|
||||||
components={screen.component.props._children}
|
components={screen.component.props._children}
|
||||||
currentComponent={$store.currentComponentInfo}
|
currentComponent={$store.currentComponentInfo}
|
||||||
onSelect={store.selectComponent}
|
|
||||||
onDeleteComponent={confirmDeleteComponent}
|
onDeleteComponent={confirmDeleteComponent}
|
||||||
onMoveUpComponent={store.moveUpComponent}
|
onMoveUpComponent={store.moveUpComponent}
|
||||||
onMoveDownComponent={store.moveDownComponent}
|
onMoveDownComponent={store.moveDownComponent}
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
|
import { goto } from "@sveltech/routify"
|
||||||
|
import { store } from "builderStore"
|
||||||
import { last } from "lodash/fp"
|
import { last } from "lodash/fp"
|
||||||
import { pipe } from "../common/core"
|
import { pipe } from "../common/core"
|
||||||
import {
|
import {
|
||||||
|
@ -28,11 +30,22 @@
|
||||||
return onMoveDownComponent(c)
|
return onMoveDownComponent(c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const selectComponent = component => {
|
||||||
|
// Set current component
|
||||||
|
store.selectComponent(component)
|
||||||
|
|
||||||
|
// Get ID path
|
||||||
|
const path = store.getPathToComponent(component)
|
||||||
|
|
||||||
|
// Go to correct URL
|
||||||
|
$goto(`./:page/:screen/${path}`)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
{#each components as component, index (component._id)}
|
{#each components as component, index (component._id)}
|
||||||
<li on:click|stopPropagation={() => onSelect(component)}>
|
<li on:click|stopPropagation={() => selectComponent(component)}>
|
||||||
<div
|
<div
|
||||||
class="budibase__nav-item item"
|
class="budibase__nav-item item"
|
||||||
class:selected={currentComponent === component}
|
class:selected={currentComponent === component}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
|
import { goto } from "@sveltech/routify"
|
||||||
// import { tick } from "svelte"
|
// import { tick } from "svelte"
|
||||||
import ComponentsHierarchyChildren from "./ComponentsHierarchyChildren.svelte"
|
import ComponentsHierarchyChildren from "./ComponentsHierarchyChildren.svelte"
|
||||||
|
|
||||||
|
@ -16,15 +17,12 @@
|
||||||
const joinPath = join("/")
|
const joinPath = join("/")
|
||||||
|
|
||||||
const normalizedName = name =>
|
const normalizedName = name =>
|
||||||
pipe(
|
pipe(name, [
|
||||||
name,
|
trimCharsStart("./"),
|
||||||
[
|
trimCharsStart("~/"),
|
||||||
trimCharsStart("./"),
|
trimCharsStart("../"),
|
||||||
trimCharsStart("~/"),
|
trimChars(" "),
|
||||||
trimCharsStart("../"),
|
])
|
||||||
trimChars(" "),
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
const lastPartOfName = c =>
|
const lastPartOfName = c =>
|
||||||
c && last(c.name ? c.name.split("/") : c._component.split("/"))
|
c && last(c.name ? c.name.split("/") : c._component.split("/"))
|
||||||
|
@ -33,10 +31,7 @@
|
||||||
|
|
||||||
const isFolderSelected = (current, folder) => isInSubfolder(current, folder)
|
const isFolderSelected = (current, folder) => isInSubfolder(current, folder)
|
||||||
|
|
||||||
$: _layout = pipe(
|
$: _layout = pipe(layout, [c => ({ component: c, title: lastPartOfName(c) })])
|
||||||
layout,
|
|
||||||
[c => ({ component: c, title: lastPartOfName(c) })]
|
|
||||||
)
|
|
||||||
|
|
||||||
const isScreenSelected = component =>
|
const isScreenSelected = component =>
|
||||||
component.component &&
|
component.component &&
|
||||||
|
@ -48,6 +43,11 @@
|
||||||
// await tick()
|
// await tick()
|
||||||
confirmDeleteDialog.show()
|
confirmDeleteDialog.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const setCurrentScreenToLayout = () => {
|
||||||
|
store.setScreenType("page")
|
||||||
|
$goto("./:page/page-layout")
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="pagelayoutSection">
|
<div class="pagelayoutSection">
|
||||||
|
@ -55,7 +55,7 @@
|
||||||
<div
|
<div
|
||||||
class="budibase__nav-item root"
|
class="budibase__nav-item root"
|
||||||
class:selected={$store.currentComponentInfo._id === _layout.component.props._id}
|
class:selected={$store.currentComponentInfo._id === _layout.component.props._id}
|
||||||
on:click|stopPropagation={() => store.setScreenType('page')}>
|
on:click|stopPropagation={setCurrentScreenToLayout}>
|
||||||
<span
|
<span
|
||||||
class="icon"
|
class="icon"
|
||||||
class:rotate={$store.currentPreviewItem.name !== _layout.title}>
|
class:rotate={$store.currentPreviewItem.name !== _layout.title}>
|
||||||
|
@ -71,9 +71,9 @@
|
||||||
|
|
||||||
{#if $store.currentPreviewItem.name === _layout.title && _layout.component.props._children}
|
{#if $store.currentPreviewItem.name === _layout.title && _layout.component.props._children}
|
||||||
<ComponentsHierarchyChildren
|
<ComponentsHierarchyChildren
|
||||||
|
thisComponent={_layout.component.props}
|
||||||
components={_layout.component.props._children}
|
components={_layout.component.props._children}
|
||||||
currentComponent={$store.currentComponentInfo}
|
currentComponent={$store.currentComponentInfo}
|
||||||
onSelect={store.selectComponent}
|
|
||||||
onDeleteComponent={confirmDeleteComponent}
|
onDeleteComponent={confirmDeleteComponent}
|
||||||
onMoveUpComponent={store.moveUpComponent}
|
onMoveUpComponent={store.moveUpComponent}
|
||||||
onMoveDownComponent={store.moveDownComponent}
|
onMoveDownComponent={store.moveDownComponent}
|
||||||
|
@ -89,23 +89,19 @@
|
||||||
onOk={() => store.deleteComponent(componentToDelete)} />
|
onOk={() => store.deleteComponent(componentToDelete)} />
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.components-nav-page {
|
.components-nav-page {
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
color: #000333;
|
color: #000333;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
padding-left: 20px;
|
padding-left: 20px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
opacity: 0.4;
|
opacity: 0.4;
|
||||||
letter-spacing: 1px;
|
letter-spacing: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.pagelayoutSection {
|
|
||||||
margin: 20px 0px 20px 0px;
|
|
||||||
}
|
|
||||||
.root {
|
|
||||||
|
|
||||||
|
.pagelayoutSection {
|
||||||
|
margin: 20px 0px 20px 0px;
|
||||||
}
|
}
|
||||||
.title {
|
.title {
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
|
import { params, goto } from "@sveltech/routify"
|
||||||
import { store } from "builderStore"
|
import { store } from "builderStore"
|
||||||
import getIcon from "components/common/icon"
|
import getIcon from "components/common/icon"
|
||||||
import { CheckIcon } from "components/common/Icons"
|
import { CheckIcon } from "components/common/Icons"
|
||||||
|
@ -19,7 +20,12 @@
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
store.setCurrentPage("main")
|
store.setCurrentPage($params.page ? $params.page : "main")
|
||||||
|
|
||||||
|
const changePage = id => {
|
||||||
|
store.setCurrentPage(id)
|
||||||
|
$goto(`./${id}/page-layout`)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="root">
|
<div class="root">
|
||||||
|
@ -27,14 +33,14 @@
|
||||||
{#each pages as { title, id }}
|
{#each pages as { title, id }}
|
||||||
<li>
|
<li>
|
||||||
<span class="icon">
|
<span class="icon">
|
||||||
{#if id === $store.currentPageName}
|
{#if id === $params.page}
|
||||||
<CheckIcon />
|
<CheckIcon />
|
||||||
{/if}
|
{/if}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
class:active={id === $store.currentPageName}
|
class:active={id === $params.page}
|
||||||
on:click={() => store.setCurrentPage(id)}>
|
on:click={() => changePage(id)}>
|
||||||
{title}
|
{title}
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -1,240 +0,0 @@
|
||||||
<script>
|
|
||||||
import ComponentsHierarchy from "./ComponentsHierarchy.svelte"
|
|
||||||
import ComponentsHierarchyChildren from "./ComponentsHierarchyChildren.svelte"
|
|
||||||
import PageLayout from "./PageLayout.svelte"
|
|
||||||
import PagesList from "./PagesList.svelte"
|
|
||||||
import { store } from "builderStore"
|
|
||||||
import IconButton from "components/common/IconButton.svelte"
|
|
||||||
import NewScreen from "./NewScreen.svelte"
|
|
||||||
import CurrentItemPreview from "./CurrentItemPreview.svelte"
|
|
||||||
import SettingsView from "./SettingsView.svelte"
|
|
||||||
import PageView from "./PageView.svelte"
|
|
||||||
import ComponentsPaneSwitcher from "./ComponentsPaneSwitcher.svelte"
|
|
||||||
import ConfirmDialog from "components/common/ConfirmDialog.svelte"
|
|
||||||
import { last } from "lodash/fp"
|
|
||||||
import { AddIcon } from "components/common/Icons"
|
|
||||||
|
|
||||||
let newScreenPicker
|
|
||||||
let confirmDeleteDialog
|
|
||||||
let componentToDelete = ""
|
|
||||||
|
|
||||||
const newScreen = () => {
|
|
||||||
newScreenPicker.show()
|
|
||||||
}
|
|
||||||
|
|
||||||
let settingsView
|
|
||||||
const settings = () => {
|
|
||||||
settingsView.show()
|
|
||||||
}
|
|
||||||
|
|
||||||
const confirmDeleteComponent = component => {
|
|
||||||
componentToDelete = component
|
|
||||||
confirmDeleteDialog.show()
|
|
||||||
}
|
|
||||||
|
|
||||||
const lastPartOfName = c => (c ? last(c.split("/")) : "")
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div class="root">
|
|
||||||
|
|
||||||
<div class="ui-nav">
|
|
||||||
|
|
||||||
<div class="pages-list-container">
|
|
||||||
<div class="nav-header">
|
|
||||||
<span class="navigator-title">Navigator</span>
|
|
||||||
<div class="border-line" />
|
|
||||||
|
|
||||||
<span class="components-nav-page">Pages</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="nav-items-container">
|
|
||||||
<PagesList />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="border-line" />
|
|
||||||
|
|
||||||
<PageLayout layout={$store.pages[$store.currentPageName]} />
|
|
||||||
|
|
||||||
<div class="border-line" />
|
|
||||||
|
|
||||||
<div class="components-list-container">
|
|
||||||
<div class="nav-group-header">
|
|
||||||
<span class="components-nav-header" style="margin-top: 0;">
|
|
||||||
Screens
|
|
||||||
</span>
|
|
||||||
<div>
|
|
||||||
<button on:click={newScreen}>
|
|
||||||
<AddIcon />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="nav-items-container">
|
|
||||||
<ComponentsHierarchy screens={$store.screens} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="preview-pane">
|
|
||||||
<CurrentItemPreview />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{#if $store.currentFrontEndType === 'screen' || $store.currentFrontEndType === 'page'}
|
|
||||||
<div class="components-pane">
|
|
||||||
<ComponentsPaneSwitcher />
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<NewScreen bind:this={newScreenPicker} />
|
|
||||||
<SettingsView bind:this={settingsView} />
|
|
||||||
|
|
||||||
<ConfirmDialog
|
|
||||||
bind:this={confirmDeleteDialog}
|
|
||||||
title="Confirm Delete"
|
|
||||||
body={`Are you sure you wish to delete this '${lastPartOfName(componentToDelete)}' component`}
|
|
||||||
okText="Delete Component"
|
|
||||||
onOk={() => store.deleteComponent(componentToDelete)} />
|
|
||||||
|
|
||||||
<style>
|
|
||||||
button {
|
|
||||||
cursor: pointer;
|
|
||||||
outline: none;
|
|
||||||
border: none;
|
|
||||||
border-radius: 5px;
|
|
||||||
width: 20px;
|
|
||||||
padding-bottom: 10px;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.root {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 275px 1fr 275px;
|
|
||||||
height: 100%;
|
|
||||||
width: 100%;
|
|
||||||
background: #fafafa;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media only screen and (min-width: 1800px) {
|
|
||||||
.root {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 300px 1fr 300px;
|
|
||||||
height: 100%;
|
|
||||||
width: 100%;
|
|
||||||
background: #fafafa;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.ui-nav {
|
|
||||||
grid-column: 1;
|
|
||||||
background-color: var(--white);
|
|
||||||
height: calc(100vh - 49px);
|
|
||||||
padding: 0;
|
|
||||||
overflow: scroll;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
.preview-pane {
|
|
||||||
grid-column: 2;
|
|
||||||
margin: 40px;
|
|
||||||
background: #fff;
|
|
||||||
border-radius: 5px;
|
|
||||||
box-shadow: 0 0px 6px rgba(0, 0, 0, 0.05);
|
|
||||||
}
|
|
||||||
|
|
||||||
.components-pane {
|
|
||||||
grid-column: 3;
|
|
||||||
background-color: var(--white);
|
|
||||||
min-height: 0px;
|
|
||||||
overflow-y: scroll;
|
|
||||||
}
|
|
||||||
|
|
||||||
.components-nav-page {
|
|
||||||
font-size: 13px;
|
|
||||||
color: #000333;
|
|
||||||
text-transform: uppercase;
|
|
||||||
padding-left: 20px;
|
|
||||||
margin-top: 20px;
|
|
||||||
font-weight: 600;
|
|
||||||
opacity: 0.4;
|
|
||||||
letter-spacing: 1px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.components-nav-header {
|
|
||||||
font-size: 13px;
|
|
||||||
color: #000333;
|
|
||||||
text-transform: uppercase;
|
|
||||||
margin-top: 20px;
|
|
||||||
font-weight: 600;
|
|
||||||
opacity: 0.4;
|
|
||||||
letter-spacing: 1px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-header {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
margin-top: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-items-container {
|
|
||||||
padding: 1rem 0rem 0rem 0rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-group-header {
|
|
||||||
display: flex;
|
|
||||||
padding: 0px 20px 0px 20px;
|
|
||||||
font-size: 0.9rem;
|
|
||||||
font-weight: bold;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-group-header > div:nth-child(1) {
|
|
||||||
padding: 0rem 0.5rem 0rem 0rem;
|
|
||||||
vertical-align: bottom;
|
|
||||||
grid-column-start: icon;
|
|
||||||
margin-right: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-group-header > span:nth-child(3) {
|
|
||||||
margin-left: 5px;
|
|
||||||
vertical-align: bottom;
|
|
||||||
grid-column-start: title;
|
|
||||||
margin-top: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-group-header > div:nth-child(3) {
|
|
||||||
vertical-align: bottom;
|
|
||||||
grid-column-start: button;
|
|
||||||
cursor: pointer;
|
|
||||||
color: var(--primary75);
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-group-header > div:nth-child(3):hover {
|
|
||||||
color: var(--primary75);
|
|
||||||
}
|
|
||||||
|
|
||||||
.navigator-title {
|
|
||||||
font-size: 14px;
|
|
||||||
color: var(--secondary100);
|
|
||||||
font-weight: 600;
|
|
||||||
text-transform: uppercase;
|
|
||||||
padding: 0 20px 20px 20px;
|
|
||||||
line-height: 1rem !important;
|
|
||||||
letter-spacing: 1px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.border-line {
|
|
||||||
border-bottom: 1px solid #d8d8d8;
|
|
||||||
}
|
|
||||||
|
|
||||||
.components-list-container {
|
|
||||||
padding: 20px 0px 0 0;
|
|
||||||
}
|
|
||||||
</style>
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
<script>
|
||||||
|
import { onMount } from "svelte"
|
||||||
|
import { params, leftover } from "@sveltech/routify"
|
||||||
|
import { store } from "builderStore"
|
||||||
|
|
||||||
|
// Get any leftover params not caught by Routifys params store.
|
||||||
|
const componentIds = $leftover.split("/").filter(id => id !== "")
|
||||||
|
|
||||||
|
// It's a screen, set it to that screen
|
||||||
|
if ($params.screen !== "page-layout") {
|
||||||
|
store.setCurrentScreen($params.screen)
|
||||||
|
|
||||||
|
// There are leftover stuff, like IDs, so navigate the components and find the ID and select it.
|
||||||
|
if ($leftover) {
|
||||||
|
// Get the correct screen children.
|
||||||
|
const screenChildren = $store.pages[$params.page]._screens.find(
|
||||||
|
screen => screen.name === $params.screen
|
||||||
|
).props._children
|
||||||
|
findComponent(componentIds, screenChildren)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// It's a page, so set the screentype to page.
|
||||||
|
store.setScreenType("page")
|
||||||
|
|
||||||
|
// There are leftover stuff, like IDs, so navigate the components and find the ID and select it.
|
||||||
|
if ($leftover) {
|
||||||
|
findComponent(componentIds, $store.pages[$params.page].props._children)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find Component with ID and continue
|
||||||
|
function findComponent(ids, children) {
|
||||||
|
// Setup stuff
|
||||||
|
let componentToSelect
|
||||||
|
let currentChildren = children
|
||||||
|
|
||||||
|
// Loop through each ID
|
||||||
|
ids.forEach(id => {
|
||||||
|
// Find ID and select it
|
||||||
|
componentToSelect = currentChildren.find(child => child._id === id)
|
||||||
|
|
||||||
|
// Update childrens array to selected components children
|
||||||
|
currentChildren = componentToSelect._children
|
||||||
|
})
|
||||||
|
|
||||||
|
// Select Component!
|
||||||
|
store.selectComponent(componentToSelect)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<slot />
|
|
@ -0,0 +1,8 @@
|
||||||
|
<script>
|
||||||
|
import { params } from "@sveltech/routify"
|
||||||
|
import { store } from "builderStore"
|
||||||
|
|
||||||
|
store.setCurrentPage($params.page)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<slot />
|
|
@ -2,6 +2,19 @@
|
||||||
import { store, backendUiStore } from "builderStore"
|
import { store, backendUiStore } from "builderStore"
|
||||||
import { goto } from "@sveltech/routify"
|
import { goto } from "@sveltech/routify"
|
||||||
import { onMount } from "svelte"
|
import { onMount } from "svelte"
|
||||||
|
import ComponentsHierarchy from "components/userInterface/ComponentsHierarchy.svelte"
|
||||||
|
import ComponentsHierarchyChildren from "components/userInterface/ComponentsHierarchyChildren.svelte"
|
||||||
|
import PageLayout from "components/userInterface/PageLayout.svelte"
|
||||||
|
import PagesList from "components/userInterface/PagesList.svelte"
|
||||||
|
import IconButton from "components/common/IconButton.svelte"
|
||||||
|
import NewScreen from "components/userInterface/NewScreen.svelte"
|
||||||
|
import CurrentItemPreview from "components/userInterface/CurrentItemPreview.svelte"
|
||||||
|
import SettingsView from "components/userInterface/SettingsView.svelte"
|
||||||
|
import PageView from "components/userInterface/PageView.svelte"
|
||||||
|
import ComponentsPaneSwitcher from "components/userInterface/ComponentsPaneSwitcher.svelte"
|
||||||
|
import ConfirmDialog from "components/common/ConfirmDialog.svelte"
|
||||||
|
import { last } from "lodash/fp"
|
||||||
|
import { AddIcon } from "components/common/Icons"
|
||||||
|
|
||||||
$: instances = $store.appInstances
|
$: instances = $store.appInstances
|
||||||
$: views = $store.hierarchy.indexes
|
$: views = $store.hierarchy.indexes
|
||||||
|
@ -17,6 +30,230 @@
|
||||||
await selectDatabase($store.appInstances[0])
|
await selectDatabase($store.appInstances[0])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
let newScreenPicker
|
||||||
|
let confirmDeleteDialog
|
||||||
|
let componentToDelete = ""
|
||||||
|
|
||||||
|
const newScreen = () => {
|
||||||
|
newScreenPicker.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
let settingsView
|
||||||
|
const settings = () => {
|
||||||
|
settingsView.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
const confirmDeleteComponent = component => {
|
||||||
|
componentToDelete = component
|
||||||
|
confirmDeleteDialog.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
const lastPartOfName = c => (c ? last(c.split("/")) : "")
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<div class="root">
|
||||||
|
|
||||||
|
<div class="ui-nav">
|
||||||
|
|
||||||
|
<div class="pages-list-container">
|
||||||
|
<div class="nav-header">
|
||||||
|
<span class="navigator-title">Navigator</span>
|
||||||
|
<div class="border-line" />
|
||||||
|
|
||||||
|
<span class="components-nav-page">Pages</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="nav-items-container">
|
||||||
|
<PagesList />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="border-line" />
|
||||||
|
|
||||||
|
<PageLayout layout={$store.pages[$store.currentPageName]} />
|
||||||
|
|
||||||
|
<div class="border-line" />
|
||||||
|
|
||||||
|
<div class="components-list-container">
|
||||||
|
<div class="nav-group-header">
|
||||||
|
<span class="components-nav-header" style="margin-top: 0;">
|
||||||
|
Screens
|
||||||
|
</span>
|
||||||
|
<div>
|
||||||
|
<button on:click={newScreen}>
|
||||||
|
<AddIcon />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="nav-items-container">
|
||||||
|
<ComponentsHierarchy screens={$store.screens} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="preview-pane">
|
||||||
|
<CurrentItemPreview />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{#if $store.currentFrontEndType === 'screen' || $store.currentFrontEndType === 'page'}
|
||||||
|
<div class="components-pane">
|
||||||
|
<ComponentsPaneSwitcher />
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<NewScreen bind:this={newScreenPicker} />
|
||||||
|
<SettingsView bind:this={settingsView} />
|
||||||
|
|
||||||
|
<ConfirmDialog
|
||||||
|
bind:this={confirmDeleteDialog}
|
||||||
|
title="Confirm Delete"
|
||||||
|
body={`Are you sure you wish to delete this '${lastPartOfName(componentToDelete)}' component`}
|
||||||
|
okText="Delete Component"
|
||||||
|
onOk={() => store.deleteComponent(componentToDelete)} />
|
||||||
|
|
||||||
<slot />
|
<slot />
|
||||||
|
|
||||||
|
<style>
|
||||||
|
button {
|
||||||
|
cursor: pointer;
|
||||||
|
outline: none;
|
||||||
|
border: none;
|
||||||
|
border-radius: 5px;
|
||||||
|
width: 20px;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.root {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 275px 1fr 275px;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
background: #fafafa;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media only screen and (min-width: 1800px) {
|
||||||
|
.root {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 300px 1fr 300px;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
background: #fafafa;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.ui-nav {
|
||||||
|
grid-column: 1;
|
||||||
|
background-color: var(--white);
|
||||||
|
height: calc(100vh - 49px);
|
||||||
|
padding: 0;
|
||||||
|
overflow: scroll;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.preview-pane {
|
||||||
|
grid-column: 2;
|
||||||
|
margin: 40px;
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 5px;
|
||||||
|
box-shadow: 0 0px 6px rgba(0, 0, 0, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.components-pane {
|
||||||
|
grid-column: 3;
|
||||||
|
background-color: var(--white);
|
||||||
|
min-height: 0px;
|
||||||
|
overflow-y: scroll;
|
||||||
|
}
|
||||||
|
|
||||||
|
.components-nav-page {
|
||||||
|
font-size: 13px;
|
||||||
|
color: #000333;
|
||||||
|
text-transform: uppercase;
|
||||||
|
padding-left: 20px;
|
||||||
|
margin-top: 20px;
|
||||||
|
font-weight: 600;
|
||||||
|
opacity: 0.4;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.components-nav-header {
|
||||||
|
font-size: 13px;
|
||||||
|
color: #000333;
|
||||||
|
text-transform: uppercase;
|
||||||
|
margin-top: 20px;
|
||||||
|
font-weight: 600;
|
||||||
|
opacity: 0.4;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-header {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-items-container {
|
||||||
|
padding: 1rem 0rem 0rem 0rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-group-header {
|
||||||
|
display: flex;
|
||||||
|
padding: 0px 20px 0px 20px;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
font-weight: bold;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-group-header > div:nth-child(1) {
|
||||||
|
padding: 0rem 0.5rem 0rem 0rem;
|
||||||
|
vertical-align: bottom;
|
||||||
|
grid-column-start: icon;
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-group-header > span:nth-child(3) {
|
||||||
|
margin-left: 5px;
|
||||||
|
vertical-align: bottom;
|
||||||
|
grid-column-start: title;
|
||||||
|
margin-top: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-group-header > div:nth-child(3) {
|
||||||
|
vertical-align: bottom;
|
||||||
|
grid-column-start: button;
|
||||||
|
cursor: pointer;
|
||||||
|
color: var(--primary75);
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-group-header > div:nth-child(3):hover {
|
||||||
|
color: var(--primary75);
|
||||||
|
}
|
||||||
|
|
||||||
|
.navigator-title {
|
||||||
|
font-size: 14px;
|
||||||
|
color: var(--secondary100);
|
||||||
|
font-weight: 600;
|
||||||
|
text-transform: uppercase;
|
||||||
|
padding: 0 20px 20px 20px;
|
||||||
|
line-height: 1rem !important;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.border-line {
|
||||||
|
border-bottom: 1px solid #d8d8d8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.components-list-container {
|
||||||
|
padding: 20px 0px 0 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
import UserInterfaceRoot from "components/userInterface/UserInterfaceRoot.svelte"
|
import { goto } from "@sveltech/routify"
|
||||||
|
$goto("../main")
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<UserInterfaceRoot />
|
<!-- routify:options index=false -->
|
||||||
|
|
Loading…
Reference in New Issue