diff options
-rw-r--r-- | client/components/cards/cardDetails.jade | 8 | ||||
-rw-r--r-- | client/components/cards/cardDetails.js | 5 | ||||
-rw-r--r-- | client/components/cards/minicard.jade | 4 | ||||
-rw-r--r-- | client/components/lists/listBody.js | 6 | ||||
-rw-r--r-- | client/components/users/userAvatar.js | 5 | ||||
-rw-r--r-- | models/cards.js | 68 |
6 files changed, 82 insertions, 14 deletions
diff --git a/client/components/cards/cardDetails.jade b/client/components/cards/cardDetails.jade index 3d0bfb98..64ce7f66 100644 --- a/client/components/cards/cardDetails.jade +++ b/client/components/cards/cardDetails.jade @@ -55,7 +55,7 @@ template(name="cardDetails") .card-details-items .card-details-item.card-details-item-members h3.card-details-item-title {{_ 'members'}} - each members + each getMembers +userAvatar(userId=this cardId=../_id) | {{! XXX Hack to hide syntaxic coloration /// }} if canModifyCard @@ -92,15 +92,15 @@ template(name="cardDetails") h3.card-details-item-title {{_ 'description'}} +inlinedCardDescription(classNames="card-description js-card-description") +editor(autofocus=true) - | {{getUnsavedValue 'cardDescription' _id description}} + | {{getUnsavedValue 'cardDescription' _id getDescription}} .edit-controls.clearfix button.primary(type="submit") {{_ 'save'}} a.fa.fa-times-thin.js-close-inlined-form else a.js-open-inlined-form - if description + if getDescription +viewer - = description + = getDescription else | {{_ 'edit'}} if (hasUnsavedValue 'cardDescription' _id) diff --git a/client/components/cards/cardDetails.js b/client/components/cards/cardDetails.js index 181fea1b..2cd399c1 100644 --- a/client/components/cards/cardDetails.js +++ b/client/components/cards/cardDetails.js @@ -43,8 +43,7 @@ BlazeComponent.extendComponent({ }, canModifyCard() { - return Meteor.user() && Meteor.user().isBoardMember() && - !Meteor.user().isCommentOnly() && !this.currentData().isImported(); + return Meteor.user() && Meteor.user().isBoardMember() && !Meteor.user().isCommentOnly(); }, scrollParentContainer() { @@ -275,7 +274,7 @@ BlazeComponent.extendComponent({ close(isReset = false) { if (this.isOpen.get() && !isReset) { const draft = this.getValue().trim(); - if (draft !== Cards.findOne(Session.get('currentCard')).description) { + if (draft !== Cards.findOne(Session.get('currentCard')).getDescription()) { UnsavedEdits.set(this._getUnsavedEditKey(), this.getValue()); } } diff --git a/client/components/cards/minicard.jade b/client/components/cards/minicard.jade index 7e2999d3..00120882 100644 --- a/client/components/cards/minicard.jade +++ b/client/components/cards/minicard.jade @@ -57,9 +57,9 @@ template(name="minicard") +viewer = trueValue - if members + if getMembers .minicard-members.js-minicard-members - each members + each getMembers +userAvatar(userId=this) .badges diff --git a/client/components/lists/listBody.js b/client/components/lists/listBody.js index c0533008..778312d2 100644 --- a/client/components/lists/listBody.js +++ b/client/components/lists/listBody.js @@ -300,9 +300,10 @@ BlazeComponent.extendComponent({ // Swimlane where to insert card const swimlane = $(Popup._getTopStack().openerElement).closest('.js-swimlane'); this.swimlaneId = ''; - if (board.view === 'board-view-swimlanes') + const boardView = Meteor.user().profile.boardView; + if (boardView === 'board-view-swimlanes') this.swimlaneId = Blaze.getData(swimlane[0])._id; - else + else if (boardView === 'board-view-lists') this.swimlaneId = Swimlanes.findOne({boardId: this.boardId})._id; }, @@ -382,7 +383,6 @@ BlazeComponent.extendComponent({ sort: Lists.findOne(this.listId).cards().count(), type: 'cardType-importedBoard', importedId: impBoardId, - description: Boards.findOne({_id: impBoardId}).description, }); Filter.addException(_id); Popup.close(); diff --git a/client/components/users/userAvatar.js b/client/components/users/userAvatar.js index be7a85d2..91cad237 100644 --- a/client/components/users/userAvatar.js +++ b/client/components/users/userAvatar.js @@ -134,8 +134,9 @@ BlazeComponent.extendComponent({ Template.cardMembersPopup.helpers({ isCardMember() { - const cardId = Template.parentData()._id; - const cardMembers = Cards.findOne(cardId).members || []; + const card = Template.parentData(); + const cardMembers = card.getMembers(); + return _.contains(cardMembers, this.userId); }, diff --git a/models/cards.js b/models/cards.js index 4b18b8f3..de868dde 100644 --- a/models/cards.js +++ b/models/cards.js @@ -406,6 +406,18 @@ Cards.helpers({ return this.isImportedCard() || this.isImportedBoard(); }, + setDescription(description) { + if (this.isImportedCard()) { + const card = Cards.findOne({_id: this.importedId}); + return Cards.update({_id: this.importedId}, {$set: {description}}); + } else if (this.isImportedBoard()) { + const board = Boards.findOne({_id: this.importedId}); + return Boards.update({_id: this.importedId}, {$set: {description}}); + } else { + return {$set: {description}}; + } + }, + getDescription() { if (this.isImportedCard()) { const card = Cards.findOne({_id: this.importedId}); @@ -426,6 +438,62 @@ Cards.helpers({ return null; } }, + + getMembers() { + if (this.isImportedCard()) { + const card = Cards.findOne({_id: this.importedId}); + return card.members; + } else if (this.isImportedBoard()) { + const board = Boards.findOne({_id: this.importedId}); + return board.activeMembers().map((member) => { + return member.userId; + }); + } else { + return this.members; + } + }, + + assignMember(memberId) { + if (this.isImportedCard()) { + return Cards.update( + { _id: this.importedId }, + { $addToSet: { members: memberId }} + ); + } else if (this.isImportedBoard()) { + const board = Boards.findOne({_id: this.importedId}); + return board.addMember(memberId); + } else { + return Cards.update( + { _id: this._id }, + { $addToSet: { members: memberId}} + ); + } + }, + + unassignMember(memberId) { + if (this.isImportedCard()) { + return Cards.update( + { _id: this.importedId }, + { $pull: { members: memberId }} + ); + } else if (this.isImportedBoard()) { + const board = Boards.findOne({_id: this.importedId}); + return board.removeMember(memberId); + } else { + return Cards.update( + { _id: this._id }, + { $pull: { members: memberId}} + ); + } + }, + + toggleMember(memberId) { + if (this.getMembers() && this.getMembers().indexOf(memberId) > -1) { + return this.unassignMember(memberId); + } else { + return this.assignMember(memberId); + } + }, }); Cards.mutations({ |