From e661d03e8d7ea8c1d2190de2c7c59eaf0700534b Mon Sep 17 00:00:00 2001 From: Nico Date: Thu, 9 Apr 2020 02:00:15 +0200 Subject: Add vote import from Trello --- models/trelloCreator.js | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'models/trelloCreator.js') diff --git a/models/trelloCreator.js b/models/trelloCreator.js index cb1a6a67..48dce7eb 100644 --- a/models/trelloCreator.js +++ b/models/trelloCreator.js @@ -1,4 +1,4 @@ -const DateString = Match.Where(function(dateAsString) { +const DateString = Match.Where(function (dateAsString) { check(dateAsString, String); return moment(dateAsString, moment.ISO_8601).isValid(); }); @@ -285,6 +285,29 @@ export class TrelloCreator { cardToCreate.members = wekanMembers; } } + // add vote + if (card.idMembersVoted) { + // Trello only know's positive votes + const positiveVotes = []; + card.idMembersVoted.forEach(trelloId => { + if (this.members[trelloId]) { + const wekanId = this.members[trelloId]; + // we may map multiple Trello members to the same wekan user + // in which case we risk adding the same user multiple times + if (!positiveVotes.find(wId => wId === wekanId)) { + positiveVotes.push(wekanId); + } + } + return true; + }) + if (positiveVotes.length > 0) { + cardToCreate.vote = { + question: cardToCreate.title, + positive: positiveVotes, + } + } + } + // insert card const cardId = Cards.direct.insert(cardToCreate); // keep track of Trello id => Wekan id @@ -345,7 +368,7 @@ export class TrelloCreator { // so we make it server only, and let UI catch up once it is done, forget about latency comp. const self = this; if (Meteor.isServer) { - file.attachData(att.url, function(error) { + file.attachData(att.url, function (error) { file.boardId = boardId; file.cardId = cardId; file.userId = self._user(att.idMemberCreator); -- cgit v1.2.3-1-g7c22 From 8f28a409c7dd90319f785e3fc4c1b26803f67f31 Mon Sep 17 00:00:00 2001 From: Nico Date: Fri, 10 Apr 2020 01:46:36 +0200 Subject: Public vote --- models/trelloCreator.js | 1 + 1 file changed, 1 insertion(+) (limited to 'models/trelloCreator.js') diff --git a/models/trelloCreator.js b/models/trelloCreator.js index 48dce7eb..28982f43 100644 --- a/models/trelloCreator.js +++ b/models/trelloCreator.js @@ -303,6 +303,7 @@ export class TrelloCreator { if (positiveVotes.length > 0) { cardToCreate.vote = { question: cardToCreate.title, + public: true, positive: positiveVotes, } } -- cgit v1.2.3-1-g7c22 From 9e95c06415e614e587d684ff9660cc53c5f8c8d3 Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Wed, 22 Apr 2020 21:00:31 +0300 Subject: Fix lint errors in lint error fix. Thanks to xet7 ! --- models/trelloCreator.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'models/trelloCreator.js') diff --git a/models/trelloCreator.js b/models/trelloCreator.js index 28982f43..1c5bcd93 100644 --- a/models/trelloCreator.js +++ b/models/trelloCreator.js @@ -1,4 +1,4 @@ -const DateString = Match.Where(function (dateAsString) { +const DateString = Match.Where(function(dateAsString) { check(dateAsString, String); return moment(dateAsString, moment.ISO_8601).isValid(); }); @@ -299,13 +299,13 @@ export class TrelloCreator { } } return true; - }) + }); if (positiveVotes.length > 0) { cardToCreate.vote = { question: cardToCreate.title, public: true, positive: positiveVotes, - } + }; } } @@ -369,7 +369,7 @@ export class TrelloCreator { // so we make it server only, and let UI catch up once it is done, forget about latency comp. const self = this; if (Meteor.isServer) { - file.attachData(att.url, function (error) { + file.attachData(att.url, function(error) { file.boardId = boardId; file.cardId = cardId; file.userId = self._user(att.idMemberCreator); -- cgit v1.2.3-1-g7c22