Fix kanban edit modal not locked on disconnect

pull/1/head
yflory 5 years ago
parent 572f81877f
commit d12fad3420

@ -135,8 +135,12 @@ define([
var PROPERTIES = ['title', 'body', 'tags', 'color']; var PROPERTIES = ['title', 'body', 'tags', 'color'];
var BOARD_PROPERTIES = ['title', 'color']; var BOARD_PROPERTIES = ['title', 'color'];
var createEditModal = function (framework, kanban) { var createEditModal = function (framework, kanban) {
if (framework.isReadOnly()) { return; }
if (editModal) { return editModal; }
var dataObject = {}; var dataObject = {};
var isBoard, id; var isBoard, id;
var offline = false;
var update = Util.throttle(function () { var update = Util.throttle(function () {
kanban.setBoards(kanban.options.boards); kanban.setBoards(kanban.options.boards);
@ -147,7 +151,7 @@ define([
framework.localChange(); framework.localChange();
update(); update();
}; };
if (editModal) { return editModal; }
var conflicts, conflictContainer, titleInput, tagsDiv, colors, text; var conflicts, conflictContainer, titleInput, tagsDiv, colors, text;
var content = h('div', [ var content = h('div', [
conflictContainer = h('div#cp-kanban-edit-conflicts', [ conflictContainer = h('div#cp-kanban-edit-conflicts', [
@ -167,7 +171,6 @@ define([
]); ]);
var $tags = $(tagsDiv); var $tags = $(tagsDiv);
var $conflict = $(conflicts); var $conflict = $(conflicts);
var $cc = $(conflictContainer); var $cc = $(conflictContainer);
var conflict = { var conflict = {
@ -282,6 +285,7 @@ define([
}); });
var commitTags = function () { var commitTags = function () {
if (offline) { return; }
setTimeout(function () { setTimeout(function () {
dataObject.tags = Util.deduplicateString(_field.getTokens().map(function (t) { dataObject.tags = Util.deduplicateString(_field.getTokens().map(function (t) {
return t.toLowerCase(); return t.toLowerCase();
@ -305,6 +309,7 @@ define([
var $color = $(h('span.cp-kanban-palette.fa')); var $color = $(h('span.cp-kanban-palette.fa'));
$color.addClass('cp-kanban-palette-'+(color || 'nocolor')); $color.addClass('cp-kanban-palette-'+(color || 'nocolor'));
$color.click(function () { $color.click(function () {
if (offline) { return; }
if (color === selectedColor) { return; } if (color === selectedColor) { return; }
selectedColor = color; selectedColor = color;
$colors.find('.cp-kanban-palette').removeClass('fa-check'); $colors.find('.cp-kanban-palette').removeClass('fa-check');
@ -363,6 +368,17 @@ define([
buttons: button buttons: button
}); });
modal.classList.add('cp-kanban-edit-modal'); 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) { var setId = function (_isBoard, _id) {
// Reset the mdoal with a new id // Reset the mdoal with a new id
@ -386,7 +402,7 @@ define([
.show(); .show();
} }
// Also reset the buttons // 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 () { onRemoteChange.reg(function () {
@ -975,6 +991,7 @@ define([
} }
kanban.options.readOnly = true; kanban.options.readOnly = true;
$container.addClass('cp-app-readonly'); $container.addClass('cp-app-readonly');
$container.find('.kanban-edit-item').remove();
}); });
var getCursor = function () { var getCursor = function () {

Loading…
Cancel
Save