detailView UI: Fix quickview actions not updating list view row

This commit is contained in:
Brian Federle 2013-04-22 11:52:52 -07:00
parent 2be8368f44
commit e5cea0204b

View File

@ -15,8 +15,9 @@
// specific language governing permissions and limitations // specific language governing permissions and limitations
// under the License. // under the License.
(function($, cloudStack, _l) { (function($, cloudStack, _l) {
var replaceListViewItem = function($detailView, newData) { var replaceListViewItem = function($detailView, newData, options) {
var $row = $detailView.data('list-view-row'); var $row = $detailView ? $detailView.data('list-view-row') :
options.$row;
if (!$row) return; if (!$row) return;
@ -32,7 +33,9 @@
$row: $row, $row: $row,
data: $.extend(jsonObj, newData), data: $.extend(jsonObj, newData),
after: function($newRow) { after: function($newRow) {
$detailView.data('list-view-row', $newRow); if ($detailView) {
$detailView.data('list-view-row', $newRow);
}
setTimeout(function() { setTimeout(function() {
$('.data-table').dataTable('selectRow', $newRow.index()); $('.data-table').dataTable('selectRow', $newRow.index());
@ -42,11 +45,13 @@
} }
// Refresh detail view context // Refresh detail view context
$.extend( if ($detailView) {
$detailView.data('view-args').context[ $.extend(
$detailView.data('view-args').section $detailView.data('view-args').context[
][0], newData $detailView.data('view-args').section
); ][0], newData
);
}
}; };
/** /**
@ -125,6 +130,7 @@
args = args ? args : {}; args = args ? args : {};
var $item = args.$item; var $item = args.$item;
var $row = $detailView.data('list-view-row');
notification.desc = messages.notification(args.messageArgs); notification.desc = messages.notification(args.messageArgs);
notification._custom = $.extend(args._custom ? args._custom : {}, { notification._custom = $.extend(args._custom ? args._custom : {}, {
@ -140,11 +146,14 @@
viewArgs.onActionComplete(); viewArgs.onActionComplete();
} }
if (!$detailView.parents('html').size()) return; if (!$detailView.parents('html').size()) {
replaceListViewItem(null, args.data, { $row: $row });
return;
}
replaceListViewItem($detailView, args.data);
$loading.remove(); $loading.remove();
$detailView.removeClass('detail-view-loading-state'); $detailView.removeClass('detail-view-loading-state');
replaceListViewItem($detailView, args.data);
if (!noRefresh) { if (!noRefresh) {
updateTabContent(args.data); updateTabContent(args.data);