# HG changeset patch # User Aurelien Campeas # Date 1233087383 -3600 # Node ID b84d64db23500f7b5a4f44c7eebc7d6e6668635f # Parent 21183fc36b39dd6b54ad43bfb182c1196dd08683 [tabs] prune tab set _before_ computing & setting 'active' tab diff -r 21183fc36b39 -r b84d64db2350 web/views/tabs.py --- a/web/views/tabs.py Tue Jan 27 20:51:55 2009 +0100 +++ b/web/views/tabs.py Tue Jan 27 21:16:23 2009 +0100 @@ -64,9 +64,22 @@ tab = activetab.value return tab if tab in tabs else default + def prune_tabs(self, tabs): + selected_tabs = [] + for tab in tabs: + try: + tabview = self.vreg.select_view(tab, self.req, self.rset) + selected_tabs.append(tab) + except NoSelectableObject: + continue + return selected_tabs + def render_tabs(self, tabs, default, entity): self.req.add_css('ui.tabs.css') self.req.add_js(('ui.core.js', 'ui.tabs.js', 'cubicweb.tabs.js', 'cubicweb.lazy.js')) + # prune tabs : not all are to be shown + tabs = self.prune_tabs(tabs) + # select a tab active_tab = self.active_tab(tabs, default) self.req.html_headers.add_post_inline_script(u""" jQuery(document).ready(function() { @@ -79,14 +92,7 @@ w = self.w w(u'
') w(u'') w(u'
') - for tab in selected_tabs: + for tab in tabs: w(u'
' % tab) self.lazyview(tab, entity.eid) w(u'
')