mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-17 11:04:00 +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 complete = args.complete;
|
||||||
|
var start = args.start;
|
||||||
|
|
||||||
|
start();
|
||||||
$dataList.fadeOut(function() {
|
$dataList.fadeOut(function() {
|
||||||
action({
|
action({
|
||||||
tierID: $dataList.find('.tier-select select').val(),
|
tierID: $dataList.find('.tier-select select').val(),
|
||||||
|
|||||||
@ -98,21 +98,27 @@
|
|||||||
|
|
||||||
var $form = options.$form;
|
var $form = options.$form;
|
||||||
var viewArgs = $detailView.data('view-args');
|
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) {
|
if (customAction && !noAdd) {
|
||||||
customAction({
|
customAction({
|
||||||
context: context,
|
context: context,
|
||||||
$detailView: $detailView,
|
$detailView: $detailView,
|
||||||
|
start: setLoadingState,
|
||||||
complete: function(args) {
|
complete: function(args) {
|
||||||
if (viewArgs && viewArgs.onPerformAction) {
|
if (!$detailView.hasClass('detail-view-loading-state')) {
|
||||||
viewArgs.onPerformAction();
|
setLoadingState();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set loading appearance
|
|
||||||
var $loading = $('<div>').addClass('loading-overlay');
|
|
||||||
|
|
||||||
$detailView.prepend($loading);
|
|
||||||
|
|
||||||
args = args ? args : {};
|
args = args ? args : {};
|
||||||
|
|
||||||
var $item = args.$item;
|
var $item = args.$item;
|
||||||
@ -134,6 +140,7 @@
|
|||||||
if (!$detailView.parents('html').size()) return;
|
if (!$detailView.parents('html').size()) return;
|
||||||
|
|
||||||
$loading.remove();
|
$loading.remove();
|
||||||
|
$detailView.removeClass('detail-view-loading-state');
|
||||||
replaceListViewItem($detailView, args.data);
|
replaceListViewItem($detailView, args.data);
|
||||||
|
|
||||||
if (!noRefresh) {
|
if (!noRefresh) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user