web/views/basecomponents.py
changeset 2381 caad2367d940
parent 2234 1fbcf202882d
parent 2313 2940c2341ae4
child 2476 1294a6bdf3bf
equal deleted inserted replaced
2374:ea1a44e4ad62 2381:caad2367d940
     9 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
     9 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
    10 """
    10 """
    11 __docformat__ = "restructuredtext en"
    11 __docformat__ = "restructuredtext en"
    12 _ = unicode
    12 _ = unicode
    13 
    13 
       
    14 from logilab.mtconverter import xml_escape
    14 from rql import parse
    15 from rql import parse
    15 
    16 
    16 from cubicweb.selectors import yes, two_etypes_rset, match_form_params
    17 from cubicweb.selectors import yes, two_etypes_rset, match_form_params
    17 from cubicweb.schema import display_name
    18 from cubicweb.schema import display_name
    18 from cubicweb.common.uilib import html_escape, toggle_action
    19 from cubicweb.common.uilib import toggle_action
    19 from cubicweb.web import component
    20 from cubicweb.web import component
    20 from cubicweb.web.htmlwidgets import (MenuWidget, PopupBoxMenu, BoxSeparator,
    21 from cubicweb.web.htmlwidgets import (MenuWidget, PopupBoxMenu, BoxSeparator,
    21                                       BoxLink)
    22                                       BoxLink)
    22 
    23 
    23 VISIBLE_PROP_DEF = {
    24 VISIBLE_PROP_DEF = {
    45 <fieldset>
    46 <fieldset>
    46 <input type="text" id="rql" name="rql" value="%s"  title="%s" tabindex="%s" accesskey="q" class="searchField" />
    47 <input type="text" id="rql" name="rql" value="%s"  title="%s" tabindex="%s" accesskey="q" class="searchField" />
    47 <input type="submit" value="" class="rqlsubmit" tabindex="%s" />
    48 <input type="submit" value="" class="rqlsubmit" tabindex="%s" />
    48 </fieldset>
    49 </fieldset>
    49 ''' % (not self.propval('visible') and 'hidden' or '',
    50 ''' % (not self.propval('visible') and 'hidden' or '',
    50        self.build_url('view'), html_escape(rql), req._('full text or RQL query'), req.next_tabindex(),
    51        self.build_url('view'), xml_escape(rql), req._('full text or RQL query'), req.next_tabindex(),
    51         req.next_tabindex()))
    52         req.next_tabindex()))
    52         if self.req.search_state[0] != 'normal':
    53         if self.req.search_state[0] != 'normal':
    53             self.w(u'<input type="hidden" name="__mode" value="%s"/>'
    54             self.w(u'<input type="hidden" name="__mode" value="%s"/>'
    54                    % ':'.join(req.search_state[1]))
    55                    % ':'.join(req.search_state[1]))
    55         self.w(u'</form></div>')
    56         self.w(u'</form></div>')
   200                     select.add_type_restriction(select.selection[0], etype)
   201                     select.add_type_restriction(select.selection[0], etype)
   201                 newrql = rqlst.as_string(self.req.encoding, self.rset.args)
   202                 newrql = rqlst.as_string(self.req.encoding, self.rset.args)
   202                 url = self.build_url(rql=newrql, __restrrql=restrrql,
   203                 url = self.build_url(rql=newrql, __restrrql=restrrql,
   203                                      __restrtype=etype, __restrtypes=','.join(restrtypes))
   204                                      __restrtype=etype, __restrtypes=','.join(restrtypes))
   204                 html.append(u'<span><a href="%s">%s</a></span>' % (
   205                 html.append(u'<span><a href="%s">%s</a></span>' % (
   205                         html_escape(url), elabel))
   206                         xml_escape(url), elabel))
   206                 rqlst.recover()
   207                 rqlst.recover()
   207         if on_etype:
   208         if on_etype:
   208             url = self.build_url(rql=restrrql)
   209             url = self.build_url(rql=restrrql)
   209             html.insert(0, u'<span><a href="%s">%s</a></span>' % (
   210             html.insert(0, u'<span><a href="%s">%s</a></span>' % (
   210                     url, _('Any')))
   211                     url, _('Any')))