Import members: board import

This commit is contained in:
Xavier Priour 2015-11-13 19:17:09 +01:00
parent f6f41270de
commit dd0a6e1a82
6 changed files with 48 additions and 15 deletions

View file

@ -12,6 +12,7 @@ babel-runtime@0.1.4
base64@1.0.4
binary-heap@1.0.4
blaze@2.1.3
blaze-html-templates@1.0.1
blaze-tools@1.0.4
boilerplate-generator@1.0.5-cdn-url
caching-compiler@1.0.0
@ -124,7 +125,7 @@ seriousm:emoji-continued@1.4.0
service-configuration@1.0.5
session@1.1.1
sha@1.0.4
softwarerero:accounts-t9n@1.1.4
softwarerero:accounts-t9n@1.1.6
spacebars@1.0.7
spacebars-compiler@1.0.7
srp@1.0.4

View file

@ -8,7 +8,7 @@ template(name="importPopup")
if membersMapping
div
a.show-mapping
| {{_ 'show-mapping'}}
| {{_ 'import-show-user-mapping'}}
input.primary.wide(type="submit" value="{{_ 'import'}}")
template(name="mapMembersPopup")
@ -35,7 +35,8 @@ template(name="mapMembersPopup")
template(name="mapMembersAddPopup")
.select-member
p Hello world
p
| {{_ 'import-user-select'}}
.js-map-member
+esInput(index="users")
ul.pop-over-list

View file

@ -29,13 +29,12 @@ const ImportPopup = BlazeComponent.extendComponent({
},
onShowMapping(evt) {
// todo xxx make it work - currently we don't find the text
// this._storeText(evt);
this._storeText(evt);
Popup.open('mapMembers')(evt);
},
_storeText(evt) {
const dataJson = $(evt.currentTarget).find('.js-import-json').val();
const dataJson = this.$('.js-import-json').val();
Session.set('import.text', dataJson);
return dataJson;
},

View file

@ -1,8 +1,9 @@
.map-members
.mapping:first-of-type
border-top: solid 1px #999
.mapping
margin-bottom: 10px
margin-top: 10px
border-bottom: solid
padding: 10px 0
border-bottom: solid 1px #999
.source
display: inline-block
width: 80%
@ -11,3 +12,6 @@
width: 35px
.member
float: none
a.show-mapping
text-decoration underline

View file

@ -114,6 +114,7 @@
"disambiguateMultiLabelPopup-title": "Disambiguate Label Action",
"disambiguateMultiMemberPopup-title": "Disambiguate Member Action",
"discard": "Discard",
"done": "Done",
"download": "Download",
"edit": "Edit",
"edit-avatar": "Change Avatar",
@ -141,7 +142,9 @@
"import-card": "Import a Trello card",
"import-card-trello-instruction": "Go to a Trello card, select 'Share and more...' then 'Export JSON' and copy the resulting text",
"import-json-placeholder": "Paste your valid JSON data here",
"import-members-map": "Map the Trello members you want to import to Wekan members",
"import-members-map": "Your imported board has some members. Please map the members you want to import to Wekan users",
"import-show-user-mapping": "Review members mapping",
"import-user-select": "Pick the Wekan user you want to use as this member",
"info": "Infos",
"initials": "Initials",
"joined": "joined",

View file

@ -92,6 +92,24 @@ class TrelloCreator {
stars: 0,
title: trelloBoard.name,
};
// now add other members
if(trelloBoard.memberships) {
trelloBoard.memberships.forEach((trelloMembership) => {
const trelloId = trelloMembership.idMember;
// do we have a mapping?
if(this.members[trelloId]) {
const wekanId = this.members[trelloId];
// do we already have it in our list?
if(!boardToCreate.members.find((wekanMember) => {return (wekanMember.userId === wekanId);})) {
boardToCreate.members.push({
userId: wekanId,
isAdmin: false,
isActive: true,
});
}
}
});
}
trelloBoard.labels.forEach((label) => {
const labelToCreate = {
_id: Random.id(6),
@ -197,10 +215,16 @@ class TrelloCreator {
if(card.idMembers) {
const wekanMembers = [];
// we can't just map, as some members may not have been mapped
card.idMembers.forEach((id) => {
if(this.members[id]) {
wekanMembers.push(this.members[id]);
card.idMembers.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(!wekanMembers.find((wId) => {return (wId === wekanId);})){
wekanMembers.push(wekanId);
}
}
return true;
});
if(wekanMembers.length>0) {
cardToCreate.members = wekanMembers;
@ -317,8 +341,9 @@ Meteor.methods({
// 1. check all parameters are ok from a syntax point of view
try {
// we don't use additional data - this should be an empty object
check(data, {});
check(data, {
membersMapping: Match.Optional(Object),
});
trelloCreator.checkActions(trelloBoard.actions);
trelloCreator.checkBoard(trelloBoard);
trelloCreator.checkLabels(trelloBoard.labels);