Updated Branches: refs/heads/master 0b2e5f1b1 -> e6c3e59e3
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) Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/e6c3e59e Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/e6c3e59e Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/e6c3e59e Branch: refs/heads/master Commit: e6c3e59e39c6b2e86d6af8a1fb021ee53714acb9 Parents: 0b2e5f1 Author: Brian Federle <brian.fede...@citrix.com> Authored: Thu Oct 25 14:39:24 2012 -0700 Committer: Brian Federle <brian.fede...@citrix.com> Committed: Thu Oct 25 14:40:16 2012 -0700 ---------------------------------------------------------------------- ui/scripts/ui-custom/enableStaticNAT.js | 2 ++ ui/scripts/ui/widgets/detailView.js | 23 +++++++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e6c3e59e/ui/scripts/ui-custom/enableStaticNAT.js ---------------------------------------------------------------------- diff --git a/ui/scripts/ui-custom/enableStaticNAT.js b/ui/scripts/ui-custom/enableStaticNAT.js index 405813e..47d5dd2 100644 --- a/ui/scripts/ui-custom/enableStaticNAT.js +++ b/ui/scripts/ui-custom/enableStaticNAT.js @@ -89,7 +89,9 @@ } var complete = args.complete; + var start = args.start; + start(); $dataList.fadeOut(function() { action({ tierID: $dataList.find('.tier-select select').val(), http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e6c3e59e/ui/scripts/ui/widgets/detailView.js ---------------------------------------------------------------------- diff --git a/ui/scripts/ui/widgets/detailView.js b/ui/scripts/ui/widgets/detailView.js index 838bfbd..4fc2689 100644 --- a/ui/scripts/ui/widgets/detailView.js +++ b/ui/scripts/ui/widgets/detailView.js @@ -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) {