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

Merge pull request #4056 from kazuhitoyokoi/master-validator

Add validators for complete and link call nodes
This commit is contained in:
Nick O'Leary 2023-02-20 16:50:01 +00:00 committed by GitHub
commit c9d72d7a1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 37 additions and 11 deletions

View File

@ -18,7 +18,16 @@
color:"#c0edc0", color:"#c0edc0",
defaults: { defaults: {
name: {value:""}, name: {value:""},
scope: {value:[], type:"*[]"}, scope: {
value: [],
type: "*[]",
validate: function (v, opt) {
if (v.length > 0) {
return true;
}
return RED._("node-red:complete.errors.scopeUndefined");
}
},
uncaught: {value:false} uncaught: {value:false}
}, },
inputs:0, inputs:0,

View File

@ -1,4 +1,3 @@
<script type="text/html" data-template-name="link in"> <script type="text/html" data-template-name="link in">
<div class="form-row"> <div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="common.label.name"></span></label> <label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="common.label.name"></span></label>
@ -272,7 +271,17 @@
color:"#ddd",//"#87D8CF", color:"#ddd",//"#87D8CF",
defaults: { defaults: {
name: { value: "" }, name: { value: "" },
links: { value: [], type:"link in[]" }, links: {
value: [],
type: "link in[]",
validate: function (v, opt) {
if ((this.linkType === "static" && v.length > 0)
|| this.linkType === "dynamic") {
return true;
}
return RED._("node-red:link.errors.linkUndefined");
}
},
linkType: { value:"static" }, linkType: { value:"static" },
timeout: { timeout: {
value: "30", value: "30",

View File

@ -164,10 +164,10 @@ module.exports = function(RED) {
if (returnNode && returnNode.returnLinkMessage) { if (returnNode && returnNode.returnLinkMessage) {
returnNode.returnLinkMessage(messageEvent.id, msg); returnNode.returnLinkMessage(messageEvent.id, msg);
} else { } else {
node.warn(RED._("link.error.missingReturn")) node.warn(RED._("link.errors.missingReturn"));
} }
} else { } else {
node.warn(RED._("link.error.missingReturn")) node.warn(RED._("link.errors.missingReturn"));
} }
done(); done();
} else if (mode === "link") { } else if (mode === "link") {

View File

@ -119,7 +119,10 @@
} }
}, },
"complete": { "complete": {
"completeNodes": "complete: __number__" "completeNodes": "complete: __number__",
"errors": {
"scopeUndefined": "scope undefined"
}
}, },
"debug": { "debug": {
"output": "Output", "output": "Output",
@ -181,8 +184,9 @@
"staticLinkCall": "Fixed target", "staticLinkCall": "Fixed target",
"dynamicLinkCall": "Dynamic target (msg.target)", "dynamicLinkCall": "Dynamic target (msg.target)",
"dynamicLinkLabel": "Dynamic", "dynamicLinkLabel": "Dynamic",
"error": { "errors": {
"missingReturn": "Missing return node information" "missingReturn": "Missing return node information",
"linkUndefined": "link undefined"
} }
}, },
"tls": { "tls": {

View File

@ -119,7 +119,10 @@
} }
}, },
"complete": { "complete": {
"completeNodes": "complete: __number__" "completeNodes": "complete: __number__",
"errors": {
"scopeUndefined": "スコープが未定義"
}
}, },
"debug": { "debug": {
"output": "対象", "output": "対象",
@ -181,8 +184,9 @@
"staticLinkCall": "対象を固定で指定", "staticLinkCall": "対象を固定で指定",
"dynamicLinkCall": "対象を動的に指定 (msg.target)", "dynamicLinkCall": "対象を動的に指定 (msg.target)",
"dynamicLinkLabel": "動的", "dynamicLinkLabel": "動的",
"error": { "errors": {
"missingReturn": "返却するノードの情報が存在しません" "missingReturn": "返却するノードの情報が存在しません",
"linkUndefined": "リンクが未定義"
} }
}, },
"tls": { "tls": {