diff options
Diffstat (limited to 'client/components/lists')
-rw-r--r-- | client/components/lists/listBody.js | 9 | ||||
-rw-r--r-- | client/components/lists/listHeader.js | 31 |
2 files changed, 32 insertions, 8 deletions
diff --git a/client/components/lists/listBody.js b/client/components/lists/listBody.js index 88f88db0..2d913aa9 100644 --- a/client/components/lists/listBody.js +++ b/client/components/lists/listBody.js @@ -77,7 +77,7 @@ BlazeComponent.extendComponent({ else if ( Utils.boardView() === 'board-view-lists' || Utils.boardView() === 'board-view-cal' || - !Utils.boardView + !Utils.boardView() ) swimlaneId = board.getDefaultSwimline()._id; @@ -658,10 +658,7 @@ BlazeComponent.extendComponent({ _id = element.copy(this.boardId, this.swimlaneId, this.listId); // 1.B Linked card } else { - delete element._id; - element.type = 'cardType-linkedCard'; - element.linkedId = element.linkedId || element._id; - _id = Cards.insert(element); + _id = element.link(this.boardId, this.swimlaneId, this.listId); } Filter.addException(_id); // List insertion @@ -675,7 +672,7 @@ BlazeComponent.extendComponent({ element.sort = Boards.findOne(this.boardId) .swimlanes() .count(); - element.type = 'swimlalne'; + element.type = 'swimlane'; _id = element.copy(this.boardId); } else if (this.isBoardTemplateSearch) { board = Boards.findOne(element.linkedId); diff --git a/client/components/lists/listHeader.js b/client/components/lists/listHeader.js index 46dbd748..7cd4309f 100644 --- a/client/components/lists/listHeader.js +++ b/client/components/lists/listHeader.js @@ -223,8 +223,35 @@ BlazeComponent.extendComponent({ Template.listMorePopup.events({ 'click .js-delete': Popup.afterConfirm('listDelete', function() { Popup.close(); - this.allCards().map(card => Cards.remove(card._id)); - Lists.remove(this._id); + // TODO how can we avoid the fetch call? + const allCards = this.allCards().fetch(); + const allCardIds = _.pluck(allCards, '_id'); + // it's okay if the linked cards are on the same list + if ( + Cards.find({ + $and: [ + { listId: { $ne: this._id } }, + { linkedId: { $in: allCardIds } }, + ], + }).count() === 0 + ) { + allCardIds.map(_id => Cards.remove(_id)); + Lists.remove(this._id); + } else { + // TODO: Figure out more informative message. + // Popup with a hint that the list cannot be deleted as there are + // linked cards. We can adapt the query above so we can list the linked + // cards. + // Related: + // client/components/cards/cardDetails.js about line 969 + // https://github.com/wekan/wekan/issues/2785 + const message = `${TAPi18n.__( + 'delete-linked-cards-before-this-list', + )} linkedId: ${ + this._id + } at client/components/lists/listHeader.js and https://github.com/wekan/wekan/issues/2785`; + alert(message); + } Utils.goBoardId(this.boardId); }), }); |