Add API calls to update ACL item order on drag-and-drop

This commit is contained in:
Brian Federle 2013-05-22 15:50:19 -07:00
parent ff58052d2c
commit ea440f2593
2 changed files with 40 additions and 2 deletions

View File

@ -34,6 +34,7 @@
$item.append($('<table>').append($('<tbody>')));
$tr = $('<tr>').appendTo($item.find('tbody'));
$item.data('json-obj', multiRule);
if (itemData) {
$tr.data('multi-edit-data', itemData);
@ -828,7 +829,22 @@ $.fn.multiEdit = function(args) {
$('<th>').addClass('reorder').appendTo($thead);
$('<td>').addClass('reorder').appendTo($inputForm);
$multi.find('.data-body').sortable({
handle: '.action.moveDrag'
handle: '.action.moveDrag',
update: function(event, ui) {
reorder.moveDrag.action({
context: $.extend(true, {}, context, {
// Passes all rules, so that each index can be updated
multiRule: $multi.find('.data-item').map(function(index, item) {
return $(item).data('json-obj');
})
}),
response: {
success: function(args) {
}
}
});
}
});
}

View File

@ -30,7 +30,29 @@
reorder: {
moveDrag: {
action: function(args) {
args.response.success();
$(args.context.multiRule.toArray().reverse()).map(function(index, rule) {
$.ajax({
url: createURL('updateNetworkACLItem'),
data: {
id: rule.id,
number: index + 1
},
success: function(json) {
var pollTimer = setInterval(function() {
pollAsyncJobResult({
_custom: { jobId: json.createnetworkaclresponse.jobid },
complete: function() {
clearInterval(pollTimer);
},
error: function(errorMsg) {
clearInterval(pollTimer);
cloudStack.dialog.notice(errorMsg);
}
});
}, 1000);
}
});
});
}
}
},