mirror of
https://github.com/wekan/wekan.git
synced 2026-02-04 07:31:47 +01:00
Almost full circle
This commit is contained in:
parent
93cc7f0232
commit
9b0eb0a9f1
24 changed files with 492 additions and 165 deletions
62
models/actions.js
Normal file
62
models/actions.js
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
Actions = new Mongo.Collection('actions');
|
||||
|
||||
|
||||
|
||||
Actions.mutations({
|
||||
rename(description) {
|
||||
return { $set: { description } };
|
||||
},
|
||||
});
|
||||
|
||||
Actions.allow({
|
||||
update: function () {
|
||||
// add custom authentication code here
|
||||
return true;
|
||||
},
|
||||
insert: function () {
|
||||
// add custom authentication code here
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Actions.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){
|
||||
Actions.insert({actionType: "moveCardToTop"});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -56,6 +56,17 @@ Activities.before.insert((userId, doc) => {
|
|||
doc.createdAt = new Date();
|
||||
});
|
||||
|
||||
|
||||
|
||||
Activities.after.insert((userId, doc) => {
|
||||
const activity = Activities._transform(doc);
|
||||
const matchedTriggers = Triggers.find(activity);
|
||||
if(matchedTriggers.count() > 0){
|
||||
const card = activity.card();
|
||||
Cards.direct.update({_id: card._id},{$set: {title: "ciaooo"}});
|
||||
}
|
||||
});
|
||||
|
||||
if (Meteor.isServer) {
|
||||
// For efficiency create indexes on the date of creation, and on the date of
|
||||
// creation in conjunction with the card or board id, as corresponding views
|
||||
|
|
|
|||
|
|
@ -39,15 +39,3 @@ Rules.allow({
|
|||
},
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
if (Meteor.isServer) {
|
||||
Meteor.startup(() => {
|
||||
const rules = Rules.findOne({});
|
||||
if(!rules){
|
||||
Rules.insert({title: "regola1", description: "bella"});
|
||||
Rules.insert({title: "regola2", description: "bella2"});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,34 +39,7 @@ Triggers.helpers({
|
|||
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