summaryrefslogtreecommitdiffstats
path: root/models/import.js
blob: 5e43366905a0812ea11dc2578cc1f87bcebf1e51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { TrelloCreator } from './trelloCreator';
import { WekanCreator } from './wekanCreator';
import {Exporter} from './export';
import wekanMembersMapper from './wekanmapper';

Meteor.methods({
  importBoard(board, data, importSource, currentBoard) {
    check(board, Object);
    check(data, Object);
    check(importSource, String);
    check(currentBoard, Match.Maybe(String));
    let creator;
    switch (importSource) {
    case 'trello':
      creator = new TrelloCreator(data);
      break;
    case 'wekan':
      creator = new WekanCreator(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 addData = {};
    addData.membersMapping = wekanMembersMapper.getMembersToMap(data);
    const creator =  new WekanCreator(addData);
    //data.title = `${data.title  } - ${  TAPi18n.__('copy-tag')}`;
    data.title = `${data.title}`;
    return creator.create(data, currentBoardId);
  },
});