adds working routing for clicking on components
This commit is contained in:
parent
7b77195d16
commit
4514329dfa
|
@ -1,4 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
|
import { goto } from "@sveltech/routify"
|
||||||
import { store } from "builderStore"
|
import { store } from "builderStore"
|
||||||
import { last } from "lodash/fp"
|
import { last } from "lodash/fp"
|
||||||
import { pipe } from "../common/core"
|
import { pipe } from "../common/core"
|
||||||
|
@ -17,7 +18,6 @@
|
||||||
export let onMoveUpComponent
|
export let onMoveUpComponent
|
||||||
export let onMoveDownComponent
|
export let onMoveDownComponent
|
||||||
export let onCopyComponent
|
export let onCopyComponent
|
||||||
export let ids = []
|
|
||||||
|
|
||||||
const capitalise = s => s.substring(0, 1).toUpperCase() + s.substring(1)
|
const capitalise = s => s.substring(0, 1).toUpperCase() + s.substring(1)
|
||||||
const get_name = s => (!s ? "" : last(s.split("/")))
|
const get_name = s => (!s ? "" : last(s.split("/")))
|
||||||
|
@ -31,14 +31,21 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const selectComponent = (ids, component) => {
|
const selectComponent = component => {
|
||||||
|
// Set current component
|
||||||
store.selectComponent(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={() => selectComponent(ids, 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}
|
||||||
|
|
|
@ -71,6 +71,7 @@
|
||||||
|
|
||||||
{#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}
|
||||||
onDeleteComponent={confirmDeleteComponent}
|
onDeleteComponent={confirmDeleteComponent}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
const changePage = id => {
|
const changePage = id => {
|
||||||
store.setCurrentPage(id)
|
store.setCurrentPage(id)
|
||||||
$goto(`./${id}`)
|
$goto(`./${id}/page-layout`)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue