Skip to content

Commit

Permalink
fix perspective drag (#2300)
Browse files Browse the repository at this point in the history
Co-authored-by: Marc Skov Madsen <masma@orsted.dk>
  • Loading branch information
MarcSkovMadsen and Marc Skov Madsen authored May 10, 2021
1 parent 078c8b2 commit ffa98c1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
4 changes: 2 additions & 2 deletions panel/pane/perspective.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 34 additions & 1 deletion panel/tests/pane/test_perspective.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -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

0 comments on commit ffa98c1

Please sign in to comment.