Confirm button in kanban edit modal

This commit is contained in:
yflory
2020-03-13 15:05:07 +01:00
parent 7c76e4544a
commit 729a167e59
3 changed files with 53 additions and 27 deletions

View File

@@ -386,7 +386,7 @@ define([
buttons.forEach(function (b) {
if (!b.name || !b.onClick) { return; }
var button = h('button', { tabindex: '1', 'class': b.className || '' }, b.name);
$(button).click(function () {
var todo = function () {
var noClose = b.onClick();
if (noClose) { return; }
var $modal = $(button).parents('.alertify').first();
@@ -397,7 +397,17 @@ define([
}
});
}
});
};
if (b.confirm) {
UI.confirmButton(button, {
classes: 'danger',
divClasses: 'left'
}, todo);
} else {
$(button).click(function () {
todo();
});
}
if (b.keys && b.keys.length) { $(button).attr('data-keys', JSON.stringify(b.keys)); }
navs.push(button);
});
@@ -620,6 +630,9 @@ define([
button,
timer
]);
if (config.divClasses) {
$(content).addClass(config.divClasses);
}
var to;
@@ -653,6 +666,12 @@ define([
to = setTimeout(todo, INTERVAL);
$(originalBtn).hide().after(content);
});
return {
reset: function () {
done(false);
}
};
};

View File

@@ -332,32 +332,11 @@ define([
}
};
var setId = function (_isBoard, _id) {
isBoard = _isBoard;
id = _id;
if (_isBoard) {
onCursorUpdate.fire({
board: _id
});
dataObject = kanban.getBoardJSON(id);
$(content)
.find('#cp-kanban-edit-body, #cp-kanban-edit-tags, [for="cp-kanban-edit-body"], [for="cp-kanban-edit-tags"]')
.hide();
} else {
onCursorUpdate.fire({
item: _id
});
dataObject = kanban.getItemJSON(id);
$(content)
.find('#cp-kanban-edit-body, #cp-kanban-edit-tags, [for="cp-kanban-edit-body"], [for="cp-kanban-edit-tags"]')
.show();
}
};
var button = [{
className: 'danger left',
name: Messages.kanban_delete,
onClick: function () {
confirm: true,
onClick: function (button) {
var boards = kanban.options.boards || {};
if (isBoard) {
var list = boards.list || [];
@@ -390,6 +369,31 @@ define([
});
modal.classList.add('cp-kanban-edit-modal');
var setId = function (_isBoard, _id) {
// Reset the mdoal with a new id
isBoard = _isBoard;
id = _id;
if (_isBoard) {
onCursorUpdate.fire({
board: _id
});
dataObject = kanban.getBoardJSON(id);
$(content)
.find('#cp-kanban-edit-body, #cp-kanban-edit-tags, [for="cp-kanban-edit-body"], [for="cp-kanban-edit-tags"]')
.hide();
} else {
onCursorUpdate.fire({
item: _id
});
dataObject = kanban.getItemJSON(id);
$(content)
.find('#cp-kanban-edit-body, #cp-kanban-edit-tags, [for="cp-kanban-edit-body"], [for="cp-kanban-edit-tags"]')
.show();
}
// Also reset the buttons
$(modal).find('nav').after(UI.dialog.getButtons(button)).remove();
};
onRemoteChange.reg(function () {
if (isBoard) {
dataObject = kanban.getBoardJSON(id);