mirror of
https://github.com/node-red/node-red.git
synced 2025-12-27 15:34:26 +01:00
Fix range node to handle input min > max
and add tests and add pin hover to show confiog
This commit is contained in:
@@ -64,6 +64,14 @@
|
||||
},
|
||||
inputs: 1,
|
||||
outputs: 1,
|
||||
inputLabels: function() { return this.minin + " - " + this.maxin },
|
||||
outputLabels: function(i) {
|
||||
var outie = this.minout + " - " + this.maxout
|
||||
if (this.action === "clamp") { outie = "[" + outie + "]" }
|
||||
if (this.action === "drop") { outie = "x" + outie + "x" }
|
||||
if (this.action === "roll") { outie = ">" + outie + ">" }
|
||||
return outie;
|
||||
},
|
||||
icon: "range.svg",
|
||||
label: function() {
|
||||
if (this.minout !== "" && this.maxout !== "") { return this.name||this.minout + " - " + this.maxout; }
|
||||
|
||||
@@ -24,6 +24,14 @@ module.exports = function(RED) {
|
||||
this.maxin = Number(n.maxin);
|
||||
this.minout = Number(n.minout);
|
||||
this.maxout = Number(n.maxout);
|
||||
if (this.minin > this.maxin) {
|
||||
let tmp = this.minin;
|
||||
this.minin = this.maxin;
|
||||
this.maxin = tmp;
|
||||
tmp = this.minout;
|
||||
this.minout = this.maxout;
|
||||
this.maxout = tmp;
|
||||
}
|
||||
if (this.round) {
|
||||
this.maxout = Math.floor(this.maxout);
|
||||
this.minout = Math.ceil(this.minout);
|
||||
|
||||
Reference in New Issue
Block a user