Confirm button in kanban edit modal

pull/1/head
yflory 5 years ago
parent 7c76e4544a
commit 729a167e59

@ -288,15 +288,18 @@
nav { nav {
padding: @alertify_padding-base; padding: @alertify_padding-base;
text-align: right; text-align: right;
button { button, div.cp-button-confirm {
margin: 0px !important; margin: 0px !important;
&:not(:first-child) { &:not(:first-child):not(.left) {
margin-left: @alertify_padding-base !important; margin-left: @alertify_padding-base !important;
} }
&.left { &.left {
float: left; float: left;
} }
} }
div.cp-button-confirm {
vertical-align: middle;
}
} }
} }
} }

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

@ -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 = [{ var button = [{
className: 'danger left', className: 'danger left',
name: Messages.kanban_delete, name: Messages.kanban_delete,
onClick: function () { confirm: true,
onClick: function (button) {
var boards = kanban.options.boards || {}; var boards = kanban.options.boards || {};
if (isBoard) { if (isBoard) {
var list = boards.list || []; var list = boards.list || [];
@ -390,6 +369,31 @@ define([
}); });
modal.classList.add('cp-kanban-edit-modal'); 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 () { onRemoteChange.reg(function () {
if (isBoard) { if (isBoard) {
dataObject = kanban.getBoardJSON(id); dataObject = kanban.getBoardJSON(id);

Loading…
Cancel
Save