1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00
This commit is contained in:
Dave Conway-Jones 2020-06-05 11:22:42 +01:00
commit cb218a57f1
No known key found for this signature in database
GPG Key ID: 302A6725C594817F
6 changed files with 34 additions and 20 deletions

View File

@ -20,7 +20,9 @@
"fill": "Fill", "fill": "Fill",
"label": "Label", "label": "Label",
"color": "Color", "color": "Color",
"position": "Position" "position": "Position",
"enable": "Enable",
"disable": "Disable"
}, },
"type": { "type": {
"string": "string", "string": "string",
@ -595,7 +597,9 @@
"showTips":"You can open the tips from the settings panel", "showTips":"You can open the tips from the settings panel",
"outline": "Outline", "outline": "Outline",
"empty": "empty", "empty": "empty",
"globalConfig": "Global Configuration Nodes" "globalConfig": "Global Configuration Nodes",
"triggerAction": "Trigger action",
"find": "Find in workspace"
}, },
"help": { "help": {
"name": "Help", "name": "Help",

View File

@ -33,7 +33,7 @@
* methods: * methods:
* - addItem(itemData) * - addItem(itemData)
* - insertItemAt : function(data,index) - add an item at the specified index * - 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) * - getItemAt(index)
* - indexOf(itemData) * - indexOf(itemData)
* - width(width) * - width(width)
@ -332,11 +332,15 @@
this.addItem(items[i]); this.addItem(items[i]);
} }
}, },
removeItem: function(data) { removeItem: function(data,detach) {
var items = this.element.children().filter(function(f) { var items = this.element.children().filter(function(f) {
return data === $(this).children(".red-ui-editableList-item-content").data('data'); return data === $(this).children(".red-ui-editableList-item-content").data('data');
}); });
items.remove(); if (detach) {
items.detach();
} else {
items.remove();
}
if (this.options.removeItem) { if (this.options.removeItem) {
this.options.removeItem(data); this.options.removeItem(data);
} }

View File

@ -65,7 +65,7 @@
* item.treeList.container * item.treeList.container
* item.treeList.label - the label element for the item * item.treeList.label - the label element for the item
* item.treeList.parentList - the editableList instance this item is in * 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, * item.treeList.makeLeaf(detachChildElements) - turns an element with children into a leaf node,
* removing the UI decoration etc. * removing the UI decoration etc.
* detachChildElements - any children with custom * detachChildElements - any children with custom
@ -311,9 +311,9 @@
this._items[item.id] = item; this._items[item.id] = item;
item.treeList = {}; item.treeList = {};
item.depth = depth; item.depth = depth;
item.treeList.remove = function() { item.treeList.remove = function(detach) {
if (item.treeList.parentList) { if (item.treeList.parentList) {
item.treeList.parentList.editableList('removeItem',item); item.treeList.parentList.editableList('removeItem',item,detach);
} }
if (item.parent) { if (item.parent) {
var index = item.parent.children.indexOf(item); var index = item.parent.children.indexOf(item);
@ -322,7 +322,7 @@
} }
that._selected.delete(item); that._selected.delete(item);
delete item.treeList; delete item.treeList;
delete(that._items[item.id]); delete that._items[item.id];
} }
item.treeList.insertChildAt = function(newItem,position,select) { item.treeList.insertChildAt = function(newItem,position,select) {
newItem.parent = item; newItem.parent = item;

View File

@ -135,11 +135,12 @@ RED.sidebar.info.outliner = (function() {
function addControls(n,div) { function addControls(n,div) {
var controls = $('<div>',{class:"red-ui-info-outline-item-controls red-ui-info-outline-item-hover-controls"}).appendTo(div); var controls = $('<div>',{class:"red-ui-info-outline-item-controls red-ui-info-outline-item-hover-controls"}).appendTo(div);
if (n._def.button) { if (n._def.button) {
$('<button type="button" class="red-ui-info-outline-item-control-action red-ui-button red-ui-button-small"><i class="fa fa-toggle-right"></i></button>').appendTo(controls).on("click",function(evt) { var triggerButton = $('<button type="button" class="red-ui-info-outline-item-control-action red-ui-button red-ui-button-small"><i class="fa fa-toggle-right"></i></button>').appendTo(controls).on("click",function(evt) {
evt.preventDefault(); evt.preventDefault();
evt.stopPropagation(); evt.stopPropagation();
RED.view.clickNodeButton(n); RED.view.clickNodeButton(n);
}) })
RED.popover.tooltip(triggerButton,RED._("sidebar.info.triggerAction"));
} }
// $('<button type="button" class="red-ui-info-outline-item-control-reveal red-ui-button red-ui-button-small"><i class="fa fa-eye"></i></button>').appendTo(controls).on("click",function(evt) { // $('<button type="button" class="red-ui-info-outline-item-control-reveal red-ui-button red-ui-button-small"><i class="fa fa-eye"></i></button>').appendTo(controls).on("click",function(evt) {
// evt.preventDefault(); // evt.preventDefault();
@ -147,7 +148,7 @@ RED.sidebar.info.outliner = (function() {
// RED.view.reveal(n.id); // RED.view.reveal(n.id);
// }) // })
if (n.type !== 'group' && n.type !== 'subflow') { if (n.type !== 'group' && n.type !== 'subflow') {
$('<button type="button" class="red-ui-info-outline-item-control-disable red-ui-button red-ui-button-small"><i class="fa fa-circle-thin"></i><i class="fa fa-ban"></i></button>').appendTo(controls).on("click",function(evt) { var toggleButton = $('<button type="button" class="red-ui-info-outline-item-control-disable red-ui-button red-ui-button-small"><i class="fa fa-circle-thin"></i><i class="fa fa-ban"></i></button>').appendTo(controls).on("click",function(evt) {
evt.preventDefault(); evt.preventDefault();
evt.stopPropagation(); evt.stopPropagation();
if (n.type === 'tab') { if (n.type === 'tab') {
@ -179,6 +180,9 @@ RED.sidebar.info.outliner = (function() {
RED.view.redraw(); RED.view.redraw();
} }
}); });
RED.popover.tooltip(toggleButton,function() {
return RED._("common.label."+((n.type==='tab' && n.disabled) || (n.type!=='tab' && n.d))?"enable":"disable")
});
} else { } else {
$('<div class="red-ui-info-outline-item-control-spacer">').appendTo(controls) $('<div class="red-ui-info-outline-item-control-spacer">').appendTo(controls)
} }
@ -361,7 +365,7 @@ RED.sidebar.info.outliner = (function() {
function onNodeChange(n) { function onNodeChange(n) {
var existingObject = objects[n.id]; var existingObject = objects[n.id];
var parent = n.g||n.z; var parent = n.g||n.z||"__global__";
var nodeLabelText = getNodeLabelText(n); var nodeLabelText = getNodeLabelText(n);
if (nodeLabelText) { if (nodeLabelText) {
@ -369,10 +373,9 @@ RED.sidebar.info.outliner = (function() {
} else { } else {
existingObject.element.find(".red-ui-info-outline-item-label").html("&nbsp;"); existingObject.element.find(".red-ui-info-outline-item-label").html("&nbsp;");
} }
if (parent !== existingObject.parent.id) { if (parent !== existingObject.parent.id) {
existingObject.treeList.remove(); existingObject.treeList.remove(true);
if (!parent) { if (parent === "__global__") {
globalConfigNodes.treeList.addChild(existingObject); globalConfigNodes.treeList.addChild(existingObject);
} else { } else {
if (empties[parent]) { if (empties[parent]) {
@ -401,11 +404,12 @@ RED.sidebar.info.outliner = (function() {
} }
function getGutter(n) { function getGutter(n) {
var span = $("<span>",{class:"red-ui-info-outline-gutter"}); var span = $("<span>",{class:"red-ui-info-outline-gutter"});
$('<button type="button" class="red-ui-info-outline-item-control-reveal red-ui-button red-ui-button-small"><i class="fa fa-search"></i></button>').appendTo(span).on("click",function(evt) { var revealButton = $('<button type="button" class="red-ui-info-outline-item-control-reveal red-ui-button red-ui-button-small"><i class="fa fa-search"></i></button>').appendTo(span).on("click",function(evt) {
evt.preventDefault(); evt.preventDefault();
evt.stopPropagation(); evt.stopPropagation();
RED.view.reveal(n.id); RED.view.reveal(n.id);
}) })
RED.popover.tooltip(revealButton,RED._("sidebar.info.find"));
return span; return span;
} }
function onNodeAdd(n) { function onNodeAdd(n) {

View File

@ -222,8 +222,10 @@
} }
} }
var val = editor.getValue(); var val = editor.getValue();
if (defaultValue && val == defaultValue) { if (defaultValue) {
val = ""; if (val.trim() == defaultValue.trim()) {
val = "";
}
} }
editor.destroy(); editor.destroy();
delete node[editorName]; delete node[editorName];

View File

@ -92,8 +92,8 @@ module.exports = function(RED) {
var node = this; var node = this;
node.name = n.name; node.name = n.name;
node.func = n.func; node.func = n.func;
node.ini = n.initialize ? n.initialize : ""; node.ini = n.initialize ? n.initialize.trim() : "";
node.fin = n.finalize ? n.finalize : ""; node.fin = n.finalize ? n.finalize.trim() : "";
var handleNodeDoneCall = true; var handleNodeDoneCall = true;