mirror of
https://github.com/wekan/wekan.git
synced 2025-12-18 00:10:13 +01:00
Merge pull request #2239 from bentiss/customFields-activities
Activities: register customFields changes in the activities
This commit is contained in:
commit
951a9f81d6
4 changed files with 81 additions and 0 deletions
|
|
@ -114,6 +114,12 @@ template(name="boardActivities")
|
||||||
if($eq activityType 'removedLabel')
|
if($eq activityType 'removedLabel')
|
||||||
| {{{_ 'activity-removed-label' lastLabel cardLink}}}.
|
| {{{_ 'activity-removed-label' lastLabel cardLink}}}.
|
||||||
|
|
||||||
|
if($eq activityType 'setCustomField')
|
||||||
|
| {{{_ 'activity-set-customfield' lastCustomField lastCustomFieldValue cardLink}}}.
|
||||||
|
|
||||||
|
if($eq activityType 'unsetCustomField')
|
||||||
|
| {{{_ 'activity-unset-customfield' lastCustomField cardLink}}}.
|
||||||
|
|
||||||
if($eq activityType 'unjoinMember')
|
if($eq activityType 'unjoinMember')
|
||||||
if($eq user._id member._id)
|
if($eq user._id member._id)
|
||||||
| {{{_ 'activity-unjoined' cardLink}}}.
|
| {{{_ 'activity-unjoined' cardLink}}}.
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,24 @@ BlazeComponent.extendComponent({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
lastCustomField(){
|
||||||
|
const lastCustomField = CustomFields.findOne(this.currentData().customFieldId);
|
||||||
|
return lastCustomField.name;
|
||||||
|
},
|
||||||
|
|
||||||
|
lastCustomFieldValue(){
|
||||||
|
const lastCustomField = CustomFields.findOne(this.currentData().customFieldId);
|
||||||
|
const value = this.currentData().value;
|
||||||
|
if (lastCustomField.settings.dropdownItems && lastCustomField.settings.dropdownItems.length > 0) {
|
||||||
|
const dropDownValue = _.find(lastCustomField.settings.dropdownItems, (item) => {
|
||||||
|
return item._id === value;
|
||||||
|
});
|
||||||
|
if (dropDownValue)
|
||||||
|
return dropDownValue.name;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
},
|
||||||
|
|
||||||
listLabel() {
|
listLabel() {
|
||||||
return this.currentData().list().title;
|
return this.currentData().list().title;
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -567,6 +567,8 @@
|
||||||
"activity-added-label-card": "added label '%s'",
|
"activity-added-label-card": "added label '%s'",
|
||||||
"activity-removed-label-card": "removed label '%s'",
|
"activity-removed-label-card": "removed label '%s'",
|
||||||
"activity-delete-attach-card": "deleted an attachment",
|
"activity-delete-attach-card": "deleted an attachment",
|
||||||
|
"activity-set-customfield": "set custom field '%s' to '%s' in %s",
|
||||||
|
"activity-unset-customfield": "unset custom field '%s' in %s",
|
||||||
"r-rule": "Rule",
|
"r-rule": "Rule",
|
||||||
"r-add-trigger": "Add trigger",
|
"r-add-trigger": "Add trigger",
|
||||||
"r-add-action": "Add action",
|
"r-add-action": "Add action",
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
function cardCreation(userId, doc) {
|
||||||
Activities.insert({
|
Activities.insert({
|
||||||
userId,
|
userId,
|
||||||
|
|
@ -1471,6 +1521,11 @@ if (Meteor.isServer) {
|
||||||
cardLabels(userId, doc, fieldNames, modifier);
|
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 all activities associated with a card if we remove the card
|
||||||
// Remove also card_comments / checklists / attachments
|
// Remove also card_comments / checklists / attachments
|
||||||
Cards.after.remove((userId, doc) => {
|
Cards.after.remove((userId, doc) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue