From cdf070189e11205eecd11641226ae62964cc03e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Manelli?= Date: Sat, 23 Feb 2019 01:40:11 +0100 Subject: Remove links from templates board for the moment Insert the correct template type in templates board Allow independant lists in templates board Add some helpers --- client/components/lists/listBody.jade | 15 ++++++++------- client/components/lists/listBody.js | 11 ++++++++--- client/components/swimlanes/swimlaneHeader.js | 2 ++ client/components/swimlanes/swimlanes.jade | 7 +++++++ client/components/swimlanes/swimlanes.js | 7 +++++++ models/lists.js | 7 +++++++ models/swimlanes.js | 22 ++++++++++++++++++++++ 7 files changed, 61 insertions(+), 10 deletions(-) diff --git a/client/components/lists/listBody.jade b/client/components/lists/listBody.jade index f030833b..10d39d15 100644 --- a/client/components/lists/listBody.jade +++ b/client/components/lists/listBody.jade @@ -45,13 +45,14 @@ template(name="addCardForm") .add-controls.clearfix button.primary.confirm(type="submit") {{_ 'add'}} unless isSandstorm - span.quiet - | {{_ 'or'}} - a.js-link {{_ 'link'}} - span.quiet - |   - | / - a.js-search {{_ 'search'}} + unless currentBoard.isTemplatesBoard + span.quiet + | {{_ 'or'}} + a.js-link {{_ 'link'}} + span.quiet + |   + | / + a.js-search {{_ 'search'}} template(name="autocompleteLabelLine") .minicard-label(class="card-label-{{colorName}}" title=labelName) diff --git a/client/components/lists/listBody.js b/client/components/lists/listBody.js index 0f5caac5..576bcd9f 100644 --- a/client/components/lists/listBody.js +++ b/client/components/lists/listBody.js @@ -70,7 +70,11 @@ BlazeComponent.extendComponent({ const boardId = this.data().board(); let swimlaneId = ''; const boardView = Meteor.user().profile.boardView; - if (boardView === 'board-view-swimlanes') + let cardType = 'cardType-card'; + if (this.data().board().isTemplatesBoard()) { + swimlaneId = this.parentComponent().parentComponent().data()._id; // Always swimlanes view + cardType = (Swimlanes.findOne(swimlaneId).isCardTemplatesSwimlane())?'template-card':'cardType-card'; + } else if (boardView === 'board-view-swimlanes') swimlaneId = this.parentComponent().parentComponent().data()._id; else if ((boardView === 'board-view-lists') || (boardView === 'board-view-cal')) swimlaneId = boardId.getDefaultSwimline()._id; @@ -85,7 +89,7 @@ BlazeComponent.extendComponent({ boardId: boardId._id, sort: sortIndex, swimlaneId, - type: 'cardType-card', + type: cardType, }); // if the displayed card count is less than the total cards in the list, @@ -149,7 +153,8 @@ BlazeComponent.extendComponent({ idOrNull(swimlaneId) { const currentUser = Meteor.user(); - if (currentUser.profile.boardView === 'board-view-swimlanes') + if (currentUser.profile.boardView === 'board-view-swimlanes' + || this.data().board().isTemplatesBoard()) return swimlaneId; return undefined; }, diff --git a/client/components/swimlanes/swimlaneHeader.js b/client/components/swimlanes/swimlaneHeader.js index 1004cb25..b78bdc96 100644 --- a/client/components/swimlanes/swimlaneHeader.js +++ b/client/components/swimlanes/swimlaneHeader.js @@ -47,12 +47,14 @@ BlazeComponent.extendComponent({ const titleInput = this.find('.swimlane-name-input'); const title = titleInput.value.trim(); const sortValue = calculateIndexData(this.currentSwimlane, nextSwimlane, 1); + const swimlaneType = (currentBoard.isTemplatesBoard())?'template-swimlane':'swimlane'; if (title) { Swimlanes.insert({ title, boardId: Session.get('currentBoard'), sort: sortValue.base, + type: swimlaneType, }); titleInput.value = ''; diff --git a/client/components/swimlanes/swimlanes.jade b/client/components/swimlanes/swimlanes.jade index 34177a02..0e070a21 100644 --- a/client/components/swimlanes/swimlanes.jade +++ b/client/components/swimlanes/swimlanes.jade @@ -10,6 +10,13 @@ template(name="swimlane") +miniList(this) if currentUser.isBoardMember +addListForm + else if currentBoard.isTemplatesBoard + each lists + +list(this) + if currentCardIsInThisList _id ../_id + +cardDetails(currentCard) + if currentUser.isBoardMember + +addListForm else each currentBoard.lists +list(this) diff --git a/client/components/swimlanes/swimlanes.js b/client/components/swimlanes/swimlanes.js index ce327f54..4dd84604 100644 --- a/client/components/swimlanes/swimlanes.js +++ b/client/components/swimlanes/swimlanes.js @@ -153,6 +153,10 @@ BlazeComponent.extendComponent({ }).register('swimlane'); BlazeComponent.extendComponent({ + onCreated() { + this.currentSwimlane = this.currentData(); + }, + // Proxy open() { this.childComponents('inlinedForm')[0].open(); @@ -164,11 +168,14 @@ BlazeComponent.extendComponent({ evt.preventDefault(); const titleInput = this.find('.list-name-input'); const title = titleInput.value.trim(); + const listType = (this.currentSwimlane.isListTemplatesSwimlane())?'template-list':'list'; if (title) { Lists.insert({ title, boardId: Session.get('currentBoard'), sort: $('.list').length, + type: listType, + swimlaneId: this.currentSwimlane._id, }); titleInput.value = ''; diff --git a/models/lists.js b/models/lists.js index e0040752..a0b882bc 100644 --- a/models/lists.js +++ b/models/lists.js @@ -27,6 +27,13 @@ Lists.attachSchema(new SimpleSchema({ */ type: String, }, + swimlaneId: { + /** + * the swimalen associated to this list. Used for templates + */ + type: String, + defaultValue: '', + }, createdAt: { /** * creation date diff --git a/models/swimlanes.js b/models/swimlanes.js index 185422ce..9d4e16de 100644 --- a/models/swimlanes.js +++ b/models/swimlanes.js @@ -108,6 +108,13 @@ Swimlanes.helpers({ }), { sort: ['sort'] }); }, + lists() { + return Lists.find(Filter.mongoSelector({ + swimlaneId: this._id, + archived: false, + }), { sort: ['sort'] }); + }, + allCards() { return Cards.find({ swimlaneId: this._id }); }, @@ -129,6 +136,21 @@ Swimlanes.helpers({ isTemplateContainer() { return this.type === 'template-container'; }, + + isListTemplatesSwimlane() { + const user = Users.findOne(Meteor.userId()); + return user.profile.listTemplatesSwimlaneId === this._id; + }, + + isCardTemplatesSwimlane() { + const user = Users.findOne(Meteor.userId()); + return user.profile.cardTemplatesSwimlaneId === this._id; + }, + + isBoardTemplatesSwimlane() { + const user = Users.findOne(Meteor.userId()); + return user.profile.boardsTemplatesSwimlaneId === this._id; + }, }); Swimlanes.mutations({ -- cgit v1.2.3-1-g7c22