Skip to content

Instantly share code, notes, and snippets.

@Axelplacer1
Last active February 2, 2021 11:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Axelplacer1/d93d7f5baa7a452af998b5e0ea28cdbe to your computer and use it in GitHub Desktop.
Save Axelplacer1/d93d7f5baa7a452af998b5e0ea28cdbe to your computer and use it in GitHub Desktop.
{
"NVALS_TAB":
[
{
"ID":"0000999504",
"FL":"0",
"VAL":"Workflow started"
},
{
"ID":"0000999504",
"FL":"1",
"VAL":"SGVT"
},
{
"ID":"0000999504",
"FL":"2",
"VAL":"999504"
},
{
"ID":"0000999504",
"FL":"@",
"VAL":"9/l_b_erin.bmp"
},
{
"ID":"0000999504",
"FL":"?",
"VAL":"18"
},
{
"ID":"0000000021",
"FL":"0",
"VAL":"XOR"
},
{
"ID":"0000000021",
"FL":"?",
"VAL":"17"
},
{
"ID":"0000000150",
"FL":"0",
"VAL":"Processing of Request"
},
{
"ID":"0000000150",
"FL":"1",
"VAL":"CASE"
},
{
"ID":"0000000150",
"FL":"2",
"VAL":"000150"
},
{
"ID":"0000000150",
"FL":"@",
"VAL":"9/l_b_mbed.bmp"
},
{
"ID":"0000000150",
"FL":"?",
"VAL":"5"
},
{
"ID":"0000000152",
"FL":"0",
"VAL":"END"
},
{
"ID":"0000000152",
"FL":"?",
"VAL":"19"
},
{
"ID":"0000000038",
"FL":"0",
"VAL":"Approval Process"
},
{
"ID":"0000000038",
"FL":"1",
"VAL":"FUNC"
},
{
"ID":"0000000038",
"FL":"2",
"VAL":"000038"
},
{
"ID":"0000000038",
"FL":"@",
"VAL":"9/l_b_akti.bmp"
},
{
"ID":"0000000038",
"FL":"?",
"VAL":"2"
},
{
"ID":"0000000158",
"FL":"0",
"VAL":"Request Approved?"
},
{
"ID":"0000000158",
"FL":"1",
"VAL":"CASE"
},
{
"ID":"0000000158",
"FL":"2",
"VAL":"000158"
},
{
"ID":"0000000158",
"FL":"@",
"VAL":"9/l_b_mbed.bmp"
},
{
"ID":"0000000158",
"FL":"?",
"VAL":"5"
},
{
"ID":"0000000142",
"FL":"0",
"VAL":"Wait for Status Change"
},
{
"ID":"0000000142",
"FL":"1",
"VAL":"WAIT"
},
{
"ID":"0000000142",
"FL":"2",
"VAL":"000142"
},
{
"ID":"0000000142",
"FL":"@",
"VAL":"9/l_b_were.bmp"
},
{
"ID":"0000000142",
"FL":"?",
"VAL":"7"
},
{
"ID":"0000000160",
"FL":"0",
"VAL":"END"
},
{
"ID":"0000000160",
"FL":"?",
"VAL":"19"
},
{
"ID":"0000000022",
"FL":"0",
"VAL":"Requester to Process Again?"
},
{
"ID":"0000000022",
"FL":"1",
"VAL":"UNTL"
},
{
"ID":"0000000022",
"FL":"2",
"VAL":"000022"
},
{
"ID":"0000000022",
"FL":"@",
"VAL":"9/l_b_unti.bmp"
},
{
"ID":"0000000022",
"FL":"?",
"VAL":"11"
},
{
"ID":"0000000166",
"FL":"0",
"VAL":"Status change effected"
},
{
"ID":"0000000166",
"FL":"1",
"VAL":"CASE"
},
{
"ID":"0000000166",
"FL":"2",
"VAL":"000166"
},
{
"ID":"0000000166",
"FL":"@",
"VAL":"9/l_b_mbed.bmp"
},
{
"ID":"0000000166",
"FL":"?",
"VAL":"5"
},
{
"ID":"0000000121",
"FL":"0",
"VAL":"Process Request by Employee"
},
{
"ID":"0000000121",
"FL":"1",
"VAL":"FUNC"
},
{
"ID":"0000000121",
"FL":"2",
"VAL":"000121"
},
{
"ID":"0000000121",
"FL":"@",
"VAL":"9/l_b_akti.bmp"
},
{
"ID":"0000000121",
"FL":"?",
"VAL":"2"
},
{
"ID":"0000000168",
"FL":"0",
"VAL":"END"
},
{
"ID":"0000000168",
"FL":"?",
"VAL":"19"
},
{
"ID":"0000999503",
"FL":"0",
"VAL":"Workflow completed"
},
{
"ID":"0000999503",
"FL":"1",
"VAL":"EVTG"
},
{
"ID":"0000999503",
"FL":"2",
"VAL":"999503"
},
{
"ID":"0000999503",
"FL":"@",
"VAL":"9/l_b_erin.bmp"
},
{
"ID":"0000999503",
"FL":"?",
"VAL":"18"
},
{
"ID":"FUNC",
"FL":"0",
"VAL":"Activity"
},
{
"ID":"FUNC",
"FL":"@",
"VAL":"9/l_b_akti.bmp"
},
{
"ID":"WEB",
"FL":"0",
"VAL":"Web activity"
},
{
"ID":"WEB",
"FL":"@",
"VAL":"9/l_webflo.bmp"
},
{
"ID":"MAIL",
"FL":"0",
"VAL":"Send Mail"
},
{
"ID":"MAIL",
"FL":"@",
"VAL":"9/l_t_mail.bmp"
},
{
"ID":"FORM",
"FL":"0",
"VAL":"Form"
},
{
"ID":"FORM",
"FL":"@",
"VAL":"9/l_b_form.bmp"
},
{
"ID":"MSEL",
"FL":"0",
"VAL":"User Decision"
},
{
"ID":"MSEL",
"FL":"@",
"VAL":"9/l_b_bent.bmp"
},
{
"ID":"TMPL",
"FL":"0",
"VAL":"Document from Template"
},
{
"ID":"TMPL",
"FL":"@",
"VAL":"9/l_wfdoku.bmp"
},
{
"ID":"IF",
"FL":"0",
"VAL":"Condition"
},
{
"ID":"IF",
"FL":"@",
"VAL":"9/l_b_bedi.bmp"
},
{
"ID":"CASE",
"FL":"0",
"VAL":"Multiple Condition"
},
{
"ID":"CASE",
"FL":"@",
"VAL":"9/l_b_mbed.bmp"
},
{
"ID":"TRIG",
"FL":"0",
"VAL":"Event creator"
},
{
"ID":"TRIG",
"FL":"@",
"VAL":"9/l_b_sere.bmp"
},
{
"ID":"WAIT",
"FL":"0",
"VAL":"Wait"
},
{
"ID":"WAIT",
"FL":"@",
"VAL":"9/l_b_were.bmp"
},
{
"ID":"OPRT",
"FL":"0",
"VAL":"Container operation"
},
{
"ID":"OPRT",
"FL":"@",
"VAL":"9/l_b_cont.bmp"
},
{
"ID":"CTRL",
"FL":"0",
"VAL":"Process Control"
},
{
"ID":"CTRL",
"FL":"@",
"VAL":"9/l_b_steu.bmp"
},
{
"ID":"UNTL",
"FL":"0",
"VAL":"Loop (Until)"
},
{
"ID":"UNTL",
"FL":"@",
"VAL":"9/l_b_unti.bmp"
},
{
"ID":"WHIL",
"FL":"0",
"VAL":"Loop (While)"
},
{
"ID":"WHIL",
"FL":"@",
"VAL":"9/l_b_whil.bmp"
},
{
"ID":"FORK",
"FL":"0",
"VAL":"Fork"
},
{
"ID":"FORK",
"FL":"@",
"VAL":"9/l_b_pabs.bmp"
},
{
"ID":"VOID",
"FL":"0",
"VAL":"Undefined"
},
{
"ID":"VOID",
"FL":"@",
"VAL":"9/l_b_unbe.bmp"
},
{
"ID":"ANCH",
"FL":"0",
"VAL":"Ad Hoc Anchor"
},
{
"ID":"ANCH",
"FL":"@",
"VAL":"9/l_b_anch.bmp"
},
{
"ID":"XBLK",
"FL":"0",
"VAL":"Block"
},
{
"ID":"XBLK",
"FL":"@",
"VAL":"9/l_b_nxti.bmp"
},
{
"ID":"XFLO",
"FL":"0",
"VAL":"Local Workflow"
},
{
"ID":"XFLO",
"FL":"@",
"VAL":"9/@HF@"
}
],
"POSITIONS_TAB":
[
{
"ID":"0000000021",
"X_POS":"4",
"Y_POS":" 6",
"OBJ_TYPE":"n"
},
{
"ID":"0000000150",
"X_POS":"4",
"Y_POS":" 8",
"OBJ_TYPE":"n"
},
{
"ID":"0000000152",
"X_POS":"4",
"Y_POS":" 12",
"OBJ_TYPE":"n"
},
{
"ID":"0000000038",
"X_POS":"4",
"Y_POS":" 10",
"OBJ_TYPE":"n"
},
{
"ID":"0000000158",
"X_POS":"4",
"Y_POS":" 14",
"OBJ_TYPE":"n"
},
{
"ID":"0000000142",
"X_POS":"4",
"Y_POS":" 16",
"OBJ_TYPE":"n"
},
{
"ID":"0000000160",
"X_POS":"4",
"Y_POS":" 22",
"OBJ_TYPE":"n"
},
{
"ID":"0000000022",
"X_POS":"4",
"Y_POS":" 24",
"OBJ_TYPE":"n"
},
{
"ID":"0000000166",
"X_POS":"4",
"Y_POS":" 18",
"OBJ_TYPE":"n"
},
{
"ID":"0000000121",
"X_POS":"4",
"Y_POS":" 26",
"OBJ_TYPE":"n"
},
{
"ID":"0000000168",
"X_POS":"4",
"Y_POS":" 20",
"OBJ_TYPE":"n"
},
{
"ID":"0000999503",
"X_POS":"5",
"Y_POS":" 26",
"OBJ_TYPE":"n"
},
{
"ID":"0000999504",
"X_POS":" 4",
"Y_POS":" 1",
"OBJ_TYPE":"n"
}
],
"LVALS_TAB":
[
{
"ID":"0000000053",
"FL":"E",
"VAL":"32"
},
{
"ID":"0000000053",
"FL":"?",
"VAL":"20"
},
{
"ID":"0000000003",
"FL":"E",
"VAL":"32"
},
{
"ID":"0000000003",
"FL":"?",
"VAL":"20"
},
{
"ID":"0000000022",
"FL":"E",
"VAL":"32"
},
{
"ID":"0000000022",
"FL":"0",
"VAL":"Request Withdrawn"
},
{
"ID":"0000000022",
"FL":"?",
"VAL":"20"
},
{
"ID":"0000000023",
"FL":"E",
"VAL":"32"
},
{
"ID":"0000000023",
"FL":"0",
"VAL":"Approval Not Required"
},
{
"ID":"0000000023",
"FL":"?",
"VAL":"20"
},
{
"ID":"0000000024",
"FL":"E",
"VAL":"32"
},
{
"ID":"0000000024",
"FL":"0",
"VAL":"Approval Required"
},
{
"ID":"0000000024",
"FL":"?",
"VAL":"20"
},
{
"ID":"0000000025",
"FL":"E",
"VAL":"32"
},
{
"ID":"0000000025",
"FL":"?",
"VAL":"20"
},
{
"ID":"0000000054",
"FL":"E",
"VAL":"32"
},
{
"ID":"0000000054",
"FL":"0",
"VAL":""
},
{
"ID":"0000000054",
"FL":"?",
"VAL":"20"
},
{
"ID":"0000000030",
"FL":"E",
"VAL":"32"
},
{
"ID":"0000000030",
"FL":"0",
"VAL":"Approved"
},
{
"ID":"0000000030",
"FL":"?",
"VAL":"20"
},
{
"ID":"0000000031",
"FL":"E",
"VAL":"32"
},
{
"ID":"0000000031",
"FL":"0",
"VAL":"Canceled"
},
{
"ID":"0000000031",
"FL":"?",
"VAL":"20"
},
{
"ID":"0000000032",
"FL":"E",
"VAL":"32"
},
{
"ID":"0000000032",
"FL":"0",
"VAL":"Rejected"
},
{
"ID":"0000000032",
"FL":"?",
"VAL":"20"
},
{
"ID":"0000000056",
"FL":"E",
"VAL":"32"
},
{
"ID":"0000000056",
"FL":"0",
"VAL":"Request Posted, Incorrect, or Withdrawn"
},
{
"ID":"0000000056",
"FL":"?",
"VAL":"20"
},
{
"ID":"0000000033",
"FL":"E",
"VAL":"32"
},
{
"ID":"0000000033",
"FL":"?",
"VAL":"20"
},
{
"ID":"0000000005",
"FL":"E",
"VAL":"32"
},
{
"ID":"0000000005",
"FL":"0",
"VAL":"Resubmission"
},
{
"ID":"0000000005",
"FL":"?",
"VAL":"20"
},
{
"ID":"0000000006",
"FL":"E",
"VAL":"32"
},
{
"ID":"0000000006",
"FL":"0",
"VAL":"End Process"
},
{
"ID":"0000000006",
"FL":"?",
"VAL":"20"
},
{
"ID":"0000000038",
"FL":"E",
"VAL":"32"
},
{
"ID":"0000000038",
"FL":"0",
"VAL":"Canceled"
},
{
"ID":"0000000038",
"FL":"?",
"VAL":"20"
},
{
"ID":"0000000039",
"FL":"E",
"VAL":"32"
},
{
"ID":"0000000039",
"FL":"0",
"VAL":"Posted"
},
{
"ID":"0000000039",
"FL":"?",
"VAL":"20"
},
{
"ID":"0000000059",
"FL":"E",
"VAL":"32"
},
{
"ID":"0000000059",
"FL":"0",
"VAL":""
},
{
"ID":"0000000059",
"FL":"?",
"VAL":"20"
},
{
"ID":"0000000040",
"FL":"E",
"VAL":"32"
},
{
"ID":"0000000040",
"FL":"?",
"VAL":"20"
}
],
"LINES_TAB":
[
{
"ID":"0000000053",
"PRE":"0000999504",
"SUC":"0000000021",
"TYPE":"0",
"AB":"EA"
},
{
"ID":"0000000003",
"PRE":"0000000021",
"SUC":"0000000150",
"TYPE":"0",
"AB":"EA"
},
{
"ID":"0000000022",
"PRE":"0000000150",
"SUC":"0000000152",
"TYPE":"0",
"AB":"EA"
},
{
"ID":"0000000023",
"PRE":"0000000150",
"SUC":"0000000152",
"TYPE":"0",
"AB":"EA"
},
{
"ID":"0000000024",
"PRE":"0000000150",
"SUC":"0000000038",
"TYPE":"0",
"AB":"EA"
},
{
"ID":"0000000025",
"PRE":"0000000152",
"SUC":"0000000158",
"TYPE":"0",
"AB":"EA"
},
{
"ID":"0000000054",
"PRE":"0000000038",
"SUC":"0000000152",
"TYPE":"0",
"AB":"EA"
},
{
"ID":"0000000030",
"PRE":"0000000158",
"SUC":"0000000142",
"TYPE":"0",
"AB":"EA"
},
{
"ID":"0000000031",
"PRE":"0000000158",
"SUC":"0000000160",
"TYPE":"0",
"AB":"EA"
},
{
"ID":"0000000032",
"PRE":"0000000158",
"SUC":"0000000160",
"TYPE":"0",
"AB":"EA"
},
{
"ID":"0000000056",
"PRE":"0000000142",
"SUC":"0000000166",
"TYPE":"0",
"AB":"EA"
},
{
"ID":"0000000033",
"PRE":"0000000160",
"SUC":"0000000022",
"TYPE":"0",
"AB":"EA"
},
{
"ID":"0000000005",
"PRE":"0000000022",
"SUC":"0000000121",
"TYPE":"0",
"AB":"EA"
},
{
"ID":"0000000006",
"PRE":"0000000022",
"SUC":"0000999503",
"TYPE":"0",
"AB":"EA"
},
{
"ID":"0000000038",
"PRE":"0000000166",
"SUC":"0000000168",
"TYPE":"0",
"AB":"EA"
},
{
"ID":"0000000039",
"PRE":"0000000166",
"SUC":"0000000168",
"TYPE":"0",
"AB":"EA"
},
{
"ID":"0000000059",
"PRE":"0000000121",
"SUC":"0000000021",
"TYPE":"0",
"AB":"EA"
},
{
"ID":"0000000040",
"PRE":"0000000168",
"SUC":"0000000160",
"TYPE":"0",
"AB":"EA"
}
]
}
sap.ui.define(["sap/ui/core/Control", "sap/ui/thirdparty/d3"], (function (t, e) {
let r = t.extend("my.sap.wfvis.Workflow", {
metadata: {
properties: {
workflowDef: {type: "object", defaultValue: null},
minWidth: {type: "int", defaultValue: 100},
maxWidth: {type: "int", defaultValue: 200},
minHeight: {type: "int", defaultValue: 60},
maxHeight: {type: "int", defaultValue: 120}
}, events: {}
}, init: function () {
}, setWorkflowDef(t) {
this.setProperty("workflowDef", t, true)
}, onBeforeRendering: function () {
}, onAfterRendering: function () {
let t = jQuery("#idWFContainer");
t.height(jQuery(document).height() - 60);
t.width(jQuery(document).width());
if (!this.getWorkflowDef().POSITIONS_TAB) {
return
}
this.drawFlowChart()
}, renderer: function (t, e) {
t.write("<div");
t.writeControlData(e);
t.writeClasses();
t.write(">");
t.write("<div id='idWFContainer' style='overflow: scroll;'/>")
}, calculateLinePath: function (t, e, i, r) {
let l = function (t, i, r) {
let l = jQuery.grep(e, (function (e) {
return Number(e.X_POS) === t && Number(e.Y_POS) === i
}));
return l.length === 0 || l[0].ID === r
};
let n = function (t, e) {
return t <= i + 1 && e <= r + 1 && t > -1 && e > -1
};
let a = function (t, e, i) {
return i.SX_POS === t && i.SY_POS === e
};
let h = function (t) {
let e = jQuery.extend(true, {}, t);
t.original = e;
t.PRE = e.SUC;
t.SUC = e.PRE;
t.SX_POS = e.X_POS;
t.SY_POS = e.Y_POS;
t.X_POS = e.SX_POS;
t.Y_POS = e.SY_POS;
t.reversed = true
};
let o = function (t, e, i, r) {
let a = 0;
let h = [];
let o = false;
let c = t;
while (c !== e) {
a = c < e ? 1 : -1;
c += a;
if (c !== e && l(c, i, r) && n(c, i)) {
h.push({x: c, y: i})
} else {
break
}
}
if (c === e && l(c, i, r) && n(c, i)) {
h.push({x: c, y: i});
return {reached: true, path: h, x: c, y: i}
}
};
let c = function (t, e, i, r) {
let a = 0;
let h = [];
let o = false;
let c = t;
while (c !== e) {
a = c < e ? 1 : -1;
c += a;
if (c !== e && l(i, c, r) && n(i, c)) {
h.push({x: i, y: c})
} else {
break
}
}
if (c === e && l(i, c, r) && n(i, c)) {
h.push({x: i, y: c});
return {reached: true, path: h, x: i, y: c}
}
};
t.forEach((t, e) => {
let i = [];
let r = 0;
let u = 0;
if (t.SY_POS < t.Y_POS) {
h(t)
}
let f = {x: t.X_POS, y: t.Y_POS};
i.push({x: f.x, y: f.y});
let p = 0, s = 0, d = 0;
let x = t.SX_POS;
let y = t.X_POS > t.SX_POS ? -1 : 1;
do {
let e = false;
s = 0;
while (!e) {
let r = false;
let h, u;
if (f.y !== t.SY_POS) {
h = c(f.y, t.SY_POS, f.x, t.SUC);
if (h && h.reached) {
h.path.forEach(t => {
i.push(t)
});
f.y = h.y
}
}
if (f.x !== x) {
u = o(f.x, x, f.y, t.SUC);
if (u && u.reached) {
u.path.forEach(t => {
i.push(t)
});
f.x = u.x
}
}
r = !h && !u;
e = a(f.x, f.y, {SX_POS: x, SY_POS: t.SY_POS});
if (!e && r) {
f.x += y;
if (n(f.x, f.y) && l(f.x, f.y, t.SUC)) {
} else {
f.x += t.X_POS > x ? 1 : -1;
f.y += t.Y_POS > t.SY_POS ? -1 : 1;
if (!n(f.x, f.y) || !l(f.x, f.y, t.SUC)) {
break
}
}
i.push({x: f.x, y: f.y});
e = a(f.x, f.y, {SX_POS: x, SY_POS: t.SY_POS})
}
if (e) {
if (x !== t.SX_POS) {
e = false;
x = t.SX_POS
} else {
break
}
}
s++;
if (s > 10) {
i.splice(0, i.length);
i.push({x: t.X_POS, y: t.Y_POS});
f = {x: t.X_POS, y: t.Y_POS};
break
}
}
p++;
x += y;
if (p === 5 && s > 10 && !e && d === 0) {
y *= -1;
d++;
x = t.SX_POS;
d = 1;
p = 0
}
} while (p < 5 && s > 10);
if (!a(f.x, f.y, t)) {
} else if (t.reversed) {
let e = i.length - 1;
let r = function (e) {
let r = true;
for (let a = 3; a < i.length - 1; a++) {
if (i[a].x === t.SX_POS) {
if (!(n(f.x - e, f.y) && l(f.x, f.y, t.SUC))) {
r = false;
break
}
}
}
return r
};
if (i[e].x === i[e - 1].x) {
let e = true;
let l = 1;
e = r(l);
if (!e) {
l = -1;
e = r(l)
}
if (e) {
for (let r = 2; r < i.length - 1; r++) {
if (i[r].x === t.SX_POS) {
if (e) {
i.splice(r, 0, {x: i[r].x, y: i[r].y});
r++;
e = false
}
i[r].x += l
}
}
i.splice(i.length - 1, 0, {x: i[i.length - 2].x, y: t.SY_POS})
}
}
}
t.path = i
})
}, detectLineCollisions: function (t) {
let i = [];
let r = function (t) {
let e = jQuery.grep(i, (function (e) {
return e.x === t.x && e.y === t.y
}));
if (e.length > 0) {
e[0].l += 1;
return e[0].l
} else {
i.push(t);
return 1
}
};
t.forEach(t => {
if (!t.node || !t.node.lines) {
return
}
t.node.lines.forEach(i => {
for (let t = 1; t < i.path.length - 1; t++) {
i.path[t + 1].l = 0;
if (i.path[t].x === i.path[t + 1].x && i.path[t].y !== i.path[t + 1].y) {
i.path[t + 1].l = r(i.path[t + 1])
}
}
i.lineShift = e.max(i.path, (function (t) {
return t.l ? t.l : 0
}));
i.type = t.type
})
})
}, calculateBlocks: function (t, i) {
let r = this.getWorkflowDef().POSITIONS_TAB;
let l = this.getWorkflowDef().NVALS_TAB;
let n = this.getWorkflowDef().LINES_TAB;
let a = this.getWorkflowDef().LINES;
let h = this.getWorkflowDef().LVALS_TAB;
let o = e.max(r, (function (t) {
return parseInt(t.X_POS, 10)
}));
let c = e.max(r, (function (t) {
return parseInt(t.Y_POS, 10)
}));
let u = t / (o + 1) > this.getMinWidth() ? t / o : this.getMinWidth();
let f = i / (c + 1) > this.getMinHeight() ? i / c : this.getMinHeight();
u = u > this.getMaxWidth() ? this.getMaxWidth() : u;
f = f > this.getMaxHeight() ? this.getMaxHeight() : f;
let p = {maxX: o, maxY: c, blockWidth: u, blockHeight: f, grid: [], circ: []};
p.totalWidth = u * (o + 2);
p.totalHeight = f * (c + 2);
var s = function (t) {
let e = jQuery.grep(h, (function (e) {
return e.ID === t.ID && e.FL === "0"
}));
if (e.length > 0) {
return e[0]
}
};
for (let t = 0; t <= c + 1; t++) {
for (let e = 0; e <= o + 1; e++) {
let i = jQuery.grep(r, (function (i) {
return parseInt(i.X_POS, 10) === e + 1 && parseInt(i.Y_POS, 10) === t + 1
}));
let a = [];
if (i.length > 0) {
a = jQuery.grep(l, (function (t) {
return t.ID === i[0].ID && t.FL === "0"
}));
if (a.length > 0) {
i[0].text = a[0].VAL
}
a = [];
a = jQuery.grep(l, (function (t) {
return t.ID === i[0].ID && t.FL === "1"
}));
if (a.length > 0) {
i[0].NTYPE = a[0].VAL
}
let t = [];
t = jQuery.grep(n, (function (t) {
return t.PRE === i[0].ID
}));
i[0].lines = t;
i[0].X_POS = parseInt(i[0].X_POS, 10);
i[0].Y_POS = parseInt(i[0].Y_POS, 10);
i[0].lines.forEach(t => {
let e = jQuery.grep(r, (function (e) {
return e.ID === t.SUC
}));
if (e.length > 0) {
t.SX_POS = parseInt(e[0].X_POS, 10);
t.SY_POS = parseInt(e[0].Y_POS, 10)
}
t.X_POS = i[0].X_POS;
t.Y_POS = i[0].Y_POS;
t.X_NODE = i[0].ID;
t.lineCount = i[0].lines.length;
t.value = s(t)
});
this.calculateLinePath(i[0].lines, r, o, c)
} else {
continue
}
p.grid.push({
xpos: e,
ypos: t,
x: p.blockWidth * e,
y: p.blockHeight * t,
node: i.length > 0 ? i[0] : null
});
if (i[0] && i[0].text) {
switch (i[0].text) {
case"XOR":
case"END":
i[0].text = "";
p.grid[p.grid.length - 1].type = "circle";
break;
default:
p.grid[p.grid.length - 1].type = "";
break
}
}
}
}
this.detectLineCollisions(p.grid);
return p
}, wrapText: function (t, i) {
t.each((function () {
var t = e.select(this), r = t.text().split(/\s+/).reverse(), l, n = [], a = 0, h = 1.1, o = t.attr("x"),
c = t.attr("y"), u = 0,
f = t.text(null).append("tspan").attr("x", o).attr("y", c).attr("dy", u + "em");
while (l = r.pop()) {
n.push(l);
f.text(n.join(" "));
if (f.node().getComputedTextLength() > i) {
n.pop();
f.text(n.join(" "));
n = [l];
f = t.append("tspan").attr("x", o).attr("y", c).attr("dy", ++a * h + u + "em").text(l)
}
}
}))
}, drawFlowChart: function () {
let t = jQuery("#idWFContainer");
let r = this.calculateBlocks(t.width(), t.height());
let l = [];
let n = 12, a = 12;
let h = e.selectAll("#idWFContainer").append("svg").attr("class", "svgMainContainer").attr("width", r.totalWidth).attr("height", r.totalHeight);
h.append("defs").append("marker").attr("id", "idArrowMarker").attr("markerWidth", n).attr("markerHeight", a).attr("markerUnits", "strokeWidth").attr("refX", "10").attr("refY", "3").attr("orient", "auto").append("path").attr("d", "M0,0 L0,6 L9,3 z").attr("fill", "#4682b4");
let o = h.append("g").attr("class", "nodes");
let c = o.selectAll("g.nodes").data(r.grid);
c.remove();
let u = c.enter().append("g").attr("transform", (function (t) {
return "translate(" + t.x + "," + t.y + ")"
}));
u.append("rect").attr("width", r.blockWidth).attr("height", r.blockHeight).attr("class", (function (t) {
return t.type === "circle" ? "gridBlock" : "gridBlock"
})).attr("rx", (function (t) {
return t.type === "circle" ? r.blockHeight / 2 : "0"
})).attr("ry", (function (t) {
return t.type === "circle" ? r.blockHeight / 2 : "0"
}));
u.append("circle").attr("cx", r.blockWidth / 2).attr("cy", r.blockHeight / 2).attr("r", r.blockHeight / 4).attr("class", (function (t) {
return t.type === "circle" ? "gridCircle" : "gridBlockHidden"
}));
let f = u.selectAll("g").data((function (t) {
return t.node ? t.node.lines : []
}));
f.enter().append("path").attr("class", "joinLine").attr("marker-end", "url(#idArrowMarker)").attr("d", (function (t) {
const e = 5;
let n = t.lineShift > 1 ? t.lineShift * e : 0;
let a = [];
let h = function (e, i) {
let l = "";
let h = "";
if (e.x === i.x) {
l = `M ${r.blockWidth / 2 + n} ${r.blockHeight}`;
a.push(n ? -n : 0);
t.sp = "d"
} else if (e.x > i.x) {
let e = 0;
l = `M ${e} ${r.blockHeight / 2}`;
a.push(n ? n : 0);
a.push(n ? -n : 0);
t.sp = "l"
} else if (e.x < i.x) {
let e = 0;
l = `M ${r.blockWidth + e} ${r.blockHeight / 2}`;
a.push(n ? -n : 0);
a.push(n ? -n : 0);
t.sp = "r"
} else {
l = "M0 0"
}
return l
};
let o = function (e, r, l) {
if (e.x - 1 === l.x && e.y + 1 === l.y && e.x === r.x && e.y + 1 === r.y) {
e.c = "DRL";
t.path[t.path.length - 2].c = "RLD";
for (j = i; j < t.path.length; j++) {
t.path[j].x += -1;
t.path[j].y += -1
}
}
if (e.x + 1 === l.x && e.y + 1 === l.y && e.x + 1 === r.x && e.y === r.y) {
r.c = "LRD"
}
if (e.x - 1 === l.x && e.y + 1 === l.y && e.x - 1 === r.x && e.y === r.y) {
r.c = "RLD"
}
if (e.x - 1 === l.x && e.y + 1 === l.y && e.x === r.x && e.y + 1 === r.y) {
r.c = "DRL"
}
if (e.x + 1 === l.x && e.y + 1 === l.y && e.x === r.x && e.y + 1 === r.y) {
r.c = "DLR";
if (e.x !== t.X_POS || e.y !== t.Y_POS) {
delete r.c;
e.c = "DLR";
t.path[t.path.length - 2].c = "LRD";
for (j = i; j < t.path.length; j++) {
t.path[j].x += -1;
t.path[j].y += -1
}
}
}
if (e.x + 1 === l.x && e.y - 1 === l.y && e.x + 1 === r.x && e.y === r.y) {
r.c = "LRU"
}
if (e.x - 1 === l.x && e.y - 1 === l.y && e.x === r.x && e.y - 1 === r.y) {
r.c = "URL"
}
if (e.x - 1 === l.x && e.y - 1 === l.y && e.x - 1 === r.x && e.y === r.y) {
r.c = "RLU"
}
if (e.x + 1 === l.x && e.y - 1 === l.y && e.x === r.x && e.y - 1 === r.y) {
r.c = "ULR"
}
};
let c = function (t, e) {
switch (t) {
case"DRL":
return `q0 ${r.blockHeight / 2} -${r.blockWidth / 2 + e} ${r.blockHeight / 2}`;
case"RLD":
return `q-${r.blockWidth / 2 + e} 0 -${r.blockWidth / 2 + e} ${r.blockHeight / 2}`;
case"DLR":
return `q0 ${r.blockHeight / 2} ${r.blockWidth / 2 + e} ${r.blockHeight / 2}`;
case"LRD":
return `q${r.blockWidth / 2 + e} 0 ${r.blockWidth / 2 + e} ${r.blockHeight / 2}`;
case"LRU":
return `q${r.blockWidth / 2 + e} 0 ${r.blockWidth / 2 + e} -${r.blockHeight / 2}`;
case"URL":
return `q0 -${r.blockHeight / 2} -${r.blockWidth / 2 + e} -${r.blockHeight / 2}`;
case"RLU":
return `q-${r.blockWidth / 2 + e} 0 -${r.blockWidth / 2 + e} -${r.blockHeight / 2}`;
case"ULR":
return `q0 -${r.blockHeight / 2} ${r.blockWidth / 2 + e} -${r.blockHeight / 2}`
}
};
let u = function (t, e, i) {
if (e.c) {
let t = a.pop();
t = t ? t * -1 : 0;
return c(e.c, t)
}
return `l ${(i.x - e.x) * r.blockWidth} ${(i.y - e.y) * r.blockHeight}`
};
let f = function (t) {
let e = 0, i = {}, n = 0, a = 0;
for (e = 0; e < t.path.length; e++) {
if (t.path[e].c) {
i = t.path[e];
break
}
}
switch (t.sp) {
case"d":
if (t.lineCount > 1 && i.c === "DLR") {
n = r.blockHeight * 2 - 20;
a = r.blockWidth + 25
} else {
n = r.blockHeight + 20;
a = r.blockWidth / 2
}
break;
case"l":
if (t.lineCount > 1 && i.c === "RLD") {
n = r.blockHeight;
a = r.blockWidth * (i.x - t.path[0].x) + r.blockWidth / 2
} else {
n = r.blockHeight / 2 - 5;
a = r.blockWidth * -1 / 3
}
break;
case"r":
if (t.lineCount > 1 && i.c === "LRD") {
n = r.blockHeight;
a = r.blockWidth * (i.x - t.path[0].x) + r.blockWidth / 2
} else {
n = r.blockHeight / 2 - 5;
a = r.blockWidth * 1.5
}
break
}
let h = jQuery.grep(l, (function (e) {
return t.lineCount > 1 && a === e.x && n === e.y && e.id === (t.reversed ? t.SUC : t.PRE)
}));
n += h.length > 0 ? t.reversed ? -25 : 25 : 0;
a += h.length > 0 ? t.lineShift === 1 ? -15 : t.lineShift * 15 : 0;
l.push({id: t.reversed ? t.SUC : t.PRE, x: a, y: n});
t.ty = n;
t.tx = a
};
let p = function (t) {
let e = jQuery.grep(r.grid, (function (e) {
return e.node.ID === t
}));
return e.length > 0 && e[0].type === "circle"
};
if (!t.reversed) {
for (i = 1; i < t.path.length - 1; i++) {
let e = t.path[i - 1];
let r = t.path[i];
let l = t.path[i + 1];
o(e, r, l)
}
} else {
for (i = t.path.length - 2; i > 0; i--) {
let e = t.path[i + 1];
let r = t.path[i];
let l = t.path[i - 1];
o(e, r, l)
}
}
let s = h(t.path[0], t.path[1]);
if (!t.reversed) {
for (i = 1; i < t.path.length - 1; i++) {
s = s + u(t.path[i - 1], t.path[i], t.path[i + 1])
}
let e = t.path[t.path.length - 1].x - t.path[t.path.length - 2].x;
let r = t.path[t.path.length - 1].y - t.path[t.path.length - 2].y
} else {
for (i = t.path.length - 2; i > 0; i--) {
s = s + u(t.path[i + 1], t.path[i], t.path[i - 1])
}
}
f(t);
return s
}));
f.enter().append("text").attr("y", (function (t) {
return t.ty
})).attr("x", (function (t) {
return t.tx
})).attr("class", "lineText").text((function (t) {
return t.value ? t.value.VAL : ""
})).call(this.wrapText, r.blockWidth - 10);
c.enter().append("g").attr("transform", (function (t) {
return "translate(" + t.x + "," + t.y + ")"
})).append("text").attr("y", 12).attr("x", r.blockWidth / 2).attr("class", "nodeText").text((function (t) {
return t.node ? t.node.text ? t.node.text : "" : t.xpos + 1 + "," + (t.ypos + 1)
})).call(this.wrapText, r.blockWidth - 10)
}
});
return r
}), true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment