diff --git a/panel/pane/perspective.py b/panel/pane/perspective.py index 6e3fa496a2..28b32d7a6e 100644 --- a/panel/pane/perspective.py +++ b/panel/pane/perspective.py @@ -391,9 +391,9 @@ def _process_property_change(self, msg): if msg.get(prop): msg[prop] = [self._as_digit(col) for col in msg[prop]] if msg.get('sort'): - msg['sort'] = [[self._as_digit(col), d] for col, d in msg['sort']] + msg['sort'] = [[self._as_digit(col), *args] for col, *args in msg['sort']] if msg.get('filters'): - msg['filters'] = [[self._as_digit(col), e, val] for col, e, val in msg['filters']] + msg['filters'] = [[self._as_digit(col), *args] for col, *args in msg['filters']] if msg.get('aggregates'): msg['aggregates'] = {self._as_digit(col): agg for col, agg in msg['aggregates'].items()} return msg diff --git a/panel/tests/pane/test_perspective.py b/panel/tests/pane/test_perspective.py index 55d6f98039..44d12fcfdd 100644 --- a/panel/tests/pane/test_perspective.py +++ b/panel/tests/pane/test_perspective.py @@ -26,7 +26,7 @@ def test_perspective_int_cols(): assert model.sort == [['0', 'desc']] psp2 = Perspective(data) - + psp2._process_events({ 'columns': ['0'], 'row_pivots': ['0'], @@ -42,3 +42,36 @@ def test_perspective_int_cols(): assert psp2.aggregates == {0: 'mean'} assert psp2.sort == [[0, 'desc']] assert psp2.filters == [[0, '==', 'None']] + +def test_perspective_can_drag_to_filter(): + # Given + msg = {'filters': [['Curve', '==', None, 'integer', 'sum']]} + # When + actual = Perspective()._process_property_change(msg) + # Then + assert actual == msg + +def test_perspective_can_filter_to_value(): + # Given + msg = {'filters': [['Curve', '==', 4]]} + # When + actual = Perspective()._process_property_change(msg) + # Then + assert actual == msg + +def test_perspective_can_drag_to_sort(): + # Given + msg = {'sort': [['Curve']]} + # When + actual = Perspective()._process_property_change(msg) + # Then + assert actual == msg + +def test_perspective_can_sort_desc(): + # Given + msg = {'sort': [['Curve', 'desc']]} + # When + actual = Perspective()._process_property_change(msg) + # Then + assert actual == msg +