From f77ca9c3c47d641e9c773944d402ded9c8c1e715 Mon Sep 17 00:00:00 2001 From: omsaggau Date: Tue, 17 Oct 2023 12:45:08 +0200 Subject: [PATCH] Make part config optional in keyfigure part --- src/main/resources/site/parts/keyFigure/keyFigure.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/resources/site/parts/keyFigure/keyFigure.ts b/src/main/resources/site/parts/keyFigure/keyFigure.ts index a9beba88b..d52a4e2de 100644 --- a/src/main/resources/site/parts/keyFigure/keyFigure.ts +++ b/src/main/resources/site/parts/keyFigure/keyFigure.ts @@ -52,7 +52,6 @@ function renderPart( if (!page) throw Error('No page found') const config = getComponent()?.config - if (!config) throw Error('No part found') const showPreviewDraft: boolean = hasWritePermissionsAndPreview(req, page._id) @@ -78,16 +77,16 @@ function renderPart( }) as Array } - return renderKeyFigure(page, config, keyFigures, keyFiguresDraft, showPreviewDraft, req) + return renderKeyFigure(page, keyFigures, keyFiguresDraft, showPreviewDraft, req, config) } function renderKeyFigure( page: Content, - config: KeyFigurePartConfig, parsedKeyFigures: Array, parsedKeyFiguresDraft: Array | null, showPreviewDraft: boolean, - req: XP.Request + req: XP.Request, + config?: KeyFigurePartConfig ): XP.Response { const draftExist = !!parsedKeyFiguresDraft if ((parsedKeyFigures && parsedKeyFigures.length > 0) || draftExist) { @@ -112,8 +111,8 @@ function renderKeyFigure( }) : undefined, sourceLabel: getPhrases(page).source, - source: config && config.source, - columns: config && config.columns, + source: config?.source, + columns: !!config?.columns, showPreviewDraft, paramShowDraft: req.params.showDraft, draftExist,