diff options
author | Romulus Urakagi Tsai <urakagi@gmail.com> | 2020-05-20 15:12:55 +0800 |
---|---|---|
committer | Romulus Urakagi Tsai <urakagi@gmail.com> | 2020-05-20 15:12:55 +0800 |
commit | af7c74b2d36681cd16b7e7d1a88c2b3a93b69d3d (patch) | |
tree | c8f1cd693195bbe20237308b0aac95ce43a592ca /client/components/lists/listHeader.js | |
parent | 4064f3f4063136c97aa7bcbcdc18fec923934b74 (diff) | |
parent | b80396f627665119cd38f11f2d466ce53ec573ab (diff) | |
download | wekan-af7c74b2d36681cd16b7e7d1a88c2b3a93b69d3d.tar.gz wekan-af7c74b2d36681cd16b7e7d1a88c2b3a93b69d3d.tar.bz2 wekan-af7c74b2d36681cd16b7e7d1a88c2b3a93b69d3d.zip |
Merge branch 'lib-change' of https://github.com/PDIS/wekan into lib-change
Diffstat (limited to 'client/components/lists/listHeader.js')
-rw-r--r-- | client/components/lists/listHeader.js | 31 |
1 files changed, 29 insertions, 2 deletions
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); }), }); |