Merge pull request #4845 from emanuelschuetze/pdf-toc
Motion PDF improvements
This commit is contained in:
commit
d1ffea4fd7
@ -356,18 +356,22 @@ export class PdfDocumentService {
|
||||
const logoFooterLeftUrl = this.configService.instant<any>('logo_pdf_footer_L').path;
|
||||
const logoFooterRightUrl = this.configService.instant<any>('logo_pdf_footer_R').path;
|
||||
|
||||
let footerText = '';
|
||||
let footerPageNumber = '';
|
||||
if (showPage) {
|
||||
footerText += `${currentPage} / ${pageCount}`;
|
||||
footerPageNumber += `${currentPage} / ${pageCount}`;
|
||||
if (showDate) {
|
||||
footerText += '\n';
|
||||
footerPageNumber += '\n';
|
||||
}
|
||||
}
|
||||
|
||||
let footerDate = {};
|
||||
if (showDate) {
|
||||
footerText += `${this.translate.instant('As of')}: ${new Date().toLocaleDateString(
|
||||
this.translate.currentLang
|
||||
)}`;
|
||||
footerDate = {
|
||||
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
|
||||
@ -402,7 +406,7 @@ export class PdfDocumentService {
|
||||
|
||||
// add the page number
|
||||
columns.push({
|
||||
text: footerText,
|
||||
text: [footerPageNumber, footerDate],
|
||||
style: 'footerPageNumber',
|
||||
alignment: pageNumberPosition
|
||||
});
|
||||
@ -501,7 +505,7 @@ export class PdfDocumentService {
|
||||
margin: [0, 10, 0, 0]
|
||||
},
|
||||
footerPageNumber: {
|
||||
fontSize: 9,
|
||||
fontSize: 8,
|
||||
margin: [0, 15, 0, 0],
|
||||
color: '#555'
|
||||
},
|
||||
@ -540,8 +544,7 @@ export class PdfDocumentService {
|
||||
bold: false
|
||||
},
|
||||
tocHeaderRow: {
|
||||
fontSize: 8,
|
||||
italics: true
|
||||
fontSize: 7
|
||||
},
|
||||
tocSubEntry: {
|
||||
fontSize: pageSize === 'A5' ? 9 : 10,
|
||||
@ -759,10 +762,11 @@ export class PdfDocumentService {
|
||||
*
|
||||
* @returns {Object} An object for `DocDefinition` for `pdf-make`.
|
||||
*/
|
||||
public createTocLineInline(text: string): Object {
|
||||
public createTocLineInline(text: string, italics: boolean = false): Object {
|
||||
return {
|
||||
text: '\n' + text,
|
||||
style: StyleType.SUB_ENTRY
|
||||
style: StyleType.SUB_ENTRY,
|
||||
italics: italics
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -277,21 +277,19 @@
|
||||
<mat-icon>local_offer</mat-icon>
|
||||
<span translate>Tags</span>
|
||||
</button>
|
||||
<button mat-menu-item (click)="openExportDialog()">
|
||||
<mat-icon>archive</mat-icon>
|
||||
<span translate>Export</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<button mat-menu-item (click)="openExportDialog()">
|
||||
<mat-icon>archive</mat-icon>
|
||||
<span translate>Export</span>
|
||||
</button>
|
||||
|
||||
<div *ngIf="perms.isAllowed('manage')">
|
||||
<button mat-menu-item routerLink="import">
|
||||
<mat-icon>cloud_upload</mat-icon>
|
||||
<span translate>Import</span>
|
||||
</button>
|
||||
</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 *ngIf="isMultiSelect">
|
||||
<button mat-menu-item (click)="selectAll()">
|
||||
|
@ -20,7 +20,7 @@ import {
|
||||
FileFormat,
|
||||
ExportFormData
|
||||
} 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 { ViewCategory } from 'app/site/motions/models/view-category';
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
|
@ -123,26 +123,25 @@ export class MotionPdfCatalogService {
|
||||
if (categories && categories.length) {
|
||||
const catTocBody = [];
|
||||
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
|
||||
const motionToCurrentCat = motions.filter(motionIn => category === motionIn.category);
|
||||
|
||||
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) {
|
||||
if (exportSubmitterRecommendation) {
|
||||
tocBody.push(this.appendSubmittersAndRecommendation(motion, StyleType.CATEGORY_SECTION));
|
||||
@ -161,6 +160,8 @@ export class MotionPdfCatalogService {
|
||||
catTocBody.push(
|
||||
this.pdfService.createTocTableDef(tocBody, StyleType.CATEGORY_SECTION, layout, header)
|
||||
);
|
||||
|
||||
catTocBody.push(this.pdfService.getPageBreak());
|
||||
}
|
||||
}
|
||||
|
||||
@ -214,10 +215,11 @@ export class MotionPdfCatalogService {
|
||||
return [
|
||||
{ text: this.translate.instant('Identifier'), style: 'tocHeaderRow' },
|
||||
{
|
||||
text: `${this.translate.instant('Title')} · ${this.translate.instant(
|
||||
'Submitters'
|
||||
)} · ${this.translate.instant('Recommendation')}`,
|
||||
style: 'tocHeaderRow'
|
||||
style: 'tocHeaderRow',
|
||||
text: [
|
||||
`${this.translate.instant('Title')} · ${this.translate.instant('Submitters')} · `,
|
||||
{ text: `${this.translate.instant('Recommendation')}`, italics: true }
|
||||
]
|
||||
},
|
||||
{ text: this.translate.instant('Page'), style: 'tocHeaderRow', alignment: 'right' }
|
||||
];
|
||||
@ -246,7 +248,7 @@ export class MotionPdfCatalogService {
|
||||
`${motion.id}`,
|
||||
style,
|
||||
this.pdfService.createTocLineInline(submitterList),
|
||||
this.pdfService.createTocLineInline(recommendation)
|
||||
this.pdfService.createTocLineInline(recommendation, true)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user