mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 15:30:13 +01:00
code review fixes
This commit is contained in:
parent
ad27a59e57
commit
33193b6f7b
4 changed files with 68 additions and 51 deletions
|
|
@ -1 +1 @@
|
||||||
METEOR@1.2.2-cdn-url
|
METEOR@1.2.1
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ binary-heap@1.0.4
|
||||||
blaze@2.1.3
|
blaze@2.1.3
|
||||||
blaze-html-templates@1.0.1
|
blaze-html-templates@1.0.1
|
||||||
blaze-tools@1.0.4
|
blaze-tools@1.0.4
|
||||||
boilerplate-generator@1.0.5-cdn-url
|
boilerplate-generator@1.0.4
|
||||||
caching-compiler@1.0.0
|
caching-compiler@1.0.0
|
||||||
caching-html-compiler@1.0.2
|
caching-html-compiler@1.0.2
|
||||||
callback-hook@1.0.4
|
callback-hook@1.0.4
|
||||||
|
|
@ -142,6 +142,6 @@ useraccounts:core@1.12.4
|
||||||
useraccounts:flow-routing@1.12.4
|
useraccounts:flow-routing@1.12.4
|
||||||
useraccounts:unstyled@1.12.4
|
useraccounts:unstyled@1.12.4
|
||||||
verron:autosize@3.0.8
|
verron:autosize@3.0.8
|
||||||
webapp@1.2.4-cdn-url
|
webapp@1.2.3
|
||||||
webapp-hashing@1.0.5
|
webapp-hashing@1.0.5
|
||||||
zimme:active-route@2.3.2
|
zimme:active-route@2.3.2
|
||||||
|
|
|
||||||
|
|
@ -33,12 +33,6 @@ const ImportPopup = BlazeComponent.extendComponent({
|
||||||
Popup.open('mapMembers')(evt);
|
Popup.open('mapMembers')(evt);
|
||||||
},
|
},
|
||||||
|
|
||||||
_storeText() {
|
|
||||||
const dataJson = this.$('.js-import-json').val();
|
|
||||||
Session.set('import.text', dataJson);
|
|
||||||
return dataJson;
|
|
||||||
},
|
|
||||||
|
|
||||||
onSubmit(evt){
|
onSubmit(evt){
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
const dataJson = this._storeText(evt);
|
const dataJson = this._storeText(evt);
|
||||||
|
|
@ -50,23 +44,27 @@ const ImportPopup = BlazeComponent.extendComponent({
|
||||||
this.setError('error-json-malformed');
|
this.setError('error-json-malformed');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// if there are members listed in the import and we have no mapping for them...
|
if(this._hasAllNeededData(dataObject)) {
|
||||||
if(dataObject.members.length > 0 && !this.membersMapping()) {
|
this._import(dataObject);
|
||||||
// we will work on the list itself (an ordered array of POJO)
|
|
||||||
// when a mapping is done, we add a 'wekan' field to the POJO 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.wekan = wekanUser;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// store members data and mapping in Session
|
|
||||||
// (we go deep and 2-way, so storing in data context is not a viable option)
|
|
||||||
Session.set('import.membersToMap', membersToMap);
|
|
||||||
Popup.open('mapMembers')(evt);
|
|
||||||
} else {
|
} else {
|
||||||
|
this._prepareAdditionalData(dataObject);
|
||||||
|
Popup.open(this._screenAdditionalData())(evt);
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
events() {
|
||||||
|
return [{
|
||||||
|
submit: this.onSubmit,
|
||||||
|
'click .show-mapping': this.onShowMapping,
|
||||||
|
}];
|
||||||
|
},
|
||||||
|
|
||||||
|
setError(error) {
|
||||||
|
this.error.set(error);
|
||||||
|
},
|
||||||
|
|
||||||
|
_import: function (dataObject) {
|
||||||
const additionalData = this.getAdditionalData();
|
const additionalData = this.getAdditionalData();
|
||||||
const membersMapping = this.membersMapping();
|
const membersMapping = this.membersMapping();
|
||||||
if (membersMapping) {
|
if (membersMapping) {
|
||||||
|
|
@ -91,20 +89,39 @@ const ImportPopup = BlazeComponent.extendComponent({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
_hasAllNeededData(dataObject) {
|
||||||
|
// import has no members or they are already mapped
|
||||||
|
return dataObject.members.length === 0 || this.membersMapping();
|
||||||
|
},
|
||||||
|
|
||||||
|
_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.wekan = wekanUser;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
// store members data and mapping in Session
|
||||||
|
// (we go deep and 2-way, so storing in data context is not a viable option)
|
||||||
|
Session.set('import.membersToMap', membersToMap);
|
||||||
|
return membersToMap;
|
||||||
},
|
},
|
||||||
|
|
||||||
events() {
|
_screenAdditionalData() {
|
||||||
return [{
|
return 'mapMembers';
|
||||||
submit: this.onSubmit,
|
|
||||||
'click .show-mapping': this.onShowMapping,
|
|
||||||
}];
|
|
||||||
},
|
},
|
||||||
|
|
||||||
setError(error) {
|
_storeText() {
|
||||||
this.error.set(error);
|
const dataJson = this.$('.js-import-json').val();
|
||||||
|
Session.set('import.text', dataJson);
|
||||||
|
return dataJson;
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
ImportPopup.extendComponent({
|
ImportPopup.extendComponent({
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ class TrelloCreator {
|
||||||
if(this.members[trelloId]) {
|
if(this.members[trelloId]) {
|
||||||
const wekanId = this.members[trelloId];
|
const wekanId = this.members[trelloId];
|
||||||
// do we already have it in our list?
|
// do we already have it in our list?
|
||||||
if(!boardToCreate.members.find((wekanMember) => {return (wekanMember.userId === wekanId);})) {
|
if(!boardToCreate.members.find((wekanMember) => wekanMember.userId === wekanId)) {
|
||||||
boardToCreate.members.push({
|
boardToCreate.members.push({
|
||||||
userId: wekanId,
|
userId: wekanId,
|
||||||
isAdmin: false,
|
isAdmin: false,
|
||||||
|
|
@ -181,7 +181,7 @@ class TrelloCreator {
|
||||||
const wekanId = this.members[trelloId];
|
const wekanId = this.members[trelloId];
|
||||||
// we may map multiple Trello members to the same wekan user
|
// we may map multiple Trello members to the same wekan user
|
||||||
// in which case we risk adding the same user multiple times
|
// in which case we risk adding the same user multiple times
|
||||||
if(!wekanMembers.find((wId) => {return (wId === wekanId);})){
|
if(!wekanMembers.find((wId) => wId === wekanId)){
|
||||||
wekanMembers.push(wekanId);
|
wekanMembers.push(wekanId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue