Merge branch 'xavierpriour-devel' into devel

Conflicts:
	models/import.js
This commit is contained in:
Maxime Quandalle 2015-10-20 20:06:26 +02:00
commit 7a5f030cc8
13 changed files with 526 additions and 199 deletions

View file

@ -14,56 +14,62 @@ template(name="boardActivities")
p.activity-desc
+memberName(user=user)
if($eq activityType 'createBoard')
| {{_ 'activity-created' boardLabel}}.
if($eq activityType 'createList')
| {{_ 'activity-added' list.title boardLabel}}.
if($eq activityType 'archivedList')
| {{_ 'activity-archived' list.title}}.
if($eq activityType 'createCard')
| {{{_ 'activity-added' cardLink boardLabel}}}.
if($eq activityType 'importCard')
| {{{_ 'activity-imported' cardLink boardLabel sourceLink}}}.
if($eq activityType 'archivedCard')
| {{{_ 'activity-archived' cardLink}}}.
if($eq activityType 'restoredCard')
| {{{_ 'activity-sent' cardLink boardLabel}}}.
if($eq activityType 'moveCard')
| {{{_ 'activity-moved' cardLink oldList.title list.title}}}.
if($eq activityType 'addAttachment')
| {{{_ 'activity-attached' attachmentLink cardLink}}}.
if($eq activityType 'addBoardMember')
| {{{_ 'activity-added' memberLink boardLabel}}}.
if($eq activityType 'removeBoardMember')
| {{{_ 'activity-excluded' memberLink boardLabel}}}.
if($eq activityType 'joinMember')
if($eq currentUser._id member._id)
| {{{_ 'activity-joined' cardLink}}}.
else
| {{{_ 'activity-added' memberLink cardLink}}}.
if($eq activityType 'unjoinMember')
if($eq currentUser._id member._id)
| {{{_ 'activity-unjoined' cardLink}}}.
else
| {{{_ 'activity-removed' memberLink cardLink}}}.
if($eq activityType 'addComment')
| {{{_ 'activity-on' cardLink}}}
a.activity-comment(href="{{ card.absoluteUrl }}")
+viewer
= comment.text
if($eq activityType 'addAttachment')
| {{{_ 'activity-attached' attachmentLink cardLink}}}.
if($eq activityType 'archivedCard')
| {{{_ 'activity-archived' cardLink}}}.
if($eq activityType 'archivedList')
| {{_ 'activity-archived' list.title}}.
if($eq activityType 'createBoard')
| {{_ 'activity-created' boardLabel}}.
if($eq activityType 'createCard')
| {{{_ 'activity-added' cardLink boardLabel}}}.
if($eq activityType 'createList')
| {{_ 'activity-added' list.title boardLabel}}.
if($eq activityType 'importBoard')
| {{{_ 'activity-imported-board' boardLabel sourceLink}}}.
if($eq activityType 'importCard')
| {{{_ 'activity-imported' cardLink boardLabel sourceLink}}}.
if($eq activityType 'importList')
| {{{_ 'activity-imported' listLabel boardLabel sourceLink}}}.
if($eq activityType 'joinMember')
if($eq currentUser._id member._id)
| {{{_ 'activity-joined' cardLink}}}.
else
| {{{_ 'activity-added' memberLink cardLink}}}.
if($eq activityType 'moveCard')
| {{{_ 'activity-moved' cardLink oldList.title list.title}}}.
if($eq activityType 'removeBoardMember')
| {{{_ 'activity-excluded' memberLink boardLabel}}}.
if($eq activityType 'restoredCard')
| {{{_ 'activity-sent' cardLink boardLabel}}}.
if($eq activityType 'unjoinMember')
if($eq currentUser._id member._id)
| {{{_ 'activity-unjoined' cardLink}}}.
else
| {{{_ 'activity-removed' memberLink cardLink}}}.
span.activity-meta {{ moment createdAt }}

View file

@ -60,11 +60,22 @@ BlazeComponent.extendComponent({
}, card.title));
},
listLabel() {
return this.currentData().list().title;
},
sourceLink() {
const source = this.currentData().source;
return source && Blaze.toHTML(HTML.A({
href: source.url,
}, source.system));
if(source) {
if(source.url) {
return Blaze.toHTML(HTML.A({
href: source.url,
}, source.system));
} else {
return source.system;
}
}
return null;
},
memberLink() {

View file

@ -107,6 +107,9 @@ template(name="createBoardPopup")
| {{{_ 'board-private-info'}}}
a.js-change-visibility {{_ 'change'}}.
input.primary.wide(type="submit" value="{{_ 'create'}}")
span.quiet
| {{_ 'or'}}
a.js-import {{_ 'import-board'}}
template(name="boardChangeTitlePopup")

View file

@ -145,6 +145,7 @@ BlazeComponent.extendComponent({
this.setVisibility(this.currentData());
},
'click .js-change-visibility': this.toggleVisibilityMenu,
'click .js-import': Popup.open('boardImportBoard'),
submit: this.onSubmit,
}];
},

