summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2019-03-08 20:51:57 +0200
committerLauri Ojansivu <x@xet7.org>2019-03-08 20:51:57 +0200
commitc5e72d1a2b7326ba21e5e0f01b370d37e59c67f7 (patch)
tree6b410ef99dfdcddd55d0d98ad1de7da873531b71
parent117c9e069ecc5e5fcf52838062b53781bdb59f27 (diff)
parent951a9f81d6d98fda465c7dc724e7554353788956 (diff)
downloadwekan-c5e72d1a2b7326ba21e5e0f01b370d37e59c67f7.tar.gz
wekan-c5e72d1a2b7326ba21e5e0f01b370d37e59c67f7.tar.bz2
wekan-c5e72d1a2b7326ba21e5e0f01b370d37e59c67f7.zip
Merge branch 'edge' of github.com:wekan/wekan into edge
-rw-r--r--client/components/activities/activities.jade6
-rw-r--r--client/components/activities/activities.js18
-rw-r--r--i18n/en.i18n.json2
-rw-r--r--models/cards.js55
4 files changed, 81 insertions, 0 deletions
diff --git a/client/components/activities/activities.jade b/client/components/activities/activities.jade
index bddc4dad..949400f6 100644
--- a/client/components/activities/activities.jade
+++ b/client/components/activities/activities.jade
@@ -114,6 +114,12 @@ template(name="boardActivities")
if($eq activityType 'removedLabel')
| {{{_ '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 user._id member._id)
| {{{_ 'activity-unjoined' cardLink}}}.
diff --git a/client/components/activities/activities.js b/client/components/activities/activities.js
index b3fe8f50..81995221 100644
--- a/client/components/activities/activities.js
+++ b/client/components/activities/activities.js
@@ -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() {
return this.currentData().list().title;
},
diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json
index c4b4b824..580a9456 100644
--- a/i18n/en.i18n.json
+++ b/i18n/en.i18n.json
@@ -567,6 +567,8 @@
"activity-added-label-card": "added label '%s'",
"activity-removed-label-card": "removed label '%s'",
"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-add-trigger": "Add trigger",
"r-add-action": "Add action",
diff --git a/models/cards.js b/models/cards.js
index 43d2bbfe..eef62be1 100644
--- a/models/cards.js
+++ b/models/cards.js
@@ -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) => {