Skip to content

Commit 4cd5dfe

Browse files
committed
CLOUDSTACK-3153: On reorder, only update target ACL item's number
1 parent 5304d49 commit 4cd5dfe

2 files changed

Lines changed: 36 additions & 25 deletions

File tree

‎ui/scripts/ui/widgets/multiEdit.js‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -832,15 +832,24 @@ $.fn.multiEdit = function(args) {
832832
handle: '.action.moveDrag',
833833

834834
update: function(event, ui) {
835+
var $loading = $('<div>').addClass('loading-overlay');
836+
837+
$loading.prependTo($multi);
835838
reorder.moveDrag.action({
839+
targetIndex: ui.item.index(),
836840
context: $.extend(true, {}, context, {
837841
// Passes all rules, so that each index can be updated
838-
multiRule: $multi.find('.data-item').map(function(index, item) {
839-
return $(item).data('json-obj');
840-
})
842+
multiRule: [ui.item.data('json-obj')]
841843
}),
842844
response: {
843845
success: function(args) {
846+
$multi.trigger('refresh');
847+
$loading.remove();
848+
},
849+
error: function(msg) {
850+
$multi.trigger('refresh');
851+
cloudStack.dialog.notice(msg);
852+
$loading.remove();
844853
}
845854
}
846855
});

‎ui/scripts/vpc.js‎

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,30 @@
3030
reorder: {
3131
moveDrag: {
3232
action: function(args) {
33-
$(args.context.multiRule.toArray().reverse()).map(function(index, rule) {
34-
$.ajax({
35-
url: createURL('updateNetworkACLItem'),
36-
data: {
37-
id: rule.id,
38-
number: index + 1
39-
},
40-
success: function(json) {
41-
var pollTimer = setInterval(function() {
42-
pollAsyncJobResult({
43-
_custom: { jobId: json.createnetworkaclresponse.jobid },
44-
complete: function() {
45-
clearInterval(pollTimer);
46-
},
47-
error: function(errorMsg) {
48-
clearInterval(pollTimer);
49-
cloudStack.dialog.notice(errorMsg);
50-
}
51-
});
52-
}, 1000);
53-
}
54-
});
33+
var rule = args.context.multiRule[0];
34+
var index = args.targetIndex;
35+
36+
$.ajax({
37+
url: createURL('updateNetworkACLItem'),
38+
data: {
39+
id: rule.id,
40+
number: index + 1
41+
},
42+
success: function(json) {
43+
var pollTimer = setInterval(function() {
44+
pollAsyncJobResult({
45+
_custom: { jobId: json.createnetworkaclresponse.jobid },
46+
complete: function() {
47+
clearInterval(pollTimer);
48+
args.response.success();
49+
},
50+
error: function(errorMsg) {
51+
clearInterval(pollTimer);
52+
args.response.error(parseXMLHttpResponse(errorMsg));
53+
}
54+
});
55+
}, 1000);
56+
}
5557
});
5658
}
5759
}

0 commit comments

Comments
 (0)