Merge pull request #4774 from GabrielInTheWorld/pdf-checkbox

Implements checkboxes
This commit is contained in:
Emanuel Schütze 2019-06-27 22:44:49 +02:00 committed by GitHub
commit 964712c77d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 80 additions and 3 deletions

View File

@ -735,4 +735,24 @@ export class PdfDocumentService {
style: StyleType.SUB_ENTRY style: StyleType.SUB_ENTRY
}; };
} }
/**
* Draw a circle on its position on the paper
*
* @param y vertical offset
* @param size the size of the circle
* @returns an array containing one circle definition for pdfMake
*/
public drawCircle(y: number, size: number): object[] {
return [
{
type: 'ellipse',
x: 0,
y: y,
lineColor: 'black',
r1: size,
r2: size
}
];
}
} }

View File

@ -101,6 +101,11 @@ export class MotionPdfService {
): object { ): object {
// get the line length from the config // get the line length from the config
const lineLength = this.configService.instant<number>('motions_line_length'); const lineLength = this.configService.instant<number>('motions_line_length');
// whether to append checkboxes to follow the recommendation or not
const optionToFollowRecommendation = this.configService.instant<boolean>(
'motions_export_follow_recommendation'
);
let motionPdfContent = []; let motionPdfContent = [];
// Enforces that statutes should always have Diff Mode and no line numbers // Enforces that statutes should always have Diff Mode and no line numbers
@ -126,7 +131,13 @@ export class MotionPdfService {
motionPdfContent = [title, subtitle]; motionPdfContent = [title, subtitle];
if ((infoToExport && infoToExport.length > 0) || !infoToExport) { if ((infoToExport && infoToExport.length > 0) || !infoToExport) {
const metaInfo = this.createMetaInfoTable(motion, lineLength, crMode, infoToExport); const metaInfo = this.createMetaInfoTable(
motion,
lineLength,
crMode,
infoToExport,
optionToFollowRecommendation
);
motionPdfContent.push(metaInfo); motionPdfContent.push(metaInfo);
} }
@ -206,7 +217,8 @@ export class MotionPdfService {
motion: ViewMotion, motion: ViewMotion,
lineLength: number, lineLength: number,
crMode: ChangeRecoMode, crMode: ChangeRecoMode,
infoToExport?: InfoToExport[] infoToExport?: InfoToExport[],
optionToFollowRecommendation?: boolean
): object { ): object {
const metaTableBody = []; const metaTableBody = [];
@ -427,7 +439,7 @@ export class MotionPdfService {
if (columnChangeType.length > 0) { if (columnChangeType.length > 0) {
metaTableBody.push([ metaTableBody.push([
{ {
text: this.translate.instant('Summary of changes'), text: this.translate.instant('Summary of changes:'),
style: 'boldText' style: 'boldText'
}, },
{ {
@ -447,6 +459,41 @@ export class MotionPdfService {
} }
} }
// Checkboxes for resolution
if (optionToFollowRecommendation) {
metaTableBody.push([
{
text: `${this.translate.instant('Decision')}:`,
style: 'boldText'
},
{
margin: [5, 2, 0, 2],
columns: [
{
width: 8,
canvas: this.pdfDocumentService.drawCircle(6.5, 4)
},
{
width: 'auto',
text: this.translate.instant('As recommendation')
},
{
width: 20,
text: ''
},
{
width: 8,
canvas: this.pdfDocumentService.drawCircle(6.5, 4)
},
{
width: 'auto',
text: this.translate.instant('Divergent:')
}
]
}
]);
}
if (metaTableBody.length > 0) { if (metaTableBody.length > 0) {
return { return {
table: { table: {

View File

@ -383,3 +383,13 @@ def get_config_variables():
group="Motions", group="Motions",
subgroup="PDF export", subgroup="PDF export",
) )
yield ConfigVariable(
name="motions_export_follow_recommendation",
default_value=False,
label="Show checkbox to record decision",
input_type="boolean",
weight=379,
group="Motions",
subgroup="Export",
)