mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Fix inject so more backwards compatible
reuse old payload property and copy over topic if a string.
This commit is contained in:
parent
13932b2cfb
commit
247fa0ce7c
@ -485,7 +485,6 @@
|
|||||||
v: this.topic ? this.topic : '',
|
v: this.topic ? this.topic : '',
|
||||||
vt:'string'
|
vt:'string'
|
||||||
}
|
}
|
||||||
|
|
||||||
this.props = [payload,topic];
|
this.props = [payload,topic];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -499,12 +498,6 @@
|
|||||||
|
|
||||||
},
|
},
|
||||||
oneditsave: function() {
|
oneditsave: function() {
|
||||||
/* Cleanup Legacy */
|
|
||||||
delete this.payload;
|
|
||||||
delete this.payloadType
|
|
||||||
delete this.topic
|
|
||||||
/* */
|
|
||||||
|
|
||||||
var repeat = "";
|
var repeat = "";
|
||||||
var crontab = "";
|
var crontab = "";
|
||||||
var type = $("#inject-time-type-select").val();
|
var type = $("#inject-time-type-select").val();
|
||||||
@ -599,6 +592,9 @@
|
|||||||
var props = $("#node-input-property-container").editableList('items');
|
var props = $("#node-input-property-container").editableList('items');
|
||||||
var node = this;
|
var node = this;
|
||||||
node.props= [];
|
node.props= [];
|
||||||
|
delete node.payloadType;
|
||||||
|
delete node.payload;
|
||||||
|
delete node.topic;
|
||||||
props.each(function(i) {
|
props.each(function(i) {
|
||||||
var prop = $(this);
|
var prop = $(this);
|
||||||
var p = {
|
var p = {
|
||||||
@ -607,8 +603,18 @@
|
|||||||
if (p.p) {
|
if (p.p) {
|
||||||
p.v = prop.find(".node-input-prop-property-value").typedInput('value');
|
p.v = prop.find(".node-input-prop-property-value").typedInput('value');
|
||||||
p.vt = prop.find(".node-input-prop-property-value").typedInput('type');
|
p.vt = prop.find(".node-input-prop-property-value").typedInput('type');
|
||||||
|
if (p.p === "payload") { // save payload to old "legacy" property
|
||||||
|
node.payloadType = p.vt;
|
||||||
|
node.payload = p.v;
|
||||||
|
}
|
||||||
|
else if (p.p === "topic" && p.vt === "str") {
|
||||||
|
node.topic = p.v;
|
||||||
node.props.push(p);
|
node.props.push(p);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
node.props.push(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
button: {
|
button: {
|
||||||
|
@ -43,6 +43,9 @@ module.exports = function(RED) {
|
|||||||
this.onceDelay = (n.onceDelay || 0.1) * 1000;
|
this.onceDelay = (n.onceDelay || 0.1) * 1000;
|
||||||
this.interval_id = null;
|
this.interval_id = null;
|
||||||
this.cronjob = null;
|
this.cronjob = null;
|
||||||
|
if (n.payload && n.payloadType) { // load up original payload
|
||||||
|
this.props.unshift({p:"payload",v:n.payload,vt:n.payloadType});
|
||||||
|
}
|
||||||
var node = this;
|
var node = this;
|
||||||
|
|
||||||
node.props.forEach(function (prop) {
|
node.props.forEach(function (prop) {
|
||||||
|
Loading…
Reference in New Issue
Block a user