From 55f967a14b18f2f7aa2dc1edaa1c3b853b550d3a Mon Sep 17 00:00:00 2001 From: Maximilian Krambach Date: Tue, 12 Feb 2019 17:59:33 +0100 Subject: [PATCH] call list subheaders --- .../motions/services/motion-pdf.service.ts | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/client/src/app/site/motions/services/motion-pdf.service.ts b/client/src/app/site/motions/services/motion-pdf.service.ts index 3d3801303..7c5bb79d0 100644 --- a/client/src/app/site/motions/services/motion-pdf.service.ts +++ b/client/src/app/site/motions/services/motion-pdf.service.ts @@ -489,6 +489,8 @@ export class MotionPdfService { /** * Creates pdfMake definitions for the call list of given motions + * Any motions that are 'top level' (no sort_parent_id) will have their tags + * used as comma separated header titles in an extra row * * @param motions A list of motions * @returns definitions ready to be opened or exported via {@link PdfDocumentService} @@ -528,7 +530,32 @@ export class MotionPdfService { ] ]; - const callListRows = motions.map(motion => this.createCallListRow(motion)); + const callListRows: object[] = []; + let currentTitle = ''; + + motions.map(motion => { + if (!motion.sort_parent_id) { + const heading = motion.tags ? motion.tags.map(tag => tag.name).join(', ') : ''; + if (heading !== currentTitle) { + callListRows.push([ + { + text: heading, + colSpan: 6, + style: 'heading3', + margin: [0, 10, 0, 10] + }, + '', + '', + '', + '', + '' + ]); + currentTitle = heading; + } + } + callListRows.push(this.createCallListRow(motion)); + }); + const table: object = { table: { widths: ['auto', 'auto', 'auto', '*', 'auto', 'auto'],