View file

@ -0,0 +1,2 @@
a.js-import
text-decoration underline

View file

@ -0,0 +1,7 @@
template(name="importPopup")
if error.get
.warning {{_ error.get}}
form
p: label(for='import-textarea') {{_ getLabel}}
textarea#import-textarea.js-import-json(placeholder="{{_ 'import-json-placeholder'}}" autofocus)
input.primary.wide(type="submit" value="{{_ 'import'}}")

View file

@ -0,0 +1,90 @@
/// Abstract root for all import popup screens.
/// Descendants must define:
/// - getMethodName(): return the Meteor method to call for import, passing json
/// data decoded as object and additional data (see below);
/// - getAdditionalData(): return object containing additional data passed to
/// Meteor method (like list ID and position for a card import);
/// - getLabel(): i18n key for the text displayed in the popup, usually to
/// explain how to get the data out of the source system.
const ImportPopup = BlazeComponent.extendComponent({
template() {
return 'importPopup';
},
events() {
return [{
'submit': (evt) => {
evt.preventDefault();
const dataJson = $(evt.currentTarget).find('.js-import-json').val();
let dataObject;
try {
dataObject = JSON.parse(dataJson);
} catch (e) {
this.setError('error-json-malformed');
return;
}
Meteor.call(this.getMethodName(), dataObject, this.getAdditionalData(),
(error, response) => {
if (error) {
this.setError(error.error);
} else {
Filter.addException(response);
this.onFinish(response);
}
}
);
},
}];
},
onCreated() {
this.error = new ReactiveVar('');
},
setError(error) {
this.error.set(error);
},
onFinish() {
Popup.close();
},
});
ImportPopup.extendComponent({
getAdditionalData() {
const listId = this.data()._id;
const selector = `#js-list-${this.currentData()._id} .js-minicard:first`;
const firstCardDom = $(selector).get(0);
const sortIndex = Utils.calculateIndex(null, firstCardDom).base;
const result = {listId, sortIndex};
return result;
},
getMethodName() {
return 'importTrelloCard';
},
getLabel() {
return 'import-card-trello-instruction';
},
}).register('listImportCardPopup');
ImportPopup.extendComponent({
getAdditionalData() {
const result = {};
return result;
},
getMethodName() {
return 'importTrelloBoard';
},
getLabel() {
return 'import-board-trello-instruction';
},
onFinish(response) {
Utils.goBoardId(response);
},
}).register('boardImportBoardPopup');

View file

@ -31,15 +31,6 @@ template(name="listActionPopup")
template(name="listMoveCardsPopup")
+boardLists
template(name="listImportCardPopup")
if error.get
.warning {{_ error.get}}
form
label
| {{_ 'card-json'}}
textarea.js-card-json(placeholder="{{_ 'card-json-placeholder'}}" autofocus)
input.primary.wide(type="submit" value="{{_ 'import'}}")
template(name="boardLists")
ul.pop-over-list
each currentBoard.lists

View file

@ -49,45 +49,6 @@ Template.listActionPopup.events({
},
});
BlazeComponent.extendComponent({
events() {
return [{
'submit': (evt) => {
evt.preventDefault();
const jsonData = $(evt.currentTarget).find('textarea').val();
const firstCardDom = $(`#js-list-${this.currentData()._id} .js-minicard:first`).get(0);
const sortIndex = Utils.calculateIndex(null, firstCardDom).base;
let trelloCard;
try {
trelloCard = JSON.parse(jsonData);
} catch (e) {
this.setError('error-json-malformed');
return;
}
Meteor.call('importTrelloCard', trelloCard, this.currentData()._id, sortIndex,
(error, response) => {
if (error) {
this.setError(error.error);
} else {
Filter.addException(response);
Popup.close();
}
}
);
},
}];
},
onCreated() {
this.error = new ReactiveVar('');
},
setError(error) {
this.error.set(error);
},
}).register('listImportCardPopup');
Template.listMoveCardsPopup.events({
'click .js-select-list'() {
const fromList = Template.parentData(2).data;

View file

@ -17,9 +17,11 @@ $popupWidth = 300px
margin: 4px -10px
width: $popupWidth
p,
textarea,
input[type="text"],
input[type="email"],
input[type="password"]
input[type="password"],
input[type="file"]
margin: 4px 0 12px
width: 100%
@ -30,8 +32,6 @@ $popupWidth = 300px
textarea
height: 72px
margin: 4px 0 12px
width: 100%
.header
height: 36px