Skip to content

Commit

Permalink
Remove multi link of any type
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrySky committed Apr 7, 2022
1 parent beaa958 commit 442d672
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
13 changes: 8 additions & 5 deletions src/components/port/CustomPortModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,15 @@ export class CustomPortModel extends DefaultPortModel {
console.log("port name: ", thisName);
console.log("parameter port: ", port.getNode().getInPorts());
if (Object.keys(port.getLinks()).length > 0){
// When port and link is the same type, just return
if(thisNodeModelType == thisPortType) return;
// When port is 'any' type, just return
if(thisName.includes("any")) return;
// When port is 'string', 'list' and 'dict' type, just return
switch (thisPortType){
case "string":
case "list":
case "dict":
return;
}
port.getNode().getOptions().extras["borderColor"]="red";
port.getNode().getOptions().extras["tip"]=`Port only allow multiple link ${thisPortType} type`;
port.getNode().getOptions().extras["tip"]=`Port doesn't allow multi-link of ${thisPortType} type`;
port.getNode().setSelected(true);
return false;
}
Expand Down
5 changes: 2 additions & 3 deletions src/components/xircuitBodyWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -503,10 +503,9 @@ export const BodyWidget: FC<BodyWidgetProps> = ({
let equalSign = ' = ';
let sourcePortLabelStructure;

// When port is 'any','string', 'list' and 'dict' type
// When port is 'string', 'list' and 'dict' type
// append values if there's multiple link connected
if (port.includes('any') ||
port.includes('string') ||
if (port.includes('string') ||
port.includes('list') ||
port.includes('dict')
) {
Expand Down

0 comments on commit 442d672

Please sign in to comment.