From 30f968e13777e0e1e4d23775e6c99f32d2b89a38 Mon Sep 17 00:00:00 2001 From: Brian Federle Date: Wed, 22 Feb 2012 12:06:38 -0800 Subject: [PATCH] bug 13922 -Fix enable static NAT never completing if detail view was not visible -- caused by JS error in widget -If detail view isn't visible anymore, don't show post-enable/disable NAT dialog which refreshes list view status 13922: resolved fixed reviewed-by: jessica --- ui/scripts/network.js | 10 ++++++++-- ui/scripts/sharedFunctions.js | 4 ++-- ui/scripts/ui/widgets/detailView.js | 17 ++++++++++++----- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/ui/scripts/network.js b/ui/scripts/network.js index bfe582f5b10..9c9bf2e6e91 100644 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -1225,7 +1225,9 @@ } }); - ipChangeNotice(); + if (args._custom.$detailView.is(':visible')) { + ipChangeNotice(); + } } } }, @@ -1254,7 +1256,11 @@ return ['enableStaticNAT']; }; }, - onComplete: ipChangeNotice + onComplete: function(args, _custom) { + if (_custom.$detailView.is(':visible')) { + ipChangeNotice(); + } + } } }); }, diff --git a/ui/scripts/sharedFunctions.js b/ui/scripts/sharedFunctions.js index fefad46eb95..d054befb246 100644 --- a/ui/scripts/sharedFunctions.js +++ b/ui/scripts/sharedFunctions.js @@ -41,7 +41,7 @@ var pollAsyncJobResult = function(args) { return; //Job has not completed } else { - if (result.jobstatus == 1) { // Succeeded + if (result.jobstatus == 1) { // Succeeded if(args._custom.getUpdatedItem != null && args._custom.getActionFilter != null) { args.complete({ data: args._custom.getUpdatedItem(json), @@ -64,7 +64,7 @@ var pollAsyncJobResult = function(args) { } if (args._custom.onComplete) { - args._custom.onComplete(json); + args._custom.onComplete(json, args._custom); } } else if (result.jobstatus == 2) { // Failed diff --git a/ui/scripts/ui/widgets/detailView.js b/ui/scripts/ui/widgets/detailView.js index cbddc2b3e83..149a18bcaf6 100644 --- a/ui/scripts/ui/widgets/detailView.js +++ b/ui/scripts/ui/widgets/detailView.js @@ -82,9 +82,11 @@ if (customAction && !noAdd) { customAction({ context: context, + $detailView: $detailView, complete: function(args) { // Set loading appearance var $loading = $('
').addClass('loading-overlay'); + $detailView.prepend($loading); args = args ? args : {}; @@ -92,20 +94,23 @@ var $item = args.$item; notification.desc = messages.notification(args.messageArgs); - notification._custom = args._custom; + notification._custom = $.extend(args._custom ? args._custom : {}, { + $detailView: $detailView + }); cloudStack.ui.notifications.add( notification, // Success function(args) { - $loading.remove(); + if (!$detailView.is(':visible')) return; + + $loading.remove(); + replaceListViewItem($detailView, args.data); if (!noRefresh) { updateTabContent(args.data); } - - replaceListViewItem($detailView, args.data); }, {}, @@ -131,7 +136,9 @@ response: { success: function(args) { args = args ? args : {}; - notification._custom = args._custom; + notification._custom = $.extend(args._custom ? args._custom : {}, { + $detailView: $detailView + }); if (additional && additional.success) additional.success(args);