summaryrefslogtreecommitdiffstats
path: root/client/components/lists/listHeader.js
diff options
context:
space:
mode:
authorXavier Priour <xavier.priour@bubblyware.com>2015-10-14 00:32:44 +0200
committerMaxime Quandalle <maxime@quandalle.com>2015-10-14 23:23:16 +0200
commit1b9df0049259438d001abd9c81f15ce8f7d25b14 (patch)
tree5b94b6375effad4158edd8122e828d712ead6141 /client/components/lists/listHeader.js
parentbc79b83140ec2e120f4050ac78f6f8baa0483137 (diff)
downloadwekan-1b9df0049259438d001abd9c81f15ce8f7d25b14.tar.gz
wekan-1b9df0049259438d001abd9c81f15ce8f7d25b14.tar.bz2
wekan-1b9df0049259438d001abd9c81f15ce8f7d25b14.zip
Import single card: title and proper sort index
Diffstat (limited to 'client/components/lists/listHeader.js')
-rw-r--r--client/components/lists/listHeader.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/client/components/lists/listHeader.js b/client/components/lists/listHeader.js
index 4f5fc3a0..28e7ab89 100644
--- a/client/components/lists/listHeader.js
+++ b/client/components/lists/listHeader.js
@@ -49,6 +49,32 @@ Template.listActionPopup.events({
},
});
+Template.listImportCardPopup.events({
+ submit(evt, template) {
+ // 1. get the json data out of the form and parse it
+ evt.preventDefault();
+ const jsonData = $(evt.currentTarget).find('textarea').val();
+ const data = JSON.parse(jsonData);
+ // 2. map all fields for the card to create
+ const firstCardDom = $(`#js-list-${this._id} .js-minicard:first`).get(0);
+ sortIndex = Utils.calculateIndex(null, firstCardDom).base;
+ const cardToCreate = {
+ title: data.name,
+ listId: this._id,
+ boardId: this.boardId,
+ userId: Meteor.userId(),
+ sort: sortIndex,
+ }
+ // 3. finally, insert new card into list
+ const _id = Cards.insert(cardToCreate);
+ // In case the filter is active we need to add the newly inserted card in
+ // the list of exceptions -- cards that are not filtered. Otherwise the
+ // card will disappear instantly.
+ // See https://github.com/wekan/wekan/issues/80
+ Filter.addException(_id);
+ }
+});
+
Template.listMoveCardsPopup.events({
'click .js-select-list'() {
const fromList = Template.parentData(2).data;