From d12fad3420ca066f361eae1449e2037660446918 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 2 Apr 2020 16:16:40 +0200 Subject: [PATCH] Fix kanban edit modal not locked on disconnect --- www/kanban/inner.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/www/kanban/inner.js b/www/kanban/inner.js index 310219e75..e99b61767 100644 --- a/www/kanban/inner.js +++ b/www/kanban/inner.js @@ -135,8 +135,12 @@ define([ var PROPERTIES = ['title', 'body', 'tags', 'color']; var BOARD_PROPERTIES = ['title', 'color']; var createEditModal = function (framework, kanban) { + if (framework.isReadOnly()) { return; } + if (editModal) { return editModal; } + var dataObject = {}; var isBoard, id; + var offline = false; var update = Util.throttle(function () { kanban.setBoards(kanban.options.boards); @@ -147,7 +151,7 @@ define([ framework.localChange(); update(); }; - if (editModal) { return editModal; } + var conflicts, conflictContainer, titleInput, tagsDiv, colors, text; var content = h('div', [ conflictContainer = h('div#cp-kanban-edit-conflicts', [ @@ -167,7 +171,6 @@ define([ ]); var $tags = $(tagsDiv); - var $conflict = $(conflicts); var $cc = $(conflictContainer); var conflict = { @@ -282,6 +285,7 @@ define([ }); var commitTags = function () { + if (offline) { return; } setTimeout(function () { dataObject.tags = Util.deduplicateString(_field.getTokens().map(function (t) { return t.toLowerCase(); @@ -305,6 +309,7 @@ define([ var $color = $(h('span.cp-kanban-palette.fa')); $color.addClass('cp-kanban-palette-'+(color || 'nocolor')); $color.click(function () { + if (offline) { return; } if (color === selectedColor) { return; } selectedColor = color; $colors.find('.cp-kanban-palette').removeClass('fa-check'); @@ -363,6 +368,17 @@ define([ buttons: button }); modal.classList.add('cp-kanban-edit-modal'); + var $modal = $(modal); + + framework.onEditableChange(function (unlocked) { + editor.setOption('readOnly', !unlocked); + $title.prop('disabled', unlocked ? '' : 'disabled'); + $(_field.element).tokenfield(unlocked ? 'enable' : 'disable'); + + $modal.find('nav button.danger').prop('disabled', unlocked ? '' : 'disabled'); + offline = !unlocked; + }); + var setId = function (_isBoard, _id) { // Reset the mdoal with a new id @@ -386,7 +402,7 @@ define([ .show(); } // Also reset the buttons - $(modal).find('nav').after(UI.dialog.getButtons(button)).remove(); + $modal.find('nav').after(UI.dialog.getButtons(button)).remove(); }; onRemoteChange.reg(function () { @@ -975,6 +991,7 @@ define([ } kanban.options.readOnly = true; $container.addClass('cp-app-readonly'); + $container.find('.kanban-edit-item').remove(); }); var getCursor = function () {