mirror of
https://github.com/wekan/wekan.git
synced 2025-12-24 03:10:12 +01:00
Refuse to delete a card as long as there is link to it
This fixes https://github.com/wekan/wekan/issues/2785.
This commit is contained in:
parent
2691f033cb
commit
b740381a72
2 changed files with 25 additions and 3 deletions
|
|
@ -967,7 +967,12 @@ BlazeComponent.extendComponent({
|
||||||
},
|
},
|
||||||
'click .js-delete': Popup.afterConfirm('cardDelete', function() {
|
'click .js-delete': Popup.afterConfirm('cardDelete', function() {
|
||||||
Popup.close();
|
Popup.close();
|
||||||
Cards.remove(this._id);
|
// verify that there are no linked cards
|
||||||
|
if (Cards.find({ linkedId: this._id }).count() === 0) {
|
||||||
|
Cards.remove(this._id);
|
||||||
|
} else {
|
||||||
|
// TODO popup...
|
||||||
|
}
|
||||||
Utils.goBoardId(this.boardId);
|
Utils.goBoardId(this.boardId);
|
||||||
}),
|
}),
|
||||||
'change .js-field-parent-board'(event) {
|
'change .js-field-parent-board'(event) {
|
||||||
|
|
|
||||||
|
|
@ -223,8 +223,25 @@ BlazeComponent.extendComponent({
|
||||||
Template.listMorePopup.events({
|
Template.listMorePopup.events({
|
||||||
'click .js-delete': Popup.afterConfirm('listDelete', function() {
|
'click .js-delete': Popup.afterConfirm('listDelete', function() {
|
||||||
Popup.close();
|
Popup.close();
|
||||||
this.allCards().map(card => Cards.remove(card._id));
|
// TODO how can we avoid the fetch call?
|
||||||
Lists.remove(this._id);
|
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);
|
Utils.goBoardId(this.boardId);
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue