Changeset 1084

Show
Ignore:
Timestamp:
03/11/08 07:39:17
Author:
piv
Message:

added switch visibility functionality

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/kssactions.zcml

    r1082 r1084  
    1111        /> 
    1212     
     13    <browser:page 
     14        for="plone.app.kss.interfaces.IPortalObject" 
     15        attribute="toggleActionsVisibility" 
     16        class=".plonetabs.PloneTabsControlPanel" 
     17        name="plonetabs-toggleActionsVisibility" 
     18        permission="cmf.ManagePortal" 
     19        /> 
     20     
     21    <browser:page 
     22        for="plone.app.kss.interfaces.IPortalObject" 
     23        attribute="toggleRootsVisibility" 
     24        class=".plonetabs.PloneTabsControlPanel" 
     25        name="plonetabs-toggleRootsVisibility" 
     26        permission="cmf.ManagePortal" 
     27        /> 
     28     
    1329</configure> 
  • qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/plonetabs.py

    r1082 r1084  
     1from Acquisition import aq_inner 
     2 
    13from zope.interface import implements 
    2 from zope.component import getUtility 
     4from zope.component import getUtility, getMultiAdapter 
    35from zope.i18n import translate 
    46from zope.schema.interfaces import IVocabularyFactory 
     
    79 
    810from Products.CMFCore.utils import getToolByName 
     11from Products.CMFCore.interfaces import IAction 
    912from Products.CMFEditions.setuphandlers import DEFAULT_POLICIES 
    1013from Products.CMFPlone import PloneMessageFactory as _ 
     
    1922from plone.app.workflow.remap import remap_workflow 
    2023from plone.memoize.instance import memoize 
    21 from kss.core import kssaction 
     24from kss.core import kssaction, KSSExplicitError 
    2225 
    2326from quintagroup.plonetabs.config import * 
     
    6366    def getPortalActions(self, category="portal_tabs"): 
    6467        """ See interface """ 
    65         return getToolByName(self.context, "portal_actions").listActions(categories=[category,]) 
     68        portal_actions = getToolByName(self.context, "portal_actions") 
     69         
     70        if category not in portal_actions.objectIds(): 
     71            return [] 
     72         
     73        actions = [] 
     74        for item in portal_actions[category].objectValues(): 
     75            if IAction.providedBy(item): 
     76                actions.append(item) 
     77         
     78        return actions 
    6679     
    6780    def isGeneratedTabs(self): 
     
    165178     
    166179    @kssaction 
    167     def toggleGeneratedTabs(self, field, checked="0"): 
     180    def toggleGeneratedTabs(self, field, checked='0'): 
    168181        """ Toggle autogenaration setting on configlet """ 
    169182         
    170183        changeProperties = getToolByName(self.context, "portal_properties").site_properties.manage_changeProperties 
    171         if checked == "1"
     184        if checked == '1'
    172185            changeProperties(**{field : False}) 
    173186        else: 
     
    180193        ksscore.replaceInnerHTML(ksscore.getHtmlIdSelector(replace_id), content, withKssSetup="True") 
    181194         
    182          
     195        # update global-sections viewlet 
    183196        self.updateGlobalSections(ksscore) 
    184197     
    185  
    186  
     198    @kssaction 
     199    def toggleActionsVisibility(self, id, checked='0', category=None): 
     200        """ Toggle visibility for portal actions """ 
     201        portal_actions = getToolByName(self.context, "portal_actions") 
     202         
     203        if category not in portal_actions.objectIds(): 
     204            raise KSSExplicitError, "Unexistent root portal actions category %s" % category 
     205         
     206        # remove prefix, added for making ids on configlet unique ("tabslist_") 
     207        act_id = id[len("tabslist_"):] 
     208         
     209        cat_container = portal_actions[category] 
     210        if act_id not in cat_container.objectIds(): 
     211            raise KSSExplicitError, "%s action does not exist in %s category" % (act_id, category) 
     212         
     213        if checked == '1': 
     214            checked = True 
     215        else: 
     216            checked = False 
     217         
     218        cat_container[act_id].visible = checked 
     219         
     220        ksscore = self.getCommandSet("core") 
     221        if checked: 
     222            ksscore.removeClass(ksscore.getHtmlIdSelector(id), value="invisible") 
     223        else: 
     224            ksscore.addClass(ksscore.getHtmlIdSelector(id), value="invisible") 
     225         
     226        # update global-sections viewlet 
     227        self.updateGlobalSections(ksscore) 
     228     
     229    @kssaction 
     230    def toggleRootsVisibility(self, id, checked='0'): 
     231        """ Toggle visibility for portal root objects (exclude_from_nav) """ 
     232        portal = getMultiAdapter((aq_inner(self.context), self.request), name='plone_portal_state').portal() 
     233         
     234        # remove prefix, added for making ids on configlet unique ("roottabs_") 
     235        obj_id = id[len("roottabs_"):] 
     236         
     237        if obj_id not in portal.objectIds(): 
     238            raise KSSExplicitError, "Object with %s id doesn't exist in portal root" % obj_id 
     239         
     240        if checked == '1': 
     241            checked = True 
     242        else: 
     243            checked = False 
     244         
     245        portal[obj_id].update(excludeFromNav=not checked) 
     246         
     247        ksscore = self.getCommandSet("core") 
     248        if checked: 
     249            ksscore.removeClass(ksscore.getHtmlIdSelector(id), value="invisible") 
     250        else: 
     251            ksscore.addClass(ksscore.getHtmlIdSelector(id), value="invisible") 
     252         
     253        # update global-sections viewlet 
     254        self.updateGlobalSections(ksscore) 
     255     
     256 
     257 
     258 
     259 
  • qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/resources/plonetabs.kss

    r1083 r1084  
    1111/* Add class to body to allow conditional styling when kss is available */ 
    1212 
     13#actions_category:load { 
     14    action-client: setStateVar; 
     15    setStateVar-varname: plonetabs-category; 
     16    setStateVar-value: currentFormVar(); 
     17} 
     18 
    1319#select_category:change { 
    1420    action-client: plonetabs-redirectTo; 
     
    1622} 
    1723 
    18 /* Hovering for IE especially */ 
     24/* Hovering for IE especially  
    1925#app li:mouseover { 
    2026    action-client: addClass; 
     
    2632    removeClass-value: onHover; 
    2733} 
    28 
     34*/ 
    2935 
    3036/* Automatically generated tabs */ 
     
    4046    plonetabs-toggleGeneratedTabs-checked: currentFormVar(); 
    4147} 
     48 
     49/* Visibility switching */ 
     50#tabslist .visibility:click { 
     51    action-server: plonetabs-toggleActionsVisibility; 
     52    plonetabs-toggleActionsVisibility-id: nodeAttr(id, true); 
     53    plonetabs-toggleActionsVisibility-checked: currentFormVar(); 
     54    plonetabs-toggleActionsVisibility-category: stateVar(plonetabs-category); 
     55} 
     56 
     57#roottabs .visibility:click { 
     58    action-server: plonetabs-toggleRootsVisibility; 
     59    plonetabs-toggleRootsVisibility-id: nodeAttr(id, true); 
     60    plonetabs-toggleRootsVisibility-checked: currentFormVar(); 
     61} 
  • qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/templates/autogenerated.pt

    r1082 r1084  
    1212<li tal:define="id tab/id; 
    1313                visible python:not tab['exclude_from_nav']" 
    14     tal:attributes="id string:tabslist_${id}; 
     14    tal:attributes="id string:roottabs_${id}; 
    1515                    title tab/description|nothing; 
    1616                    class python:view.test(visible, '', 'invisible')"> 
    17   <div class="bridge"><input type="checkbox" class="visibility" value="1" id="id" name="rootvis"  title="visibility" 
    18          tal:attributes="name string:i${repeat/tab/index}_${attrs/name}; 
    19                          id id; 
    20                          checked python:view.test(visible, 'checked', None)" /></div> 
     17  <div class="bridge"> 
     18    <input type="checkbox" class="visibility" value="1" name="rootvis"  title="visibility" 
     19           tal:attributes="name string:i${repeat/tab/index}_${attrs/name}; 
     20                           checked python:view.test(visible, 'checked', None)" /> 
     21  </div> 
    2122  <span class="url-helper" tal:content="python:tab['url']">Tab Action</span> 
    2223  <span class="tab-title"  tal:content="tab/name">Tab Name</span> 
  • qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/plugins/plugin.js

    r1082 r1084  
    1  
    2 /* Use onDOMLoad event to initialize kukit 
    3    earlier then the document is fully loaded, 
    4    but after the DOM is at its place already. 
    5  
    6    This functionality is missing from Plone 2.1, 
    7    the script is present in >=2.5, but it is not 
    8    always added to RR - it needs to be added manually. 
    9  
    10    If it's present we use it. 
    11 */ 
    121 
    132kukit.plonetabs = {};