feat: allow adding sorted-list items from forms outside of modal

v1.18.x
gasoved 4 years ago committed by Julian Lam
parent 3403635ce6
commit a3e95e798f

@ -36,15 +36,7 @@ define('settings/sorted-list', [
addBtn.on('click', function () {
var modal = bootbox.confirm(formHtml, function (save) {
if (save) {
var itemUUID = utils.generateUUID();
var form = $('<form class="" data-sorted-list-uuid="' + itemUUID + '" data-sorted-list-object="' + key + '"></form>');
form.append(modal.find('form').children());
$('#content').append(form.hide());
var data = Settings.helper.serializeForm(form);
parse($container, itemUUID, data);
SortedList.addItem(modal.find('form').children(), $container);
}
});
});
@ -69,6 +61,17 @@ define('settings/sorted-list', [
$list.sortable().addClass('pointer');
},
addItem: function ($formElements, $target) {
const key = $target.attr('data-sorted-list');
const itemUUID = utils.generateUUID();
const form = $('<form class="" data-sorted-list-uuid="' + itemUUID + '" data-sorted-list-object="' + key + '"></form>');
form.append($formElements);
$('#content').append(form.hide());
const data = Settings.helper.serializeForm(form);
parse($target, itemUUID, data);
},
};
function setupRemoveButton($container, itemUUID) {

Loading…
Cancel
Save