mirror of
https://github.com/wekan/wekan.git
synced 2025-04-22 04:57:07 -04:00
Complete checklist activities
This commit is contained in:
parent
f7446ba934
commit
cc285afd59
6 changed files with 124 additions and 0 deletions
|
@ -34,12 +34,30 @@ template(name="boardActivities")
|
|||
.activity-checklist(href="{{ card.absoluteUrl }}")
|
||||
+viewer
|
||||
= checklist.title
|
||||
if($eq activityType 'removeChecklist')
|
||||
| {{{_ 'activity-checklist-removed' cardLink}}}
|
||||
|
||||
if($eq activityType 'checkedItem')
|
||||
| {{{_ 'activity-checked-item' checkItem checklist.title cardLink}}}
|
||||
|
||||
if($eq activityType 'uncheckedItem')
|
||||
| {{{_ 'activity-unchecked-item' checkItem checklist.title cardLink}}}
|
||||
|
||||
if($eq activityType 'checklistCompleted')
|
||||
| {{{_ 'activity-checklist-completed' checklist.title cardLink}}}
|
||||
|
||||
if($eq activityType 'checklistUncompleted')
|
||||
| {{{_ 'activity-checklist-uncompleted' checklist.title cardLink}}}
|
||||
|
||||
|
||||
|
||||
if($eq activityType 'addChecklistItem')
|
||||
| {{{_ 'activity-checklist-item-added' checklist.title cardLink}}}.
|
||||
.activity-checklist(href="{{ card.absoluteUrl }}")
|
||||
+viewer
|
||||
= checklistItem.title
|
||||
if($eq activityType 'removedChecklistItem')
|
||||
| {{{_ 'activity-checklist-item-removed' checklist.title cardLink}}}
|
||||
|
||||
if($eq activityType 'archivedCard')
|
||||
| {{{_ 'activity-archived' cardLink}}}.
|
||||
|
|
|
@ -41,6 +41,12 @@ BlazeComponent.extendComponent({
|
|||
this.loadNextPageLocked = true;
|
||||
}
|
||||
},
|
||||
|
||||
checkItem(){
|
||||
const checkItemId = this.currentData().checklistItemId;
|
||||
const checkItem = ChecklistItems.findOne({_id:checkItemId});
|
||||
return checkItem.title;
|
||||
},
|
||||
|
||||
boardLabel() {
|
||||
return TAPi18n.__('this-board');
|
||||
|
|
|
@ -43,8 +43,14 @@
|
|||
"activity-sent": "sent %s to %s",
|
||||
"activity-unjoined": "unjoined %s",
|
||||
"activity-subtask-added": "added subtask to %s",
|
||||
"activity-checked-item": "checked %s in checklist %s of %s",
|
||||
"activity-unchecked-item": "unchecked %s in checklist %s of %s",
|
||||
"activity-checklist-added": "added checklist to %s",
|
||||
"activity-checklist-removed": "removed a checklist from %s",
|
||||
"activity-checklist-completed": "completed the checklist %s of %s",
|
||||
"activity-checklist-uncompleted": "uncompleted the checklist %s of %s",
|
||||
"activity-checklist-item-added": "added checklist item to '%s' in %s",
|
||||
"activity-checklist-item-removed": "removed a checklist item from '%s' in %s",
|
||||
"add": "Add",
|
||||
"add-attachment": "Add Attachment",
|
||||
"add-board": "Add Board",
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -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,
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -20,9 +20,18 @@ TriggersDef = {
|
|||
addChecklist:{
|
||||
matchingFields: ["boardId","checklistId"]
|
||||
},
|
||||
removeChecklist:{
|
||||
matchingFields: ["boardId","checklistId"]
|
||||
},
|
||||
addChecklistItem:{
|
||||
matchingFields: ["boardId","checklistItemId"]
|
||||
},
|
||||
checkedItem:{
|
||||
matchingFields: ["boardId","checklistId"]
|
||||
},
|
||||
uncheckedItem:{
|
||||
matchingFields: ["boardId","checklistItemId"]
|
||||
},
|
||||
addAttachment:{
|
||||
matchingFields: ["boardId","checklistId"]
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue