mirror of
https://github.com/wekan/wekan.git
synced 2026-01-06 17:48:49 +01:00
Complete checklist activities
This commit is contained in:
parent
f7446ba934
commit
cc285afd59
6 changed files with 124 additions and 0 deletions
|
|
@ -74,17 +74,93 @@ function itemCreation(userId, doc) {
|
|||
}
|
||||
|
||||
function itemRemover(userId, doc) {
|
||||
const card = Cards.findOne(doc.cardId);
|
||||
const boardId = card.boardId;
|
||||
Activities.insert({
|
||||
userId,
|
||||
activityType: 'removedChecklistItem',
|
||||
cardId: doc.cardId,
|
||||
boardId,
|
||||
checklistId: doc.checklistId,
|
||||
checklistItemId: doc._id,
|
||||
});
|
||||
Activities.remove({
|
||||
checklistItemId: doc._id,
|
||||
});
|
||||
}
|
||||
|
||||
function publishCheckActivity(userId,doc){
|
||||
const card = Cards.findOne(doc.cardId);
|
||||
const boardId = card.boardId;
|
||||
let activityType;
|
||||
if(doc.isFinished){
|
||||
activityType = "checkedItem";
|
||||
}else{
|
||||
activityType = "uncheckedItem";
|
||||
}
|
||||
let act = {
|
||||
userId,
|
||||
activityType: activityType,
|
||||
cardId: doc.cardId,
|
||||
boardId,
|
||||
checklistId: doc.checklistId,
|
||||
checklistItemId: doc._id,
|
||||
}
|
||||
console.log(act);
|
||||
Activities.insert(act);
|
||||
}
|
||||
|
||||
function publishChekListCompleted(userId,doc,fieldNames,modifier){
|
||||
const card = Cards.findOne(doc.cardId);
|
||||
const boardId = card.boardId;
|
||||
const checklistId = doc.checklistId;
|
||||
const checkList = Checklists.findOne({_id:checklistId});
|
||||
if(checkList.isFinished()){
|
||||
let act = {
|
||||
userId,
|
||||
activityType: "checklistCompleted",
|
||||
cardId: doc.cardId,
|
||||
boardId,
|
||||
checklistId: doc.checklistId,
|
||||
}
|
||||
Activities.insert(act);
|
||||
}
|
||||
}
|
||||
|
||||
function publishChekListUncompleted(userId,doc,fieldNames,modifier){
|
||||
const card = Cards.findOne(doc.cardId);
|
||||
const boardId = card.boardId;
|
||||
const checklistId = doc.checklistId;
|
||||
const checkList = Checklists.findOne({_id:checklistId});
|
||||
if(checkList.isFinished()){
|
||||
let act = {
|
||||
userId,
|
||||
activityType: "checklistUncompleted",
|
||||
cardId: doc.cardId,
|
||||
boardId,
|
||||
checklistId: doc.checklistId,
|
||||
}
|
||||
Activities.insert(act);
|
||||
}
|
||||
}
|
||||
|
||||
// Activities
|
||||
if (Meteor.isServer) {
|
||||
Meteor.startup(() => {
|
||||
ChecklistItems._collection._ensureIndex({ checklistId: 1 });
|
||||
});
|
||||
|
||||
ChecklistItems.after.update((userId, doc, fieldNames, modifier) => {
|
||||
publishCheckActivity(userId,doc);
|
||||
publishChekListCompleted(userId,doc,fieldNames,modifier)
|
||||
});
|
||||
|
||||
ChecklistItems.before.update((userId, doc, fieldNames, modifier) => {
|
||||
publishChekListUncompleted(userId,doc,fieldNames,modifier)
|
||||
});
|
||||
|
||||
|
||||
|
||||
ChecklistItems.after.insert((userId, doc) => {
|
||||
itemCreation(userId, doc);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue