mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Validate all edit dialog inputs when one changes
This commit is contained in:
parent
bac8a3092f
commit
088e3e5374
@ -139,6 +139,32 @@ RED.editor = (function() {
|
|||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function validateNodeEditor(node,prefix) {
|
||||||
|
for (var prop in node._def.defaults) {
|
||||||
|
if (node._def.defaults.hasOwnProperty(prop)) {
|
||||||
|
validateNodeEditorProperty(node,node._def.defaults,prop,prefix);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (node._def.credentials) {
|
||||||
|
for (prop in node._def.credentials) {
|
||||||
|
if (node._def.credentials.hasOwnProperty(prop)) {
|
||||||
|
validateNodeEditorProperty(node,node._def.credentials,prop,prefix);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function validateNodeEditorProperty(node,defaults,property,prefix) {
|
||||||
|
var input = $("#"+prefix+"-"+property);
|
||||||
|
if (input.length > 0) {
|
||||||
|
if (!validateNodeProperty(node, defaults, property,input.val())) {
|
||||||
|
input.addClass("input-error");
|
||||||
|
} else {
|
||||||
|
input.removeClass("input-error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the node's properties have changed.
|
* Called when the node's properties have changed.
|
||||||
* Marks the node as dirty and needing a size check.
|
* Marks the node as dirty and needing a size check.
|
||||||
@ -274,11 +300,7 @@ RED.editor = (function() {
|
|||||||
*/
|
*/
|
||||||
function attachPropertyChangeHandler(node,definition,property,prefix) {
|
function attachPropertyChangeHandler(node,definition,property,prefix) {
|
||||||
$("#"+prefix+"-"+property).change(function() {
|
$("#"+prefix+"-"+property).change(function() {
|
||||||
if (!validateNodeProperty(node, definition, property,this.value)) {
|
validateNodeEditor(node,prefix);
|
||||||
$(this).addClass("input-error");
|
|
||||||
} else {
|
|
||||||
$(this).removeClass("input-error");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,11 +330,6 @@ RED.editor = (function() {
|
|||||||
attachPropertyChangeHandler(node, credDef, cred, prefix);
|
attachPropertyChangeHandler(node, credDef, cred, prefix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (cred in credDef) {
|
|
||||||
if (credDef.hasOwnProperty(cred)) {
|
|
||||||
$("#" + prefix + "-" + cred).change();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -380,11 +397,7 @@ RED.editor = (function() {
|
|||||||
if (definition.oneditprepare) {
|
if (definition.oneditprepare) {
|
||||||
definition.oneditprepare.call(node);
|
definition.oneditprepare.call(node);
|
||||||
}
|
}
|
||||||
for (var d in definition.defaults) {
|
validateNodeEditor(node,prefix);
|
||||||
if (definition.defaults.hasOwnProperty(d)) {
|
|
||||||
$("#"+prefix+"-"+d).change();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (definition.credentials) {
|
if (definition.credentials) {
|
||||||
|
Loading…
Reference in New Issue
Block a user