(core) Improving custom widget API. Changing destroy function signature.

Summary:
Destroy function in TableOperations was throwing error when invoked with a single
record id instead of an array. Now it returns a void type.

Also changing mapColumns function signature as it doesn't require options for a default
behavior.

Test Plan: Updated tests.

Reviewers: alexmojaki

Reviewed By: alexmojaki

Differential Revision: https://phab.getgrist.com/D3404
This commit is contained in:
Jarosław Sadziński
2022-05-05 13:42:50 +02:00
parent 1e42871cc9
commit db57815d2b
4 changed files with 14 additions and 17 deletions

View File

@@ -67,15 +67,12 @@ export class TableOperationsImpl implements TableOperations {
});
}
public destroy(recordId: Types.RecordId): Promise<Types.RecordId>;
public destroy(recordIds: Types.RecordId[]): Promise<Types.RecordId[]>;
public async destroy(recordIdOrRecordIds: Types.RecordId|Types.RecordId[]): Promise<Types.RecordId|Types.RecordId[]> {
return withRecords(recordIdOrRecordIds, async (recordIds) => {
public async destroy(recordIdOrRecordIds: Types.RecordId|Types.RecordId[]): Promise<void> {
await withRecords(recordIdOrRecordIds, async (recordIds) => {
const tableId = await this._platform.getTableId();
const actions = [['BulkRemoveRecord', tableId, recordIds]];
const sandboxRes = await this._applyUserActions(
tableId, [], actions);
return sandboxRes.retValues[0];
await this._applyUserActions(tableId, [], actions);
return [];
});
}