Implement view all behavior for multi-items

-Call viewAll() on click to open new panel with corresponding view

-Pass context of selected item (such as nic object) to panel

-Allow custom title for panel
This commit is contained in:
Brian Federle 2013-02-25 11:05:42 -08:00
parent 4c0fd582dc
commit b652d2e4ba
2 changed files with 24 additions and 6 deletions

View File

@ -1244,7 +1244,12 @@
],
viewAll: {
path: 'network.ipAddresses',
attachTo: 'ipaddress'
attachTo: 'ipaddress',
title: function(args) {
var title = _l('label.menu.ipaddresses') + ' - ' + args.context.nics[0].name;
return title;
}
},
dataProvider: function(args) {
$.ajax({

View File

@ -587,7 +587,8 @@
var $listView;
var isCustom = $.isFunction(viewAllID.custom);
var updateContext = options.updateContext;
var customTitle = options.title;
if (isCustom) {
$browser.cloudBrowser('addPanel', {
title: _l(viewAllID.label),
@ -644,7 +645,7 @@
// Make panel
var $panel = $browser.cloudBrowser('addPanel', {
title: _l(listViewArgs.title),
title: customTitle ? customTitle({ context: context }) : _l(listViewArgs.title),
data: '',
noSelectPanel: true,
maximizeIfSelected: true,
@ -970,7 +971,7 @@
var tabs = args.tabs[targetTabID];
var dataProvider = tabs.dataProvider;
var isMultiple = tabs.multiple || tabs.isMultiple;
var viewAll = args.viewAll;
var viewAllArgs = args.viewAll;
var $detailView = $tabContent.closest('.detail-view');
var jsonObj = $detailView.data('view-args').jsonObj;
@ -1024,6 +1025,8 @@
if (isMultiple) {
$(data).each(function() {
var item = this;
var $fieldContent = makeFieldContent(
$.extend(true, {}, tabs, {
id: targetTabID
@ -1036,12 +1039,22 @@
).appendTo($tabContent);
if (tabData.viewAll) {
$tabContent.find('tr')
$fieldContent.find('tr')
.filter('.' + tabData.viewAll.attachTo).find('td.value')
.append(
$('<div>').addClass('view-all').append(
$('<span>').html(_l('label.view.all'))
)
).click(function() {
viewAll(
tabData.viewAll.path,
{
updateContext: function(args) {
return { nics: [item] };
},
title: tabData.viewAll.title
}
);
})
);
}
});