diff options
-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 | ||||
-rw-r--r-- | models/boards.js | 24 | ||||
-rw-r--r-- | models/lists.js | 18 |
8 files changed, 121 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'); diff --git a/models/boards.js b/models/boards.js index 25cf5e37..530a6f71 100644 --- a/models/boards.js +++ b/models/boards.js @@ -463,6 +463,30 @@ Boards.helpers({ return _id; }, + searchLists(term) { + check(term, Match.OneOf(String, null, undefined)); + + const query = { boardId: this._id }; + if (this.isTemplatesBoard()) { + query.type = 'template-list'; + query.archived = false; + } else { + query.type = {$nin: ['template-list']}; + } + const projection = { limit: 10, sort: { createdAt: -1 } }; + + if (term) { + const regex = new RegExp(term, 'i'); + + query.$or = [ + { title: regex }, + { description: regex }, + ]; + } + + return Lists.find(query, projection); + }, + searchCards(term, excludeLinked) { check(term, Match.OneOf(String, null, undefined)); diff --git a/models/lists.js b/models/lists.js index 236432cc..e2ded36e 100644 --- a/models/lists.js +++ b/models/lists.js @@ -137,6 +137,24 @@ Lists.allow({ }); Lists.helpers({ + copy() { + const oldId = this._id; + this._id = null; + const _id = Lists.insert(this); + + // Copy all cards in list + Cards.find({ + listId: oldId, + archived: false, + }).forEach((card) => { + card.type = 'cardType-card'; + card.listId = _id; + card.boardId = this.boardId; + card.swimlaneId = this.swimlaneId; + card.copy(); + }); + }, + cards(swimlaneId) { const selector = { listId: this._id, |