1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Merge pull request #3390 from node-red/copy-node-props

Copy node props
This commit is contained in:
Nick O'Leary 2022-03-03 21:57:00 +00:00 committed by GitHub
commit c75bebfc90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 15 deletions

View File

@ -280,15 +280,18 @@ RED.sidebar.info.outliner = (function() {
data:getFlowData()
})
treeList.on('treelistselect', function(e,item) {
var node = RED.nodes.node(item.id) || RED.nodes.group(item.id);
var node = RED.nodes.node(item.id) || RED.nodes.group(item.id) || RED.nodes.workspace(item.id) || RED.nodes.subflow(item.id);
if (node) {
if (node.type === 'group' || node._def.category !== "config") {
// RED.view.select({nodes:[node]})
} else if (node._def.category === "config") {
RED.sidebar.info.refresh(node);
// if (node.type === 'group' || node._def.category !== "config") {
// // RED.view.select({nodes:[node]})
// } else if (node._def.category === "config") {
// RED.sidebar.info.refresh(node);
// } else {
// // RED.view.select({nodes:[]})
// }
} else {
// RED.view.select({nodes:[]})
}
RED.sidebar.info.refresh(null);
}
})
treeList.on('treelistconfirm', function(e,item) {

View File

@ -163,6 +163,7 @@ RED.sidebar.info = (function() {
});
return el;
}
function refresh(node) {
if (node === undefined) {
refreshSelection();
@ -271,7 +272,7 @@ RED.sidebar.info = (function() {
objectType = "group";
}
$(propRow.children()[0]).text(RED._("sidebar.info."+objectType))
RED.utils.createObjectElement(node.id).appendTo(propRow.children()[1]);
RED.utils.createObjectElement(node.id,{sourceId: node.id}).appendTo(propRow.children()[1]);
if (node.type === "tab" || node.type === "subflow") {
// If nothing is selected, but we're on a flow or subflow tab.
@ -365,7 +366,7 @@ RED.sidebar.info = (function() {
}
} else {
RED.utils.createObjectElement(val).appendTo(propRow.children()[1]);
RED.utils.createObjectElement(val,{sourceId: node.id}).appendTo(propRow.children()[1]);
}
}
}
@ -431,6 +432,7 @@ RED.sidebar.info = (function() {
}
function setInfoText(infoText,target) {
var info = addTargetToExternalLinks($('<div class="red-ui-help"><span class="red-ui-text-bidi-aware" dir=\"'+RED.text.bidi.resolveBaseTextDir(infoText)+'">'+infoText+'</span></div>')).appendTo(target);
info.find(".red-ui-text-bidi-aware").contents().filter(function() { return this.nodeType === 3 && this.textContent.trim() !== "" }).wrap( "<span></span>" );
@ -447,6 +449,7 @@ RED.sidebar.info = (function() {
$(this).toggleClass('expanded',!isExpanded);
})
}
var tips = (function() {
var enabled = true;
var startDelay = 1000;

View File

@ -365,7 +365,16 @@ RED.utils = (function() {
}
}
function buildMessageElement(obj,options) {
/**
* Create a DOM element representation of obj - as used by Debug sidebar etc
*
* @params obj - the data to display
* @params options - a bag of options
*
* - If you want the Copy Value button, then set `sourceId`
* - If you want the Copy Path button, also set `path` to the value to be copied
*/
function createObjectElement(obj,options) {
options = options || {};
var key = options.key;
var typeHint = options.typeHint;
@ -555,7 +564,7 @@ RED.utils = (function() {
if (fullLength <= 10) {
for (i=0;i<fullLength;i++) {
row = $('<div class="red-ui-debug-msg-object-entry collapsed"></div>').appendTo(arrayRows);
subElements[path+"["+i+"]"] = buildMessageElement(
subElements[path+"["+i+"]"] = createObjectElement(
data[i],
{
key: ""+i,
@ -585,7 +594,7 @@ RED.utils = (function() {
return function() {
for (var i=min;i<=max;i++) {
var row = $('<div class="red-ui-debug-msg-object-entry collapsed"></div>').appendTo(parent);
subElements[path+"["+i+"]"] = buildMessageElement(
subElements[path+"["+i+"]"] = createObjectElement(
data[i],
{
key: ""+i,
@ -641,7 +650,7 @@ RED.utils = (function() {
newPath += "[\""+keys[i].replace(/"/,"\\\"")+"\"]"
}
}
subElements[newPath] = buildMessageElement(
subElements[newPath] = createObjectElement(
data[keys[i]],
{
key: keys[i],
@ -1369,7 +1378,7 @@ RED.utils = (function() {
}
return {
createObjectElement: buildMessageElement,
createObjectElement: createObjectElement,
getMessageProperty: getMessageProperty,
setMessageProperty: setMessageProperty,
normalisePropertyExpression: normalisePropertyExpression,