Cleanups
This commit is contained in:
parent
048d56456c
commit
79180bfac5
|
@ -1,7 +1,7 @@
|
||||||
import { get } from "svelte/store"
|
import { get } from "svelte/store"
|
||||||
import { selectedScreen as selectedScreenStore } from "./screens"
|
import { selectedScreen as selectedScreenStore } from "./screens"
|
||||||
import { findComponentPath } from "@/helpers/components"
|
import { findComponentPath } from "@/helpers/components"
|
||||||
import { Screen, Component } from "@budibase/types"
|
import { Component } from "@budibase/types"
|
||||||
import { BudiStore, PersistenceType } from "@/stores/BudiStore"
|
import { BudiStore, PersistenceType } from "@/stores/BudiStore"
|
||||||
|
|
||||||
interface OpenNodesState {
|
interface OpenNodesState {
|
||||||
|
@ -49,9 +49,9 @@ export class ComponentTreeNodesStore extends BudiStore<OpenNodesState> {
|
||||||
|
|
||||||
// Will ensure all parents of a node are expanded so that it is visible in the tree
|
// Will ensure all parents of a node are expanded so that it is visible in the tree
|
||||||
makeNodeVisible(componentId: string) {
|
makeNodeVisible(componentId: string) {
|
||||||
const selectedScreen: Screen = get(selectedScreenStore)!
|
const selectedScreen = get(selectedScreenStore)
|
||||||
|
|
||||||
const path = findComponentPath(selectedScreen.props, componentId)
|
const path = findComponentPath(selectedScreen?.props, componentId)
|
||||||
|
|
||||||
const componentIds = path.map((component: Component) => component._id)
|
const componentIds = path.map((component: Component) => component._id)
|
||||||
|
|
||||||
|
|
|
@ -610,14 +610,14 @@ export class ComponentStore extends BudiStore<ComponentState> {
|
||||||
async patch(
|
async patch(
|
||||||
patchFn: (component: Component, screen: Screen) => any,
|
patchFn: (component: Component, screen: Screen) => any,
|
||||||
componentId?: string,
|
componentId?: string,
|
||||||
screenId?: string | null
|
screenId?: string
|
||||||
) {
|
) {
|
||||||
// Use selected component by default
|
// Use selected component by default
|
||||||
if (!componentId || !screenId) {
|
if (!componentId || !screenId) {
|
||||||
const state = get(this.store)
|
const state = get(this.store)
|
||||||
componentId = componentId ?? state.selectedComponentId ?? undefined
|
componentId = componentId ?? state.selectedComponentId ?? undefined
|
||||||
const screenState = get(screenStore)
|
const screenState = get(screenStore)
|
||||||
screenId = screenId || screenState.selectedScreenId
|
screenId = (screenId || screenState.selectedScreenId) ?? undefined
|
||||||
}
|
}
|
||||||
if (!componentId || !screenId || !patchFn) {
|
if (!componentId || !screenId || !patchFn) {
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue