(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

@@ -7,6 +7,7 @@
* FocusLayerManager will watch for this element to lose focus or to get disposed, and will
* restore focus to the default element.
*/
import * as Mousetrap from 'app/client/lib/Mousetrap';
import {arrayRemove} from 'app/common/gutil';
import {RefCountMap} from 'app/common/RefCountMap';
import {Disposable, dom} from 'grainjs';
@@ -21,7 +22,12 @@ export interface FocusLayerOptions {
defaultFocusElem: HTMLElement;
// When true for an element, that element may hold focus even while this layer is active.
allowFocus: (elem: Element) => boolean;
// Defaults to any element except document.body.
allowFocus?: (elem: Element) => boolean;
// If set, pause mousetrap keyboard shortcuts while this FocusLayer is active. Without it, arrow
// keys will navigate in a grid underneath this layer, and Enter may open a cell there.
pauseMousetrap?: boolean;
// Called when the defaultFocusElem gets focused.
onDefaultFocus?: () => void;
@@ -139,10 +145,20 @@ export class FocusLayer extends Disposable implements FocusLayerOptions {
constructor(options: FocusLayerOptions) {
super();
this.defaultFocusElem = options.defaultFocusElem;
this.allowFocus = options.allowFocus;
this.allowFocus = options.allowFocus || (elem => elem !== document.body);
this._onDefaultFocus = options.onDefaultFocus;
this._onDefaultBlur = options.onDefaultBlur;
// Make sure the element has a tabIndex attribute, to make it focusable.
if (!this.defaultFocusElem.hasAttribute('tabindex')) {
this.defaultFocusElem.setAttribute('tabindex', '-1');
}
if (options.pauseMousetrap) {
Mousetrap.setPaused(true);
this.onDispose(() => Mousetrap.setPaused(false));
}
const managerRefCount = this.autoDispose(_focusLayerManager.use(null));
const manager = managerRefCount.get();
manager.addLayer(this);