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.js31
1 files changed, 29 insertions, 2 deletions
diff --git a/client/components/rules/rulesMain.js b/client/components/rules/rulesMain.js
index 0752a541..2e125960 100644
--- a/client/components/rules/rulesMain.js
+++ b/client/components/rules/rulesMain.js
@@ -1,4 +1,4 @@
-BlazeComponent.extendComponent({
+const rulesMainComponent = BlazeComponent.extendComponent({
onCreated() {
this.rulesCurrentTab = new ReactiveVar('rulesList');
this.ruleName = new ReactiveVar('');
@@ -9,7 +9,13 @@ BlazeComponent.extendComponent({
setTrigger() {
this.rulesCurrentTab.set('trigger');
},
-
+ sanitizeObject(obj){
+ Object.keys(obj).forEach((key) => {
+ if(obj[key] == '' || obj[key] == undefined){
+ obj[key] = '*';
+ }}
+ );
+ },
setRulesList() {
this.rulesCurrentTab.set('rulesList');
},
@@ -42,8 +48,27 @@ BlazeComponent.extendComponent({
},
'click .js-goto-action' (event) {
event.preventDefault();
+ // Add user to the trigger
+ const username = $(event.currentTarget.offsetParent).find('.user-name').val();
+ let trigger = this.triggerVar.get();
+ trigger.userId = '*';
+ if(username != undefined ){
+ const userFound = Users.findOne({username});
+ if(userFound != undefined){
+ trigger.userId = userFound._id;
+ this.triggerVar.set(trigger);
+ }
+ }
+ // Sanitize trigger
+ trigger = this.triggerVar.get();
+ this.sanitizeObject(trigger);
+ this.triggerVar.set(trigger);
this.setAction();
},
+ 'click .js-show-user-field' (event) {
+ event.preventDefault();
+ $(event.currentTarget.offsetParent).find('.user-details').removeClass('hide-element');
+ },
'click .js-goto-rules' (event) {
event.preventDefault();
this.setRulesList();
@@ -68,3 +93,5 @@ BlazeComponent.extendComponent({
},
}).register('rulesMain');
+
+