Skip to content

Commit

Permalink
fix issue with automatic layout duplication (#964)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjosttveit authored Feb 28, 2023
1 parent 372885a commit 5343cc8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/features/pdf/data/generatePdfSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { PartyActions } from 'src/shared/resources/party/partySlice';
import { QueueActions } from 'src/shared/resources/queue/queueSlice';
import { TextResourcesActions } from 'src/shared/resources/textResources/textResourcesSlice';
import { getCurrentTaskDataElementId } from 'src/utils/appMetadata';
import { topLevelComponents } from 'src/utils/formLayout';
import { httpGet } from 'src/utils/network/networking';
import { pdfPreviewMode, shouldGeneratePdf } from 'src/utils/pdf';
import { getPdfFormatUrl } from 'src/utils/urls/appUrlHelper';
Expand Down Expand Up @@ -64,11 +65,14 @@ function generateAutomaticLayout(pdfFormat: IPdfFormat, uiConfig: IUiConfig, lay
.filter(([pageRef]) => !hiddenPages.has(pageRef))
.filter(([pageRef]) => pageOrder?.includes(pageRef))
.sort(([pA], [pB]) => (pageOrder ? pageOrder.indexOf(pA) - pageOrder.indexOf(pB) : 0))
.map(([pageRef, layout]) => [
pageRef,
topLevelComponents(layout ?? []).filter((component) => !excludedComponents.has(component.id)),
])
.flatMap(
([pageRef, components]) =>
([pageRef, components]: [string, ILayout]) =>
components?.map((component) => [pageRef, component]) as [string, ILayoutComponentOrGroup][],
)
.filter(([_, component]) => !excludedComponents.has(component.id))
.map(([pageRef, component]) => {
const layoutComponent = getLayoutComponentObject(component.type);

Expand Down

0 comments on commit 5343cc8

Please sign in to comment.