FEATURE: Added condition duplication
This commit is contained in:
@@ -4479,6 +4479,18 @@ const AngularWorkflow = (props) => {
|
|||||||
const [open, setOpen] = React.useState(false)
|
const [open, setOpen] = React.useState(false)
|
||||||
const [anchorEl, setAnchorEl] = React.useState(null)
|
const [anchorEl, setAnchorEl] = React.useState(null)
|
||||||
|
|
||||||
|
const duplicateCondition = (conditionIndex) => {
|
||||||
|
|
||||||
|
var newEdge = JSON.parse(JSON.stringify(selectedEdge.conditions[conditionIndex]))
|
||||||
|
const newUuid = uuid.v4()
|
||||||
|
newEdge.condition.id = newUuid
|
||||||
|
newEdge.source.id = newUuid
|
||||||
|
newEdge.destination.id = newUuid
|
||||||
|
selectedEdge.conditions.push(newEdge)
|
||||||
|
|
||||||
|
setUpdate(Math.random())
|
||||||
|
}
|
||||||
|
|
||||||
const deleteCondition = (conditionIndex) => {
|
const deleteCondition = (conditionIndex) => {
|
||||||
console.log(selectedEdge)
|
console.log(selectedEdge)
|
||||||
if (selectedEdge.conditions.length === 1) {
|
if (selectedEdge.conditions.length === 1) {
|
||||||
@@ -4511,7 +4523,7 @@ const AngularWorkflow = (props) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Paper square style={paperVariableStyle} onClick={() => {}}>
|
<Paper key={condition.condition.id} square style={paperVariableStyle} onClick={() => {}}>
|
||||||
<div style={{marginLeft: "10px", marginTop: "5px", marginBottom: "5px", width: "2px", backgroundColor: "orange", marginRight: "5px"}} />
|
<div style={{marginLeft: "10px", marginTop: "5px", marginBottom: "5px", width: "2px", backgroundColor: "orange", marginRight: "5px"}} />
|
||||||
<div style={{display: "flex", width: "100%"}}>
|
<div style={{display: "flex", width: "100%"}}>
|
||||||
<div style={{flex: "10", display: "flex"}} onClick={() => {
|
<div style={{flex: "10", display: "flex"}} onClick={() => {
|
||||||
@@ -4520,11 +4532,11 @@ const AngularWorkflow = (props) => {
|
|||||||
setDestinationValue(condition.destination)
|
setDestinationValue(condition.destination)
|
||||||
setConditionsModalOpen(true)
|
setConditionsModalOpen(true)
|
||||||
}}>
|
}}>
|
||||||
<div style={{flex: 1, textAlign: "left", marginTop: "15px", marginLeft: "10px", overflow: "hidden"}}>
|
<div style={{flex: 1, textAlign: "left", marginTop: "15px", marginLeft: "10px", overflow: "hidden", maxWidth: 72, }}>
|
||||||
{condition.source.value}
|
{condition.source.value}
|
||||||
</div>
|
</div>
|
||||||
<Divider style={{height: "100%", width: "1px", marginLeft: "5px", marginRight: "5px", backgroundColor: "rgb(91, 96, 100)"}}/>
|
<Divider style={{height: "100%", width: "1px", marginLeft: "5px", marginRight: "5px", backgroundColor: "rgb(91, 96, 100)"}}/>
|
||||||
<div style={{flex: 1, textAlign: "center", marginTop: "15px", overflow: "hidden"}} onClick={() => {}}>
|
<div style={{flex: 1, textAlign: "center", marginTop: "15px", overflow: "hidden", maxWidth: 72,}} onClick={() => {}}>
|
||||||
{condition.condition.value}
|
{condition.condition.value}
|
||||||
</div>
|
</div>
|
||||||
<Divider style={{height: "100%", width: "1px", marginLeft: "5px", marginRight: "5px", backgroundColor: "rgb(91, 96, 100)"}}/>
|
<Divider style={{height: "100%", width: "1px", marginLeft: "5px", marginRight: "5px", backgroundColor: "rgb(91, 96, 100)"}}/>
|
||||||
@@ -4557,13 +4569,13 @@ const AngularWorkflow = (props) => {
|
|||||||
setAnchorEl(null)
|
setAnchorEl(null)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
<MenuItem style={{backgroundColor: inputColor, color: "white"}} onClick={() => {
|
||||||
|
duplicateCondition(index)
|
||||||
|
}} key={"Duplicate"}>{"Duplicate"}</MenuItem>
|
||||||
<MenuItem style={{backgroundColor: inputColor, color: "white"}} onClick={() => {
|
<MenuItem style={{backgroundColor: inputColor, color: "white"}} onClick={() => {
|
||||||
setOpen(false)
|
setOpen(false)
|
||||||
deleteCondition(index)
|
deleteCondition(index)
|
||||||
}} key={"Delete"}>{"Delete"}</MenuItem>
|
}} key={"Delete"}>{"Delete"}</MenuItem>
|
||||||
<MenuItem style={{backgroundColor: inputColor, color: "white"}} onClick={() => {
|
|
||||||
duplicateCondition(index)
|
|
||||||
}} key={"Duplicate"}>{"Duplicate"}</MenuItem>
|
|
||||||
</Menu>
|
</Menu>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user