From e99122433a236f86582c67d176c5ddeb1fd44314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaros=C5=82aw=20Sadzi=C5=84ski?= Date: Thu, 10 Feb 2022 13:31:14 +0100 Subject: [PATCH] (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 --- app/client/models/entities/ViewSectionRec.ts | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/app/client/models/entities/ViewSectionRec.ts b/app/client/models/entities/ViewSectionRec.ts index 9269c544..cfb73289 100644 --- a/app/client/models/entities/ViewSectionRec.ts +++ b/app/client/models/entities/ViewSectionRec.ts @@ -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]));