diff --git a/webapp/src/components/DAGSvgs/DAGBoard.tsx b/webapp/src/components/DAGSvgs/DAGBoard.tsx
index a08f7af..e9ab43b 100644
--- a/webapp/src/components/DAGSvgs/DAGBoard.tsx
+++ b/webapp/src/components/DAGSvgs/DAGBoard.tsx
@@ -12,7 +12,7 @@ import { DAGCircle } from "./DAGCircle";
export interface DAGCircleElm {
type: 'circle';
loc: Point;
- onClick?: () => void;
+ onClick?: ['add', () => void] | ['edit', () => void];
}
export interface DAGNodeElm {
type: 'node';
@@ -135,11 +135,16 @@ export function* mapDataToElements({
break
case 'circle':
const loc = mapWithNode(elm.loc, [0, st.nodeHeight / 2 - st.circleSize / 2]);
+ const clickProps = elm.onClick ? (
+ elm.onClick[0] === 'add' ?
+ { onAdd: elm.onClick[1] } :
+ { onEdit: elm.onClick[1] }
+ ) : {}
yield
break
default:
diff --git a/webapp/src/components/DAGSvgs/DAGCircle.stories.tsx b/webapp/src/components/DAGSvgs/DAGCircle.stories.tsx
index 7e4917e..141ec6d 100644
--- a/webapp/src/components/DAGSvgs/DAGCircle.stories.tsx
+++ b/webapp/src/components/DAGSvgs/DAGCircle.stories.tsx
@@ -17,11 +17,18 @@ export default {
export const Basic: ComponentStory = args => {
return
+
}
diff --git a/webapp/src/components/DAGSvgs/DAGCircle.tsx b/webapp/src/components/DAGSvgs/DAGCircle.tsx
index a81f7b1..bd87214 100644
--- a/webapp/src/components/DAGSvgs/DAGCircle.tsx
+++ b/webapp/src/components/DAGSvgs/DAGCircle.tsx
@@ -1,26 +1,39 @@
// import "./DAGCircle.css";
import { Point } from "types/graphs";
-import { PencilIcon } from '../Icons/index';
+import { AddIcon, PencilIcon } from '../Icons/index';
import { useCircleStyles } from './styles';
export interface AddProps {
- onClick?: () => void;
+ onEdit?: () => void;
+ onAdd?: () => void;
loc: Point,
size: number,
}
export const DAGCircle = ({
loc: [x, y],
size,
- onClick,
+ onEdit,
+ onAdd,
}: AddProps) => {
const { classes } = useCircleStyles({ size: size * 0.9 });
- console.log({ onClick })
+ console.log({ onEdit })
return <>
- {onClick ?
: "else"}
+ {onEdit ?
+
: onAdd ?
+
+ : "else"}
>
diff --git a/webapp/src/components/SequenceNodes/positions.ts b/webapp/src/components/SequenceNodes/positions.ts
index 68200a3..67ad960 100644
--- a/webapp/src/components/SequenceNodes/positions.ts
+++ b/webapp/src/components/SequenceNodes/positions.ts
@@ -32,7 +32,7 @@ const makeOffsetMaintainer = (startPoint: Point) => {
}
}
-function* inner(
+function* dealWithNested(
nodeLoc: Point,
innerStartLoc: Point,
updater: Updater,
@@ -49,7 +49,7 @@ function* inner(
yield {
type: 'circle',
loc: innerStartLoc,
- onClick: onEdit
+ onClick: ['edit', onEdit],
}
yield {
type: 'edge',
@@ -72,12 +72,14 @@ function* dealWithChoose(
node: ChooseAction,
nodeLoc: Point,
makeUpdater: (j: number | null) => Updater,
+ onAdd: () => void,
offset: ReturnType,
-) {
+): Generator {
offset.resetY()
+ // conditions
for (let j = 0; j < node.action_data.choose.length; j++) {
const innerStartLoc = offsetPoint(nodeLoc, [1, j + 1 + offset.y]);
- for (let elm of inner(
+ for (let elm of dealWithNested(
nodeLoc,
innerStartLoc ,
makeUpdater(j),
@@ -88,13 +90,17 @@ function* dealWithChoose(
if (elm.type === 'node') {
offset.update(elm.loc, innerStartLoc)
}
+ if (elm.type === 'circle') {
+ offset.update(offsetPoint(elm.loc, [0, -1]), innerStartLoc)
+ }
}
}
+ // default
const innerStartLoc = offsetPoint(
nodeLoc,
- [1, node.action_data.choose.length + 1 + offset.y],
+ [1, node.action_data.choose.length + 2 + offset.y],
);
- for (let elm of inner(
+ for (let elm of dealWithNested(
nodeLoc,
innerStartLoc,
makeUpdater(null),
@@ -105,6 +111,16 @@ function* dealWithChoose(
offset.update(elm.loc, innerStartLoc)
}
}
+ // add new conditions
+ const newCondLoc = offsetPoint(
+ nodeLoc,
+ [1, node.action_data.choose.length + 1 + offset.y],
+ );
+ yield {
+ type: 'circle',
+ loc: newCondLoc,
+ onClick: ['add', onAdd],
+ }
}
@@ -143,6 +159,19 @@ export function* computeNodesEdgesPos(
node,
nodeLoc,
j => rootUpdater.makeChildUpdaterForChooseAction(i, j),
+ () => rootUpdater.updateNode(i, {
+ ...node,
+ action_data: {
+ ...node.action_data,
+ choose: [
+ ...node.action_data.choose,
+ {
+ conditions: [],
+ sequence: [],
+ }
+ ]
+ }
+ }),
offset,
)
}