summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2019-03-11 20:26:23 +0200
committerLauri Ojansivu <x@xet7.org>2019-03-11 20:26:23 +0200
commitaee05a549f64cb70a838a4285d0a736d2a3ac819 (patch)
treeb8951e4971942cd9df7e6b6f26d9da7af93bbd69 /models
parent0155c7d8ce5591cab7c9cd4ace2be6cbd741f9a1 (diff)
parent7da2a8a15e2e33a321b21aa926fdcf493e2e0423 (diff)
downloadwekan-aee05a549f64cb70a838a4285d0a736d2a3ac819.tar.gz
wekan-aee05a549f64cb70a838a4285d0a736d2a3ac819.tar.bz2
wekan-aee05a549f64cb70a838a4285d0a736d2a3ac819.zip
v2.44
Merge branch 'edge' into meteor-1.8
Diffstat (limited to 'models')
-rw-r--r--models/cards.js55
-rw-r--r--models/checklistItems.js24
-rw-r--r--models/import.js8
-rw-r--r--models/wekanCreator.js8
4 files changed, 79 insertions, 16 deletions
diff --git a/models/cards.js b/models/cards.js
index 43d2bbfe..c3bae400 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[dotNotation[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) => {
diff --git a/models/checklistItems.js b/models/checklistItems.js
index 30e57aec..c46fe9bd 100644
--- a/models/checklistItems.js
+++ b/models/checklistItems.js
@@ -99,17 +99,6 @@ 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,
- checklistItemName:doc.title,
- });
Activities.remove({
checklistItemId: doc._id,
});
@@ -206,8 +195,19 @@ if (Meteor.isServer) {
itemCreation(userId, doc);
});
- ChecklistItems.after.remove((userId, doc) => {
+ ChecklistItems.before.remove((userId, doc) => {
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,
+ checklistItemName:doc.title,
+ });
});
}
diff --git a/models/import.js b/models/import.js
index 5cdf8dc1..343e1c24 100644
--- a/models/import.js
+++ b/models/import.js
@@ -3,10 +3,10 @@ import { WekanCreator } from './wekanCreator';
Meteor.methods({
importBoard(board, data, importSource, currentBoard) {
- //check(board, Object);
- //check(data, Object);
- //check(importSource, String);
- //check(currentBoard, Match.Maybe(String));
+ check(board, Object);
+ check(data, Object);
+ check(importSource, String);
+ check(currentBoard, Match.Maybe(String));
let creator;
switch (importSource) {
case 'trello':
diff --git a/models/wekanCreator.js b/models/wekanCreator.js
index 2d3ec5de..3a627424 100644
--- a/models/wekanCreator.js
+++ b/models/wekanCreator.js
@@ -298,6 +298,10 @@ export class WekanCreator {
cardToCreate.members = wekanMembers;
}
}
+ // set color
+ if (card.color) {
+ cardToCreate.color = card.color;
+ }
// insert card
const cardId = Cards.direct.insert(cardToCreate);
// keep track of Wekan id => Wekan id
@@ -484,6 +488,10 @@ export class WekanCreator {
title: swimlane.title,
sort: swimlane.sort ? swimlane.sort : swimlaneIndex,
};
+ // set color
+ if (swimlane.color) {
+ swimlaneToCreate.color = swimlane.color;
+ }
const swimlaneId = Swimlanes.direct.insert(swimlaneToCreate);
Swimlanes.direct.update(swimlaneId, {
$set: {