[tabs] backport entity-less support for tabs
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Thu, 16 Jul 2009 17:00:19 +0200
changeset 2386 b246d5cee44e
parent 2385 8fa16dc4b8c8
child 2387 ea1defea9636
[tabs] backport entity-less support for tabs
web/views/tabs.py
--- a/web/views/tabs.py	Thu Jul 16 16:34:02 2009 +0200
+++ b/web/views/tabs.py	Thu Jul 16 17:00:19 2009 +0200
@@ -107,12 +107,9 @@
         active_tab = self.active_tab(tabs, default)
         # build the html structure
         w = self.w
-        if entity:
-            w(u'<div id="entity-tabs-%s">' % entity.eid)
-        else:
-            uid = make_uid('tab')
-            w(u'<div id="entity-tabs-%s">' % uid)
-        w(u'<ul class="css-tabs" id="tabs-%s">' % entity.eid)
+        uid = entity and entity.eid or make_uid('tab')
+        w(u'<div id="entity-tabs-%s">' % uid)
+        w(u'<ul class="css-tabs" id="tabs-%s">' % uid)
         for tab in tabs:
             w(u'<li>')
             w(u'<a href="#as-%s">' % tab)
@@ -123,7 +120,7 @@
             w(u'</li>')
         w(u'</ul>')
         w(u'</div>')
-        w(u'<div id="panes-%s">' % entity.eid)
+        w(u'<div id="panes-%s">' % uid)
         for tab in tabs:
             w(u'<div>')
             if entity:
@@ -139,7 +136,7 @@
     jQuery(function() {
       jQuery("#tabs-%(eeid)s").tabs("#panes-%(eeid)s > div", {initialIndex: %(tabindex)s});
       set_tab('%(vid)s', '%(cookiename)s');
-    });''' % {'eeid' : entity.eid,
+    });''' % {'eeid' : (entity and entity.eid or uid),
               'vid'  : active_tab,
               'cookiename' : self.cookie_name,
               'tabindex' : tabs.index(active_tab)})