--- a/web/views/facets.py Wed Jul 08 10:34:31 2009 +0200
+++ b/web/views/facets.py Wed Jul 08 12:51:04 2009 +0200
@@ -16,7 +16,8 @@
match_context_prop, yes, relation_possible)
from cubicweb.web.box import BoxTemplate
from cubicweb.web.facet import (AbstractFacet, FacetStringWidget, RelationFacet,
- prepare_facets_rqlst, filter_hiddens)
+ prepare_facets_rqlst, filter_hiddens, _cleanup_rqlst,
+ _prepare_vocabulary_rqlst)
@objectify_selector
def contextview_selector(cls, req, rset=None, row=None, col=None, view=None,
@@ -163,6 +164,18 @@
return
self.rqlst.add_type_restriction(self.filtered_variable, value)
+ def possible_values(self):
+ """return a list of possible values (as string since it's used to
+ compare to a form value in javascript) for this facet
+ """
+ rqlst = self.rqlst
+ rqlst.save_state()
+ try:
+ _cleanup_rqlst(rqlst, self.filtered_variable)
+ _prepare_vocabulary_rqlst(rqlst, self.filtered_variable, self.rtype, self.role)
+ return [x.name for x in self.rqlexec(rqlst.as_string()).entities()]
+ finally:
+ rqlst.recover()
class HasTextFacet(AbstractFacet):
__select__ = relation_possible('has_text', 'subject') & match_context_prop()