mirror of
https://github.com/wekan/wekan.git
synced 2025-04-23 13:37:09 -04:00
Finished alpha rules
This commit is contained in:
parent
fc73dc5bbc
commit
30a3daa6af
11 changed files with 237 additions and 306 deletions
|
@ -13,47 +13,49 @@ BlazeComponent.extendComponent({
|
|||
const actionSelected = this.find('#move-spec-action').value;
|
||||
const listTitle = this.find('#listName').value;
|
||||
const boardId = Session.get('currentBoard');
|
||||
|
||||
const desc = Utils.getTriggerActionDesc(event,this);
|
||||
if(actionSelected == "top"){
|
||||
const triggerId = Triggers.insert(trigger);
|
||||
const actionId = Actions.insert({actionType: "moveCardToTop","listTitle":listTitle,"boardId":boardId});
|
||||
const actionId = Actions.insert({actionType: "moveCardToTop","listTitle":listTitle,"boardId":boardId,"desc":desc});
|
||||
Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId});
|
||||
}
|
||||
if(actionSelected == "bottom"){
|
||||
const triggerId = Triggers.insert(trigger);
|
||||
const actionId = Actions.insert({actionType: "moveCardToBottom","listTitle":listTitle,"boardId":boardId});
|
||||
const actionId = Actions.insert({actionType: "moveCardToBottom","listTitle":listTitle,"boardId":boardId,"desc":desc});
|
||||
Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId});
|
||||
}
|
||||
},
|
||||
'click .js-add-gen-move-action'(event) {
|
||||
const desc = Utils.getTriggerActionDesc(event,this);
|
||||
const boardId = Session.get('currentBoard');
|
||||
const ruleName = this.data().ruleName.get();
|
||||
const trigger = this.data().triggerVar.get();
|
||||
const actionSelected = this.find('#move-gen-action').value;
|
||||
if(actionSelected == "top"){
|
||||
const triggerId = Triggers.insert(trigger);
|
||||
const actionId = Actions.insert({actionType: "moveCardToTop","listTitle":"*","boardId":boardId});
|
||||
const actionId = Actions.insert({actionType: "moveCardToTop","listTitle":"*","boardId":boardId,"desc":desc});
|
||||
Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId});
|
||||
}
|
||||
if(actionSelected == "bottom"){
|
||||
const triggerId = Triggers.insert(trigger);
|
||||
const actionId = Actions.insert({actionType: "moveCardToBottom","listTitle":"*","boardId":boardId});
|
||||
const actionId = Actions.insert({actionType: "moveCardToBottom","listTitle":"*","boardId":boardId,"desc":desc});
|
||||
Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId});
|
||||
}
|
||||
},
|
||||
'click .js-add-arch-action'(event) {
|
||||
const desc = Utils.getTriggerActionDesc(event,this);
|
||||
const boardId = Session.get('currentBoard');
|
||||
const ruleName = this.data().ruleName.get();
|
||||
const trigger = this.data().triggerVar.get();
|
||||
const actionSelected = this.find('#arch-action').value;
|
||||
if(actionSelected == "archive"){
|
||||
const triggerId = Triggers.insert(trigger);
|
||||
const actionId = Actions.insert({actionType: "archive","boardId":boardId});
|
||||
const actionId = Actions.insert({actionType: "archive","boardId":boardId,"desc":desc});
|
||||
Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId});
|
||||
}
|
||||
if(actionSelected == "unarchive"){
|
||||
const triggerId = Triggers.insert(trigger);
|
||||
const actionId = Actions.insert({actionType: "unarchive","boardId":boardId});
|
||||
const actionId = Actions.insert({actionType: "unarchive","boardId":boardId,"desc":desc});
|
||||
Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId});
|
||||
}
|
||||
},
|
||||
|
|
|
@ -24,45 +24,47 @@ BlazeComponent.extendComponent({
|
|||
const actionSelected = this.find('#label-action').value;
|
||||
const labelId = this.find('#label-id').value;
|
||||
const boardId = Session.get('currentBoard');
|
||||
|
||||
const desc = Utils.getTriggerActionDesc(event,this);
|
||||
if(actionSelected == "add"){
|
||||
const triggerId = Triggers.insert(trigger);
|
||||
const actionId = Actions.insert({actionType: "addLabel","labelId":labelId,"boardId":boardId});
|
||||
const actionId = Actions.insert({actionType: "addLabel","labelId":labelId,"boardId":boardId,"desc":desc});
|
||||
Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId});
|
||||
}
|
||||
if(actionSelected == "remove"){
|
||||
const triggerId = Triggers.insert(trigger);
|
||||
const actionId = Actions.insert({actionType: "removeLabel","labelId":labelId,"boardId":boardId});
|
||||
const actionId = Actions.insert({actionType: "removeLabel","labelId":labelId,"boardId":boardId,"desc":desc});
|
||||
Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId});
|
||||
}
|
||||
|
||||
},
|
||||
'click .js-add-member-action'(event) {
|
||||
const ruleName = this.data().ruleName.get();
|
||||
const trigger = this.data().triggerVar.get();
|
||||
const actionSelected = this.find('#member-action').value;
|
||||
const memberName = this.find('#member-name').value;
|
||||
const boardId = Session.get('currentBoard');
|
||||
if(actionSelected == "add"){
|
||||
const triggerId = Triggers.insert(trigger);
|
||||
const actionId = Actions.insert({actionType: "addMember","memberName":memberName,"boardId":boardId});
|
||||
Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId});
|
||||
}
|
||||
if(actionSelected == "remove"){
|
||||
const triggerId = Triggers.insert(trigger);
|
||||
const actionId = Actions.insert({actionType: "removeMember","memberName":memberName,"boardId":boardId});
|
||||
Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId});
|
||||
}
|
||||
},
|
||||
'click .js-add-removeall-action'(event) {
|
||||
const ruleName = this.data().ruleName.get();
|
||||
const trigger = this.data().triggerVar.get();
|
||||
const triggerId = Triggers.insert(trigger);
|
||||
const boardId = Session.get('currentBoard');
|
||||
const actionId = Actions.insert({actionType: "removeMember","memberName":"*","boardId":boardId});
|
||||
Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId});
|
||||
},
|
||||
}];
|
||||
const ruleName = this.data().ruleName.get();
|
||||
const trigger = this.data().triggerVar.get();
|
||||
const actionSelected = this.find('#member-action').value;
|
||||
const memberName = this.find('#member-name').value;
|
||||
const boardId = Session.get('currentBoard');
|
||||
const desc = Utils.getTriggerActionDesc(event,this);
|
||||
if(actionSelected == "add"){
|
||||
const triggerId = Triggers.insert(trigger);
|
||||
const actionId = Actions.insert({actionType: "addMember","memberName":memberName,"boardId":boardId,"desc":desc});
|
||||
Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId,"desc":desc});
|
||||
}
|
||||
if(actionSelected == "remove"){
|
||||
const triggerId = Triggers.insert(trigger);
|
||||
const actionId = Actions.insert({actionType: "removeMember","memberName":memberName,"boardId":boardId,"desc":desc});
|
||||
Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId});
|
||||
}
|
||||
},
|
||||
'click .js-add-removeall-action'(event) {
|
||||
const ruleName = this.data().ruleName.get();
|
||||
const trigger = this.data().triggerVar.get();
|
||||
const triggerId = Triggers.insert(trigger);
|
||||
const desc = Utils.getTriggerActionDesc(event,this);
|
||||
const boardId = Session.get('currentBoard');
|
||||
const actionId = Actions.insert({actionType: "removeMember","memberName":"*","boardId":boardId,"desc":desc});
|
||||
Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId});
|
||||
},
|
||||
}];
|
||||
},
|
||||
|
||||
}).register('cardActions');
|
|
@ -10,15 +10,15 @@ BlazeComponent.extendComponent({
|
|||
const actionSelected = this.find('#check-action').value;
|
||||
const checklistName = this.find('#checklist-name').value;
|
||||
const boardId = Session.get('currentBoard');
|
||||
|
||||
const desc = Utils.getTriggerActionDesc(event,this);
|
||||
if(actionSelected == "add"){
|
||||
const triggerId = Triggers.insert(trigger);
|
||||
const actionId = Actions.insert({actionType: "addChecklist","checklistName":checklistName,"boardId":boardId});
|
||||
const actionId = Actions.insert({actionType: "addChecklist","checklistName":checklistName,"boardId":boardId,"desc":desc});
|
||||
Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId});
|
||||
}
|
||||
if(actionSelected == "remove"){
|
||||
const triggerId = Triggers.insert(trigger);
|
||||
const actionId = Actions.insert({actionType: "removeChecklist","checklistName":checklistName,"boardId":boardId});
|
||||
const actionId = Actions.insert({actionType: "removeChecklist","checklistName":checklistName,"boardId":boardId,"desc":desc});
|
||||
Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId});
|
||||
}
|
||||
|
||||
|
@ -29,14 +29,15 @@ BlazeComponent.extendComponent({
|
|||
const actionSelected = this.find('#checkall-action').value;
|
||||
const checklistName = this.find('#checklist-name2').value;
|
||||
const boardId = Session.get('currentBoard');
|
||||
const desc = Utils.getTriggerActionDesc(event,this);
|
||||
if(actionSelected == "check"){
|
||||
const triggerId = Triggers.insert(trigger);
|
||||
const actionId = Actions.insert({actionType: "checkAll","checklistName":checklistName,"boardId":boardId});
|
||||
const actionId = Actions.insert({actionType: "checkAll","checklistName":checklistName,"boardId":boardId,"desc":desc});
|
||||
Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId});
|
||||
}
|
||||
if(actionSelected == "uncheck"){
|
||||
const triggerId = Triggers.insert(trigger);
|
||||
const actionId = Actions.insert({actionType: "uncheckAll","checklistName":checklistName,"boardId":boardId});
|
||||
const actionId = Actions.insert({actionType: "uncheckAll","checklistName":checklistName,"boardId":boardId,"desc":desc});
|
||||
Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId});
|
||||
}
|
||||
},
|
||||
|
@ -47,14 +48,15 @@ BlazeComponent.extendComponent({
|
|||
const checklistName = this.find("#checklist-name3");
|
||||
const actionSelected = this.find('#check-item-action').value;
|
||||
const boardId = Session.get('currentBoard');
|
||||
const desc = Utils.getTriggerActionDesc(event,this);
|
||||
if(actionSelected == "check"){
|
||||
const triggerId = Triggers.insert(trigger);
|
||||
const actionId = Actions.insert({actionType: "checkItem","checklistName":checklistName,"checkItemName":checkItemName,"boardId":boardId});
|
||||
const actionId = Actions.insert({actionType: "checkItem","checklistName":checklistName,"checkItemName":checkItemName,"boardId":boardId,"desc":desc});
|
||||
Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId});
|
||||
}
|
||||
if(actionSelected == "uncheck"){
|
||||
const triggerId = Triggers.insert(trigger);
|
||||
const actionId = Actions.insert({actionType: "uncheckItem","checklistName":checklistName,"checkItemName":checkItemName,"boardId":boardId});
|
||||
const actionId = Actions.insert({actionType: "uncheckItem","checklistName":checklistName,"checkItemName":checkItemName,"boardId":boardId,"desc":desc});
|
||||
Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId});
|
||||
}
|
||||
},
|
||||
|
|
|
@ -13,7 +13,8 @@ BlazeComponent.extendComponent({
|
|||
const ruleName = this.data().ruleName.get();
|
||||
const triggerId = Triggers.insert(trigger);
|
||||
const boardId = Session.get('currentBoard');
|
||||
const actionId = Actions.insert({actionType: "sendEmail","emailTo":emailTo,"emailSubject":emailSubject,"emailMsg":emailMsg,"boardId":boardId});
|
||||
const desc = Utils.getTriggerActionDesc(event,this);
|
||||
const actionId = Actions.insert({actionType: "sendEmail","emailTo":emailTo,"emailSubject":emailSubject,"emailMsg":emailMsg,"boardId":boardId,"desc":desc});
|
||||
Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId});
|
||||
},
|
||||
}];
|
||||
|
|
|
@ -3,5 +3,16 @@ template(name="ruleDetails")
|
|||
h2
|
||||
i.fa.fa-magic
|
||||
| {{{_ 'r-rule-details' }}}
|
||||
= trigger
|
||||
= action
|
||||
.triggers-content
|
||||
.triggers-body
|
||||
.triggers-main-body
|
||||
div.trigger-item
|
||||
div.trigger-content
|
||||
div.trigger-text
|
||||
= trigger
|
||||
div.trigger-item
|
||||
div.trigger-content
|
||||
div.trigger-text
|
||||
= action
|
||||
|
||||
|
|
@ -2,12 +2,11 @@ BlazeComponent.extendComponent({
|
|||
onCreated() {
|
||||
this.subscribe('allRules');
|
||||
},
|
||||
|
||||
labels(){
|
||||
labels() {
|
||||
const labels = Boards.findOne(Session.get('currentBoard')).labels;
|
||||
console.log(labels);
|
||||
for(let i = 0;i<labels.length;i++){
|
||||
if(labels[i].name == "" || labels[i].name == undefined){
|
||||
for (let i = 0; i < labels.length; i++) {
|
||||
if (labels[i].name == "" || labels[i].name == undefined) {
|
||||
labels[i].name = labels[i].color.toUpperCase();
|
||||
}
|
||||
}
|
||||
|
@ -15,70 +14,117 @@ BlazeComponent.extendComponent({
|
|||
return labels;
|
||||
},
|
||||
events() {
|
||||
return [
|
||||
{'click .js-add-gen-label-trigger'(event) {
|
||||
|
||||
let datas = this.data();
|
||||
const actionSelected = this.find('#label-action').value;
|
||||
const boardId = Session.get('currentBoard')
|
||||
if(actionSelected == "added"){
|
||||
datas.triggerVar.set({activityType: "addedLabel","boardId":boardId,"labelId":"*"});
|
||||
}
|
||||
if(actionSelected == "removed"){
|
||||
datas.triggerVar.set({activityType: "removedLabel","boardId":boardId,"labelId":"*"});
|
||||
}
|
||||
},
|
||||
'click .js-add-spec-label-trigger'(event) {
|
||||
let datas = this.data();
|
||||
const actionSelected = this.find('#spec-label-action').value;
|
||||
const labelId = this.find('#spec-label').value;
|
||||
const boardId = Session.get('currentBoard')
|
||||
if(actionSelected == "added"){
|
||||
datas.triggerVar.set({activityType: "addedLabel","boardId":boardId,"labelId":labelId});
|
||||
}
|
||||
if(actionSelected == "removed"){
|
||||
datas.triggerVar.set({activityType: "removedLabel","boardId":boardId,"labelId":labelId});
|
||||
}
|
||||
},
|
||||
'click .js-add-gen-member-trigger'(event) {
|
||||
|
||||
let datas = this.data();
|
||||
const actionSelected = this.find('#gen-member-action').value;
|
||||
const boardId = Session.get('currentBoard')
|
||||
if(actionSelected == "added"){
|
||||
datas.triggerVar.set({activityType: "joinMember","boardId":boardId,"memberId":"*"});
|
||||
}
|
||||
if(actionSelected == "removed"){
|
||||
datas.triggerVar.set({activityType: "unjoinMember","boardId":boardId,"memberId":"*"});
|
||||
}
|
||||
},
|
||||
'click .js-add-spec-member-trigger'(event) {
|
||||
let datas = this.data();
|
||||
const actionSelected = this.find('#spec-member-action').value;
|
||||
const memberId = this.find('#spec-member').value;
|
||||
const boardId = Session.get('currentBoard')
|
||||
if(actionSelected == "added"){
|
||||
datas.triggerVar.set({activityType: "joinMember","boardId":boardId,"memberId":memberId});
|
||||
}
|
||||
if(actionSelected == "removed"){
|
||||
datas.triggerVar.set({activityType: "unjoinMember","boardId":boardId,"memberId":memberId});
|
||||
}
|
||||
},
|
||||
'click .js-add-attachment-trigger'(event) {
|
||||
|
||||
let datas = this.data();
|
||||
const actionSelected = this.find('#attach-action').value;
|
||||
const boardId = Session.get('currentBoard')
|
||||
if(actionSelected == "added"){
|
||||
datas.triggerVar.set({activityType: "addAttachment","boardId":boardId});
|
||||
}
|
||||
if(actionSelected == "removed"){
|
||||
datas.triggerVar.set({activityType: "deleteAttachment","boardId":boardId});
|
||||
}
|
||||
},
|
||||
return [{
|
||||
'click .js-add-gen-label-trigger' (event) {
|
||||
const desc = Utils.getTriggerActionDesc(event, this);
|
||||
let datas = this.data();
|
||||
const actionSelected = this.find('#label-action').value;
|
||||
const boardId = Session.get('currentBoard')
|
||||
if (actionSelected == "added") {
|
||||
datas.triggerVar.set({
|
||||
activityType: "addedLabel",
|
||||
"boardId": boardId,
|
||||
"labelId": "*",
|
||||
"desc": desc
|
||||
});
|
||||
}
|
||||
if (actionSelected == "removed") {
|
||||
datas.triggerVar.set({
|
||||
activityType: "removedLabel",
|
||||
"boardId": boardId,
|
||||
"labelId": "*",
|
||||
"desc": desc
|
||||
});
|
||||
}
|
||||
},
|
||||
'click .js-add-spec-label-trigger' (event) {
|
||||
const desc = Utils.getTriggerActionDesc(event, this);
|
||||
let datas = this.data();
|
||||
const actionSelected = this.find('#spec-label-action').value;
|
||||
const labelId = this.find('#spec-label').value;
|
||||
const boardId = Session.get('currentBoard')
|
||||
if (actionSelected == "added") {
|
||||
datas.triggerVar.set({
|
||||
activityType: "addedLabel",
|
||||
"boardId": boardId,
|
||||
"labelId": labelId,
|
||||
"desc": desc
|
||||
});
|
||||
}
|
||||
if (actionSelected == "removed") {
|
||||
datas.triggerVar.set({
|
||||
activityType: "removedLabel",
|
||||
"boardId": boardId,
|
||||
"labelId": labelId,
|
||||
"desc": desc
|
||||
});
|
||||
}
|
||||
},
|
||||
'click .js-add-gen-member-trigger' (event) {
|
||||
const desc = Utils.getTriggerActionDesc(event, this);
|
||||
let datas = this.data();
|
||||
const actionSelected = this.find('#gen-member-action').value;
|
||||
const boardId = Session.get('currentBoard')
|
||||
if (actionSelected == "added") {
|
||||
datas.triggerVar.set({
|
||||
activityType: "joinMember",
|
||||
"boardId": boardId,
|
||||
"memberId": "*",
|
||||
"desc": desc
|
||||
});
|
||||
}
|
||||
if (actionSelected == "removed") {
|
||||
datas.triggerVar.set({
|
||||
activityType: "unjoinMember",
|
||||
"boardId": boardId,
|
||||
"memberId": "*",
|
||||
"desc": desc
|
||||
});
|
||||
}
|
||||
},
|
||||
'click .js-add-spec-member-trigger' (event) {
|
||||
const desc = Utils.getTriggerActionDesc(event, this);
|
||||
let datas = this.data();
|
||||
const actionSelected = this.find('#spec-member-action').value;
|
||||
const memberId = this.find('#spec-member').value;
|
||||
const boardId = Session.get('currentBoard')
|
||||
if (actionSelected == "added") {
|
||||
datas.triggerVar.set({
|
||||
activityType: "joinMember",
|
||||
"boardId": boardId,
|
||||
"memberId": memberId,
|
||||
"desc": desc
|
||||
});
|
||||
}
|
||||
if (actionSelected == "removed") {
|
||||
datas.triggerVar.set({
|
||||
activityType: "unjoinMember",
|
||||
"boardId": boardId,
|
||||
"memberId": memberId,
|
||||
"desc": desc
|
||||
});
|
||||
}
|
||||
},
|
||||
'click .js-add-attachment-trigger' (event) {
|
||||
const desc = Utils.getTriggerActionDesc(event, this);
|
||||
let datas = this.data();
|
||||
const actionSelected = this.find('#attach-action').value;
|
||||
const boardId = Session.get('currentBoard')
|
||||
if (actionSelected == "added") {
|
||||
datas.triggerVar.set({
|
||||
activityType: "addAttachment",
|
||||
"boardId": boardId,
|
||||
"desc": desc
|
||||
});
|
||||
}
|
||||
if (actionSelected == "removed") {
|
||||
datas.triggerVar.set({
|
||||
activityType: "deleteAttachment",
|
||||
"boardId": boardId,
|
||||
"desc": desc
|
||||
});
|
||||
}
|
||||
},
|
||||
}];
|
||||
},
|
||||
|
||||
}).register('cardTriggers');
|
||||
|
||||
|
||||
}).register('cardTriggers');
|
|
@ -5,79 +5,83 @@ BlazeComponent.extendComponent({
|
|||
events() {
|
||||
return [
|
||||
{'click .js-add-gen-check-trigger'(event) {
|
||||
|
||||
const desc = Utils.getTriggerActionDesc(event,this);
|
||||
let datas = this.data();
|
||||
const actionSelected = this.find('#gen-check-action').value;
|
||||
const boardId = Session.get('currentBoard')
|
||||
if(actionSelected == "created"){
|
||||
datas.triggerVar.set({activityType: "addChecklist","boardId":boardId,"checklistName":"*"});
|
||||
datas.triggerVar.set({activityType: "addChecklist","boardId":boardId,"checklistName":"*","desc":desc});
|
||||
}
|
||||
if(actionSelected == "removed"){
|
||||
datas.triggerVar.set({activityType: "removeChecklist","boardId":boardId,"checklistName":"*"});
|
||||
datas.triggerVar.set({activityType: "removeChecklist","boardId":boardId,"checklistName":"*","desc":desc});
|
||||
}
|
||||
},
|
||||
'click .js-add-spec-check-trigger'(event) {
|
||||
const desc = Utils.getTriggerActionDesc(event,this);
|
||||
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"){
|
||||
datas.triggerVar.set({activityType: "addChecklist","boardId":boardId,"checklistName":checklistId});
|
||||
datas.triggerVar.set({activityType: "addChecklist","boardId":boardId,"checklistName":checklistId,"desc":desc});
|
||||
}
|
||||
if(actionSelected == "removed"){
|
||||
datas.triggerVar.set({activityType: "removeChecklist","boardId":boardId,"checklistName":checklistId});
|
||||
datas.triggerVar.set({activityType: "removeChecklist","boardId":boardId,"checklistName":checklistId,"desc":desc});
|
||||
}
|
||||
},
|
||||
'click .js-add-gen-comp-trigger'(event) {
|
||||
const desc = Utils.getTriggerActionDesc(event,this);
|
||||
|
||||
let datas = this.data();
|
||||
const actionSelected = this.find('#gen-comp-check-action').value;
|
||||
const boardId = Session.get('currentBoard')
|
||||
if(actionSelected == "completed"){
|
||||
datas.triggerVar.set({activityType: "completeChecklist","boardId":boardId,"checklistName":"*"});
|
||||
datas.triggerVar.set({activityType: "completeChecklist","boardId":boardId,"checklistName":"*","desc":desc});
|
||||
}
|
||||
if(actionSelected == "uncompleted"){
|
||||
datas.triggerVar.set({activityType: "uncompleteChecklist","boardId":boardId,"checklistName":"*"});
|
||||
datas.triggerVar.set({activityType: "uncompleteChecklist","boardId":boardId,"checklistName":"*","desc":desc});
|
||||
}
|
||||
},
|
||||
'click .js-add-spec-comp-trigger'(event) {
|
||||
const desc = Utils.getTriggerActionDesc(event,this);
|
||||
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"){
|
||||
datas.triggerVar.set({activityType: "completeChecklist","boardId":boardId,"checklistName":checklistId});
|
||||
datas.triggerVar.set({activityType: "completeChecklist","boardId":boardId,"checklistName":checklistId,"desc":desc});
|
||||
}
|
||||
if(actionSelected == "removed"){
|
||||
datas.triggerVar.set({activityType: "uncompleteChecklist","boardId":boardId,"checklistName":checklistId});
|
||||
datas.triggerVar.set({activityType: "uncompleteChecklist","boardId":boardId,"checklistName":checklistId,"desc":desc});
|
||||
}
|
||||
},
|
||||
'click .js-add-gen-check-item-trigger'(event) {
|
||||
|
||||
const desc = Utils.getTriggerActionDesc(event,this);
|
||||
let datas = this.data();
|
||||
const actionSelected = this.find('#check-item-gen-action').value;
|
||||
const boardId = Session.get('currentBoard')
|
||||
if(actionSelected == "checked"){
|
||||
datas.triggerVar.set({activityType: "checkedItem","boardId":boardId,"checklistItemName":"*"});
|
||||
datas.triggerVar.set({activityType: "checkedItem","boardId":boardId,"checklistItemName":"*","desc":desc});
|
||||
}
|
||||
if(actionSelected == "unchecked"){
|
||||
datas.triggerVar.set({activityType: "uncheckedItem","boardId":boardId,"checklistItemName":"*"});
|
||||
datas.triggerVar.set({activityType: "uncheckedItem","boardId":boardId,"checklistItemName":"*","desc":desc});
|
||||
}
|
||||
},
|
||||
'click .js-add-spec-check-item-trigger'(event) {
|
||||
const desc = Utils.getTriggerActionDesc(event,this);
|
||||
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 == "checked"){
|
||||
datas.triggerVar.set({activityType: "checkedItem","boardId":boardId,"checklistItemName":checklistItemId});
|
||||
datas.triggerVar.set({activityType: "checkedItem","boardId":boardId,"checklistItemName":checklistItemId,"desc":desc});
|
||||
}
|
||||
if(actionSelected == "unchecked"){
|
||||
datas.triggerVar.set({activityType: "uncheckedItem","boardId":boardId,"checklistItemName":checklistItemId});
|
||||
datas.triggerVar.set({activityType: "uncheckedItem","boardId":boardId,"checklistItemName":checklistItemId,"desc":desc});
|
||||
}
|
||||
},
|
||||
}];
|
||||
},
|
||||
}];
|
||||
},
|
||||
|
||||
}).register('checklistTriggers');
|
||||
|
||||
|
|
|
@ -152,9 +152,9 @@ Utils = {
|
|||
for(let i = 0;i< triggerEls.length;i++){
|
||||
const element = tempInstance.$(triggerEls[i]);
|
||||
if(element.hasClass("trigger-text")){
|
||||
finalString += element.text();
|
||||
finalString += element.text().toLowerCase();
|
||||
}else if(element.find("select").length > 0){
|
||||
finalString += element.find("select option:selected").text();
|
||||
finalString += element.find("select option:selected").text().toLowerCase();
|
||||
}else if(element.find("input").length > 0){
|
||||
finalString += element.find("input").val();
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ Utils = {
|
|||
finalString += " ";
|
||||
}
|
||||
}
|
||||
return finalString.toLowerCase();
|
||||
return finalString;
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -16,85 +16,7 @@ Actions.allow({
|
|||
|
||||
Actions.helpers({
|
||||
description() {
|
||||
if(this.actionType == "moveCardToTop"){
|
||||
if(this.listTitle == "*"){
|
||||
return TAPi18n.__('r-d-move-to-top-gen');
|
||||
}else{
|
||||
return TAPi18n.__('r-d-move-to-top-spec') + " " + this.listTitle;
|
||||
}
|
||||
}
|
||||
if(this.actionType == "moveCardToBottom"){
|
||||
if(this.listTitle == "*"){
|
||||
return TAPi18n.__('r-d-move-to-bottom-gen');
|
||||
}else{
|
||||
return TAPi18n.__('r-d-move-to-bottom-spec') + " " + this.listTitle;
|
||||
}
|
||||
}
|
||||
if(this.actionType == "sendEmail"){
|
||||
const to = " " + TAPi18n.__('r-d-send-email-to') + ": " + this.emailTo + ", ";
|
||||
const subject = TAPi18n.__('r-d-send-email-subject') + ": " + this.emailSubject + ", ";
|
||||
const message = TAPi18n.__('r-d-send-email-message') + ": " + this.emailMsg;
|
||||
const total = TAPi18n.__('r-d-send-email') + to + subject + message;
|
||||
return total;
|
||||
}
|
||||
if(this.actionType == "archive"){
|
||||
return TAPi18n.__('r-d-archive');
|
||||
}
|
||||
if(this.actionType == "unarchive"){
|
||||
return TAPi18n.__('r-d-unarchive');
|
||||
}
|
||||
if(this.actionType == "addLabel"){
|
||||
const board = Boards.findOne(Session.get('currentBoard'));
|
||||
const label = board.getLabelById(this.labelId);
|
||||
let name;
|
||||
if(label.name == "" || label.name == undefined){
|
||||
name = label.color.toUpperCase();
|
||||
}else{
|
||||
name = label.name;
|
||||
}
|
||||
|
||||
return TAPi18n.__('r-d-add-label') + ": "+name;
|
||||
}
|
||||
if(this.actionType == "removeLabel"){
|
||||
const board = Boards.findOne(Session.get('currentBoard'));
|
||||
const label = board.getLabelById(this.labelId);
|
||||
let name;
|
||||
if(label.name == "" || label.name == undefined){
|
||||
name = label.color.toUpperCase();
|
||||
}else{
|
||||
name = label.name;
|
||||
}
|
||||
return TAPi18n.__('r-d-remove-label') + ": " + name;
|
||||
}
|
||||
if(this.actionType == "addMember"){
|
||||
return TAPi18n.__('r-d-add-member') + ": " + this.memberName;
|
||||
}
|
||||
if(this.actionType == "removeMember"){
|
||||
if(this.memberName == "*"){
|
||||
return TAPi18n.__('r-d-remove-all-member');
|
||||
}
|
||||
return TAPi18n.__('r-d-remove-member') + ": "+ this.memberName;
|
||||
}
|
||||
if(this.actionType == "checkAll"){
|
||||
return TAPi18n.__('r-d-check-all') + ": " + this.checklistName;
|
||||
}
|
||||
if(this.actionType == "uncheckAll"){
|
||||
return TAPi18n.__('r-d-uncheck-all') + ": "+ this.checklistName;
|
||||
}
|
||||
if(this.actionType == "checkItem"){
|
||||
return TAPi18n.__('r-d-check-one') + ": "+ this.checkItemName + " " + TAPi18n.__('r-d-check-of-list') + ": " +this.checklistName;
|
||||
}
|
||||
if(this.actionType == "uncheckItem"){
|
||||
return TAPi18n.__('r-d-check-one') + ": "+ this.checkItemName + " " + TAPi18n.__('r-d-check-of-list') + ": " +this.checklistName;
|
||||
}
|
||||
if(this.actionType == "addChecklist"){
|
||||
return TAPi18n.__('r-d-add-checklist') + ": "+ this.checklistName;
|
||||
}
|
||||
if(this.actionType == "removeChecklist"){
|
||||
return TAPi18n.__('r-d-remove-checklist') + ": "+ this.checklistName;
|
||||
}
|
||||
|
||||
return "Ops not trigger description";
|
||||
return this.desc;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
Triggers = new Mongo.Collection('triggers');
|
||||
|
||||
|
||||
|
||||
Triggers.mutations({
|
||||
rename(description) {
|
||||
return { $set: { description } };
|
||||
return {
|
||||
$set: {
|
||||
description
|
||||
}
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -20,87 +22,37 @@ Triggers.allow({
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
Triggers.helpers({
|
||||
|
||||
description() {
|
||||
return this.desc;
|
||||
},
|
||||
|
||||
description(){
|
||||
if(this.activityType == "createCard"){
|
||||
if(this.listName == "*"){
|
||||
return TAPi18n.__('r-when-a-card-is') + " " + TAPi18n.__('r-added-to').toLowerCase() + " " + TAPi18n.__('r-the-board');
|
||||
}else{
|
||||
return TAPi18n.__('r-when-a-card-is') + " " + TAPi18n.__('r-added-to').toLowerCase() + " " + TAPi18n.__('r-list') + " " +this.listName;
|
||||
}
|
||||
}
|
||||
if(this.activityType == "removeCard"){
|
||||
if(this.listName == "*"){
|
||||
return TAPi18n.__('r-when-a-card-is') + " " + TAPi18n.__('r-removed-from') + " " + TAPi18n.__('r-the-board');
|
||||
}else{
|
||||
return TAPi18n.__('r-when-a-card-is') + " " + TAPi18n.__('r-removed-from') + " " + TAPi18n.__('r-list') + " " +this.listName;
|
||||
}
|
||||
}
|
||||
if(this.activityType == "moveCard"){
|
||||
if(this.listName = "*"){
|
||||
return TAPi18n.__('r-when-a-card-is') + " " + TAPi18n.__('r-moved-from') + " " + this.oldListName;
|
||||
}else{
|
||||
return TAPi18n.__('r-when-a-card-is') + " " + TAPi18n.__('r-moved-to') + " " + this.listName;
|
||||
}
|
||||
|
||||
}
|
||||
if(this.activityType = "archivedCard"){
|
||||
return TAPi18n.__('r-when-a-card-is') + " " + TAPi18n.__('r-archived');
|
||||
}
|
||||
if(this.activityType = "restoredCard"){
|
||||
return TAPi18n.__('r-when-a-card-is') + " " + TAPi18n.__('r-unarchived');
|
||||
}
|
||||
if(this.activityType = "addedLabel"){
|
||||
if(this.labelId == "*"){
|
||||
return TAPi18n.__('r-when-a-label-is') + " " + TAPi18n.__('r-added-to') + " " + TAPi18n.__('r-a-card');
|
||||
}else{
|
||||
const board = Boards.findOne(Session.get('currentBoard'));
|
||||
const label = board.getLabelById(this.labelId);
|
||||
let name;
|
||||
if(label.name == "" || label.name == undefined){
|
||||
name = label.color.toUpperCase();
|
||||
}else{
|
||||
name = label.name;
|
||||
}
|
||||
}
|
||||
getRule() {
|
||||
return Rules.findOne({
|
||||
triggerId: this._id
|
||||
});
|
||||
},
|
||||
|
||||
fromList() {
|
||||
return Lists.findOne(this.fromId);
|
||||
},
|
||||
|
||||
toList() {
|
||||
return Lists.findOne(this.toId);
|
||||
},
|
||||
|
||||
findList(title) {
|
||||
return Lists.findOne({
|
||||
title: title
|
||||
});
|
||||
},
|
||||
|
||||
labels() {
|
||||
const boardLabels = this.board().labels;
|
||||
const cardLabels = _.filter(boardLabels, (label) => {
|
||||
return _.contains(this.labelIds, label._id);
|
||||
});
|
||||
return cardLabels;
|
||||
}
|
||||
if(this.activityType = "restoredCard"){
|
||||
return TAPi18n.__('r-when-a-card-is') + " " + TAPi18n.__('r-unarchived');
|
||||
}
|
||||
|
||||
|
||||
|
||||
return "No description found";
|
||||
},
|
||||
|
||||
getRule(){
|
||||
return Rules.findOne({triggerId:this._id});
|
||||
},
|
||||
|
||||
fromList() {
|
||||
return Lists.findOne(this.fromId);
|
||||
},
|
||||
|
||||
toList() {
|
||||
return Lists.findOne(this.toId);
|
||||
},
|
||||
|
||||
findList(title) {
|
||||
return Lists.findOne({title:title});
|
||||
},
|
||||
|
||||
labels() {
|
||||
const boardLabels = this.board().labels;
|
||||
const cardLabels = _.filter(boardLabels, (label) => {
|
||||
return _.contains(this.labelIds, label._id);
|
||||
});
|
||||
return cardLabels;
|
||||
}});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
|
@ -1,10 +1,7 @@
|
|||
RulesHelper = {
|
||||
executeRules(activity){
|
||||
const matchingRules = this.findMatchingRules(activity);
|
||||
console.log("Matching rules:")
|
||||
console.log(matchingRules);
|
||||
for(let i = 0;i< matchingRules.length;i++){
|
||||
console.log(matchingRules[i]);
|
||||
const action = matchingRules[i].getAction();
|
||||
this.performAction(activity,action);
|
||||
}
|
||||
|
@ -34,11 +31,6 @@ RulesHelper = {
|
|||
return matchingMap;
|
||||
},
|
||||
performAction(activity,action){
|
||||
|
||||
console.log("Performing action - Activity");
|
||||
console.log(activity);
|
||||
console.log("Performing action - Action");
|
||||
console.log(action);
|
||||
const card = Cards.findOne({_id:activity.cardId});
|
||||
const boardId = activity.boardId;
|
||||
if(action.actionType == "moveCardToTop"){
|
||||
|
@ -96,14 +88,11 @@ RulesHelper = {
|
|||
}
|
||||
if(action.actionType == "addMember"){
|
||||
const memberId = Users.findOne({username:action.memberName})._id;
|
||||
console.log(memberId);
|
||||
card.assignMember(memberId);
|
||||
}
|
||||
if(action.actionType == "removeMember"){
|
||||
if(action.memberName == "*"){
|
||||
console.log(card);
|
||||
const members = card.members;
|
||||
console.log(members);
|
||||
for(let i = 0;i< members.length;i++){
|
||||
card.unassignMember(members[i]);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue