(core) Raw renames

Summary:
A new way for renaming tables.

  - There is a new popup to rename section (where you can also rename the table)
  - Renaming/Deleting page doesn't modify/delete the table.
  - Renaming table can rename a page if the names match (and the page contains a section with that table).
  - User can rename table in Raw Data UI in two ways - either on the listing or by using the section name popup
  - As before, there is no way to change tableId - it is derived from a table name.
  - When the section name is empty the table name is shown instead.
  - White space for section name is allowed (to discuss) - so the user can just paste '   '.
  - Empty name for a page is not allowed (but white space is).
  - Some bugs related to deleting tables with attached summary tables (and with undoing this operation) were fixed (but not all of them yet).

Test Plan: Updated tests.

Reviewers: georgegevoian

Reviewed By: georgegevoian

Subscribers: georgegevoian

Differential Revision: https://phab.getgrist.com/D3360
This commit is contained in:
Jarosław Sadziński
2022-04-27 19:46:24 +02:00
parent 8a1cca629b
commit 6f00106d7c
37 changed files with 946 additions and 452 deletions

View File

@@ -49,7 +49,7 @@ LocaleCurrencyMap["SS"] = "SSP";
LocaleCurrencyMap["XK"] = "EUR";
const currenciesCodes = Object.values(LocaleCurrencyMap);
export function getCurrency(code: string) {
const currency = LocaleCurrency.getCurrency(code);
const currency = LocaleCurrency.getCurrency(code ?? 'en-US');
// Fallback to USD
return currency ?? DEFAULT_CURRENCY;
}

View File

@@ -38,7 +38,7 @@ export interface NumberFormatOptions extends FormatOptions {
}
export function getCurrency(options: NumberFormatOptions, docSettings: DocumentSettings): string {
return options.currency || docSettings.currency || LocaleCurrency.getCurrency(docSettings.locale);
return options.currency || docSettings.currency || LocaleCurrency.getCurrency(docSettings.locale ?? 'en-US');
}
export function buildNumberFormat(options: NumberFormatOptions, docSettings: DocumentSettings): Intl.NumberFormat {

View File

@@ -167,12 +167,14 @@ export class TableData extends ActionDispatcher implements SkippableRows {
* Given a column name, returns a function that takes a rowId and returns the value for that
* column of that row. The returned function is faster than getValue() calls.
*/
public getRowPropFunc(colId: string): undefined | UIRowFunc<CellValue|undefined> {
const colData = this._columns.get(colId);
if (!colData) { return undefined; }
const values = colData.values;
public getRowPropFunc(colId: string): UIRowFunc<CellValue|undefined> {
const rowMap = this._rowMap;
return function(rowId: UIRowId) { return values[rowMap.get(rowId as number)!]; };
return (rowId: UIRowId) => {
const colData = this._columns.get(colId);
if (!colData) { return undefined; }
const values = colData.values;
return values[rowMap.get(rowId as number)!];
};
}
// By default, no rows are skippable, all are kept.

View File

@@ -7,6 +7,12 @@ import {TableData} from "./TableData";
*/
export function isHiddenTable(tablesData: TableData, tableRef: UIRowId): boolean {
const tableId = tablesData.getValue(tableRef, 'tableId') as string|undefined;
return tablesData.getValue(tableRef, 'summarySourceTable') !== 0 ||
Boolean(tableId?.startsWith('GristHidden'));
return !isRawTable(tablesData, tableRef) || Boolean(tableId?.startsWith('GristHidden'));
}
/**
* Return whether a table identified by the rowId of its metadata record should be visible on Raw Data page.
*/
export function isRawTable(tablesData: TableData, tableRef: UIRowId): boolean {
return tablesData.getValue(tableRef, 'summarySourceTable') === 0;
}