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

Spinner fixes (#1371)

* Fix for function node invalid spinner values

to close #1370

* better validation of spinners for inject and delay

(don’t allow negative numbers)

* remove need for declaring local min variable
This commit is contained in:
Dave Conway-Jones 2017-08-21 22:00:23 +01:00 committed by Nick O'Leary
parent e09efba313
commit a844ca161f
3 changed files with 12 additions and 6 deletions

View File

@ -181,7 +181,7 @@ If you want every 20 minutes from now - use the <i>"interval"</i> option.</p>
topic: {value:""}, topic: {value:""},
payload: {value:"", validate: RED.validators.typedInput("payloadType")}, payload: {value:"", validate: RED.validators.typedInput("payloadType")},
payloadType: {value:"date"}, payloadType: {value:"date"},
repeat: {value:""}, repeat: {value:"", validate:function(v) { return ((v === "") || (RED.validators.number(v) && (v >= 0))) }},
crontab: {value:""}, crontab: {value:""},
once: {value:false} once: {value:false}
}, },

View File

@ -73,7 +73,13 @@
oneditprepare: function() { oneditprepare: function() {
var that = this; var that = this;
$( "#node-input-outputs" ).spinner({ $( "#node-input-outputs" ).spinner({
min:1 min:1,
change: function(event, ui) {
var value = this.value;
if (!value.match(/^\d+$/)) { value = 1; }
else if (value < this.min) { value = this.min; }
if (value !== this.value) { $(this).spinner("value", value); }
}
}); });
this.editor = RED.editor.createEditor({ this.editor = RED.editor.createEditor({

View File

@ -129,13 +129,13 @@
defaults: { defaults: {
name: {value:""}, name: {value:""},
pauseType: {value:"delay", required:true}, pauseType: {value:"delay", required:true},
timeout: {value:"5", required:true, validate:RED.validators.number()}, timeout: {value:"5", required:true, validate:function(v) { return RED.validators.number(v) && (v >= 0); }},
timeoutUnits: {value:"seconds"}, timeoutUnits: {value:"seconds"},
rate: {value:"1", required:true, validate:RED.validators.number()}, rate: {value:"1", required:true, validate:function(v) { return RED.validators.number(v) && (v >= 0); }},
nbRateUnits: {value:"1", required:false, validate:RED.validators.regex(/\d+|/)}, nbRateUnits: {value:"1", required:false, validate:RED.validators.regex(/\d+|/)},
rateUnits: {value: "second"}, rateUnits: {value: "second"},
randomFirst: {value:"1", required:true, validate:RED.validators.number()}, randomFirst: {value:"1", required:true, validate:function(v) { return RED.validators.number(v) && (v >= 0); }},
randomLast: {value:"5", required:true, validate:RED.validators.number()}, randomLast: {value:"5", required:true, validate:function(v) { return RED.validators.number(v) && (v >= 0); }},
randomUnits: {value: "seconds"}, randomUnits: {value: "seconds"},
drop: {value:false} drop: {value:false}
}, },