(core) Don't clear widget options when changing column type

Summary: Previously, changing the type of a column would clear its widget options and conditional style rules by default, with a few exceptions to explicitly keep them. This diff reverses that behaviour, keeping the options by default.

Test Plan: Updated several existing tests, plus lots of manual testing.

Reviewers: cyprien

Reviewed By: cyprien

Subscribers: dsagal

Differential Revision: https://phab.getgrist.com/D3491
This commit is contained in:
Alex Hall
2022-07-07 14:58:37 +02:00
parent 8469b7ded0
commit 77775401fc
3 changed files with 51 additions and 36 deletions

View File

@@ -104,7 +104,6 @@ class TestUserActions(test_engine.EngineTestCase):
self.assertPartialOutActions(out_actions, { "stored": [
['ModifyColumn', 'Schools', 'city', {'type': 'Ref:Address'}],
['UpdateRecord', 'Schools', 4, {'city': 0}],
['UpdateRecord', '_grist_Views_section_field', 1, {'widgetOptions': ''}],
['UpdateRecord', '_grist_Tables_column', 23, {
'type': 'Ref:Address', 'widgetOptions': 'world'
}],

View File

@@ -705,11 +705,10 @@ class UserActions(object):
if has_diff_value(values, 'colId', c.colId):
self._do_doc_action(actions.RenameColumn(c.parentId.tableId, c.colId, values['colId']))
# If we change a column's type, we should ALSO unset each affected field's widgetOptions and
# displayCol.
# If we change a column's type, we should ALSO unset each affected field's displayCol.
type_changed = [c for c, values in update_pairs if has_diff_value(values, 'type', c.type)]
self._docmodel.update([f for c in type_changed for f in c.viewFields],
widgetOptions='', displayCol=0)
displayCol=0)
self.doBulkUpdateFromPairs(table_id, update_pairs)
@@ -820,10 +819,8 @@ class UserActions(object):
# Look at the actual data for that column (first 1000 values) to decide on the type.
col_values['type'] = guess_type(self._get_column_values(col), convert=False)
# If changing the type of a column, unset its widgetOptions, displayCol and rules by default.
# If changing the type of a column, unset its displayCol by default.
if 'type' in col_values:
col_values.setdefault('widgetOptions', '')
col_values.setdefault('rules', None)
col_values.setdefault('displayCol', 0)
# Collect all updates for dependent summary columns.