(core) Sending visible columns for not configured widgets

Summary:
Custom widgets will receive all visible columns when they are not configured.
This will make the existing configuration work without the need to pick columns.

Test Plan: updated tests

Reviewers: paulfitz

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D3259
pull/131/head
Jarosław Sadziński 2 years ago
parent 1c855537d6
commit e99122433a

@ -529,18 +529,11 @@ export function createViewSectionRec(this: ViewSectionRec, docModel: DocModel):
// if we have a saved configuration.
const request = this.columnsToMap();
const mapping = this.customDef.columnsMapping();
if (!request) {
if (!request || !mapping) {
return null;
}
// Convert simple column expressions (widget can just specify a name of a column) to a rich column definition.
const columnsToMap = request.map(r => new ColumnToMapImpl(r));
if (!mapping) {
// If we don't have mappings, return an empty object.
return columnsToMap.reduce((o: WidgetColumnMap, c) => {
o[c.name] = c.allowMultiple ? [] : null;
return o;
}, {});
}
const result: WidgetColumnMap = {};
// Prepare map of existing column, will need this for translating colRefs to colIds.
const colMap = new Map(this.columns().map(f => [f.id.peek(), f]));

Loading…
Cancel
Save