feat: added correct showing of goals with the description and can_fail

ref: N25B-434
This commit is contained in:
Björn Otgaar
2026-01-08 12:31:46 +01:00
parent e6f29a0f6b
commit c7ed3c8ef2
4 changed files with 41 additions and 11 deletions

View File

@@ -9,7 +9,7 @@ import { TextField } from '../../../../components/TextField';
import {MultiConnectionHandle} from "../components/RuleBasedHandle.tsx";
import {allowOnlyConnectionsFromHandle, allowOnlyConnectionsFromType} from "../HandleRules.ts";
import useFlowStore from '../VisProgStores';
import {DoesPlanIterate, PlanReduce, type Plan } from '../components/Plan';
import {DoesPlanIterate, HasCheckingSubGoal, PlanReduce, type Plan } from '../components/Plan';
import PlanEditorDialog from '../components/PlanEditor';
import { MultilineTextField } from '../../../../components/MultilineTextField';
import { defaultPlan } from '../components/Plan.default.ts';
@@ -45,10 +45,12 @@ export type GoalNode = Node<GoalNodeData>
*/
export default function GoalNode({id, data}: NodeProps<GoalNode>) {
const {updateNodeData} = useFlowStore();
const _nodes = useFlowStore().nodes;
const text_input_id = `goal_${id}_text_input`;
const checkbox_id = `goal_${id}_checkbox`;
const planIterate = DoesPlanIterate(data.plan);
const planIterate = DoesPlanIterate(_nodes, data.plan);
const hasCheckSubGoal = data.plan !== undefined && HasCheckingSubGoal(data.plan, _nodes)
const setDescription = (value: string) => {
updateNodeData(id, {...data, description: value});
@@ -75,7 +77,7 @@ export default function GoalNode({id, data}: NodeProps<GoalNode>) {
/>
</div>
{data.can_fail && (<div>
{(data.can_fail || hasCheckSubGoal) && (<div>
<label htmlFor={text_input_id}>Description/ Condition of goal:</label>
<div className={"flex-wrap"}>
<MultilineTextField
@@ -95,8 +97,8 @@ export default function GoalNode({id, data}: NodeProps<GoalNode>) {
<input
id={checkbox_id}
type={"checkbox"}
disabled={!planIterate}
checked={!planIterate || data.can_fail}
disabled={!planIterate || (data.plan && HasCheckingSubGoal(data.plan, _nodes))}
checked={!planIterate || data.can_fail || (data.plan && HasCheckingSubGoal(data.plan, _nodes))}
onChange={(e) => planIterate ? setFailable(e.target.checked) : setFailable(false)}
/>
</div>
@@ -137,7 +139,7 @@ export function GoalReduce(node: Node, _nodes: Node[]) {
id: node.id,
name: data.name,
description: data.description,
can_fail: data.can_fail,
can_fail: data.can_fail || (data.plan && HasCheckingSubGoal(data.plan, _nodes)),
plan: data.plan ? PlanReduce(_nodes, data.plan) : "",
}
}