From 285c06865c92c5964b0e181c32bc390615172dce Mon Sep 17 00:00:00 2001 From: Brian Federle Date: Thu, 21 Nov 2013 13:53:11 -0800 Subject: [PATCH] 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. --- ui/scripts/ui/widgets/listView.js | 36 ++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/ui/scripts/ui/widgets/listView.js b/ui/scripts/ui/widgets/listView.js index 3fa8f5418e6..53b37f187eb 100644 --- a/ui/scripts/ui/widgets/listView.js +++ b/ui/scripts/ui/widgets/listView.js @@ -1330,9 +1330,24 @@ var itemID = $tr.data('list-view-item-id'); var jsonObj = $tr.data('json-obj'); var $loading = $('
').addClass('loading-overlay').appendTo($detailsContainer); + var listViewArgs = $listView.data('view-args'); + var listViewActiveSection = activeSection; + var targetSection; 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.append( $('').html(_l('label.quickview') + ': '), @@ -1352,7 +1367,7 @@ if (!$quickViewTooltip.is(':visible')) return; // Init detail view - context[activeSection] = [jsonObj]; + context[targetSection] = [jsonObj]; createDetailView({ data: $.extend(true, {}, detailView, { onLoad: function($detailView) { @@ -1998,13 +2013,24 @@ var listViewArgs = $listView.data('view-args'); + var targetSection; + detailViewArgs.section = listViewArgs.activeSection ? listViewArgs.activeSection : listViewArgs.id; - detailViewArgs.context[ - listViewActiveSection != '_zone' ? - listViewActiveSection : detailViewArgs.section - ] = [jsonObj]; + 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; + } + + detailViewArgs.context[targetSection] = [jsonObj]; if ($.isFunction(detailViewArgs.data)) { detailViewArgs.data = detailViewArgs.data({