web/views/tabs.py
changeset 923 7c184924d492
parent 917 51d5224b1698
child 985 6a25c58a1c23
child 999 999198995a53
--- 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'<div id="lazy-%s" cubicweb:loadurl="%s">' % (
             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'<div id="entity-tabs-%s">' % entity.eid)
+        w(u'<div id="entity-tabs">')
         w(u'<ul>')
         for tab in tabs:
             w(u'<li>')
@@ -117,16 +110,15 @@
         w(u'</div>')
         for tab in tabs:
             w(u'<div id="as-%s">' % tab)
-            self.lazyview(tab, eid=entity.eid)
+            self.lazyview(tab, entity.eid)
             w(u'</div>')
         # 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,)