summaryrefslogtreecommitdiffstats
path: root/client/components/lists/listBody.js
diff options
context:
space:
mode:
authorAndrés Manelli <andresmanelli@gmail.com>2019-02-23 20:41:36 +0100
committerAndrés Manelli <andresmanelli@gmail.com>2019-02-24 00:05:00 +0100
commitf888cfd565b197903c24a07221f6a6a44e1b6223 (patch)
tree7745b9c3913ae62f2bc08fb0a1049ec9754f2d4d /client/components/lists/listBody.js
parent044126188d28a24b0df5d67cf69d081ce7790886 (diff)
downloadwekan-f888cfd565b197903c24a07221f6a6a44e1b6223.tar.gz
wekan-f888cfd565b197903c24a07221f6a6a44e1b6223.tar.bz2
wekan-f888cfd565b197903c24a07221f6a6a44e1b6223.zip
Allow list creation from template
Diffstat (limited to 'client/components/lists/listBody.js')
-rw-r--r--client/components/lists/listBody.js62
1 files changed, 43 insertions, 19 deletions
diff --git a/client/components/lists/listBody.js b/client/components/lists/listBody.js
index e84874bb..ad34efef 100644
--- a/client/components/lists/listBody.js
+++ b/client/components/lists/listBody.js
@@ -524,7 +524,10 @@ BlazeComponent.extendComponent({
},
onCreated() {
- this.isTemplateSearch = $(Popup._getTopStack().openerElement).hasClass('js-search-template');
+ this.isCardTemplateSearch = $(Popup._getTopStack().openerElement).hasClass('js-card-template');
+ this.isListTemplateSearch = $(Popup._getTopStack().openerElement).hasClass('js-list-template');
+ this.isSwimlaneTemplateSearch = $(Popup._getTopStack().openerElement).hasClass('js-swimlane-template');
+ this.isTemplateSearch = this.isCardTemplateSearch || this.isListTemplateSearch || this.isSwimlaneTemplateSearch;
let board = {};
if (this.isTemplateSearch) {
board = Boards.findOne(Meteor.user().profile.templatesBoardId);
@@ -579,7 +582,15 @@ BlazeComponent.extendComponent({
return [];
}
const board = Boards.findOne(this.selectedBoardId.get());
- return board.searchCards(this.term.get(), false);
+ if (!this.isTemplateSearch || this.isCardTemplateSearch) {
+ return board.searchCards(this.term.get(), false);
+ } else if (this.isListTemplateSearch) {
+ return board.searchLists(this.term.get());
+ } else if (this.isSwimlaneTemplateSearch) {
+ return board.searchSwimlanes(this.term.get());
+ } else {
+ return [];
+ }
},
events() {
@@ -593,25 +604,38 @@ BlazeComponent.extendComponent({
this.term.set(evt.target.searchTerm.value);
},
'click .js-minicard'(evt) {
- let card = Blaze.getData(evt.currentTarget);
+ // 0. Common
+ let element = Blaze.getData(evt.currentTarget);
+ console.log(element);
+ element.boardId = this.boardId;
let _id = '';
- // Common
- card.listId = this.listId;
- card.swimlaneId = this.swimlaneId;
- card.boardId = this.boardId;
- card.sort = Lists.findOne(this.listId).cards().count();
- // From template
- if (this.isTemplateSearch) {
- card.type = 'cardType-card';
- card.linkedId = '';
- _id = card.copy();
- } else { // Linked
- card._id = null;
- card.type = 'cardType-linkedCard';
- card.linkedId = card.linkedId || card._id;
- _id = Cards.insert(card);
+ if (!this.isTemplateSearch || this.isCardTemplateSearch) {
+ // Card insertion
+ // 1. Common
+ element.listId = this.listId;
+ element.swimlaneId = this.swimlaneId;
+ element.sort = Lists.findOne(this.listId).cards().count();
+ // 1.A From template
+ if (this.isTemplateSearch) {
+ element.type = 'cardType-card';
+ element.linkedId = '';
+ _id = element.copy();
+ // 1.B Linked card
+ } else {
+ element._id = null;
+ element.type = 'cardType-linkedCard';
+ element.linkedId = element.linkedId || element._id;
+ _id = Cards.insert(element);
+ }
+ Filter.addException(_id);
+ // List insertion
+ } else if (this.isListTemplateSearch) {
+ element.swimlaneId = '';
+ element.sort = Swimlanes.findOne(this.swimlaneId).lists().count();
+ element.type = 'list';
+ element.swimlaneId = this.swimlaneId;
+ _id = element.copy();
}
- Filter.addException(_id);
Popup.close();
},
}];