mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-16 10:32:34 +01:00
UI custom actions/enable static NAT: fix loading state
Fixes a bug where the loading state is not immediataly set for the detail view on performing certain custom UI actions, particularly enable static NAT. This passes a separate 'start' function to the custom widgets, which triggers the loading state, and 'complete' when the action completes (i.e., the server call is done)
This commit is contained in:
parent
0b2e5f1b17
commit
e6c3e59e39
@ -89,7 +89,9 @@
|
||||
}
|
||||
|
||||
var complete = args.complete;
|
||||
var start = args.start;
|
||||
|
||||
start();
|
||||
$dataList.fadeOut(function() {
|
||||
action({
|
||||
tierID: $dataList.find('.tier-select select').val(),
|
||||
|
||||
@ -98,21 +98,27 @@
|
||||
|
||||
var $form = options.$form;
|
||||
var viewArgs = $detailView.data('view-args');
|
||||
var $loading = $('<div>').addClass('loading-overlay');
|
||||
|
||||
var setLoadingState = function() {
|
||||
if (viewArgs && viewArgs.onPerformAction) {
|
||||
viewArgs.onPerformAction();
|
||||
}
|
||||
|
||||
$detailView.addClass('detail-view-loading-state');
|
||||
$detailView.prepend($loading);
|
||||
};
|
||||
|
||||
if (customAction && !noAdd) {
|
||||
customAction({
|
||||
context: context,
|
||||
$detailView: $detailView,
|
||||
start: setLoadingState,
|
||||
complete: function(args) {
|
||||
if (viewArgs && viewArgs.onPerformAction) {
|
||||
viewArgs.onPerformAction();
|
||||
if (!$detailView.hasClass('detail-view-loading-state')) {
|
||||
setLoadingState();
|
||||
}
|
||||
|
||||
// Set loading appearance
|
||||
var $loading = $('<div>').addClass('loading-overlay');
|
||||
|
||||
$detailView.prepend($loading);
|
||||
|
||||
|
||||
args = args ? args : {};
|
||||
|
||||
var $item = args.$item;
|
||||
@ -134,6 +140,7 @@
|
||||
if (!$detailView.parents('html').size()) return;
|
||||
|
||||
$loading.remove();
|
||||
$detailView.removeClass('detail-view-loading-state');
|
||||
replaceListViewItem($detailView, args.data);
|
||||
|
||||
if (!noRefresh) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user