diff options
author | Angelo Gallarello <angelo.gallarell@gmail.com> | 2018-08-17 14:16:56 +0200 |
---|---|---|
committer | Angelo Gallarello <angelo.gallarell@gmail.com> | 2018-08-17 14:16:56 +0200 |
commit | 3b62b5ec5dd34eec323c14d466fe07e34287e7b0 (patch) | |
tree | 48f48f035460d12df8ad37234018c69ffa35b47b /client/components/rules | |
parent | 2f24dcfc7d2f1b426e83459ed5328529a440955d (diff) | |
download | wekan-3b62b5ec5dd34eec323c14d466fe07e34287e7b0.tar.gz wekan-3b62b5ec5dd34eec323c14d466fe07e34287e7b0.tar.bz2 wekan-3b62b5ec5dd34eec323c14d466fe07e34287e7b0.zip |
Fixed triggers to use names and not id
Diffstat (limited to 'client/components/rules')
-rw-r--r-- | client/components/rules/triggers/boardTriggers.js | 26 | ||||
-rw-r--r-- | client/components/rules/triggers/checklistTriggers.jade | 46 | ||||
-rw-r--r-- | client/components/rules/triggers/checklistTriggers.js | 108 |
3 files changed, 136 insertions, 44 deletions
diff --git a/client/components/rules/triggers/boardTriggers.js b/client/components/rules/triggers/boardTriggers.js index 6ec1ec4e..49c00c16 100644 --- a/client/components/rules/triggers/boardTriggers.js +++ b/client/components/rules/triggers/boardTriggers.js @@ -11,7 +11,7 @@ BlazeComponent.extendComponent({ const actionSelected = this.find('#gen-action').value; const boardId = Session.get('currentBoard') if(actionSelected == "created"){ - Triggers.insert({activityType: "createCard","boardId":boardId,"listId":"*"},function(error,id){ + Triggers.insert({activityType: "createCard","boardId":boardId,"listName":"*"},function(error,id){ datas.triggerIdVar.set(id); }); } @@ -27,20 +27,13 @@ BlazeComponent.extendComponent({ const actionSelected = this.find('#create-action').value; const listName = this.find('#create-list-name').value; const boardId = Session.get('currentBoard') - const list = Lists.findOne({title:listName}); - let listId; - if(list == undefined){ - listId = "*" - }else{ - listId = list._id; - } if(actionSelected == "created"){ - Triggers.insert({activityType: "createCard","boardId":boardId,"listId":listId},function(error,id){ + Triggers.insert({activityType: "createCard","boardId":boardId,"listName":listName},function(error,id){ datas.triggerIdVar.set(id); }); } if(actionSelected == "removed"){ - Triggers.insert({activityType: "removeCard","boardId":boardId,"listId":listId},function(error,id){ + Triggers.insert({activityType: "removeCard","boardId":boardId,"listName":listName},function(error,id){ datas.triggerIdVar.set(id); }); } @@ -50,22 +43,13 @@ BlazeComponent.extendComponent({ const actionSelected = this.find('#move-action').value; const listName = this.find('#move-list-name').value; const boardId = Session.get('currentBoard') - const list = Lists.findOne({title:listName}); - console.log(list); - let listId; - if(list == undefined){ - listId = "*" - }else{ - listId = list._id; - } - console.log(listId); if(actionSelected == "moved-to"){ - Triggers.insert({activityType: "moveCard","boardId":boardId,"listId":listId,"oldListId":"*"},function(error,id){ + Triggers.insert({activityType: "moveCard","boardId":boardId,"listName":listName,"oldListName":"*"},function(error,id){ datas.triggerIdVar.set(id); }); } if(actionSelected == "moved-from"){ - Triggers.insert({activityType: "moveCard","boardId":boardId,"listId":"*","oldListId":listId},function(error,id){ + Triggers.insert({activityType: "moveCard","boardId":boardId,"listName":"*","oldListName":listName},function(error,id){ datas.triggerIdVar.set(id); }); } diff --git a/client/components/rules/triggers/checklistTriggers.jade b/client/components/rules/triggers/checklistTriggers.jade index a34d89d0..e7d6d34e 100644 --- a/client/components/rules/triggers/checklistTriggers.jade +++ b/client/components/rules/triggers/checklistTriggers.jade @@ -4,12 +4,12 @@ template(name="checklistTriggers") div.trigger-text | When a checklist is div.trigger-dropdown - select(id="create-action") + select(id="gen-check-action") option(value="created") Added to option(value="removed") Removed from div.trigger-text | a card - div.trigger-button.js-add-gen.member-trigger.js-goto-action + div.trigger-button.js-add-gen-check-trigger.js-goto-action i.fa.fa-plus @@ -18,16 +18,16 @@ template(name="checklistTriggers") div.trigger-text | When the checklist div.trigger-dropdown - input(id="create-list-name",type=text,placeholder="Name") + input(id="check-name",type=text,placeholder="Name") div.trigger-text | is div.trigger-dropdown - select(id="create-action") + select(id="spec-check-action") option(value="created") Added to option(value="removed") Removed from div.trigger-text | a card - div.trigger-button.js-add-checklist-trigger.js-goto-action + div.trigger-button.js-add-spec-check-trigger.js-goto-action i.fa.fa-plus div.trigger-item @@ -35,10 +35,10 @@ template(name="checklistTriggers") div.trigger-text | When a checklist is div.trigger-dropdown - select(id="create-action") - option(value="created") Completed - option(value="removed") Made incomplete - div.trigger-button.js-add-gen.member-trigger.js-goto-action + select(id="gen-comp-check-action") + option(value="completed") Completed + option(value="uncompleted") Made incomplete + div.trigger-button.js-add-gen-comp-trigger.js-goto-action i.fa.fa-plus div.trigger-item @@ -46,14 +46,14 @@ template(name="checklistTriggers") div.trigger-text | When the checklist div.trigger-dropdown - input(id="create-list-name",type=text,placeholder="Name") + input(id="spec-comp-check-name",type=text,placeholder="Name") div.trigger-text | is div.trigger-dropdown - select(id="create-action") - option(value="created") Completed - option(value="removed") Made incomplete - div.trigger-button.js-add-checklist-trigger.js-goto-action + select(id="spec-comp-check-action") + option(value="completed") Completed + option(value="uncompleted") Made incomplete + div.trigger-button.js-add-spec-comp-trigger.js-goto-action i.fa.fa-plus div.trigger-item @@ -61,10 +61,10 @@ template(name="checklistTriggers") div.trigger-text | When a checklist item is div.trigger-dropdown - select(id="create-action") - option(value="created") Checked - option(value="removed") Unchecked - div.trigger-button.js-add-gen.member-trigger.js-goto-action + select(id="check-item-gen-action") + option(value="checked") Checked + option(value="unchecked") Unchecked + div.trigger-button.js-add-gen-check-item-trigger.js-goto-action i.fa.fa-plus div.trigger-item @@ -72,12 +72,12 @@ template(name="checklistTriggers") div.trigger-text | When the checklist item div.trigger-dropdown - input(id="create-list-name",type=text,placeholder="Name") + input(id="check-item-name",type=text,placeholder="Name") div.trigger-text | is div.trigger-dropdown - select(id="create-action") - option(value="created") Checked - option(value="removed") Unchecked - div.trigger-button.js-add-checklist-trigger.js-goto-action + select(id="check-item-spec-action") + option(value="checked") Checked + option(value="unchecked") Unchecked + div.trigger-button.js-add-spec-check-item-trigger.js-goto-action i.fa.fa-plus
\ No newline at end of file diff --git a/client/components/rules/triggers/checklistTriggers.js b/client/components/rules/triggers/checklistTriggers.js new file mode 100644 index 00000000..9880e3bb --- /dev/null +++ b/client/components/rules/triggers/checklistTriggers.js @@ -0,0 +1,108 @@ +BlazeComponent.extendComponent({ + onCreated() { + this.subscribe('allRules'); + }, + events() { + return [ + {'click .js-add-gen-check-trigger'(event) { + + let datas = this.data(); + const actionSelected = this.find('#gen-check-action').value; + const boardId = Session.get('currentBoard') + if(actionSelected == "created"){ + Triggers.insert({activityType: "addChecklist","boardId":boardId,"checklistName":"*"},function(error,id){ + datas.triggerIdVar.set(id); + }); + } + if(actionSelected == "removed"){ + Triggers.insert({activityType: "removeChecklist","boardId":boardId,"checklistName":"*"},function(error,id){ + datas.triggerIdVar.set(id); + }); + } + }, + 'click .js-add-spec-check-trigger'(event) { + let datas = this.data(); + const actionSelected = this.find('#spec-check-action').value; + const checklistId = this.find('#check-name').value; + const boardId = Session.get('currentBoard') + if(actionSelected == "created"){ + Triggers.insert({activityType: "addChecklist","boardId":boardId,"checklistName":checklistId},function(error,id){ + datas.triggerIdVar.set(id); + }); + } + if(actionSelected == "removed"){ + Triggers.insert({activityType: "removeChecklist","boardId":boardId,"checklistName":checklistId},function(error,id){ + datas.triggerIdVar.set(id); + }); + } + }, + 'click .js-add-gen-comp-trigger'(event) { + + let datas = this.data(); + const actionSelected = this.find('#gen-comp-check-action').value; + const boardId = Session.get('currentBoard') + if(actionSelected == "completed"){ + Triggers.insert({activityType: "completeChecklist","boardId":boardId,"checklistName":"*"},function(error,id){ + datas.triggerIdVar.set(id); + }); + } + if(actionSelected == "uncompleted"){ + Triggers.insert({activityType: "uncompleteChecklist","boardId":boardId,"checklistName":"*"},function(error,id){ + datas.triggerIdVar.set(id); + }); + } + }, + 'click .js-add-spec-comp-trigger'(event) { + let datas = this.data(); + const actionSelected = this.find('#spec-comp-check-action').value; + const checklistId = this.find('#spec-comp-check-name').value; + const boardId = Session.get('currentBoard') + if(actionSelected == "added"){ + Triggers.insert({activityType: "joinMember","boardId":boardId,"checklistName":checklistId},function(error,id){ + datas.triggerIdVar.set(id); + }); + } + if(actionSelected == "removed"){ + Triggers.insert({activityType: "unjoinMember","boardId":boardId,"checklistName":checklistId},function(error,id){ + datas.triggerIdVar.set(id); + }); + } + }, + 'click .js-add-gen-check-item-trigger'(event) { + + let datas = this.data(); + const actionSelected = this.find('#check-item-gen-action').value; + const boardId = Session.get('currentBoard') + if(actionSelected == "checked"){ + Triggers.insert({activityType: "checkedItem","boardId":boardId,"checklistItemName":"*"},function(error,id){ + datas.triggerIdVar.set(id); + }); + } + if(actionSelected == "unchecked"){ + Triggers.insert({activityType: "uncheckedItem","boardId":boardId,"checklistItemName":"*"},function(error,id){ + datas.triggerIdVar.set(id); + }); + } + }, + 'click .js-add-spec-check-item-trigger'(event) { + let datas = this.data(); + const actionSelected = this.find('#check-item-spec-action').value; + const checklistItemId = this.find('#check-item-name').value; + const boardId = Session.get('currentBoard') + if(actionSelected == "added"){ + Triggers.insert({activityType: "joinMember","boardId":boardId,"checklistItemName":checklistItemId},function(error,id){ + datas.triggerIdVar.set(id); + }); + } + if(actionSelected == "removed"){ + Triggers.insert({activityType: "unjoinMember","boardId":boardId,"checklistItemName":checklistItemId},function(error,id){ + datas.triggerIdVar.set(id); + }); + } + }, + }]; + }, + +}).register('checklistTriggers'); + + |