mirror of
				https://github.com/gristlabs/grist-core.git
				synced 2025-06-13 20:53:59 +00:00 
			
		
		
		
	(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:
		
							parent
							
								
									d84e7e37e2
								
							
						
					
					
						commit
						b263d83122
					
				@ -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),
 | 
			
		||||
 | 
			
		||||
@ -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',
 | 
			
		||||
 | 
			
		||||
@ -19,11 +19,13 @@ export function CellContextMenu(rowOptions: IRowContextMenu, colOptions: IMultiC
 | 
			
		||||
  const disableForReadonlyView = dom.cls('disabled', isReadonly);
 | 
			
		||||
 | 
			
		||||
  const numCols: number = colOptions.numColumns;
 | 
			
		||||
  const nameClearColumns = colOptions.isFiltered ? t("ClearEntireColumns", {count: numCols}) : t("ClearColumns", {count: numCols})
 | 
			
		||||
  const nameDeleteColumns = t("DeleteColumns", {count: numCols})
 | 
			
		||||
  const nameClearColumns = colOptions.isFiltered ?
 | 
			
		||||
    t("ResetEntireColumns", {count: numCols}) :
 | 
			
		||||
    t("ResetColumns", {count: numCols});
 | 
			
		||||
  const nameDeleteColumns = t("DeleteColumns", {count: numCols});
 | 
			
		||||
 | 
			
		||||
  const numRows: number = rowOptions.numRows;
 | 
			
		||||
  const nameDeleteRows = t("DeleteRows", {count: numRows})
 | 
			
		||||
  const nameDeleteRows = t("DeleteRows", {count: numRows});
 | 
			
		||||
 | 
			
		||||
  const nameClearCells = (numRows > 1 || numCols > 1) ? t('ClearValues') : t('ClearCell');
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -135,8 +135,8 @@ export function MultiColumnMenu(options: IMultiColumnContextMenu) {
 | 
			
		||||
  const disableForReadonlyView = dom.cls('disabled', options.isReadonly);
 | 
			
		||||
  const num: number = options.numColumns;
 | 
			
		||||
  const nameClearColumns = options.isFiltered ?
 | 
			
		||||
    t('ClearEntireColumns', {count: num}) :
 | 
			
		||||
    t('ClearColumns', {count: num});
 | 
			
		||||
    t('ResetEntireColumns', {count: num}) :
 | 
			
		||||
    t('ResetColumns', {count: num});
 | 
			
		||||
  const nameDeleteColumns = t('DeleteColumns', {count: num});
 | 
			
		||||
  const nameHideColumns = t('HideColumns', {count: num});
 | 
			
		||||
  const frozenMenu = options.disableFrozenMenu ? null : freezeMenuItemCmd(options);
 | 
			
		||||
 | 
			
		||||
@ -55,10 +55,10 @@
 | 
			
		||||
    "MemoryError": "Memory Error"
 | 
			
		||||
  },
 | 
			
		||||
  "CellContextMenu": {
 | 
			
		||||
    "ClearEntireColumns_one": "Clear entire column",
 | 
			
		||||
    "ClearEntireColumns_other": "Clear {{count}} entire columns",
 | 
			
		||||
    "ClearColumns_one": "Clear column",
 | 
			
		||||
    "ClearColumns_other": "Clear {{count}} columns",
 | 
			
		||||
    "ResetEntireColumns_one": "Reset entire column",
 | 
			
		||||
    "ResetEntireColumns_other": "Reset {{count}} entire columns",
 | 
			
		||||
    "ResetColumns_one": "Reset column",
 | 
			
		||||
    "ResetColumns_other": "Reset {{count}} columns",
 | 
			
		||||
    "DeleteColumns_one": "Delete column",
 | 
			
		||||
    "DeleteColumns_other": "Delete {{count}} columns",
 | 
			
		||||
    "DeleteRows_one": "Delete row",
 | 
			
		||||
@ -256,10 +256,10 @@
 | 
			
		||||
    "Sort": "Sort",
 | 
			
		||||
    "MoreSortOptions": "More sort options ...",
 | 
			
		||||
    "RenameColumn": "Rename column",
 | 
			
		||||
    "ClearEntireColumns_one": "Clear entire column",
 | 
			
		||||
    "ClearEntireColumns_other": "Clear {{count}} entire columns",
 | 
			
		||||
    "ClearColumns_one": "Clear column",
 | 
			
		||||
    "ClearColumns_other": "Clear {{count}} columns",
 | 
			
		||||
    "ResetEntireColumns_one": "Reset entire column",
 | 
			
		||||
    "ResetEntireColumns_other": "Reset {{count}} entire columns",
 | 
			
		||||
    "ResetColumns_one": "Reset column",
 | 
			
		||||
    "ResetColumns_other": "Reset {{count}} columns",
 | 
			
		||||
    "DeleteColumns_one": "Delete column",
 | 
			
		||||
    "DeleteColumns_other": "Delete {{count}} columns",
 | 
			
		||||
    "HideColumns_one": "Hide column",
 | 
			
		||||
 | 
			
		||||
@ -54,10 +54,10 @@
 | 
			
		||||
    "MemoryError": "Erreur mémoire"
 | 
			
		||||
  },
 | 
			
		||||
  "CellContextMenu": {
 | 
			
		||||
    "ClearEntireColumns_one": "Effacer la colonne entière",
 | 
			
		||||
    "ClearEntireColumns_other": "Effacer ces {{count}} colonnes entières",
 | 
			
		||||
    "ClearColumns_one": "Effacer la colonne",
 | 
			
		||||
    "ClearColumns_other": "Effacer {{count}} colonnes",
 | 
			
		||||
    "ResetEntireColumns_one": "Réinitialiser la colonne entière",
 | 
			
		||||
    "ResetEntireColumns_other": "Réinitialiser ces {{count}} colonnes entières",
 | 
			
		||||
    "ResetColumns_one": "Réinitialiser la colonne",
 | 
			
		||||
    "ResetColumns_other": "Réinitialiser {{count}} colonnes",
 | 
			
		||||
    "DeleteColumns_one": "Supprimer la colonne",
 | 
			
		||||
    "DeleteColumns_other": "Supprimer {{count}} colonnes",
 | 
			
		||||
    "DeleteRows_one": "Supprimer la ligne",
 | 
			
		||||
@ -255,10 +255,10 @@
 | 
			
		||||
    "Sort": "Trier",
 | 
			
		||||
    "MoreSortOptions": "Plus d’options de tri…",
 | 
			
		||||
    "RenameColumn": "Renommer la colonne",
 | 
			
		||||
    "ClearEntireColumns_one": "Effacer la colonne entière",
 | 
			
		||||
    "ClearEntireColumns_other": "Effacer {{count}} colonnes entières",
 | 
			
		||||
    "ClearColumns_one": "Effacer la colonne",
 | 
			
		||||
    "ClearColumns_other": "Effacer {{count}} colonnes",
 | 
			
		||||
    "ResetEntireColumns_one": "Réinitialiser la colonne entière",
 | 
			
		||||
    "ResetEntireColumns_other": "Réinitialiser {{count}} colonnes entières",
 | 
			
		||||
    "ResetColumns_one": "Réinitialiser la colonne",
 | 
			
		||||
    "ResetColumns_other": "Réinitialiser {{count}} colonnes",
 | 
			
		||||
    "DeleteColumns_one": "Supprimer la colonne",
 | 
			
		||||
    "DeleteColumns_other": "Supprimer {{count}} colonnes",
 | 
			
		||||
    "HideColumns_one": "Masquer la colonne",
 | 
			
		||||
 | 
			
		||||
@ -156,11 +156,14 @@ describe('MultiColumn', function() {
 | 
			
		||||
      ]);
 | 
			
		||||
      await selectColumns('Test1', 'Test3');
 | 
			
		||||
      assert.equal(await columnBehavior(), 'Formula Columns');
 | 
			
		||||
      await alignment('center');
 | 
			
		||||
      assert.equal(await alignment(), 'center');
 | 
			
		||||
 | 
			
		||||
      // Reset all of them
 | 
			
		||||
      assert.deepEqual(await gu.availableBehaviorOptions(), ['Convert columns to data', 'Clear and reset']);
 | 
			
		||||
      await gu.changeBehavior('Clear and reset');
 | 
			
		||||
      assert.equal(await columnBehavior(), 'Empty Columns');
 | 
			
		||||
      assert.equal(await alignment(), 'left');
 | 
			
		||||
 | 
			
		||||
      // Make them all data columns
 | 
			
		||||
      await gu.getCell('Test1', 1).click(); await gu.enterCell('a');
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user