(core) Change 'Clear ... column' menu options to 'Reset', and make resetting columns reset type too

Summary:
The renaming is to clarify that the operation is more of a schema change, than
a data update. In particular, this is to reduce confusion why it is allowed to
anyone having Structure permission in Access Rules.

The resetting of type is a separate but related cleanup. Changing type to Any
returns the column to initial state, letting it guess type from new data, and
making it easy to enter a formula. It applies also to the "Clear and reset"
option in the Creator Panel.

Test Plan: Updated tests, added a check for type changing to Any.

Reviewers: jarek

Reviewed By: jarek

Differential Revision: https://phab.getgrist.com/D3685
This commit is contained in:
Dmitry S
2022-10-27 20:23:18 -04:00
parent d84e7e37e2
commit b263d83122
7 changed files with 35 additions and 23 deletions

View File

@@ -790,11 +790,18 @@ export class GristDoc extends DisposableWithEvents {
}
// Turn the given columns into empty columns, losing any data stored in them.
public async clearColumns(colRefs: number[]): Promise<void> {
public async clearColumns(colRefs: number[], {keepType}: {keepType?: boolean} = {}): Promise<void> {
await this.docModel.columns.sendTableAction(
['BulkUpdateRecord', colRefs, {
isFormula: colRefs.map(f => true),
formula: colRefs.map(f => ''),
...(keepType ? {} : {
type: colRefs.map(f => 'Any'),
widgetOptions: colRefs.map(f => ''),
visibleCol: colRefs.map(f => null),
displayCol: colRefs.map(f => null),
rules: colRefs.map(f => null),
}),
// Set recalc settings to defaults when emptying a column.
recalcWhen: colRefs.map(f => RecalcWhen.DEFAULT),
recalcDeps: colRefs.map(f => null),

View File

@@ -692,7 +692,7 @@ export class Importer extends DisposableWithEvents {
return [
menuItem(
async () => {
await this._gristDoc.clearColumns([sourceColId]);
await this._gristDoc.clearColumns([sourceColId], {keepType: true});
await this._updateImportDiff(info);
},
'Skip',