web/views/tabs.py
changeset 3230 1d25e928c299
parent 3035 2e4a381ea5b7
parent 3209 c2c8f88a4520
child 3408 c92170fca813
equal deleted inserted replaced
3199:fc63b80ec979 3230:1d25e928c299
    69     @property
    69     @property
    70     def cookie_name(self):
    70     def cookie_name(self):
    71         return str('%s_active_tab' % self.config.appid)
    71         return str('%s_active_tab' % self.config.appid)
    72 
    72 
    73     def active_tab(self, tabs, default):
    73     def active_tab(self, tabs, default):
       
    74         formtab = self.req.form.get('tab')
       
    75         if formtab in tabs:
       
    76             return formtab
    74         cookies = self.req.get_cookie()
    77         cookies = self.req.get_cookie()
    75         cookiename = self.cookie_name
    78         cookiename = self.cookie_name
    76         activetab = cookies.get(cookiename)
    79         activetab = cookies.get(cookiename)
    77         if activetab is None:
    80         if activetab is None:
    78             cookies[cookiename] = default
    81             cookies[cookiename] = default
   110         uid = entity and entity.eid or make_uid('tab')
   113         uid = entity and entity.eid or make_uid('tab')
   111         w(u'<div id="entity-tabs-%s">' % uid)
   114         w(u'<div id="entity-tabs-%s">' % uid)
   112         w(u'<ul>')
   115         w(u'<ul>')
   113         for tab in tabs:
   116         for tab in tabs:
   114             w(u'<li>')
   117             w(u'<li>')
   115             w(u'<a href="#as-%s">' % tab)
   118             w(u'<a href="#%s">' % tab)
   116             w(u'<span onclick="set_tab(\'%s\', \'%s\')">' % (tab, self.cookie_name))
   119             w(u'<span onclick="set_tab(\'%s\', \'%s\')">' % (tab, self.cookie_name))
   117             w(self.req._(tab))
   120             w(self.req._(tab))
   118             w(u'</span>')
   121             w(u'</span>')
   119             w(u'</a>')
   122             w(u'</a>')
   120             w(u'</li>')
   123             w(u'</li>')
   121         w(u'</ul>')
   124         w(u'</ul>')
   122         w(u'</div>')
   125         w(u'</div>')
   123         for tab in tabs:
   126         for tab in tabs:
   124             w(u'<div id="as-%s">' % tab)
   127             w(u'<div id="%s">' % tab)
   125             if entity:
   128             if entity:
   126                 self.lazyview(tab, eid=entity.eid)
   129                 self.lazyview(tab, eid=entity.eid)
   127             else:
   130             else:
   128                 self.lazyview(tab, static=True)
   131                 self.lazyview(tab, static=True)
   129             w(u'</div>')
   132             w(u'</div>')
   151         __select__ = EntityRelationView.__select__ & implements('Project')
   154         __select__ = EntityRelationView.__select__ & implements('Project')
   152         rtype = 'screenshot'
   155         rtype = 'screenshot'
   153         role = 'subject'
   156         role = 'subject'
   154         vid = 'gallery'
   157         vid = 'gallery'
   155 
   158 
   156     in this example, entities related to project entity by the'screenshot'
   159     in this example, entities related to project entity by the 'screenshot'
   157     relation (where the project is subject of the relation) will be displayed
   160     relation (where the project is subject of the relation) will be displayed
   158     using the 'gallery' view.
   161     using the 'gallery' view.
   159     """
   162     """
   160     __select__ = EntityView.__select__ & partial_has_related_entities()
   163     __select__ = EntityView.__select__ & partial_has_related_entities()
   161     vid = 'list'
   164     vid = 'list'