summaryrefslogtreecommitdiffstats
path: root/client/components/import/import.js
diff options
context:
space:
mode:
authorGhassen Rjab <rjab.ghassen@gmail.com>2017-07-08 13:23:33 +0100
committerGhassen Rjab <rjab.ghassen@gmail.com>2017-07-08 13:23:33 +0100
commit3f4c2855513646fbd826d0473b6304dbad1f3b16 (patch)
treecb9ba1943eed0e66989370992e69981bce68eb09 /client/components/import/import.js
parent61b2c91ffed53a616eeab0cee4e8b0c4eb7f764e (diff)
downloadwekan-3f4c2855513646fbd826d0473b6304dbad1f3b16.tar.gz
wekan-3f4c2855513646fbd826d0473b6304dbad1f3b16.tar.bz2
wekan-3f4c2855513646fbd826d0473b6304dbad1f3b16.zip
Add import Wekan board feature
Diffstat (limited to 'client/components/import/import.js')
-rw-r--r--client/components/import/import.js48
1 files changed, 32 insertions, 16 deletions
diff --git a/client/components/import/import.js b/client/components/import/import.js
index 11a5308a..d02637d6 100644
--- a/client/components/import/import.js
+++ b/client/components/import/import.js
@@ -1,3 +1,12 @@
+import trelloMembersMapper from './trelloMembersMapper';
+import wekanMembersMapper from './wekanMembersMapper';
+
+BlazeComponent.extendComponent({
+ title() {
+ return `import-board-title-${Session.get('importSource')}!`;
+ },
+}).register('importHeaderBar');
+
BlazeComponent.extendComponent({
onCreated() {
this.error = new ReactiveVar('');
@@ -5,6 +14,7 @@ BlazeComponent.extendComponent({
this._currentStepIndex = new ReactiveVar(0);
this.importedData = new ReactiveVar();
this.membersToMap = new ReactiveVar([]);
+ this.importSource = Session.get('importSource');
},
currentTemplate() {
@@ -27,7 +37,10 @@ BlazeComponent.extendComponent({
const dataObject = JSON.parse(dataJson);
this.setError('');
this.importedData.set(dataObject);
- this._prepareAdditionalData(dataObject);
+ const membersToMap = this._prepareAdditionalData(dataObject);
+ // store members data and mapping in Session
+ // (we go deep and 2-way, so storing in data context is not a viable option)
+ this.membersToMap.set(membersToMap);
this.nextStep();
} catch (e) {
this.setError('error-json-malformed');
@@ -51,7 +64,10 @@ BlazeComponent.extendComponent({
additionalData.membersMapping = mappingById;
}
this.membersToMap.set([]);
- Meteor.call('importTrelloBoard', this.importedData.get(), additionalData,
+ Meteor.call('importBoard',
+ this.importedData.get(),
+ additionalData,
+ this.importSource,
(err, res) => {
if (err) {
this.setError(err.error);
@@ -63,20 +79,16 @@ BlazeComponent.extendComponent({
},
_prepareAdditionalData(dataObject) {
- // we will work on the list itself (an ordered array of objects) when a
- // mapping is done, we add a 'wekan' field to the object representing the
- // imported member
- const membersToMap = dataObject.members;
- // auto-map based on username
- membersToMap.forEach((importedMember) => {
- const wekanUser = Users.findOne({ username: importedMember.username });
- if (wekanUser) {
- importedMember.wekanId = wekanUser._id;
- }
- });
- // store members data and mapping in Session
- // (we go deep and 2-way, so storing in data context is not a viable option)
- this.membersToMap.set(membersToMap);
+ const importSource = Session.get('importSource');
+ let membersToMap;
+ switch (importSource) {
+ case 'trello':
+ membersToMap = trelloMembersMapper.getMembersToMap(dataObject);
+ break;
+ case 'wekan':
+ membersToMap = wekanMembersMapper.getMembersToMap(dataObject);
+ break;
+ }
return membersToMap;
},
@@ -90,6 +102,10 @@ BlazeComponent.extendComponent({
return 'importTextarea';
},
+ instruction() {
+ return `import-board-instruction-${Session.get('importSource')}!`;
+ },
+
events() {
return [{
submit(evt) {