fix the tabs widget
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Thu, 20 Dec 2012 08:21:47 +0000 (09:21 +0100)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Thu, 20 Dec 2012 08:21:47 +0000 (09:21 +0100)
engine/composite.py
plugins/tabs.py
plugins/templates/tabs.html
plugins/verticallayout.py

index 71f358d..cd653f8 100644 (file)
@@ -9,3 +9,16 @@ class Composite (Plugin):
     def insert (self, plugin):
         self.sons.append(plugin)
 
+    def render_env (self, request):
+        # this is designed so as to support a template like
+        # {% for son in sons %} {{ son.rendered }} ...
+        return { 'sons': 
+                 [ { 'rendered': son.render(request),
+                     'title': son.title(),
+                     'uuid': son.uuid}
+                   for son in self.sons ]}
+
+    # xxx need a way to select an active son, like e.g.
+    # Composite (active='some string')
+    # and we could then try to find that string in either title or uuid or some other place
+    # in which case the corresponding 'son' entry in render_env above would son.active=True
index 46e404b..4008e4f 100644 (file)
@@ -12,14 +12,4 @@ class Tabs (Composite):
     def template (self):
         return "tabs.html"
     
-    def render_env (self, request):
-        env = {}
-        sons_rendered = [ son.render(request) for son in self.sons ]
-        sons_titles = [ son.title() for son in self.sons ]
-        ids = range (len(self.sons))
-        # for now we don't have a title to pass
-        sons = [ { 'id':id, 'rendered':rendered, 'title':title } 
-                 for id,rendered,title in zip (ids, sons_rendered, sons_titles) ]
-        env['sons']=sons
-        return env
     
index e8de9eb..c9d792a 100644 (file)
@@ -1,13 +1,13 @@
 {# could try to set class='active' on the one we want to highlight #}
 <ul class="nav nav-tabs" id='{{ uuid }}'>
 {% for son in sons %}
-<li> <a href="#{{ son.uuid }}" data-toggle="tab"> son.title </a> </li>
+<li> <a href="#{{ son.uuid }}" data-toggle="tab">{{ son.title }}</a> </li>
 {% endfor %}
-</ul>
+</ul><!--nav-tabs-->
 <div class="tab-content">
 {% for son in sons %}
 <div class="tab-pane fade in" id="{{ son.uuid }}">
 {{ son.rendered }}
-</div>
+</div><!--tab-pane-->
 {% endfor %}
-</div>
+</div><!--tab-content-->
index eeb134d..6f97601 100644 (file)
@@ -7,15 +7,3 @@ class VerticalLayout (Composite) :
     def title (self) : return "VLayout title"
 
     def template (self):        return "verticallayout.html"
-
-    def render_env (self, request):
-        env = {}
-        sons_rendered = [ son.render(request) for son in self.sons ]
-        sons_titles = [ son.title() for son in self.sons ]
-        ids = range (len(self.sons))
-        # for now we don't have a title to pass
-        sons = [ { 'id':id, 'rendered':rendered, 'title':title } 
-                 for id,rendered,title in zip (ids, sons_rendered, sons_titles) ]
-        env['sons']=sons
-        return env
-