From 6e0739bc6281e079807dcb0f575ed8d2dd9caab5 Mon Sep 17 00:00:00 2001 From: Paul Friederichsen Date: Sat, 2 Jan 2021 18:20:46 -0600 Subject: [PATCH] Correct logic for adding blanks sections when numPerPage > 1 --- .../marker-generator/marker-generator.component.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/app/pages/marker-generator/marker-generator.component.ts b/src/app/pages/marker-generator/marker-generator.component.ts index 09c93704..6b7a659e 100644 --- a/src/app/pages/marker-generator/marker-generator.component.ts +++ b/src/app/pages/marker-generator/marker-generator.component.ts @@ -31,9 +31,9 @@ interface Page { * The marker number. */ value: string; - + type: 'Flower' | 'Nest'; - + /** * The marker image, as SVG source code. */ @@ -153,9 +153,10 @@ export class MarkerGeneratorComponent implements OnInit { const backgroundSVGPages = chunk(pages.map(p => p.backgroundSVG), numPerPage); - if (numPerPage > 1 && pages.length % 2) { - columnPages.push([...columnPages.pop(), []]); - backgroundSVGPages.push([...backgroundSVGPages.pop(), blankSVG]); + if (numPerPage > 1 && pages.length % numPerPage) { + const extraColumns = numPerPage - (pages.length % numPerPage); + columnPages.push([...columnPages.pop(), ...new Array(extraColumns).fill([])]); + backgroundSVGPages.push([...backgroundSVGPages.pop(), ...new Array(extraColumns).fill(blankSVG)]); } const content: Content[] = columnPages.map((c, i, arr) => ({