mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
@@ -448,12 +448,18 @@ RED.nodes = (function() {
|
||||
doZFilter = true;
|
||||
}
|
||||
}
|
||||
var objectLookup = false;
|
||||
if (searchSet === null) {
|
||||
searchSet = nodes;
|
||||
searchSet = Object.keys(nodes);
|
||||
objectLookup = true;
|
||||
}
|
||||
|
||||
|
||||
for (var n=0;n<searchSet.length;n++) {
|
||||
var node = searchSet[n];
|
||||
if (objectLookup) {
|
||||
node = nodes[node];
|
||||
}
|
||||
if (filter.hasOwnProperty("type") && node.type !== filter.type) {
|
||||
continue;
|
||||
}
|
||||
@@ -1118,8 +1124,8 @@ RED.nodes = (function() {
|
||||
}
|
||||
}
|
||||
if ((!n._def.defaults || !n._def.defaults.hasOwnProperty("l")) && n.hasOwnProperty('l')) {
|
||||
var isLink = /^link (in|out)$/.test(node.type);
|
||||
if (isLink == n.l) {
|
||||
var showLabel = n._def.hasOwnProperty("showLabel")?n._def.showLabel:true;
|
||||
if (showLabel != n.l) {
|
||||
node.l = n.l;
|
||||
}
|
||||
}
|
||||
|
@@ -41,6 +41,7 @@
|
||||
* sublabel: 'Local', // a sub-label for the item
|
||||
* icon: 'fa fa-rocket', // (optional) icon for the item
|
||||
* checkbox: true/false, // (optional) if present, display checkbox accordingly
|
||||
* radio: 'group-name', // (optional) if present, display radio box - using group-name to set radio group
|
||||
* selected: true/false, // (optional) whether the item is selected or not
|
||||
* children: [] | function(done,item) // (optional) an array of child items, or a function
|
||||
* // that will call the `done` callback with an array
|
||||
@@ -640,6 +641,41 @@
|
||||
}
|
||||
}
|
||||
selectWrapper.appendTo(label)
|
||||
} else if (item.radio) {
|
||||
var selectWrapper = $('<span class="red-ui-treeList-icon"></span>');
|
||||
var cb = $('<input class="red-ui-treeList-radio" type="radio">').prop('name', item.radio).prop('checked',item.selected).appendTo(selectWrapper);
|
||||
cb.on('click', function(e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
cb.on('change', function(e) {
|
||||
item.selected = this.checked;
|
||||
that._selected.forEach(function(selectedItem) {
|
||||
if (selectedItem.radio === item.radio) {
|
||||
selectedItem.treeList.label.removeClass("selected");
|
||||
selectedItem.selected = false;
|
||||
that._selected.delete(selectedItem);
|
||||
}
|
||||
})
|
||||
if (item.selected) {
|
||||
that._selected.add(item);
|
||||
} else {
|
||||
that._selected.delete(item);
|
||||
}
|
||||
label.toggleClass("selected",this.checked);
|
||||
that._trigger("select",e,item);
|
||||
})
|
||||
if (!item.children) {
|
||||
label.on("click", function(e) {
|
||||
e.stopPropagation();
|
||||
cb.trigger("click");
|
||||
})
|
||||
}
|
||||
item.treeList.select = function(v) {
|
||||
if (v !== item.selected) {
|
||||
cb.trigger("click");
|
||||
}
|
||||
}
|
||||
selectWrapper.appendTo(label)
|
||||
} else {
|
||||
label.on("click", function(e) {
|
||||
if (!that.options.multi) {
|
||||
|
@@ -151,7 +151,7 @@ RED.editor = (function() {
|
||||
valid = definition[property].hasOwnProperty("required") && !definition[property].required;
|
||||
} else {
|
||||
var configNode = RED.nodes.node(value);
|
||||
valid = (configNode !== null && (configNode.valid == null || configNode.valid));
|
||||
valid = (configNode && (configNode.valid == null || configNode.valid));
|
||||
}
|
||||
}
|
||||
return valid;
|
||||
|
@@ -93,17 +93,20 @@
|
||||
|
||||
|
||||
}
|
||||
var showLabel = node._def.hasOwnProperty("showLabel")?node._def.showLabel:true;
|
||||
|
||||
if (!$("#node-input-show-label").prop('checked')) {
|
||||
// Not checked - hide label
|
||||
if (!/^link (in|out)$/.test(node.type)) {
|
||||
// Not a link node - default state is true
|
||||
|
||||
if (showLabel) {
|
||||
// Default to show label
|
||||
if (node.l !== false) {
|
||||
editState.changes.l = node.l
|
||||
editState.changed = true;
|
||||
}
|
||||
node.l = false;
|
||||
} else {
|
||||
// A link node - default state is false
|
||||
// Node has showLabel:false (eg link nodes)
|
||||
if (node.hasOwnProperty('l') && node.l) {
|
||||
editState.changes.l = node.l
|
||||
editState.changed = true;
|
||||
@@ -112,8 +115,8 @@
|
||||
}
|
||||
} else {
|
||||
// Checked - show label
|
||||
if (!/^link (in|out)$/.test(node.type)) {
|
||||
// Not a link node - default state is true
|
||||
if (showLabel) {
|
||||
// Default to show label
|
||||
if (node.hasOwnProperty('l') && !node.l) {
|
||||
editState.changes.l = node.l
|
||||
editState.changed = true;
|
||||
@@ -204,8 +207,8 @@
|
||||
})
|
||||
|
||||
if (!node.hasOwnProperty("l")) {
|
||||
// Show label if type not link
|
||||
node.l = !/^link (in|out)$/.test(node._def.type);
|
||||
// Show label unless def.showLabel set to false
|
||||
node.l = node._def.hasOwnProperty("showLabel")?node._def.showLabel:true;
|
||||
}
|
||||
$("#node-input-show-label").prop("checked",node.l).trigger("change");
|
||||
|
||||
|
@@ -159,15 +159,15 @@ RED.view.tools = (function() {
|
||||
nodes.forEach(function(n) {
|
||||
var modified = false;
|
||||
var oldValue = n.l === undefined?true:n.l;
|
||||
var isLink = /^link (in|out)$/.test(n._def.type);
|
||||
var showLabel = n._def.hasOwnProperty("showLabel")?n._def.showLabel:true;
|
||||
|
||||
if (labelShown) {
|
||||
if (n.l === false || (isLink && !n.hasOwnProperty('l'))) {
|
||||
if (n.l === false || (!showLabel && !n.hasOwnProperty('l'))) {
|
||||
n.l = true;
|
||||
modified = true;
|
||||
}
|
||||
} else {
|
||||
if ((!isLink && (!n.hasOwnProperty('l') || n.l === true)) || (isLink && n.l === true) ) {
|
||||
if ((showLabel && (!n.hasOwnProperty('l') || n.l === true)) || (!showLabel && n.l === true) ) {
|
||||
n.l = false;
|
||||
modified = true;
|
||||
}
|
||||
|
@@ -413,7 +413,7 @@ RED.view = (function() {
|
||||
var nn = result.node;
|
||||
|
||||
var showLabel = RED.utils.getMessageProperty(RED.settings.get('editor'),"view.view-node-show-label");
|
||||
if (showLabel !== undefined && !/^link (in|out)$/.test(nn._def.type) && !nn._def.defaults.hasOwnProperty("l")) {
|
||||
if (showLabel !== undefined && (nn._def.hasOwnProperty("showLabel")?nn._def.showLabel:true) && !nn._def.defaults.hasOwnProperty("l")) {
|
||||
nn.l = showLabel;
|
||||
}
|
||||
|
||||
@@ -1088,7 +1088,7 @@ RED.view = (function() {
|
||||
nn.x = point[0];
|
||||
nn.y = point[1];
|
||||
var showLabel = RED.utils.getMessageProperty(RED.settings.get('editor'),"view.view-node-show-label");
|
||||
if (showLabel !== undefined && !/^link (in|out)$/.test(nn._def.type) && !nn._def.defaults.hasOwnProperty("l")) {
|
||||
if (showLabel !== undefined && (nn._def.hasOwnProperty("showLabel")?nn._def.showLabel:true) && !nn._def.defaults.hasOwnProperty("l")) {
|
||||
nn.l = showLabel;
|
||||
}
|
||||
if (quickAddLink) {
|
||||
@@ -1991,7 +1991,7 @@ RED.view = (function() {
|
||||
activeLinkNodes = {};
|
||||
for (var i=0;i<movingSet.length();i++) {
|
||||
var msn = movingSet.get(i);
|
||||
if ((msn.n.type === "link out" || msn.n.type === "link in") &&
|
||||
if (((msn.n.type === "link out" && msn.n.mode !== 'return') || msn.n.type === "link in") &&
|
||||
(msn.n.z === activeWorkspace)) {
|
||||
var linkNode = msn.n;
|
||||
activeLinkNodes[linkNode.id] = linkNode;
|
||||
@@ -4140,7 +4140,7 @@ RED.view = (function() {
|
||||
}
|
||||
var numOutputs = d.outputs;
|
||||
if (isLink && d.type === "link out") {
|
||||
if (showAllLinkPorts===PORT_TYPE_OUTPUT || activeLinkNodes[d.id]) {
|
||||
if (d.mode !== "return" && (showAllLinkPorts===PORT_TYPE_OUTPUT || activeLinkNodes[d.id])) {
|
||||
numOutputs = 1;
|
||||
} else {
|
||||
numOutputs = 0;
|
||||
|
@@ -95,7 +95,8 @@
|
||||
color: $list-item-color;
|
||||
}
|
||||
|
||||
input.red-ui-treeList-checkbox {
|
||||
input.red-ui-treeList-checkbox,
|
||||
input.red-ui-treeList-radio {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user