summaryrefslogtreecommitdiffstats
path: root/client/components/lists
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2020-05-14 00:22:22 +0300
committerLauri Ojansivu <x@xet7.org>2020-05-14 00:22:22 +0300
commit0a123190025062f382f6849837c8077b641cbc96 (patch)
treec4c712e6f47135a021d5218b8b4c048e91db645c /client/components/lists
parent2f33e3a76be0c58d07e628a48d8d32db46e6127c (diff)
parent9cba640120940eec45397d2daf8de573dbedf2b1 (diff)
downloadwekan-0a123190025062f382f6849837c8077b641cbc96.tar.gz
wekan-0a123190025062f382f6849837c8077b641cbc96.tar.bz2
wekan-0a123190025062f382f6849837c8077b641cbc96.zip
Merge branch 'fixes' of https://github.com/marc1006/wekan into marc1006-fixes
Diffstat (limited to 'client/components/lists')
-rw-r--r--client/components/lists/listBody.js7
-rw-r--r--client/components/lists/listHeader.js21
2 files changed, 21 insertions, 7 deletions
diff --git a/client/components/lists/listBody.js b/client/components/lists/listBody.js
index e0b3a66c..2d913aa9 100644
--- a/client/components/lists/listBody.js
+++ b/client/components/lists/listBody.js
@@ -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..a839bb72 100644
--- a/client/components/lists/listHeader.js
+++ b/client/components/lists/listHeader.js
@@ -223,8 +223,25 @@ 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 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.
+ }
Utils.goBoardId(this.boardId);
}),
});