mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
parent
7dbbafec1b
commit
c7017ee84b
@ -95,19 +95,24 @@ module.exports = function(RED) {
|
||||
}
|
||||
|
||||
this.on("input", function(msg, send, done) {
|
||||
var errors = [];
|
||||
var props = this.props;
|
||||
const errors = [];
|
||||
let props = this.props;
|
||||
if (msg.__user_inject_props__ && Array.isArray(msg.__user_inject_props__)) {
|
||||
props = msg.__user_inject_props__;
|
||||
}
|
||||
delete msg.__user_inject_props__;
|
||||
props.forEach(p => {
|
||||
var property = p.p;
|
||||
var value = p.v ? p.v : '';
|
||||
var valueType = p.vt ? p.vt : 'str';
|
||||
|
||||
if (!property) return;
|
||||
props = [...props]
|
||||
function evaluateProperty(doneEvaluating) {
|
||||
if (props.length === 0) {
|
||||
doneEvaluating()
|
||||
return
|
||||
}
|
||||
const p = props.shift()
|
||||
const property = p.p;
|
||||
const value = p.v ? p.v : '';
|
||||
const valueType = p.vt ? p.vt : 'str';
|
||||
|
||||
if (property) {
|
||||
if (valueType === "jsonata") {
|
||||
if (p.v) {
|
||||
try {
|
||||
@ -119,21 +124,35 @@ module.exports = function(RED) {
|
||||
errors.push(err.message);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
evaluateProperty(doneEvaluating)
|
||||
} else {
|
||||
try {
|
||||
RED.util.setMessageProperty(msg,property,RED.util.evaluateNodeProperty(value, valueType, this, msg),true);
|
||||
RED.util.evaluateNodeProperty(value, valueType, node, msg, (err, newValue) => {
|
||||
if (err) {
|
||||
errors.push(err.toString())
|
||||
} else {
|
||||
RED.util.setMessageProperty(msg,property,newValue,true);
|
||||
}
|
||||
evaluateProperty(doneEvaluating)
|
||||
})
|
||||
} catch (err) {
|
||||
errors.push(err.toString());
|
||||
evaluateProperty(doneEvaluating)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
evaluateProperty(doneEvaluating)
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
evaluateProperty(() => {
|
||||
if (errors.length) {
|
||||
done(errors.join('; '));
|
||||
} else {
|
||||
send(msg);
|
||||
done();
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user