changed rules property to be stored as a JSON string
This commit is contained in:
@@ -6,7 +6,7 @@ RED.nodes.registerType('xilica-subscribe', {
|
||||
name: { value: "" },
|
||||
action: { value: "subscribe" },
|
||||
connection: { value: "", type: "xilica-connection" },
|
||||
rules: { value: [] },
|
||||
rules: { value: "[]" },
|
||||
transport: { value: "TCP" }
|
||||
},
|
||||
inputs: 1,
|
||||
@@ -21,15 +21,10 @@ RED.nodes.registerType('xilica-subscribe', {
|
||||
},
|
||||
oneditprepare: function () {
|
||||
var node = this;
|
||||
var rules = node.rules || [];
|
||||
if (typeof rules === "string") {
|
||||
try {
|
||||
rules = JSON.parse(rules);
|
||||
} catch (e) {
|
||||
rules = [];
|
||||
}
|
||||
}
|
||||
if (!Array.isArray(rules)) {
|
||||
var rules;
|
||||
try {
|
||||
rules = node.rules ? JSON.parse(node.rules) : [];
|
||||
} catch (e) {
|
||||
rules = [];
|
||||
}
|
||||
|
||||
@@ -121,7 +116,7 @@ RED.nodes.registerType('xilica-subscribe', {
|
||||
rules.push(rule);
|
||||
});
|
||||
|
||||
this.rules = rules;
|
||||
this.rules = JSON.stringify(rules);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user