mirror of https://github.com/wekan/wekan
The Open Source kanban (built with Meteor). Keep variable/table/field names camelCase. For translations, only add Pull Request changes to wekan/i18n/en.i18n.json , other translations are done at https://transifex.com/wekan/wekan only.
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
2.0 KiB
66 lines
2.0 KiB
import { TrelloCreator } from './trelloCreator';
|
|
import { WekanCreator } from './wekanCreator';
|
|
import { CsvCreator } from './csvCreator';
|
|
import { Exporter } from './exporter';
|
|
import { getMembersToMap } from './wekanmapper';
|
|
|
|
Meteor.methods({
|
|
importBoard(board, data, importSource, currentBoard) {
|
|
check(data, Object);
|
|
check(importSource, String);
|
|
check(currentBoard, Match.Maybe(String));
|
|
let creator;
|
|
switch (importSource) {
|
|
case 'trello':
|
|
check(board, Object);
|
|
creator = new TrelloCreator(data);
|
|
break;
|
|
case 'wekan':
|
|
check(board, Object);
|
|
creator = new WekanCreator(data);
|
|
break;
|
|
case 'csv':
|
|
check(board, Array);
|
|
creator = new CsvCreator(data);
|
|
break;
|
|
}
|
|
|
|
// 1. check all parameters are ok from a syntax point of view
|
|
//creator.check(board);
|
|
|
|
// 2. check parameters are ok from a business point of view (exist &
|
|
// authorized) nothing to check, everyone can import boards in their account
|
|
|
|
// 3. create all elements
|
|
return creator.create(board, currentBoard);
|
|
},
|
|
});
|
|
|
|
Meteor.methods({
|
|
cloneBoard(sourceBoardId, currentBoardId) {
|
|
check(sourceBoardId, String);
|
|
check(currentBoardId, Match.Maybe(String));
|
|
const exporter = new Exporter(sourceBoardId);
|
|
const data = exporter.build();
|
|
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);
|
|
//data.title = `${data.title } - ${ TAPi18n.__('copy-tag')}`;
|
|
data.title = `${data.title}`;
|
|
return creator.create(data, currentBoardId);
|
|
},
|
|
});
|
|
|