Merge pull request #4845 from emanuelschuetze/pdf-toc

Motion PDF improvements
This commit is contained in:
Emanuel Schütze 2019-07-13 13:08:53 +02:00 committed by GitHub
commit d1ffea4fd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 = {
text: `${this.translate.instant('As of')}: ${new Date().toLocaleDateString(
this.translate.currentLang 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>
</div>
<button mat-menu-item (click)="openExportDialog()"> <button mat-menu-item (click)="openExportDialog()">
<mat-icon>archive</mat-icon> <mat-icon>archive</mat-icon>
<span translate>Export</span> <span translate>Export</span>
</button> </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,6 +123,10 @@ 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)) {
// find out if the category has any motions
const motionToCurrentCat = motions.filter(motionIn => category === motionIn.category);
if (motionToCurrentCat && motionToCurrentCat.length) {
catTocBody.push({ catTocBody.push({
table: { table: {
body: [ body: [
@ -137,12 +141,7 @@ export class MotionPdfCatalogService {
layout: exportSubmitterRecommendation ? 'lightHorizontalLines' : 'noBorders' layout: exportSubmitterRecommendation ? 'lightHorizontalLines' : 'noBorders'
}); });
// find out if the category has any motions
const motionToCurrentCat = motions.filter(motionIn => category === motionIn.category);
if (motionToCurrentCat && motionToCurrentCat.length) {
const tocBody = []; 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)
); );
} }
} }