chore: cleanup broken tests, add extra documentation, make sure everything is clean and code style isn't inconsistant
This commit is contained in:
@@ -54,7 +54,7 @@ export function EndReduce(node: Node, nodes: Node[]) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Any connection functionality that should get called when a connection is made to this node
|
||||
* Any connection functionality that should get called when a connection is made to this node type (end)
|
||||
* @param thisNode the node of which the functionality gets called
|
||||
* @param otherNode the other node which has connected
|
||||
* @param isThisSource whether this node is the one that is the source of the connection
|
||||
|
||||
@@ -2,8 +2,6 @@ import {
|
||||
Handle,
|
||||
type NodeProps,
|
||||
Position,
|
||||
type Connection,
|
||||
type Edge,
|
||||
type Node,
|
||||
} from '@xyflow/react';
|
||||
import { Toolbar } from '../components/NodeComponents';
|
||||
@@ -26,15 +24,9 @@ export type GoalNodeData = {
|
||||
hasReduce: boolean;
|
||||
};
|
||||
|
||||
|
||||
|
||||
export type GoalNode = Node<GoalNodeData>
|
||||
|
||||
|
||||
export function GoalNodeCanConnect(connection: Connection | Edge): boolean {
|
||||
return (connection != undefined);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines how a Goal node should be rendered
|
||||
* @param props NodeProps, like id, label, children
|
||||
|
||||
@@ -2,8 +2,6 @@ import {
|
||||
Handle,
|
||||
type NodeProps,
|
||||
Position,
|
||||
type Connection,
|
||||
type Edge,
|
||||
type Node,
|
||||
} from '@xyflow/react';
|
||||
import { Toolbar } from '../components/NodeComponents';
|
||||
@@ -25,15 +23,8 @@ export type NormNodeData = {
|
||||
hasReduce: boolean;
|
||||
};
|
||||
|
||||
|
||||
|
||||
export type NormNode = Node<NormNodeData>
|
||||
|
||||
|
||||
export function NormNodeCanConnect(connection: Connection | Edge): boolean {
|
||||
return (connection != undefined);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines how a Norm node should be rendered
|
||||
* @param props NodeProps, like id, label, children
|
||||
|
||||
@@ -24,10 +24,8 @@ export type PhaseNodeData = {
|
||||
hasReduce: boolean;
|
||||
};
|
||||
|
||||
|
||||
export type PhaseNode = Node<PhaseNodeData>
|
||||
|
||||
|
||||
/**
|
||||
* Defines how a phase node should be rendered
|
||||
* @param props NodeProps, like id, label, children
|
||||
@@ -36,9 +34,7 @@ export type PhaseNode = Node<PhaseNodeData>
|
||||
export default function PhaseNode(props: NodeProps<Node>) {
|
||||
const data = props.data as PhaseNodeData;
|
||||
const {updateNodeData} = useFlowStore();
|
||||
|
||||
const updateLabel = (value: string) => updateNodeData(props.id, {...data, label: value});
|
||||
|
||||
const label_input_id = `phase_${props.id}_label_input`;
|
||||
|
||||
return (
|
||||
@@ -62,10 +58,11 @@ export default function PhaseNode(props: NodeProps<Node>) {
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Reduces each phase, including its children down into its relevant data.
|
||||
* @param props: The Node Properties of this node.
|
||||
* @param node the node which is being reduced
|
||||
* @param nodes all the nodes currently in the flow.
|
||||
* @returns A collection of all reduced nodes in this phase, starting with this phases' reduced data.
|
||||
*/
|
||||
export function PhaseReduce(node: Node, nodes: Node[]) {
|
||||
const thisnode = node as PhaseNode;
|
||||
@@ -104,7 +101,12 @@ export function PhaseReduce(node: Node, nodes: Node[]) {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function is called whenever a connection is made with this node type (phase)
|
||||
* @param thisNode the node of this node type which function is called
|
||||
* @param otherNode the other node which was part of the connection
|
||||
* @param isThisSource whether this instance of the node was the source in the connection, true = yes.
|
||||
*/
|
||||
export function PhaseConnects(thisNode: Node, otherNode: Node, isThisSource: boolean) {
|
||||
console.log("Connect functionality called.")
|
||||
const node = thisNode as PhaseNode
|
||||
|
||||
@@ -41,6 +41,12 @@ export function StartReduce(node: Node, nodes: Node[]) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called whenever a connection is made with this node type (start)
|
||||
* @param thisNode the node of this node type which function is called
|
||||
* @param otherNode the other node which was part of the connection
|
||||
* @param isThisSource whether this instance of the node was the source in the connection, true = yes.
|
||||
*/
|
||||
export function StartConnects(thisNode: Node, otherNode: Node, isThisSource: boolean) {
|
||||
// Replace this for connection logic
|
||||
if (thisNode == undefined && otherNode == undefined && isThisSource == false) {
|
||||
|
||||
@@ -81,6 +81,12 @@ export function TriggerReduce(node: Node, nodes: Node[]) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called whenever a connection is made with this node type (trigger)
|
||||
* @param thisNode the node of this node type which function is called
|
||||
* @param otherNode the other node which was part of the connection
|
||||
* @param isThisSource whether this instance of the node was the source in the connection, true = yes.
|
||||
*/
|
||||
export function TriggerConnects(thisNode: Node, otherNode: Node, isThisSource: boolean) {
|
||||
// Replace this for connection logic
|
||||
if (thisNode == undefined && otherNode == undefined && isThisSource == false) {
|
||||
@@ -88,14 +94,13 @@ export function TriggerConnects(thisNode: Node, otherNode: Node, isThisSource: b
|
||||
}
|
||||
}
|
||||
|
||||
// Definitions for the possible triggers, being keywords and emotions
|
||||
type Keyword = { id: string, keyword: string };
|
||||
|
||||
export type EmotionTriggerNodeProps = {
|
||||
type: "emotion";
|
||||
value: string;
|
||||
}
|
||||
|
||||
type Keyword = { id: string, keyword: string };
|
||||
|
||||
export type KeywordTriggerNodeProps = {
|
||||
type: "keywords";
|
||||
value: Keyword[];
|
||||
@@ -103,6 +108,11 @@ export type KeywordTriggerNodeProps = {
|
||||
|
||||
export type TriggerNodeProps = EmotionTriggerNodeProps | KeywordTriggerNodeProps;
|
||||
|
||||
/**
|
||||
* The JSX element that is responsible for updating the field and showing the text
|
||||
* @param param0 the function that updates the field
|
||||
* @returns React.JSX.Element that handles adding keywords
|
||||
*/
|
||||
function KeywordAdder({ addKeyword }: { addKeyword: (keyword: string) => void }) {
|
||||
const [input, setInput] = useState("");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user