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 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 () {

Loading…
Cancel
Save