2020-02-20 18:11:41 +01:00
|
|
|
<script>
|
2020-04-28 15:28:31 +02:00
|
|
|
import { goto } from "@sveltech/routify"
|
2020-02-20 18:11:41 +01:00
|
|
|
// import { tick } from "svelte"
|
|
|
|
import ComponentsHierarchyChildren from "./ComponentsHierarchyChildren.svelte"
|
|
|
|
|
2020-05-07 11:53:34 +02:00
|
|
|
import {
|
|
|
|
last,
|
|
|
|
sortBy,
|
|
|
|
map,
|
|
|
|
trimCharsStart,
|
|
|
|
trimChars,
|
|
|
|
join,
|
|
|
|
compose,
|
|
|
|
} from "lodash/fp"
|
2020-03-31 13:16:03 +02:00
|
|
|
import ConfirmDialog from "components/common/ConfirmDialog.svelte"
|
|
|
|
import { pipe } from "components/common/core"
|
|
|
|
import { store } from "builderStore"
|
|
|
|
import { ArrowDownIcon, GridIcon } from "components/common/Icons/"
|
2020-02-20 18:11:41 +01:00
|
|
|
|
|
|
|
export let layout
|
|
|
|
|
|
|
|
let confirmDeleteDialog
|
|
|
|
let componentToDelete = ""
|
|
|
|
|
|
|
|
const joinPath = join("/")
|
|
|
|
|
|
|
|
const lastPartOfName = c =>
|
|
|
|
c && last(c.name ? c.name.split("/") : c._component.split("/"))
|
|
|
|
|
|
|
|
const isComponentSelected = (current, comp) => current === comp
|
|
|
|
|
2020-05-02 16:29:10 +02:00
|
|
|
$: _layout = {
|
|
|
|
component: layout,
|
2020-05-07 11:53:34 +02:00
|
|
|
title: lastPartOfName(layout),
|
2020-05-02 16:29:10 +02:00
|
|
|
}
|
2020-02-20 18:11:41 +01:00
|
|
|
|
|
|
|
const confirmDeleteComponent = async component => {
|
|
|
|
componentToDelete = component
|
|
|
|
confirmDeleteDialog.show()
|
|
|
|
}
|
2020-04-28 15:28:31 +02:00
|
|
|
|
|
|
|
const setCurrentScreenToLayout = () => {
|
|
|
|
store.setScreenType("page")
|
|
|
|
$goto("./:page/page-layout")
|
|
|
|
}
|
2020-02-20 18:11:41 +01:00
|
|
|
</script>
|
|
|
|
|
2020-04-02 18:11:38 +02:00
|
|
|
<div class="pagelayoutSection">
|
|
|
|
<div class="components-nav-page">Page Layout</div>
|
2020-02-25 00:23:33 +01:00
|
|
|
<div
|
2020-04-02 17:37:22 +02:00
|
|
|
class="budibase__nav-item root"
|
2020-02-25 00:23:33 +01:00
|
|
|
class:selected={$store.currentComponentInfo._id === _layout.component.props._id}
|
2020-04-28 15:28:31 +02:00
|
|
|
on:click|stopPropagation={setCurrentScreenToLayout}>
|
2020-02-20 18:11:41 +01:00
|
|
|
<span
|
|
|
|
class="icon"
|
|
|
|
class:rotate={$store.currentPreviewItem.name !== _layout.title}>
|
2020-04-02 17:37:22 +02:00
|
|
|
<ArrowDownIcon />
|
2020-02-20 18:11:41 +01:00
|
|
|
</span>
|
|
|
|
|
|
|
|
<span class="icon">
|
|
|
|
<GridIcon />
|
|
|
|
</span>
|
|
|
|
|
2020-04-02 17:37:22 +02:00
|
|
|
<span class="title">Page Layout</span>
|
2020-02-20 18:11:41 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
{#if $store.currentPreviewItem.name === _layout.title && _layout.component.props._children}
|
|
|
|
<ComponentsHierarchyChildren
|
2020-05-04 10:32:25 +02:00
|
|
|
thisComponent={_layout.component.props}
|
2020-02-20 18:11:41 +01:00
|
|
|
components={_layout.component.props._children}
|
|
|
|
currentComponent={$store.currentComponentInfo}
|
|
|
|
onDeleteComponent={confirmDeleteComponent}
|
|
|
|
onMoveUpComponent={store.moveUpComponent}
|
|
|
|
onMoveDownComponent={store.moveDownComponent}
|
|
|
|
onCopyComponent={store.copyComponent} />
|
|
|
|
{/if}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<ConfirmDialog
|
|
|
|
bind:this={confirmDeleteDialog}
|
|
|
|
title="Confirm Delete"
|
2020-02-24 17:41:02 +01:00
|
|
|
body={`Are you sure you wish to delete this '${lastPartOfName(componentToDelete)}' component?`}
|
2020-02-20 18:11:41 +01:00
|
|
|
okText="Delete Component"
|
|
|
|
onOk={() => store.deleteComponent(componentToDelete)} />
|
|
|
|
|
|
|
|
<style>
|
2020-04-28 15:28:31 +02:00
|
|
|
.components-nav-page {
|
|
|
|
font-size: 13px;
|
|
|
|
color: #000333;
|
|
|
|
text-transform: uppercase;
|
|
|
|
margin-bottom: 10px;
|
|
|
|
padding-left: 20px;
|
|
|
|
font-weight: 600;
|
|
|
|
opacity: 0.4;
|
|
|
|
letter-spacing: 1px;
|
|
|
|
}
|
2020-04-02 18:11:38 +02:00
|
|
|
|
2020-04-28 15:28:31 +02:00
|
|
|
.pagelayoutSection {
|
|
|
|
margin: 20px 0px 20px 0px;
|
2020-04-02 17:37:22 +02:00
|
|
|
}
|
2020-02-20 18:11:41 +01:00
|
|
|
.title {
|
|
|
|
margin-left: 10px;
|
2020-04-02 18:11:38 +02:00
|
|
|
font-size: 13px;
|
2020-02-20 18:11:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
.icon {
|
|
|
|
display: inline-block;
|
|
|
|
transition: 0.2s;
|
|
|
|
width: 20px;
|
|
|
|
margin-top: 2px;
|
2020-04-02 18:11:38 +02:00
|
|
|
color: #000333;
|
2020-02-20 18:11:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
.icon:nth-of-type(2) {
|
|
|
|
width: 14px;
|
|
|
|
margin: 0 0 0 5px;
|
|
|
|
}
|
|
|
|
|
|
|
|
:global(svg) {
|
|
|
|
transition: 0.2s;
|
|
|
|
}
|
|
|
|
|
|
|
|
.rotate :global(svg) {
|
|
|
|
transform: rotate(-90deg);
|
|
|
|
}
|
|
|
|
</style>
|