web/views/facets.py
changeset 8551 6cf9e4da54a9
parent 8190 2a3c1b787688
child 9379 b0b1148b6963
equal deleted inserted replaced
8549:0740ffe73df1 8551:6cf9e4da54a9
    24 
    24 
    25 from logilab.mtconverter import xml_escape
    25 from logilab.mtconverter import xml_escape
    26 from logilab.common.decorators import cachedproperty
    26 from logilab.common.decorators import cachedproperty
    27 from logilab.common.registry import objectify_predicate, yes
    27 from logilab.common.registry import objectify_predicate, yes
    28 
    28 
       
    29 from cubicweb import tags
    29 from cubicweb.predicates import (non_final_entity, multi_lines_rset,
    30 from cubicweb.predicates import (non_final_entity, multi_lines_rset,
    30                                  match_context_prop, relation_possible)
    31                                  match_context_prop, relation_possible)
    31 from cubicweb.utils import json_dumps
    32 from cubicweb.utils import json_dumps
    32 from cubicweb.uilib import css_em_num_value
    33 from cubicweb.uilib import css_em_num_value
    33 from cubicweb.view import AnyRsetView
    34 from cubicweb.view import AnyRsetView
   232         assert len(rset) > 1
   233         assert len(rset) > 1
   233         if vid is None:
   234         if vid is None:
   234             vid = req.form.get('vid')
   235             vid = req.form.get('vid')
   235         if self.bk_linkbox_template and req.vreg.schema['Bookmark'].has_perm(req, 'add'):
   236         if self.bk_linkbox_template and req.vreg.schema['Bookmark'].has_perm(req, 'add'):
   236             w(self.bookmark_link(rset))
   237             w(self.bookmark_link(rset))
       
   238         w(self.focus_link(rset))
   237         hiddens = {}
   239         hiddens = {}
   238         for param in ('subvid', 'vtitle'):
   240         for param in ('subvid', 'vtitle'):
   239             if param in req.form:
   241             if param in req.form:
   240                 hiddens[param] = req.form[param]
   242                 hiddens[param] = req.form[param]
   241         self.generate_form(w, rset, divid, vid, paginate=paginate,
   243         self.generate_form(w, rset, divid, vid, paginate=paginate,
   267         bk_link = u'<a cubicweb:target="%s" id="facetBkLink" href="%s">%s</a>' % (
   269         bk_link = u'<a cubicweb:target="%s" id="facetBkLink" href="%s">%s</a>' % (
   268                 xml_escape(bk_base_url), xml_escape(bk_add_url),
   270                 xml_escape(bk_base_url), xml_escape(bk_add_url),
   269                 req._('bookmark this search'))
   271                 req._('bookmark this search'))
   270         return self.bk_linkbox_template % bk_link
   272         return self.bk_linkbox_template % bk_link
   271 
   273 
       
   274     def focus_link(self, rset):
       
   275         return self.bk_linkbox_template % tags.a(self._cw._('focus on this selection'),
       
   276                                                  href=self._cw.url(), id='focusLink')
   272 
   277 
   273 class FilterTable(FacetFilterMixIn, AnyRsetView):
   278 class FilterTable(FacetFilterMixIn, AnyRsetView):
   274     __regid__ = 'facet.filtertable'
   279     __regid__ = 'facet.filtertable'
   275     __select__ = has_facets()
   280     __select__ = has_facets()
   276     average_perfacet_uncomputable_overhead = .3
   281     average_perfacet_uncomputable_overhead = .3