[search box] allow to specify domid in select arguments. Closes #2162166

needed when one want to display search box twice in a page (eg logilabfr)

authorSylvain Thénault <sylvain.thenault@logilab.fr>
changeset7d658ea27ec5
branchdefault
phasepublic
hiddenno
parent revision#166ad5458ed8 [migractions] fix comment to avoid ambiguity. Closes #2015260
child revision#9be5625b1c34 [book] Fix typos in rql datetime functions documentation
files modified by this revision
web/data/cubicweb.css
web/views/boxes.py
# HG changeset patch
# User Sylvain Thénault <sylvain.thenault@logilab.fr>
# Date 1327586318 -3600
# Thu Jan 26 14:58:38 2012 +0100
# Node ID 7d658ea27ec53584f33a3e5269720ae50b911b9d
# Parent 166ad5458ed853cc568f77ee3722066a68b48f53
[search box] allow to specify domid in select arguments. Closes #2162166

needed when one want to display search box twice in a page (eg logilabfr)

diff --git a/web/data/cubicweb.css b/web/data/cubicweb.css
@@ -570,11 +570,11 @@
1    height: 20px;
2    background: %(buttonBgColor)s url("go.png") 50% 50% no-repeat;
3    vertical-align: bottom;
4  }
5 
6 -input#norql{
7 +input.norql{
8    width:155px;
9    margin-right: 2px;
10  }
11 
12  /* user actions menu */
diff --git a/web/views/boxes.py b/web/views/boxes.py
@@ -134,17 +134,17 @@
13      """display a box with a simple search form"""
14      __regid__ = 'search_box'
15 
16      title = _('search')
17      order = 0
18 -    formdef = u"""<form action="%s">
19 -<table id="tsearch"><tr><td>
20 -<input id="norql" type="text" accesskey="q" tabindex="%s" title="search text" value="%s" name="rql" />
21 +    formdef = u"""<form action="%(action)s">
22 +<table id="%(id)s"><tr><td>
23 +<input class="norql" type="text" accesskey="q" tabindex="%(tabindex1)s" title="search text" value="%(value)s" name="rql" />
24  <input type="hidden" name="__fromsearchbox" value="1" />
25  <input type="hidden" name="subvid" value="tsearch" />
26  </td><td>
27 -<input tabindex="%s" type="submit" id="rqlboxsubmit" class="rqlsubmit" value="" />
28 +<input tabindex="%(tabindex2)s" type="submit" class="rqlsubmit" value="" />
29   </td></tr></table>
30   </form>"""
31 
32      def render_title(self, w):
33          w(u"""<span onclick="javascript: toggleVisibility('rqlinput')">%s</span>"""
@@ -153,12 +153,17 @@
34      def render_body(self, w):
35          if self._cw.form.pop('__fromsearchbox', None):
36              rql = self._cw.form.get('rql', '')
37          else:
38              rql = ''
39 -        w(self.formdef % (self._cw.build_url('view'), self._cw.next_tabindex(),
40 -                          xml_escape(rql), self._cw.next_tabindex()))
41 +        tabidx1 = self._cw.next_tabindex()
42 +        tabidx2 = self._cw.next_tabindex()
43 +        w(self.formdef % {'action': self._cw.build_url('view'),
44 +                          'value': xml_escape(rql),
45 +                          'id': self.cw_extra_kwargs.get('domid', 'tsearch'),
46 +                          'tabindex1': tabidx1,
47 +                          'tabindex2': tabidx2})
48 
49 
50  # boxes disabled by default ###################################################
51 
52  class PossibleViewsBox(component.CtxComponent):