2017-07-08 13:23:33 +01:00
|
|
|
import { TrelloCreator } from './trelloCreator';
|
|
|
|
import { WekanCreator } from './wekanCreator';
|
2020-05-07 01:29:22 +03:00
|
|
|
import { CsvCreator } from './csvCreator';
|
2020-05-10 23:58:15 +03:00
|
|
|
import { Exporter } from './exporter';
|
2020-11-02 16:25:01 +02:00
|
|
|
import { getMembersToMap } from './wekanmapper';
|
2015-10-17 19:29:25 +02:00
|
|
|
|
2015-10-14 17:57:58 +02:00
|
|
|
Meteor.methods({
|
2017-07-24 23:56:51 +01:00
|
|
|
importBoard(board, data, importSource, currentBoard) {
|
2019-03-11 11:42:05 +01:00
|
|
|
check(data, Object);
|
|
|
|
check(importSource, String);
|
|
|
|
check(currentBoard, Match.Maybe(String));
|
2017-07-08 13:23:33 +01:00
|
|
|
let creator;
|
|
|
|
switch (importSource) {
|
2019-06-28 12:52:09 -05:00
|
|
|
case 'trello':
|
2020-05-07 01:29:22 +03:00
|
|
|
check(board, Object);
|
2019-06-28 12:52:09 -05:00
|
|
|
creator = new TrelloCreator(data);
|
|
|
|
break;
|
|
|
|
case 'wekan':
|
2020-05-07 01:29:22 +03:00
|
|
|
check(board, Object);
|
2019-06-28 12:52:09 -05:00
|
|
|
creator = new WekanCreator(data);
|
|
|
|
break;
|
2020-05-07 01:29:22 +03:00
|
|
|
case 'csv':
|
|
|
|
check(board, Array);
|
|
|
|
creator = new CsvCreator(data);
|
|
|
|
break;
|
2017-07-08 13:23:33 +01:00
|
|
|
}
|
2015-10-19 20:14:29 +02:00
|
|
|
|
2015-10-19 12:41:56 +02:00
|
|
|
// 1. check all parameters are ok from a syntax point of view
|
2018-11-08 22:49:08 +02:00
|
|
|
//creator.check(board);
|
2015-10-14 17:57:58 +02:00
|
|
|
|
2015-10-20 20:02:12 +02:00
|
|
|
// 2. check parameters are ok from a business point of view (exist &
|
|
|
|
// authorized) nothing to check, everyone can import boards in their account
|
2015-10-19 20:14:29 +02:00
|
|
|
|
2015-10-19 00:59:50 +02:00
|
|
|
// 3. create all elements
|
2017-07-24 23:56:51 +01:00
|
|
|
return creator.create(board, currentBoard);
|
2015-10-19 00:59:50 +02:00
|
|
|
},
|
2015-10-14 17:57:58 +02:00
|
|
|
});
|
2019-02-12 23:40:12 +01:00
|
|
|
|
|
|
|
Meteor.methods({
|
2019-04-06 09:00:13 +03:00
|
|
|
cloneBoard(sourceBoardId, currentBoardId) {
|
2019-02-12 23:40:12 +01:00
|
|
|
check(sourceBoardId, String);
|
|
|
|
check(currentBoardId, Match.Maybe(String));
|
|
|
|
const exporter = new Exporter(sourceBoardId);
|
2019-04-06 09:00:13 +03:00
|
|
|
const data = exporter.build();
|
2020-12-09 15:02:50 +02:00
|
|
|
const additionalData = {};
|
|
|
|
|
|
|
|
//get the members to map
|
|
|
|
const membersMapping = getMembersToMap(data);
|
|
|
|
|
|
|
|
//now mirror the mapping done in finishImport in client/components/import/import.js:
|
|
|
|
if (membersMapping) {
|
|
|
|
const mappingById = {};
|
|
|
|
membersMapping.forEach(member => {
|
|
|
|
if (member.wekanId) {
|
|
|
|
mappingById[member.id] = member.wekanId;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
additionalData.membersMapping = mappingById;
|
|
|
|
}
|
|
|
|
|
|
|
|
const creator = new WekanCreator(additionalData);
|
2019-04-06 13:47:15 +03:00
|
|
|
//data.title = `${data.title } - ${ TAPi18n.__('copy-tag')}`;
|
|
|
|
data.title = `${data.title}`;
|
2019-02-12 23:40:12 +01:00
|
|
|
return creator.create(data, currentBoardId);
|
|
|
|
},
|
|
|
|
});
|