Set - set a property. The value can be a variety of different types, or
can be taken from an existing message or context property.
Change - search & replace parts of the property. If regular expressions
- are enabled, the replace with property can include capture groups, for example $1
+ are enabled, the replace with property can include capture groups, for
+ example $1. Replace will only change the type if there
+ is a complete match.
Delete - delete a property.
-
Move - move or rename a property. Equivalent to set and delete in one operation.
+
Move - move or rename a property.
@@ -135,7 +137,7 @@
var selectField = $('',{class:"node-input-rule-type",style:"width:110px; margin-right:10px;"}).appendTo(row1);
var selectOptions = [{v:"set",l:set},{v:"change",l:change},{v:"delete",l:del},{v:"move",l:move}];
- for (var i=0;i<4;i++) {
+ for (var i=0; i<4; i++) {
selectField.append($("").val(selectOptions[i].v).text(selectOptions[i].l));
}
@@ -241,7 +243,7 @@
this.rules = [rule];
}
- for (var i=0;idiv:not(.node-input-rule-container-row)");
var height = size.height;
- for (var i=0;idiv.node-input-rule-container-row");
diff --git a/nodes/core/logic/15-change.js b/nodes/core/logic/15-change.js
index 6a22f2585..67f30f12f 100644
--- a/nodes/core/logic/15-change.js
+++ b/nodes/core/logic/15-change.js
@@ -152,7 +152,7 @@ module.exports = function(RED) {
} else if (rule.t === 'change') {
current = RED.util.getMessageProperty(msg,property);
if (typeof current === 'string') {
- if ((fromType === 'num' || fromType === 'bool') && current === fromValue) {
+ if ((fromType === 'num' || fromType === 'bool' || fromType === 'str') && current === fromValue) {
// str representation of exact from number/boolean
// only replace if they match exactly
RED.util.setMessageProperty(msg,property,value);
@@ -170,7 +170,8 @@ module.exports = function(RED) {
}
}
}
- } else {
+ }
+ else {
var target;
if (rule.pt === 'flow') {
target = node.context().flow;
@@ -185,7 +186,7 @@ module.exports = function(RED) {
} else if (rule.t === 'change') {
current = target.get(msg,property);
if (typeof current === 'string') {
- if ((fromType === 'num' || fromType === 'bool') && current === fromValue) {
+ if ((fromType === 'num' || fromType === 'bool' || fromType === 'str') && current === fromValue) {
// str representation of exact from number/boolean
// only replace if they match exactly
target.set(property,value);
@@ -211,14 +212,14 @@ module.exports = function(RED) {
if (valid) {
var node = this;
this.on('input', function(msg) {
- for (var i=0;i