Skip to content

Commit

Permalink
Merge pull request #347 from XpressAI/fahreza/dyna-fixes
Browse files Browse the repository at this point in the history
✨ / 🐛 Spawn Literal Any Dialog on Dragging from Dynaports + Fix Compulsory InPorts with DynaPorts
  • Loading branch information
MFA-X-AI authored Jul 30, 2024
2 parents e13ae15 + a3daaaa commit 9c0bdc9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/commands/NodeActionCommands.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,15 @@ export function addNodeActionCommands(
}
newLink.setSourcePort(sourcePort);
newLink.setTargetPort(targetPort);

if (targetPort instanceof CustomDynaPortModel){
const newPort = targetPort.spawnDynamicPort({ offset: 1 });
newPort.previous = targetPort.getID();
targetPort.next = newPort.getID();
widget.xircuitsApp.getDiagramEngine().getModel().addNode(targetPort.getParent());
}
widget.xircuitsApp.getDiagramEngine().getModel().addLink(newLink);
widget.xircuitsApp.getDiagramEngine().repaintCanvas();
},
label: trans.__('Link node')
});
Expand Down
2 changes: 2 additions & 0 deletions src/components/XircuitsBodyWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,8 @@ export const BodyWidget: FC<BodyWidgetProps> = ({
nodeType = boolValue === 'false' ? 'False' : 'True';
break;
case 'any':
case 'dynalist':
case 'dynatuple':
// When inPort is 'any' type, get the correct literal type based on the first character inputed
let portAnyType = await getItsLiteralType();
if (portAnyType == undefined) return;
Expand Down
2 changes: 2 additions & 0 deletions src/components/port/CustomDynaPortModel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ export class CustomDynaPortModel extends CustomPortModel {
newDynamicPortName = `parameter-${port.dataType}-${port.varName}`;
newDynamicPortLabel = `${port.varName}`;
} else {
// strip compulsory notation [★] if not first dynaport
port.varName = port.varName.replace(//g, '');
newDynamicPortName = `parameter-${port.dataType}-${port.varName}-${newDynamicPortOrder}`;
newDynamicPortLabel = `${port.varName}[${newDynamicPortOrder}]`;
}
Expand Down

0 comments on commit 9c0bdc9

Please sign in to comment.