Show all cards when all the selected tags have been deleted

pull/1/head
yflory 5 years ago
parent ab2337e2f6
commit e31ddda8f5

@ -84,6 +84,24 @@
this.options = __extendDefaults(defaults, arguments[0]); this.options = __extendDefaults(defaults, arguments[0]);
} }
var removeUnusedTags = function (boards) {
var tags = self.options.getTags(boards);
var filter = self.options.tags || [];
var toClean = [];
filter.forEach(function (tag) {
if (tags.indexOf(tag) === -1) { toClean.push(tag); }
});
toClean.forEach(function (t) {
var idx = filter.indexOf(t);
if (idx === -1) { return; }
filter.splice(idx, 1);
});
// If all the tags have bene remove, make sure we show everything again
if (!filter.length) {
$('.kanban-item-hidden').removeClass('kanban-item-hidden');
}
};
this.init = function () { this.init = function () {
// set initial boards // set initial boards
__setBoard(); __setBoard();
@ -337,6 +355,8 @@
// If it's a deletion, remove the item data // If it's a deletion, remove the item data
if (!board) { if (!board) {
delete boards.items[eid]; delete boards.items[eid];
removeUnusedTags(boards);
self.options.refresh();
return; return;
} }
// If it's moved to the same board at a bigger index, decrement the index by one // If it's moved to the same board at a bigger index, decrement the index by one
@ -583,17 +603,7 @@
this.setBoards = function (boards) { this.setBoards = function (boards) {
var scroll = {}; var scroll = {};
// Fix the tags // Fix the tags
var tags = self.options.getTags(boards); removeUnusedTags(boards);
var filter = self.options.tags || [];
var toClean = [];
filter.forEach(function (tag) {
if (tags.indexOf(tag) === -1) { toClean.push(tag); }
});
toClean.forEach(function (t) {
var idx = filter.indexOf(t);
if (idx === -1) { return; }
filter.splice(idx, 1);
});
// Remove all boards // Remove all boards
for (var i in this.options.boards.list) { for (var i in this.options.boards.list) {
var boardkey = this.options.boards.list[i]; var boardkey = this.options.boards.list[i];

Loading…
Cancel
Save