changed rules property to be stored as a JSON string

This commit is contained in:
Niko Vujić
2025-12-31 10:29:00 +01:00
parent e07341fa05
commit 7c9c1ddf3a
4 changed files with 52 additions and 27 deletions

View File

@@ -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>