Add admin display rules adjustments

This commit is contained in:
Pedro Silva 2023-09-18 08:54:54 +01:00
parent e31e09f0c7
commit 71fc53f495
No known key found for this signature in database
GPG key ID: E2EE20C0669D24B3

View file

@ -8,6 +8,7 @@ class Rule {
this.conditions = {}; this.conditions = {};
this.actions = {}; this.actions = {};
this.triggerUpdate = triggerUpdate; this.triggerUpdate = triggerUpdate;
this.status = null;
const updateStatus = this.updateStatus.bind(this); const updateStatus = this.updateStatus.bind(this);
for (const conditionConfig of this.config.conditions) { for (const conditionConfig of this.config.conditions) {
@ -29,7 +30,7 @@ class Rule {
return this.config.key; return this.config.key;
} }
updateStatus() { updateStatus(forceRunActions = false) {
let status = true; let status = true;
for (const [key, condition] of Object.entries(this.conditions)) { for (const [key, condition] of Object.entries(this.conditions)) {
@ -40,6 +41,8 @@ class Rule {
this.status = status; this.status = status;
this.triggerUpdate(); this.triggerUpdate();
this.runActions(); this.runActions();
} else if (forceRunActions) {
this.runActions();
} }
} }
@ -57,7 +60,7 @@ class Rule {
action.register(); action.register();
} }
this.updateStatus(); this.updateStatus(true);
} }
} }