Unselect tags that don't exist anymore on redraw

pull/1/head
yflory 5 years ago
parent 8bc8a6b08f
commit ab2337e2f6

@ -746,6 +746,7 @@ define([
getTextColor: getTextColor,
getAvatar: getAvatar,
openLink: openLink,
getTags: getExistingTags,
cursors: remoteCursors,
boards: boards
});
@ -856,6 +857,11 @@ define([
return $(this).data('tag') === t;
}).addClass('active');
});
if (tags.length) {
$reset.css('visibility', '');
} else {
$reset.css('visibility', 'hidden');
}
//framework._.sfCommon.setPadAttribute('tagsFilter', tags);
};
$reset.css('visibility', 'hidden').click(function () {
@ -1014,6 +1020,7 @@ define([
isBoard = false;
json = kanban.getItemJSON(id);
}
if (!json) { return; }
// Editing a board or card title...
$el.find(isBoard ? '.kanban-title-board' : '.kanban-item-text').click();

@ -58,6 +58,7 @@
},
getAvatar: function () {},
openLink: function () {},
getTags: function () {},
getTextColor: function () { return '#000'; },
cursors: {},
tags: [],
@ -581,15 +582,29 @@
this.setBoards = function (boards) {
var scroll = {};
//self.element
// Fix the tags
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);
});
// Remove all boards
for (var i in this.options.boards.list) {
var boardkey = this.options.boards.list[i];
scroll[boardkey] = $('.kanban-board[data-id="'+boardkey+'"] .kanban-drag').scrollTop();
this.removeBoard(boardkey);
}
this.options.boards = boards;
// Add all new boards
this.addBoards();
self.options.refresh();
// Preserve scroll
this.options.boards.list.forEach(function (id) {
if (!scroll[id]) { return; }
$('.kanban-board[data-id="'+id+'"] .kanban-drag').scrollTop(scroll[id]);

Loading…
Cancel
Save