mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Support 'new' row in anchor links.
Summary: - Anchor links with row of 'new' could be created but weren't parsed or used correctly. This fixes it. - Also adds UIRowId type for row IDs which includes the special 'new' row. It's already been used in places as `number|'new'`, this diff gives it a name usable in app/common (it doesn't touch another name, RowId, that's been available in app/client). Test Plan: Added a test assert for anchor links to new row Reviewers: alexmojaki Reviewed By: alexmojaki Differential Revision: https://phab.getgrist.com/D3039
This commit is contained in:
@@ -8,17 +8,18 @@ import * as BaseView from 'app/client/components/BaseView';
|
||||
import * as commands from 'app/client/components/commands';
|
||||
import * as BaseRowModel from 'app/client/models/BaseRowModel';
|
||||
import {LazyArrayModel} from 'app/client/models/DataTableModel';
|
||||
import type {RowId} from 'app/client/models/rowset';
|
||||
import {Disposable} from 'grainjs';
|
||||
import * as ko from 'knockout';
|
||||
|
||||
export interface CursorPos {
|
||||
rowId?: number;
|
||||
rowId?: RowId;
|
||||
rowIndex?: number;
|
||||
fieldIndex?: number;
|
||||
sectionId?: number;
|
||||
}
|
||||
|
||||
function nullAsUndefined(value: number|null|undefined): number|undefined {
|
||||
function nullAsUndefined<T>(value: T|null|undefined): T|undefined {
|
||||
return value == null ? undefined : value;
|
||||
}
|
||||
|
||||
@@ -66,7 +67,7 @@ export class Cursor extends Disposable {
|
||||
public rowIndex: ko.Computed<number|null>; // May be null when there are no rows.
|
||||
public fieldIndex: ko.Observable<number>;
|
||||
|
||||
private _rowId: ko.Observable<number|null>; // May be null when there are no rows.
|
||||
private _rowId: ko.Observable<RowId|null>; // May be null when there are no rows.
|
||||
|
||||
// The cursor's _rowId property is always fixed across data changes. When isLive is true,
|
||||
// the rowIndex of the cursor is recalculated to match _rowId. When false, they will
|
||||
|
||||
9
app/client/declarations.d.ts
vendored
9
app/client/declarations.d.ts
vendored
@@ -291,13 +291,14 @@ declare module "app/client/models/DataTableModel" {
|
||||
import {SortedRowSet} from "app/client/models/rowset";
|
||||
import {TableData} from "app/client/models/TableData";
|
||||
import * as TableModel from "app/client/models/TableModel";
|
||||
import {UIRowId} from "app/common/UIRowId";
|
||||
|
||||
namespace DataTableModel {
|
||||
interface LazyArrayModel<T> extends KoArray<T | null> {
|
||||
getRowId(index: number): number;
|
||||
getRowIndex(index: number): number;
|
||||
getRowIndexWithSub(rowId: number): number;
|
||||
getRowModel(rowId: number): T|undefined;
|
||||
getRowId(index: number): UIRowId;
|
||||
getRowIndex(rowId: UIRowId): number;
|
||||
getRowIndexWithSub(rowId: UIRowId): number;
|
||||
getRowModel(rowId: UIRowId): T|undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user