Make facet methods chainable.
This commit is contained in:
parent
364bed871b
commit
a65ad6fce1
|
@ -70,13 +70,16 @@ class TextFacet(Facet):
|
||||||
if s['v']['v'] == value:
|
if s['v']['v'] == value:
|
||||||
return
|
return
|
||||||
self.selection.append({'v': {'v': value, 'l': value}})
|
self.selection.append({'v': {'v': value, 'l': value}})
|
||||||
|
return self
|
||||||
|
|
||||||
def exclude(self, value):
|
def exclude(self, value):
|
||||||
self.selection = [s for s in self.selection
|
self.selection = [s for s in self.selection
|
||||||
if s['v']['v'] != value]
|
if s['v']['v'] != value]
|
||||||
|
return self
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
self.selection = []
|
self.selection = []
|
||||||
|
return self
|
||||||
|
|
||||||
|
|
||||||
class StarredFacet(TextFacet):
|
class StarredFacet(TextFacet):
|
||||||
|
|
|
@ -79,6 +79,8 @@ class FacetTest(unittest.TestCase):
|
||||||
self.assertEqual(len(facet.selection), 1)
|
self.assertEqual(len(facet.selection), 1)
|
||||||
facet.reset()
|
facet.reset()
|
||||||
self.assertEqual(len(facet.selection), 0)
|
self.assertEqual(len(facet.selection), 0)
|
||||||
|
facet.include('element').include('element 2')
|
||||||
|
self.assertEqual(len(facet.selection), 2)
|
||||||
|
|
||||||
def test_reset_remove(self):
|
def test_reset_remove(self):
|
||||||
text_facet1 = TextFacet('column name')
|
text_facet1 = TextFacet('column name')
|
||||||
|
|
Loading…
Reference in New Issue