Fix selection validation and error message

This commit is contained in:
anovazzi1 2024-01-29 16:33:29 -03:00
commit 7d7a980e7c

View file

@ -677,6 +677,7 @@ export function validateSelection(
if (selection.edges.length === 0) { if (selection.edges.length === 0) {
selection.edges = edges; selection.edges = edges;
} }
// get only edges that are connected to the nodes in the selection // get only edges that are connected to the nodes in the selection
// first creates a set of all the nodes ids // first creates a set of all the nodes ids
let nodesSet = new Set(selection.nodes.map((n) => n.id)); let nodesSet = new Set(selection.nodes.map((n) => n.id));
@ -692,7 +693,17 @@ export function validateSelection(
if (selection.nodes.length < 2) { if (selection.nodes.length < 2) {
errorsArray.push("Please select more than one node"); errorsArray.push("Please select more than one node");
} }
if (
selection.nodes.some(
(node) =>
isInputNode(node.data as NodeDataType) ||
isOutputNode(node.data as NodeDataType)
)
) {
errorsArray.push(
"Please select only nodes that are not input or output nodes"
);
}
//check if there are two or more nodes with free outputs //check if there are two or more nodes with free outputs
if ( if (
selection.nodes.filter( selection.nodes.filter(