Changeset 2272 in products for quintagroup.dropdownmenu


Ignore:
Timestamp:
May 7, 2010 2:11:41 PM (14 years ago)
Author:
chervol
Message:

improved the curentParent calculation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/browser/viewlets.py

    r2267 r2272  
    6969    def _subactions(self, category, object, level=0): 
    7070        tabs = [] 
     71        currentParentId = -1 
     72        index = -1 
     73        currentParent = False 
    7174        for info in self._actionInfos(category, object): 
    7275            # prepare data for action 
     
    7578            #       actions tabs are rendered separately 
    7679            currentItem = False 
    77             currentParent = False 
     80 
     81            index += 1 
    7882            icon = info['icon'] and '<img src="%s" />' % info['icon'] or '' 
    7983 
     
    9397                    if IActionCategory.providedBy(subcat): 
    9498                        children = self._subactions(subcat, object, level+1) 
    95                 url = self.context.absolute_url()         
    96                 if url.startswith(info['url']): 
    97                     currentParent = True 
    98                 if url == info['url']: 
    99                     currentItem = True 
     99 
     100            url = self.context.absolute_url()         
     101            if url.startswith(info['url']): 
     102                if currentParentId > -1: 
     103                    if len(tabs[currentParentId]['getURL']) < len(info['url']):  
     104                        currentParentId = index 
     105                else: 
     106                    currentParentId = index 
     107            if url == info['url']: 
     108                currentItem = True 
    100109            # make up final tab dictionary 
    101110            tab = {'Title': info['title'], 
     
    109118                   'normalized_review_state': 'visible'} 
    110119            tabs.append(tab) 
     120        if currentParentId > -1: 
     121            tabs[currentParentId]['currentParent'] = True 
    111122        return tabs 
    112123 
Note: See TracChangeset for help on using the changeset viewer.