diff --git a/www/kanban/inner.js b/www/kanban/inner.js index a9176adbf..88fd63c61 100644 --- a/www/kanban/inner.js +++ b/www/kanban/inner.js @@ -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(); diff --git a/www/kanban/jkanban.js b/www/kanban/jkanban.js index 37c3b0772..f4a13b909 100644 --- a/www/kanban/jkanban.js +++ b/www/kanban/jkanban.js @@ -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]);