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

Moar changes

This commit is contained in:
Nick O'Leary 2020-06-15 21:06:27 +01:00
parent 7599e865fd
commit b65e4d5794
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
4 changed files with 41 additions and 4 deletions

View File

@ -331,10 +331,12 @@ RED.history = (function() {
var currentConfigNode = RED.nodes.node(ev.node[i]); var currentConfigNode = RED.nodes.node(ev.node[i]);
if (currentConfigNode) { if (currentConfigNode) {
currentConfigNode.users.splice(currentConfigNode.users.indexOf(ev.node),1); currentConfigNode.users.splice(currentConfigNode.users.indexOf(ev.node),1);
RED.events.emit("nodes:change",currentConfigNode);
} }
var newConfigNode = RED.nodes.node(ev.changes[i]); var newConfigNode = RED.nodes.node(ev.changes[i]);
if (newConfigNode) { if (newConfigNode) {
newConfigNode.users.push(ev.node); newConfigNode.users.push(ev.node);
RED.events.emit("nodes:change",newConfigNode);
} }
} }
ev.node[i] = ev.changes[i]; ev.node[i] = ev.changes[i];

View File

@ -1283,10 +1283,12 @@ RED.editor = (function() {
if (configNode) { if (configNode) {
var users = configNode.users; var users = configNode.users;
users.splice(users.indexOf(editing_node),1); users.splice(users.indexOf(editing_node),1);
RED.events.emit("nodes:change",configNode);
} }
configNode = RED.nodes.node(newValue); configNode = RED.nodes.node(newValue);
if (configNode) { if (configNode) {
configNode.users.push(editing_node); configNode.users.push(editing_node);
RED.events.emit("nodes:change",configNode);
} }
} }
changes[d] = editing_node[d]; changes[d] = editing_node[d];
@ -1911,10 +1913,12 @@ RED.editor = (function() {
if (configNode) { if (configNode) {
var users = configNode.users; var users = configNode.users;
users.splice(users.indexOf(editing_config_node),1); users.splice(users.indexOf(editing_config_node),1);
RED.events.emit("nodes:change",configNode);
} }
configNode = RED.nodes.node(newValue); configNode = RED.nodes.node(newValue);
if (configNode) { if (configNode) {
configNode.users.push(editing_config_node); configNode.users.push(editing_config_node);
RED.events.emit("nodes:change",configNode);
} }
} }
editing_config_node[d] = newValue; editing_config_node[d] = newValue;
@ -2503,10 +2507,12 @@ RED.editor = (function() {
if (configNode) { if (configNode) {
var users = configNode.users; var users = configNode.users;
users.splice(users.indexOf(editing_node),1); users.splice(users.indexOf(editing_node),1);
RED.events.emit("nodes:change",configNode);
} }
configNode = RED.nodes.node(newValue); configNode = RED.nodes.node(newValue);
if (configNode) { if (configNode) {
configNode.users.push(editing_node); configNode.users.push(editing_node);
RED.events.emit("nodes:change",configNode);
} }
} }
changes[d] = editing_node[d]; changes[d] = editing_node[d];

View File

@ -79,6 +79,18 @@ RED.search = (function() {
return val; return val;
} }
function extractValue(val, flagName, flags) {
// flagName:XYZ
var regEx = new RegExp("(?:^| )"+flagName+":([^ ]+)(?: |$)");
var m
while(m = regEx.exec(val)) {
val = val.replace(regEx," ").trim();
flags[flagName] = flags[flagName] || [];
flags[flagName].push(m[1]);
}
return val;
}
function search(val) { function search(val) {
var results = []; var results = [];
var keys = Object.keys(index); var keys = Object.keys(index);
@ -93,6 +105,8 @@ RED.search = (function() {
val = extractFlag(val,"unused",flags); val = extractFlag(val,"unused",flags);
val = extractFlag(val,"config",flags); val = extractFlag(val,"config",flags);
val = extractFlag(val,"subflow",flags); val = extractFlag(val,"subflow",flags);
// uses:<node-id>
val = extractValue(val,"uses",flags);
var hasFlags = Object.keys(flags).length > 0; var hasFlags = Object.keys(flags).length > 0;

View File

@ -145,6 +145,16 @@ 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.category === "config" && n.type !== "group") {
var userCountBadge = $('<button type="button" class="red-ui-info-outline-item-control-users red-ui-button red-ui-button-small"><i class="fa fa-toggle-right"></i></button>').text(n.users.length).appendTo(controls).on("click",function(evt) {
evt.preventDefault();
evt.stopPropagation();
RED.search.show("uses:"+n.id);
})
RED.popover.tooltip(userCountBadge,function() { return RED._('editor.nodesUse',{count:n.users.length})});
}
if (n._def.button) { if (n._def.button) {
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) { 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();
@ -405,7 +415,7 @@ RED.sidebar.info.outliner = (function() {
if (parentItem.config) { if (parentItem.config) {
// this is a config // this is a config
parentItem.treeList.remove(); parentItem.treeList.remove();
console.log("Removing",n.type,"from",parentItem.parent.id||parentItem.parent.parent.id) // console.log("Removing",n.type,"from",parentItem.parent.id||parentItem.parent.parent.id)
delete configNodeTypes[parentItem.parent.id||parentItem.parent.parent.id].types[n.type]; delete configNodeTypes[parentItem.parent.id||parentItem.parent.parent.id].types[n.type];
@ -446,6 +456,11 @@ RED.sidebar.info.outliner = (function() {
// } // }
} }
existingObject.element.toggleClass("red-ui-info-outline-item-disabled", !!n.d) existingObject.element.toggleClass("red-ui-info-outline-item-disabled", !!n.d)
if (n._def.category === "config" && n.type !== 'group') {
existingObject.element.find(".red-ui-info-outline-item-control-users").text(n.users.length);
}
updateSearch(); updateSearch();
} }
function onObjectRemove(n) { function onObjectRemove(n) {
@ -488,7 +503,7 @@ RED.sidebar.info.outliner = (function() {
} }
function createFlowConfigNode(parent,type) { function createFlowConfigNode(parent,type) {
console.log("createFlowConfig",parent,type,configNodeTypes[parent]); // console.log("createFlowConfig",parent,type,configNodeTypes[parent]);
if (empties[parent]) { if (empties[parent]) {
empties[parent].treeList.remove(); empties[parent].treeList.remove();
delete empties[parent]; delete empties[parent];
@ -502,7 +517,7 @@ RED.sidebar.info.outliner = (function() {
children: [] children: []
} }
objects[parent].treeList.insertChildAt(configNodeTypes[parent],0); objects[parent].treeList.insertChildAt(configNodeTypes[parent],0);
console.log("CREATED", parent) // console.log("CREATED", parent)
} }
if (!configNodeTypes[parent].types[type]) { if (!configNodeTypes[parent].types[type]) {
configNodeTypes[parent].types[type] = { configNodeTypes[parent].types[type] = {
@ -511,7 +526,7 @@ RED.sidebar.info.outliner = (function() {
children: [] children: []
} }
configNodeTypes[parent].treeList.addChild(configNodeTypes[parent].types[type]); configNodeTypes[parent].treeList.addChild(configNodeTypes[parent].types[type]);
console.log("CREATED", parent,type) // console.log("CREATED", parent,type)
} }
} }
function onNodeAdd(n) { function onNodeAdd(n) {