This commit is contained in:
Gerard Burns 2024-03-04 08:07:15 +00:00
parent 2f90d7f431
commit f1208919ee
5 changed files with 20 additions and 14 deletions

View File

@ -4,7 +4,7 @@
selectedScreen, selectedScreen,
componentStore, componentStore,
selectedComponent, selectedComponent,
componentTreeNodesStore componentTreeNodesStore,
} from "stores/builder" } from "stores/builder"
import { findComponent } from "helpers/components" import { findComponent } from "helpers/components"
import { goto, isActive } from "@roxi/routify" import { goto, isActive } from "@roxi/routify"

View File

@ -8,7 +8,7 @@
userSelectedResourceMap, userSelectedResourceMap,
selectedComponent, selectedComponent,
hoverStore, hoverStore,
componentTreeNodesStore componentTreeNodesStore,
} from "stores/builder" } from "stores/builder"
import { import {
findComponentPath, findComponentPath,

View File

@ -20,9 +20,11 @@ const expandNode = componentId => {
const expandNodes = componentIds => { const expandNodes = componentIds => {
baseStore.update(openNodes => { baseStore.update(openNodes => {
const newNodes = Object.fromEntries(componentIds.map(id => ([`nodeOpen-${id}`, true]))) const newNodes = Object.fromEntries(
componentIds.map(id => [`nodeOpen-${id}`, true])
)
return { ...openNodes, ...newNodes }; return { ...openNodes, ...newNodes }
}) })
} }

View File

@ -19,7 +19,7 @@ import {
appStore, appStore,
previewStore, previewStore,
tables, tables,
componentTreeNodesStore componentTreeNodesStore,
} from "stores/builder/index" } from "stores/builder/index"
import { buildFormSchema, getSchemaForDatasource } from "dataBinding" import { buildFormSchema, getSchemaForDatasource } from "dataBinding"
import { import {
@ -654,7 +654,9 @@ export class ComponentStore extends BudiStore {
state.selectedScreenId = targetScreenId state.selectedScreenId = targetScreenId
state.selectedComponentId = newComponentId state.selectedComponentId = newComponentId
const targetScreen = get(screenStore).screens.find(screen => screen.id === targetScreenId) const targetScreen = get(screenStore).screens.find(
screen => screen.id === targetScreenId
)
const componentPathIds = findComponentPath( const componentPathIds = findComponentPath(
targetScreen?.props, targetScreen?.props,
@ -814,7 +816,10 @@ export class ComponentStore extends BudiStore {
// sibling // sibling
const previousSibling = parent._children[index - 1] const previousSibling = parent._children[index - 1]
const definition = this.getDefinition(previousSibling._component) const definition = this.getDefinition(previousSibling._component)
if (definition.hasChildren && componentTreeNodes[`nodeOpen-${previousSibling._id}`] !== false) { if (
definition.hasChildren &&
componentTreeNodes[`nodeOpen-${previousSibling._id}`] !== false
) {
previousSibling._children.push(originalComponent) previousSibling._children.push(originalComponent)
} }
@ -842,7 +847,6 @@ export class ComponentStore extends BudiStore {
const parent = findComponentParent(screen.props, componentId) const parent = findComponentParent(screen.props, componentId)
const componentTreeNodes = get(componentTreeNodesStore) const componentTreeNodes = get(componentTreeNodesStore)
// Sanity check parent is found // Sanity check parent is found
if (!parent?._children?.length) { if (!parent?._children?.length) {
return false return false
@ -868,7 +872,10 @@ export class ComponentStore extends BudiStore {
// If the next sibling has children, and is not collapsed, become the first child // If the next sibling has children, and is not collapsed, become the first child
const nextSibling = parent._children[index] const nextSibling = parent._children[index]
const definition = this.getDefinition(nextSibling._component) const definition = this.getDefinition(nextSibling._component)
if (definition.hasChildren && componentTreeNodes[`nodeOpen-${nextSibling._id}`] !== false) { if (
definition.hasChildren &&
componentTreeNodes[`nodeOpen-${nextSibling._id}`] !== false
) {
nextSibling._children.splice(0, 0, originalComponent) nextSibling._children.splice(0, 0, originalComponent)
} }

View File

@ -1,9 +1,6 @@
import { layoutStore } from "./layouts.js" import { layoutStore } from "./layouts.js"
import { appStore } from "./app.js" import { appStore } from "./app.js"
import { import { componentStore, selectedComponent } from "./components"
componentStore,
selectedComponent,
} from "./components"
import { navigationStore } from "./navigation.js" import { navigationStore } from "./navigation.js"
import { themeStore } from "./theme.js" import { themeStore } from "./theme.js"
import { screenStore, selectedScreen, sortedScreens } from "./screens.js" import { screenStore, selectedScreen, sortedScreens } from "./screens.js"
@ -29,7 +26,7 @@ import { integrations } from "./integrations"
import { sortedIntegrations } from "./sortedIntegrations" import { sortedIntegrations } from "./sortedIntegrations"
import { queries } from "./queries" import { queries } from "./queries"
import { flags } from "./flags" import { flags } from "./flags"
import componentTreeNodesStore from './componentTreeNodes'; import componentTreeNodesStore from "./componentTreeNodes"
export { export {
componentTreeNodesStore, componentTreeNodesStore,