diff -r 4328bcbd748e -r 7c184924d492 web/views/tabs.py --- a/web/views/tabs.py Mon Feb 23 11:30:38 2009 +0100 +++ b/web/views/tabs.py Mon Feb 23 12:12:59 2009 +0100 @@ -33,22 +33,15 @@ });""" % {'event': 'load_%s' % vid, 'vid': vid, 'reloadable' : str(reloadable).lower()}) - def lazyview(self, vid, rql=None, eid=None, rset=None, static=False, - reloadable=False, show_spinbox=True, w=None): + def lazyview(self, vid, eid=None, reloadable=False, show_spinbox=True, w=None): """a lazy version of wview first version only support lazy viewing for an entity at a time """ - assert rql or eid or rset or static, \ - 'lazyview wants at least : rql, or an eid, or an rset -- or call it with static=True' w = w or self.w self.req.add_js('cubicweb.lazy.js') urlparams = {'vid' : vid, 'mode' : 'html'} - if rql: - urlparams['rql'] = rql - elif eid: + if eid: urlparams['rql'] = rql_for_eid(eid) - elif rset: - urlparams['rql'] = rset.printable_rql() w(u'
' % ( vid, html_escape(self.build_url('json', **urlparams)))) if show_spinbox: @@ -72,12 +65,12 @@ return str('%s_active_tab' % self.config.appid) def active_tab(self, tabs, default): - cookies = self.req.get_cookie() + cookie = self.req.get_cookie() cookiename = self.cookie_name - activetab = cookies.get(cookiename) + activetab = cookie.get(cookiename) if activetab is None: - cookies[cookiename] = default - self.req.set_cookie(cookies, cookiename) + cookie[cookiename] = default + self.req.set_cookie(cookie, cookiename) tab = default else: tab = activetab.value @@ -103,7 +96,7 @@ active_tab = self.active_tab(tabs, default) # build the html structure w = self.w - w(u'
' % entity.eid) + w(u'
') w(u'
    ') for tab in tabs: w(u'
  • ') @@ -117,16 +110,15 @@ w(u'
') for tab in tabs: w(u'
' % tab) - self.lazyview(tab, eid=entity.eid) + self.lazyview(tab, entity.eid) w(u'
') # call the set_tab() JS function *after* each tab is generated # because the callback binding needs to be done before self.req.html_headers.add_onload(u""" - jQuery('#entity-tabs-%(eeid)s > ul').tabs( { selected: %(tabindex)s }); + jQuery('#entity-tabs > ul').tabs( { selected: %(tabindex)s }); set_tab('%(vid)s', '%(cookiename)s'); """ % {'tabindex' : tabs.index(active_tab), 'vid' : active_tab, - 'eeid' : entity.eid, 'cookiename' : self.cookie_name}) @@ -146,10 +138,11 @@ vid = 'gallery' __selectors__ = EntityRelationView.__selectors__ + (one_line_rset,) + This is the view we want to have in a tab, only if there is something to show. Then, just define as below, and declare this being the tab content : - class ProjectScreenshotTab(EntityRelatedTab, ProjectScreenshotsView): + class ProjectScreenshotTab(DataDependantTab, ProjectScreenshotsView): id = 'screenshots_tab' """ __selectors__ = EntityView.__selectors__ + (has_related_entities,)