diff --git a/src/lib/data-access/store/sessionSlice.ts b/src/lib/data-access/store/sessionSlice.ts index e6247f734c29eacc876adf023b4830f005411435..ba839a366df817a8470c3b45eea66a8c47998cdc 100644 --- a/src/lib/data-access/store/sessionSlice.ts +++ b/src/lib/data-access/store/sessionSlice.ts @@ -353,37 +353,39 @@ export const selectQuerybuilderHash = (state: RootState): string => { return ''; // Return an empty string if no active graph exists } - function isEmptyLogicPill(node: any) { - if (node == null || node.attributes.inputs == null) return false; - const input = Object.values(node.attributes.inputs)[0]; - return node.attributes.type == 'logic' && input != null && input == node.attributes.logic.input.default; + function isNotEmptyLogicPill(node: any) { + if (node == null) { + return false; // is empty + } else if (node.attributes.type !== 'logic') { + return true; // is not a logic + } else if (node.attributes.logic.numExtraInputs === 0) { + return true; // is a logic with no extra inputs required + } else if (node.attributes.inputs == null || Object.values(node.attributes.inputs).some(i => i == null || i === '')) { + return false; // there is a missing input to be filled in, so assume empty + } + + return true; // default } - const hashedNodes = activeQuery.graph.nodes - .filter(n => { - if (isEmptyLogicPill(n)) return false; - return true; - }) - .map(n => { - const node = { ...n }; - if (n?.attributes) { - const newAttributes = { ...n?.attributes }; - newAttributes.x = 0; - newAttributes.y = 0; - newAttributes.height = 0; - newAttributes.width = 0; - node.attributes = newAttributes; - } - return node; - }); + const hashedNodes = activeQuery.graph.nodes.filter(isNotEmptyLogicPill).map(n => { + const node = { ...n }; + if (n?.attributes) { + const newAttributes = { ...n?.attributes }; + newAttributes.x = 0; + newAttributes.y = 0; + newAttributes.height = 0; + newAttributes.width = 0; + node.attributes = newAttributes; + } + return node; + }); const ret = { nodes: hashedNodes, edges: activeQuery.graph.edges .filter(e => { const targetNode = activeQuery.graph.nodes.find(n => n.key == e.target); - if (isEmptyLogicPill(targetNode)) return false; - return true; + return isNotEmptyLogicPill(targetNode); }) .map(n => ({ key: n.key, diff --git a/src/lib/querybuilder/model/graphology/utils.ts b/src/lib/querybuilder/model/graphology/utils.ts index f259c21b1f06382d8f7ba52fad753f4cef8673b1..7f4fc96ae55227b83b206f202c6677ccb785542d 100644 --- a/src/lib/querybuilder/model/graphology/utils.ts +++ b/src/lib/querybuilder/model/graphology/utils.ts @@ -126,7 +126,7 @@ export class QueryMultiGraphology extends MultiGraph<QueryGraphNodes, QueryGraph attributes.logic.inputs.forEach((input, i) => { // Setup default non-linked inputs as regular values matching the input expected type if (!attributes.inputs) attributes.inputs = {}; - attributes.inputs[input.name] = inputValues?.[input.name] || input.default; + attributes.inputs[input.name] = inputValues?.[input.name] || input.default || ''; }); // (attributes as LogicNodeAttributes).leftEntityHandleId = getHandleId(attributes.id, name, type, Handles.RelationLeft, ''); // (attributes as LogicNodeAttributes).rightEntityHandleId = getHandleId(attributes.id, name, type, Handles.RelationRight, '');