mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(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:
@@ -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
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user