8 |
8 |
9 from simplejson import dumps |
9 from simplejson import dumps |
10 |
10 |
11 from logilab.mtconverter import html_escape |
11 from logilab.mtconverter import html_escape |
12 |
12 |
|
13 from cubicweb.vregistry import objectify_selector |
13 from cubicweb.selectors import (chainfirst, chainall, non_final_entity, |
14 from cubicweb.selectors import (chainfirst, chainall, non_final_entity, |
14 two_lines_rset, match_context_prop, |
15 two_lines_rset, match_context_prop, |
15 yes, one_has_relation) |
16 yes, relation_possible) |
16 from cubicweb.web.box import BoxTemplate |
17 from cubicweb.web.box import BoxTemplate |
17 from cubicweb.web.facet import (AbstractFacet, VocabularyFacet, FacetStringWidget, |
18 from cubicweb.web.facet import (AbstractFacet, VocabularyFacet, FacetStringWidget, |
18 RelationFacet, prepare_facets_rqlst, filter_hiddens) |
19 RelationFacet, prepare_facets_rqlst, filter_hiddens) |
19 |
20 |
|
21 @objectify_selector |
20 def contextview_selector(cls, req, rset, row=None, col=None, view=None, |
22 def contextview_selector(cls, req, rset, row=None, col=None, view=None, |
21 **kwargs): |
23 **kwargs): |
22 if view and getattr(view, 'filter_box_context_info', lambda: None)(): |
24 if view and getattr(view, 'filter_box_context_info', lambda: None)(): |
23 return 1 |
25 return 1 |
24 return 0 |
26 return 0 |
25 |
27 |
26 |
28 |
27 class FilterBox(BoxTemplate): |
29 class FilterBox(BoxTemplate): |
28 """filter results of a query""" |
30 """filter results of a query""" |
29 id = 'filter_box' |
31 id = 'filter_box' |
30 __selectors__ = ((non_final_entity() & two_lines_rset) | contextview_selector, |
32 __select__ = (((non_final_entity() & two_lines_rset()) |
31 match_context_prop) |
33 | contextview_selector |
|
34 ) & match_context_prop) |
32 context = 'left' |
35 context = 'left' |
33 title = _('boxes_filter_box') |
36 title = _('boxes_filter_box') |
34 visible = True # functionality provided by the search box by default |
37 visible = True # functionality provided by the search box by default |
35 order = 1 |
38 order = 1 |
36 roundcorners = True |
39 roundcorners = True |