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

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

Loading…
Cancel
Save