Motion PDF improvements

- show motion export dialog for all users
- print recommendation in table of content lines in italic
- only print categories of filtered motions in table of content
- add page break after each (sub)category
- reduce font size for footer date
This commit is contained in:
Emanuel Schütze 2019-07-11 20:09:08 +02:00
parent 3fd519e0d4
commit 4e6eddef98
4 changed files with 47 additions and 55 deletions

View File

@ -356,18 +356,22 @@ export class PdfDocumentService {
const logoFooterLeftUrl = this.configService.instant<any>('logo_pdf_footer_L').path; const logoFooterLeftUrl = this.configService.instant<any>('logo_pdf_footer_L').path;
const logoFooterRightUrl = this.configService.instant<any>('logo_pdf_footer_R').path; const logoFooterRightUrl = this.configService.instant<any>('logo_pdf_footer_R').path;
let footerText = ''; let footerPageNumber = '';
if (showPage) { if (showPage) {
footerText += `${currentPage} / ${pageCount}`; footerPageNumber += `${currentPage} / ${pageCount}`;
if (showDate) { if (showDate) {
footerText += '\n'; footerPageNumber += '\n';
} }
} }
let footerDate = {};
if (showDate) { if (showDate) {
footerText += `${this.translate.instant('As of')}: ${new Date().toLocaleDateString( footerDate = {
this.translate.currentLang text: `${this.translate.instant('As of')}: ${new Date().toLocaleDateString(
)}`; this.translate.currentLang
)}`,
fontSize: 6
};
} }
// if there is a single logo, give it a lot of space // if there is a single logo, give it a lot of space
@ -402,7 +406,7 @@ export class PdfDocumentService {
// add the page number // add the page number
columns.push({ columns.push({
text: footerText, text: [footerPageNumber, footerDate],
style: 'footerPageNumber', style: 'footerPageNumber',
alignment: pageNumberPosition alignment: pageNumberPosition
}); });
@ -501,7 +505,7 @@ export class PdfDocumentService {
margin: [0, 10, 0, 0] margin: [0, 10, 0, 0]
}, },
footerPageNumber: { footerPageNumber: {
fontSize: 9, fontSize: 8,
margin: [0, 15, 0, 0], margin: [0, 15, 0, 0],
color: '#555' color: '#555'
}, },
@ -540,8 +544,7 @@ export class PdfDocumentService {
bold: false bold: false
}, },
tocHeaderRow: { tocHeaderRow: {
fontSize: 8, fontSize: 7
italics: true
}, },
tocSubEntry: { tocSubEntry: {
fontSize: pageSize === 'A5' ? 9 : 10, fontSize: pageSize === 'A5' ? 9 : 10,
@ -759,10 +762,11 @@ export class PdfDocumentService {
* *
* @returns {Object} An object for `DocDefinition` for `pdf-make`. * @returns {Object} An object for `DocDefinition` for `pdf-make`.
*/ */
public createTocLineInline(text: string): Object { public createTocLineInline(text: string, italics: boolean = false): Object {
return { return {
text: '\n' + text, text: '\n' + text,
style: StyleType.SUB_ENTRY style: StyleType.SUB_ENTRY,
italics: italics
}; };
} }

View File

@ -277,21 +277,19 @@
<mat-icon>local_offer</mat-icon> <mat-icon>local_offer</mat-icon>
<span translate>Tags</span> <span translate>Tags</span>
</button> </button>
<button mat-menu-item (click)="openExportDialog()"> </div>
<mat-icon>archive</mat-icon>
<span translate>Export</span> <button mat-menu-item (click)="openExportDialog()">
</button> <mat-icon>archive</mat-icon>
<span translate>Export</span>
</button>
<div *ngIf="perms.isAllowed('manage')">
<button mat-menu-item routerLink="import"> <button mat-menu-item routerLink="import">
<mat-icon>cloud_upload</mat-icon> <mat-icon>cloud_upload</mat-icon>
<span translate>Import</span> <span translate>Import</span>
</button> </button>
</div> </div>
<div *ngIf="!perms.isAllowed('manage')">
<button mat-menu-item (click)="directPdfExport()">
<mat-icon>archive</mat-icon>
<span translate>Export as PDF</span>
</button>
</div>
</div> </div>
<div *ngIf="isMultiSelect"> <div *ngIf="isMultiSelect">
<button mat-menu-item (click)="selectAll()"> <button mat-menu-item (click)="selectAll()">

View File

@ -20,7 +20,7 @@ import {
FileFormat, FileFormat,
ExportFormData ExportFormData
} from '../motion-export-dialog/motion-export-dialog.component'; } from '../motion-export-dialog/motion-export-dialog.component';
import { ViewMotion, LineNumberingMode, ChangeRecoMode } from 'app/site/motions/models/view-motion'; import { ViewMotion } from 'app/site/motions/models/view-motion';
import { ViewWorkflow } from 'app/site/motions/models/view-workflow'; import { ViewWorkflow } from 'app/site/motions/models/view-workflow';
import { ViewCategory } from 'app/site/motions/models/view-category'; import { ViewCategory } from 'app/site/motions/models/view-category';
import { ViewMotionBlock } from 'app/site/motions/models/view-motion-block'; import { ViewMotionBlock } from 'app/site/motions/models/view-motion-block';
@ -396,18 +396,6 @@ export class MotionListComponent extends BaseListViewComponent<ViewMotion> imple
return this.motionRepo.getExtendedStateLabel(motion); return this.motionRepo.getExtendedStateLabel(motion);
} }
/**
* Directly export all motions as pdf, using the current default config settings
*/
public directPdfExport(): void {
const lnMode = this.configService.instant<string>('motions_default_line_numbering') as LineNumberingMode;
const crMode = this.configService.instant<string>('motions_recommendation_text_mode') as ChangeRecoMode;
this.pdfExport.exportMotionCatalog(this.dataSource.source, {
lnMode: lnMode,
crMode: crMode
});
}
/** /**
* This function saves the selected view by changes. * This function saves the selected view by changes.
* *

View File

@ -123,26 +123,25 @@ export class MotionPdfCatalogService {
if (categories && categories.length) { if (categories && categories.length) {
const catTocBody = []; const catTocBody = [];
for (const category of categories.sort((a, b) => a.weight - b.weight)) { for (const category of categories.sort((a, b) => a.weight - b.weight)) {
catTocBody.push({
table: {
body: [
[
{
text: category.getTitle(),
style: !!category.parent ? 'tocSubcategoryTitle' : 'tocCategoryTitle'
}
]
]
},
layout: exportSubmitterRecommendation ? 'lightHorizontalLines' : 'noBorders'
});
// find out if the category has any motions // find out if the category has any motions
const motionToCurrentCat = motions.filter(motionIn => category === motionIn.category); const motionToCurrentCat = motions.filter(motionIn => category === motionIn.category);
if (motionToCurrentCat && motionToCurrentCat.length) { if (motionToCurrentCat && motionToCurrentCat.length) {
const tocBody = []; catTocBody.push({
table: {
body: [
[
{
text: category.getTitle(),
style: !!category.parent ? 'tocSubcategoryTitle' : 'tocCategoryTitle'
}
]
]
},
layout: exportSubmitterRecommendation ? 'lightHorizontalLines' : 'noBorders'
});
const tocBody = [];
for (const motion of motionToCurrentCat) { for (const motion of motionToCurrentCat) {
if (exportSubmitterRecommendation) { if (exportSubmitterRecommendation) {
tocBody.push(this.appendSubmittersAndRecommendation(motion, StyleType.CATEGORY_SECTION)); tocBody.push(this.appendSubmittersAndRecommendation(motion, StyleType.CATEGORY_SECTION));
@ -161,6 +160,8 @@ export class MotionPdfCatalogService {
catTocBody.push( catTocBody.push(
this.pdfService.createTocTableDef(tocBody, StyleType.CATEGORY_SECTION, layout, header) this.pdfService.createTocTableDef(tocBody, StyleType.CATEGORY_SECTION, layout, header)
); );
catTocBody.push(this.pdfService.getPageBreak());
} }
} }
@ -214,10 +215,11 @@ export class MotionPdfCatalogService {
return [ return [
{ text: this.translate.instant('Identifier'), style: 'tocHeaderRow' }, { text: this.translate.instant('Identifier'), style: 'tocHeaderRow' },
{ {
text: `${this.translate.instant('Title')} · ${this.translate.instant( style: 'tocHeaderRow',
'Submitters' text: [
)} · ${this.translate.instant('Recommendation')}`, `${this.translate.instant('Title')} · ${this.translate.instant('Submitters')} · `,
style: 'tocHeaderRow' { text: `${this.translate.instant('Recommendation')}`, italics: true }
]
}, },
{ text: this.translate.instant('Page'), style: 'tocHeaderRow', alignment: 'right' } { text: this.translate.instant('Page'), style: 'tocHeaderRow', alignment: 'right' }
]; ];
@ -246,7 +248,7 @@ export class MotionPdfCatalogService {
`${motion.id}`, `${motion.id}`,
style, style,
this.pdfService.createTocLineInline(submitterList), this.pdfService.createTocLineInline(submitterList),
this.pdfService.createTocLineInline(recommendation) this.pdfService.createTocLineInline(recommendation, true)
); );
} }
} }