Cleanups
This commit is contained in:
parent
8018f5f25b
commit
69e1ae0aec
|
@ -85,7 +85,7 @@ export const findComponentPath = (
|
||||||
* a certain selector
|
* a certain selector
|
||||||
*/
|
*/
|
||||||
export const findAllMatchingComponents = (
|
export const findAllMatchingComponents = (
|
||||||
rootComponent: Component,
|
rootComponent: Component | null,
|
||||||
selector: (component: Component) => boolean
|
selector: (component: Component) => boolean
|
||||||
) => {
|
) => {
|
||||||
if (!rootComponent || !selector) {
|
if (!rootComponent || !selector) {
|
||||||
|
|
|
@ -485,7 +485,7 @@ export class ComponentStore extends BudiStore<ComponentState> {
|
||||||
(component: Component) => component._component.endsWith("/form")
|
(component: Component) => component._component.endsWith("/form")
|
||||||
)
|
)
|
||||||
const formSteps = findAllMatchingComponents(
|
const formSteps = findAllMatchingComponents(
|
||||||
parentForm!,
|
parentForm,
|
||||||
(component: Component) => component._component.endsWith("/formstep")
|
(component: Component) => component._component.endsWith("/formstep")
|
||||||
)
|
)
|
||||||
extras.step = formSteps.length + 1
|
extras.step = formSteps.length + 1
|
||||||
|
@ -644,7 +644,7 @@ export class ComponentStore extends BudiStore<ComponentState> {
|
||||||
nextId = nextId.replace("-navigation", "-screen")
|
nextId = nextId.replace("-navigation", "-screen")
|
||||||
}
|
}
|
||||||
this.update(state => {
|
this.update(state => {
|
||||||
state.selectedComponentId = nextId!
|
state.selectedComponentId = nextId ?? undefined
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -704,7 +704,7 @@ export class ComponentStore extends BudiStore<ComponentState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async paste(
|
async paste(
|
||||||
targetComponent: Component | null,
|
targetComponent: Component,
|
||||||
mode: string,
|
mode: string,
|
||||||
targetScreen: Screen,
|
targetScreen: Screen,
|
||||||
selectComponent = true
|
selectComponent = true
|
||||||
|
@ -727,7 +727,7 @@ export class ComponentStore extends BudiStore<ComponentState> {
|
||||||
// Patch screen
|
// Patch screen
|
||||||
const patch = (screen: Screen) => {
|
const patch = (screen: Screen) => {
|
||||||
// Get up to date ref to target
|
// Get up to date ref to target
|
||||||
targetComponent = findComponent(screen.props, targetComponent!._id!)
|
targetComponent = findComponent(screen.props, targetComponent!._id!)!
|
||||||
if (!targetComponent) {
|
if (!targetComponent) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -789,7 +789,7 @@ export class ComponentStore extends BudiStore<ComponentState> {
|
||||||
}
|
}
|
||||||
const targetIndex = parent._children.findIndex(
|
const targetIndex = parent._children.findIndex(
|
||||||
(component: Component) => {
|
(component: Component) => {
|
||||||
return component._id === targetComponent!._id
|
return component._id === targetComponent._id
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
const index = mode === "above" ? targetIndex : targetIndex + 1
|
const index = mode === "above" ? targetIndex : targetIndex + 1
|
||||||
|
|
Loading…
Reference in New Issue