diff options
author | Andrés Manelli <andresmanelli@gmail.com> | 2019-02-23 20:41:36 +0100 |
---|---|---|
committer | Andrés Manelli <andresmanelli@gmail.com> | 2019-02-24 00:05:00 +0100 |
commit | f888cfd565b197903c24a07221f6a6a44e1b6223 (patch) | |
tree | 7745b9c3913ae62f2bc08fb0a1049ec9754f2d4d /client | |
parent | 044126188d28a24b0df5d67cf69d081ce7790886 (diff) | |
download | wekan-f888cfd565b197903c24a07221f6a6a44e1b6223.tar.gz wekan-f888cfd565b197903c24a07221f6a6a44e1b6223.tar.bz2 wekan-f888cfd565b197903c24a07221f6a6a44e1b6223.zip |
Allow list creation from template
Diffstat (limited to 'client')
-rw-r--r-- | client/components/lists/listBody.jade | 13 | ||||
-rw-r--r-- | client/components/lists/listBody.js | 62 | ||||
-rw-r--r-- | client/components/lists/minilist.jade | 8 | ||||
-rw-r--r-- | client/components/swimlanes/miniswimlane.jade | 8 | ||||
-rw-r--r-- | client/components/swimlanes/swimlanes.jade | 6 | ||||
-rw-r--r-- | client/components/swimlanes/swimlanes.js | 8 |
6 files changed, 79 insertions, 26 deletions
diff --git a/client/components/lists/listBody.jade b/client/components/lists/listBody.jade index 80ce70c0..46f90f99 100644 --- a/client/components/lists/listBody.jade +++ b/client/components/lists/listBody.jade @@ -57,7 +57,7 @@ template(name="addCardForm") span.quiet | | / - a.js-search-template {{_ 'template'}} + a.js-card-template {{_ 'template'}} template(name="autocompleteLabelLine") .minicard-label(class="card-label-{{colorName}}" title=labelName) @@ -104,5 +104,12 @@ template(name="searchCardPopup") .list-body.js-perfect-scrollbar.search-card-results .minicards.clearfix.js-minicards each results - a.minicard-wrapper.js-minicard - +minicard(this) + if isListTemplateSearch + a.minicard-wrapper.js-minicard + +minilist(this) + if isSwimlaneTemplateSearch + a.minicard-wrapper.js-minicard + +miniswimlane(this) + unless isTemplateSearch + a.minicard-wrapper.js-minicard + +minicard(this) 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(); }, }]; diff --git a/client/components/lists/minilist.jade b/client/components/lists/minilist.jade new file mode 100644 index 00000000..e34214c4 --- /dev/null +++ b/client/components/lists/minilist.jade @@ -0,0 +1,8 @@ +template(name="minilist") + .minicard( + class="minicard-{{colorClass}}") + .minicard-title + .handle + .fa.fa-arrows + +viewer + = title diff --git a/client/components/swimlanes/miniswimlane.jade b/client/components/swimlanes/miniswimlane.jade new file mode 100644 index 00000000..d4be8599 --- /dev/null +++ b/client/components/swimlanes/miniswimlane.jade @@ -0,0 +1,8 @@ +template(name="miniswimlane") + .minicard( + class="minicard-{{colorClass}}") + .minicard-title + .handle + .fa.fa-arrows + +viewer + = title diff --git a/client/components/swimlanes/swimlanes.jade b/client/components/swimlanes/swimlanes.jade index 0e070a21..ba174cb5 100644 --- a/client/components/swimlanes/swimlanes.jade +++ b/client/components/swimlanes/swimlanes.jade @@ -51,7 +51,11 @@ template(name="addListForm") autocomplete="off" autofocus) .edit-controls.clearfix button.primary.confirm(type="submit") {{_ 'save'}} - a.fa.fa-times-thin.js-close-inlined-form + unless currentBoard.isTemplatesBoard + unless currentBoard.isTemplateBoard + span.quiet + | {{_ 'or'}} + a.js-list-template {{_ 'template'}} else a.open-list-composer.js-open-inlined-form i.fa.fa-plus diff --git a/client/components/swimlanes/swimlanes.js b/client/components/swimlanes/swimlanes.js index 63266e5f..bdaed81d 100644 --- a/client/components/swimlanes/swimlanes.js +++ b/client/components/swimlanes/swimlanes.js @@ -154,6 +154,8 @@ BlazeComponent.extendComponent({ BlazeComponent.extendComponent({ onCreated() { + currentBoard = Boards.findOne(Session.get('currentBoard')); + this.isListTemplatesSwimlane = currentBoard.isTemplatesBoard() && this.currentData().isListTemplatesSwimlane(); this.currentSwimlane = this.currentData(); }, @@ -169,19 +171,19 @@ BlazeComponent.extendComponent({ const titleInput = this.find('.list-name-input'); const title = titleInput.value.trim(); if (title) { - const listType = (this.currentSwimlane.isListTemplatesSwimlane())?'template-list':'list'; Lists.insert({ title, boardId: Session.get('currentBoard'), sort: $('.list').length, - type: listType, - swimlaneId: this.currentSwimlane._id, + type: (this.isListTemplatesSwimlane)?'template-list':'list', + swimlaneId: (this.isListTemplatesSwimlane)?this.currentSwimlane._id:'', }); titleInput.value = ''; titleInput.focus(); } }, + 'click .js-list-template': Popup.open('searchCard'), }]; }, }).register('addListForm'); |