mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Preserve event handlers when moving outliner items
This commit is contained in:
parent
565aae5967
commit
7c2786969a
@ -33,7 +33,7 @@
|
||||
* methods:
|
||||
* - addItem(itemData)
|
||||
* - insertItemAt : function(data,index) - add an item at the specified index
|
||||
* - removeItem(itemData)
|
||||
* - removeItem(itemData, detach) - remove the item. Optionally detach to preserve any event handlers on the item's label
|
||||
* - getItemAt(index)
|
||||
* - indexOf(itemData)
|
||||
* - width(width)
|
||||
@ -332,11 +332,15 @@
|
||||
this.addItem(items[i]);
|
||||
}
|
||||
},
|
||||
removeItem: function(data) {
|
||||
removeItem: function(data,detach) {
|
||||
var items = this.element.children().filter(function(f) {
|
||||
return data === $(this).children(".red-ui-editableList-item-content").data('data');
|
||||
});
|
||||
items.remove();
|
||||
if (detach) {
|
||||
items.detach();
|
||||
} else {
|
||||
items.remove();
|
||||
}
|
||||
if (this.options.removeItem) {
|
||||
this.options.removeItem(data);
|
||||
}
|
||||
|
@ -65,7 +65,7 @@
|
||||
* item.treeList.container
|
||||
* item.treeList.label - the label element for the item
|
||||
* item.treeList.parentList - the editableList instance this item is in
|
||||
* item.treeList.remove() - removes the item from the tree
|
||||
* item.treeList.remove(detach) - removes the item from the tree. Optionally detach to preserve any event handlers on the item's label
|
||||
* item.treeList.makeLeaf(detachChildElements) - turns an element with children into a leaf node,
|
||||
* removing the UI decoration etc.
|
||||
* detachChildElements - any children with custom
|
||||
@ -311,9 +311,9 @@
|
||||
this._items[item.id] = item;
|
||||
item.treeList = {};
|
||||
item.depth = depth;
|
||||
item.treeList.remove = function() {
|
||||
item.treeList.remove = function(detach) {
|
||||
if (item.treeList.parentList) {
|
||||
item.treeList.parentList.editableList('removeItem',item);
|
||||
item.treeList.parentList.editableList('removeItem',item,detach);
|
||||
}
|
||||
if (item.parent) {
|
||||
var index = item.parent.children.indexOf(item);
|
||||
@ -322,7 +322,7 @@
|
||||
}
|
||||
that._selected.delete(item);
|
||||
delete item.treeList;
|
||||
delete(that._items[item.id]);
|
||||
delete that._items[item.id];
|
||||
}
|
||||
item.treeList.insertChildAt = function(newItem,position,select) {
|
||||
newItem.parent = item;
|
||||
|
@ -365,7 +365,7 @@ RED.sidebar.info.outliner = (function() {
|
||||
|
||||
function onNodeChange(n) {
|
||||
var existingObject = objects[n.id];
|
||||
var parent = n.g||n.z;
|
||||
var parent = n.g||n.z||"__global__";
|
||||
|
||||
var nodeLabelText = getNodeLabelText(n);
|
||||
if (nodeLabelText) {
|
||||
@ -373,10 +373,9 @@ RED.sidebar.info.outliner = (function() {
|
||||
} else {
|
||||
existingObject.element.find(".red-ui-info-outline-item-label").html(" ");
|
||||
}
|
||||
|
||||
if (parent !== existingObject.parent.id) {
|
||||
existingObject.treeList.remove();
|
||||
if (!parent) {
|
||||
existingObject.treeList.remove(true);
|
||||
if (parent === "__global__") {
|
||||
globalConfigNodes.treeList.addChild(existingObject);
|
||||
} else {
|
||||
if (empties[parent]) {
|
||||
|
Loading…
Reference in New Issue
Block a user