feat: add critical checkbox to the norm node, send it with the program, add test.

ref: N25B-390
This commit is contained in:
Björn Otgaar
2025-12-10 15:38:54 +01:00
parent 8149d67491
commit 062e9e3f38
4 changed files with 67 additions and 1 deletions

View File

@@ -8,4 +8,5 @@ export const NormNodeDefaults: NormNodeData = {
droppable: true,
norm: "",
hasReduce: true,
critical: false,
};

View File

@@ -21,6 +21,7 @@ export type NormNodeData = {
droppable: boolean;
norm: string;
hasReduce: boolean;
critical: boolean;
};
export type NormNode = Node<NormNodeData>
@@ -35,11 +36,16 @@ export default function NormNode(props: NodeProps<NormNode>) {
const {updateNodeData} = useFlowStore();
const text_input_id = `norm_${props.id}_text_input`;
const checkbox_id = `goal_${props.id}_checkbox`;
const setValue = (value: string) => {
updateNodeData(props.id, {norm: value});
}
const setAchieved = (value: boolean) => {
updateNodeData(props.id, {...data, critical: value});
}
return <>
<Toolbar nodeId={props.id} allowDelete={true}/>
<div className={`${styles.defaultNode} ${styles.nodeNorm}`}>
@@ -52,6 +58,15 @@ export default function NormNode(props: NodeProps<NormNode>) {
placeholder={"Pepper should ..."}
/>
</div>
<div className={"flex-row gap-md align-center"}>
<label htmlFor={checkbox_id}>Critical:</label>
<input
id={checkbox_id}
type={"checkbox"}
checked={data.critical || false}
onChange={(e) => setAchieved(e.target.checked)}
/>
</div>
<Handle type="source" position={Position.Right} id="norms"/>
</div>
</>;
@@ -69,6 +84,7 @@ export function NormReduce(node: Node, _nodes: Node[]) {
id: node.id,
label: data.label,
norm: data.norm,
critical: data.critical,
}
}