Only redraw node status when it has changed

This commit is contained in:
Nick O'Leary 2019-05-16 14:42:41 +01:00
parent 68b94737ed
commit 8567f1655e
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
2 changed files with 22 additions and 17 deletions

View File

@ -353,6 +353,7 @@ var RED = (function() {
}
}
node.status = msg;
node.dirtyStatus = true;
node.dirty = true;
RED.view.redraw();
}
@ -579,7 +580,7 @@ var RED = (function() {
}
options.target = $("#red-ui-editor");
options.target.addClass("red-ui-editor");
buildEditor(options);
RED.i18n.init(options, function() {
RED.settings.init(options, loadEditor);

View File

@ -3036,23 +3036,27 @@ RED.view = (function() {
// });
}
if (!showStatus || !d.status) {
thisNode.selectAll(".red-ui-flow-node-status-group").style("display","none");
} else {
var fill = status_colours[d.status.fill]; // Only allow our colours for now
if (d.status.shape == null && fill == null) {
thisNode.selectAll(".red-ui-flow-node-status").style("display","none");
thisNode.selectAll(".red-ui-flow-node-status-group").style("display","inline").attr("transform","translate(-14,"+(d.h+3)+")");
if (d.dirtyStatus) {
if (!showStatus || !d.status) {
thisNode.selectAll(".red-ui-flow-node-status-group").style("display","none");
} else {
thisNode.selectAll(".red-ui-flow-node-status-group").style("display","inline").attr("transform","translate(3,"+(d.h+3)+")");
var statusClass = "red-ui-flow-node-status-"+(d.status.shape||"dot")+"-"+d.status.fill;
thisNode.selectAll(".red-ui-flow-node-status").attr("class","red-ui-flow-node-status "+statusClass);
}
if (d.status.text) {
thisNode.selectAll(".red-ui-flow-node-status-label").text(d.status.text);
} else {
thisNode.selectAll(".red-ui-flow-node-status-label").text("");
thisNode.selectAll(".red-ui-flow-node-status-group").style("display","inline");
var fill = status_colours[d.status.fill]; // Only allow our colours for now
if (d.status.shape == null && fill == null) {
thisNode.selectAll(".red-ui-flow-node-status").style("display","none");
thisNode.selectAll(".red-ui-flow-node-status-group").attr("transform","translate(-14,"+(d.h+3)+")");
} else {
thisNode.selectAll(".red-ui-flow-node-status-group").attr("transform","translate(3,"+(d.h+3)+")");
var statusClass = "red-ui-flow-node-status-"+(d.status.shape||"dot")+"-"+d.status.fill;
thisNode.selectAll(".red-ui-flow-node-status").attr("class","red-ui-flow-node-status "+statusClass);
}
if (d.status.text) {
thisNode.selectAll(".red-ui-flow-node-status-label").text(d.status.text);
} else {
thisNode.selectAll(".red-ui-flow-node-status-label").text("");
}
}
delete d.dirtyStatus;
}
d.dirty = false;
@ -3454,7 +3458,7 @@ RED.view = (function() {
}
function toggleStatus(s) {
showStatus = s;
RED.nodes.eachNode(function(n) { n.dirty = true;});
RED.nodes.eachNode(function(n) { n.dirtyStatus = true; n.dirty = true;});
//TODO: subscribe/unsubscribe here
redraw();
}