Don't remove both kanban items when a duplicate is deleted

pull/1/head
yflory 4 years ago
parent 1c9d36d9ea
commit dbba45e67e

@ -145,7 +145,7 @@ define([
};
var _updateBoardsThrottle = Util.throttle(_updateBoards, 1000);
var updateBoards = function (framework, kanban, boards) {
if ((now() - _lastUpdate) > 5000) {
if ((now() - _lastUpdate) > 5000 || framework.isLocked()) {
_updateBoards(framework, kanban, boards);
return;
}
@ -1207,8 +1207,17 @@ define([
var items = boards.items || {};
var data = boards.data || {};
var list = boards.list || [];
// Remove duplicate boards
list = boards.list = Util.deduplicateString(list);
Object.keys(data).forEach(function (id) {
if (list.indexOf(Number(id)) === -1) { delete data[id]; }
if (list.indexOf(Number(id)) === -1) {
list.push(Number(id));
}
// Remove duplicate items
var b = data[id];
b.item = Util.deduplicateString(b.item || []);
});
Object.keys(items).forEach(function (eid) {
var exists = Object.keys(data).some(function (id) {

@ -299,7 +299,9 @@ define([
// Move to trash?
if (target.classList.contains('kanban-trash')) {
list.splice(index1, 1);
delete self.options.boards.data[id];
if (list.indexOf(id) === -1) {
delete self.options.boards.data[id];
}
self.onChange();
return;
}
@ -444,6 +446,14 @@ define([
});
return res;
};
this.checkItem = function (eid) {
var boards = self.options.boards;
var data = boards.data || {};
var exists = Object.keys(data).some(function (id) {
return (data[id].item || []).indexOf(Number(eid)) !== -1;
});
return exists;
};
this.moveItem = function (eid, board, pos) {
var boards = self.options.boards;
var same = -1;
@ -453,11 +463,13 @@ define([
obj.board.item.splice(obj.pos, 1);
if (obj.board === board) { same = obj.pos; }
});
// If it's a deletion, remove the item data
// If it's a deletion and not a duplicate, remove the item data
if (!board) {
delete boards.items[eid];
delete self.cache[eid];
removeUnusedTags(boards);
if (!self.checkItem(eid)) {
delete boards.items[eid];
delete self.cache[eid];
removeUnusedTags(boards);
}
self.options.refresh();
return;
}

Loading…
Cancel
Save