summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorAngelo Gallarello <angelo.gallarell@gmail.com>2018-08-16 21:49:56 +0200
committerAngelo Gallarello <angelo.gallarell@gmail.com>2018-08-16 21:49:56 +0200
commitcc285afd5939dbc251ac0f5f64116d0dc17592bb (patch)
tree833f802a2f47f9b8eada6623e967342ad32ea7d7 /models
parentf7446ba9346d52431a9d37c8b4c856daf2c73621 (diff)
downloadwekan-cc285afd5939dbc251ac0f5f64116d0dc17592bb.tar.gz
wekan-cc285afd5939dbc251ac0f5f64116d0dc17592bb.tar.bz2
wekan-cc285afd5939dbc251ac0f5f64116d0dc17592bb.zip
Complete checklist activities
Diffstat (limited to 'models')
-rw-r--r--models/checklistItems.js76
-rw-r--r--models/checklists.js9
2 files changed, 85 insertions, 0 deletions
diff --git a/models/checklistItems.js b/models/checklistItems.js
index e075eda2..1378e0f5 100644
--- a/models/checklistItems.js
+++ b/models/checklistItems.js
@@ -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);
});
diff --git a/models/checklists.js b/models/checklists.js
index c58453ef..3f07c858 100644
--- a/models/checklists.js
+++ b/models/checklists.js
@@ -101,6 +101,15 @@ if (Meteor.isServer) {
Activities.remove(activity._id);
});
}
+ Activities.insert({
+ userId,
+ activityType: 'removeChecklist',
+ cardId: doc.cardId,
+ boardId: Cards.findOne(doc.cardId).boardId,
+ checklistId: doc._id,
+ });
+
+
});
}