(core) Adds setSelectedRows to the grist api for custom view

Summary:
This is needed to let custom widget driver filtering of other widget in the same page.

Descripion here:
 - https://grist.quip.com/ctytAQJoFMsM/Hopefully-Small-Projects#temp:C:NNCfe2030b27647439886ca83595

Test Plan: New api tested in a new nbrowser test

Reviewers: paulfitz

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D3253
This commit is contained in:
Cyprien P
2022-02-01 20:51:40 +01:00
parent e264094412
commit 2f6eafff35
7 changed files with 58 additions and 7 deletions

View File

@@ -22,7 +22,7 @@ import {arrayRepeat} from 'app/common/gutil';
import {Sort} from 'app/common/SortSpec';
import {ColumnsToMap, WidgetColumnMap} from 'app/plugin/CustomSectionAPI';
import {ColumnToMapImpl} from 'app/client/models/ColumnToMap';
import {Computed} from 'grainjs';
import {Computed, Observable} from 'grainjs';
import * as ko from 'knockout';
import defaults = require('lodash/defaults');
@@ -159,6 +159,12 @@ export interface ViewSectionRec extends IRowModel<"_grist_Views_section"> {
// Temporary variable holding widget desired access (changed either from manifest or via API).
desiredAccessLevel: ko.Observable<AccessLevel|null>;
// Show widget as linking source. Used by custom widget.
allowSelectBy: Observable<boolean>;
// List of selected rows
selectedRows: Observable<number[]>;
// Save all filters of fields/columns in the section.
saveFilters(): Promise<void>;
@@ -562,4 +568,7 @@ export function createViewSectionRec(this: ViewSectionRec, docModel: DocModel):
}
return result;
});
this.allowSelectBy = Observable.create(this, false);
this.selectedRows = Observable.create(this, []);
}