Skip to content

Commit

Permalink
Make part config optional in keyfigure part (#2158)
Browse files Browse the repository at this point in the history
  • Loading branch information
omsaggau authored Oct 17, 2023
1 parent b4b8ee3 commit 6f746fc
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/main/resources/site/parts/keyFigure/keyFigure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ function renderPart(
if (!page) throw Error('No page found')

const config = getComponent<XP.PartComponent.KeyFigure>()?.config
if (!config) throw Error('No part found')

const showPreviewDraft: boolean = hasWritePermissionsAndPreview(req, page._id)

Expand All @@ -78,16 +77,16 @@ function renderPart(
}) as Array<KeyFigureData>
}

return renderKeyFigure(page, config, keyFigures, keyFiguresDraft, showPreviewDraft, req)
return renderKeyFigure(page, keyFigures, keyFiguresDraft, showPreviewDraft, req, config)
}

function renderKeyFigure(
page: Content,
config: KeyFigurePartConfig,
parsedKeyFigures: Array<KeyFigureData>,
parsedKeyFiguresDraft: Array<KeyFigureData> | null,
showPreviewDraft: boolean,
req: XP.Request
req: XP.Request,
config?: KeyFigurePartConfig
): XP.Response {
const draftExist = !!parsedKeyFiguresDraft
if ((parsedKeyFigures && parsedKeyFigures.length > 0) || draftExist) {
Expand All @@ -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,
Expand Down

0 comments on commit 6f746fc

Please sign in to comment.