[tabs] some convenience classes for tabbed views stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 06 Oct 2009 17:15:24 +0200
branchstable
changeset 3570 c31de6ea6984
parent 3569 89a60802711b
child 3571 54743fc6172c
[tabs] some convenience classes for tabbed views
web/views/tabs.py
--- a/web/views/tabs.py	Tue Oct 06 17:15:04 2009 +0200
+++ b/web/views/tabs.py	Tue Oct 06 17:15:24 2009 +0200
@@ -15,6 +15,7 @@
 from cubicweb.view import EntityView
 from cubicweb.common import tags, uilib
 from cubicweb.utils import make_uid
+from cubicweb.web.views import primary
 
 class LazyViewMixin(object):
     """provides two convenience methods for the tab machinery
@@ -178,3 +179,30 @@
             self.w(tags.h1(self.req._(self.title)))
         self.wview(self.vid, rset, 'noresult')
         self.w(u'</div>')
+
+
+class TabedPrimaryView(TabsMixin, primary.PrimaryView):
+    __abstract__ = True # don't register
+
+    tabs = ['main_tab']
+    default_tab = 'main_tab'
+
+    def cell_call(self, row, col):
+        entity = self.complete_entity(row, col)
+        self.render_entity_title(entity)
+        self.render_entity_metadata(entity)
+        self.render_tabs(self.tabs, self.default_tab, entity)
+
+
+class PrimaryTab(primary.PrimaryView):
+    id = 'main_tab'
+
+    def is_primary(self):
+        return True
+
+    def render_entity_title(self, entity):
+        pass
+
+    def render_entity_metadata(self, entity):
+        pass
+