|
|
@ -4,7 +4,7 @@ |
|
|
import { getComponentDefinition } from "builderStore/storeUtils" |
|
|
import { getComponentDefinition } from "builderStore/storeUtils" |
|
|
import ConfirmDialog from "components/common/ConfirmDialog.svelte" |
|
|
import ConfirmDialog from "components/common/ConfirmDialog.svelte" |
|
|
import { last } from "lodash/fp" |
|
|
import { last } from "lodash/fp" |
|
|
import { getParent, saveCurrentPreviewItem } from "builderStore/storeUtils" |
|
|
import { getParent } from "builderStore/storeUtils" |
|
|
import { DropdownMenu } from "@budibase/bbui" |
|
|
import { DropdownMenu } from "@budibase/bbui" |
|
|
import { DropdownContainer, DropdownItem } from "components/common/Dropdowns" |
|
|
import { DropdownContainer, DropdownItem } from "components/common/Dropdowns" |
|
|
|
|
|
|
|
|
@ -31,44 +31,44 @@ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const moveUpComponent = () => { |
|
|
const moveUpComponent = () => { |
|
|
store.update(s => { |
|
|
store.update(state => { |
|
|
const parent = getParent(s.currentPreviewItem.props, component) |
|
|
const parent = getParent(state.currentPreviewItem.props, component) |
|
|
|
|
|
|
|
|
if (parent) { |
|
|
if (parent) { |
|
|
const currentIndex = parent._children.indexOf(component) |
|
|
const currentIndex = parent._children.indexOf(component) |
|
|
if (currentIndex === 0) return s |
|
|
if (currentIndex === 0) return state |
|
|
|
|
|
|
|
|
const newChildren = parent._children.filter(c => c !== component) |
|
|
const newChildren = parent._children.filter(c => c !== component) |
|
|
newChildren.splice(currentIndex - 1, 0, component) |
|
|
newChildren.splice(currentIndex - 1, 0, component) |
|
|
parent._children = newChildren |
|
|
parent._children = newChildren |
|
|
} |
|
|
} |
|
|
s.currentComponentInfo = component |
|
|
state.currentComponentInfo = component |
|
|
saveCurrentPreviewItem(s) |
|
|
store.actions.preview.saveSelected() |
|
|
|
|
|
|
|
|
return s |
|
|
return state |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const moveDownComponent = () => { |
|
|
const moveDownComponent = () => { |
|
|
store.update(s => { |
|
|
store.update(state => { |
|
|
const parent = getParent(s.currentPreviewItem.props, component) |
|
|
const parent = getParent(state.currentPreviewItem.props, component) |
|
|
|
|
|
|
|
|
if (parent) { |
|
|
if (parent) { |
|
|
const currentIndex = parent._children.indexOf(component) |
|
|
const currentIndex = parent._children.indexOf(component) |
|
|
if (currentIndex === parent._children.length - 1) return s |
|
|
if (currentIndex === parent._children.length - 1) return state |
|
|
|
|
|
|
|
|
const newChildren = parent._children.filter(c => c !== component) |
|
|
const newChildren = parent._children.filter(c => c !== component) |
|
|
newChildren.splice(currentIndex + 1, 0, component) |
|
|
newChildren.splice(currentIndex + 1, 0, component) |
|
|
parent._children = newChildren |
|
|
parent._children = newChildren |
|
|
} |
|
|
} |
|
|
s.currentComponentInfo = component |
|
|
state.currentComponentInfo = component |
|
|
saveCurrentPreviewItem(s) |
|
|
store.actions.preview.saveSelected() |
|
|
|
|
|
|
|
|
return s |
|
|
return state |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const copyComponent = () => { |
|
|
const duplicateComponent = () => { |
|
|
storeComponentForCopy(false) |
|
|
storeComponentForCopy(false) |
|
|
pasteComponent("below") |
|
|
pasteComponent("below") |
|
|
} |
|
|
} |
|
|
@ -82,7 +82,7 @@ |
|
|
selectComponent(parent) |
|
|
selectComponent(parent) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
saveCurrentPreviewItem(state) |
|
|
store.actions.preview.saveSelected() |
|
|
return state |
|
|
return state |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
@ -119,7 +119,7 @@ |
|
|
<DropdownItem |
|
|
<DropdownItem |
|
|
icon="ri-repeat-one-line" |
|
|
icon="ri-repeat-one-line" |
|
|
title="Duplicate" |
|
|
title="Duplicate" |
|
|
on:click={copyComponent} /> |
|
|
on:click={duplicateComponent} /> |
|
|
<DropdownItem |
|
|
<DropdownItem |
|
|
icon="ri-scissors-cut-line" |
|
|
icon="ri-scissors-cut-line" |
|
|
title="Cut" |
|
|
title="Cut" |
|
|
|