beta-glozic-workflow 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -0
- package/dist/component/TaskPalette/TaskPalette.css +105 -0
- package/dist/component/TaskPalette/TaskPalette.js +104 -0
- package/dist/component/TaskPalette/index.js +10 -0
- package/dist/component/TaskPaletteGroup/TaskPaletteGroup.css +85 -0
- package/dist/component/TaskPaletteGroup/TaskPaletteGroup.js +71 -0
- package/dist/component/TaskPaletteGroup/index.js +10 -0
- package/dist/css/style.css +363 -0
- package/dist/index.css +0 -0
- package/dist/index.js +2040 -0
- package/dist/nodeconfig.js +50 -0
- package/dist/utils/Designer.module.js +202 -0
- package/dist/utils/taskConfig.js +330 -0
- package/dist/utils/workflow.config.js +176 -0
- package/package.json +58 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,2040 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.SPECIAL_END_NODE = exports.SPECIAL_CORNER_NODE = exports.NODE_START = exports.NODE_END = void 0;
|
|
7
|
+
require("core-js/modules/es.object.assign.js");
|
|
8
|
+
require("core-js/modules/es.promise.js");
|
|
9
|
+
require("core-js/modules/es.json.stringify.js");
|
|
10
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
11
|
+
require("core-js/modules/es.array.includes.js");
|
|
12
|
+
require("core-js/modules/es.string.includes.js");
|
|
13
|
+
require("core-js/modules/es.parse-float.js");
|
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
+
var _TaskPalette = _interopRequireDefault(require("./component/TaskPalette"));
|
|
16
|
+
var _reactstrap = require("reactstrap");
|
|
17
|
+
var _jsplumb = require("jsplumb");
|
|
18
|
+
var _workflow = require("./utils/workflow.config");
|
|
19
|
+
var _jquery = _interopRequireDefault(require("jquery"));
|
|
20
|
+
var _Designer = require("./utils/Designer.module");
|
|
21
|
+
require("./css/style.css");
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
24
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
26
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
27
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
28
|
+
// import './index.css';
|
|
29
|
+
|
|
30
|
+
//Actions
|
|
31
|
+
const NODE_START = 'node-start';
|
|
32
|
+
exports.NODE_START = NODE_START;
|
|
33
|
+
const NODE_END = 'node-end';
|
|
34
|
+
exports.NODE_END = NODE_END;
|
|
35
|
+
const SPECIAL_END_NODE = 'special_end_node';
|
|
36
|
+
exports.SPECIAL_END_NODE = SPECIAL_END_NODE;
|
|
37
|
+
const SPECIAL_CORNER_NODE = 'SPECIAL_CORNER_NODE';
|
|
38
|
+
exports.SPECIAL_CORNER_NODE = SPECIAL_CORNER_NODE;
|
|
39
|
+
let taskConfig = {};
|
|
40
|
+
Object.values(_workflow.config.taskType).map(s => {
|
|
41
|
+
taskConfig = Object.assign(taskConfig, s);
|
|
42
|
+
});
|
|
43
|
+
let _count = 0; // every node has a unique name node-${_count}
|
|
44
|
+
|
|
45
|
+
const layout = {
|
|
46
|
+
"workflowName": "",
|
|
47
|
+
"workflowDescription": "",
|
|
48
|
+
"workflowType": "",
|
|
49
|
+
"isPublished": 0,
|
|
50
|
+
"definition": {
|
|
51
|
+
"variables": [],
|
|
52
|
+
"actions": [],
|
|
53
|
+
"settings": {}
|
|
54
|
+
},
|
|
55
|
+
"createdTime": "",
|
|
56
|
+
"createdBy": "",
|
|
57
|
+
"modifiedTime": "",
|
|
58
|
+
"modifiedBy": ""
|
|
59
|
+
};
|
|
60
|
+
class Designer extends _react.Component {
|
|
61
|
+
constructor(_props) {
|
|
62
|
+
super(_props);
|
|
63
|
+
_defineProperty(this, "componentDidMount", async () => {
|
|
64
|
+
this.onload();
|
|
65
|
+
this.onUpdateNodes(this.props);
|
|
66
|
+
});
|
|
67
|
+
_defineProperty(this, "componentWillReceiveProps", props => {
|
|
68
|
+
this.onUpdateNodes(props);
|
|
69
|
+
});
|
|
70
|
+
_defineProperty(this, "onUpdateNodes", props => {
|
|
71
|
+
if (props.Nodes && props.Nodes.length != 0) {
|
|
72
|
+
let data = JSON.parse(JSON.stringify(layout));
|
|
73
|
+
data.definition.actions = props.Nodes;
|
|
74
|
+
this.importedJsonFile(data);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
_defineProperty(this, "onload", async () => {
|
|
78
|
+
let self = this;
|
|
79
|
+
this.fileLoadedFromServer = _Designer.getFileNameParam;
|
|
80
|
+
this.paletteContainer = document.getElementById('workflow-task-palette-container');
|
|
81
|
+
// this.paletteContainer.style.height = (window.innerHeight - this.paletteContainer.offsetTop) + 'px';
|
|
82
|
+
(0, _jquery.default)('.workflow--node-task-palette-item').on('mousedown', e => {
|
|
83
|
+
e.stopPropagation();
|
|
84
|
+
});
|
|
85
|
+
(0, _jquery.default)('.workflow--node-task-palette-item').on('dragstart', function (event) {
|
|
86
|
+
self.draged = event.target;
|
|
87
|
+
event.stopPropagation();
|
|
88
|
+
});
|
|
89
|
+
(0, _jquery.default)('.fc-workflow--node-task-palette-item').on('dragstart', function (event) {
|
|
90
|
+
console.log(event.target);
|
|
91
|
+
self.draged = event.target;
|
|
92
|
+
event.stopPropagation();
|
|
93
|
+
});
|
|
94
|
+
(0, _jquery.default)('.workflow--node-task-palette-item').on('drag', function (event) {
|
|
95
|
+
event.stopPropagation();
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// prevent dragenter and dragover if you want drop event fired
|
|
99
|
+
document.addEventListener("dragenter", function (event) {
|
|
100
|
+
// highlight potential drop target when the draggable element enters it
|
|
101
|
+
if (event.target.className.indexOf('jtk-overlay') >= 0) {
|
|
102
|
+
event.target.classList.add('onDroping');
|
|
103
|
+
}
|
|
104
|
+
event.stopPropagation();
|
|
105
|
+
}, false);
|
|
106
|
+
/* events fired on the drop targets */
|
|
107
|
+
document.addEventListener("dragover", function (event) {
|
|
108
|
+
// prevent default to allow drop
|
|
109
|
+
event.preventDefault();
|
|
110
|
+
}, false);
|
|
111
|
+
document.addEventListener("dragleave", function (event) {
|
|
112
|
+
event.stopPropagation();
|
|
113
|
+
// reset background of potential drop target when the draggable element leaves it
|
|
114
|
+
if (event.target.className.indexOf('jtk-overlay') >= 0) {
|
|
115
|
+
event.target.classList.remove('onDroping');
|
|
116
|
+
}
|
|
117
|
+
}, false);
|
|
118
|
+
document.addEventListener("dragend", function (event) {
|
|
119
|
+
// reset the transparency
|
|
120
|
+
}, false);
|
|
121
|
+
document.addEventListener("drop", function (event) {
|
|
122
|
+
let moveTask = false,
|
|
123
|
+
taskId = "";
|
|
124
|
+
// prevent default action (open as link for some elements)
|
|
125
|
+
event.preventDefault();
|
|
126
|
+
// move dragged elem to the selected drop target
|
|
127
|
+
if (event.target.className.indexOf('jtk-overlay') >= 0) {
|
|
128
|
+
event.target.classList.remove('onDroping');
|
|
129
|
+
if (self.draged.getAttribute('datatype')) {
|
|
130
|
+
var datatype = JSON.parse(self.draged.getAttribute('datatype'));
|
|
131
|
+
if (datatype && datatype.fc) {
|
|
132
|
+
taskId = self.draged.getAttribute('id');
|
|
133
|
+
moveTask = true;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (moveTask) {
|
|
137
|
+
self.addBranchTaskToPlaceHolder(taskId, event.target);
|
|
138
|
+
self.deleteTaskById(taskId);
|
|
139
|
+
} else {
|
|
140
|
+
self.addTaskToDropZone(event.target, self.draged);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
//When Node Move to other place then deleted old node
|
|
144
|
+
self.draged = null;
|
|
145
|
+
}
|
|
146
|
+
window.setTimeout(() => {
|
|
147
|
+
self.props.onChange(self.flowchartToJson());
|
|
148
|
+
}, 300);
|
|
149
|
+
}, false);
|
|
150
|
+
document.addEventListener('click', e => {
|
|
151
|
+
//console.log(e.target, document.getElementById('designer-form-container'))
|
|
152
|
+
//console.log(e.target.childNodes)
|
|
153
|
+
if (document.getElementById('designer-form-container') && document.getElementById('designer-form-container').contains(e.target) || e.target.className.indexOf('glyphicon-remove') >= 0 || e.target.childNodes.length && e.target.childNodes[0].className && e.target.childNodes[0].className.indexOf('glyphicon-remove') >= 0) return;
|
|
154
|
+
if (e.target.className.indexOf('task-iconmenu-item') >= 0 || e.target.parentElement.className.indexOf('task-iconmenu-item') >= 0) {
|
|
155
|
+
let btn = e.target.className.indexOf('task-iconmenu-item') >= 0 ? e.target : e.target.parentElement;
|
|
156
|
+
let btnType = btn.getAttribute('data-btn');
|
|
157
|
+
let taskId = btn.parentElement.getAttribute('data-task');
|
|
158
|
+
switch (btnType) {
|
|
159
|
+
case 'copy':
|
|
160
|
+
this.curCopyTask = taskId;
|
|
161
|
+
break;
|
|
162
|
+
case 'delete':
|
|
163
|
+
self.deleteTaskById(taskId);
|
|
164
|
+
break;
|
|
165
|
+
case 'rename':
|
|
166
|
+
this.curFocusTask = taskId;
|
|
167
|
+
self.setState({
|
|
168
|
+
popupRenameFormDisplay: true
|
|
169
|
+
});
|
|
170
|
+
break;
|
|
171
|
+
case 'disabled':
|
|
172
|
+
(0, _Designer.toggleDisabledTask)(taskId, this.nodes);
|
|
173
|
+
break;
|
|
174
|
+
default:
|
|
175
|
+
}
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
if (e.target.className.indexOf('fc-item') >= 0 || e.target.parentElement.className.indexOf('fc-item') >= 0) {
|
|
179
|
+
let target = e.target.className.indexOf('fc-item') >= 0 ? e.target : e.target.parentElement;
|
|
180
|
+
let targetId = target.getAttribute('id');
|
|
181
|
+
// focus on NODE_END or NODE_START
|
|
182
|
+
if (targetId === NODE_START || targetId === NODE_END) {
|
|
183
|
+
this.props.onChange(this.flowchartToJson());
|
|
184
|
+
return self.setState({
|
|
185
|
+
currentNodeFocused: null
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
var actionObj = self.nodes[target.getAttribute('id')];
|
|
189
|
+
var vars = []; //self.props.workflowSettingReducer.variables.map((v, i) => v.name)
|
|
190
|
+
|
|
191
|
+
//comment by anup start
|
|
192
|
+
// if (actionObj.schema.properties) {
|
|
193
|
+
// Object.keys(actionObj.schema.properties).forEach(key => {
|
|
194
|
+
// if (actionObj.schema.properties[key].enum && actionObj.schema.properties[key].enum[0] === "<WF_Variables_setting>") {
|
|
195
|
+
// actionObj.schema.properties[key].enum = vars; //vars.map(v => `<<${v}>>`);
|
|
196
|
+
// actionObj.schema.properties[key].enumNames = vars;
|
|
197
|
+
// }
|
|
198
|
+
// })
|
|
199
|
+
// }
|
|
200
|
+
// if (actionObj.schema.items && actionObj.schema.items.properties) {
|
|
201
|
+
// Object.keys(actionObj.schema.items.properties).forEach(key => {
|
|
202
|
+
// if (actionObj.schema.items.properties[key].enum && actionObj.schema.items.properties[key].enum[0] === "<WF_Variables_setting>") {
|
|
203
|
+
// actionObj.schema.items.properties[key].enum = vars; //vars.map(v => `<<${v}>>`);
|
|
204
|
+
// actionObj.schema.items.properties[key].enumNames = vars;
|
|
205
|
+
// }
|
|
206
|
+
// })
|
|
207
|
+
// }
|
|
208
|
+
//comment by anup Stop
|
|
209
|
+
this.props.onNodeClick(actionObj, this.flowchartToJson());
|
|
210
|
+
self.setState({
|
|
211
|
+
currentNodeFocused: actionObj
|
|
212
|
+
});
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
// not focusing on Node
|
|
216
|
+
if (this.state.currentTab === 'workflowSetting') return;
|
|
217
|
+
return self.setState(_objectSpread({
|
|
218
|
+
currentNodeFocused: null
|
|
219
|
+
}, e.target.className.indexOf('popupform-mask') >= 0 && {
|
|
220
|
+
popupRenameFormDisplay: false
|
|
221
|
+
}));
|
|
222
|
+
});
|
|
223
|
+
this.firstInstance = _jsplumb.jsPlumb.getInstance({
|
|
224
|
+
Container: 'designer-area',
|
|
225
|
+
Anchors: ['Top', 'TopCenter', 'TopRight', 'TopLeft', 'Right', 'RightMiddle', 'Bottom', 'BottomCenter', 'BottomRight', 'BottomLeft', 'Left', 'LeftMiddle'],
|
|
226
|
+
DragOptions: {
|
|
227
|
+
cursor: "pointer",
|
|
228
|
+
zIndex: 2000
|
|
229
|
+
},
|
|
230
|
+
Container: 'flowBox',
|
|
231
|
+
PaintStyle: {
|
|
232
|
+
strokeWidth: 2,
|
|
233
|
+
stroke: "#9E9E9E",
|
|
234
|
+
boxShadow: "0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12)",
|
|
235
|
+
transition: "color 0.15s ease-in -out, background - color 0.15s ease -in -out, border - color 0.15s ease -in -out, box - shadow 0.15s ease -in -out"
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
this.paletteBoard = document.getElementById('workflow-task-palette-container');
|
|
239
|
+
if (this.paletteBoard) {
|
|
240
|
+
this.firstInstance.importDefaults({
|
|
241
|
+
Connector: ["Flowchart", {
|
|
242
|
+
cornerRadius: 4,
|
|
243
|
+
stub: 0
|
|
244
|
+
}]
|
|
245
|
+
// ConnectionOverlays: [['Custom', overlayPlus()]]
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
this.containerWrapper = document.getElementById('workflow-node-designer-wrapper-area');
|
|
249
|
+
this.container = document.getElementById('designer-area');
|
|
250
|
+
this.containerWrapper.addEventListener('wheel', e => {
|
|
251
|
+
if (e.ctrlKey) {
|
|
252
|
+
e.preventDefault();
|
|
253
|
+
let formData = document.getElementById('designer-form-container');
|
|
254
|
+
if (formData && formData.contains(e.target)) return;
|
|
255
|
+
console.log(e.target);
|
|
256
|
+
let xScreen = e.pageX - self.container.offsetLeft;
|
|
257
|
+
let yScreen = e.pageY - self.container.offsetTop;
|
|
258
|
+
|
|
259
|
+
// find current location on the image at the current scale
|
|
260
|
+
self.xImage = self.xImage + (xScreen - self.xLast) * self.scale;
|
|
261
|
+
self.yImage = self.yImage + (yScreen - self.yLast) * self.scale;
|
|
262
|
+
|
|
263
|
+
// determine the new scale
|
|
264
|
+
if (e.deltaY > 0) {
|
|
265
|
+
self.scale += 0.02;
|
|
266
|
+
} else {
|
|
267
|
+
self.scale += -0.02;
|
|
268
|
+
}
|
|
269
|
+
if (self.scale < 0.3) {
|
|
270
|
+
self.scale = 0.3;
|
|
271
|
+
return;
|
|
272
|
+
} else if (self.scale > 2) {
|
|
273
|
+
self.scale = 2;
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// determine the location on the screen at the new scale
|
|
278
|
+
let xNew = (xScreen - self.xImage) / self.scale;
|
|
279
|
+
let yNew = (yScreen - self.yImage) / self.scale;
|
|
280
|
+
|
|
281
|
+
// save the current screen location
|
|
282
|
+
self.xLast = xScreen;
|
|
283
|
+
self.yLast = yScreen;
|
|
284
|
+
|
|
285
|
+
// redraw
|
|
286
|
+
self.container.style.cssText = ["-webkit-transform: scale(".concat(self.scale, ")"), "-moz-transform: scale(".concat(self.scale, ")"), "-ms-transform: scale(".concat(self.scale, ")"), "-o-transform: scale(".concat(self.scale, ")"), "transform: scale(".concat(self.scale, ")"), "transform-origin: ".concat(self.xImage, "px ").concat(self.yImage, "px") // `translate: ${xNew*self.scale}px ${yNew*self.scale}px`
|
|
287
|
+
].join(';');
|
|
288
|
+
self.container.style.left = "".concat(self.containerPosition.x, "px");
|
|
289
|
+
self.container.style.top = "".concat(self.containerPosition.y, "px");
|
|
290
|
+
self.firstInstance.setZoom(self.scale);
|
|
291
|
+
return false;
|
|
292
|
+
} else if (this.state.currentNodeFocused === null) {
|
|
293
|
+
if (e.deltaY > 0) {
|
|
294
|
+
self.containerPosition = {
|
|
295
|
+
x: self.containerPosition.x,
|
|
296
|
+
y: self.containerPosition.y - 10
|
|
297
|
+
};
|
|
298
|
+
} else {
|
|
299
|
+
self.containerPosition = {
|
|
300
|
+
x: self.containerPosition.x,
|
|
301
|
+
y: self.containerPosition.y + 10
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
self.container.style.left = "".concat(self.containerPosition.x, "px");
|
|
305
|
+
self.container.style.top = "".concat(self.containerPosition.y, "px");
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
var touchStartY, touchStartX;
|
|
309
|
+
this.containerWrapper.addEventListener('touchend', e => {
|
|
310
|
+
touchStartY = undefined;
|
|
311
|
+
touchStartX = undefined;
|
|
312
|
+
});
|
|
313
|
+
this.containerWrapper.addEventListener('touchmove', e => {
|
|
314
|
+
if (this.state.currentNodeFocused === null) {
|
|
315
|
+
e.preventDefault();
|
|
316
|
+
//console.log("on touchmove")
|
|
317
|
+
touchStartY = touchStartY ? touchStartY : Math.round(e.touches[0].pageY);
|
|
318
|
+
touchStartX = touchStartX ? touchStartX : Math.round(e.touches[0].pageX);
|
|
319
|
+
var yEnd = Math.round(e.touches[0].pageY),
|
|
320
|
+
xEnd = Math.round(e.touches[0].pageX),
|
|
321
|
+
yDistance = yEnd - touchStartY,
|
|
322
|
+
xDistance = xEnd - touchStartX;
|
|
323
|
+
if (yDistance > 5 || yDistance < -5) {
|
|
324
|
+
touchStartY = touchStartY + yDistance;
|
|
325
|
+
self.containerPosition = {
|
|
326
|
+
x: self.containerPosition.x,
|
|
327
|
+
y: self.containerPosition.y + yDistance
|
|
328
|
+
};
|
|
329
|
+
self.container.style.left = "".concat(self.containerPosition.x, "px");
|
|
330
|
+
self.container.style.top = "".concat(self.containerPosition.y, "px");
|
|
331
|
+
}
|
|
332
|
+
if (xDistance > 5 || xDistance < -5) {
|
|
333
|
+
touchStartX = touchStartX + xDistance;
|
|
334
|
+
self.containerPosition = {
|
|
335
|
+
x: self.containerPosition.x + xDistance,
|
|
336
|
+
y: self.containerPosition.y
|
|
337
|
+
};
|
|
338
|
+
self.container.style.left = "".concat(self.containerPosition.x, "px");
|
|
339
|
+
self.container.style.top = "".concat(self.containerPosition.y, "px");
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
this.containerWrapper.addEventListener('mousedown', e => {
|
|
344
|
+
//////console.log('mousedown ', e.target)
|
|
345
|
+
if (e.target === self.containerWrapper || e.target === self.container || e.target.className.indexOf('jtk-overlay') >= 0) {
|
|
346
|
+
self.startDropPosition = {
|
|
347
|
+
x: e.pageX,
|
|
348
|
+
y: e.pageY
|
|
349
|
+
};
|
|
350
|
+
self.onDragContainer = true;
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
this.containerWrapper.addEventListener('mouseup', e => {
|
|
354
|
+
// if (self.onDragContainer) {
|
|
355
|
+
// self.firstInstance.repaintEverything();
|
|
356
|
+
// }
|
|
357
|
+
self.onDragContainer = false;
|
|
358
|
+
});
|
|
359
|
+
this.containerWrapper.addEventListener('mousemove', e => {
|
|
360
|
+
if (self.onDragContainer) {
|
|
361
|
+
self.containerPosition = {
|
|
362
|
+
x: self.containerPosition.x + (e.pageX - self.startDropPosition.x) / 1,
|
|
363
|
+
y: self.containerPosition.y + (e.pageY - self.startDropPosition.y) / 1
|
|
364
|
+
};
|
|
365
|
+
self.container.style.left = "".concat(self.containerPosition.x, "px");
|
|
366
|
+
self.container.style.top = "".concat(self.containerPosition.y, "px");
|
|
367
|
+
self.startDropPosition.x = e.pageX;
|
|
368
|
+
self.startDropPosition.y = e.pageY;
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
this.containerWrapper.addEventListener('click', e => {
|
|
372
|
+
console.log('click', e.target);
|
|
373
|
+
if (e.target.className.indexOf('fc-task-placeholder') >= 0 && !this.state.taskPalette.display) {
|
|
374
|
+
this.setState({
|
|
375
|
+
taskPalette: {
|
|
376
|
+
display: true,
|
|
377
|
+
x: e.pageX,
|
|
378
|
+
y: e.pageY
|
|
379
|
+
}
|
|
380
|
+
}).then(ele => {
|
|
381
|
+
this.props.onChange(this.flowchartToJson());
|
|
382
|
+
});
|
|
383
|
+
} else {
|
|
384
|
+
window.setTimeout(() => {
|
|
385
|
+
this.props.onChange(this.flowchartToJson());
|
|
386
|
+
}, 300);
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
this.resetFlowchart();
|
|
390
|
+
this.firstInstance.draggable([this.paletteBoard], {
|
|
391
|
+
containment: document.getElementById('workflow-node-designer-wrapper-area'),
|
|
392
|
+
stop: params => {
|
|
393
|
+
console.log(this.nodes);
|
|
394
|
+
console.log('STOP');
|
|
395
|
+
// ////////console.log('STOP ', params)
|
|
396
|
+
},
|
|
397
|
+
|
|
398
|
+
start: () => {
|
|
399
|
+
console.log(this.nodes);
|
|
400
|
+
console.log('start');
|
|
401
|
+
},
|
|
402
|
+
drag: e => {
|
|
403
|
+
// ////////console.log('dragging', e)
|
|
404
|
+
// return false;
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
if (this.fileLoadedFromServer) {
|
|
408
|
+
// this.props.loadFileFromServer(this.fileLoadedFromServer());
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
_defineProperty(this, "addBranchTaskToPlaceHolder", (task, placeholder) => {
|
|
413
|
+
// this.setState({paletteActive: true});
|
|
414
|
+
let plusIcon = placeholder.querySelector('.workflow--node-dropable-zone');
|
|
415
|
+
let source = plusIcon.getAttribute('data-source');
|
|
416
|
+
let target = plusIcon.getAttribute('data-target');
|
|
417
|
+
let branch = plusIcon.getAttribute('data-position');
|
|
418
|
+
let self = this;
|
|
419
|
+
let newParent = "node-".concat(_count);
|
|
420
|
+
let endBranchNode;
|
|
421
|
+
|
|
422
|
+
////console.log('addBranchTaskToPlaceHolder', task, self.nodes)
|
|
423
|
+
let taskCount = _count;
|
|
424
|
+
self.addTaskToDropZone(placeholder, null, self.nodes[task].datatype, self.nodes[task]);
|
|
425
|
+
// renameTask(`node-${_count-1}`, self.nodes, self.nodes[task].displayName);
|
|
426
|
+
let endId = "node-end-".concat(self.nodes[task].count);
|
|
427
|
+
for (var i = 0; i < self.nodes[task].branch; i++) {
|
|
428
|
+
let cNode = self.nodes[task].next[i];
|
|
429
|
+
let countInBranch;
|
|
430
|
+
////console.log('2706 branch =====> ', cNode, newParent)
|
|
431
|
+
while (cNode !== endId) {
|
|
432
|
+
////console.log('2706 cNode ****', cNode)
|
|
433
|
+
if (self.nodes[cNode].type === SPECIAL_END_NODE || self.nodes[cNode].type === SPECIAL_CORNER_NODE) {
|
|
434
|
+
cNode = self.nodes[cNode].next;
|
|
435
|
+
} else if (cNode === newParent) {
|
|
436
|
+
cNode = "node-end-".concat(self.nodes[cNode].count);
|
|
437
|
+
} else {
|
|
438
|
+
let previous = self.nodes[cNode].previous;
|
|
439
|
+
let next = self.nodes[cNode].next;
|
|
440
|
+
////console.log('previous, next ', previous, next, self.nodes[previous], self.nodes[next])
|
|
441
|
+
if (self.nodes[previous].type === SPECIAL_CORNER_NODE) {
|
|
442
|
+
previous = "node-topbranch_".concat(i, "-").concat(taskCount);
|
|
443
|
+
} else if (self.nodes[previous].type === SPECIAL_END_NODE) {
|
|
444
|
+
previous = "node-end-".concat(countInBranch);
|
|
445
|
+
} else {
|
|
446
|
+
previous = "node-".concat(_count - 1);
|
|
447
|
+
}
|
|
448
|
+
next = "node-botbranch_".concat(i, "-").concat(taskCount);
|
|
449
|
+
let o = self.getOverlayBySourceTarget(previous, next);
|
|
450
|
+
if (!self.nodes[cNode].branch) {
|
|
451
|
+
self.addTaskToDropZone(o, null, this.nodes[cNode].datatype, self.nodes[cNode]);
|
|
452
|
+
// renameTask(`node-${_count-1}`, self.nodes, self.nodes[cNode].displayName);
|
|
453
|
+
cNode = self.nodes[cNode].next;
|
|
454
|
+
} else {
|
|
455
|
+
countInBranch = _count;
|
|
456
|
+
this.addBranchTaskToPlaceHolder(cNode, o);
|
|
457
|
+
cNode = self.nodes["node-end-".concat(self.nodes[cNode].count)].next;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
});
|
|
463
|
+
_defineProperty(this, "updateWorkflowPermission", permission => {
|
|
464
|
+
this.setState({
|
|
465
|
+
permission: permission,
|
|
466
|
+
newWorkflowSetup: false
|
|
467
|
+
});
|
|
468
|
+
});
|
|
469
|
+
_defineProperty(this, "setDroppable", () => {
|
|
470
|
+
console.log(this.flowchartToJson());
|
|
471
|
+
});
|
|
472
|
+
this.currentFocusOverlay = null;
|
|
473
|
+
this.state = {
|
|
474
|
+
options: [],
|
|
475
|
+
taskPalette: {
|
|
476
|
+
display: true,
|
|
477
|
+
x: 0,
|
|
478
|
+
y: 0
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
this.togglePalette = this.togglePalette.bind(this);
|
|
482
|
+
|
|
483
|
+
//Workflow
|
|
484
|
+
this.elements = [];
|
|
485
|
+
this.scale = 1;
|
|
486
|
+
this.xLast = 0; // last x location on the screen
|
|
487
|
+
this.yLast = 0; // last y location on the screen
|
|
488
|
+
this.xImage = 0; // last x location on the image
|
|
489
|
+
this.yImage = 0; // last y location on the image
|
|
490
|
+
this.nodes = {};
|
|
491
|
+
this.IsMainBranch = true;
|
|
492
|
+
this.startDropPosition = {
|
|
493
|
+
x: null,
|
|
494
|
+
y: null
|
|
495
|
+
};
|
|
496
|
+
this.containerPosition = {
|
|
497
|
+
x: 0,
|
|
498
|
+
y: 0
|
|
499
|
+
};
|
|
500
|
+
this.onDragContainer = false;
|
|
501
|
+
this.variables = {};
|
|
502
|
+
this.curCopyTask = false;
|
|
503
|
+
this.curFocusTask = false;
|
|
504
|
+
this.curTaskCallService = null;
|
|
505
|
+
this.flexibleNode = {
|
|
506
|
+
id: null,
|
|
507
|
+
jsonData: null
|
|
508
|
+
};
|
|
509
|
+
// this.currentFocusOverlay = null;
|
|
510
|
+
this.handleClickOverlay = this.handleClickOverlay.bind(this);
|
|
511
|
+
this.togglePalette = this.togglePalette.bind(this);
|
|
512
|
+
this.moveDownFlowchart = this.moveDownFlowchart.bind(this);
|
|
513
|
+
this.nodes = {};
|
|
514
|
+
this.exportFlowchart = this.exportFlowchart.bind(this);
|
|
515
|
+
this.addTaskToDropZone = this.addTaskToDropZone.bind(this);
|
|
516
|
+
this.updateFormValue = this.updateFormValue.bind(this);
|
|
517
|
+
this.updateFormVar = this.updateFormVar.bind(this);
|
|
518
|
+
this.addEndPointToNode = this.addEndPointToNode.bind(this);
|
|
519
|
+
this.connectNodes = this.connectNodes.bind(this);
|
|
520
|
+
this.expandFlowchart = this.expandFlowchart.bind(this);
|
|
521
|
+
this.getDataBranchTask = this.getDataBranchTask.bind(this);
|
|
522
|
+
this.getDataBranchNode = this.getDataBranchNode.bind(this);
|
|
523
|
+
this.addEndpoints = this.addEndpoints.bind(this);
|
|
524
|
+
this.hoverTaskAction = this.hoverTaskAction.bind(this);
|
|
525
|
+
this.deleteTaskById = this.deleteTaskById.bind(this);
|
|
526
|
+
this.getOverlayBySourceTarget = this.getOverlayBySourceTarget.bind(this);
|
|
527
|
+
this.narrowFlowchart = this.narrowFlowchart.bind(this);
|
|
528
|
+
this.moveUpFlowchart = this.moveUpFlowchart.bind(this);
|
|
529
|
+
this.handleRenameTask = this.handleRenameTask.bind(this);
|
|
530
|
+
this.importedJsonFile = this.importedJsonFile.bind(this);
|
|
531
|
+
this.reRenderFromFile = this.reRenderFromFile.bind(this);
|
|
532
|
+
this.resetFlowchart = this.resetFlowchart.bind(this);
|
|
533
|
+
this.getVariablesHardcode = this.getVariablesHardcode.bind(this);
|
|
534
|
+
this.flowchartToJson = this.flowchartToJson.bind(this);
|
|
535
|
+
this.selectTab = this.selectTab.bind(this);
|
|
536
|
+
this.handleChangePermissionSetting = this.handleChangePermissionSetting.bind(this);
|
|
537
|
+
this.removeBranch = this.removeBranch.bind(this);
|
|
538
|
+
this.addNewBranch = this.addNewBranch.bind(this);
|
|
539
|
+
this.reRenderBranchTask = this.reRenderBranchTask.bind(this);
|
|
540
|
+
this.removeAllEndpointOfNode = this.removeAllEndpointOfNode.bind(this);
|
|
541
|
+
this.handleSubmitTaskForm = this.handleSubmitTaskForm.bind(this);
|
|
542
|
+
}
|
|
543
|
+
// componentWillReceiveProps(newProps) {
|
|
544
|
+
// console.log(newProps.workflowobj)
|
|
545
|
+
// console.log(newProps.is_import)
|
|
546
|
+
// console.log('componentWillReceiveProps ', newProps)
|
|
547
|
+
// let self = this;
|
|
548
|
+
// if (newProps.workflowobj) {
|
|
549
|
+
// self.onload();
|
|
550
|
+
// }
|
|
551
|
+
// }
|
|
552
|
+
|
|
553
|
+
render() {
|
|
554
|
+
let self = this;
|
|
555
|
+
const props = this.props;
|
|
556
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
557
|
+
className: "workflow-node-designer-container"
|
|
558
|
+
}, /*#__PURE__*/_react.default.createElement(_TaskPalette.default, {
|
|
559
|
+
buttonRef: props.buttonRef,
|
|
560
|
+
onCancel: props.onCancel,
|
|
561
|
+
onSave: props.onSave,
|
|
562
|
+
isToggele: props.isToggele,
|
|
563
|
+
options: props.options,
|
|
564
|
+
isActive: !!this.currentFocusOverlay,
|
|
565
|
+
isDisplay: this.state.taskPalette.display,
|
|
566
|
+
left: this.state.taskPalette.x + 40,
|
|
567
|
+
top: this.state.taskPalette.y,
|
|
568
|
+
toggle: this.togglePalette
|
|
569
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
570
|
+
className: "workflow-node-designer-wrapper",
|
|
571
|
+
id: "workflow-node-designer-wrapper-area"
|
|
572
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
573
|
+
id: "designer-area",
|
|
574
|
+
ref: e => this.container = e
|
|
575
|
+
})));
|
|
576
|
+
}
|
|
577
|
+
handleSubmitTaskForm(nodeId, e) {
|
|
578
|
+
let self = this;
|
|
579
|
+
}
|
|
580
|
+
selectTab(tab) {
|
|
581
|
+
//console.log('==================== ', tab)
|
|
582
|
+
this.setState({
|
|
583
|
+
currentTab: tab
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
handleChangePermissionSetting(inputName, e) {
|
|
587
|
+
let {
|
|
588
|
+
permission
|
|
589
|
+
} = this.state;
|
|
590
|
+
if (inputName == 'permissionRead') {
|
|
591
|
+
permission.read = e;
|
|
592
|
+
} else if (inputName == 'permissionDesign') {
|
|
593
|
+
permission.design = e;
|
|
594
|
+
}
|
|
595
|
+
this.setState({
|
|
596
|
+
permission
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
getVariablesHardcode() {
|
|
600
|
+
let self = this;
|
|
601
|
+
let listVar = {};
|
|
602
|
+
// this.props.workflowSettingReducer.variables.forEach(v => {
|
|
603
|
+
// listVar[v.name] = {
|
|
604
|
+
// /*"displayName": v.name,
|
|
605
|
+
// "dataType": {
|
|
606
|
+
// "name": v.type,
|
|
607
|
+
// "version": 1
|
|
608
|
+
// },
|
|
609
|
+
// "defaultValue": v.defaultValue,
|
|
610
|
+
// "displayDefaultValue": "",
|
|
611
|
+
// "output": false,
|
|
612
|
+
// "name": v.name,
|
|
613
|
+
// "source": "workflow",
|
|
614
|
+
// "initiate": false,
|
|
615
|
+
// "configuration": {
|
|
616
|
+
// "description": "",
|
|
617
|
+
// "defaultValue": '',
|
|
618
|
+
// "displayDefaultValue": ""
|
|
619
|
+
// },
|
|
620
|
+
// "isInUse": false,
|
|
621
|
+
// "isUsedInActions": true,
|
|
622
|
+
// "usedInActions": []*/
|
|
623
|
+
// "name": v.name,
|
|
624
|
+
// "type": v.type,
|
|
625
|
+
// ...(v.defaultValueString !== undefined && { "defaultValueString": v.defaultValueString }),
|
|
626
|
+
// ...(v.defaultValueNumber !== undefined && { "defaultValueNumber": v.defaultValueNumber }),
|
|
627
|
+
// ...(v.defaultValueBoolean !== undefined && { "defaultValueBoolean": v.defaultValueBoolean }),
|
|
628
|
+
// ...(v.defaultValueObject !== undefined && { "defaultValueObject": v.defaultValueObject }),
|
|
629
|
+
// ...(v.defaultValueArray != undefined && { "defaultValueArray": v.defaultValueArray }),
|
|
630
|
+
// "value": v.value
|
|
631
|
+
// }
|
|
632
|
+
// })
|
|
633
|
+
|
|
634
|
+
let result = [];
|
|
635
|
+
Object.keys(listVar).forEach(key => result.push(listVar[key]));
|
|
636
|
+
//console.log(result)
|
|
637
|
+
return result;
|
|
638
|
+
}
|
|
639
|
+
reRenderBranchTask(task, placeholder) {
|
|
640
|
+
//console.log('1307 reRenderBranchTask ', task, placeholder)
|
|
641
|
+
let self = this;
|
|
642
|
+
let taskCount = _count;
|
|
643
|
+
self.addTaskToDropZone(placeholder, null, task.datatype, task, task.number);
|
|
644
|
+
//console.log(this.nodes)
|
|
645
|
+
let endId = "node-end-".concat(task.number);
|
|
646
|
+
for (var i = 0; i < task.branches.length; i++) {
|
|
647
|
+
let cNode = task.branches[i][0];
|
|
648
|
+
// console('1307 loop though branches', i, task.branches[i])
|
|
649
|
+
// let countInBranch;
|
|
650
|
+
////console.log('2706 branch =====> ', cNode, newParent)
|
|
651
|
+
task.branches[i].actions.forEach((n, j) => {
|
|
652
|
+
//console.log('loop in branch ', i, n, j);
|
|
653
|
+
cNode = "node-".concat(n.number);
|
|
654
|
+
let pre;
|
|
655
|
+
let nex = "node-botbranch_".concat(i, "-").concat(task.number);
|
|
656
|
+
if (j === 0) {
|
|
657
|
+
pre = "node-topbranch_".concat(i, "-").concat(task.number);
|
|
658
|
+
} else {
|
|
659
|
+
pre = "node-".concat(n.previous);
|
|
660
|
+
//console.log(task.branches)
|
|
661
|
+
if (task.branches[i].actions[j - 1].branches && task.branches[i].actions[j - 1].branches.length > 0) {
|
|
662
|
+
pre = "node-end-".concat(n.previous);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
let o = self.getOverlayBySourceTarget(pre, nex);
|
|
666
|
+
if (!n.branches || !n.branches.length) {
|
|
667
|
+
self.addTaskToDropZone(o, null, n.datatype, n, n.number);
|
|
668
|
+
} else {
|
|
669
|
+
self.reRenderBranchTask(n, o);
|
|
670
|
+
}
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
reRenderFromFile() {
|
|
675
|
+
this.resetFlowchart();
|
|
676
|
+
let self = this;
|
|
677
|
+
let previous = NODE_START;
|
|
678
|
+
this.maxCount = -1;
|
|
679
|
+
//console.log('1307 reRenderFromFile ', this.importData)
|
|
680
|
+
this.importData.definition && this.importData.definition.actions && this.importData.definition.actions.forEach((e, i) => {
|
|
681
|
+
let o = self.getOverlayBySourceTarget(previous, NODE_END);
|
|
682
|
+
if (e.branches && e.branches.length >= 1) {
|
|
683
|
+
self.reRenderBranchTask(e, o);
|
|
684
|
+
previous = "node-end-".concat(e.number);
|
|
685
|
+
} else {
|
|
686
|
+
//console.log(o)
|
|
687
|
+
self.addTaskToDropZone(o, null, e.datatype, e, e.number);
|
|
688
|
+
previous = "node-".concat(e.number);
|
|
689
|
+
}
|
|
690
|
+
});
|
|
691
|
+
Object.keys(this.nodes).forEach(key => {
|
|
692
|
+
if (self.nodes[key].configuration && self.nodes[key].configuration.actionName === 'set_variables') {
|
|
693
|
+
self.variables[key] = {};
|
|
694
|
+
self.nodes[key].configuration.properties.forEach(variable => {
|
|
695
|
+
self.variables[key][variable.var] = variable.value;
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
});
|
|
699
|
+
|
|
700
|
+
//console.log('bon0507 variables ', self.variables)
|
|
701
|
+
_count = this.maxCount + 1;
|
|
702
|
+
this.firstInstance.repaintEverything();
|
|
703
|
+
console.log(this.nodes);
|
|
704
|
+
}
|
|
705
|
+
removeAllEndpointOfNode(node) {
|
|
706
|
+
let self = this;
|
|
707
|
+
this.firstInstance.selectEndpoints({
|
|
708
|
+
element: node
|
|
709
|
+
}).each(ep => {
|
|
710
|
+
// //console.log('1307 remove endpoint ', ep);
|
|
711
|
+
self.firstInstance.deleteEndpoint(ep);
|
|
712
|
+
});
|
|
713
|
+
//console.log('1307 ep select after remove', node, this.firstInstance.selectEndpoints({element: node}))
|
|
714
|
+
// this.firstInstance.deleteEveryEndpoint();
|
|
715
|
+
// this.firstInstance.deleteEndpoint({uuid: `${node}-ep-right`});
|
|
716
|
+
// this.firstInstance.deleteEndpoint({uuid: `${node}-ep-bottom`});
|
|
717
|
+
// this.firstInstance.deleteEndpoint({uuid: `${node}-ep-left`});
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
handleRenameTask(value) {
|
|
721
|
+
(0, _Designer.renameTask)(this.curFocusTask, this.nodes, value);
|
|
722
|
+
this.setState({
|
|
723
|
+
popupRenameFormDisplay: false
|
|
724
|
+
});
|
|
725
|
+
this.props.onChange(this.flowchartToJson());
|
|
726
|
+
}
|
|
727
|
+
getOverlayBySourceTarget(source, target) {
|
|
728
|
+
let o = document.querySelector('.jtk-overlay .workflow--node-dropable-zone[data-source="' + source + '"][data-target="' + target + '"]');
|
|
729
|
+
//console.log('getOverlayBySourceTarget ', source, target, o)
|
|
730
|
+
return o.parentElement;
|
|
731
|
+
}
|
|
732
|
+
resetFlowchart() {
|
|
733
|
+
let self = this;
|
|
734
|
+
Object.keys(this.nodes).forEach(key => {
|
|
735
|
+
//console.log('0507====> key', key, self.nodes[key])
|
|
736
|
+
if (self.nodes[key].element) {
|
|
737
|
+
self.firstInstance.deleteConnectionsForElement(key);
|
|
738
|
+
self.nodes[key].element.remove();
|
|
739
|
+
}
|
|
740
|
+
});
|
|
741
|
+
this.firstInstance.deleteEveryEndpoint();
|
|
742
|
+
this.nodes = {};
|
|
743
|
+
let xValue = window.innerWidth * 0.5 - 20;
|
|
744
|
+
let yMiddle = (window.innerHeight - 50) * 0.1;
|
|
745
|
+
let yValue = 10 + _workflow.config.nodeSizeDefault / 2 + _workflow.config.nodeGap + _workflow.config.nodeSizeDefault / 2;
|
|
746
|
+
// add startpoint and endpoint
|
|
747
|
+
this.container.innerHTML += '<div id="' + NODE_START + '" class="fc-item fc-item-draggable" style="top: ' + (yMiddle - _workflow.config.nodeGap / 2 - _workflow.config.nodeSizeDefault / 2) + 'px; left: ' + xValue + 'px;"><span class="fa fa-play"></span></div>';
|
|
748
|
+
this.container.innerHTML += '<div id="' + NODE_END + '" class="fc-item fc-item-draggable" style="top: ' + (yMiddle + _workflow.config.nodeGap / 2) + 'px; left: ' + xValue + 'px;"><span class="fa fa-stop"></span></div>';
|
|
749
|
+
this.nodes.nodeStart = document.getElementById(NODE_START);
|
|
750
|
+
this.nodes.nodeEnd = document.getElementById(NODE_END);
|
|
751
|
+
this.addEndPointToNode(this.nodes.nodeStart, 'Bottom', "".concat(NODE_START, "-ep-bottom"));
|
|
752
|
+
this.addEndPointToNode(this.nodes.nodeEnd, 'Top', "".concat(NODE_END, "-ep-top"));
|
|
753
|
+
this.connectNodes(['Custom', (0, _Designer.overlayPlus)(NODE_START, NODE_END)], NODE_START + '-ep-bottom', NODE_END + '-ep-top');
|
|
754
|
+
this.nodes[NODE_START] = {
|
|
755
|
+
nodeId: NODE_START,
|
|
756
|
+
next: NODE_END,
|
|
757
|
+
previous: null,
|
|
758
|
+
element: this.nodes.nodeStart,
|
|
759
|
+
type: NODE_START,
|
|
760
|
+
data: {}
|
|
761
|
+
};
|
|
762
|
+
this.nodes[NODE_END] = {
|
|
763
|
+
nodeId: NODE_END,
|
|
764
|
+
next: null,
|
|
765
|
+
previous: NODE_START,
|
|
766
|
+
element: this.nodes.nodeEnd,
|
|
767
|
+
type: NODE_END,
|
|
768
|
+
data: {}
|
|
769
|
+
};
|
|
770
|
+
this.firstInstance.repaintEverything();
|
|
771
|
+
let connections = this.firstInstance.getConnections({
|
|
772
|
+
source: NODE_START,
|
|
773
|
+
target: NODE_END
|
|
774
|
+
});
|
|
775
|
+
//console.log('0507', this.nodes, connections)
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
deleteTaskById(taskId) {
|
|
779
|
+
let previous = this.nodes[taskId].previous;
|
|
780
|
+
let next = this.nodes[taskId].next;
|
|
781
|
+
let branch = this.nodes[taskId].onBranch ? Number(this.nodes[taskId].onBranch) : null;
|
|
782
|
+
let nodeList = [taskId];
|
|
783
|
+
let parent = this.nodes[taskId].parent;
|
|
784
|
+
let onBranch = this.nodes[taskId].onBranch;
|
|
785
|
+
let self = this;
|
|
786
|
+
if (this.nodes[taskId].branch) {
|
|
787
|
+
next = this.nodes["node-end-".concat(this.nodes[taskId].count)].next;
|
|
788
|
+
nodeList.push("node-end-".concat(this.nodes[taskId].count));
|
|
789
|
+
for (var i = 0; i < this.nodes[taskId].branch; i++) {
|
|
790
|
+
for (var j = 0; j < this.nodes[taskId][i].length; j++) {
|
|
791
|
+
nodeList.push(this.nodes[taskId][i][j]);
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
if (this.nodes[taskId].wrapper) {
|
|
796
|
+
nodeList = [...nodeList, "node-lefttop-".concat(this.nodes[taskId].count), "node-leftbot-".concat(this.nodes[taskId].count), "node-righttop-".concat(this.nodes[taskId].count), "node-rightbot-".concat(this.nodes[taskId].count)];
|
|
797
|
+
}
|
|
798
|
+
let loopParent = parent;
|
|
799
|
+
while (loopParent) {
|
|
800
|
+
////console.log(loopParent)
|
|
801
|
+
let i = this.nodes[loopParent][onBranch].length;
|
|
802
|
+
////console.log('i', i, nodeList)
|
|
803
|
+
while (i--) {
|
|
804
|
+
////console.log('===> ', i)
|
|
805
|
+
if (nodeList.includes(this.nodes[loopParent][onBranch][i])) this.nodes[loopParent][onBranch].splice(i, 1);
|
|
806
|
+
}
|
|
807
|
+
onBranch = this.nodes[loopParent].onBranch;
|
|
808
|
+
loopParent = this.nodes[loopParent].parent;
|
|
809
|
+
}
|
|
810
|
+
this.narrowFlowchart(taskId);
|
|
811
|
+
this.moveUpFlowchart(taskId);
|
|
812
|
+
this.firstInstance.repaintEverything();
|
|
813
|
+
// delete all connections
|
|
814
|
+
nodeList.forEach(n => {
|
|
815
|
+
//console.log('1307 remove node ', n)
|
|
816
|
+
self.firstInstance.deleteConnectionsForElement(n);
|
|
817
|
+
// self.firstInstance.detach(n);
|
|
818
|
+
self.removeAllEndpointOfNode(n);
|
|
819
|
+
});
|
|
820
|
+
// delete all nodes
|
|
821
|
+
nodeList.forEach(n => {
|
|
822
|
+
////console.log(n)
|
|
823
|
+
document.getElementById(n).remove();
|
|
824
|
+
delete self.nodes[n];
|
|
825
|
+
});
|
|
826
|
+
this.connectNodes(['Custom', Object.assign({}, (0, _Designer.overlayPlus)(previous, next, branch))], "".concat(previous, "-ep-bottom"), "".concat(next, "-ep-top"));
|
|
827
|
+
this.nodes[next].previous = previous;
|
|
828
|
+
this.nodes[previous].next = next;
|
|
829
|
+
}
|
|
830
|
+
moveUpFlowchart(deletedTask) {
|
|
831
|
+
let previous = this.nodes[deletedTask].previous;
|
|
832
|
+
let next = this.nodes[deletedTask].next;
|
|
833
|
+
if (this.nodes[deletedTask].branch) next = this.nodes["node-end-".concat(this.nodes[deletedTask].count)].next;
|
|
834
|
+
let currentGap = this.nodes[next].element.offsetTop - (this.nodes[previous].element.offsetTop + this.nodes[previous].element.offsetHeight);
|
|
835
|
+
let gapMinus = -(currentGap - (_workflow.config.nodeGap - 50));
|
|
836
|
+
let parent = this.nodes[deletedTask].parent;
|
|
837
|
+
////console.log('********', previous, next, currentGap, config.nodeGap, this.nodes[deletedTask].onBranch)
|
|
838
|
+
let item = deletedTask;
|
|
839
|
+
let smallestGap = -gapMinus;
|
|
840
|
+
// calculate gap each branch
|
|
841
|
+
if (parent && this.nodes[parent].branch) {
|
|
842
|
+
for (var i = 0; i < this.nodes[parent].branch; i++) {
|
|
843
|
+
if (this.nodes[deletedTask].onBranch && i === +this.nodes[deletedTask].onBranch) continue;
|
|
844
|
+
let botNode = "node-botbranch_".concat(i, "-").concat(this.nodes[parent].count);
|
|
845
|
+
let prevBot = this.nodes[botNode].previous;
|
|
846
|
+
let bGap = this.nodes[botNode].element.offsetTop - (this.nodes[prevBot].element.offsetTop + this.nodes[prevBot].element.offsetHeight);
|
|
847
|
+
if (smallestGap > bGap) smallestGap = bGap;
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
////console.log('smallestGap', smallestGap)
|
|
851
|
+
if (smallestGap > _workflow.config.nodeGap) gapMinus = _workflow.config.nodeGap - smallestGap;else return;
|
|
852
|
+
while (item) {
|
|
853
|
+
////console.log('08/06 ', item, gapMinus)
|
|
854
|
+
this.nodes[item].element.style.top = "".concat(this.nodes[item].element.offsetTop + gapMinus, "px");
|
|
855
|
+
let itemP = item.split('-');
|
|
856
|
+
let corner;
|
|
857
|
+
if (itemP[1].indexOf('botbranch') >= 0) {
|
|
858
|
+
let c = this.nodes[item].count;
|
|
859
|
+
for (var i = 0; i < this.nodes[this.nodes[item].parent].branch; i++) {
|
|
860
|
+
if (item === "node-botbranch_".concat(i, "-").concat(c)) continue;
|
|
861
|
+
this.nodes["node-botbranch_".concat(i, "-").concat(c)].element.style.top = "".concat(this.nodes["node-botbranch_".concat(i, "-").concat(c)].element.offsetTop + gapMinus, "px");
|
|
862
|
+
}
|
|
863
|
+
item = this.nodes[item].next;
|
|
864
|
+
continue;
|
|
865
|
+
}
|
|
866
|
+
if (this.nodes[item].type === SPECIAL_END_NODE && this.nodes[item].parent && this.nodes[this.nodes[item].parent].wrapper) {
|
|
867
|
+
let itemLeft = "node-leftbot-".concat(this.nodes[item].count);
|
|
868
|
+
let itemRight = "node-rightbot-".concat(this.nodes[item].count);
|
|
869
|
+
this.nodes[itemLeft].element.style.top = "".concat(this.nodes[itemLeft].element.offsetTop + gapMinus, "px");
|
|
870
|
+
this.nodes[itemRight].element.style.top = "".concat(this.nodes[itemRight].element.offsetTop + gapMinus, "px");
|
|
871
|
+
}
|
|
872
|
+
if (this.nodes[item].wrapper) {
|
|
873
|
+
this.nodes["node-lefttop-".concat(this.nodes[item].count)].element.style.top = this.nodes["node-lefttop-".concat(this.nodes[item].count)].element.offsetTop + gapMinus + 'px';
|
|
874
|
+
this.nodes["node-leftbot-".concat(this.nodes[item].count)].element.style.top = this.nodes["node-leftbot-".concat(this.nodes[item].count)].element.offsetTop + gapMinus + 'px';
|
|
875
|
+
this.nodes["node-righttop-".concat(this.nodes[item].count)].element.style.top = this.nodes["node-righttop-".concat(this.nodes[item].count)].element.offsetTop + gapMinus + 'px';
|
|
876
|
+
this.nodes["node-rightbot-".concat(this.nodes[item].count)].element.style.top = this.nodes["node-rightbot-".concat(this.nodes[item].count)].element.offsetTop + gapMinus + 'px';
|
|
877
|
+
}
|
|
878
|
+
if (this.nodes[item].branch >= 1) {
|
|
879
|
+
for (var i = 0; i < this.nodes[item].branch; i++) {
|
|
880
|
+
this.nodes[item][i].forEach(n => {
|
|
881
|
+
this.nodes[n].element.style.top = "".concat(this.nodes[n].element.offsetTop + gapMinus, "px");
|
|
882
|
+
});
|
|
883
|
+
}
|
|
884
|
+
this.nodes["node-end-".concat(this.nodes[item].count)].element.style.top = "".concat(this.nodes["node-end-".concat(this.nodes[item].count)].element.offsetTop + gapMinus, "px");
|
|
885
|
+
item = "node-end-".concat(this.nodes[item].count);
|
|
886
|
+
}
|
|
887
|
+
if (!this.nodes[item].branch) {
|
|
888
|
+
item = this.nodes[item].next;
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
removeBranch(branchIndex, node) {
|
|
893
|
+
// let self = this;
|
|
894
|
+
// this.nodes[node][branchIndex].forEach(n => {
|
|
895
|
+
// self.firstInstance.deleteConnectionsForElement(n);
|
|
896
|
+
// self.firstInstance.deleteEndNo
|
|
897
|
+
// })
|
|
898
|
+
}
|
|
899
|
+
addNewBranch() {}
|
|
900
|
+
updateFormValue(node, value, removedIndex) {
|
|
901
|
+
console.log('updateFormValue', node, value, removedIndex, this.nodes[node]);
|
|
902
|
+
let self = this;
|
|
903
|
+
// add/remove branch
|
|
904
|
+
if (value && value.branches && value.branches instanceof Array) {
|
|
905
|
+
let jsonTask = self.getDataBranchNode(node);
|
|
906
|
+
console.log(jsonTask);
|
|
907
|
+
let previous = this.nodes[node].previous;
|
|
908
|
+
let next = this.nodes["node-end-".concat(jsonTask.number)].next;
|
|
909
|
+
//console.log('endpoint nodestart', this.firstInstance.selectEndpoints({element: NODE_START}));
|
|
910
|
+
if (value.branches.length !== this.nodes[node].configuration.properties.branches.length) {
|
|
911
|
+
// remove branche
|
|
912
|
+
if (value.branches.length < this.nodes[node].configuration.properties.branches.length) {
|
|
913
|
+
jsonTask.branches.splice(removedIndex, 1);
|
|
914
|
+
//console.log(jsonTask)
|
|
915
|
+
jsonTask.branch--;
|
|
916
|
+
jsonTask.configuration.properties = value;
|
|
917
|
+
}
|
|
918
|
+
// add branch
|
|
919
|
+
else if (value.branches.length > this.nodes[node].configuration.properties.branches.length) {
|
|
920
|
+
jsonTask.branches.push({
|
|
921
|
+
name: value[value.length - 1],
|
|
922
|
+
actions: []
|
|
923
|
+
});
|
|
924
|
+
jsonTask.configuration.properties = value;
|
|
925
|
+
jsonTask.branch++;
|
|
926
|
+
}
|
|
927
|
+
this.flexibleNode.id = node;
|
|
928
|
+
this.flexibleNode.jsonData = jsonTask;
|
|
929
|
+
let data = this.flowchartToJson();
|
|
930
|
+
this.importData = data;
|
|
931
|
+
self.resetFlowchart();
|
|
932
|
+
this.reRenderFromFile();
|
|
933
|
+
}
|
|
934
|
+
// change branch name
|
|
935
|
+
else {
|
|
936
|
+
this.nodes[node].configuration.properties = value;
|
|
937
|
+
}
|
|
938
|
+
return;
|
|
939
|
+
}
|
|
940
|
+
this.nodes[node].configuration.properties = value;
|
|
941
|
+
if (this.nodes[node].configuration.actionName === 'set_variables') {
|
|
942
|
+
// value.forEach((v, i) => {
|
|
943
|
+
// if (v.var && !v.value) {
|
|
944
|
+
// v.value = this.settingVarDefaultValue[v.var];
|
|
945
|
+
// }
|
|
946
|
+
// })
|
|
947
|
+
this.nodes[node].configuration.properties = value;
|
|
948
|
+
this.setState(Object.assign({}, {
|
|
949
|
+
currentNodeFocused: Object.assign({}, this.nodes[node], {
|
|
950
|
+
schema: this.state.currentNodeFocused.schema,
|
|
951
|
+
configuration: Object.assign({}, this.nodes[node].configuration, {
|
|
952
|
+
properties: value
|
|
953
|
+
})
|
|
954
|
+
})
|
|
955
|
+
})).then(() => {
|
|
956
|
+
this.props.onChange(this.flowchartToJson());
|
|
957
|
+
});
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
shouldComponentUpdate(newProps, newState) {
|
|
961
|
+
return true;
|
|
962
|
+
}
|
|
963
|
+
togglePalette() {
|
|
964
|
+
this.setState({
|
|
965
|
+
taskPalette: Object.assign({}, this.state.taskPalette, {
|
|
966
|
+
display: !this.state.taskPalette.display
|
|
967
|
+
})
|
|
968
|
+
}).then(() => {
|
|
969
|
+
this.props.onChange(this.flowchartToJson());
|
|
970
|
+
});
|
|
971
|
+
}
|
|
972
|
+
addEndPointToNode(node, position, uuid) {
|
|
973
|
+
this.firstInstance.addEndpoint(node, {
|
|
974
|
+
isSource: true,
|
|
975
|
+
isTarget: true,
|
|
976
|
+
endpoint: 'Blank',
|
|
977
|
+
uuid: uuid,
|
|
978
|
+
anchor: [position],
|
|
979
|
+
maxConnections: 100
|
|
980
|
+
});
|
|
981
|
+
}
|
|
982
|
+
addEndpoints(node, position, uuids, nodeId) {
|
|
983
|
+
let self = this;
|
|
984
|
+
if (position && position.length) {
|
|
985
|
+
position.forEach((p, i) => {
|
|
986
|
+
self.addEndPointToNode(node, p, uuids[i]);
|
|
987
|
+
});
|
|
988
|
+
return;
|
|
989
|
+
} else {
|
|
990
|
+
self.addEndPointToNode(node, 'Left', "".concat(nodeId, "-ep-left"));
|
|
991
|
+
self.addEndPointToNode(node, 'Top', "".concat(nodeId, "-ep-top"));
|
|
992
|
+
self.addEndPointToNode(node, 'Right', "".concat(nodeId, "-ep-right"));
|
|
993
|
+
self.addEndPointToNode(node, 'Bottom', "".concat(nodeId, "-ep-bottom"));
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
connectNodes(overlays, endpointStart, endpointEnd, PaintStyle) {
|
|
997
|
+
// //console.log('0507 connectNodes', overlays, PaintStyle, endpointStart, endpointEnd)
|
|
998
|
+
let self = this;
|
|
999
|
+
let connOptions = {
|
|
1000
|
+
uuids: [endpointStart, endpointEnd]
|
|
1001
|
+
};
|
|
1002
|
+
if (overlays) connOptions.overlays = [overlays];
|
|
1003
|
+
if (PaintStyle) connOptions.paintStyle = PaintStyle;
|
|
1004
|
+
let conn = this.firstInstance.connect(connOptions);
|
|
1005
|
+
conn.bind('click', self.handleClickOverlay);
|
|
1006
|
+
// //console.log('0507', conn)
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
addTaskToDropZone(destination, node, tasktype, copyTask, countValue) {
|
|
1010
|
+
//console.log('1307 addTaskToDropZone', destination, node, tasktype, countValue, _count, copyTask)
|
|
1011
|
+
if (!destination) return;
|
|
1012
|
+
if (!isNaN(parseFloat(countValue)) && isFinite(countValue)) {
|
|
1013
|
+
_count = countValue;
|
|
1014
|
+
this.maxCount = _count > this.maxCount ? _count : this.maxCount;
|
|
1015
|
+
}
|
|
1016
|
+
let self = this;
|
|
1017
|
+
let leftPosNewNode = destination.offsetLeft - 80;
|
|
1018
|
+
let destinationLeft = destination.offsetLeft;
|
|
1019
|
+
let source = destination.querySelector('.workflow--node-dropable-zone').getAttribute('data-source');
|
|
1020
|
+
let target = destination.querySelector('.workflow--node-dropable-zone').getAttribute('data-target');
|
|
1021
|
+
let position = destination.querySelector('.workflow--node-dropable-zone').getAttribute('data-position');
|
|
1022
|
+
let datatype = node ? JSON.parse(node.getAttribute('datatype')) : tasktype;
|
|
1023
|
+
// //console.log('====> datatype ', datatype)
|
|
1024
|
+
//let item = config.taskType[datatype.parent][datatype.type];
|
|
1025
|
+
let item = taskConfig[datatype.type];
|
|
1026
|
+
let branches = copyTask ? copyTask.branches ? copyTask.branches.length : null : item.branch;
|
|
1027
|
+
let connections = this.firstInstance.getConnections({
|
|
1028
|
+
source: source,
|
|
1029
|
+
target: target
|
|
1030
|
+
});
|
|
1031
|
+
let parent = '';
|
|
1032
|
+
let newNodeId = "node-".concat(_count);
|
|
1033
|
+
let taskTitle = item.title;
|
|
1034
|
+
//console.log(branches)
|
|
1035
|
+
// //console.log('0806 ', this.nodes)
|
|
1036
|
+
if (this.nodes[source].type === SPECIAL_CORNER_NODE) parent = this.nodes[source].parent;
|
|
1037
|
+
if (this.nodes[source].branch >= 1) parent = source;
|
|
1038
|
+
if (this.nodes[target].type === SPECIAL_END_NODE) parent = this.nodes[target].parent;
|
|
1039
|
+
if (this.nodes[target].parent) parent = this.nodes[target].parent;
|
|
1040
|
+
if (parent != "" && parent && this.nodes[parent].nestedLevel >= _workflow.config.MAXIMUM_NESTED) return;
|
|
1041
|
+
let curConnection = connections.filter(c => {
|
|
1042
|
+
if (!c.getOverlays().overlayPLus) return false;
|
|
1043
|
+
return c.getOverlays().overlayPLus.canvas.id === destination.getAttribute('id');
|
|
1044
|
+
});
|
|
1045
|
+
|
|
1046
|
+
// calculate the gap between source->target => decide this flowchart will be moved down or not
|
|
1047
|
+
// only do this when new node is adding to branch of other node
|
|
1048
|
+
let needToMoveFlowchart = true;
|
|
1049
|
+
let needToExpandBranchNode = false;
|
|
1050
|
+
let p = null;
|
|
1051
|
+
let parentExpand = null;
|
|
1052
|
+
if (position) {
|
|
1053
|
+
if (this.nodes[source].branch >= 1) p = source;else if (this.nodes[source].type === SPECIAL_END_NODE) p = this.nodes[this.nodes[source].parent].parent;else if (this.nodes[source].parent) p = this.nodes[source].parent;
|
|
1054
|
+
parentExpand = p;
|
|
1055
|
+
needToMoveFlowchart = (0, _Designer.isFlowchartWillMove)(this.nodes, p, position, item, source, target);
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
// remove old connection -> move nodes down -> repaint
|
|
1059
|
+
this.firstInstance.deleteConnection(curConnection[0]);
|
|
1060
|
+
if (needToMoveFlowchart) {
|
|
1061
|
+
self.moveDownFlowchart(target, datatype.type, position, branches);
|
|
1062
|
+
}
|
|
1063
|
+
this.firstInstance.repaintEverything(); // redraw everything before you addd new connect
|
|
1064
|
+
|
|
1065
|
+
// calculate top position new node
|
|
1066
|
+
let sourceH = [SPECIAL_END_NODE, SPECIAL_CORNER_NODE].includes(this.nodes[source].type) ? 0 : _workflow.config.nodeSizeDefault / 2;
|
|
1067
|
+
let targetH = [SPECIAL_END_NODE, SPECIAL_CORNER_NODE].includes(this.nodes[target].type) ? 0 : _workflow.config.nodeSizeDefault / 2;
|
|
1068
|
+
// let topPos = (this.nodes[target].element.offsetTop + this.nodes[source].element.offsetTop + sourceH + targetH)/2 - config.nodeSizeDefault/2;
|
|
1069
|
+
let topPosNewNode = this.nodes[source].element.offsetTop + (this.nodes[source].branch === 2 ? sourceH : sourceH * 2) + _workflow.config.nodeGap;
|
|
1070
|
+
if (branches === 2) {
|
|
1071
|
+
// let gapSize = this.nodes[target].element.offsetTop - (this.nodes[source].element.offsetTop + config.nodeSizeDefault);
|
|
1072
|
+
// topPos = (this.nodes[source].element.offsetTop + (source === NODE_START ? config.nodeStartEndSize : config.nodeSizeDefault)) + config.nodeGap;
|
|
1073
|
+
topPosNewNode = this.nodes[source].element.offsetTop + (this.nodes[source].branch === 2 ? sourceH : sourceH * 2) + _workflow.config.nodeGap;
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
// create new node element -> add attribute -> append to container canvas
|
|
1077
|
+
let newNode = document.createElement('div');
|
|
1078
|
+
newNode.setAttribute('id', newNodeId);
|
|
1079
|
+
newNode.setAttribute('datatype', JSON.stringify({
|
|
1080
|
+
type: item.name,
|
|
1081
|
+
parent: item.type,
|
|
1082
|
+
fc: true
|
|
1083
|
+
}));
|
|
1084
|
+
newNode.draggable = "true";
|
|
1085
|
+
newNode.className = 'fc-workflow--node-task-palette-item fc-item fc-item-draggable fc-item-default';
|
|
1086
|
+
newNode.style.cssText = 'top: ' + topPosNewNode + 'px; left: ' + leftPosNewNode + 'px;';
|
|
1087
|
+
newNode.innerHTML = node ? node.innerHTML : "\n <div class=\"task-palette-icon fa fa-".concat(item.icon, " unselectable\" ></div>\n <div class=\"task-palette-title unselectable\">").concat(copyTask ? copyTask.configuration.actionTitle : taskTitle, "</div>");
|
|
1088
|
+
(0, _Designer.addTaskMenuIcon)(newNode);
|
|
1089
|
+
this.container.append(newNode);
|
|
1090
|
+
(0, _jquery.default)('.fc-workflow--node-task-palette-item').on('dragstart', function (event) {
|
|
1091
|
+
self.draged = event.target;
|
|
1092
|
+
event.stopPropagation();
|
|
1093
|
+
});
|
|
1094
|
+
|
|
1095
|
+
// add endpoint to new node
|
|
1096
|
+
// 2 branches -> add RIGHT and LEFT endpoints
|
|
1097
|
+
//console.log('1307 check endpoint before add ', this.firstInstance.selectEndpoints({element: newNodeId}))
|
|
1098
|
+
this.addEndpoints(newNode, null, null, newNodeId);
|
|
1099
|
+
//console.log('1307 check endpoint after add ', this.firstInstance.selectEndpoints({element: newNodeId}))
|
|
1100
|
+
this.firstInstance.repaintEverything();
|
|
1101
|
+
// add TOP endpoint
|
|
1102
|
+
// this.addEndPointToNode(newNode, 'Top', `node-${_count}-ep-top`);
|
|
1103
|
+
|
|
1104
|
+
// 2 branches -> add one more node as end of new node (end-new-node)
|
|
1105
|
+
let newEndNode = null;
|
|
1106
|
+
let newLeftTopNode = null;
|
|
1107
|
+
let newLeftBotNode = null;
|
|
1108
|
+
let newRightTopNode = null;
|
|
1109
|
+
let newRightBotNode = null;
|
|
1110
|
+
let lefttopId;
|
|
1111
|
+
let leftbotId;
|
|
1112
|
+
let righttopId;
|
|
1113
|
+
let rightbotId;
|
|
1114
|
+
let endId;
|
|
1115
|
+
let nodesCornerList = [];
|
|
1116
|
+
////////console.log('branches ', branches)
|
|
1117
|
+
if (branches >= 1) {
|
|
1118
|
+
if (item.wrapper) {
|
|
1119
|
+
lefttopId = "node-lefttop-".concat(_count);
|
|
1120
|
+
leftbotId = "node-leftbot-".concat(_count);
|
|
1121
|
+
righttopId = "node-righttop-".concat(_count);
|
|
1122
|
+
rightbotId = "node-rightbot-".concat(_count);
|
|
1123
|
+
newLeftTopNode = document.createElement('div');
|
|
1124
|
+
newLeftBotNode = document.createElement('div');
|
|
1125
|
+
newRightTopNode = document.createElement('div');
|
|
1126
|
+
newRightBotNode = document.createElement('div');
|
|
1127
|
+
let gapSize = this.nodes[target].element.offsetTop - (this.nodes[source].element.offsetTop + _workflow.config.nodeSizeDefault);
|
|
1128
|
+
let topPos = this.nodes[target].element.offsetTop - _workflow.config.nodeGap;
|
|
1129
|
+
newLeftTopNode.setAttribute('id', "node-lefttop-".concat(_count));
|
|
1130
|
+
newLeftBotNode.setAttribute('id', "node-leftbot-".concat(_count));
|
|
1131
|
+
newRightTopNode.setAttribute('id', "node-righttop-".concat(_count));
|
|
1132
|
+
newRightBotNode.setAttribute('id', "node-rightbot-".concat(_count));
|
|
1133
|
+
newLeftTopNode.className = 'fc-item fc-item-draggable fc-item-end-point';
|
|
1134
|
+
newLeftBotNode.className = 'fc-item fc-item-draggable fc-item-end-point';
|
|
1135
|
+
newRightTopNode.className = 'fc-item fc-item-draggable fc-item-end-point';
|
|
1136
|
+
newRightBotNode.className = 'fc-item fc-item-draggable fc-item-end-point';
|
|
1137
|
+
newLeftTopNode.style.cssText = 'top: ' + (topPosNewNode + _workflow.config.nodeSizeDefault / 2) + 'px; left: ' + (leftPosNewNode - 90) + 'px;';
|
|
1138
|
+
newLeftBotNode.style.cssText = 'top: ' + (this.nodes[target].element.offsetTop - _workflow.config.nodeGap + 10) + 'px; left: ' + (leftPosNewNode - 90) + 'px;';
|
|
1139
|
+
newRightTopNode.style.cssText = 'top: ' + (topPosNewNode + _workflow.config.nodeSizeDefault / 2) + 'px; left: ' + (leftPosNewNode + 160 + 90) + 'px;';
|
|
1140
|
+
newRightBotNode.style.cssText = 'top: ' + (this.nodes[target].element.offsetTop - _workflow.config.nodeGap + 10) + 'px; left: ' + (leftPosNewNode + 160 + 90) + 'px;';
|
|
1141
|
+
this.container.append(newLeftTopNode);
|
|
1142
|
+
this.container.append(newRightTopNode);
|
|
1143
|
+
this.container.append(newRightBotNode);
|
|
1144
|
+
this.container.append(newLeftBotNode);
|
|
1145
|
+
this.addEndPointToNode(newLeftTopNode, 'Bottom', "".concat(lefttopId, "-ep-bottom"));
|
|
1146
|
+
this.addEndPointToNode(newLeftTopNode, 'Right', "".concat(lefttopId, "-ep-right"));
|
|
1147
|
+
this.addEndPointToNode(newRightTopNode, 'Bottom', "".concat(righttopId, "-ep-bottom"));
|
|
1148
|
+
this.addEndPointToNode(newRightTopNode, 'Left', "".concat(righttopId, "-ep-left"));
|
|
1149
|
+
this.addEndPointToNode(newRightBotNode, 'Top', "".concat(rightbotId, "-ep-top"));
|
|
1150
|
+
this.addEndPointToNode(newRightBotNode, 'Left', "".concat(rightbotId, "-ep-left"));
|
|
1151
|
+
this.addEndPointToNode(newLeftBotNode, 'Top', "".concat(leftbotId, "-ep-top"));
|
|
1152
|
+
this.addEndPointToNode(newLeftBotNode, 'Right', "".concat(leftbotId, "-ep-right"));
|
|
1153
|
+
this.nodes["node-lefttop-".concat(_count)] = {
|
|
1154
|
+
nodeId: "node-lefttop-".concat(_count),
|
|
1155
|
+
previous: "node-".concat(_count),
|
|
1156
|
+
next: "node-leftbot-".concat(_count),
|
|
1157
|
+
element: newLeftTopNode,
|
|
1158
|
+
type: SPECIAL_CORNER_NODE,
|
|
1159
|
+
data: [],
|
|
1160
|
+
title: '',
|
|
1161
|
+
parent: "node-".concat(_count),
|
|
1162
|
+
count: _count
|
|
1163
|
+
};
|
|
1164
|
+
this.nodes["node-righttop-".concat(_count)] = {
|
|
1165
|
+
nodeId: "node-righttop-".concat(_count),
|
|
1166
|
+
previous: "node-".concat(_count),
|
|
1167
|
+
next: "node-rightbot-".concat(_count),
|
|
1168
|
+
element: newRightTopNode,
|
|
1169
|
+
type: SPECIAL_CORNER_NODE,
|
|
1170
|
+
data: [],
|
|
1171
|
+
title: '',
|
|
1172
|
+
parent: "node-".concat(_count),
|
|
1173
|
+
count: _count
|
|
1174
|
+
};
|
|
1175
|
+
this.nodes["node-leftbot-".concat(_count)] = {
|
|
1176
|
+
nodeId: "node-leftbot-".concat(_count),
|
|
1177
|
+
previous: "node-lefttop-".concat(_count),
|
|
1178
|
+
next: "node-end-".concat(_count),
|
|
1179
|
+
element: newLeftBotNode,
|
|
1180
|
+
type: SPECIAL_CORNER_NODE,
|
|
1181
|
+
data: [],
|
|
1182
|
+
title: '',
|
|
1183
|
+
parent: "node-".concat(_count),
|
|
1184
|
+
count: _count
|
|
1185
|
+
};
|
|
1186
|
+
this.nodes["node-rightbot-".concat(_count)] = {
|
|
1187
|
+
nodeId: "node-rightbot-".concat(_count),
|
|
1188
|
+
previous: "node-righttop-".concat(_count),
|
|
1189
|
+
next: "node-end-".concat(_count),
|
|
1190
|
+
element: newRightBotNode,
|
|
1191
|
+
type: SPECIAL_CORNER_NODE,
|
|
1192
|
+
data: [],
|
|
1193
|
+
title: '',
|
|
1194
|
+
parent: "node-".concat(_count),
|
|
1195
|
+
count: _count
|
|
1196
|
+
};
|
|
1197
|
+
nodesCornerList = [lefttopId, leftbotId, righttopId, rightbotId];
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
// branches >= 3
|
|
1201
|
+
let halfBranches = Math.floor(branches / 2);
|
|
1202
|
+
endId = "node-end-".concat(_count);
|
|
1203
|
+
newEndNode = document.createElement('div');
|
|
1204
|
+
newEndNode.setAttribute('id', "node-end-".concat(_count));
|
|
1205
|
+
newEndNode.className = 'fc-item fc-item-draggable fc-item-end-point';
|
|
1206
|
+
newEndNode.style.cssText = 'top: ' + (this.nodes[target].element.offsetTop - _workflow.config.nodeGap + 10) + 'px; left: ' + destinationLeft + 'px;';
|
|
1207
|
+
this.addEndpoints(newEndNode, null, null, endId);
|
|
1208
|
+
this.container.append(newEndNode);
|
|
1209
|
+
this.nodes["node-end-".concat(_count)] = {
|
|
1210
|
+
nodeId: "node-end-".concat(_count),
|
|
1211
|
+
previous: {
|
|
1212
|
+
left: leftbotId,
|
|
1213
|
+
right: rightbotId
|
|
1214
|
+
},
|
|
1215
|
+
next: target,
|
|
1216
|
+
element: newEndNode,
|
|
1217
|
+
type: SPECIAL_END_NODE,
|
|
1218
|
+
data: [],
|
|
1219
|
+
title: '',
|
|
1220
|
+
parent: "node-".concat(_count),
|
|
1221
|
+
count: _count
|
|
1222
|
+
};
|
|
1223
|
+
let equalPostionLeft = null;
|
|
1224
|
+
let equalPostionRight = null;
|
|
1225
|
+
for (let i = 0; i < branches; i++) {
|
|
1226
|
+
let topBranchId = "node-topbranch_".concat(i, "-").concat(_count);
|
|
1227
|
+
let botBranchId = "node-botbranch_".concat(i, "-").concat(_count);
|
|
1228
|
+
let newTopBranchNode = document.createElement('div');
|
|
1229
|
+
let newBotBranchNode = document.createElement('div');
|
|
1230
|
+
let topPos = this.nodes[target].element.offsetTop - _workflow.config.nodeGap;
|
|
1231
|
+
newTopBranchNode.setAttribute('id', topBranchId);
|
|
1232
|
+
newBotBranchNode.setAttribute('id', botBranchId);
|
|
1233
|
+
newTopBranchNode.className = 'fc-item fc-item-draggable fc-item-end-point';
|
|
1234
|
+
newBotBranchNode.className = 'fc-item fc-item-draggable fc-item-end-point';
|
|
1235
|
+
let left;
|
|
1236
|
+
let top;
|
|
1237
|
+
if (branches % 2 === 1 && Math.floor(branches / 2) === i) {
|
|
1238
|
+
left = leftPosNewNode + _workflow.config.nodeWidthDefault / 2;
|
|
1239
|
+
top = topPosNewNode + _workflow.config.nodeSizeDefault;
|
|
1240
|
+
} else if (i < halfBranches) {
|
|
1241
|
+
left = leftPosNewNode + _workflow.config.nodeWidthDefault / 2 - (halfBranches - i) * 180;
|
|
1242
|
+
// if (this.IsMainBranch) {
|
|
1243
|
+
// equalPostionLeft = (leftPosNewNode + config.nodeWidthDefault / 2) - (halfBranches - i) * 180
|
|
1244
|
+
// left = (equalPostionRight && equalPostionRight >= equalPostionLeft) ? equalPostionLeft : ((equalPostionRight / 2))
|
|
1245
|
+
// }
|
|
1246
|
+
top = topPosNewNode + _workflow.config.nodeSizeDefault / 2;
|
|
1247
|
+
} else {
|
|
1248
|
+
left = leftPosNewNode + _workflow.config.nodeWidthDefault / 2 + (i - halfBranches + (branches % 2 ? 0 : 1)) * 180;
|
|
1249
|
+
// if (this.IsMainBranch) {
|
|
1250
|
+
// equalPostionRight = (leftPosNewNode + config.nodeWidthDefault / 2) + (i - halfBranches + (branches % 2 ? 0 : 1)) * 180;
|
|
1251
|
+
// left = equalPostionRight >= equalPostionLeft ? equalPostionRight : equalPostionRight;
|
|
1252
|
+
// }
|
|
1253
|
+
top = topPosNewNode + _workflow.config.nodeSizeDefault / 2;
|
|
1254
|
+
}
|
|
1255
|
+
if (equalPostionRight != null && equalPostionLeft != null) {
|
|
1256
|
+
this.IsMainBranch = false;
|
|
1257
|
+
}
|
|
1258
|
+
newTopBranchNode.style.cssText = 'top: ' + top + 'px; left: ' + left + 'px;';
|
|
1259
|
+
newBotBranchNode.style.cssText = 'top: ' + (this.nodes[target].element.offsetTop - _workflow.config.nodeGap) + 'px; left: ' + left + 'px;';
|
|
1260
|
+
this.container.append(newTopBranchNode);
|
|
1261
|
+
this.container.append(newBotBranchNode);
|
|
1262
|
+
this.addEndpoints(newTopBranchNode, null, null, topBranchId);
|
|
1263
|
+
this.addEndpoints(newBotBranchNode, null, null, botBranchId);
|
|
1264
|
+
this.nodes[topBranchId] = {
|
|
1265
|
+
nodeId: topBranchId,
|
|
1266
|
+
previous: "node-".concat(_count),
|
|
1267
|
+
next: botBranchId,
|
|
1268
|
+
element: newTopBranchNode,
|
|
1269
|
+
type: SPECIAL_CORNER_NODE,
|
|
1270
|
+
data: [],
|
|
1271
|
+
title: '',
|
|
1272
|
+
parent: "node-".concat(_count),
|
|
1273
|
+
count: _count,
|
|
1274
|
+
positionBranch: i
|
|
1275
|
+
};
|
|
1276
|
+
this.nodes[botBranchId] = {
|
|
1277
|
+
nodeId: botBranchId,
|
|
1278
|
+
previous: topBranchId,
|
|
1279
|
+
next: endId,
|
|
1280
|
+
element: newBotBranchNode,
|
|
1281
|
+
type: SPECIAL_CORNER_NODE,
|
|
1282
|
+
data: [],
|
|
1283
|
+
title: '',
|
|
1284
|
+
parent: "node-".concat(_count),
|
|
1285
|
+
count: _count,
|
|
1286
|
+
positionBranch: i
|
|
1287
|
+
};
|
|
1288
|
+
if (branches % 2 === 1 && Math.floor(branches / 2) === i) {
|
|
1289
|
+
this.connectNodes(null, "node-".concat(_count, "-ep-bottom"), "".concat(topBranchId, "-ep-top"));
|
|
1290
|
+
} else if (i < halfBranches) {
|
|
1291
|
+
this.connectNodes(null, "node-".concat(_count, "-ep-left"), "".concat(topBranchId, "-ep-right"));
|
|
1292
|
+
} else {
|
|
1293
|
+
this.connectNodes(null, "node-".concat(_count, "-ep-right"), "".concat(topBranchId, "-ep-left"));
|
|
1294
|
+
}
|
|
1295
|
+
this.connectNodes(['Custom', Object.assign({}, (0, _Designer.overlayPlus)(topBranchId, botBranchId, i))], "".concat(topBranchId, "-ep-bottom"), "".concat(botBranchId, "-ep-top"));
|
|
1296
|
+
this.connectNodes(null, "".concat(botBranchId, "-ep-bottom"), "".concat(endId, "-ep-top"));
|
|
1297
|
+
nodesCornerList.push(topBranchId, botBranchId);
|
|
1298
|
+
}
|
|
1299
|
+
this.connectNodes(['Custom', Object.assign((0, _Designer.overlayPlus)(endId, target, position))], "".concat(endId, "-ep-bottom"), "".concat(target, "-ep-top"));
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
// connect from source to new node
|
|
1303
|
+
// if source has 2 branches
|
|
1304
|
+
if (this.nodes[source].type === SPECIAL_CORNER_NODE) {
|
|
1305
|
+
this.connectNodes(['Custom', Object.assign({}, (0, _Designer.overlayPlus)(source, "node-".concat(_count), position))], "".concat(source, "-ep-bottom"), "".concat(newNodeId, "-ep-top"));
|
|
1306
|
+
} else {
|
|
1307
|
+
this.connectNodes(['Custom', Object.assign({}, (0, _Designer.overlayPlus)(source, "node-".concat(_count), position))], "".concat(source, "-ep-bottom"), "node-".concat(_count, "-ep-top"));
|
|
1308
|
+
}
|
|
1309
|
+
if (item.wrapper) {
|
|
1310
|
+
this.connectNodes(null, "node-".concat(_count, "-ep-left"), "".concat(lefttopId, "-ep-right"), {
|
|
1311
|
+
strokeWidth: 2,
|
|
1312
|
+
stroke: "#1565C0",
|
|
1313
|
+
dashstyle: "2 4"
|
|
1314
|
+
});
|
|
1315
|
+
this.connectNodes(null, "node-".concat(_count, "-ep-right"), "".concat(righttopId, "-ep-left"), {
|
|
1316
|
+
strokeWidth: 2,
|
|
1317
|
+
stroke: "#1565C0",
|
|
1318
|
+
dashstyle: "2 4"
|
|
1319
|
+
});
|
|
1320
|
+
this.connectNodes(null, "".concat(leftbotId, "-ep-right"), "".concat(endId, "-ep-left"), {
|
|
1321
|
+
strokeWidth: 2,
|
|
1322
|
+
stroke: "#1565C0",
|
|
1323
|
+
dashstyle: "2 4"
|
|
1324
|
+
});
|
|
1325
|
+
this.connectNodes(null, "".concat(rightbotId, "-ep-left"), "".concat(endId, "-ep-right"), {
|
|
1326
|
+
strokeWidth: 2,
|
|
1327
|
+
stroke: "#1565C0",
|
|
1328
|
+
dashstyle: "2 4"
|
|
1329
|
+
});
|
|
1330
|
+
this.connectNodes(item.wrapper ? null : ['Custom', Object.assign({}, (0, _Designer.overlayPlus)(lefttopId, leftbotId, 'left'))], "".concat(lefttopId, "-ep-bottom"), "".concat(leftbotId, "-ep-top"), {
|
|
1331
|
+
strokeWidth: 2,
|
|
1332
|
+
stroke: "#1565C0",
|
|
1333
|
+
dashstyle: "2 4"
|
|
1334
|
+
});
|
|
1335
|
+
this.connectNodes(item.wrapper ? null : ['Custom', Object.assign({}, (0, _Designer.overlayPlus)(righttopId, rightbotId, 'right'))], "".concat(righttopId, "-ep-bottom"), "".concat(rightbotId, "-ep-top"), {
|
|
1336
|
+
strokeWidth: 2,
|
|
1337
|
+
stroke: "#1565C0",
|
|
1338
|
+
dashstyle: "2 4"
|
|
1339
|
+
});
|
|
1340
|
+
}
|
|
1341
|
+
if (branches < 1) {
|
|
1342
|
+
if (this.nodes[target].type === SPECIAL_CORNER_NODE) {
|
|
1343
|
+
this.connectNodes(['Custom', Object.assign((0, _Designer.overlayPlus)("node-".concat(_count), target, position))], "node-".concat(_count, "-ep-bottom"), "".concat(target, "-ep-top"));
|
|
1344
|
+
} else {
|
|
1345
|
+
this.connectNodes(['Custom', (0, _Designer.overlayPlus)("node-".concat(_count), target, position)], "node-".concat(_count, "-ep-bottom"), "".concat(target, "-ep-top"));
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
//debugger
|
|
1350
|
+
// this.firstInstance.draggable(this.paletteBoard);
|
|
1351
|
+
|
|
1352
|
+
// add next previous property to new-node data
|
|
1353
|
+
if (position && typeof this.nodes[source].next === 'object' && this.nodes[source].next) {
|
|
1354
|
+
this.nodes[source].next[position] = "node-".concat(_count);
|
|
1355
|
+
} else {
|
|
1356
|
+
this.nodes[source].next = "node-".concat(_count);
|
|
1357
|
+
}
|
|
1358
|
+
// ////////console.log('source ', position, this.nodes[source].next)
|
|
1359
|
+
if (position && typeof this.nodes[target].previous === 'object' && this.nodes[target].previous) {
|
|
1360
|
+
this.nodes[target].previous[position] = newEndNode ? "node-end-".concat(_count) : "node-".concat(_count);
|
|
1361
|
+
} else {
|
|
1362
|
+
this.nodes[target].previous = newEndNode ? "node-end-".concat(_count) : "node-".concat(_count);
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
// let datatype = JSON.parse(node.getAttribute('datatype'));
|
|
1366
|
+
let newObject = {};
|
|
1367
|
+
//////console.log('1806 ', config.taskType[datatype.parent][datatype.type])
|
|
1368
|
+
|
|
1369
|
+
let propertiesClone;
|
|
1370
|
+
if (copyTask) {
|
|
1371
|
+
if (copyTask.configuration.properties instanceof Array) {
|
|
1372
|
+
propertiesClone = [];
|
|
1373
|
+
copyTask.configuration.properties.forEach(prop => {
|
|
1374
|
+
propertiesClone.push(Object.assign({}, prop));
|
|
1375
|
+
});
|
|
1376
|
+
} else {
|
|
1377
|
+
propertiesClone = Object.assign({}, copyTask.configuration.properties);
|
|
1378
|
+
}
|
|
1379
|
+
} else {
|
|
1380
|
+
console.log(this.nodes);
|
|
1381
|
+
console.log(_workflow.config);
|
|
1382
|
+
console.log(_jsplumb.jsPlumb.getConnections());
|
|
1383
|
+
|
|
1384
|
+
// comment by anup
|
|
1385
|
+
//propertiesClone = item.schema.type === 'array' ? [] : {};
|
|
1386
|
+
//Add by anup
|
|
1387
|
+
propertiesClone = {};
|
|
1388
|
+
if (item.defaultFormData) {
|
|
1389
|
+
propertiesClone = item.defaultFormData;
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
this.nodes["node-".concat(_count)] = {
|
|
1393
|
+
number: _count,
|
|
1394
|
+
next: '',
|
|
1395
|
+
previous: source,
|
|
1396
|
+
next: '',
|
|
1397
|
+
actionConfig: copyTask ? copyTask.actionConfig : {},
|
|
1398
|
+
configuration: {
|
|
1399
|
+
actionID: "node-".concat(_count),
|
|
1400
|
+
actionTitle: item.title,
|
|
1401
|
+
actionName: copyTask ? copyTask.configuration.actionName : item.name,
|
|
1402
|
+
actionImage: item.actionImage,
|
|
1403
|
+
properties: propertiesClone,
|
|
1404
|
+
nodeType: item.nodeType,
|
|
1405
|
+
isDisabled: copyTask ? copyTask.configuration.isDisabled : false,
|
|
1406
|
+
isHidden: false
|
|
1407
|
+
},
|
|
1408
|
+
branches: null,
|
|
1409
|
+
wrapper: item.wrapper,
|
|
1410
|
+
count: _count,
|
|
1411
|
+
nodeId: "node-".concat(_count),
|
|
1412
|
+
element: newNode,
|
|
1413
|
+
type: datatype.type,
|
|
1414
|
+
nodeType: item.nodeType,
|
|
1415
|
+
branch: branches,
|
|
1416
|
+
// schema: copyTask && copyTask.schema ? Object.assign({}, copyTask.schema) : item.schema, //comment by anup
|
|
1417
|
+
// uiSchema: copyTask && copyTask.uiSchema ? Object.assign({}, copyTask.uiSchema) : item.uiSchema, //comment by anup
|
|
1418
|
+
onBranch: position,
|
|
1419
|
+
parent: '',
|
|
1420
|
+
taskType: item.type,
|
|
1421
|
+
datatype: datatype
|
|
1422
|
+
// code: config.taskType[datatype.parent][datatype.type].code
|
|
1423
|
+
};
|
|
1424
|
+
|
|
1425
|
+
if (this.nodes[newNodeId].configuration.isDisabled) {
|
|
1426
|
+
this.nodes[newNodeId].element.classList.add('is-disabled');
|
|
1427
|
+
}
|
|
1428
|
+
if (branches > 0) {
|
|
1429
|
+
this.nodes[newNodeId].next = {};
|
|
1430
|
+
this.nodes[endId].previous = {};
|
|
1431
|
+
this.nodes[newNodeId].branches = [];
|
|
1432
|
+
for (var i = 0; i < branches; i++) {
|
|
1433
|
+
this.nodes[newNodeId].next[i] = "node-topbranch_".concat(i, "-").concat(_count);
|
|
1434
|
+
this.nodes[endId].previous[i] = "node-botbranch_".concat(i, "-").concat(_count);
|
|
1435
|
+
this.nodes["node-".concat(_count)][i] = ["node-topbranch_".concat(i, "-").concat(_count), "node-botbranch_".concat(i, "-").concat(_count)];
|
|
1436
|
+
this.nodes[newNodeId].branches[i] = Object.assign({}, item.branches[i], {
|
|
1437
|
+
actions: []
|
|
1438
|
+
});
|
|
1439
|
+
}
|
|
1440
|
+
} else {
|
|
1441
|
+
this.nodes[newNodeId].next = target;
|
|
1442
|
+
}
|
|
1443
|
+
if (this.nodes[source].parent) {
|
|
1444
|
+
////////console.log(this.nodes[source].parent, this.nodes[source]);
|
|
1445
|
+
if (this.nodes[source].type === SPECIAL_END_NODE) {
|
|
1446
|
+
parent = this.nodes[this.nodes[source].parent].parent;
|
|
1447
|
+
} else {
|
|
1448
|
+
parent = this.nodes[source].parent;
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
this.nodes["node-".concat(_count)].parent = parent;
|
|
1452
|
+
let fields = item.fields;
|
|
1453
|
+
if (branches >= 1) {
|
|
1454
|
+
let currentNestedLevel = 0;
|
|
1455
|
+
if (parent) {
|
|
1456
|
+
currentNestedLevel = this.nodes[parent].nestedLevel + 1;
|
|
1457
|
+
}
|
|
1458
|
+
this.nodes["node-".concat(_count)].nestedLevel = currentNestedLevel;
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
// add this node id to parent left, right array
|
|
1462
|
+
if (parent) {
|
|
1463
|
+
if (branches >= 1 && position) {
|
|
1464
|
+
this.nodes[parent][position] = [...this.nodes[parent][position], "node-".concat(_count), "node-end-".concat(_count), ...nodesCornerList];
|
|
1465
|
+
} else if (position) {
|
|
1466
|
+
////////console.log('===) add new node to parent ', parent, position, `node-${_count}`)
|
|
1467
|
+
if (this.nodes[parent][position]) {
|
|
1468
|
+
this.nodes[parent][position].push("node-".concat(_count));
|
|
1469
|
+
} else {
|
|
1470
|
+
this.nodes[parent][position] = ["node-".concat(_count)];
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
let cP = this.nodes[parent].parent;
|
|
1474
|
+
while (cP) {
|
|
1475
|
+
if (this.nodes[cP].branch >= 1) {
|
|
1476
|
+
let positionBranch;
|
|
1477
|
+
for (var i = 0; i < this.nodes[cP].branch; i++) {
|
|
1478
|
+
if (this.nodes[cP][i].includes(parent)) positionBranch = i;
|
|
1479
|
+
}
|
|
1480
|
+
if (branches >= 1) {
|
|
1481
|
+
this.nodes[cP][positionBranch] = [...this.nodes[cP][positionBranch], "node-".concat(_count), "node-end-".concat(_count), ...nodesCornerList];
|
|
1482
|
+
} else {
|
|
1483
|
+
this.nodes[cP][positionBranch].push("node-".concat(_count));
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
////////console.log(this.nodes[cP])
|
|
1487
|
+
cP = this.nodes[cP].parent;
|
|
1488
|
+
// ////////console.log('2605 cP ', cP)
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
if (branches >= 1 && this.nodes["node-".concat(_count)].parent) self.expandFlowchart(this.nodes["node-".concat(_count)].parent, "node-".concat(_count), position);
|
|
1493
|
+
this.firstInstance.repaintEverything();
|
|
1494
|
+
////console.log(this.nodes)
|
|
1495
|
+
// increase _count variable
|
|
1496
|
+
_count++;
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
////console.log(this.nodes[this.curCopyTask], this.curCopyTask)
|
|
1500
|
+
|
|
1501
|
+
handleClickOverlay(overlay, e, i) {
|
|
1502
|
+
if (e.target.className.indexOf('jtk-overlay') >= 0) return;
|
|
1503
|
+
if (!this.curCopyTask) return;
|
|
1504
|
+
////console.log('handleClickOverlay ', overlay, e, i)
|
|
1505
|
+
this.currentFocusOverlay = overlay;
|
|
1506
|
+
if (!this.nodes[this.curCopyTask].branch) {
|
|
1507
|
+
this.addTaskToDropZone(overlay.canvas, null, this.nodes[this.curCopyTask].datatype, this.nodes[this.curCopyTask]);
|
|
1508
|
+
// renameTask(`node-${_count-1}`, self.nodes, self.nodes[this.curCopyTask].displayName);
|
|
1509
|
+
this.curCopyTask = null;
|
|
1510
|
+
} else {
|
|
1511
|
+
let parent = this.nodes[this.curCopyTask];
|
|
1512
|
+
this.addBranchTaskToPlaceHolder(this.curCopyTask, overlay.canvas);
|
|
1513
|
+
}
|
|
1514
|
+
this.curCopyTask = null;
|
|
1515
|
+
}
|
|
1516
|
+
moveDownFlowchart(item, type, position, branches) {
|
|
1517
|
+
if (!this.nodes[item]) return;
|
|
1518
|
+
// this.nodes[item].element.style.top = `${this.nodes[item].element.offsetTop + _gap}px`;
|
|
1519
|
+
////console.log('moveDownFlowchart', type, item, this.nodes[item].previous, this.nodes)
|
|
1520
|
+
let currentGap = this.nodes[item].element.offsetTop - this.nodes[this.nodes[item].previous].element.offsetTop - this.nodes[this.nodes[item].previous].element.offsetHeight;
|
|
1521
|
+
let gapPlus;
|
|
1522
|
+
let self = this;
|
|
1523
|
+
if (branches >= 2) {
|
|
1524
|
+
gapPlus = _workflow.config.nodeGap * 3 + _workflow.config.nodeSizeDefault / 2;
|
|
1525
|
+
} else if (branches === 1) {
|
|
1526
|
+
gapPlus = _workflow.config.nodeGap * 3 + _workflow.config.nodeSizeDefault;
|
|
1527
|
+
} else {
|
|
1528
|
+
gapPlus = _workflow.config.nodeGap * 2 + _workflow.config.nodeSizeDefault;
|
|
1529
|
+
}
|
|
1530
|
+
//////console.log('0806 moveDownFlowchart ', branches, item, this.nodes[item], currentGap, gapPlus)
|
|
1531
|
+
gapPlus = gapPlus - currentGap;
|
|
1532
|
+
while (item) {
|
|
1533
|
+
////console.log('08/06 ', item, gapPlus)
|
|
1534
|
+
this.nodes[item].element.style.top = "".concat(this.nodes[item].element.offsetTop + gapPlus, "px");
|
|
1535
|
+
let itemP = item.split('-');
|
|
1536
|
+
let corner;
|
|
1537
|
+
// switch (itemP[1]) {
|
|
1538
|
+
// case 'leftbot':
|
|
1539
|
+
// corner = 'rightbot';
|
|
1540
|
+
// break;
|
|
1541
|
+
// case 'lefttop':
|
|
1542
|
+
// corner = 'righttop';
|
|
1543
|
+
// break;
|
|
1544
|
+
// case 'righttop':
|
|
1545
|
+
// corner = 'lefttop';
|
|
1546
|
+
// break;
|
|
1547
|
+
// case 'rightbot':
|
|
1548
|
+
// corner = 'leftbot';
|
|
1549
|
+
// break;
|
|
1550
|
+
// default:
|
|
1551
|
+
// break;
|
|
1552
|
+
// }
|
|
1553
|
+
//
|
|
1554
|
+
// // ////////console.log('moveDownFlowchart ', item, itemP, corner)
|
|
1555
|
+
// if (['rightbot', 'righttop', 'lefttop', 'leftbot'].includes(itemP[1])) {
|
|
1556
|
+
// this.nodes[`${itemP[0]}-${corner}-${itemP[2]}`].element.style.top = `${this.nodes[`${itemP[0]}-${corner}-${itemP[2]}`].element.offsetTop + gapPlus}px`;
|
|
1557
|
+
// }
|
|
1558
|
+
if (itemP[1].indexOf('botbranch') >= 0) {
|
|
1559
|
+
let c = this.nodes[item].count;
|
|
1560
|
+
for (var i = 0; i < this.nodes[this.nodes[item].parent].branch; i++) {
|
|
1561
|
+
if (item === "node-botbranch_".concat(i, "-").concat(c)) continue;
|
|
1562
|
+
////////console.log('0806 move down ', `node-botbranch_${i}-${c}`, `${this.nodes[`node-botbranch_${i}-${c}`].element.style.offsetTop + gapPlus}px`)
|
|
1563
|
+
this.nodes["node-botbranch_".concat(i, "-").concat(c)].element.style.top = "".concat(this.nodes["node-botbranch_".concat(i, "-").concat(c)].element.offsetTop + gapPlus, "px");
|
|
1564
|
+
////////console.log('0806 move down ', this.nodes[`node-botbranch_${i}-${c}`].element.style.offsetTop)
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
item = this.nodes[item].next;
|
|
1568
|
+
continue;
|
|
1569
|
+
}
|
|
1570
|
+
// ////////console.log(this.nodes[item], position)
|
|
1571
|
+
// if (typeof this.nodes[item].next === 'object' && this.nodes[item].next && !position) {
|
|
1572
|
+
// self.nodes[item].left.forEach(child => {
|
|
1573
|
+
// self.nodes[child].element.style.top = `${this.nodes[child].element.offsetTop + gapPlus}px`;
|
|
1574
|
+
// });
|
|
1575
|
+
// self.nodes[item].right.forEach(child => {
|
|
1576
|
+
// self.nodes[child].element.style.top = `${this.nodes[child].element.offsetTop + gapPlus}px`;
|
|
1577
|
+
// });
|
|
1578
|
+
// item = `${itemP[0]}-end-${itemP[1]}`;
|
|
1579
|
+
// }
|
|
1580
|
+
////////console.log('======> ', item, self.nodes[item], `node-leftbot-${self.nodes[item].count}`, item, self.nodes)
|
|
1581
|
+
if (this.nodes[item].type === SPECIAL_END_NODE && this.nodes[item].parent && this.nodes[this.nodes[item].parent].wrapper) {
|
|
1582
|
+
let itemLeft = "node-leftbot-".concat(self.nodes[item].count);
|
|
1583
|
+
let itemRight = "node-rightbot-".concat(self.nodes[item].count);
|
|
1584
|
+
this.nodes[itemLeft].element.style.top = "".concat(this.nodes[itemLeft].element.offsetTop + gapPlus, "px");
|
|
1585
|
+
this.nodes[itemRight].element.style.top = "".concat(this.nodes[itemRight].element.offsetTop + gapPlus, "px");
|
|
1586
|
+
}
|
|
1587
|
+
if (this.nodes[item].wrapper) {
|
|
1588
|
+
//////console.log('moveDownFlowchart ', this.nodes[item])
|
|
1589
|
+
this.nodes["node-lefttop-".concat(this.nodes[item].count)].element.style.top = this.nodes["node-lefttop-".concat(this.nodes[item].count)].element.offsetTop + gapPlus + 'px';
|
|
1590
|
+
this.nodes["node-leftbot-".concat(this.nodes[item].count)].element.style.top = this.nodes["node-leftbot-".concat(this.nodes[item].count)].element.offsetTop + gapPlus + 'px';
|
|
1591
|
+
this.nodes["node-righttop-".concat(this.nodes[item].count)].element.style.top = this.nodes["node-righttop-".concat(this.nodes[item].count)].element.offsetTop + gapPlus + 'px';
|
|
1592
|
+
this.nodes["node-rightbot-".concat(this.nodes[item].count)].element.style.top = this.nodes["node-rightbot-".concat(this.nodes[item].count)].element.offsetTop + gapPlus + 'px';
|
|
1593
|
+
}
|
|
1594
|
+
if (this.nodes[item].branch >= 1) {
|
|
1595
|
+
for (var i = 0; i < this.nodes[item].branch; i++) {
|
|
1596
|
+
this.nodes[item][i].forEach(n => {
|
|
1597
|
+
this.nodes[n].element.style.top = "".concat(this.nodes[n].element.offsetTop + gapPlus, "px");
|
|
1598
|
+
});
|
|
1599
|
+
}
|
|
1600
|
+
this.nodes["node-end-".concat(this.nodes[item].count)].element.style.top = "".concat(this.nodes["node-end-".concat(this.nodes[item].count)].element.offsetTop + gapPlus, "px");
|
|
1601
|
+
item = "node-end-".concat(this.nodes[item].count);
|
|
1602
|
+
}
|
|
1603
|
+
if (!this.nodes[item].branch) {
|
|
1604
|
+
//////console.log(item, this.nodes[item])
|
|
1605
|
+
item = this.nodes[item].next;
|
|
1606
|
+
}
|
|
1607
|
+
////////console.log(item)
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1611
|
+
narrowFlowchart(deletedTask) {
|
|
1612
|
+
let self = this;
|
|
1613
|
+
let parent = this.nodes[deletedTask].parent;
|
|
1614
|
+
let child = deletedTask;
|
|
1615
|
+
while (parent) {
|
|
1616
|
+
let colLeft = Number.MAX_SAFE_INTEGER;
|
|
1617
|
+
let colRight = Number.MIN_SAFE_INTEGER;
|
|
1618
|
+
let deletedTaskOnBranch = Number(this.nodes[child].onBranch);
|
|
1619
|
+
let rightPosOfPre = Number.MIN_SAFE_INTEGER;
|
|
1620
|
+
let leftPosOfNext = Number.MAX_SAFE_INTEGER;
|
|
1621
|
+
let gapLeft, gapRight;
|
|
1622
|
+
let narrowLeft, narrowRight;
|
|
1623
|
+
let parentHalfBranch = Math.floor(this.nodes[parent].branch / 2);
|
|
1624
|
+
let centerPosition = self.nodes[parent].element.offsetLeft + self.nodes[parent].element.offsetWidth / 2;
|
|
1625
|
+
////console.log('2606', parent, child)
|
|
1626
|
+
this.nodes[parent][deletedTaskOnBranch].forEach((item, i) => {
|
|
1627
|
+
////console.log('asdfsadfas', item)
|
|
1628
|
+
if (item === deletedTask || this.nodes[item].parent === deletedTask) return;
|
|
1629
|
+
////console.log('=====> ', item)
|
|
1630
|
+
let l = this.nodes[item].element.offsetLeft;
|
|
1631
|
+
// ////console.log(colLeft, l)
|
|
1632
|
+
if (colLeft > l) colLeft = l;
|
|
1633
|
+
let r = this.nodes[item].element.offsetLeft + this.nodes[item].element.offsetWidth;
|
|
1634
|
+
if (colRight < r) colRight = r;
|
|
1635
|
+
});
|
|
1636
|
+
|
|
1637
|
+
// right position of Previous branch
|
|
1638
|
+
if (deletedTaskOnBranch == 0) rightPosOfPre = colLeft;else {
|
|
1639
|
+
this.nodes[parent][deletedTaskOnBranch - 1].forEach((item, i) => {
|
|
1640
|
+
let r = this.nodes[item].element.offsetLeft + this.nodes[item].element.offsetWidth;
|
|
1641
|
+
if (rightPosOfPre < r) rightPosOfPre = r;
|
|
1642
|
+
});
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1645
|
+
// left position of next branch
|
|
1646
|
+
if (deletedTaskOnBranch + 1 == this.nodes[parent].branch) leftPosOfNext = colRight;else {
|
|
1647
|
+
this.nodes[parent][deletedTaskOnBranch + 1].forEach((item, i) => {
|
|
1648
|
+
let l = this.nodes[item].element.offsetLeft;
|
|
1649
|
+
if (leftPosOfNext > l) leftPosOfNext = l;
|
|
1650
|
+
});
|
|
1651
|
+
}
|
|
1652
|
+
gapLeft = colLeft - rightPosOfPre;
|
|
1653
|
+
gapRight = leftPosOfNext - colRight;
|
|
1654
|
+
if (gapLeft > 180) narrowLeft = gapLeft - 180;
|
|
1655
|
+
if (gapRight > 180) narrowRight = gapRight - 180;
|
|
1656
|
+
if (!narrowLeft && !narrowRight) {
|
|
1657
|
+
child = parent;
|
|
1658
|
+
parent = this.nodes[child].parent;
|
|
1659
|
+
return;
|
|
1660
|
+
}
|
|
1661
|
+
if (deletedTaskOnBranch === parentHalfBranch && self.nodes[parent].branch % 2) {
|
|
1662
|
+
if (narrowLeft) {
|
|
1663
|
+
for (var i = 0; i < parentHalfBranch; i++) {
|
|
1664
|
+
this.nodes[parent][i].forEach((nodeId, j) => {
|
|
1665
|
+
self.nodes[nodeId].element.style.left = self.nodes[nodeId].element.offsetLeft + narrowLeft + 'px';
|
|
1666
|
+
});
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
if (narrowRight) {
|
|
1670
|
+
for (var i = parentHalfBranch + 1; i < self.nodes[parent].branch; i++) {
|
|
1671
|
+
this.nodes[parent][i].forEach((nodeId, j) => {
|
|
1672
|
+
self.nodes[nodeId].element.style.left = self.nodes[nodeId].element.offsetLeft - narrowRight + 'px';
|
|
1673
|
+
});
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
} else if (deletedTaskOnBranch < parentHalfBranch) {
|
|
1677
|
+
if (narrowLeft) {
|
|
1678
|
+
for (var i = 0; i < deletedTaskOnBranch; i++) {
|
|
1679
|
+
this.nodes[parent][i].forEach((nodeId, j) => {
|
|
1680
|
+
self.nodes[nodeId].element.style.left = self.nodes[nodeId].element.offsetLeft + narrowLeft + 'px';
|
|
1681
|
+
});
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
if (narrowRight) {
|
|
1685
|
+
for (var i = 0; i <= deletedTaskOnBranch; i++) {
|
|
1686
|
+
this.nodes[parent][i].forEach((nodeId, j) => {
|
|
1687
|
+
// depend on gap between this element and center position
|
|
1688
|
+
let gap = centerPosition - colRight;
|
|
1689
|
+
////console.log('=====> nodeId', nodeId, gap, deletedTaskOnBranch + 1 === parentHalfBranch, (deletedTaskOnBranch + 1 === parentHalfBranch) ? gap - 180 : narrowRight)
|
|
1690
|
+
self.nodes[nodeId].element.style.left = self.nodes[nodeId].element.offsetLeft + (deletedTaskOnBranch + 1 === parentHalfBranch ? gap - 180 : narrowRight) + 'px';
|
|
1691
|
+
});
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
} else if (deletedTaskOnBranch >= parentHalfBranch) {
|
|
1695
|
+
if (narrowLeft) {
|
|
1696
|
+
for (var i = deletedTaskOnBranch; i < this.nodes[parent].branch; i++) {
|
|
1697
|
+
////console.log(this.nodes[parent][i])
|
|
1698
|
+
// depend on gap between this element and center position
|
|
1699
|
+
let gap = colLeft - centerPosition;
|
|
1700
|
+
this.nodes[parent][i].forEach((nodeId, j) => {
|
|
1701
|
+
self.nodes[nodeId].element.style.left = self.nodes[nodeId].element.offsetLeft - (deletedTaskOnBranch === parentHalfBranch ? gap - 180 : narrowLeft) + 'px';
|
|
1702
|
+
});
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
if (narrowRight) {
|
|
1706
|
+
for (var i = deletedTaskOnBranch + 1; i < this.nodes[parent].branch; i++) {
|
|
1707
|
+
this.nodes[parent][i].forEach((nodeId, j) => {
|
|
1708
|
+
self.nodes[nodeId].element.style.left = self.nodes[nodeId].element.offsetLeft - narrowRight + 'px';
|
|
1709
|
+
});
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
child = parent;
|
|
1714
|
+
parent = this.nodes[child].parent;
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
expandFlowchart(item, childItem, position) {
|
|
1718
|
+
let self = this;
|
|
1719
|
+
let count = 1;
|
|
1720
|
+
while (item) {
|
|
1721
|
+
let childCenter = this.nodes["node-end-".concat(this.nodes[childItem].count)].element.offsetLeft;
|
|
1722
|
+
let self = this;
|
|
1723
|
+
let childColumns = self.nodes[childItem].branch;
|
|
1724
|
+
let childLeftColumns = Number.MAX_SAFE_INTEGER;
|
|
1725
|
+
let childRightColumns = Number.MIN_SAFE_INTEGER;
|
|
1726
|
+
this.nodes[childItem][0].forEach(nodeId => {
|
|
1727
|
+
if (childLeftColumns > self.nodes[nodeId].element.offsetLeft) childLeftColumns = self.nodes[nodeId].element.offsetLeft;
|
|
1728
|
+
});
|
|
1729
|
+
this.nodes[childItem][this.nodes[childItem].branch - 1].forEach(nodeId => {
|
|
1730
|
+
if (childRightColumns < self.nodes[nodeId].element.offsetLeft + self.nodes[nodeId].element.offsetWidth) {
|
|
1731
|
+
childRightColumns = self.nodes[nodeId].element.offsetLeft + self.nodes[nodeId].element.offsetWidth;
|
|
1732
|
+
}
|
|
1733
|
+
});
|
|
1734
|
+
childLeftColumns = (childCenter - childLeftColumns) / 180;
|
|
1735
|
+
childRightColumns = (childRightColumns - childCenter) / 180;
|
|
1736
|
+
let childOnBranch;
|
|
1737
|
+
let childHalfColumn = Math.floor(childColumns / 2);
|
|
1738
|
+
for (var i = 0; i < self.nodes[item].branch; i++) {
|
|
1739
|
+
if (self.nodes[item][i].includes(childItem)) childOnBranch = i;
|
|
1740
|
+
}
|
|
1741
|
+
let parentHalfBranch = Math.floor(self.nodes[item].branch / 2);
|
|
1742
|
+
let leftGap;
|
|
1743
|
+
let rightGap;
|
|
1744
|
+
// calculate expect rightgap
|
|
1745
|
+
let leftColumnsNextBranch = Number.MAX_SAFE_INTEGER;
|
|
1746
|
+
if (childOnBranch + 1 === self.nodes[item].branch) {
|
|
1747
|
+
leftColumnsNextBranch = 0;
|
|
1748
|
+
} else {
|
|
1749
|
+
let centerNextBranch = self.nodes["node-topbranch_".concat(childOnBranch + 1, "-").concat(self.nodes[item].count)].element.offsetLeft;
|
|
1750
|
+
this.nodes[item][childOnBranch + 1].forEach(nodeId => {
|
|
1751
|
+
if (leftColumnsNextBranch > self.nodes[nodeId].element.offsetLeft) leftColumnsNextBranch = self.nodes[nodeId].element.offsetLeft;
|
|
1752
|
+
});
|
|
1753
|
+
leftColumnsNextBranch = (centerNextBranch - leftColumnsNextBranch) / 180;
|
|
1754
|
+
}
|
|
1755
|
+
// end calculate expect rightgap
|
|
1756
|
+
// calculate expect leftgap
|
|
1757
|
+
let rightColumnsPreBranch = Number.MIN_SAFE_INTEGER;
|
|
1758
|
+
if (childOnBranch === 0) {
|
|
1759
|
+
rightColumnsPreBranch = 0;
|
|
1760
|
+
} else {
|
|
1761
|
+
let centerPreBranch = self.nodes["node-topbranch_".concat(childOnBranch - 1, "-").concat(self.nodes[item].count)].element.offsetLeft;
|
|
1762
|
+
this.nodes[item][childOnBranch - 1].forEach(nodeId => {
|
|
1763
|
+
if (rightColumnsPreBranch < self.nodes[nodeId].element.offsetLeft + self.nodes[nodeId].element.offsetWidth) {
|
|
1764
|
+
rightColumnsPreBranch = self.nodes[nodeId].element.offsetLeft + self.nodes[nodeId].element.offsetWidth;
|
|
1765
|
+
}
|
|
1766
|
+
});
|
|
1767
|
+
rightColumnsPreBranch = (rightColumnsPreBranch - centerPreBranch) / 180;
|
|
1768
|
+
}
|
|
1769
|
+
let expectLeftGap = (childLeftColumns + rightColumnsPreBranch + 1) * 180;
|
|
1770
|
+
let expectRightGap = (childRightColumns + leftColumnsNextBranch + 1) * 180;
|
|
1771
|
+
if (childOnBranch === 0) leftGap = expectLeftGap + 1;else {
|
|
1772
|
+
leftGap = this.nodes["node-topbranch_".concat(childOnBranch, "-").concat(this.nodes[item].count)].element.offsetLeft - this.nodes["node-topbranch_".concat(childOnBranch - 1, "-").concat(this.nodes[item].count)].element.offsetLeft;
|
|
1773
|
+
}
|
|
1774
|
+
if (childOnBranch === self.nodes[item].branch - 1) {
|
|
1775
|
+
rightGap = expectRightGap + 1;
|
|
1776
|
+
} else {
|
|
1777
|
+
rightGap = -this.nodes["node-topbranch_".concat(childOnBranch, "-").concat(this.nodes[item].count)].element.offsetLeft + this.nodes["node-topbranch_".concat(childOnBranch + 1, "-").concat(this.nodes[item].count)].element.offsetLeft;
|
|
1778
|
+
}
|
|
1779
|
+
if (childOnBranch === parentHalfBranch && self.nodes[item].branch % 2) {
|
|
1780
|
+
if (leftGap <= expectLeftGap) {
|
|
1781
|
+
for (var i = 0; i < parentHalfBranch; i++) {
|
|
1782
|
+
this.nodes[item][i].forEach((nodeId, j) => {
|
|
1783
|
+
this.nodes[nodeId].element.style.left = this.nodes[nodeId].element.offsetLeft - (expectLeftGap - leftGap) + 'px';
|
|
1784
|
+
});
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
for (var i = parentHalfBranch + 1; i < self.nodes[item].branch; i++) {
|
|
1788
|
+
this.nodes[item][i].forEach((nodeId, j) => {
|
|
1789
|
+
self.nodes[nodeId].element.style.left = self.nodes[nodeId].element.offsetLeft + (expectRightGap - rightGap) + 'px';
|
|
1790
|
+
});
|
|
1791
|
+
}
|
|
1792
|
+
} else if (childOnBranch < parentHalfBranch) {
|
|
1793
|
+
if (rightGap <= expectRightGap) {
|
|
1794
|
+
for (var i = 0; i <= childOnBranch; i++) {
|
|
1795
|
+
this.nodes[item][i].forEach((nodeId, j) => {
|
|
1796
|
+
self.nodes[nodeId].element.style.left = self.nodes[nodeId].element.offsetLeft - (expectRightGap - rightGap) + 'px';
|
|
1797
|
+
});
|
|
1798
|
+
}
|
|
1799
|
+
}
|
|
1800
|
+
if (leftGap <= expectLeftGap) {
|
|
1801
|
+
for (var i = 0; i < childOnBranch; i++) {
|
|
1802
|
+
this.nodes[item][i].forEach((nodeId, j) => {
|
|
1803
|
+
self.nodes[nodeId].element.style.left = self.nodes[nodeId].element.offsetLeft - (expectLeftGap - leftGap) + 'px';
|
|
1804
|
+
});
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
} else if (childOnBranch >= parentHalfBranch) {
|
|
1808
|
+
if (leftGap <= expectLeftGap) {
|
|
1809
|
+
for (var i = childOnBranch; i < this.nodes[item].branch; i++) {
|
|
1810
|
+
this.nodes[item][i].forEach((nodeId, j) => {
|
|
1811
|
+
////console.log('====> bug ', nodeId)
|
|
1812
|
+
self.nodes[nodeId].element.style.left = self.nodes[nodeId].element.offsetLeft + (expectLeftGap - leftGap) + 'px';
|
|
1813
|
+
});
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1816
|
+
if (leftGap <= expectLeftGap) {
|
|
1817
|
+
for (var i = childOnBranch + 1; i < this.nodes[item].branch; i++) {
|
|
1818
|
+
this.nodes[item][i].forEach((nodeId, j) => {
|
|
1819
|
+
self.nodes[nodeId].element.style.left = self.nodes[nodeId].element.offsetLeft + (expectRightGap - rightGap) + 'px';
|
|
1820
|
+
});
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
if (this.nodes[item].wrapper) {
|
|
1825
|
+
let itemp = item.split('-');
|
|
1826
|
+
let endItem = "".concat(itemp[0], "-end-").concat(itemp[1]);
|
|
1827
|
+
let width = 0;
|
|
1828
|
+
let cornerPosition = (0, _Designer.getWidthOfGroup)(self.nodes, item);
|
|
1829
|
+
if (cornerPosition.left !== false) {
|
|
1830
|
+
self.nodes["node-lefttop-".concat(self.nodes[item].count)].element.style.left = "".concat(cornerPosition.left - 15, "px");
|
|
1831
|
+
self.nodes["node-leftbot-".concat(self.nodes[item].count)].element.style.left = "".concat(cornerPosition.left - 15, "px");
|
|
1832
|
+
}
|
|
1833
|
+
if (cornerPosition.right !== false) {
|
|
1834
|
+
self.nodes["node-righttop-".concat(self.nodes[item].count)].element.style.left = "".concat(cornerPosition.right + 15, "px");
|
|
1835
|
+
self.nodes["node-rightbot-".concat(self.nodes[item].count)].element.style.left = "".concat(cornerPosition.right + 15, "px");
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1838
|
+
childItem = item;
|
|
1839
|
+
item = this.nodes[item].parent;
|
|
1840
|
+
count++;
|
|
1841
|
+
}
|
|
1842
|
+
}
|
|
1843
|
+
hoverTaskAction(e) {}
|
|
1844
|
+
flowchartToJson() {
|
|
1845
|
+
let itemId = this.nodes[NODE_START].next;
|
|
1846
|
+
let data = [];
|
|
1847
|
+
let text = '[\r\n';
|
|
1848
|
+
let self = this;
|
|
1849
|
+
let jsonData = {
|
|
1850
|
+
"workflowName": "",
|
|
1851
|
+
"workflowDescription": "",
|
|
1852
|
+
"workflowType": "",
|
|
1853
|
+
"isPublished": 0,
|
|
1854
|
+
"definition": {
|
|
1855
|
+
"variables": [],
|
|
1856
|
+
"actions": [],
|
|
1857
|
+
"settings": {}
|
|
1858
|
+
},
|
|
1859
|
+
"createdTime": "",
|
|
1860
|
+
"createdBy": "",
|
|
1861
|
+
"modifiedTime": "",
|
|
1862
|
+
"modifiedBy": ""
|
|
1863
|
+
};
|
|
1864
|
+
// if (this.importData) {
|
|
1865
|
+
// jsonData = Object.assign({}, this.importData, {
|
|
1866
|
+
// workflowDefinition: {
|
|
1867
|
+
// state: { modified: false },
|
|
1868
|
+
// actions: [],
|
|
1869
|
+
// settings: {}
|
|
1870
|
+
// }
|
|
1871
|
+
// })
|
|
1872
|
+
// }
|
|
1873
|
+
while (itemId && itemId !== NODE_END) {
|
|
1874
|
+
//////console.log(itemId, this.nodes[itemId])
|
|
1875
|
+
if (this.nodes[itemId].type === SPECIAL_END_NODE) {
|
|
1876
|
+
itemId = this.nodes[itemId].next;
|
|
1877
|
+
continue;
|
|
1878
|
+
}
|
|
1879
|
+
if (this.nodes[itemId].type === 'set_variables') {
|
|
1880
|
+
//console.log('getTaskData call')
|
|
1881
|
+
jsonData.definition.actions.push((0, _Designer.getTaskData)(this.nodes[itemId], this.nodes));
|
|
1882
|
+
} else if (this.nodes[itemId].branch >= 1) {
|
|
1883
|
+
let data = self.getDataBranchNode(itemId);
|
|
1884
|
+
//console.log('0207 ---------> ', data)
|
|
1885
|
+
// text+= `${data},\r\n`;
|
|
1886
|
+
//console.log('getTaskData call')
|
|
1887
|
+
jsonData.definition.actions.push((0, _Designer.getTaskData)(data, this.nodes));
|
|
1888
|
+
} else {
|
|
1889
|
+
//console.log('getTaskData call')
|
|
1890
|
+
jsonData.definition.actions.push((0, _Designer.getTaskData)(this.nodes[itemId], this.nodes));
|
|
1891
|
+
}
|
|
1892
|
+
if (self.nodes[itemId].branch >= 1) {
|
|
1893
|
+
let itemIdP = itemId.split('-');
|
|
1894
|
+
itemId = "".concat(itemIdP[0], "-end-").concat(itemIdP[1]);
|
|
1895
|
+
} else {
|
|
1896
|
+
itemId = this.nodes[itemId].next;
|
|
1897
|
+
}
|
|
1898
|
+
}
|
|
1899
|
+
// text += ']';
|
|
1900
|
+
jsonData.definition.variables = self.getVariablesHardcode();
|
|
1901
|
+
// jsonData.definition.settings = this.props.workflowSettingReducer.detail;
|
|
1902
|
+
// jsonData.workflowType = this.props.workflowSettingReducer.detail.workflowType;
|
|
1903
|
+
// jsonData.workflowName = this.props.workflowSettingReducer.detail.workflowName;
|
|
1904
|
+
// jsonData.workflowDescription = this.props.workflowSettingReducer.detail.workflowDescription;
|
|
1905
|
+
return jsonData;
|
|
1906
|
+
}
|
|
1907
|
+
exportFlowchart() {
|
|
1908
|
+
let data = this.flowchartToJson();
|
|
1909
|
+
|
|
1910
|
+
// downloadJSON(JSON.stringify(data, null, "\t"), 'flowchart.json', 'text/plain');
|
|
1911
|
+
//downloadJSON(JSON.stringify(data, null, '\t'), 'flowchart.json', 'text/plain');
|
|
1912
|
+
}
|
|
1913
|
+
|
|
1914
|
+
getDataBranchNode(node) {
|
|
1915
|
+
if (node === this.flexibleNode.id) {
|
|
1916
|
+
this.flexibleNode.id = null;
|
|
1917
|
+
return this.flexibleNode.jsonData;
|
|
1918
|
+
}
|
|
1919
|
+
let self = this;
|
|
1920
|
+
let left = self.nodes[node].next.left;
|
|
1921
|
+
let right = self.nodes[node].next.right;
|
|
1922
|
+
let leftData = [];
|
|
1923
|
+
let rightData = [];
|
|
1924
|
+
let nodeP = node.split('-');
|
|
1925
|
+
let newData = [];
|
|
1926
|
+
let actionsData = Object.assign({}, self.nodes[node], {
|
|
1927
|
+
branches: []
|
|
1928
|
+
});
|
|
1929
|
+
for (var i = 0; i < self.nodes[node].branch; i++) {
|
|
1930
|
+
let cNode = self.nodes[self.nodes[node].next[i]].next;
|
|
1931
|
+
let endBranchId = "node-botbranch_".concat(i, "-").concat(self.nodes[node].count);
|
|
1932
|
+
newData[i] = [];
|
|
1933
|
+
let curBranch = Object.assign({}, this.nodes[node].branches[i], {
|
|
1934
|
+
actions: []
|
|
1935
|
+
});
|
|
1936
|
+
while (cNode !== endBranchId) {
|
|
1937
|
+
//console.log('ele in branch ', cNode, this.nodes[cNode])
|
|
1938
|
+
////console.log('get data while ', cNode, endBranchId, this.nodes[cNode])
|
|
1939
|
+
let l = '';
|
|
1940
|
+
if (this.nodes[cNode].type === SPECIAL_END_NODE || this.nodes[cNode].type === SPECIAL_CORNER_NODE) {
|
|
1941
|
+
cNode = self.nodes[cNode].next;
|
|
1942
|
+
continue;
|
|
1943
|
+
}
|
|
1944
|
+
if (this.nodes[cNode].type === 'set_variables') {
|
|
1945
|
+
//console.log('getTaskData call')
|
|
1946
|
+
curBranch.actions.push((0, _Designer.getTaskData)(this.nodes[cNode], this.nodes));
|
|
1947
|
+
} else if (self.nodes[cNode].branch >= 1) {
|
|
1948
|
+
l = self.getDataBranchNode(cNode);
|
|
1949
|
+
//console.log('getTaskData call')
|
|
1950
|
+
curBranch.actions.push((0, _Designer.getTaskData)(l, this.nodes));
|
|
1951
|
+
} else {
|
|
1952
|
+
//console.log('getTaskData call')
|
|
1953
|
+
curBranch.actions.push((0, _Designer.getTaskData)(this.nodes[cNode], this.nodes));
|
|
1954
|
+
}
|
|
1955
|
+
if (self.nodes[cNode].branch >= 1) {
|
|
1956
|
+
cNode = "node-end-".concat(this.nodes[cNode].count);
|
|
1957
|
+
} else {
|
|
1958
|
+
cNode = self.nodes[cNode].next;
|
|
1959
|
+
}
|
|
1960
|
+
}
|
|
1961
|
+
actionsData.branches[i] = curBranch;
|
|
1962
|
+
}
|
|
1963
|
+
//console.log('0207 --> ', actionsData)
|
|
1964
|
+
return actionsData;
|
|
1965
|
+
}
|
|
1966
|
+
getDataBranchTask(node) {
|
|
1967
|
+
//////console.log(node, this.nodes[node])
|
|
1968
|
+
let self = this;
|
|
1969
|
+
let cNode = this.nodes[node].next[0];
|
|
1970
|
+
let endId = "node-end-".concat(this.nodes[node].count);
|
|
1971
|
+
let data = [];
|
|
1972
|
+
let text = '';
|
|
1973
|
+
let actionsData = Object.assign({}, self.nodes[node], {
|
|
1974
|
+
branches: []
|
|
1975
|
+
});
|
|
1976
|
+
// if (!actionsData.branches) actionsData.branches = [];
|
|
1977
|
+
// actionsData.branches = [];
|
|
1978
|
+
//////console.log(cNode)
|
|
1979
|
+
let curBranch = Object.assign({}, this.nodes[node].branches[0], {
|
|
1980
|
+
actions: []
|
|
1981
|
+
});
|
|
1982
|
+
while (cNode !== endId) {
|
|
1983
|
+
////console.log('0106 ', cNode, this.nodes[cNode])
|
|
1984
|
+
let l;
|
|
1985
|
+
if (this.nodes[cNode].type === 'set_variables') {
|
|
1986
|
+
//console.log('getTaskData call')
|
|
1987
|
+
actionsData.branches[0].actions.push((0, _Designer.getTaskData)(this.nodes[cNode], this.nodes));
|
|
1988
|
+
} else if (self.nodes[cNode].branch >= 1) {
|
|
1989
|
+
l = self.getDataBranchNode(cNode);
|
|
1990
|
+
actionsData.branches[0].actions.push((0, _Designer.getTaskData)(cNode, this.nodes));
|
|
1991
|
+
} else if (self.nodes[cNode].type !== SPECIAL_END_NODE && this.nodes[cNode].type !== SPECIAL_CORNER_NODE) {
|
|
1992
|
+
//console.log('getTaskData call')
|
|
1993
|
+
actionsData.branches[0].actions.push((0, _Designer.getTaskData)(this.nodes[cNode], this.nodes));
|
|
1994
|
+
}
|
|
1995
|
+
// if (l) data.push(l);
|
|
1996
|
+
if (self.nodes[cNode].branch >= 1) {
|
|
1997
|
+
cNode = "node-end-".concat(this.nodes[cNode].count);
|
|
1998
|
+
} else {
|
|
1999
|
+
cNode = this.nodes[cNode].next;
|
|
2000
|
+
}
|
|
2001
|
+
}
|
|
2002
|
+
return actionsData;
|
|
2003
|
+
}
|
|
2004
|
+
importedJsonFile(jsonData) {
|
|
2005
|
+
let temPermission = jsonData.permission ? _objectSpread({}, jsonData.permission) : {
|
|
2006
|
+
read: [],
|
|
2007
|
+
readAl: [],
|
|
2008
|
+
write: [],
|
|
2009
|
+
design: []
|
|
2010
|
+
};
|
|
2011
|
+
temPermission.read = temPermission.read ? temPermission.read.map(member => ({
|
|
2012
|
+
value: member.id,
|
|
2013
|
+
label: member.email
|
|
2014
|
+
})) : [];
|
|
2015
|
+
temPermission.design = temPermission.design ? temPermission.design.map(member => ({
|
|
2016
|
+
value: member.id,
|
|
2017
|
+
label: member.email
|
|
2018
|
+
})) : [];
|
|
2019
|
+
this.setState({
|
|
2020
|
+
permission: temPermission
|
|
2021
|
+
});
|
|
2022
|
+
this.importData = jsonData;
|
|
2023
|
+
this.reRenderFromFile();
|
|
2024
|
+
|
|
2025
|
+
// comment by anup
|
|
2026
|
+
// jsonData && jsonData.definition && this.props.updateWorkflowSetting(this.importData.definition.settings);
|
|
2027
|
+
// jsonData && jsonData.definition && this.props.updateWorkflowVariables(this.importData.definition.variables);
|
|
2028
|
+
}
|
|
2029
|
+
|
|
2030
|
+
updateFormVar(node, value) {
|
|
2031
|
+
let self = this;
|
|
2032
|
+
self.variables[node] = {};
|
|
2033
|
+
value.forEach(item => {
|
|
2034
|
+
//////console.log('item ', item)
|
|
2035
|
+
self.variables[node][item.var] = item.value;
|
|
2036
|
+
});
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
var _default = Designer;
|
|
2040
|
+
exports.default = _default;
|