2667 lines
122 KiB
JavaScript
2667 lines
122 KiB
JavaScript
function WorkflowDesigner(e) {
|
|
var t = this;
|
|
this.Settings = e,
|
|
this.GetName = function () {
|
|
return t.Settings.name
|
|
}, this.error = function (e) {
|
|
alert(e)
|
|
}, this.load = function (e) {
|
|
var i = new Array;
|
|
this.schemecode = e.schemecode, this.processid = e.processid, this.schemeid = e.schemeid, this.readonly = e.readonly, i.push({
|
|
name: "schemecode",
|
|
value: this.schemecode
|
|
}), i.push({
|
|
name: "processid",
|
|
value: this.processid
|
|
}), i.push({
|
|
name: "schemeid",
|
|
value: this.schemeid
|
|
}), i.push({
|
|
name: "operation",
|
|
value: "load"
|
|
});
|
|
$.ajax({
|
|
url: this.Settings.apiurl,
|
|
data: i,
|
|
async: !0,
|
|
success: function (e) {
|
|
var i = {};
|
|
try {
|
|
i = JSON.parse(e)
|
|
} catch (n) {
|
|
return void t.error(e)
|
|
}
|
|
return i.isError ? void t.error(i.errorMessage) : (t.data = i, void t.render())
|
|
},
|
|
error: function (e, i, n) {
|
|
t.error(i + " " + n)
|
|
}
|
|
})
|
|
}, this.exists = function (e) {
|
|
var i = new Array;
|
|
this.schemecode = e.schemecode, this.processid = e.processid, this.schemeid = e.schemeid, this.readonly = e.readonly, i.push({
|
|
name: "schemecode",
|
|
value: this.schemecode
|
|
}), i.push({
|
|
name: "processid",
|
|
value: this.processid
|
|
}), i.push({
|
|
name: "schemeid",
|
|
value: this.schemeid
|
|
}), i.push({
|
|
name: "operation",
|
|
value: "exists"
|
|
});
|
|
var n = $.ajax({
|
|
url: this.Settings.apiurl,
|
|
data: i,
|
|
async: !1,
|
|
error: function (e, i, n) {
|
|
t.error(i + " " + n)
|
|
}
|
|
}).responseText;
|
|
try {
|
|
return JSON.parse(n)
|
|
} catch (o) {
|
|
return t.error(n), !1
|
|
}
|
|
}, this.create = function () {
|
|
var e = new Array;
|
|
e.push({
|
|
name: "operation",
|
|
value: "load"
|
|
});
|
|
$.ajax({
|
|
url: this.Settings.apiurl,
|
|
data: e,
|
|
async: !0,
|
|
success: function (e) {
|
|
try {
|
|
t.data = JSON.parse(e)
|
|
} catch (i) {
|
|
t.error(e)
|
|
}
|
|
t.render()
|
|
}
|
|
})
|
|
}, this.render = function () {
|
|
t.Graph && t.Graph.destroy();
|
|
var e = [WorkflowDesignerBackground, WorkflowDesignerActivity, WorkflowDesignerTransition, WorkflowDesignerKeyboard];
|
|
this.Settings.notrendertoolbar || e.push(WorkflowDesignerToolbar), t.Graph = new WorkflowGraph(this.Settings.renderTo, t, t.Settings, e), WorkflowDesignerCommon.DataCorrection(t.data), t.Graph.Draw(t.data)
|
|
}, this.save = function (e) {
|
|
if (t.readonly) return void alert(WorkflowDesignerConstants.ErrorReadOnlySaveText);
|
|
var i = new Array;
|
|
i.push({
|
|
name: "schemecode",
|
|
value: this.schemecode
|
|
}), i.push({
|
|
name: "processid",
|
|
value: this.processid
|
|
}), i.push({
|
|
name: "schemeid",
|
|
value: this.schemeid
|
|
}), i.push({
|
|
name: "operation",
|
|
value: "save"
|
|
}), i.push({
|
|
name: "data",
|
|
value: JSON.stringify(this.data)
|
|
});
|
|
$.ajax({
|
|
url: this.Settings.apiurl,
|
|
data: i,
|
|
async: !0,
|
|
type: "post",
|
|
success: function (i) {
|
|
var n = {};
|
|
try {
|
|
n = JSON.parse(i)
|
|
} catch (o) {
|
|
return void t.error(i)
|
|
}
|
|
return n.isError ? void t.error(n.errorMessage) : (t.data = n, t.render(), void (e && setTimeout(function () {
|
|
e(t)
|
|
}, 100)))
|
|
}
|
|
})
|
|
}, this.downloadscheme = function (e) {
|
|
var t = new Array;
|
|
t.push({
|
|
name: "operation",
|
|
value: "downloadscheme"
|
|
}), t.push({
|
|
name: "data",
|
|
value: JSON.stringify(this.data)
|
|
}), WorkflowDesignerCommon.download(this.Settings.apiurl, t, "post")
|
|
}, this.uploadscheme = function (e, i) {
|
|
var n = this.GetName() + "_uploadiframe",
|
|
o = document.createElement("iframe");
|
|
o.setAttribute("id", n), o.setAttribute("name", n), o.setAttribute("width", "0"), o.setAttribute("height", "0"), o.setAttribute("border", "0"), o.setAttribute("style", "width: 0; height: 0; border: none;"), e.parentNode.appendChild(o), window.frames[n].name = n, iframeId = document.getElementById(n);
|
|
var r = function () {
|
|
iframeId.detachEvent ? iframeId.detachEvent("onload", r) : iframeId.removeEventListener("load", r, !1), iframeId.contentDocument ? content = iframeId.contentDocument.body.innerHTML : iframeId.contentWindow ? content = iframeId.contentWindow.document.body.innerHTML : iframeId.document && (content = iframeId.document.body.innerHTML), setTimeout("iframeId.parentNode.removeChild(iframeId)", 250);
|
|
var e = {};
|
|
try {
|
|
e = JSON.parse(content)
|
|
} catch (n) {
|
|
return void t.error(content)
|
|
}
|
|
return e.isError ? void t.error(e.errorMessage) : (t.data = e, t.render(), void (i && i(t)))
|
|
};
|
|
iframeId.addEventListener && iframeId.addEventListener("load", r, !0), iframeId.attachEvent && iframeId.attachEvent("onload", r), e.setAttribute("target", n), e.setAttribute("action", this.createurl("uploadscheme")), e.setAttribute("method", "post"), e.setAttribute("enctype", "multipart/form-data"), e.setAttribute("encoding", "multipart/form-data"), e.submit()
|
|
}, this.createurl = function (e) {
|
|
var t = this.Settings.apiurl,
|
|
i = "?";
|
|
return t.indexOf("?") >= 0 && (i = "&"), t += i + "operation=" + e, i = "&", void 0 != this.schemeid && (t += i + "schemeid=" + this.schemeid), void 0 != this.processid && (t += i + "processid=" + this.processid), void 0 != this.schemecode && (t += i + "schemecode=" + this.schemecode), t
|
|
}, this.validate = function () {
|
|
var e = void 0,
|
|
i = $.grep(t.data.Activities, function (e) {
|
|
return 1 == e.IsInitial
|
|
});
|
|
return 1 != i.length && (e = WorkflowDesignerConstants.ErrorActivityIsInitialCountText), e
|
|
}, this.destroy = function () {
|
|
this.schemecode = void 0, this.processid = void 0, this.schemeid = void 0, this.data = void 0, this.Graph.destroy()
|
|
}, this.compile = function (e, i) {
|
|
e = {
|
|
Name: e.Name,
|
|
Type: e.Type,
|
|
IsGlobal: e.IsGlobal,
|
|
ActionCode: e.ActionCode,
|
|
Usings: e.Usings
|
|
};
|
|
var n = new Array;
|
|
n.push({
|
|
name: "schemecode",
|
|
value: this.schemecode
|
|
}), n.push({
|
|
name: "processid",
|
|
value: this.processid
|
|
}), n.push({
|
|
name: "schemeid",
|
|
value: this.schemeid
|
|
}), n.push({
|
|
name: "operation",
|
|
value: "compile"
|
|
}), n.push({
|
|
name: "data",
|
|
value: JSON.stringify(e)
|
|
});
|
|
$.ajax({
|
|
url: this.Settings.apiurl,
|
|
data: n,
|
|
async: !0,
|
|
type: "post",
|
|
success: function (e) {
|
|
try {
|
|
e = JSON.parse(e)
|
|
} catch (n) {
|
|
t.error(e)
|
|
}
|
|
i && setTimeout(function () {
|
|
i(e)
|
|
}, 100)
|
|
}
|
|
})
|
|
}, this.getemptytype = function (e, t) {
|
|
var i = new Array;
|
|
i.push({
|
|
name: "operation",
|
|
value: "getemptytype"
|
|
}), i.push({
|
|
name: "data",
|
|
value: JSON.stringify(e)
|
|
});
|
|
$.ajax({
|
|
url: this.Settings.apiurl,
|
|
data: i,
|
|
async: !0,
|
|
type: "post",
|
|
success: function (e) {
|
|
t && setTimeout(function () {
|
|
t(e)
|
|
}, 100)
|
|
}
|
|
})
|
|
}
|
|
hideCodedActions = !this.Settings.ShowCodedOptions;
|
|
}
|
|
|
|
function WorkflowDesignerActivity() {
|
|
this.type = "WorkflowDesignerActivity", this.init = function (e) {
|
|
this.designer = e, this.Layer = new Kinetic.Layer, this.designer.Stage.add(this.Layer), this.Layer.setZIndex(1), this.ImageCreateTransitionAndActivity = new Image, this.ImageCreateTransitionAndActivity.src = this.designer.Settings.imagefolder + "designer.createat.png", this.ImageCreateTransition = new Image, this.ImageCreateTransition.src = this.designer.Settings.imagefolder + "designer.createt.png", this.ImageDeleteActivity = new Image, this.ImageDeleteActivity.src = this.designer.Settings.imagefolder + "designer.delete.png"
|
|
}, this.ItemControls = new Array, this.draw = function () {
|
|
null != this.ItemControls && this.ItemControls.forEach(function (e) {
|
|
e.control.destroy()
|
|
}), this.ItemControls = new Array;
|
|
var e = this;
|
|
void 0 != this.designer.data.Activities && this.designer.data.Activities.forEach(function (t) {
|
|
var i, n;
|
|
if ("" != t.DesignerSettings.X && "" != t.DesignerSettings.Y) i = Number(t.DesignerSettings.X), n = Number(t.DesignerSettings.Y);
|
|
else {
|
|
var o = this.GetDefaultPosition();
|
|
i = o.x, n = o.y
|
|
}
|
|
var r = new WorkflowDesignerActivityControl({
|
|
x: i,
|
|
y: n,
|
|
item: t,
|
|
designer: e.designer,
|
|
manager: e
|
|
});
|
|
e.ItemControls.push(r), r.Draw(), r.Sync()
|
|
}), this.Layer.batchDraw()
|
|
}, this.CreateNewActivity = function (e, t) {
|
|
void 0 == e && (e = this.GetDefaultPosition()), void 0 == t && (t = {
|
|
IsAutoSchemeUpdate: !0,
|
|
IsForSetState: !0
|
|
}), void 0 == t.Name && (t.Name = this.GetDefaultName()), 0 == this.designer.data.Activities.length && (t.IsInitial = !0), t.DesignerSettings && (t.DesignerSettings = new {
|
|
X: e.x,
|
|
Y: e.y
|
|
});
|
|
var i = new WorkflowDesignerActivityControl({
|
|
x: e.x,
|
|
y: e.y,
|
|
item: t,
|
|
designer: this.designer,
|
|
manager: this
|
|
});
|
|
return this.designer.data.Activities.push(t), this.ItemControls.push(i), i.Draw(), i.Sync(), i
|
|
}, this.GetDefaultName = function () {
|
|
for (var e = WorkflowDesignerConstants.ActivityNamePrefix, t = 1, i = 0; i < this.designer.data.Activities.length; i++) {
|
|
var n = this.designer.data.Activities[i];
|
|
n.Name == e + t && (t++, i = -1)
|
|
}
|
|
return e + t
|
|
}, this.GetDefaultPosition = function () {
|
|
for (var e = this.designer.CorrectPossition({
|
|
x: 50,
|
|
y: 50
|
|
}, this.Layer), t = this.designer.Settings.DefaultMoveStep / this.Layer.getScaleX(), i = 0; i < this.ItemControls.length; i++) {
|
|
var n = this.ItemControls[i].control.getPosition();
|
|
n.x == e.x && n.y == e.y && (e.x += t, e.y += t, i = -1)
|
|
}
|
|
return e
|
|
}, this.find = function (e) {
|
|
if ("object" == typeof e && void 0 != e.Name) return this.find(e.Name);
|
|
for (var t = 0; t < this.ItemControls.length; t++)
|
|
if (this.ItemControls[t].GetName() == e) return this.ItemControls[t]
|
|
}, this.getIntersectingActivity = function (e) {
|
|
for (var t = 0; t < this.ItemControls.length; t++) {
|
|
var i = this.ItemControls[t];
|
|
if (i.getIntersectingActivity(e)) return i
|
|
}
|
|
}, this.LayerSetOffset = function (e) {
|
|
this.Layer.setOffset(e)
|
|
}, this.LayerScale = function (e) {
|
|
this.Layer.setScale({
|
|
x: this.Layer.getScale().x + e,
|
|
y: this.Layer.getScale().y + e
|
|
})
|
|
}, this.LayerScaleNorm = function (e) {
|
|
this.Layer.setScale({
|
|
x: 1,
|
|
y: 1
|
|
}), this.Layer.setOffset({
|
|
x: 0,
|
|
y: 0
|
|
})
|
|
}, this.redrawTransitions = function () {
|
|
return void 0 == this.cTransition && (this.cTransition = this.designer.GetComponentByType("WorkflowDesignerTransition")), this.cTransition.batchDraw()
|
|
}, this.batchDraw = function () {
|
|
this.Layer.batchDraw()
|
|
}, this.DeselectAll = function () {
|
|
this.ItemControls.forEach(function (e) {
|
|
e.Deselect()
|
|
})
|
|
}, this.GetSizeForSaveAsImage = function (e) {
|
|
for (var t = 0; t < this.ItemControls.length; t++) {
|
|
var i = this.ItemControls[t],
|
|
n = i.rectangle.getAbsolutePosition(),
|
|
o = n.x,
|
|
r = n.y,
|
|
a = o + i.rectangle.getWidth() * this.Layer.getScaleX(),
|
|
s = r + i.rectangle.getHeight() * this.Layer.getScaleX();
|
|
o < e.x1 && (e.x1 = o), r < e.y1 && (e.y1 = r), a > e.x2 && (e.x2 = a), s > e.y2 && (e.y2 = s)
|
|
}
|
|
return e
|
|
}, this.GetSelected = function () {
|
|
var e = new Array;
|
|
return this.ItemControls.forEach(function (t) {
|
|
t.selected && e.push(t)
|
|
}), e
|
|
}, this.SelectByPosition = function (e) {
|
|
this.ItemControls.forEach(function (t) {
|
|
t.getIntersectingActivityRect(e) && t.Select()
|
|
})
|
|
}, this.SelectByItem = function (e) {
|
|
this.ItemControls.forEach(function (t) {
|
|
t.item == e && t.Select()
|
|
})
|
|
}, this.ObjectMove = function (e) {
|
|
this.ItemControls.forEach(function (t) {
|
|
t.selected && e.sender != t && t.ObjectMove(e.changepos)
|
|
}), this.redrawTransitions()
|
|
}, this.createTransitionAndActivity = function (e) {
|
|
var t = {
|
|
x: e.control.getX() + 2 * e.rectangle.attrs.width,
|
|
y: e.control.getY()
|
|
},
|
|
i = this.CreateNewActivity(t),
|
|
n = this.designer.GetComponentByType("WorkflowDesignerTransition");
|
|
n.CreateNewTransition(e, i), this.designer.redrawAll()
|
|
}, this.createTransition = function (e) {
|
|
var t = this.designer.GetComponentByType("WorkflowDesignerTransition");
|
|
return t.CreateNewTransition(e)
|
|
}
|
|
}
|
|
|
|
function WorkflowDesignerActivityControl(e) {
|
|
var t = this;
|
|
this.manager = e.manager, this.designer = e.designer, this.x = e.x, this.y = e.y, this.item = e.item, this.control = void 0, this.rectangle = void 0, this.text = void 0, this.deleteButton = void 0, this.createTransitionAndActivityButton = void 0, this.createTransitionButton = void 0, this.selected = !1, this.dependentTransitions = new Array, this.getX = function () {
|
|
return this.rectangle.attrs.x + this.control.attrs.x
|
|
}, this.getY = function () {
|
|
return this.rectangle.attrs.y + this.control.attrs.y
|
|
}, this.GetName = function () {
|
|
return this.item.Name
|
|
}, this.SetName = function (e) {
|
|
this.item.Name = e
|
|
}, this.Draw = function () {
|
|
var i = t.designer.Settings;
|
|
t.control = new Kinetic.Group({
|
|
x: e.x,
|
|
y: e.y,
|
|
rotationDeg: 0,
|
|
draggable: !0,
|
|
dragBoundFunc: function (e) {
|
|
var n = (i.DefaultMoveStep * t.manager.Layer.getScaleX(), i.DefaultMoveStep * t.manager.Layer.getScaleY()),
|
|
e = {
|
|
x: Math.round(e.x / n) * n,
|
|
y: Math.round(e.y / n) * n
|
|
};
|
|
if (t.selected) {
|
|
var o = this.getAbsolutePosition();
|
|
t.manager.ObjectMove({
|
|
sender: t,
|
|
changepos: {
|
|
x: e.x - o.x,
|
|
y: e.y - o.y
|
|
}
|
|
})
|
|
}
|
|
return e
|
|
}
|
|
});
|
|
var n = WorkflowDesignerConstants.ActivityColor;
|
|
t.item.IsFinal && (n = WorkflowDesignerConstants.ActivityFinalColor), t.item.IsInitial && (n = WorkflowDesignerConstants.ActivityInitialColor), t.designer.GetCurrentActivity() == t.item.Name && (n = WorkflowDesignerConstants.ActivityCurrentColor), t.rectangle = new Kinetic.Rect({
|
|
x: 0,
|
|
y: 0,
|
|
width: this.designer.Settings.DefaultActivityWidth,
|
|
height: this.designer.Settings.DefaultActivityHeight,
|
|
stroke: "black",
|
|
strokeWidth: 1,
|
|
fill: n,
|
|
shadowOpacity: .5
|
|
}), t.text = new Kinetic.Text({
|
|
x: 2,
|
|
y: 2,
|
|
text: this.GetName(),
|
|
fontSize: 12,
|
|
fontFamily: "Calibri",
|
|
fontStyle: "bold",
|
|
fill: "black"
|
|
}), t.text.setX((t.rectangle.attrs.width - t.text.getWidth()) / 2), t.text.setY((t.rectangle.attrs.height - t.text.getHeight()) / 2 - 6), void 0 == t.item.State && (t.item.State = ""), t.stateText = new Kinetic.Text({
|
|
x: 2,
|
|
y: 2,
|
|
text: WorkflowDesignerConstants.ActivityFormLabel.State + ": " + t.item.State,
|
|
fontSize: 10,
|
|
fontFamily: "Calibri",
|
|
fill: "black"
|
|
}), t.stateText.setX((t.rectangle.attrs.width - t.stateText.getWidth()) / 2), t.stateText.setY(t.text.getY() + 15), t.deleteButton = new Kinetic.Image({
|
|
x: t.rectangle.attrs.width - 13,
|
|
y: 3,
|
|
image: t.manager.ImageDeleteActivity,
|
|
width: 10,
|
|
height: 10
|
|
}), t.createTransitionAndActivityButton = new Kinetic.Image({
|
|
x: t.rectangle.attrs.width - 13,
|
|
y: t.rectangle.attrs.height - 26,
|
|
image: t.manager.ImageCreateTransitionAndActivity,
|
|
width: 10,
|
|
height: 10
|
|
}), t.createTransitionButton = new Kinetic.Image({
|
|
x: t.rectangle.attrs.width - 13,
|
|
y: t.rectangle.attrs.height - 13,
|
|
image: t.manager.ImageCreateTransition,
|
|
width: 10,
|
|
height: 10
|
|
}), t.control.add(t.rectangle), t.control.add(t.text), t.control.add(t.stateText), t.control.add(t.deleteButton), t.control.add(t.createTransitionAndActivityButton), t.control.add(t.createTransitionButton), this.control.on("dragend", this.Sync), this.control.on("dragmove", this._onMove), this.control.on("click", this._onClick), this.control.on("dblclick", this._onDblClick), this.deleteButton.on("click", this._onDelete), this.createTransitionAndActivityButton.on("click", this._onCreateTransitionAndActivity), this.createTransitionButton.on("click", this._onCreateTransition), t.manager.Layer.add(t.control)
|
|
}, this.Delete = function () {
|
|
this.control.destroy(), this.designer.data.Activities.splice(this.designer.data.Activities.indexOf(this.item), 1), this.manager.ItemControls.splice(this.manager.ItemControls.indexOf(this), 1);
|
|
for (var e = new Array, t = 0; t < this.dependentTransitions.length; t++) e.push(this.dependentTransitions[t]);
|
|
for (var t = 0; t < e.length; t++) e[t].Delete()
|
|
}, this.Select = function () {
|
|
this.rectangle.setStrokeWidth(4), this.rectangle.setOpacity(.5), this.rectangle.setStroke(WorkflowDesignerConstants.SelectColor), this.selected = !0
|
|
}, this.Deselect = function () {
|
|
this.rectangle.setStrokeWidth(1), this.rectangle.setOpacity(1), this.rectangle.setStroke("black"), this.selected = !1
|
|
}, this.ObjectMove = function (e) {
|
|
var i = this.control.getAbsolutePosition();
|
|
if (i.x += e.x, i.y += e.y, this.control.setAbsolutePosition(i), this.Sync(), !(t.dependentTransitions.length < 1))
|
|
for (var n = 0; n < t.dependentTransitions.length; n++) t.dependentTransitions[n].Draw()
|
|
}, this._onMove = function () {
|
|
if (!(t.dependentTransitions.length < 1)) {
|
|
for (var e = 0; e < t.dependentTransitions.length; e++) {
|
|
var i = t.dependentTransitions[e];
|
|
i.Draw()
|
|
}
|
|
t.manager.redrawTransitions()
|
|
}
|
|
}, this._onClick = function (e) {
|
|
var i = t.selected;
|
|
e.evt.ctrlKey || t.designer.DeselectAll(), i ? t.Deselect() : t.Select(), t.manager.batchDraw()
|
|
}, this._onDblClick = function () {
|
|
t.designer.DeselectAll(), t.Select(), t.manager.batchDraw(), t.ShowProperties()
|
|
}, this._onDelete = function () {
|
|
confirm(WorkflowDesignerConstants.DeleteConfirm) && (t.Delete(), t.designer.redrawAll())
|
|
}, this._onCreateTransitionAndActivity = function () {
|
|
t.manager.createTransitionAndActivity(t)
|
|
}, this._onCreateTransition = function () {
|
|
t.manager.createTransition(t)
|
|
}, this.RegisterTransition = function (e) {
|
|
for (var t = !1, i = 0; i < this.dependentTransitions.length; i++)
|
|
if (this.dependentTransitions[i].GetName() == e.GetName()) {
|
|
t = !0;
|
|
break
|
|
}
|
|
t || this.dependentTransitions.push(e)
|
|
}, this.UnregisterTransition = function (e) {
|
|
for (var t = new Array, i = 0; i < this.dependentTransitions.length; i++) this.dependentTransitions[i].GetName() != e.GetName() && t.push(this.dependentTransitions[i]);
|
|
this.dependentTransitions = t
|
|
}, this.RegisterTransition = function (e) {
|
|
for (var t = !1, i = 0; i < this.dependentTransitions.length; i++)
|
|
if (this.dependentTransitions[i].GetName() == e.GetName()) {
|
|
t = !0;
|
|
break
|
|
}
|
|
t || this.dependentTransitions.push(e)
|
|
}, this.UnregisterTransition = function (e) {
|
|
for (var t = new Array, i = 0; i < this.dependentTransitions.length; i++) this.dependentTransitions[i].GetName() != e.GetName() && t.push(this.dependentTransitions[i]);
|
|
this.dependentTransitions = t
|
|
}, this.getRectPos = function () {
|
|
var e = this.rectangle.getAbsolutePosition(),
|
|
t = e.x,
|
|
i = e.y,
|
|
n = t + this.rectangle.getWidth() * this.manager.Layer.getScaleX(),
|
|
o = i + this.rectangle.getHeight() * this.manager.Layer.getScaleY();
|
|
return {
|
|
xl: t,
|
|
yl: i,
|
|
xr: n,
|
|
yr: o
|
|
}
|
|
}, this.getIntersectingActivity = function (e) {
|
|
var t = this.getRectPos();
|
|
return e.x >= t.xl && e.x < t.xr && e.y >= t.yl && e.y < t.yr
|
|
}, this.getIntersectingActivityRect = function (e) {
|
|
var t = this.getRectPos();
|
|
return e.xl > t.xr || e.xr < t.xl || e.yl > t.yr || e.yr < t.yl ? !1 : !0
|
|
}, this.ShowProperties = function () {
|
|
var e = WorkflowDesignerConstants.ActivityFormLabel,
|
|
i = [{
|
|
name: e.ImpOrder,
|
|
code: "impOrder",
|
|
field: "Order",
|
|
type: "input",
|
|
width: "40px"
|
|
}, {
|
|
name: e.ImpAction,
|
|
code: "impAction",
|
|
field: "ActionName",
|
|
type: "select",
|
|
datasource: t.designer.getActionNames()
|
|
}, {
|
|
name: e.ImpActionParameter,
|
|
code: "impparam",
|
|
field: "ActionParameter",
|
|
type: "json"
|
|
}],
|
|
n = {
|
|
type: "form",
|
|
title: e.Title,
|
|
width: "800px",
|
|
data: this.item,
|
|
elements: [{
|
|
name: e.Name,
|
|
field: "Name",
|
|
type: "input"
|
|
}, {
|
|
name: e.State,
|
|
field: "State",
|
|
type: "input"
|
|
}, {
|
|
name: e.IsInitial,
|
|
field: "IsInitial",
|
|
type: "checkbox"
|
|
}, {
|
|
name: e.IsFinal,
|
|
field: "IsFinal",
|
|
type: "checkbox"
|
|
}, {
|
|
name: e.IsForSetState,
|
|
field: "IsForSetState",
|
|
type: "checkbox"
|
|
}, {
|
|
name: e.IsAutoSchemeUpdate,
|
|
field: "IsAutoSchemeUpdate",
|
|
type: "checkbox"
|
|
}, {
|
|
name: e.Implementation,
|
|
field: "Implementation",
|
|
type: "table",
|
|
elements: i,
|
|
onrowadded: function (e) {
|
|
var t = e.find("[name=impOrder]");
|
|
"" === t[0].value && (t[0].value = e.parent().children().length)
|
|
}
|
|
}, {
|
|
name: e.PreExecutionImplementation,
|
|
field: "PreExecutionImplementation",
|
|
type: "table",
|
|
elements: i,
|
|
onrowadded: function (e) {
|
|
var t = e.find("[name=impOrder]");
|
|
"" === t[0].value && (t[0].value = e.parent().children().length)
|
|
}
|
|
}],
|
|
designer: t.designer
|
|
},
|
|
o = new WorkflowDesignerForm(n),
|
|
r = function (e, i) {
|
|
var n = !0;
|
|
return n &= e.CheckRequired([i], ["Name"], WorkflowDesignerConstants.FieldIsRequired), t.designer.data.Activities.forEach(function (o) {
|
|
o != t.item && o.Name == i.Name && (n = !1, e.ControlAddError(i.control_Name, WorkflowDesignerConstants.FieldMustBeUnique))
|
|
}), e.CheckRequired(i.Implementation, ["ActionName", "Order"], WorkflowDesignerConstants.FieldIsRequired) || (n = !1), e.CheckRequired(i.PreExecutionImplementation, ["ActionName", "Order"], WorkflowDesignerConstants.FieldIsRequired) || (n = !1), n
|
|
},
|
|
a = function (e) {
|
|
return r(o, e) ? (o.ClearTempField(e), t.item.Name = e.Name, t.item.State = e.State, t.item.IsInitial = e.IsInitial, t.item.IsFinal = e.IsFinal, t.item.IsForSetState = e.IsForSetState, t.item.IsAutoSchemeUpdate = e.IsAutoSchemeUpdate, t.item.Implementation = e.Implementation, t.item.PreExecutionImplementation = e.PreExecutionImplementation, WorkflowDesignerCommon.DataCorrection(t.designer.data), t.designer.Draw(t.designer.data), !0) : !1
|
|
};
|
|
o.showModal(a)
|
|
}, this.Sync = function () {
|
|
void 0 == t.item.DesignerSettings && (t.item.DesignerSettings = {});
|
|
var e = t.control.getPosition();
|
|
t.item.DesignerSettings.X = e.x, t.item.DesignerSettings.Y = e.y
|
|
}
|
|
}
|
|
|
|
function WorkflowDesignerBackground() {
|
|
this.type = "WorkflowDesignerBackground", this.init = function (e) {
|
|
var t = this;
|
|
this.designer = e, this.BackgroundLayer = new Kinetic.Layer, this.designer.Stage.add(this.BackgroundLayer), this.BackgroundLayer.setZIndex(0), this.SelectionLayer = new Kinetic.Layer, this.designer.Stage.add(this.SelectionLayer), this.SelectionLayer.setZIndex(1);
|
|
var i = new Image;
|
|
i.onload = function () {
|
|
t.RectBG.setFillPatternImage(i), t.BackgroundLayer.batchDraw()
|
|
}, i.src = this.designer.Settings.imagefolder + "grid.gif", this.RectBG = new Kinetic.Rect({
|
|
x: 0,
|
|
y: 0,
|
|
width: 5e3,
|
|
height: 5e3,
|
|
draggable: !1,
|
|
dragBoundFunc: function (e) {
|
|
var i = (t.designer.Settings.DefaultMoveStep * t.BackgroundLayer.getScaleX(), t.designer.Settings.DefaultMoveStep * t.BackgroundLayer.getScaleY()),
|
|
n = {
|
|
x: Math.round(e.x / i) * i,
|
|
y: Math.round(e.y / i) * i
|
|
};
|
|
return t.designer.GraphLayerSetOffset(-n.x / t.BackgroundLayer.getScaleX(), -n.y / t.BackgroundLayer.getScaleY()), n
|
|
},
|
|
designerparam: "background"
|
|
}), this.BackgroundLayer.add(this.RectBG), this.BackgroundLayer.batchDraw(), this.designer.Stage.on("mousedown.background", function (e) {
|
|
t._movemodeenabled || "background" != e.target.attrs.designerparam || (t._mousedownpos = t.designer.CorrectPossition({
|
|
x: e.evt.layerX,
|
|
y: e.evt.layerY
|
|
}, t.SelectionLayer))
|
|
}), this.designer.Stage.on("mousemove.backgrounde", function (e) {
|
|
if (!t._movemodeenabled && t._mousedownpos) {
|
|
var i = t.designer.CorrectPossition({
|
|
x: e.evt.layerX,
|
|
y: e.evt.layerY
|
|
}, t.SelectionLayer);
|
|
t.DrawSelectionRect(i)
|
|
}
|
|
}), this.designer.Stage.on("mouseup.background", function (e) {
|
|
if (!t._movemodeenabled && void 0 != t._mousedownpos) {
|
|
var i = t.getSelectionRectPos();
|
|
void 0 == i ? e.evt.ctrlKey || t.designer.DeselectAll() : (Math.abs(i.xl - i.xr) > 10 || Math.abs(i.yl - i.yr) > 10) && (t.designer.DeselectAll(), t.designer.ComponentsExecute("SelectByPosition", i))
|
|
}
|
|
t._mousedownpos = void 0, t.DeleteSelectionRect()
|
|
})
|
|
}, this.setMoveModeEnabled = function (e) {
|
|
this._movemodeenabled = e, this.RectBG.setDraggable(this._movemodeenabled)
|
|
}, this.LayerScale = function (e) {
|
|
this.BackgroundLayer.setScale({
|
|
x: this.BackgroundLayer.getScale().x + e,
|
|
y: this.BackgroundLayer.getScale().y + e
|
|
})
|
|
}, this.LayerScaleNorm = function (e) {
|
|
this.BackgroundLayer.setScale({
|
|
x: 1,
|
|
y: 1
|
|
}), this.SelectionLayer.setScale({
|
|
x: 1,
|
|
y: 1
|
|
}), this.RectBG.setPosition({
|
|
x: 0,
|
|
y: 0
|
|
})
|
|
}, this.DrawSelectionRect = function (e) {
|
|
this.RectSelection ? (this.RectSelection.setWidth(e.x - this._mousedownpos.x), this.RectSelection.setHeight(e.y - this._mousedownpos.y)) : (this.RectSelection = new Kinetic.Rect({
|
|
x: this._mousedownpos.x,
|
|
y: this._mousedownpos.y,
|
|
width: e.x - this._mousedownpos.x,
|
|
height: e.y - this._mousedownpos.y,
|
|
draggable: !1,
|
|
fill: "#66CCFF",
|
|
opacity: .2
|
|
}), this.SelectionLayer.add(this.RectSelection)), this.SelectionLayer.batchDraw()
|
|
}, this.DeleteSelectionRect = function (e) {
|
|
this.RectSelection && (this.RectSelection.destroy(), this.RectSelection = void 0, this.SelectionLayer.batchDraw())
|
|
}, this.getSelectionRectPos = function () {
|
|
if (void 0 != this.RectSelection) {
|
|
var e = this.RectSelection.getAbsolutePosition(),
|
|
t = e.x,
|
|
i = e.y,
|
|
n = t + this.RectSelection.getWidth() * this.SelectionLayer.getScaleX(),
|
|
o = i + this.RectSelection.getHeight() * this.SelectionLayer.getScaleX();
|
|
return {
|
|
xl: Math.min(t, n),
|
|
yl: Math.min(i, o),
|
|
xr: Math.max(t, n),
|
|
yr: Math.max(i, o)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function WorkflowDesignerKeyboard() {
|
|
this.type = "WorkflowDesignerKeyboard", this.init = function (e) {
|
|
this.designer = e
|
|
}
|
|
}
|
|
|
|
function WorkflowDesignerToolbar() {
|
|
this.type = "WorkflowDesignerToolbar";
|
|
var e = this;
|
|
this.init = function (t) {
|
|
this.designer = t, this.Layer = new Kinetic.Layer, this.designer.Stage.add(this.Layer), this.Layer.setZIndex(4);
|
|
var i = 40,
|
|
n = 10,
|
|
o = 0;
|
|
this.Items.forEach(function (t) {
|
|
if (t.Hide)
|
|
return;
|
|
t.index = o, o++, t.separator || (t.ImageToolbar = new Image, t.ImageToolbar.onload = function () {
|
|
t.cImageToolbar = new Kinetic.Image({
|
|
x: i + 40 * t.index,
|
|
y: n,
|
|
image: t.ImageToolbar,
|
|
width: 32,
|
|
height: 32,
|
|
strokeWidth: 0
|
|
}), t.cImageToolbar.on("click", t.click), e.Layer.add(t.cImageToolbar), WorkflowDesignerTooltip(e.Layer, t.cImageToolbar, t.title), e.Layer.batchDraw()
|
|
}, t.ImageToolbar.src = e.designer.Settings.imagefolder + t.img, t.imgactive && (t.ImageActiveToolbar = new Image, t.ImageActiveToolbar.src = e.designer.Settings.imagefolder + t.imgactive))
|
|
}), this.CreateInfoBlock({
|
|
x: i + 40 * (this.Items[this.Items.length - 1].index + 1),
|
|
y: n - 7
|
|
});
|
|
var r = this.GetWorkflowDesignerBackground();
|
|
r.RectBG.setDraggable(!1)
|
|
}, this.draw = function () {
|
|
this.GraphRedrawAll()
|
|
}, this.GraphRedrawAll = function () {
|
|
this.UpdateInfoBlock(), this.Layer.batchDraw()
|
|
}, this.CreateInfoBlock = function (e) {
|
|
this.infoText = new Kinetic.Text({
|
|
text: this.GetInfoBlockText(),
|
|
fontFamily: "Calibri",
|
|
fontSize: 12,
|
|
padding: 5,
|
|
fill: "black"
|
|
}), this.info = new Kinetic.Group(e), this.info.add(this.infoText), this.Layer.add(this.info)
|
|
}, this.UpdateInfoBlock = function (e) {
|
|
this.infoText.setText(this.GetInfoBlockText())
|
|
}, this.GetInfoBlockText = function () {
|
|
var e = 0,
|
|
t = 0,
|
|
i = 0;
|
|
return void 0 != this.designer.data && (e = this.designer.data.Activities.length, t = this.designer.data.Transitions.length, i = this.designer.data.Commands.length), WorkflowDesignerConstants.InfoBlockLabel.Activity + e + "\r\n" + WorkflowDesignerConstants.InfoBlockLabel.Transition + t + "\r\n" + WorkflowDesignerConstants.InfoBlockLabel.Command + i
|
|
}, this.ToolbarMovePress = function () {
|
|
var e = this.GetWorkflowDesignerBackground();
|
|
e.setMoveModeEnabled(!e._movemodeenabled);
|
|
var t = this.GetItemByCode("move").cImageToolbar;
|
|
e._movemodeenabled ? (t.setStrokeWidth(4), t.setStrokeEnabled(!0), t.setStroke(WorkflowDesignerConstants.SelectColor)) : (t.setStrokeEnabled(!1), t.setStroke("black")), this.Layer.batchDraw()
|
|
}, this.GetWorkflowDesignerBackground = function () {
|
|
return this.designer.GetComponentByType("WorkflowDesignerBackground")
|
|
}, this.CreateActivity = function () {
|
|
var e = this.designer.GetComponentByType("WorkflowDesignerActivity");
|
|
e.CreateNewActivity(), this.designer.redrawAll()
|
|
}, this.AutoArrangement = function () {
|
|
if (0 != e.designer.data.Activities.length) {
|
|
var t = new Array;
|
|
e.designer.data.Activities.forEach(function (e) {
|
|
e.IsInitial && t.push(e)
|
|
}), e.designer.data.Activities.forEach(function (i) {
|
|
if (!i.IsInitial) {
|
|
for (var n = !0, o = 0; o < e.designer.data.Transitions.length; o++) {
|
|
var r = e.designer.data.Transitions[o];
|
|
if ("Direct" == r.Classifier && r.To == i) {
|
|
n = !1;
|
|
break
|
|
}
|
|
}
|
|
n && t.push(i)
|
|
}
|
|
}), 0 == t.length && t.push(e.designer.data.Activities[0]);
|
|
var i = {
|
|
x: 80,
|
|
y: 80
|
|
},
|
|
n = {
|
|
x: 250,
|
|
y: 150
|
|
},
|
|
o = Array(),
|
|
r = function (t, i, a) {
|
|
var s = {
|
|
x: i.x,
|
|
y: i.y
|
|
};
|
|
a || (s.x += n.x);
|
|
for (var d = new Array, l = 0; l < t.length; l++) {
|
|
var c = t[l];
|
|
void 0 == c.DesignerSettings && (c.DesignerSettings = {}), !a && $.inArray(c, o) >= 0 || (c.DesignerSettings.X = s.x, o.push(c), d.push(c))
|
|
}
|
|
for (var l = 0; l < d.length; l++) {
|
|
var c = d[l];
|
|
l > 0 && (s.y += n.y);
|
|
var h = new Array;
|
|
e.designer.data.Transitions.forEach(function (e) {
|
|
"Direct" == e.Classifier && e.From == c && h.push(e.To)
|
|
}), c.DesignerSettings.Y = s.y;
|
|
var m = r(h, {
|
|
x: s.x,
|
|
y: s.y
|
|
});
|
|
s.y = m.y
|
|
}
|
|
return {
|
|
x: s.x,
|
|
y: s.y
|
|
}
|
|
};
|
|
r(t, i, !0), e.designer.data.Transitions.forEach(function (e) {
|
|
void 0 == e.DesignerSettings && (e.DesignerSettings = {}), e.DesignerSettings.Bending = 0
|
|
}), e.designer.Draw(e.designer.data)
|
|
}
|
|
}, this.CopySelectedGenUniqueValue = function (e, t, i) {
|
|
for (var n = e, o = 1; !0; o++) {
|
|
for (var r = !1, a = 0; a < t.length; a++)
|
|
if (t[a][i] == n) {
|
|
r = !0;
|
|
break
|
|
}
|
|
if (!r) break;
|
|
n = e + "_" + o
|
|
}
|
|
return n
|
|
}, this.CopySelected = function () {
|
|
var t = this.designer.GetComponentByType("WorkflowDesignerActivity"),
|
|
i = this.designer.GetComponentByType("WorkflowDesignerTransition"),
|
|
n = t.GetSelected(),
|
|
o = i.GetSelected(),
|
|
r = [];
|
|
n.forEach(function (t) {
|
|
var i = JSON.parse(JSON.stringify(t.item));
|
|
i.DesignerSettings.Y += 150, i.Name = e.CopySelectedGenUniqueValue(i.Name, e.designer.data.Activities, "Name"), r.push({
|
|
oldItem: t.item,
|
|
newItem: i
|
|
}), e.designer.data.Activities.push(i)
|
|
});
|
|
var a = [];
|
|
o.forEach(function (t) {
|
|
for (var i = t.item.From, n = t.item.To, o = 0; o < r.length; o++) i == r[o].oldItem && (i = r[o].newItem), n == r[o].oldItem && (n = r[o].newItem);
|
|
var s = JSON.parse(JSON.stringify(t.item));
|
|
s.Name = e.CopySelectedGenUniqueValue(s.Name, e.designer.data.Transitions, "Name"), s.From = i, s.To = n, a.push({
|
|
oldItem: t.item,
|
|
newItem: s
|
|
}), e.designer.data.Transitions.push(s)
|
|
}), WorkflowDesignerCommon.DataCorrection(e.designer.data), e.designer.Draw(e.designer.data), r.forEach(function (e) {
|
|
t.SelectByItem(e.newItem)
|
|
}), a.forEach(function (e) {
|
|
i.SelectByItem(e.newItem)
|
|
})
|
|
}, this.EditLocalization = function () {
|
|
var t = WorkflowDesignerConstants.LocalizationFormLabel,
|
|
i = {
|
|
type: "table",
|
|
title: t.Title,
|
|
width: "800px",
|
|
data: this.designer.data.Localization,
|
|
datadefault: {
|
|
Culture: "en-US",
|
|
Type: "State"
|
|
},
|
|
elements: [{
|
|
name: t.ObjectName,
|
|
field: "ObjectName",
|
|
type: "input"
|
|
}, {
|
|
name: t.Type,
|
|
field: "Type",
|
|
type: "select",
|
|
displayfield: "Name",
|
|
valuefield: "Value",
|
|
datasource: [{
|
|
Name: t.Types[0],
|
|
Value: "Command"
|
|
}, {
|
|
Name: t.Types[1],
|
|
Value: "State"
|
|
}, {
|
|
Name: t.Types[2],
|
|
Value: "Parameter"
|
|
}]
|
|
}, {
|
|
name: t.IsDefault,
|
|
field: "IsDefault",
|
|
type: "checkbox"
|
|
}, {
|
|
name: t.Culture,
|
|
field: "Culture",
|
|
type: "input"
|
|
}, {
|
|
name: t.Value,
|
|
field: "Value",
|
|
type: "input"
|
|
}]
|
|
},
|
|
n = new WorkflowDesignerForm(i),
|
|
o = function (t, o) {
|
|
return n.CheckRequired(t, ["ObjectName", "Type", "Culture", "Value"], WorkflowDesignerConstants.FieldIsRequired) && n.CheckUnique(t, ["ObjectName", "Type", "Culture"], WorkflowDesignerConstants.FieldMustBeUnique) ? (n.ClearTempField(t), e.SyncTable(e.designer.data.Localization, t, i), !0) : !1
|
|
};
|
|
n.showModal(o)
|
|
}, this.EditTimer = function () {
|
|
var t = WorkflowDesignerConstants.TimerFormLabel,
|
|
i = {
|
|
type: "table",
|
|
title: t.Title,
|
|
width: "800px",
|
|
data: this.designer.data.Timers,
|
|
keyproperty: "Name",
|
|
elements: [{
|
|
name: t.Name,
|
|
field: "Name",
|
|
type: "input"
|
|
}, {
|
|
name: t.Type,
|
|
field: "Type",
|
|
type: "select",
|
|
datasource: this.designer.data.AdditionalParams.TimerTypes
|
|
}, {
|
|
name: t.Value,
|
|
field: "Value",
|
|
type: "input"
|
|
}, {
|
|
name: t.NotOverrideIfExists,
|
|
field: "NotOverrideIfExists",
|
|
type: "checkbox"
|
|
}]
|
|
},
|
|
n = new WorkflowDesignerForm(i),
|
|
o = function (t, o) {
|
|
return n.CheckRequired(t, ["Name", "Type", "Value"], WorkflowDesignerConstants.FieldIsRequired) && n.CheckUnique(t, ["Name"], WorkflowDesignerConstants.FieldMustBeUnique) ? (n.ClearTempField(t), void 0 == e.designer.data.Timers && (e.designer.data.Timers = []), e.SyncTable(e.designer.data.Timers, t, i), !0) : !1
|
|
};
|
|
n.showModal(o)
|
|
}, this.EditActors = function () {
|
|
var t = WorkflowDesignerConstants.ActorFormLabel,
|
|
i = {
|
|
type: "table",
|
|
title: t.Title,
|
|
width: "800px",
|
|
data: this.designer.data.Actors,
|
|
keyproperty: "Name",
|
|
elements: [{
|
|
name: t.Name,
|
|
field: "Name",
|
|
type: "input"
|
|
}, {
|
|
name: t.Rule,
|
|
field: "Rule",
|
|
type: "select",
|
|
datasource: this.designer.getActorConditions()
|
|
}, {
|
|
name: t.Value,
|
|
field: "Value",
|
|
type: "select",
|
|
datasource: this.designer.getActorNames()
|
|
}],
|
|
designer: e.designer
|
|
},
|
|
n = new WorkflowDesignerForm(i),
|
|
o = function (t, o) {
|
|
return n.CheckRequired(t, ["Name", "Rule"], WorkflowDesignerConstants.FieldIsRequired) && n.CheckUnique(t, ["Name"], WorkflowDesignerConstants.FieldMustBeUnique) ? (n.ClearTempField(t), e.SyncTable(e.designer.data.Actors, t, i), !0) : !1
|
|
};
|
|
n.showModal(o)
|
|
}, this.EditParameters = function () {
|
|
var e = WorkflowDesignerConstants.ParameterFormLabel,
|
|
t = this,
|
|
i = function (e, i, n) {
|
|
for (var o = void 0, r = e.getEditData(e.parameters), a = 0; a < r.length; a++) {
|
|
var s = r[a];
|
|
if (s.control_InitialValue.id === i.id) {
|
|
o = s.Type;
|
|
break
|
|
}
|
|
}
|
|
void 0 != o && t.designer.designer.getemptytype(encodeURIComponent(o), n)
|
|
},
|
|
n = {
|
|
type: "table",
|
|
title: e.Title,
|
|
width: "900px",
|
|
data: this.designer.data.Parameters,
|
|
datadefault: {
|
|
Purpose: "Persistence"
|
|
},
|
|
keyproperty: "Name",
|
|
elements: [{
|
|
name: e.Name,
|
|
field: "Name",
|
|
type: "input"
|
|
}, {
|
|
name: e.Type,
|
|
field: "Type",
|
|
type: "input",
|
|
datasource: this.designer.getTypeNames(),
|
|
width: "35%"
|
|
}, {
|
|
name: e.Purpose,
|
|
field: "Purpose",
|
|
type: "select",
|
|
displayfield: "Name",
|
|
datasource: [{
|
|
Name: "Temporary"
|
|
}, {
|
|
Name: "Persistence"
|
|
}, {
|
|
Name: "System"
|
|
}]
|
|
}, {
|
|
name: e.InitialValue,
|
|
field: "InitialValue",
|
|
type: "json",
|
|
width: "25%",
|
|
getemptytype: i
|
|
}],
|
|
top: $('<div style="float: right;"></div>'),
|
|
beforerowadded: function (e) {
|
|
void 0 != e.Type && (e.Type = decodeURIComponent(e.Type))
|
|
},
|
|
onrowadded: function (e) {
|
|
var t = e.find("[name=Purpose]"),
|
|
i = t[0];
|
|
t.change(function () {
|
|
s(e)
|
|
}), void 0 != i && "System" !== i.value && e.find('[name=Purpose] option[value="System"]').remove(), s(e)
|
|
},
|
|
designer: t.designer
|
|
},
|
|
o = new WorkflowDesignerForm(n),
|
|
r = function () {
|
|
for (var e = $(o.window.find(".WorkflowDesignerTable"))[0], t = 0; t < e.rows.length; t++) {
|
|
var i = $(e.rows[t]),
|
|
n = i.find("[name=Purpose]")[0];
|
|
void 0 != n && "System" === n.value && i.hide()
|
|
}
|
|
},
|
|
a = function () {
|
|
for (var e = $(o.window.find(".WorkflowDesignerTable"))[0], t = 0; t < e.rows.length; t++) {
|
|
var i = $(e.rows[t]),
|
|
n = i.find("[name=Purpose]")[0];
|
|
void 0 != n && "System" === n.value && i.show()
|
|
}
|
|
},
|
|
s = function (e) {
|
|
var t = e.find("[name=Purpose]")[0];
|
|
void 0 != t && "System" === t.value ? (e.find(":input").attr("readonly", !0), e.find("[name=Purpose]").attr("disabled", !0), e.find("[name=InitialValue]").val(""), e.find(".btnDelete").remove()) : void 0 != t && "Temporary" === t.value ? (e.find("[name=InitialValue]").attr("readonly", !0), e.find("[name=InitialValue]").val("")) : void 0 != t && "Persistence" === t.value && e.find("[name=InitialValue]").attr("readonly", !1)
|
|
},
|
|
d = function () {
|
|
for (var e = $(o.window.find(".WorkflowDesignerTable"))[0], t = 0; t < e.rows.length; t++) {
|
|
var i = $(e.rows[t]);
|
|
s(i)
|
|
}
|
|
};
|
|
n.top.append('<input type="checkbox" id="check1"/><label for="check1">' + WorkflowDesignerConstants.ParameterFormLabel.ShowSystemParameters + "</label>"), n.top.buttonset().click(function (e, t) {
|
|
var i = n.top.buttonset().first()[0].childNodes[0].checked;
|
|
i ? a() : r()
|
|
});
|
|
var l = function (e, i) {
|
|
if (o.CheckRequired(e, ["Name", "Type", "Purpose", "Parameter"], WorkflowDesignerConstants.FieldIsRequired) && o.CheckUnique(e, ["Name"], WorkflowDesignerConstants.FieldMustBeUnique)) {
|
|
o.ClearTempField(e), t.SyncTable(t.designer.data.Parameters, e, n);
|
|
for (var r = 0; r < t.designer.data.Parameters.length; r++) {
|
|
var a = t.designer.data.Parameters[r].Type;
|
|
t.designer.data.Parameters[r].Type = encodeURIComponent(a)
|
|
}
|
|
return !0
|
|
}
|
|
return !1
|
|
};
|
|
o.showModal(l), r(), d()
|
|
}, this.EditCodeActions = function () {
|
|
var t = WorkflowDesignerConstants.CodeActionsFormLabel,
|
|
i = {
|
|
type: "table",
|
|
title: t.Title,
|
|
width: "800px",
|
|
data: this.designer.data.CodeActions,
|
|
datadefault: {},
|
|
elements: [{
|
|
name: t.Name,
|
|
field: "Name",
|
|
type: "input"
|
|
}, {
|
|
name: t.Type,
|
|
field: "Type",
|
|
type: "select",
|
|
displayfield: "Name",
|
|
datasource: [{
|
|
Name: "Action"
|
|
}, {
|
|
Name: "Condition"
|
|
}, {
|
|
Name: "RuleGet"
|
|
}, {
|
|
Name: "RuleCheck"
|
|
}]
|
|
}, {
|
|
name: t.IsGlobal,
|
|
field: "IsGlobal",
|
|
type: "checkbox"
|
|
}, {
|
|
name: t.ActionCode,
|
|
field: "ActionCode",
|
|
type: "code"
|
|
}],
|
|
designer: e.designer
|
|
},
|
|
n = new WorkflowDesignerForm(i),
|
|
o = function (t, o) {
|
|
if (n.CheckRequired(t, ["Name", "Type", "ActionCode.code"], WorkflowDesignerConstants.FieldIsRequired) && n.CheckUnique(t, ["Name", "Type"], WorkflowDesignerConstants.FieldMustBeUnique)) {
|
|
n.ClearTempField(t), e.SyncTable(e.designer.data.CodeActions, t, i);
|
|
for (var r = 0; r < e.designer.data.CodeActions.length; r++) {
|
|
var a = e.designer.data.CodeActions[r].ActionCode;
|
|
e.designer.data.CodeActions[r].ActionCode = encodeURIComponent(a.code), e.designer.data.CodeActions[r].Usings = encodeURIComponent(a.usings)
|
|
}
|
|
return !0
|
|
}
|
|
return !1
|
|
};
|
|
n.showModal(o)
|
|
}, this.EditCommands = function () {
|
|
var e = WorkflowDesignerConstants.CommandFormLabel,
|
|
t = this,
|
|
i = function (e, i, n) {
|
|
for (var o = void 0, r = void 0, a = e.getEditData(e.parameters), s = 0; s < a.length; s++) {
|
|
var d = a[s];
|
|
if (void 0 != d.InputParameters)
|
|
for (var l = 0; l < d.InputParameters.length; l++)
|
|
if (d.InputParameters[l].control_DefaultValue.id === i.id) {
|
|
r = d.InputParameters[l].Parameter.Name;
|
|
break
|
|
}
|
|
}
|
|
if (void 0 != r)
|
|
for (var c = t.designer.data.Parameters, s = 0; s < c.length; s++)
|
|
if (c[s].Name === r) {
|
|
o = c[s].Type;
|
|
break
|
|
}
|
|
void 0 != o && t.designer.designer.getemptytype(o, n)
|
|
},
|
|
n = {
|
|
type: "table",
|
|
title: e.Title,
|
|
width: "900px",
|
|
data: this.designer.data.Commands,
|
|
datadefault: {},
|
|
keyproperty: "Name",
|
|
elements: [{
|
|
name: e.Name,
|
|
field: "Name",
|
|
type: "input"
|
|
}, {
|
|
name: e.InputParameters,
|
|
field: "InputParameters",
|
|
type: "table",
|
|
elements: [{
|
|
name: e.InputParametersName,
|
|
code: "ipname",
|
|
field: "Name",
|
|
type: "input"
|
|
}, {
|
|
name: e.InputParametersParameter,
|
|
code: "ipparameter",
|
|
field: "Parameter.Name",
|
|
type: "select",
|
|
displayfield: "Name",
|
|
datasource: this.designer.getNonSystemParameters()
|
|
}, {
|
|
name: e.InputParametersIsRequired,
|
|
code: "iisrequired",
|
|
field: "IsRequired",
|
|
type: "checkbox"
|
|
}, {
|
|
name: e.InputParametersDefaultValue,
|
|
code: "idefaultvalue",
|
|
field: "DefaultValue",
|
|
type: "json",
|
|
width: "40%",
|
|
getemptytype: i
|
|
}]
|
|
}],
|
|
designer: t.designer
|
|
},
|
|
o = new WorkflowDesignerForm(n),
|
|
r = function (e, t) {
|
|
var i = !0;
|
|
return i &= e.CheckRequired(t, ["Name"], WorkflowDesignerConstants.FieldIsRequired), i &= e.CheckUnique(t, ["Name"], WorkflowDesignerConstants.FieldMustBeUnique), t.forEach(function (t) {
|
|
e.CheckRequired(t.InputParameters, ["Name", "Parameter.Name"], WorkflowDesignerConstants.FieldIsRequired) || (i = !1)
|
|
}), i
|
|
},
|
|
a = function (e) {
|
|
return r(o, e) ? (o.ClearTempField(e), t.SyncTable(t.designer.data.Commands, e, n), WorkflowDesignerCommon.DataCorrection(t.designer.data), t.GraphRedrawAll(), !0) : !1
|
|
};
|
|
o.showModal(a)
|
|
}, this.EditAdditionalParameters = function () {
|
|
var e = WorkflowDesignerConstants.AdditionalParamsFormLabel,
|
|
t = {
|
|
type: "form",
|
|
title: e.Title,
|
|
width: "800px",
|
|
data: this.designer.data.AdditionalParams,
|
|
readonly: !0,
|
|
elements: [{
|
|
name: e.IsObsolete,
|
|
field: "IsObsolete",
|
|
type: "checkbox"
|
|
}, {
|
|
name: e.DefiningParameters,
|
|
field: "DefiningParameters",
|
|
type: "textarea"
|
|
}, {
|
|
name: e.ProcessParameters,
|
|
field: "ProcessParameters",
|
|
type: "table",
|
|
elements: [{
|
|
name: e.ProcessParametersName,
|
|
field: "Name",
|
|
type: "input"
|
|
}, {
|
|
name: e.ProcessParametersValue,
|
|
field: "Value",
|
|
type: "input"
|
|
}]
|
|
}]
|
|
},
|
|
i = new WorkflowDesignerForm(t),
|
|
n = function (e, t) {
|
|
return !0
|
|
};
|
|
i.showModal(n)
|
|
|
|
|
|
}, this.Items = [{
|
|
title: WorkflowDesignerConstants.ToolbarLabel.CreateActivity,
|
|
img: "designer.tb.add.png",
|
|
click: function () {
|
|
e.CreateActivity()
|
|
}
|
|
}, {
|
|
title: WorkflowDesignerConstants.ToolbarLabel.CopySelected,
|
|
img: "designer.tb.copy.png",
|
|
click: function () {
|
|
e.CopySelected()
|
|
}
|
|
}, {
|
|
title: WorkflowDesignerConstants.ButtonTextDelete,
|
|
img: "designer.tb.delete.png",
|
|
click: function () {
|
|
e.designer.DeleteSelected()
|
|
}
|
|
}, {
|
|
separator: !0
|
|
}, {
|
|
title: WorkflowDesignerConstants.ToolbarLabel.Move,
|
|
img: "designer.tb.move.png",
|
|
code: "move",
|
|
click: function () {
|
|
e.ToolbarMovePress()
|
|
}
|
|
}, {
|
|
title: WorkflowDesignerConstants.ToolbarLabel.ZoomIn,
|
|
img: "designer.tb.zoomIn.png",
|
|
click: function () {
|
|
e.designer.GraphLayerScale(.1)
|
|
}
|
|
}, {
|
|
title: WorkflowDesignerConstants.ToolbarLabel.ZoomOut,
|
|
img: "designer.tb.zoomOut.png",
|
|
click: function () {
|
|
e.designer.GraphLayerScale(-.1)
|
|
}
|
|
}, {
|
|
title: WorkflowDesignerConstants.ToolbarLabel.ZoomPositionDefault,
|
|
img: "designer.tb.zoomnorm.png",
|
|
click: function () {
|
|
e.designer.GraphLayerScaleNorm()
|
|
}
|
|
}, {
|
|
title: WorkflowDesignerConstants.ToolbarLabel.AutoArrangement,
|
|
img: "designer.tb.arrangment.png",
|
|
click: function () {
|
|
e.AutoArrangement()
|
|
}
|
|
}, {
|
|
separator: !0
|
|
}, {
|
|
title: WorkflowDesignerConstants.ToolbarLabel.Actors,
|
|
img: "designer.tb.actor.png",
|
|
click: function () {
|
|
e.EditActors()
|
|
}
|
|
}, {
|
|
title: WorkflowDesignerConstants.ToolbarLabel.Commands,
|
|
img: "designer.tb.command.png",
|
|
click: function () {
|
|
e.EditCommands()
|
|
}
|
|
}, {
|
|
title: WorkflowDesignerConstants.ToolbarLabel.Parameters,
|
|
img: "designer.tb.parameter.png",
|
|
click: function () {
|
|
e.EditParameters()
|
|
}
|
|
}, {
|
|
title: WorkflowDesignerConstants.ToolbarLabel.Localization,
|
|
img: "designer.tb.locale.png",
|
|
click: function () {
|
|
e.EditLocalization()
|
|
}
|
|
}, {
|
|
title: WorkflowDesignerConstants.ToolbarLabel.Timers,
|
|
img: "designer.tb.timer.png",
|
|
click: function () {
|
|
e.EditTimer()
|
|
}
|
|
},
|
|
{
|
|
title: WorkflowDesignerConstants.ToolbarLabel.CodeActions,
|
|
img: "designer.tb.codeactions.png",
|
|
Hide: hideCodedActions,
|
|
click: function () {
|
|
e.EditCodeActions()
|
|
}
|
|
},
|
|
|
|
{
|
|
title: WorkflowDesignerConstants.ToolbarLabel.AdditionalParameters,
|
|
img: "designer.tb.additionalparameters.png",
|
|
click: function () {
|
|
e.EditAdditionalParameters()
|
|
}
|
|
}], this.GetItemByCode = function (e) {
|
|
for (var t = 0; t < this.Items.length; t++) {
|
|
var i = this.Items[t];
|
|
if (i.code == e) return i
|
|
}
|
|
}, this.SyncTable = function (e, t, i) {
|
|
if (void 0 == i.keyproperty) {
|
|
e.splice(0, e.length);
|
|
for (var n = 0; n < t.length; n++) {
|
|
var o = {};
|
|
i.elements.forEach(function (e) {
|
|
o[e.field] = t[n][e.field]
|
|
}), e.push(o)
|
|
}
|
|
} else {
|
|
for (var n = e.length - 1; n >= 0; n--) {
|
|
var r = $.grep(t, function (t) {
|
|
return e[n][i.keyproperty] == t.keyproperty
|
|
});
|
|
0 == r.length ? e.splice(n, 1) : i.elements.forEach(function (t) {
|
|
e[n][t.field] = r[0][t.field]
|
|
})
|
|
}
|
|
for (var n = 0; n < t.length; n++) {
|
|
var r = $.grep(e, function (e) {
|
|
return t[n][i.keyproperty] == e[i.keyproperty]
|
|
});
|
|
if (0 == r.length) {
|
|
var o = {};
|
|
i.elements.forEach(function (e) {
|
|
o[e.field] = t[n][e.field]
|
|
}), e.push(o)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function WorkflowDesignerTooltip(e, t, i, n) {
|
|
var o = this;
|
|
t.on("mouseover", function () {
|
|
if (void 0 == t.ToolTip) {
|
|
var o = new Kinetic.Label({
|
|
x: t.getX() + t.getWidth() / 2,
|
|
y: t.getY() + 30,
|
|
opacity: .75
|
|
});
|
|
o.add(new Kinetic.Tag({
|
|
fill: "black",
|
|
pointerDirection: "up",
|
|
pointerWidth: 10,
|
|
pointerHeight: 10,
|
|
lineJoin: "round",
|
|
shadowColor: "black",
|
|
shadowBlur: 10,
|
|
shadowOffset: 10,
|
|
shadowOpacity: .5
|
|
})), o.add(new Kinetic.Text({
|
|
text: i,
|
|
fontFamily: "Calibri",
|
|
fontSize: 12,
|
|
padding: 5,
|
|
fill: "white"
|
|
})), n ? (o.attrs.x = 0, o.attrs.y = 15, t.add(o)) : e.add(o), t.ToolTip = o, e.batchDraw()
|
|
}
|
|
}), t.on("mouseleave", function () {
|
|
o.Destroy(t), e.batchDraw()
|
|
}), this.Destroy = function (e) {
|
|
void 0 != e.ToolTip && (e.ToolTip.destroy(), e.ToolTip = void 0)
|
|
}
|
|
}
|
|
|
|
function WorkflowDesignerTransition() {
|
|
this.type = "WorkflowDesignerTransition", this.init = function (e) {
|
|
this.designer = e, this.Layer = new Kinetic.Layer, this.designer.Stage.add(this.Layer), this.Layer.setZIndex(2), this.designer = e, this.APLayer = new Kinetic.Layer, this.designer.Stage.add(this.APLayer), this.APLayer.setZIndex(3), this.ImageDelete = new Image, this.ImageDelete.src = this.designer.Settings.imagefolder + "designer.delete.png"
|
|
}, this.ItemControls = new Array, this.draw = function () {
|
|
null != this.ItemControls && this.ItemControls.forEach(function (e) {
|
|
e.destroy()
|
|
}), this.ItemControls = new Array;
|
|
var e = this;
|
|
void 0 != this.designer.data.Transitions && this.designer.data.Transitions.forEach(function (t) {
|
|
var i = e.designer.GetComponentByType("WorkflowDesignerActivity"),
|
|
n = new WorkflowDesignerTransitionControl({
|
|
from: i.find(t.From),
|
|
to: i.find(t.To),
|
|
item: t,
|
|
designer: e.designer,
|
|
manager: e
|
|
});
|
|
e.ItemControls.push(n), n.Draw()
|
|
}), this.batchDraw()
|
|
}, this.batchDraw = function () {
|
|
this.Layer.batchDraw(), this.APLayer.batchDraw()
|
|
}, this.getIntersectingActivity = function (e) {
|
|
var t = this.designer.GetComponentByType("WorkflowDesignerActivity");
|
|
return t.getIntersectingActivity(e)
|
|
}, this.LayerSetOffset = function (e, t) {
|
|
this.Layer.setOffset(e, t), this.APLayer.setOffset(e, t)
|
|
}, this.LayerScale = function (e) {
|
|
this.Layer.setScale({
|
|
x: this.Layer.getScale().x + e,
|
|
y: this.Layer.getScale().y + e
|
|
}), this.APLayer.setScale({
|
|
x: this.APLayer.getScale().x + e,
|
|
y: this.APLayer.getScale().y + e
|
|
})
|
|
}, this.LayerScaleNorm = function (e) {
|
|
this.Layer.setScale({
|
|
x: 1,
|
|
y: 1
|
|
}), this.Layer.setOffset({
|
|
x: 0,
|
|
y: 0
|
|
}), this.APLayer.setScale({
|
|
x: 1,
|
|
y: 1
|
|
}), this.APLayer.setOffset({
|
|
x: 0,
|
|
y: 0
|
|
})
|
|
}, this.DeselectAll = function () {
|
|
this.ItemControls.forEach(function (e) {
|
|
e.Deselect()
|
|
})
|
|
}, this.GetSelected = function () {
|
|
var e = new Array;
|
|
return this.ItemControls.forEach(function (t) {
|
|
t.selected && e.push(t)
|
|
}), e
|
|
}, this.SelectByPosition = function (e) {
|
|
this.ItemControls.forEach(function (t) {
|
|
t.getIntersectingRect(e) && t.Select()
|
|
})
|
|
}, this.SelectByItem = function (e) {
|
|
this.ItemControls.forEach(function (t) {
|
|
t.item == e && t.Select()
|
|
})
|
|
}, this.CreateNewTransition = function (e, t) {
|
|
var i = this;
|
|
if (void 0 == t) {
|
|
var n = e.control.getX() + e.rectangle.attrs.width,
|
|
o = e.control.getY() + e.rectangle.attrs.height / 2,
|
|
r = {
|
|
x: n,
|
|
y: o
|
|
},
|
|
a = new WorkflowDesignerTransitionTempControl({
|
|
x: r.x,
|
|
y: r.y,
|
|
manager: this
|
|
});
|
|
a.Draw(r.x + 10, r.y), this.batchDraw();
|
|
var s = function (e) {
|
|
var t = i.designer.CorrectPossition({
|
|
x: e.evt.layerX,
|
|
y: e.evt.layerY
|
|
}, i.Layer);
|
|
a.Redraw(t), i.Layer.batchDraw()
|
|
},
|
|
d = function (t) {
|
|
var n = {
|
|
x: t.evt.layerX,
|
|
y: t.evt.layerY
|
|
},
|
|
o = i.getIntersectingActivity(n);
|
|
void 0 != o && i.CreateNewTransition(e, o), a.Delete(), i.designer.Stage.off("mousemove.WorkflowDesignerTransitionTempControl", s), i.designer.Stage.off("mouseup.WorkflowDesignerTransitionTempControl", d), i.batchDraw()
|
|
};
|
|
return this.designer.Stage.on("mousemove.WorkflowDesignerTransitionTempControl", s), this.designer.Stage.on("mouseup.WorkflowDesignerTransitionTempControl", d), a
|
|
}
|
|
var l = {
|
|
Name: this.GetDefaultName(e.GetName(), t.GetName()),
|
|
From: e.item,
|
|
To: t.item,
|
|
Trigger: {
|
|
Type: "Auto"
|
|
},
|
|
Conditions: [{
|
|
Type: "Always"
|
|
}],
|
|
AllowConcatenationType: "And",
|
|
RestrictConcatenationType: "And",
|
|
ConditionsConcatenationType: "And",
|
|
Classifier: "Direct",
|
|
DesignerSettings: {}
|
|
},
|
|
c = new WorkflowDesignerTransitionControl({
|
|
from: e,
|
|
to: t,
|
|
item: l,
|
|
designer: i.designer,
|
|
manager: i
|
|
});
|
|
return i.ItemControls.push(c), this.designer.data.Transitions.push(l), c.Draw(), c
|
|
}, this.GetDefaultName = function (e, t) {
|
|
for (var i = e + "_" + t + "_", n = 1, o = 0; o < this.designer.data.Transitions.length; o++) {
|
|
var r = this.designer.data.Transitions[o];
|
|
r.Name == i + n && (n++, o = -1)
|
|
}
|
|
return i + n
|
|
}
|
|
}
|
|
|
|
function WorkflowDesignerTransitionControl(e) {
|
|
var t = this;
|
|
this.manager = e.manager, this.designer = e.designer, this.from = e.from, this.to = e.to, this.item = e.item, this.setFrom = function (e) {
|
|
this.from = e, this.item.From = e.item
|
|
}, this.setTo = function (e) {
|
|
this.to = e, this.item.To = e.item
|
|
}, this.GetName = function () {
|
|
return this.item.Name
|
|
}, this.SetName = function (e) {
|
|
this.item.Name = e
|
|
}, this.control = void 0, this.arrow = void 0, this.line = void 0, void 0 == this.item.DesignerSettings || void 0 == this.item.DesignerSettings.Bending ? this.bending = 0 : this.bending = this.item.DesignerSettings.Bending, this.from.RegisterTransition(this), this.to.RegisterTransition(this), this.start = void 0, this.end = void 0, this.middle = void 0, this.angle = void 0, this.lineAngle = void 0, this.activePoint = void 0, this.touchpoints = [], this._getCBPoint = function (e, t, i, n, o, r, a) {
|
|
var s, d = o,
|
|
l = r;
|
|
s = d < Math.PI / 2 && d > 0 ? 1 : d >= Math.PI / 2 ? -1 : 0 >= d && d > -Math.PI / 2 ? -1 : 1, s = (d > 0 ? 1 : -1) * s;
|
|
var c = a * l * s,
|
|
h = (e + i) / 2,
|
|
m = (t + n) / 2,
|
|
g = h - c * Math.cos(Math.PI / 2 + d),
|
|
u = m - c * Math.sin(Math.PI / 2 + d);
|
|
return {
|
|
x: g,
|
|
y: u
|
|
}
|
|
}, this.DrawTransition = function (e, t) {
|
|
var i, n, o, r, a = this.bending,
|
|
s = 50,
|
|
d = this.from.rectangle,
|
|
l = this.to.rectangle;
|
|
i = this.from.getX(), n = this.from.getY(), o = this.to.getX(), r = this.to.getY();
|
|
var c, h, m, g, u = i + d.attrs.width / 2,
|
|
f = n + d.attrs.height / 2,
|
|
p = o + l.attrs.width / 2,
|
|
y = r + l.attrs.height / 2;
|
|
p >= u - s - l.attrs.width / 2 && p <= u + s + l.attrs.width / 2 && y >= f ? (c = u, h = n + d.attrs.height, m = p, g = r) : p >= u - s - l.attrs.width / 2 && p <= u + s + l.attrs.width / 2 && f > y ? (c = u, h = n, m = p, g = r + l.attrs.height) : u > p ? (c = i, h = f, m = o + l.attrs.width, g = y) : (c = i + d.attrs.width, h = n + d.attrs.height / 2, m = o, g = r + l.attrs.height / 2), void 0 != e && (c = e.x, h = e.y), void 0 != t && (m = t.x, g = t.y);
|
|
var v = Math.atan2(g - h, m - c),
|
|
C = this._getLineLength(c, h, m, g),
|
|
w = this._getCBPoint(c, h, m, g, v, C, a),
|
|
T = w.x,
|
|
A = w.y,
|
|
S = .5,
|
|
b = Math.atan2(g - A, m - T),
|
|
D = Math.PI / 10 * (a > 0 ? 1 : 0 > a ? -1 : 0);
|
|
Math.abs(v) >= Math.PI / 2 && (D = -D), b += D;
|
|
var k = void 0 == this.item.Classifier ? "notspecified" : this.item.Classifier.toLowerCase(),
|
|
I = "notspecified" == k ? "gray" : "direct" == k ? "green" : "red";
|
|
if (this.start = {
|
|
x: c,
|
|
y: h
|
|
}, this.end = {
|
|
x: m,
|
|
y: g
|
|
}, this.middle = {
|
|
x: T,
|
|
y: A
|
|
}, this.angle = b, this.lineAngle = v, this.control) WorkflowDesignerCommon.updateArrowByAngle(this.arrow, m, g, b, 15, I), this.line.setPoints([c, h, T, A, m, g]), this.line.setTension(S);
|
|
else {
|
|
this.control = new Kinetic.Group({
|
|
x: 0,
|
|
y: 0,
|
|
rotationDeg: 0
|
|
}), this.arrow = WorkflowDesignerCommon.createArrowByAngle(m, g, b, 15, I);
|
|
var x = {
|
|
points: [c, h, T, A, m, g],
|
|
stroke: I,
|
|
strokeWidth: 1,
|
|
lineCap: "round",
|
|
lineJoin: "round",
|
|
tension: S
|
|
};
|
|
this.item.IsFork && (x.dash = [10, 10]), this.line = new Kinetic.Line(x), this.control.add(this.line), this.control.add(this.arrow), this.manager.Layer.add(this.control)
|
|
}
|
|
}, this.DrawActivePoint = function () {
|
|
if (this.activePoint) this._moveActivePoint(this.middle.x, this.middle.y);
|
|
else {
|
|
var e = this._createActivePoint(this.middle.x, this.middle.y, this.control);
|
|
t.manager.APLayer.add(e), this.activePoint = e
|
|
}
|
|
}, this.DrawTouchPoints = function () {
|
|
var e = .1 * this._getLineLength(this.start.x, this.start.y, this.end.x, this.end.y);
|
|
if (2 == this.touchpoints.length) this._moveTouchPoints(this.touchpoints[0], this.start.x, this.start.y, e, this.angle, this.lineAngle), this._moveTouchPoints(this.touchpoints[1], this.end.x, this.end.y, e, this.angle, this.lineAngle, !0);
|
|
else {
|
|
var i = this._createTouchPoint(this.start.x, this.start.y, e, this.angle, this.lineAngle, this.control),
|
|
n = this._createTouchPoint(this.end.x, this.end.y, e, this.angle, this.lineAngle, this.control, !0);
|
|
t.manager.APLayer.add(i), t.manager.APLayer.add(n), this.touchpoints = [i, n]
|
|
}
|
|
}, this.Draw = function (e, t) {
|
|
this.DrawTransition(e, t), this.DrawActivePoint(), this.DrawTouchPoints()
|
|
}, this.DeleteTouchPoint = function (e) {
|
|
for (var t = 0; t < this.touchpoints.length; t++) this.touchpoints[t].isend == e && this.touchpoints[t].destroy()
|
|
}, this.Delete = function () {
|
|
this.from.UnregisterTransition(this), this.to.UnregisterTransition(this), this.control.destroy(), void 0 != this.activePoint.ToolTip && this.activePoint.ToolTip.destroy(), this.activePoint.destroy();
|
|
for (var e = 0; e < this.touchpoints.length; e++) this.touchpoints[e].destroy();
|
|
this.designer.data.Transitions.splice(this.designer.data.Transitions.indexOf(this.item), 1), this.manager.ItemControls.splice(this.manager.ItemControls.indexOf(this), 1)
|
|
}, this._onDelete = function () {
|
|
confirm(WorkflowDesignerConstants.DeleteConfirm) && (t.Delete(), t.designer.redrawAll())
|
|
}, this.Select = function () {
|
|
this.oldstroke = this.line.getStroke(), this.line.setStroke(WorkflowDesignerConstants.SelectColor), this.line.setStrokeWidth(3), this.selected = !0
|
|
}, this.Deselect = function () {
|
|
this.line.setStrokeWidth(1), void 0 != this.oldstroke && this.line.setStroke(this.oldstroke), this.selected = !1
|
|
}, this._moveTouchPoints = function (e, t, i, n, o, r, a) {
|
|
var s = 180 * r / Math.PI;
|
|
e.setPosition({
|
|
x: t,
|
|
y: i
|
|
}), e.setRotationDeg(s), e.circle.setPosition({
|
|
x: (a ? -1 : 1) * n * Math.cos(-(o - r)),
|
|
y: n * Math.sin(-(o - r))
|
|
})
|
|
}, this._createTouchPoint = function (e, t, i, n, o, r, a) {
|
|
var s = this,
|
|
d = 180 * o / Math.PI,
|
|
l = new Kinetic.Group({
|
|
x: e,
|
|
y: t,
|
|
rotationDeg: d,
|
|
draggable: !0
|
|
});
|
|
l.isend = a;
|
|
var c = new Kinetic.Circle({
|
|
x: (a ? -1 : 1) * i * Math.cos(-(n - o)),
|
|
y: i * Math.sin(-(n - o)),
|
|
radius: 5,
|
|
fill: "lightgray"
|
|
});
|
|
l.add(c), l.circle = c, l.transition = r;
|
|
var h = function () {
|
|
var e = s.designer.CorrectPossition(c.getAbsolutePosition(), s.manager.Layer);
|
|
void 0 == s.oldbending && (s.oldbending = s.bending), s.bending = 0;
|
|
var t = e;
|
|
a ? s.DrawTransition(void 0, t) : s.DrawTransition(t, void 0), s.DrawActivePoint(), s.DeleteTouchPoint(!a), s.manager.batchDraw()
|
|
};
|
|
return l.on("dragmove", function () {
|
|
h()
|
|
}), l.on("dragend", function () {
|
|
var e = c.getAbsolutePosition(),
|
|
t = s.manager.getIntersectingActivity(e);
|
|
void 0 != t ? (s.oldbending = void 0, s.bending = 0, s.Sync(), a ? (s.to.UnregisterTransition(s), s.setTo(t), s.to.RegisterTransition(s)) : (s.from.UnregisterTransition(s), s.setFrom(t), s.from.RegisterTransition(s)), s.Draw()) : (s.bending = s.oldbending, s.oldbending = void 0, s.Draw())
|
|
}), l
|
|
}, this._moveActivePoint = function (e, t) {
|
|
this.activePoint.setPosition({
|
|
x: e,
|
|
y: t
|
|
})
|
|
}, this._createActivePoint = function (e, t, i) {
|
|
var n = this,
|
|
o = new Kinetic.Group({
|
|
x: e,
|
|
y: t,
|
|
rotationDeg: 0,
|
|
draggable: !0
|
|
}),
|
|
r = new Kinetic.Circle({
|
|
x: 0,
|
|
y: 0,
|
|
radius: 15,
|
|
fill: "lightgray"
|
|
});
|
|
o.add(r);
|
|
var a = "",
|
|
s = this.item.Trigger.Type.toLowerCase();
|
|
"auto" == s ? a += "A" : "command" == s ? a += "C" : "timer" == s && (a += "T");
|
|
var d = this.item.Conditions[0].Type.toLowerCase();
|
|
"always" == d ? a += "A" : "action" == d ? a += "C" : "otherwise" == d && (a += "O");
|
|
var l = new Kinetic.Text({
|
|
x: -12,
|
|
y: -11,
|
|
text: a,
|
|
fontSize: 20,
|
|
fontFamily: "Calibri",
|
|
fill: "black",
|
|
fontStyle: "bold"
|
|
});
|
|
o.add(l);
|
|
var c = new Kinetic.Image({
|
|
x: 12,
|
|
y: -20,
|
|
image: this.manager.ImageDelete,
|
|
width: 10,
|
|
height: 10
|
|
});
|
|
c.on("click", this._onDelete), o.add(c), o.transition = i;
|
|
var h = function (e, t) {
|
|
var i = o.getPosition();
|
|
t ? n.bending = 0 : n.bending = n._getBendingKoeff(n.start.x, n.start.y, n.end.x, n.end.y, i.x, i.y), Math.abs(n.bending) < .07 && (n.bending = 0), n.DrawTransition(), n.DrawTouchPoints(), e && (n.DrawActivePoint(), n.Sync()), n.manager.batchDraw()
|
|
};
|
|
o.on("click", function (e) {
|
|
var t = n.selected;
|
|
e.evt.ctrlKey || n.designer.DeselectAll(), t ? n.Deselect() : n.Select(), n.manager.batchDraw()
|
|
}), o.on("dblclick", function () {
|
|
n.designer.DeselectAll(), n.Select(), n.manager.batchDraw(), n.ShowProperties()
|
|
}), o.on("dragmove", function () {
|
|
h(!1)
|
|
}), o.on("dragend", function () {
|
|
h(!0)
|
|
});
|
|
var m = "Trigger: " + this.item.Trigger.Type;
|
|
return void 0 != n.item.Trigger && void 0 != n.item.Trigger.Command && "Command" == n.item.Trigger.Type && (m += " " + n.item.Trigger.Command.Name), void 0 != n.item.Trigger && void 0 != n.item.Trigger.Timer && "Timer" == n.item.Trigger.Type && (m += " " + n.item.Trigger.Timer.Name), m += "\r\nCondition: " + this.item.Conditions[0].Type, void 0 != n.item.Conditions[0] && "Action" == n.item.Conditions[0].Type && (m += " " + n.item.Conditions[0].ActionName), WorkflowDesignerTooltip(n.manager.Layer, o, m, !0), o
|
|
}, this._getLineLength = function (e, t, i, n) {
|
|
return Math.sqrt(Math.pow(i - e, 2) + Math.pow(n - t, 2))
|
|
}, this._getBendingKoeff = function (e, t, i, n, o, r) {
|
|
var a = t - n,
|
|
s = i - e,
|
|
d = e * n - i * t;
|
|
0 >= s && (a = -a, s = -s, d = -d);
|
|
var l = -(d + a * o) / s,
|
|
c = r > l ? -1 : 1,
|
|
h = this._getLineLength(e, t, i, n),
|
|
m = (e + i) / 2,
|
|
g = (t + n) / 2,
|
|
u = this._getLineLength(m, g, o, r),
|
|
f = u / h * c;
|
|
return 0 == s && (f = -f), f
|
|
}, this.getIntersectingRect = function (e) {
|
|
var t = this.activePoint.getAbsolutePosition();
|
|
return t.x >= e.xl && t.x < e.xr && t.y >= e.yl && t.y < e.yr ? !0 : !1
|
|
}, this.ShowProperties = function () {
|
|
var e = WorkflowDesignerConstants.TransitionFormLabel,
|
|
i = {
|
|
type: "form",
|
|
title: e.Title,
|
|
width: "800px",
|
|
data: this.item,
|
|
elements: [{
|
|
name: e.Name,
|
|
field: "Name",
|
|
type: "input"
|
|
}, {
|
|
name: e.From,
|
|
field: "From.Name",
|
|
type: "select",
|
|
displayfield: "Name",
|
|
datasource: t.designer.data.Activities
|
|
}, {
|
|
name: e.To,
|
|
field: "To.Name",
|
|
type: "select",
|
|
displayfield: "Name",
|
|
datasource: t.designer.data.Activities
|
|
}, {
|
|
name: e.Classifier,
|
|
field: "Classifier",
|
|
type: "select",
|
|
datasource: ["Direct", "Reverse", "NotSpecified"]
|
|
}, {
|
|
name: e.Restrictions,
|
|
field: "Restrictions",
|
|
code: "restrictions",
|
|
type: "table",
|
|
datadefault: {
|
|
Type: "Allow"
|
|
},
|
|
elements: [{
|
|
name: e.RestrictionsType,
|
|
code: "resttype",
|
|
field: "Type",
|
|
type: "select",
|
|
datasource: ["Allow", "Restrict"]
|
|
}, {
|
|
name: e.RestrictionsActor,
|
|
code: "restactor",
|
|
field: "Actor.Name",
|
|
type: "select",
|
|
displayfield: "Name",
|
|
datasource: t.designer.data.Actors
|
|
}]
|
|
}, {
|
|
name: e.AllowConcatenationType,
|
|
field: "AllowConcatenationType",
|
|
type: "select",
|
|
datasource: ["And", "Or"]
|
|
}, {
|
|
name: e.RestrictConcatenationType,
|
|
field: "RestrictConcatenationType",
|
|
type: "select",
|
|
datasource: ["And", "Or"]
|
|
}, {
|
|
name: e.Trigger,
|
|
field: "Trigger",
|
|
code: "trigger",
|
|
type: "form",
|
|
datadefault: {
|
|
Type: "Command"
|
|
},
|
|
elements: [{
|
|
name: e.TriggerType,
|
|
code: "triggertype",
|
|
field: "Type",
|
|
type: "select",
|
|
datasource: ["Auto", "Command", "Timer"]
|
|
}, {
|
|
name: e.TriggerCommand,
|
|
code: "triggercommand",
|
|
field: "Command.Name",
|
|
type: "select",
|
|
displayfield: "Name",
|
|
datasource: t.designer.data.Commands
|
|
}, {
|
|
name: e.TriggerTimer,
|
|
code: "triggertimer",
|
|
field: "Timer.Name",
|
|
type: "select",
|
|
displayfield: "Name",
|
|
datasource: t.designer.data.Timers
|
|
}]
|
|
}, {
|
|
name: e.Condition,
|
|
field: "Conditions",
|
|
code: "condition",
|
|
type: "table",
|
|
datadefault: {
|
|
Type: "Always",
|
|
ResultOnPreExecution: "Null"
|
|
},
|
|
elements: [{
|
|
name: e.ConditionType,
|
|
code: "conditiontype",
|
|
field: "Type",
|
|
type: "select",
|
|
datasource: ["Always", "Action", "Otherwise"]
|
|
}, {
|
|
name: e.ConditionAction,
|
|
code: "conditionaction",
|
|
field: "Action.ActionName",
|
|
type: "select",
|
|
datasource: t.designer.getConditionNames()
|
|
}, {
|
|
name: e.ConditionActionParameter,
|
|
code: "conditionactionparameter",
|
|
field: "Action.ActionParameter",
|
|
type: "json"
|
|
}, {
|
|
name: e.ConditionInversion,
|
|
code: "conditioninversion",
|
|
field: "ConditionInversion",
|
|
type: "checkbox"
|
|
}, {
|
|
name: e.ResultOnPreExecution,
|
|
code: "conditionresult",
|
|
field: "ResultOnPreExecution",
|
|
type: "select",
|
|
datasource: ["True", "False"]
|
|
}],
|
|
onrowadded: function (e) {
|
|
var t = e.find("[name=conditiontype]"),
|
|
i = e.find("[name=conditionaction]"),
|
|
n = e.find("[name=conditionresult]"),
|
|
o = e.find("[name=conditionactionparameter]").parent().parent(),
|
|
r = e.find("[name=conditioninversion]"),
|
|
a = function () {
|
|
var e = t[0].value;
|
|
"Action" == e ? (i.show(), n.show(), o.show(), r.show()) : (i.hide(), n.hide(), o.hide(), r.hide())
|
|
};
|
|
t.on("change", a), a()
|
|
}
|
|
}, {
|
|
name: e.ConditionsConcatenationType,
|
|
field: "ConditionsConcatenationType",
|
|
type: "select",
|
|
datasource: ["And", "Or"]
|
|
}, {
|
|
name: e.IsFork,
|
|
field: "IsFork",
|
|
code: "isfork",
|
|
type: "checkbox"
|
|
}, {
|
|
name: e.MergeViaSetState,
|
|
field: "MergeViaSetState",
|
|
code: "mergeviasetstate",
|
|
type: "checkbox"
|
|
}, {
|
|
name: e.DisableParentStateControl,
|
|
field: "DisableParentStateControl",
|
|
code: "disableparentstatecontrol",
|
|
type: "checkbox"
|
|
}],
|
|
renderFinalFunc: function (e) {
|
|
var t = e.find("[name=restrictions]").parent().parent(),
|
|
i = e.find("[name=triggertype]"),
|
|
n = e.find("[name=isfork]"),
|
|
o = e.find("[name=triggercommand]").parent().parent(),
|
|
r = e.find("[name=triggertimer]").parent().parent(),
|
|
a = $(e.find("[name=AllowConcatenationType]").parent().parent()),
|
|
s = $(e.find("[name=RestrictConcatenationType]").parent().parent()),
|
|
d = $(e.find("[name=ConditionsConcatenationType]").parent().parent()),
|
|
l = e.find("[name=mergeviasetstate]").parent().parent(),
|
|
c = e.find("[name=disableparentstatecontrol]").parent().parent(),
|
|
h = function () {
|
|
var e = i[0].value;
|
|
"Command" == e ? (o.show(), r.hide(), t.show()) : "Timer" == e ? (o.hide(), r.show(), t.hide(), a.hide(), s.hide()) : (o.hide(), r.hide(), t.hide(), a.hide(), s.hide())
|
|
};
|
|
i.on("change", h), h();
|
|
var m = function () {
|
|
var e = n[0].checked;
|
|
e ? (l.show(), c.show()) : (l.hide(), c.hide())
|
|
};
|
|
n.on("change", m), m();
|
|
var g = a.find("[name=AllowConcatenationType]")[0].value.toLowerCase(),
|
|
u = s.find("[name=RestrictConcatenationType]")[0].value.toLowerCase(),
|
|
f = d.find("[name=ConditionsConcatenationType]")[0].value.toLowerCase();
|
|
"and" === g && a.hide(), "and" === u && s.hide(), "and" === f && d.hide();
|
|
var p = $(e.find("[name=restrictions]").parent().parent().children()[0]),
|
|
y = $("<button>Additional params</button>").button({
|
|
icons: {
|
|
primary: "ui-icon-wrench"
|
|
},
|
|
text: !1
|
|
}).on("click", function () {
|
|
a.is(":visible") && "and" === g ? a.hide() : a.show(), s.is(":visible") && "and" === u ? s.hide() : s.show()
|
|
});
|
|
p.append(" "), p.append(y);
|
|
var v = $(e.find("[name=condition]").parent().parent().children()[0]),
|
|
C = $("<button>Additional params</button>").button({
|
|
icons: {
|
|
primary: "ui-icon-wrench"
|
|
},
|
|
text: !1
|
|
}).on("click", function () {
|
|
d.is(":visible") && "and" === f ? d.hide() : d.show()
|
|
});
|
|
v.append(" "), v.append(C)
|
|
},
|
|
designer: t.designer
|
|
},
|
|
n = new WorkflowDesignerForm(i),
|
|
o = function (e, i) {
|
|
var n = !0;
|
|
n &= e.CheckRequired([i], ["Name"], WorkflowDesignerConstants.FieldIsRequired);
|
|
var o = ["Type"];
|
|
"Command" == i.Trigger.Type ? o.push("Command.Name") : "Timer" == i.Trigger.Type && o.push("Timer.Name"), n &= e.CheckRequired([i.Trigger], o, WorkflowDesignerConstants.FieldIsRequired), i.Conditions.forEach(function (t) {
|
|
o = ["Type"], "Action" == t.Type && o.push("Action.ActionName"), n &= e.CheckRequired([t], o, WorkflowDesignerConstants.FieldIsRequired), "Always" == t.Type && i.Conditions.length > 1 ? (n = !1, e.ControlAddError(t.control_Type, WorkflowDesignerConstants.AlwaysConditionShouldBeSingle)) : "Otherwise" == t.Type && i.Conditions.length > 1 && (n = !1, e.ControlAddError(t.control_Type, WorkflowDesignerConstants.OtherwiseConditionShouldBeSingle))
|
|
});
|
|
var r = $(i.control_Conditions.parent().parent().children()[0]).children("label");
|
|
return !i.Conditions.length > 0 ? (r.attr("title", WorkflowDesignerConstants.TransitionFormLabel.ConditionsListShouldNotBeEmpty), r.css("color", "red"), n = !1) : (r.attr("title", void 0), r.css("color", "")), t.designer.data.Transitions.forEach(function (o) {
|
|
o != t.item && o.Name == i.Name && (n = !1, e.ControlAddError(i.control_Name, WorkflowDesignerConstants.FieldMustBeUnique))
|
|
}), e.CheckRequired(i.Restrictions, ["Type", "Actor.Name"], WorkflowDesignerConstants.FieldIsRequired) || (n = !1), n
|
|
},
|
|
r = function (e) {
|
|
return o(n, e) ? (n.ClearTempField(e), t.item.Name = e.Name, t.item.From.Name = e.From.Name, t.item.To.Name = e.To.Name, t.item.Classifier = e.Classifier, t.item.Restrictions = e.Restrictions, t.item.Trigger = e.Trigger, t.item.Conditions = e.Conditions, t.item.IsFork = e.IsFork, t.item.MergeViaSetState = e.MergeViaSetState, t.item.DisableParentStateControl = e.DisableParentStateControl, t.item.ConditionsConcatenationType = e.ConditionsConcatenationType, t.item.AllowConcatenationType = e.AllowConcatenationType, t.item.RestrictConcatenationType = e.RestrictConcatenationType, WorkflowDesignerCommon.DataCorrection(t.designer.data), t.designer.Draw(t.designer.data), !0) : !1
|
|
};
|
|
n.showModal(r)
|
|
}, this.Sync = function () {
|
|
t.item.DesignerSettings.Bending = t.bending
|
|
}, this.destroy = function () {
|
|
this.control.destroy(), this.activePoint.destroy(), this.touchpoints.forEach(function (e) {
|
|
e.destroy()
|
|
})
|
|
}
|
|
}
|
|
|
|
function WorkflowDesignerTransitionTempControl(e) {
|
|
this.x = e.x, this.y = e.y, this.manager = e.manager, this.control = void 0, this.Draw = function (e, t) {
|
|
this.control = new Kinetic.Group({
|
|
x: 0,
|
|
y: 0,
|
|
rotationDeg: 0
|
|
}), this.line = new Kinetic.Line({
|
|
points: [this.x, this.y, e, t],
|
|
stroke: "#FFCC99",
|
|
strrokeWidth: 1
|
|
});
|
|
var i = Math.atan2(t - this.y, e - this.x);
|
|
this.arrow = WorkflowDesignerCommon.createArrowByAngle(e, t, i, 20, "#FFCC99"), this.control.add(this.line), this.control.add(this.arrow), this.manager.Layer.add(this.control)
|
|
}, this.Redraw = function (e) {
|
|
this.line.setPoints([this.x, this.y, e.x, e.y]);
|
|
var t = Math.atan2(e.y - this.y, e.x - this.x);
|
|
WorkflowDesignerCommon.updateArrowByAngle(this.arrow, e.x, e.y, t, 20, "#FFCC99")
|
|
}, this.Delete = function () {
|
|
this.control.destroy()
|
|
}
|
|
}
|
|
|
|
function WorkflowDesignerForm(e) {
|
|
this.type = "WorkflowDesignerForm", this.parameters = e, this.id = WorkflowDesignerCommon.createUUID(), this.isReadOnly = function () {
|
|
return this.parameters.readonly
|
|
}, this.showModal = function (e) {
|
|
var t = this;
|
|
t.window = $("<div></div>"), t.window.id = this.id;
|
|
var i = void 0;
|
|
"table" === this.parameters.type ? i = this.generateTable(this.parameters) : "form" === this.parameters.type && (i = this.generateForm(this.parameters)), void 0 == i && (i = new Array), void 0 != t.parameters.top && i.unshift(t.parameters.top), void 0 != t.parameters.bottom && i.push(t.parameters.bottom), t.window.append(i), void 0 != this.parameters.renderFinalFunc && this.parameters.renderFinalFunc(i), t.window.dialog({
|
|
modal: !0,
|
|
title: this.parameters.title,
|
|
width: this.parameters.width,
|
|
maxHeight: WorkflowDesignerConstants.FormMaxHeight,
|
|
beforeClose: function (i, n) {
|
|
if (t.ClearError(), void 0 != e && !t.isReadOnly()) {
|
|
var o = t.getEditData(t.parameters);
|
|
return e(o, t.parameters)
|
|
}
|
|
},
|
|
close: function (e, t) {
|
|
$(this).dialog("destroy").remove()
|
|
}
|
|
})
|
|
}, this.getEditData = function (e) {
|
|
var t, i = this;
|
|
if ("form" == e.type) t = {}, e.elements.forEach(function (e) {
|
|
t["control_" + e.field] = e.control, "table" == e.type || "form" == e.type ? t[e.field] = i.getEditData(e) : i.SetValueByPropertyName(t, e.field, i.getEasyControlValue(e))
|
|
});
|
|
else if ("table" == e.type) {
|
|
t = [];
|
|
var n = e.control;
|
|
if (e.elements.forEach(function (e) {
|
|
var o = i.getElementCode(e),
|
|
r = "[name=" + o + "]",
|
|
a = n.find(r);
|
|
if (void 0 != a)
|
|
for (var s = 0; s < a.length; s++) void 0 == t[s] && (t[s] = {}), t[s]["control_" + e.field] = a[s], "table" == e.type || "form" == e.type ? t[s][e.field] = i.getEditData({
|
|
type: e.type,
|
|
control: $(a[s]),
|
|
elements: e.elements
|
|
}) : i.SetValueByPropertyName(t[s], e.field, i.getEasyControlValue({
|
|
type: e.type,
|
|
control: a[s]
|
|
}))
|
|
}), e.keyproperty)
|
|
for (var o = n.children("tbody").children("tr"), r = 0; r < o.length; r++) void 0 == t[r] && (t[r] = {}), t[r].keyproperty = $(o[r]).attr("keyproperty")
|
|
}
|
|
return t
|
|
}, this.generateForm = function (e, t) {
|
|
var i = this,
|
|
n = $('<table class="WorkflowDesignerTable"></table>');
|
|
n.attr("name", i.getElementCode(e));
|
|
var o = new Array;
|
|
return e.elements.forEach(function (n) {
|
|
var r = $("<tr></tr>");
|
|
void 0 == t && (t = "");
|
|
var a = t + "_" + n.field,
|
|
s = $("<label>oooo</label>");
|
|
if (s[0].innerHTML = n.name, r.append($("<td></td>").append(s)), "table" == n.type) {
|
|
n.fieldFunc ? n.data = n.fieldFunc(e.data) : n.data = e.data[n.field];
|
|
var d = i.generateTable(n, a);
|
|
r.append($("<td></td>").append(d))
|
|
} else if ("form" == n.type) {
|
|
n.fieldFunc ? n.data = n.fieldFunc(e.data) : n.data = e.data[n.field];
|
|
var d = i.generateForm(n, a);
|
|
r.append($("<td></td>").append(d))
|
|
} else {
|
|
var l = i.generateEasyControls(n, i.GetValueByPropertyName(e.data, n.field), a);
|
|
s[0]["for"] = l[0].id, n.control = l[0], r.append($("<td></td>").append(l[0]))
|
|
}
|
|
o.push(r)
|
|
}), e.control = n, n.append(o), n
|
|
}, this.generateTable = function (e, t) {
|
|
var i = this,
|
|
n = $('<table class="WorkflowDesignerTable"></table>');
|
|
n.attr("name", i.getElementCode(e));
|
|
var o = $("<thead></thead>"),
|
|
r = $("<tr></tr>");
|
|
e.elements.forEach(function (e) {
|
|
var t = $("<th></th>");
|
|
t[0].innerHTML = e.name, void 0 != e.width && (t[0].width = e.width), r.append(t)
|
|
}), this.isReadOnly() || r.append("<th></th>"), o.append(r), n.append(o);
|
|
var a = function (o) {
|
|
void 0 != e.beforerowadded && e.beforerowadded(o);
|
|
var r = $("<tr></tr>");
|
|
e.keyproperty && r.attr("keyproperty", o[e.keyproperty]), void 0 == t && (t = "");
|
|
var a = t + WorkflowDesignerCommon.createUUID();
|
|
if (e.elements.forEach(function (e) {
|
|
if ("table" == e.type) {
|
|
e.fieldFunc ? e.data = e.fieldFunc(o) : e.data = o[e.field];
|
|
var t = i.generateTable(e, a);
|
|
r.append($("<td></td>").append(t))
|
|
} else {
|
|
var n = i.generateEasyControls(e, i.GetValueByPropertyName(o, e.field), a, o);
|
|
r.append($("<td></td>").append(n))
|
|
}
|
|
}), !i.isReadOnly()) {
|
|
var s = $('<a class="btnDelete"></a>');
|
|
s[0].innerHTML = WorkflowDesignerConstants.ButtonTextDelete, s[0].href = "#", s.on("click", function () {
|
|
return r.remove(), !1
|
|
}), r.append($("<td></td>").append(s))
|
|
}
|
|
n.append(r), void 0 != e.onrowadded && e.onrowadded(r)
|
|
};
|
|
void 0 != e.data && e.data.forEach(function (e) {
|
|
a(e)
|
|
}), e.control = n;
|
|
var s = new Array;
|
|
if (s.push(n), !this.isReadOnly()) {
|
|
var d = $('<a class="btnAdd"></a>');
|
|
d[0].innerHTML = WorkflowDesignerConstants.ButtonTextCreate, d[0].href = "#", d.on("click", function () {
|
|
var t = {};
|
|
return e.datadefault && (t = e.datadefault), a(t), !1
|
|
}), s.push(d)
|
|
}
|
|
return s
|
|
}, this.generateEasyControls = function (e, t, i, n) {
|
|
var o = this;
|
|
if ("input" == e.type) {
|
|
var r = $('<input style="width: 100%;"></input>');
|
|
if (r[0].id = this.generateid(e.field, i), r[0].name = o.getElementCode(e), void 0 != t && (r[0].value = t), o.isReadOnly() && r.attr("readonly", !0), void 0 != e.datasource) {
|
|
var a = {
|
|
minLength: 0,
|
|
autoFocus: !0,
|
|
source: e.datasource,
|
|
open: function (e, t) {
|
|
$(this).autocomplete("option", "appendTo", r[0].id), r[0].acwasopened || ($(this).autocomplete("close"), r[0].acwasopened = !0, $(this).autocomplete("search", r[0].value))
|
|
}
|
|
};
|
|
r.autocomplete(a), r.autocomplete("option", "appendTo", r[0].id)
|
|
}
|
|
return r
|
|
}
|
|
if ("json" == e.type) {
|
|
var r = $('<input style="width:100%"></input>');
|
|
r[0].id = this.generateid(e.field, i), r[0].name = o.getElementCode(e), void 0 != t && (r[0].value = t), o.isReadOnly() && r.attr("readonly", !0);
|
|
var s = $('<button style=" border: 0; background:transparent;"><img src="' + o.parameters.designer.Settings.imagefolder + 'designer.tb.codeactions.png" width="16" height="16" alt="submit" /></button>');
|
|
s[0].id = r[0].id + "_button";
|
|
var d = $('<div title="' + WorkflowDesignerConstants.EditJSONLabel.Title + '"><div id="' + r[0].id + '_editor" style="height:' + WorkflowDesignerConstants.EditJSONSettings.CodeHeight + 'px">' + r[0].value + "</div></div>");
|
|
return d[0].id = r[0].id + "_form", s.on("click", function (t) {
|
|
var i = d.dialog({
|
|
autoOpen: !1,
|
|
height: WorkflowDesignerConstants.EditJSONSettings.Height,
|
|
width: WorkflowDesignerConstants.EditJSONSettings.Width,
|
|
modal: !0,
|
|
buttons: {},
|
|
close: function () {
|
|
var e = ace.edit(r[0].id + "_editor").getValue();
|
|
r[0].value = o.toCompactJSON(e)
|
|
}
|
|
}),
|
|
n = d.dialog("option", "buttons");
|
|
r[0].readOnly || $.extend(n, {
|
|
format: {
|
|
text: WorkflowDesignerConstants.EditJSONLabel.Format,
|
|
click: function () {
|
|
var e = ace.edit(r[0].id + "_editor").getValue();
|
|
a.setValue(o.toPrettyJSON(e)), a.clearSelection()
|
|
}
|
|
}
|
|
}), void 0 == e.getemptytype || r[0].readOnly || $.extend(n, {
|
|
createemptytype: {
|
|
text: WorkflowDesignerConstants.EditJSONLabel.CreateEmptyType,
|
|
click: function () {
|
|
var t = e;
|
|
void 0 != t.getemptytype && t.getemptytype(o, r[0], function (e) {
|
|
void 0 != e && "" != e && (a.setValue(o.toPrettyJSON(e)), a.clearSelection())
|
|
})
|
|
}
|
|
}
|
|
}), d.dialog("option", "buttons", n);
|
|
var a = ace.edit(r[0].id + "_editor");
|
|
r[0].readOnly ? a.setOptions({
|
|
readOnly: !0
|
|
}) : a.setOptions({
|
|
readOnly: !1
|
|
}), a.getSession().setMode("ace/mode/json"), a.setValue(o.toPrettyJSON(r[0].value)), a.clearSelection(), i.dialog("open")
|
|
}), $('<div style="width:100%;"></div>').append($('<div style="width:16px; float:right; margin-right: 7px;"></div>').append(s)).append($('<div style="overflow: hidden;"></div>').append(r))
|
|
}
|
|
if ("code" == e.type) {
|
|
void 0 == t && (t = "");
|
|
var r = $("<button>" + WorkflowDesignerConstants.EditCodeLabel.EditCodeButton + "</button>");
|
|
r[0].id = this.generateid(e.field, i), r[0].name = o.getElementCode(e), r[0].code = {}, r[0].code.code = decodeURIComponent(t);
|
|
var l = n.Usings;
|
|
l = void 0 == l ? o.parameters.designer.data.AdditionalParams.Usings.join(";") + ";" : decodeURIComponent(l), r[0].code.usings = l;
|
|
var d = $('<div title="' + WorkflowDesignerConstants.EditCodeLabel.Title + '"><div id="' + r[0].id + '_usings"><h3>' + WorkflowDesignerConstants.EditCodeLabel.Usings + '</h3><textarea rows="10" style="width:100%" id="' + r[0].id + '_usingsedit"></textarea></div><div id="' + r[0].id + '_function_upper"></div><div id="' + r[0].id + '_editor" style="height:' + WorkflowDesignerConstants.EditCodeSettings.CodeHeight + 'px">' + this.htmlEncode(r[0].code.code) + '</div><div id="' + r[0].id + '_function_lower">}</div></div>');
|
|
return d[0].id = r[0].id + "_form", o.isReadOnly() && r.attr("disabled", !0),
|
|
r.on("click", function (e) {
|
|
var t = d.dialog({
|
|
autoOpen: !1,
|
|
height: WorkflowDesignerConstants.EditCodeSettings.Height,
|
|
width: WorkflowDesignerConstants.EditCodeSettings.Width,
|
|
modal: !0,
|
|
buttons: {
|
|
compile: {
|
|
text: WorkflowDesignerConstants.EditCodeLabel.Compile,
|
|
click: function () {
|
|
for (var e = o.getEditData(o.parameters), t = void 0, i = 0; i < e.length; i++)
|
|
if (e[i].control_ActionCode.id == r[0].id) {
|
|
t = e[i];
|
|
break
|
|
}
|
|
if (void 0 != t) {
|
|
t.ActionCode = encodeURIComponent(ace.edit(r[0].id + "_editor").getValue()), t.Usings = encodeURIComponent($("#" + r[0].id + "_usingsedit")[0].value.replace(/(\r\n|\n|\r)/gm, ""));
|
|
var n = function (e) {
|
|
$('<div title="' + (e.Success ? WorkflowDesignerConstants.EditCodeLabel.Success : WorkflowDesignerConstants.EditCodeLabel.Error) + '">' + (e.Success ? WorkflowDesignerConstants.EditCodeLabel.CompileSucceeded : e.Message) + "</div>").dialog({
|
|
modal: !0,
|
|
height: e.Success ? WorkflowDesignerConstants.EditCodeSettingsSuccessBoxHeight : WorkflowDesignerConstants.EditCodeSettings.MessageBoxHeight,
|
|
width: e.Success ? WorkflowDesignerConstants.EditCodeSettings.SuccessBoxWidth : WorkflowDesignerConstants.EditCodeSettings.MessageBoxWidth,
|
|
buttons: {
|
|
ok: {
|
|
text: WorkflowDesignerConstants.EditCodeLabel.OK,
|
|
click: function () {
|
|
$(this).dialog("close")
|
|
}
|
|
}
|
|
}
|
|
})
|
|
};
|
|
o.parameters.designer.designer.compile(t, n)
|
|
}
|
|
}
|
|
}
|
|
},
|
|
close: function () {
|
|
r[0].code = {}, r[0].code.code = ace.edit(r[0].id + "_editor").getValue(), r[0].code.usings = $("#" + r[0].id + "_usingsedit")[0].value.replace(/(\r\n|\n|\r)/gm, "")
|
|
}
|
|
});
|
|
$("#" + r[0].id + "_usingsedit")[0].value = o.htmlEncode(o.modifyUsingString(r[0].code.usings)), $("#" + r[0].id + "_usings").accordion({
|
|
collapsible: !0,
|
|
active: !1,
|
|
heightStyle: "content"
|
|
});
|
|
var n = $("#" + o.generateid("Type", i))[0].value.toLowerCase(),
|
|
a = $("#" + o.generateid("Name", i))[0].value;
|
|
"" === a && (a = "???");
|
|
var s = "{";
|
|
"action" === n && (s = "void " + a + " (ProcessInstance processInstance, WorkflowRuntime runtime, string parameter) {"), "condition" === n && (s = "bool " + a + " (ProcessInstance processInstance, WorkflowRuntime runtime, string parameter) {"), "ruleget" === n && (s = "IEnumerable<string> " + a + " (ProcessInstance processInstance, WorkflowRuntime runtime, string parameter) {"), "rulecheck" === n && (s = "bool " + a + " (ProcessInstance processInstance, WorkflowRuntime runtime, string identityId, string parameter) {"), $("#" + r[0].id + "_function_upper").html(s);
|
|
var l = ace.edit(r[0].id + "_editor");
|
|
l.getSession().setMode("ace/mode/csharp"), t.dialog("open")
|
|
}), r
|
|
}
|
|
if ("checkbox" == e.type) {
|
|
var r = $('<input style="width: 100%;"></input>');
|
|
return r[0].type = "checkbox", r[0].id = this.generateid(e.field, i), r[0].checked = t, r[0].name = o.getElementCode(e), o.isReadOnly() && r.attr("disabled", "disabled"), r
|
|
}
|
|
if ("select" == e.type) {
|
|
var r = $('<select style="width: 100%;"></select>');
|
|
return r[0].id = this.generateid(e.field, i), r[0].name = o.getElementCode(e), r.append($("<option></option>")), void 0 != e.datasource && e.datasource.forEach(function (i) {
|
|
var n = $("<option></option>");
|
|
void 0 == e.displayfield ? (n[0].value = i, n[0].innerHTML = i) : (n[0].value = i[e.displayfield], n[0].innerHTML = i[e.displayfield]), n[0].value == t && (n[0].selected = "selected"), o.isReadOnly() && r.attr("readonly", !0), r.append(n)
|
|
}), r
|
|
}
|
|
if ("textarea" == e.type) {
|
|
var r = $('<textarea rows="6" style="width: 100%;"></textarea>');
|
|
return r[0].id = o.generateid(e.field, i), r[0].name = o.getElementCode(e), void 0 != t && (r[0].value = t), this.isReadOnly() && r.attr("readonly", !0), r
|
|
}
|
|
}, this.modifyUsingString = function (e) {
|
|
var t = e.substring(e.length - 1);
|
|
return ";" === t && (e = e.substring(0, e.length - 1)), e.split(";").join(";\r\n") + ";"
|
|
}, this.getEasyControlValue = function (e) {
|
|
return "input" == e.type ? e.control.value : "json" == e.type ? e.control.value : "code" == e.type ? e.control.code : "checkbox" == e.type ? e.control.checked : "select" == e.type ? e.control.value : "textarea" == e.type ? e.control.value : void 0
|
|
}, this.generateid = function (e, t) {
|
|
return t ? e + "_" + t + "_" + this.id : e + "_" + this.id
|
|
}, this.GetValueByPropertyName = function (e, t) {
|
|
if (void 0 != e) {
|
|
if (t.indexOf(".") < 0) return e[t];
|
|
var i = e;
|
|
return t.split(".").forEach(function (e) {
|
|
void 0 != i && (i = i[e])
|
|
}), i
|
|
}
|
|
}, this.SetValueByPropertyName = function (e, t, i) {
|
|
if (t.indexOf(".") < 0) return e[t] = i;
|
|
for (var n = e, o = t.split("."), r = 0; r < o.length; r++) {
|
|
var a = o[r];
|
|
r == o.length - 1 ? n[a] = i : (void 0 == n[a] && (n[a] = {}), n = n[a])
|
|
}
|
|
}, this.ClearError = function () {
|
|
var e = this.window.find(".field-validation-error");
|
|
e.attr("title", ""), e.removeClass("field-validation-error")
|
|
}, this.ControlAddError = function (e, t) {
|
|
var i = $(e);
|
|
i.addClass("field-validation-error"), i.attr("title", t)
|
|
}, this.CheckRequired = function (e, t, i) {
|
|
var n = this,
|
|
o = !0;
|
|
return e.forEach(function (e) {
|
|
t.forEach(function (t) {
|
|
"" == n.GetValueByPropertyName(e, t) && (n.ControlAddError(e["control_" + t], i), o = !1)
|
|
})
|
|
}), o
|
|
}, this.CheckUnique = function (e, t, i) {
|
|
for (var n = this, o = !0, r = 0; r < e.length; r++)
|
|
for (var a = r + 1; a < e.length; a++) this._checkUniqueEquals(e[r], e[a], t) && (t.forEach(function (t) {
|
|
n.ControlAddError(e[r]["control_" + t], i), n.ControlAddError(e[a]["control_" + t], i)
|
|
}), o = !1);
|
|
return o
|
|
}, this._checkUniqueEquals = function (e, t, i) {
|
|
for (var n = 0; n < i.length; n++) {
|
|
var o = i[n];
|
|
if (e[o] != t[o]) return !1
|
|
}
|
|
return !0
|
|
};
|
|
var t = this;
|
|
this.ClearTempField = function (e, i) {
|
|
void 0 != e && (void 0 == i && (i = this.parameters.elements), i.forEach(function (n) {
|
|
$.isArray(e) ? e.forEach(function (e) {
|
|
t.ClearTempField(e, i)
|
|
}) : void 0 != e["control_" + n.field] && (e["control_" + n.field] = void 0), n.elements && t.ClearTempField(e[n.field], n.elements)
|
|
}))
|
|
}, this.getElementCode = function (e) {
|
|
return void 0 != e.code ? e.code : e.field
|
|
}, this.htmlEncode = function (e) {
|
|
return $("<div/>").text(e).html()
|
|
}, this.htmlDecode = function (e) {
|
|
return $("<div/>").html(e).text()
|
|
}, this.toCompactJSON = function (e) {
|
|
try {
|
|
return JSON.stringify(JSON.parse(e))
|
|
} catch (t) {
|
|
try {
|
|
return JSON5.stringify(JSON5.parse(e))
|
|
} catch (t) {
|
|
return e
|
|
}
|
|
}
|
|
}, this.toPrettyJSON = function (e) {
|
|
try {
|
|
return JSON.stringify(JSON.parse(e), null, " ")
|
|
} catch (t) {
|
|
try {
|
|
return JSON5.stringify(JSON5.parse(e), null, " ")
|
|
} catch (t) {
|
|
return e
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function WorkflowGraph(e, t, i, n) {
|
|
var o = this;
|
|
o.container = e, o.designer = t, void 0 == i && (i = new Object), void 0 == i.Container && (i.Container = "container"), void 0 == i.graphwidth && (i.graphwidth = 1024), void 0 == i.graphheight && (i.graphheight = 768), void 0 == i.DefaultActivityWidth && (i.DefaultActivityWidth = 150), void 0 == i.DefaultActivityHeight && (i.DefaultActivityHeight = 75), void 0 == i.DefaultMoveStep && (i.DefaultMoveStep = 10), void 0 == i.imagefolder && (i.imagefolder = "/Content/images/WorkFlow/"), this.Settings = i, this.Settings.ContainerStage = this.container + "_stage", $("#" + this.container).append("<div id='" + this.Settings.ContainerStage + "'></div>"), this.Stage = new Kinetic.Stage({
|
|
container: this.Settings.ContainerStage,
|
|
width: this.Settings.graphwidth,
|
|
height: this.Settings.graphheight,
|
|
stroke: "black"
|
|
}), this.Components = new Array, this.AddComponent = function (e) {
|
|
var t = new e;
|
|
return t.init(this), o.Components.push(t), t
|
|
}, this.GetComponentByType = function (e) {
|
|
for (var t = 0; t < this.Components.length; t++)
|
|
if (this.Components[t].type == e) return this.Components[t]
|
|
}, this.ComponentsExecute = function (e, t) {
|
|
o.Components.forEach(function (i) {
|
|
i[e] && i[e](t)
|
|
})
|
|
}, n && n.forEach(function (e) {
|
|
o.AddComponent(e)
|
|
}), this.Draw = function (e) {
|
|
o.data = e, o.ComponentsExecute("draw")
|
|
}, this.GraphLayerSetOffset = function (e, t) {
|
|
o.ComponentsExecute("LayerSetOffset", {
|
|
x: e,
|
|
y: t
|
|
}), o.redrawAll()
|
|
}, this.GraphLayerScale = function (e) {
|
|
o.ComponentsExecute("LayerScale", e), o.redrawAll()
|
|
}, this.GraphLayerScaleNorm = function (e) {
|
|
o.ComponentsExecute("LayerScaleNorm", e), o.redrawAll()
|
|
}, this.DeselectAll = function () {
|
|
o.ComponentsExecute("DeselectAll"), o.redrawAll()
|
|
}, this.redrawAll = function () {
|
|
o.ComponentsExecute("GraphRedrawAll"), o.Stage.batchDraw()
|
|
}, this.CorrectPossition = function (e, t) {
|
|
return 0 == t.getScaleX() || 0 == t.getScaleY() ? {
|
|
x: t.getOffsetX(),
|
|
y: 0
|
|
} : {
|
|
x: e.x / t.getScaleX() + t.getOffsetX(),
|
|
y: e.y / t.getScaleY() + t.getOffsetY()
|
|
}
|
|
}, this.DeleteSelected = function () {
|
|
var e = new Array;
|
|
this.Components.forEach(function (t) {
|
|
t.GetSelected && (e = e.concat(t.GetSelected()))
|
|
}), e.length > 0 && confirm(WorkflowDesignerConstants.DeleteConfirm) && (e.forEach(function (e) {
|
|
e.Delete()
|
|
}), this.redrawAll())
|
|
}, this.destroy = function () {
|
|
this.Stage.destroy()
|
|
}, this.GetCurrentActivity = function () {
|
|
if (void 0 != o.data && void 0 != o.data.AdditionalParams && void 0 != o.data.AdditionalParams.ProcessParameters)
|
|
for (var e = 0; e < o.data.AdditionalParams.ProcessParameters.length; e++) {
|
|
var t = o.data.AdditionalParams.ProcessParameters[e];
|
|
if ("CurrentActivity" == t.Name) return t.Value
|
|
}
|
|
}, this.getActionNames = function () {
|
|
for (var e = this, t = new Array, i = 0; i < e.data.CodeActions.length; i++) {
|
|
var n = e.data.CodeActions[i];
|
|
"action" === n.Type.toLowerCase() && t.push(n.Name)
|
|
}
|
|
return e.data.AdditionalParams.Actions.concat(t)
|
|
}, this.getConditionNames = function () {
|
|
for (var e = this, t = new Array, i = 0; i < e.data.CodeActions.length; i++) {
|
|
var n = e.data.CodeActions[i];
|
|
"condition" === n.Type.toLowerCase() && t.push(n.Name)
|
|
}
|
|
return e.data.AdditionalParams.Actions.concat(t)
|
|
}, this.getActorNames = function () {
|
|
return this.Settings.WorkFlowRoles;
|
|
|
|
|
|
|
|
}, this.getActorConditions = function () {
|
|
for (var e = this, t = new Array, i = 0; i < e.data.CodeActions.length; i++) {
|
|
var n = e.data.CodeActions[i];
|
|
("ruleget" === n.Type.toLowerCase() || "rulecheck" === n.Type.toLowerCase()) && t.push(n.Name)
|
|
}
|
|
var rt = $.unique(e.data.AdditionalParams.Rules.concat(t))
|
|
return rt
|
|
}, this.getTypeNames = function () {
|
|
for (var e = this, t = new Array, i = 0; i < e.data.Parameters.length; i++) {
|
|
var n = e.data.Parameters[i];
|
|
t.push(decodeURIComponent(n.Type))
|
|
}
|
|
return $.unique(e.data.AdditionalParams.Types.concat(t))
|
|
}, this.getNonSystemParameters = function () {
|
|
for (var e = this, t = new Array, i = 0; i < e.data.Parameters.length; i++) {
|
|
var n = e.data.Parameters[i];
|
|
"system" != n.Purpose.toLowerCase() && t.push(n)
|
|
}
|
|
return t
|
|
}
|
|
}
|
|
var hideCodedActions=false;
|
|
var WorkflowDesignerConstants = {
|
|
SelectColor: "yellow",
|
|
ActivityColor: "#F2F2F2",
|
|
ActivityInitialColor: "#CCCC99",
|
|
ActivityFinalColor: "#CC9966",
|
|
ActivityCurrentColor: "#00CCCC",
|
|
DeleteConfirm: "Are you sure you want to delete selected item(s)?",
|
|
FieldIsRequired: "Field is required!",
|
|
FieldMustBeUnique: "Field must be unique!",
|
|
ButtonTextDelete: "Delete",
|
|
ButtonTextCreate: "Create",
|
|
InfoBlockLabel: {
|
|
Activity: "Activity: ",
|
|
Transition: "Transition: ",
|
|
Command: "Command: "
|
|
},
|
|
ActivityNamePrefix: "Activity_",
|
|
ActivityFormLabel: {
|
|
Title: "Activity",
|
|
Name: "Name",
|
|
State: "State",
|
|
IsInitial: "Initial",
|
|
IsFinal: "Final",
|
|
IsForSetState: "For set state",
|
|
IsAutoSchemeUpdate: "Auto scheme update",
|
|
Implementation: "Implementation",
|
|
PreExecutionImplementation: "PreExecution Implementation",
|
|
ImpOrder: "Order",
|
|
ImpAction: "Action",
|
|
ImpActionParameter: "Action parameter",
|
|
AlwaysConditionShouldBeSingle: "Always condition should be single",
|
|
OtherwiseConditionShouldBeSingle: "Otherwise condition should be single"
|
|
},
|
|
TransitionFormLabel: {
|
|
Title: "Transition",
|
|
Name: "Name",
|
|
From: "From activity",
|
|
To: "To activity",
|
|
Classifier: "Classifier",
|
|
Restrictions: "Restrictions",
|
|
RestrictionsType: "Type",
|
|
RestrictionsActor: "Actor",
|
|
Condition: "Condition",
|
|
ConditionType: "Type",
|
|
ConditionAction: "Action",
|
|
ResultOnPreExecution: "Result on PreExecution",
|
|
Trigger: "Trigger",
|
|
TriggerType: "Type",
|
|
TriggerCommand: "Command",
|
|
TriggerTimer: "Timer",
|
|
ConditionActionParameter: "Action parameter",
|
|
ConditionInversion: "Invert action result",
|
|
ConditionsConcatenationType: "Conditions concatenation type",
|
|
AllowConcatenationType: "Concat allow as",
|
|
RestrictConcatenationType: "Concat restrict as",
|
|
ConditionsListShouldNotBeEmpty: "Conditions list should not be empty",
|
|
IsFork: "Is fork",
|
|
MergeViaSetState: "Merge subprocess via set state",
|
|
DisableParentStateControl: "Disable parent process control"
|
|
},
|
|
LocalizationFormLabel: {
|
|
Title: "Localization",
|
|
ObjectName: "ObjectName",
|
|
Type: "Type",
|
|
IsDefault: "IsDefault",
|
|
Culture: "Culture",
|
|
Value: "Value",
|
|
Types: ["Command", "State", "Parameter"]
|
|
},
|
|
TimerFormLabel: {
|
|
Title: "Timers",
|
|
Name: "Name",
|
|
Type: "Type",
|
|
Value: "Value",
|
|
Types: ["Command", "State", "Parameter"],
|
|
NotOverrideIfExists: "Do not override timer if exists"
|
|
},
|
|
ParameterFormLabel: {
|
|
Title: "Parameters",
|
|
Name: "Name",
|
|
Type: "Type",
|
|
Purpose: "Purpose",
|
|
Value: "Value",
|
|
InitialValue: "InitialValue",
|
|
ShowSystemParameters: "Show system parameters"
|
|
},
|
|
ActorFormLabel: {
|
|
Title: "Actors",
|
|
Name: "Name",
|
|
Rule: "Rule",
|
|
Value: "Value"
|
|
},
|
|
CommandFormLabel: {
|
|
Title: "Command",
|
|
Name: "Name",
|
|
InputParameters: "Input Parameters",
|
|
InputParametersName: "Name",
|
|
InputParametersIsRequired: "Required",
|
|
InputParametersParameter: "Parameter",
|
|
InputParametersDefaultValue: "Default"
|
|
},
|
|
AdditionalParamsFormLabel: {
|
|
Title: "Additional Parameters",
|
|
IsObsolete: "IsObsolete",
|
|
DefiningParameters: "Defining parameters",
|
|
ProcessParameters: "Process parameters",
|
|
ProcessParametersName: "Name",
|
|
ProcessParametersValue: "Value"
|
|
},
|
|
CodeActionsFormLabel: {
|
|
Title: "Code actions",
|
|
Name: "Name",
|
|
ActionCode: "Action code",
|
|
IsGlobal: "Is global",
|
|
Type: "Type"
|
|
},
|
|
ToolbarLabel: {
|
|
CreateActivity: "Create activity",
|
|
CopySelected: "Copy selected",
|
|
Undo: "Undo",
|
|
Redo: "Redo",
|
|
Move: "Move",
|
|
ZoomIn: "Zoom In",
|
|
ZoomOut: "Zoom Out",
|
|
ZoomPositionDefault: "Zoom and position default set",
|
|
AutoArrangement: "Auto arrangement",
|
|
Actors: "Actors",
|
|
Commands: "Commands",
|
|
Parameters: "Parameters",
|
|
Localization: "Localization",
|
|
Timers: "Timers",
|
|
AdditionalParameters: "Additional Parameters",
|
|
CodeActions: "Code actions"
|
|
},
|
|
ErrorActivityIsInitialCountText: "One element must be marked flag Initial",
|
|
ErrorReadOnlySaveText: "The Designer in ReadOnly mode, you can't save it.",
|
|
FormMaxHeight: 500,
|
|
EditCodeSettings: {
|
|
Height: 600,
|
|
Width: 1e3,
|
|
CodeHeight: 390,
|
|
MessageBoxHeight: 400,
|
|
MessageBoxWidth: 600,
|
|
SuccessBoxHeight: 150,
|
|
SuccessBoxWidth: 300
|
|
},
|
|
EditCodeLabel: {
|
|
Title: "Edit code",
|
|
EditCodeButton: "Edit code",
|
|
Usings: "Usings",
|
|
Compile: "Compile",
|
|
CompileSucceeded: "Compilation succeeded.",
|
|
Success: "Success",
|
|
Error: "Error",
|
|
OK: "OK"
|
|
},
|
|
EditJSONSettings: {
|
|
Height: 600,
|
|
Width: 1e3,
|
|
CodeHeight: 480
|
|
},
|
|
EditJSONLabel: {
|
|
Title: "Edit value in JSON",
|
|
CreateEmptyType: "Create",
|
|
Format: "Format"
|
|
}
|
|
},
|
|
WorkflowDesignerCommon = {
|
|
createArrowByAngle: function (e, t, i, n, o) {
|
|
void 0 == o && (o = "red");
|
|
var r = new Kinetic.Wedge({
|
|
x: e,
|
|
y: t,
|
|
radius: n,
|
|
angle: 40,
|
|
fill: o,
|
|
rotation: 180 * i / Math.PI - 200
|
|
});
|
|
return r
|
|
},
|
|
updateArrowByAngle: function (e, t, i, n, o, r) {
|
|
void 0 == r && (r = "red"), e.setPosition({
|
|
x: t,
|
|
y: i
|
|
}), e.setRadius(o), e.setFill(r), e.setRotation(180 * n / Math.PI - 200)
|
|
},
|
|
createUUID: function () {
|
|
for (var e = [], t = "0123456789abcdef", i = 0; 36 > i; i++) e[i] = t.substr(Math.floor(16 * Math.random()), 1);
|
|
e[14] = "4", e[19] = t.substr(3 & e[19] | 8, 1), e[8] = e[13] = e[18] = e[23] = "-";
|
|
var n = e.join("");
|
|
return n
|
|
},
|
|
DataCorrection: function (e) {
|
|
void 0 == e.AdditionalParams && (e.AdditionalParams = {}), void 0 == e.AdditionalParams.Actions && (e.AdditionalParams.Actions = []), void 0 == e.AdditionalParams.Rules && (e.AdditionalParams.Rules = []);
|
|
var t = function (e, t) {
|
|
if (void 0 != e) {
|
|
var i = $.grep(t, function (t) {
|
|
return t == e
|
|
});
|
|
0 == i.length && t.push(e)
|
|
}
|
|
},
|
|
i = function (e, t, i) {
|
|
if (void 0 != e && void 0 != t) {
|
|
var n = $.grep(t, function (t) {
|
|
return e == t[i]
|
|
});
|
|
return n.length > 0 ? n[0] : void 0
|
|
}
|
|
};
|
|
e.Activities.forEach(function (i) {
|
|
void 0 != i.Implementation && (i.Implementation.forEach(function (i) {
|
|
t(i.Name, e.AdditionalParams.Actions)
|
|
}), i.PreExecutionImplementation.forEach(function (i) {
|
|
t(i.Name, e.AdditionalParams.Actions)
|
|
}))
|
|
}), e.Transitions.forEach(function (n) {
|
|
void 0 != n.From && (n.From = i(n.From.Name, e.Activities, "Name")), void 0 != n.To && (n.To = i(n.To.Name, e.Activities, "Name")), void 0 != n.Restrictions && n.Restrictions.forEach(function (t) {
|
|
t.Actor = i(t.Actor.Name, e.Actors, "Name")
|
|
}), void 0 != n.Condition && void 0 != n.Condition.Action && t(n.Condition.Action.Name, e.AdditionalParams.Actions), void 0 != n.Trigger && void 0 != n.Trigger.Command && (n.Trigger.Command = i(n.Trigger.Command.Name, e.Commands, "Name")), void 0 != n.Trigger && void 0 != n.Trigger.Timer && (n.Trigger.Timer = i(n.Trigger.Timer.Name, e.Timers, "Name"))
|
|
}), e.Commands.forEach(function (t) {
|
|
void 0 != t.InputParameters && t.InputParameters.forEach(function (t) {
|
|
t.Parameter = i(t.Parameter.Name, e.Parameters, "Name")
|
|
})
|
|
}), e.Actors.forEach(function (i) {
|
|
void 0 != i.Rule && t(i.Rule, e.AdditionalParams.Rules)
|
|
})
|
|
},
|
|
download: function (e, t, i) {
|
|
if (e && t) {
|
|
var n = new Array;
|
|
t.forEach(function (e) {
|
|
var t = $('<input type="hidden"/>');
|
|
t.attr("name", e.name), t.attr("value", e.value), n.push(t)
|
|
});
|
|
var o = $('<form action="' + e + '" method="' + (i || "post") + '"></form>');
|
|
o.append(n), o.appendTo("body").submit().remove()
|
|
}
|
|
}
|
|
}; |