summaryrefslogtreecommitdiffstats
path: root/client/components/rules/rulesMain.js
diff options
context:
space:
mode:
Diffstat (limited to 'client/components/rules/rulesMain.js')
-rw-r--r--client/components/rules/rulesMain.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/client/components/rules/rulesMain.js b/client/components/rules/rulesMain.js
new file mode 100644
index 00000000..e4cac03d
--- /dev/null
+++ b/client/components/rules/rulesMain.js
@@ -0,0 +1,58 @@
+BlazeComponent.extendComponent({
+ onCreated() {
+ this.rulesCurrentTab = new ReactiveVar("rulesList")
+ this.ruleName = new ReactiveVar("");
+ this.triggerVar = new ReactiveVar();
+ this.ruleId = new ReactiveVar();
+ },
+
+ setTrigger() {
+ this.rulesCurrentTab.set("trigger")
+ },
+
+ setRulesList() {
+ this.rulesCurrentTab.set("rulesList")
+ },
+
+ setAction() {
+ this.rulesCurrentTab.set("action")
+ },
+ setRuleDetails() {
+ this.rulesCurrentTab.set("ruleDetails")
+ },
+
+ events() {
+ return [{
+ 'click .js-delete-rule' (event) {
+ const rule = this.currentData();
+ Rules.remove(rule._id);
+ Actions.remove(rule.actionId);
+ Triggers.remove(rule.triggerId);
+
+ },
+ 'click .js-goto-trigger' (event) {
+ event.preventDefault();
+ const ruleTitle = this.find('#ruleTitle').value;
+ this.find('#ruleTitle').value = "";
+ this.ruleName.set(ruleTitle)
+ this.setTrigger();
+ },
+ 'click .js-goto-action' (event) {
+ event.preventDefault();
+ this.setAction();
+ },
+ 'click .js-goto-rules' (event) {
+ event.preventDefault();
+ this.setRulesList();
+ },
+ 'click .js-goto-details' (event) {
+ event.preventDefault();
+ const rule = this.currentData();
+ this.ruleId.set(rule._id)
+ this.setRuleDetails();
+ },
+
+ }];
+ },
+
+}).register('rulesMain'); \ No newline at end of file