web/views/basecomponents.py
branchtls-sprint
changeset 658 b5c73b5cdc68
parent 652 603c782dc092
child 661 4f61eb8a96b7
equal deleted inserted replaced
657:fd019f41aa2f 658:b5c73b5cdc68
     3 * the rql input form
     3 * the rql input form
     4 * the logged user link
     4 * the logged user link
     5 * the workflow history section for workflowable objects
     5 * the workflow history section for workflowable objects
     6 
     6 
     7 :organization: Logilab
     7 :organization: Logilab
     8 :copyright: 2001-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     8 :copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     9 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
     9 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
    10 """
    10 """
    11 __docformat__ = "restructuredtext en"
    11 __docformat__ = "restructuredtext en"
    12 
    12 
    13 from rql import parse
    13 from rql import parse
    18 from cubicweb.schema import display_name
    18 from cubicweb.schema import display_name
    19 from cubicweb.common.selectors import (chainfirst, two_etypes_rset,
    19 from cubicweb.common.selectors import (chainfirst, two_etypes_rset,
    20                                     match_form_params)
    20                                     match_form_params)
    21 
    21 
    22 from cubicweb.web.htmlwidgets import MenuWidget, PopupBoxMenu, BoxSeparator, BoxLink
    22 from cubicweb.web.htmlwidgets import MenuWidget, PopupBoxMenu, BoxSeparator, BoxLink
    23 from cubicweb.web.component import (VComponent, SingletonVComponent, EntityVComponent, 
    23 from cubicweb.web.component import (VComponent, EntityVComponent, 
    24                                     RelatedObjectsVComponent)
    24                                     RelatedObjectsVComponent)
    25 
    25 
    26 _ = unicode
    26 _ = unicode
    27 
    27 
    28 
    28 
    29 class RQLInputForm(SingletonVComponent):
    29 class RQLInputForm(VComponent):
    30     """build the rql input form, usually displayed in the header"""
    30     """build the rql input form, usually displayed in the header"""
    31     id = 'rqlinput'
    31     id = 'rqlinput'
    32     visible = False
    32     visible = False
    33        
    33        
    34     def call(self, view=None):
    34     def call(self, view=None):
    53             self.w(u'<input type="hidden" name="__mode" value="%s"/>'
    53             self.w(u'<input type="hidden" name="__mode" value="%s"/>'
    54                    % ':'.join(req.search_state[1]))
    54                    % ':'.join(req.search_state[1]))
    55         self.w(u'</form></div>')
    55         self.w(u'</form></div>')
    56 
    56 
    57 
    57 
    58 class ApplLogo(SingletonVComponent):
    58 class ApplLogo(VComponent):
    59     """build the application logo, usually displayed in the header"""
    59     """build the application logo, usually displayed in the header"""
    60     id = 'logo'
    60     id = 'logo'
    61     site_wide = True # don't want user to hide this component using an eproperty
    61     site_wide = True # don't want user to hide this component using an eproperty
    62     def call(self):
    62     def call(self):
    63         self.w(u'<a href="%s"><img class="logo" src="%s" alt="logo"/></a>'
    63         self.w(u'<a href="%s"><img class="logo" src="%s" alt="logo"/></a>'
    64                % (self.req.base_url(), self.req.external_resource('LOGO')))
    64                % (self.req.base_url(), self.req.external_resource('LOGO')))
    65 
    65 
    66 
    66 
    67 class ApplHelp(SingletonVComponent):
    67 class ApplHelp(VComponent):
    68     """build the help button, usually displayed in the header"""
    68     """build the help button, usually displayed in the header"""
    69     id = 'help'
    69     id = 'help'
    70     def call(self):
    70     def call(self):
    71         self.w(u'<a href="%s" class="help" title="%s">&nbsp;</a>'
    71         self.w(u'<a href="%s" class="help" title="%s">&nbsp;</a>'
    72                % (self.build_url(_restpath='doc/main'),
    72                % (self.build_url(_restpath='doc/main'),
    73                   self.req._(u'help'),))
    73                   self.req._(u'help'),))
    74 
    74 
    75 
    75 
    76 class UserLink(SingletonVComponent):
    76 class UserLink(VComponent):
    77     """if the user is the anonymous user, build a link to login
    77     """if the user is the anonymous user, build a link to login
    78     else a link to the connected user object with a loggout link
    78     else a link to the connected user object with a loggout link
    79     """
    79     """
    80     id = 'loggeduserlink'
    80     id = 'loggeduserlink'
    81     site_wide = True # don't want user to hide this component using an eproperty
    81     site_wide = True # don't want user to hide this component using an eproperty
   112             self.w(self.req._('anonymous'))
   112             self.w(self.req._('anonymous'))
   113             self.w(u'&nbsp;[<a class="logout" href="%s">%s</a>]'
   113             self.w(u'&nbsp;[<a class="logout" href="%s">%s</a>]'
   114                    % (self.build_url('login'), self.req._('login')))
   114                    % (self.build_url('login'), self.req._('login')))
   115 
   115 
   116 
   116 
   117 class ApplicationMessage(SingletonVComponent):
   117 class ApplicationMessage(VComponent):
   118     """display application's messages given using the __message parameter
   118     """display application's messages given using the __message parameter
   119     into a special div section
   119     into a special div section
   120     """
   120     """
   121     __selectors__ = yes,
   121     __selectors__ = yes,
   122     id = 'applmessages'
   122     id = 'applmessages'
   167         if rset:
   167         if rset:
   168             self.wview('table', rset, title=_(self.title), displayactions=False,
   168             self.wview('table', rset, title=_(self.title), displayactions=False,
   169                        displaycols=displaycols, headers=headers)
   169                        displaycols=displaycols, headers=headers)
   170 
   170 
   171 
   171 
   172 class ApplicationName(SingletonVComponent):
   172 class ApplicationName(VComponent):
   173     """display the application name"""
   173     """display the application name"""
   174     id = 'appliname'
   174     id = 'appliname'
   175 
   175 
   176     def call(self):
   176     def call(self):
   177         self.w(u'<span id="appliName"><a href="%s">%s</a></span>' % (self.req.base_url(),
   177         self.w(u'<span id="appliName"><a href="%s">%s</a></span>' % (self.req.base_url(),
   188     # register msg not generated since no entity use see_also in cubicweb itself
   188     # register msg not generated since no entity use see_also in cubicweb itself
   189     title = _('contentnavigation_seealso')
   189     title = _('contentnavigation_seealso')
   190     help = _('contentnavigation_seealso_description')
   190     help = _('contentnavigation_seealso_description')
   191 
   191 
   192     
   192     
   193 class EtypeRestrictionComponent(SingletonVComponent):
   193 class EtypeRestrictionComponent(VComponent):
   194     """displays the list of entity types contained in the resultset
   194     """displays the list of entity types contained in the resultset
   195     to be able to filter accordingly.
   195     to be able to filter accordingly.
   196     """
   196     """
   197     id = 'etypenavigation'
   197     id = 'etypenavigation'
   198     __select__ = classmethod(chainfirst(two_etypes_rset, match_form_params))
   198     __select__ = classmethod(chainfirst(two_etypes_rset, match_form_params))