mirror of
https://github.com/wekan/wekan.git
synced 2025-12-22 02:10:12 +01:00
UI for rules list
This commit is contained in:
parent
d5870472fb
commit
f63482b587
19 changed files with 256 additions and 2 deletions
74
models/triggers.js
Normal file
74
models/triggers.js
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
Triggers = new Mongo.Collection('triggers');
|
||||
|
||||
|
||||
|
||||
Triggers.mutations({
|
||||
rename(description) {
|
||||
return { $set: { description } };
|
||||
},
|
||||
});
|
||||
|
||||
Triggers.allow({
|
||||
update: function () {
|
||||
// add custom authentication code here
|
||||
return true;
|
||||
},
|
||||
insert: function () {
|
||||
// add custom authentication code here
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Triggers.helpers({
|
||||
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 (Meteor.isServer) {
|
||||
Meteor.startup(() => {
|
||||
const rules = Triggers.findOne({});
|
||||
if(!rules){
|
||||
Triggers.insert({group: "cards", activityType: "moveCard","fromId":-1,"toId":-1 });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
Activities.after.insert((userId, doc) => {
|
||||
const activity = Activities._transform(doc);
|
||||
const matchedTriggers = Triggers.find({activityType: activity.activityType,fromId:activity.oldListId,toId:activity.listId})
|
||||
if(matchedTriggers.count() > 0){
|
||||
const card = activity.card();
|
||||
const oldTitle = card.title;
|
||||
const fromListTitle = activity.oldList().title;
|
||||
Cards.direct.update({_id: card._id, listId: card.listId, boardId: card.boardId, archived: false},
|
||||
{$set: {title: "[From "+fromListTitle +"] "+ oldTitle}});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue