mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Cursor in custom widgets
Summary: Adding a new method `setCursorPos` in the widget API, and a new configuration option for the ready message `allowSelectBy` that exposes custom widgets in the `Select by` dropdown. With this, a custom widget can control the position of the linked widgets and is able to change the column in the creator panel. Test Plan: Added new test. Existing tests should pass. Reviewers: JakubSerafin Reviewed By: JakubSerafin Subscribers: JakubSerafin Differential Revision: https://phab.getgrist.com/D3993
This commit is contained in:
@@ -29,7 +29,6 @@ import {isHiddenTable, isSummaryTable} from 'app/common/isHiddenTable';
|
||||
import {canEdit} from 'app/common/roles';
|
||||
import {RowFilterFunc} from 'app/common/RowFilterFunc';
|
||||
import {schema, SchemaTypes} from 'app/common/schema';
|
||||
import {UIRowId} from 'app/common/TableData';
|
||||
import {ACLRuleRec, createACLRuleRec} from 'app/client/models/entities/ACLRuleRec';
|
||||
import {ColumnRec, createColumnRec} from 'app/client/models/entities/ColumnRec';
|
||||
import {createDocInfoRec, DocInfoRec} from 'app/client/models/entities/DocInfoRec';
|
||||
@@ -45,6 +44,7 @@ import {CellRec, createCellRec} from 'app/client/models/entities/CellRec';
|
||||
import {RefListValue} from 'app/common/gristTypes';
|
||||
import {decodeObject} from 'app/plugin/objtypes';
|
||||
import {toKo} from 'grainjs';
|
||||
import {UIRowId} from 'app/plugin/GristAPI';
|
||||
|
||||
// Re-export all the entity types available. The recommended usage is like this:
|
||||
// import {ColumnRec, ViewFieldRec} from 'app/client/models/DocModel';
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
* TODO: client-side should show "..." or "50000 more rows not shown" in that case.
|
||||
* TODO: Reference columns don't work properly because always use a displayCol which relies on formulas
|
||||
*/
|
||||
import {ClientColumnGettersByColId} from 'app/client/models/ClientColumnGetters';
|
||||
import DataTableModel from 'app/client/models/DataTableModel';
|
||||
import {DocModel} from 'app/client/models/DocModel';
|
||||
import {BaseFilteredRowSource, RowList, RowSource} from 'app/client/models/rowset';
|
||||
@@ -36,11 +37,11 @@ import {DocData} from 'app/common/DocData';
|
||||
import {nativeCompare} from 'app/common/gutil';
|
||||
import {IRefCountSub, RefCountMap} from 'app/common/RefCountMap';
|
||||
import {getLinkingFilterFunc, RowFilterFunc} from 'app/common/RowFilterFunc';
|
||||
import {TableData as BaseTableData, UIRowId} from 'app/common/TableData';
|
||||
import {TableData as BaseTableData} from 'app/common/TableData';
|
||||
import {tbind} from 'app/common/tbind';
|
||||
import {UIRowId} from 'app/plugin/GristAPI';
|
||||
import {Disposable, Holder, IDisposableOwnerT} from 'grainjs';
|
||||
import * as ko from 'knockout';
|
||||
import {ClientColumnGettersByColId} from 'app/client/models/ClientColumnGetters';
|
||||
import debounce = require('lodash/debounce');
|
||||
|
||||
// Limit on the how many rows to request for OnDemand tables.
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// tslint:disable:no-console
|
||||
// TODO: Add documentation and clean up log statements.
|
||||
|
||||
import {CursorPos} from 'app/client/components/Cursor';
|
||||
import {GristDoc} from 'app/client/components/GristDoc';
|
||||
import {PageRec, ViewFieldRec, ViewSectionRec} from 'app/client/models/DocModel';
|
||||
import {reportError} from 'app/client/models/errors';
|
||||
@@ -10,9 +9,10 @@ import {IDocPage} from 'app/common/gristUrls';
|
||||
import {nativeCompare, waitObs} from 'app/common/gutil';
|
||||
import {TableData} from 'app/common/TableData';
|
||||
import {BaseFormatter} from 'app/common/ValueFormatter';
|
||||
import { makeT } from 'app/client/lib/localization';
|
||||
import {CursorPos} from 'app/plugin/GristAPI';
|
||||
import {Computed, Disposable, Observable} from 'grainjs';
|
||||
import debounce = require('lodash/debounce');
|
||||
import { makeT } from 'app/client/lib/localization';
|
||||
|
||||
const t = makeT('SearchModel');
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import {ColumnRec, ViewFieldRec, ViewSectionRec} from 'app/client/models/DocMode
|
||||
import {TableData} from 'app/client/models/TableData';
|
||||
import {buildColFilter, ColumnFilterFunc} from 'app/common/ColumnFilterFunc';
|
||||
import {buildRowFilter, RowFilterFunc, RowValueFunc } from 'app/common/RowFilterFunc';
|
||||
import {UIRowId} from 'app/common/TableData';
|
||||
import {UIRowId} from 'app/plugin/GristAPI';
|
||||
import {Computed, Disposable, MutableObsArray, obsArray, Observable, UseCB} from 'grainjs';
|
||||
|
||||
export type {ColumnFilterFunc};
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import BaseView from 'app/client/components/BaseView';
|
||||
import {CursorPos} from 'app/client/components/Cursor';
|
||||
import {LinkingState} from 'app/client/components/LinkingState';
|
||||
import {KoArray} from 'app/client/lib/koArray';
|
||||
import {
|
||||
@@ -22,11 +21,11 @@ import {AccessLevel, ICustomWidget} from 'app/common/CustomWidget';
|
||||
import {UserAction} from 'app/common/DocActions';
|
||||
import {arrayRepeat} from 'app/common/gutil';
|
||||
import {Sort} from 'app/common/SortSpec';
|
||||
import {UIRowId} from 'app/common/TableData';
|
||||
import {ColumnsToMap, WidgetColumnMap} from 'app/plugin/CustomSectionAPI';
|
||||
import {ColumnToMapImpl} from 'app/client/models/ColumnToMap';
|
||||
import {BEHAVIOR} from 'app/client/models/entities/ColumnRec';
|
||||
import {removeRule, RuleOwner} from 'app/client/models/RuleOwner';
|
||||
import {CursorPos, UIRowId} from 'app/plugin/GristAPI';
|
||||
import {Computed, Holder, Observable} from 'grainjs';
|
||||
import * as ko from 'knockout';
|
||||
import defaults = require('lodash/defaults');
|
||||
@@ -192,10 +191,14 @@ export interface ViewSectionRec extends IRowModel<"_grist_Views_section">, RuleO
|
||||
desiredAccessLevel: ko.Observable<AccessLevel|null>;
|
||||
|
||||
// Show widget as linking source. Used by custom widget.
|
||||
allowSelectBy: Observable<boolean>;
|
||||
allowSelectBy: ko.Observable<boolean>;
|
||||
|
||||
// List of selected rows
|
||||
selectedRows: Observable<number[]>;
|
||||
// List of selected rows from a custom widget, or null if a filter shouldn't be applied.
|
||||
selectedRows: ko.Observable<number[]|null>;
|
||||
|
||||
// If the row filter is active (i.e. if selectedRows is non-null). Separate computed to avoid
|
||||
// re-computing the filter when selectedRows changes.
|
||||
selectedRowsActive: ko.Computed<boolean>;
|
||||
|
||||
editingFormula: ko.Computed<boolean>;
|
||||
|
||||
@@ -714,8 +717,9 @@ export function createViewSectionRec(this: ViewSectionRec, docModel: DocModel):
|
||||
return result;
|
||||
});
|
||||
|
||||
this.allowSelectBy = Observable.create(this, false);
|
||||
this.selectedRows = Observable.create(this, []);
|
||||
this.allowSelectBy = ko.observable(false);
|
||||
this.selectedRows = ko.observable(null as number[]|null);
|
||||
this.selectedRowsActive = this.autoDispose(ko.pureComputed(() => this.selectedRows() !== null));
|
||||
|
||||
this.tableId = this.autoDispose(ko.pureComputed(() => this.table().tableId()));
|
||||
const rawSection = this.autoDispose(ko.pureComputed(() => this.table().rawViewSection()));
|
||||
|
||||
@@ -24,8 +24,9 @@
|
||||
import koArray, {KoArray} from 'app/client/lib/koArray';
|
||||
import {DisposableWithEvents} from 'app/common/DisposableWithEvents';
|
||||
import {CompareFunc, sortedIndex} from 'app/common/gutil';
|
||||
import {SkippableRows, UIRowId} from 'app/common/TableData';
|
||||
import {SkippableRows} from 'app/common/TableData';
|
||||
import {RowFilterFunc} from "app/common/RowFilterFunc";
|
||||
import {UIRowId} from 'app/plugin/GristAPI';
|
||||
import {Observable} from 'grainjs';
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user