List view: Support passing custom ID to detail view context

For section select list views, if 'id' is specied under section: {},
then use that ID instead of the section's key ID. This allows sections
to use i.e. the same ID as each other for a consistent context ID.
This commit is contained in:
Brian Federle 2013-11-21 13:53:11 -08:00
parent b689e615c5
commit 285c06865c

View File

@ -1330,9 +1330,24 @@
var itemID = $tr.data('list-view-item-id'); var itemID = $tr.data('list-view-item-id');
var jsonObj = $tr.data('json-obj'); var jsonObj = $tr.data('json-obj');
var $loading = $('<div>').addClass('loading-overlay').appendTo($detailsContainer); var $loading = $('<div>').addClass('loading-overlay').appendTo($detailsContainer);
var listViewArgs = $listView.data('view-args');
var listViewActiveSection = activeSection;
var targetSection;
if ($tr.hasClass('loading')) return; if ($tr.hasClass('loading')) return;
if (listViewActiveSection != '_zone') {
if (listViewArgs.sections &&
listViewArgs.sections[listViewActiveSection] &&
listViewArgs.sections[listViewActiveSection].id) {
targetSection = listViewArgs.sections[listViewActiveSection].id;
} else {
targetSection = listViewActiveSection;
}
} else {
targetSection = detailViewArgs.section;
}
// Title // Title
$title.append( $title.append(
$('<span>').html(_l('label.quickview') + ': '), $('<span>').html(_l('label.quickview') + ': '),
@ -1352,7 +1367,7 @@
if (!$quickViewTooltip.is(':visible')) return; if (!$quickViewTooltip.is(':visible')) return;
// Init detail view // Init detail view
context[activeSection] = [jsonObj]; context[targetSection] = [jsonObj];
createDetailView({ createDetailView({
data: $.extend(true, {}, detailView, { data: $.extend(true, {}, detailView, {
onLoad: function($detailView) { onLoad: function($detailView) {
@ -1998,13 +2013,24 @@
var listViewArgs = $listView.data('view-args'); var listViewArgs = $listView.data('view-args');
var targetSection;
detailViewArgs.section = listViewArgs.activeSection ? detailViewArgs.section = listViewArgs.activeSection ?
listViewArgs.activeSection : listViewArgs.id; listViewArgs.activeSection : listViewArgs.id;
detailViewArgs.context[ if (listViewActiveSection != '_zone') {
listViewActiveSection != '_zone' ? if (listViewArgs.sections &&
listViewActiveSection : detailViewArgs.section listViewArgs.sections[listViewActiveSection] &&
] = [jsonObj]; listViewArgs.sections[listViewActiveSection].id) {
targetSection = listViewArgs.sections[listViewActiveSection].id;
} else {
targetSection = listViewActiveSection;
}
} else {
targetSection = detailViewArgs.section;
}
detailViewArgs.context[targetSection] = [jsonObj];
if ($.isFunction(detailViewArgs.data)) { if ($.isFunction(detailViewArgs.data)) {
detailViewArgs.data = detailViewArgs.data({ detailViewArgs.data = detailViewArgs.data({