ActionFlow bug fix

This commit is contained in:
2023-09-17 20:21:39 +09:00
parent 59e6d33656
commit df59bff6ae
2 changed files with 11 additions and 12 deletions

View File

@@ -88,7 +88,7 @@ const onDeleteNode=(node:IActionNode)=>{
} }
const onDeleteAllNextNodes=(node:IActionNode)=>{ const onDeleteAllNextNodes=(node:IActionNode)=>{
refFlow.value.removeNode(node); refFlow.value.removeAllNext(node.id);
} }
const closeDg=(val :any)=>{ const closeDg=(val :any)=>{
console.log("Dialog closed->",val); console.log("Dialog closed->",val);

View File

@@ -78,8 +78,6 @@ class ActionProperty implements IActionProperty {
modelValue: modelValue modelValue: modelValue
}; };
} }
} }
@@ -170,7 +168,8 @@ export class RootAction implements IActionNode {
* アクションフローの定義 * アクションフローの定義
*/ */
export class ActionFlow implements IActionFlow { export class ActionFlow implements IActionFlow {
actionNodes:Array<IActionNode>;
actionNodes:Array<IActionNode>;
constructor(actionNodes:Array<IActionNode>|RootAction){ constructor(actionNodes:Array<IActionNode>|RootAction){
if(actionNodes instanceof Array){ if(actionNodes instanceof Array){
this.actionNodes=actionNodes; this.actionNodes=actionNodes;
@@ -196,10 +195,10 @@ export class ActionFlow implements IActionFlow {
newNode.inputPoint=inputPoint; newNode.inputPoint=inputPoint;
} }
if(prevNode){ if(prevNode){
this.resetNodeRelation(prevNode,newNode,inputPoint); this.connectNodes(prevNode,newNode,inputPoint||'');
}else{ }else{
prevNode=this.actionNodes[this.actionNodes.length-1]; prevNode=this.actionNodes[this.actionNodes.length-1];
this.resetNodeRelation(prevNode,newNode,inputPoint); this.connectNodes(prevNode,newNode,inputPoint||'');
} }
this.actionNodes.push(newNode); this.actionNodes.push(newNode);
return newNode; return newNode;
@@ -291,7 +290,8 @@ reconnectOrRemoveNextNodes(targetNode: IActionNode): void {
} }
//二つ以上の場合 //二つ以上の場合
for(const [point,nextid] of nextNodeIds){ for(const [point,nextid] of nextNodeIds){
if(!this.connectNodes(prevNode,nextid,point)){ const nextNode = this.findNodeById(nextid);
if(!this.connectNodes(prevNode,nextNode,point)){
this.removeAllNext(nextid); this.removeAllNext(nextid);
this.removeFromActionNodes(nextid); this.removeFromActionNodes(nextid);
} }
@@ -305,13 +305,12 @@ reconnectOrRemoveNextNodes(targetNode: IActionNode): void {
* @param point * @param point
* @returns * @returns
*/ */
connectNodes(prevNode:IActionNode,nextNodeId:string,point:string):boolean{ connectNodes(prevNode:IActionNode,nextNode:IActionNode,point:string):boolean{
if(!prevNode || !nextNodeId){ if(!prevNode || !nextNode){
return false; return false;
} }
const nextNode = this.findNodeById(nextNodeId); if(!nextNode) return false;
if(!nextNode) return false; prevNode.nextNodeIds.set(point,nextNode.id);
prevNode.nextNodeIds.set(point,nextNodeId);
nextNode.prevNodeId=prevNode.id; nextNode.prevNodeId=prevNode.id;
nextNode.inputPoint=point; nextNode.inputPoint=point;
return true; return true;