we can do cool stuff now like drag'n'drop instances
This commit is contained in:
parent
f20fa1f393
commit
f81697dd1e
@ -22,6 +22,32 @@ function McxInstanceBrowser(parentElement)
|
||||
this.NativeObject.setEditing(false);
|
||||
});
|
||||
|
||||
this.ParentElement.addEventListener("dragover", function (e) {
|
||||
if (System.ClassList.Contains(this, "mcx-editable")) {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
var data = e.dataTransfer.getData("application/x-mocha-instance");
|
||||
console.log(e);
|
||||
console.log(data);
|
||||
if (data == null)
|
||||
{
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
this.ParentElement.addEventListener("drop", function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var data = e.dataTransfer.getData("application/x-mocha-instance");
|
||||
if (data == null) return;
|
||||
|
||||
data = JSON.parse(data);
|
||||
console.log(data);
|
||||
|
||||
var instanceKey = InstanceKey.parse(data.iid);
|
||||
this.NativeObject.add(instanceKey, data.text, data.url);
|
||||
});
|
||||
|
||||
this.setEditing = function(value)
|
||||
{
|
||||
if (value)
|
||||
@ -367,10 +393,30 @@ function McxInstanceBrowser(parentElement)
|
||||
}
|
||||
});
|
||||
|
||||
this.add = function(instanceKey, title, url)
|
||||
{
|
||||
var strbps = this.HiddenElement.value;
|
||||
var strbpa = strbps.split(",");
|
||||
for (var i = 0; i < strbpa.length; i++)
|
||||
{
|
||||
if (strbpa[i] === instanceKey.toString())
|
||||
{
|
||||
Alert.show("The instance you selected has already been added", null, "uwt-alert-mini", 5000);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
strbpa.push(instanceKey.toString());
|
||||
this.HiddenElement.value = strbpa.join(",");
|
||||
|
||||
var p = McxMoniker.create(instanceKey, title, url);
|
||||
var li = document.createElement("li");
|
||||
li.appendChild(p);
|
||||
this.ListElement.appendChild(li);
|
||||
};
|
||||
|
||||
this.removeAt = function(index)
|
||||
{
|
||||
console.log(this.HiddenElement);
|
||||
|
||||
var strbps = this.HiddenElement.value;
|
||||
var strbpa = strbps.split(",");
|
||||
var strbpn = [ ];
|
||||
|
||||
@ -5,7 +5,7 @@ function InstanceKey()
|
||||
|
||||
this.toString = function()
|
||||
{
|
||||
return this.ClassIndex + "$" + this.InstanceIndex;
|
||||
return this.ClassIndex.toString() + "$" + this.InstanceIndex.toString();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -34,6 +34,20 @@ function McxMoniker(parentElement)
|
||||
this.PopupElement = this.ParentElement.children[2];
|
||||
}
|
||||
|
||||
this.ParentElement.draggable = true;
|
||||
this.LabelElement.draggable = false;
|
||||
this.ButtonElement.draggable = false;
|
||||
|
||||
this.ParentElement.addEventListener("dragstart", function (e) {
|
||||
console.log(this.McxNativeObject.ParentElement.getAttribute("data-instance-id") + "0" + this.McxNativeObject.LabelElement.innerText);
|
||||
|
||||
e.dataTransfer.setData("application/x-mocha-instance", JSON.stringify({
|
||||
"url": this.McxNativeObject.LabelElement.tagName == "A" ? this.McxNativeObject.LabelElement.href : null,
|
||||
"text": this.McxNativeObject.LabelElement.innerText,
|
||||
"iid": this.McxNativeObject.ParentElement.getAttribute("data-instance-id")
|
||||
}));
|
||||
});
|
||||
87
|
||||
this.ParentElement.addEventListener("contextmenu", function(e)
|
||||
{
|
||||
var cm = new ContextMenu();
|
||||
@ -310,8 +324,13 @@ function McxMoniker(parentElement)
|
||||
|
||||
McxMoniker.create = function(instanceKey, title, viewTask)
|
||||
{
|
||||
if (typeof (instanceKey) === 'string')
|
||||
{
|
||||
instanceKey = InstanceKey.parse(instanceKey);
|
||||
}
|
||||
|
||||
var div = document.createElement("div");
|
||||
div.setAttribute("data-instance-id", instanceKey);
|
||||
div.setAttribute("data-instance-id", instanceKey.toString());
|
||||
div.className = "mcx-moniker uwt-actionpreviewbutton apb-show-text apb-style-ellipsis";
|
||||
|
||||
var img = document.createElement("img");
|
||||
@ -320,7 +339,7 @@ McxMoniker.create = function(instanceKey, title, viewTask)
|
||||
{
|
||||
this.style.display="none";
|
||||
});
|
||||
img.src = "/madi/asset/uic-assets/1.1.5/zq/icons/1$" + instanceKey.split("$")[0];
|
||||
img.src = "/madi/asset/uic-assets/1.1.5/zq/icons/1$" + instanceKey.ClassIndex;
|
||||
img.setAttribute("alt", "");
|
||||
div.appendChild(img);
|
||||
|
||||
@ -328,7 +347,7 @@ McxMoniker.create = function(instanceKey, title, viewTask)
|
||||
if (viewTask != null)
|
||||
{
|
||||
a.className = "apb-text";
|
||||
a.href = System.ExpandRelativePath("~/" + System.TenantName + "/d/inst/" + instanceKey + ".htmld");
|
||||
a.href = System.ExpandRelativePath("~/" + System.TenantName + "/d/inst/" + instanceKey.toString() + ".htmld");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -346,7 +365,7 @@ McxMoniker.create = function(instanceKey, title, viewTask)
|
||||
|
||||
a = document.createElement("a");
|
||||
a.className = "apb-button";
|
||||
a.href = System.ExpandRelativePath("~/" + System.TenantName + "/d/inst/" + instanceKey + "/rel-tasks.htmld");
|
||||
a.href = System.ExpandRelativePath("~/" + System.TenantName + "/d/inst/" + instanceKey.toString() + "/rel-tasks.htmld");
|
||||
a.innerHTML = " ";
|
||||
div.appendChild(a);
|
||||
|
||||
@ -383,7 +402,7 @@ McxMoniker.create = function(instanceKey, title, viewTask)
|
||||
|
||||
var img = document.createElement("img");
|
||||
img.className = "apb-icon";
|
||||
img.src = "/madi/asset/uic-assets/1.1.5/zq/icons/1$" + instanceKey.split("$")[0];
|
||||
img.src = "/madi/asset/uic-assets/1.1.5/zq/icons/1$" + instanceKey.ClassIndex;
|
||||
img.setAttribute("alt", "");
|
||||
h2.appendChild(img);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user