(core) Fix changing type of source column from choice to choicelist

Summary: Updates the summary column type correctly, rebuilds the table model

Test Plan: Added a python unit test, tested manually in browser

Reviewers: dsagal

Reviewed By: dsagal

Differential Revision: https://phab.getgrist.com/D2973
This commit is contained in:
Alex Hall
2021-08-11 19:45:24 +02:00
parent ba1e919d39
commit 0d1a285129
4 changed files with 100 additions and 7 deletions

View File

@@ -91,6 +91,21 @@ def _update_sort_spec(sort_spec, old_table, new_table):
return ''
def summary_groupby_col_type(source_type):
"""
Returns the type of a groupby column in a summary table
given the type of the corresponding column in the source table.
Most types are returned unchanged.
When a source table is grouped by a list-type (RefList/ChoiceList) column
the column is 'flattened' into the corresponding non-list type
in the summary table.
"""
if source_type == 'ChoiceList':
return 'Choice'
else:
return source_type.replace('RefList:', 'Ref:')
class SummaryActions(object):
def __init__(self, useractions, docmodel):
@@ -126,8 +141,7 @@ class SummaryActions(object):
col=c,
isFormula=False,
formula='',
type='Choice' if c.type == 'ChoiceList' else
c.type.replace('RefList:', 'Ref:')
type=summary_groupby_col_type(c.type)
)
for c in source_groupby_columns
]