Browse Source

fix: automNextBlock params not inserted

Ahmad Kholid 3 years ago
parent
commit
1e72f98d36

+ 3 - 2
src/background/workflow-engine/blocks-handler/handler-interaction-block.js

@@ -86,10 +86,11 @@ async function interactionHandler(block, { refData }) {
       }
 
       if (data?.columns.insert) {
-        const arrData = Array.isArray(data.columns.data)
+        const params = Array.isArray(data.columns.data)
           ? data.columns.data
           : [data.columns.data];
-        this.addDataToColumn(arrData);
+
+        this.addDataToColumn(params);
       }
     }
 

+ 10 - 5
src/background/workflow-engine/engine.js

@@ -38,8 +38,9 @@ class WorkflowEngine {
 
     this.blocks = {};
     this.history = [];
+    this.columnsId = {};
     this.eventListeners = {};
-    this.columns = { column: { index: 0, type: 'any' } };
+    this.columns = { column: { index: 0, name: 'column', type: 'any' } };
 
     let variables = {};
     let { globalData } = workflow;
@@ -88,7 +89,7 @@ class WorkflowEngine {
     this.isUsingProxy = false;
 
     this.history = [];
-    this.columns = { column: { index: 0, type: 'any' } };
+    this.columns = { column: { index: 0, name: 'column', type: 'any' } };
 
     this.activeTab = {
       url: '',
@@ -140,7 +141,10 @@ class WorkflowEngine {
       : Object.values(workflowTable);
 
     columns.forEach(({ name, type, id }) => {
-      this.columns[id || name] = { index: 0, name, type };
+      const columnId = id || name;
+
+      this.columnsId[name] = columnId;
+      this.columns[columnId] = { index: 0, name, type };
     });
 
     this.blocks = blocks;
@@ -195,8 +199,9 @@ class WorkflowEngine {
       return;
     }
 
-    const columnKey = objectHasKey(this.columns, key) ? key : 'column';
-    const currentColumn = this.columns[columnKey];
+    const columnId =
+      (this.columns[key] ? key : this.columnsId[key]) || 'column';
+    const currentColumn = this.columns[columnId];
     const columnName = currentColumn.name || 'column';
     const convertedValue = convertData(value, currentColumn.type);