From f386d0c72beb5e144a42858732f16a108f7bf7e1 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Wed, 2 Dec 2020 17:07:30 +0000 Subject: [PATCH] tidy up --- .../modals/CreateTableModal.svelte | 1 - .../userInterface/ComponentDropdownMenu.svelte | 2 +- .../ComponentTree.svelte | 18 +++++++++--------- .../ComponentNavigationTree/PathTree.svelte | 9 ++++++--- .../ComponentNavigationTree/dragDropStore.js | 2 +- .../ComponentSelectionList.svelte | 2 +- .../src/components/userInterface/Layout.svelte | 5 +++-- .../userInterface/LayoutsList.svelte | 2 +- 8 files changed, 22 insertions(+), 19 deletions(-) diff --git a/packages/builder/src/components/backend/TableNavigator/modals/CreateTableModal.svelte b/packages/builder/src/components/backend/TableNavigator/modals/CreateTableModal.svelte index 75b27f71d3..7c26e236a6 100644 --- a/packages/builder/src/components/backend/TableNavigator/modals/CreateTableModal.svelte +++ b/packages/builder/src/components/backend/TableNavigator/modals/CreateTableModal.svelte @@ -51,7 +51,6 @@ const screens = screenTemplates($store, [table]) .filter(template => defaultScreens.includes(template.id)) .map(template => template.create()) - store.actions.layouts.select("main") for (let screen of screens) { // Record the table that created this screen so we can link it later screen.autoTableId = table._id diff --git a/packages/builder/src/components/userInterface/ComponentDropdownMenu.svelte b/packages/builder/src/components/userInterface/ComponentDropdownMenu.svelte index a6b8a63cbb..615b3d0852 100644 --- a/packages/builder/src/components/userInterface/ComponentDropdownMenu.svelte +++ b/packages/builder/src/components/userInterface/ComponentDropdownMenu.svelte @@ -28,7 +28,7 @@ const selectComponent = component => { store.actions.components.select(component) const path = store.actions.components.findRoute(component) - $goto(`./:screen/${path}`) + // $goto(`./:screen/${path}`) } const moveUpComponent = () => { diff --git a/packages/builder/src/components/userInterface/ComponentNavigationTree/ComponentTree.svelte b/packages/builder/src/components/userInterface/ComponentNavigationTree/ComponentTree.svelte index db5e747be4..d858394d80 100644 --- a/packages/builder/src/components/userInterface/ComponentNavigationTree/ComponentTree.svelte +++ b/packages/builder/src/components/userInterface/ComponentNavigationTree/ComponentTree.svelte @@ -2,16 +2,16 @@ import { goto } from "@sveltech/routify" import { store } from "builderStore" import { getComponentDefinition } from "builderStore/storeUtils" - import initDragDropStore, { DropEffect, DropPosition } from "./dragDropStore" + import { DropEffect, DropPosition } from "./dragDropStore" import ComponentDropdownMenu from "../ComponentDropdownMenu.svelte" import NavItem from "components/common/NavItem.svelte" + export let layout export let components = [] export let currentComponent export let onSelect = () => {} export let level = 0 - - export let dragDropStore = initDragDropStore() + export let dragDropStore const isScreenslot = name => name === "##builtin/screenslot" @@ -23,12 +23,11 @@ const path = store.actions.components.findRoute(component) // Go to correct URL - $goto(`./${path}`) - // if (layout) { - // $goto(`./layouts/:layout/${path}`) - // } else { - // $goto(`./screens/:screen/${path}`) - // } + if (layout) { + $goto(`./layouts/${path}`) + } else { + $goto(`./screens/${path}`) + } } const dragstart = component => e => { @@ -84,6 +83,7 @@ {#if component._children} changeScreen(screenId)}> - + {#if selectedScreen?._id === screenId} - {/if} {/each} diff --git a/packages/builder/src/components/userInterface/ComponentNavigationTree/dragDropStore.js b/packages/builder/src/components/userInterface/ComponentNavigationTree/dragDropStore.js index 1aa180e938..e657b12bb9 100644 --- a/packages/builder/src/components/userInterface/ComponentNavigationTree/dragDropStore.js +++ b/packages/builder/src/components/userInterface/ComponentNavigationTree/dragDropStore.js @@ -48,7 +48,7 @@ export default function() { if (mousePosition > 0.4 && mousePosition < 0.8) { state.dropPosition = DropPosition.INSIDE } - return + return state } // bottom half diff --git a/packages/builder/src/components/userInterface/ComponentSelectionList.svelte b/packages/builder/src/components/userInterface/ComponentSelectionList.svelte index aa468b8870..b7d0fd1f11 100644 --- a/packages/builder/src/components/userInterface/ComponentSelectionList.svelte +++ b/packages/builder/src/components/userInterface/ComponentSelectionList.svelte @@ -27,7 +27,7 @@ const onComponentChosen = component => { store.actions.components.create(component._component, component.presetProps) const path = store.actions.components.findRoute($store.currentComponentInfo) - $goto(`./:screen/${path}`) + // $goto(`./:screen/${path}`) // $goto(`./${path}`) close() } diff --git a/packages/builder/src/components/userInterface/Layout.svelte b/packages/builder/src/components/userInterface/Layout.svelte index d0e30441e3..d684a4f68c 100644 --- a/packages/builder/src/components/userInterface/Layout.svelte +++ b/packages/builder/src/components/userInterface/Layout.svelte @@ -2,6 +2,7 @@ import { goto } from "@sveltech/routify" import { FrontendTypes } from "constants" import ComponentTree from "./ComponentNavigationTree/ComponentTree.svelte" + import initDragDropStore from "./ComponentNavigationTree/dragDropStore" import NavItem from "components/common/NavItem.svelte" import { last } from "lodash/fp" import { store, currentAsset } from "builderStore" @@ -12,7 +13,7 @@ let confirmDeleteDialog let componentToDelete = "" - const dragDropStore = writable({}) + const dragDropStore = initDragDropStore(); const setCurrentScreenToLayout = () => { store.actions.selectAssetType(FrontendTypes.LAYOUT) @@ -31,7 +32,7 @@ {#if $currentAsset._id === layout._id && layout.props._children} diff --git a/packages/builder/src/components/userInterface/LayoutsList.svelte b/packages/builder/src/components/userInterface/LayoutsList.svelte index ce2e3fac2f..9ba562f81c 100644 --- a/packages/builder/src/components/userInterface/LayoutsList.svelte +++ b/packages/builder/src/components/userInterface/LayoutsList.svelte @@ -15,7 +15,7 @@ if (!$store.currentAssetId) { // refactor so the right layout is chosen - store.actions.layouts.select($params.layout || "main") + store.actions.layouts.select($params.layout) } const changeLayout = id => {