mirror of
https://github.com/wekan/wekan.git
synced 2026-02-06 00:21:48 +01:00
Activities: register customFields changed in the activities
This stores the updates to the custom fields in the activities side bar. Only manual updates to the custom fields are currently registered.
This commit is contained in:
parent
7836ab83d0
commit
6d6bb8fc57
4 changed files with 81 additions and 0 deletions
|
|
@ -1400,6 +1400,56 @@ function cardLabels(userId, doc, fieldNames, modifier) {
|
|||
}
|
||||
}
|
||||
|
||||
function cardCustomFields(userId, doc, fieldNames, modifier) {
|
||||
if (!_.contains(fieldNames, 'customFields'))
|
||||
return;
|
||||
|
||||
// Say hello to the new customField value
|
||||
if (modifier.$set) {
|
||||
_.each(modifier.$set, (value, key) => {
|
||||
if (key.startsWith('customFields')) {
|
||||
const dotNotation = key.split('.');
|
||||
|
||||
// only individual changes are registered
|
||||
if (dotNotation.length > 1) {
|
||||
const customFieldId = doc.customFields[dot_notation[1]]._id;
|
||||
const act = {
|
||||
userId,
|
||||
customFieldId,
|
||||
value,
|
||||
activityType: 'setCustomField',
|
||||
boardId: doc.boardId,
|
||||
cardId: doc._id,
|
||||
};
|
||||
Activities.insert(act);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Say goodbye to the former customField value
|
||||
if (modifier.$unset) {
|
||||
_.each(modifier.$unset, (value, key) => {
|
||||
if (key.startsWith('customFields')) {
|
||||
const dotNotation = key.split('.');
|
||||
|
||||
// only individual changes are registered
|
||||
if (dotNotation.length > 1) {
|
||||
const customFieldId = doc.customFields[dot_notation[1]]._id;
|
||||
const act = {
|
||||
userId,
|
||||
customFieldId,
|
||||
activityType: 'unsetCustomField',
|
||||
boardId: doc.boardId,
|
||||
cardId: doc._id,
|
||||
};
|
||||
Activities.insert(act);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function cardCreation(userId, doc) {
|
||||
Activities.insert({
|
||||
userId,
|
||||
|
|
@ -1471,6 +1521,11 @@ if (Meteor.isServer) {
|
|||
cardLabels(userId, doc, fieldNames, modifier);
|
||||
});
|
||||
|
||||
// Add a new activity if we edit a custom field
|
||||
Cards.before.update((userId, doc, fieldNames, modifier) => {
|
||||
cardCustomFields(userId, doc, fieldNames, modifier);
|
||||
});
|
||||
|
||||
// Remove all activities associated with a card if we remove the card
|
||||
// Remove also card_comments / checklists / attachments
|
||||
Cards.after.remove((userId, doc) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue