Sfoglia il codice sorgente

add on-click message

dds
Frank Bösing 4 anni fa
parent
commit
4a2c98eaaa
2 ha cambiato i file con 31 aggiunte e 8 eliminazioni
  1. +28
    -7
      gui/red/ui/view.js
  2. +3
    -1
      gui/style.css

+ 28
- 7
gui/red/ui/view.js Vedi File

@@ -1012,6 +1012,8 @@ RED.view = (function() {
d.w = Math.max(node_width,calculateTextWidth(l)+(d._def.inputs>0?7:0) );
d.h = Math.max(node_height,(Math.max(d.outputs,d._def.inputs)||0) * 15);

node.append("dfn").attr("class", "tooltip").append("span").attr("role","tooltip");

if (d._def.badge) {
var badge = node.append("svg:g").attr("class","node_badge_group");
var badgeRect = badge.append("rect").attr("class","node_badge").attr("rx",5).attr("ry",5).attr("width",40).attr("height",15);
@@ -1055,6 +1057,7 @@ RED.view = (function() {
.on("touchstart",nodeButtonClicked)
}


var mainRect = node.append("rect")
.attr("class", "node")
.classed("node_unknown",function(d) { return d.type == "unknown"; })
@@ -1225,11 +1228,13 @@ RED.view = (function() {
node.append("image").attr("class","node_reqerror hidden").attr("xlink:href","icons/error.png").attr("x",0).attr("y",-12).attr("width",20).attr("height",20);
});


node.each(function(d,i) {

/**********************************************************************/
//Add requirements
d.requirementError = false;
d.conflicts = new Array();
d.requirements = new Array();
requirements.forEach(function(r) {
if (r.type == d.type) d.requirements.push(r);
@@ -1241,23 +1246,30 @@ RED.view = (function() {
if (n2 != d && n2.requirements != null ) {
n2.requirements.forEach(function(r2) {
if (r["resource"] == r2["resource"]) {
if (r["shareable"] == false || r2["shareable"] == false) {
console.log("Conflict: shareable '"+r["resource"]+"' "+d.name+" and "+n2.name);
if (r["shareable"] == false ) {
var msg = "Conflict: shareable '"+r["resource"]+"' "+d.name+" and "+n2.name;
console.log(msg);
msg = n2.name + " uses " + r["resource"] + ", too";
d.conflicts.push(msg);
d.requirementError = true;
n2.requirementError = true;
}
else
//else
if (r["setting"] != r2["setting"]) {
console.log("Conflict: "+ d.name + " setting['"+r["setting"]+"'] and "+n2.name+" setting['"+r2["setting"]+"']");
var msg = "Conflict: "+ d.name + " setting['"+r["setting"]+"'] and "+n2.name+" setting['"+r2["setting"]+"']";
console.log(msg);
msg = n2.name + " has different settings: " + r["setting"] + " ./. " + r2["setting"];
d.conflicts.push(msg);
d.requirementError = true;
n2.requirementError = true;
}
}

});

}
});
});


/**********************************************************************/

if (d.dirty || d.requirementError != undefined) {
@@ -1345,9 +1357,16 @@ RED.view = (function() {
port.attr("y",y)
});


thisNode.selectAll(".node_reqerror")
.attr("x",function(d){return d.w-25-(d.changed?13:0)})
.classed("hidden",function(d) { return !d.requirementError; });
.classed("hidden",function(d){ return !d.requirementError; })
.on("click", function(){RED.notify(

'Conflicts:<ul><li>'+d.conflicts.join('</li><li>')+'</li></ul>'

)});


thisNode.selectAll(".node_icon").attr("y",function(d){return (d.h-d3.select(this).attr("height"))/2;});
thisNode.selectAll(".node_icon_shade").attr("height",function(d){return d.h;});
@@ -1494,6 +1513,8 @@ RED.view = (function() {
}
}

function conflict(a) { alert(a); }

function doSort (arr) {
arr.sort(function (a, b) {
var nameA = a.name ? a.name : a.id;

+ 3
- 1
gui/style.css Vedi File

@@ -397,11 +397,13 @@ a.brand img {
stroke: #ff7f0e;
fill: #eee;
}

.node_button {
fill: inherit;

}
.node_reqerror {
cursor:pointer;
}
.port {
fill: #ddd;
cursor: crosshair;

Loading…
Annulla
Salva