export personal note pdf
This commit is contained in:
parent
5ace768427
commit
dc27a20842
@ -21,13 +21,16 @@
|
||||
</ng-container>
|
||||
|
||||
<ng-container class="meta-text-block-action-row">
|
||||
<button mat-icon-button *ngIf="!isCommentEdited(section)" (click)="editComment(section)">
|
||||
<button mat-icon-button *ngIf="!isCommentEdited(section)" (click)="editComment(section)"
|
||||
matTooltip="{{ 'Edit' | translate }}">
|
||||
<mat-icon>edit</mat-icon>
|
||||
</button>
|
||||
<button mat-icon-button *ngIf="isCommentEdited(section)" (click)="saveComment(section)">
|
||||
<button mat-icon-button *ngIf="isCommentEdited(section)" (click)="saveComment(section)"
|
||||
matTooltip="{{ 'Save' | translate }}">
|
||||
<mat-icon>save</mat-icon>
|
||||
</button>
|
||||
<button mat-icon-button *ngIf="isCommentEdited(section)" (click)="cancelEditing(section)">
|
||||
<button mat-icon-button *ngIf="isCommentEdited(section)" (click)="cancelEditing(section)"
|
||||
matTooltip="{{ 'Cancel edit' | translate }}">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
</ng-container>
|
||||
|
@ -21,13 +21,20 @@
|
||||
</ng-container>
|
||||
|
||||
<ng-container class="meta-text-block-action-row">
|
||||
<button mat-icon-button *ngIf="!isEditMode" (click)="editPersonalNote()">
|
||||
<button mat-icon-button *ngIf="!isEditMode" (click)="editPersonalNote()"
|
||||
matTooltip="{{ 'Edit' | translate }}">
|
||||
<mat-icon>edit</mat-icon>
|
||||
</button>
|
||||
<button mat-icon-button *ngIf="isEditMode" (click)="savePersonalNote()">
|
||||
<button mat-icon-button *ngIf="!isEditMode && personalNote" (click)="printPersonalNote()"
|
||||
matTooltip="{{ 'Export personal note only' | translate }}">
|
||||
<mat-icon>picture_as_pdf</mat-icon>
|
||||
</button>
|
||||
<button mat-icon-button *ngIf="isEditMode" (click)="savePersonalNote()"
|
||||
matTooltip="{{ 'Save' | translate }}">
|
||||
<mat-icon>save</mat-icon>
|
||||
</button>
|
||||
<button mat-icon-button *ngIf="isEditMode" (click)="isEditMode = false">
|
||||
<button mat-icon-button *ngIf="isEditMode" (click)="isEditMode = false"
|
||||
matTooltip="{{ 'Cancel edit' | translate }}">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
</ng-container>
|
||||
|
@ -4,9 +4,10 @@ import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { Subscription } from 'rxjs';
|
||||
|
||||
import { BaseComponent } from '../../../../base.component';
|
||||
import { ViewMotion } from '../../models/view-motion';
|
||||
import { PersonalNoteService } from 'app/core/ui-services/personal-note.service';
|
||||
import { MotionPdfExportService } from '../../services/motion-pdf-export.service';
|
||||
import { PersonalNoteContent } from 'app/shared/models/users/personal-note';
|
||||
import { PersonalNoteService } from 'app/core/ui-services/personal-note.service';
|
||||
import { ViewMotion } from '../../models/view-motion';
|
||||
|
||||
/**
|
||||
* Component for the motion comments view
|
||||
@ -65,7 +66,18 @@ export class PersonalNoteComponent extends BaseComponent implements OnDestroy {
|
||||
*/
|
||||
private personalNoteSubscription: Subscription;
|
||||
|
||||
public constructor(private personalNoteService: PersonalNoteService, formBuilder: FormBuilder) {
|
||||
/**
|
||||
* Constructor. Creates form
|
||||
*
|
||||
* @param personalNoteService
|
||||
* @param formBuilder
|
||||
* @param pdfService
|
||||
*/
|
||||
public constructor(
|
||||
private personalNoteService: PersonalNoteService,
|
||||
formBuilder: FormBuilder,
|
||||
private pdfService: MotionPdfExportService
|
||||
) {
|
||||
super();
|
||||
this.personalNoteForm = formBuilder.group({
|
||||
note: ['']
|
||||
@ -113,4 +125,11 @@ export class PersonalNoteComponent extends BaseComponent implements OnDestroy {
|
||||
this.personalNoteSubscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers a pdf export of the personal note
|
||||
*/
|
||||
public printPersonalNote(): void {
|
||||
this.pdfService.exportPersonalNote(this.personalNote, this.motion);
|
||||
}
|
||||
}
|
||||
|
@ -3,8 +3,9 @@ import { Injectable } from '@angular/core';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
|
||||
import { CsvExportService, CsvColumnDefinitionProperty } from 'app/core/ui-services/csv-export.service';
|
||||
import { ViewMotion } from '../models/view-motion';
|
||||
import { FileExportService } from 'app/core/ui-services/file-export.service';
|
||||
import { InfoToExport } from './motion-pdf.service';
|
||||
import { ViewMotion } from '../models/view-motion';
|
||||
|
||||
/**
|
||||
* Exports CSVs for motions. Collect all CSV types here to have them in one place.
|
||||
@ -32,7 +33,7 @@ export class MotionCsvExportService {
|
||||
* @param contentToExport content properties to export
|
||||
* @param infoToExport meta info to export
|
||||
*/
|
||||
public exportMotionList(motions: ViewMotion[], contentToExport: string[], infoToExport: string[]): void {
|
||||
public exportMotionList(motions: ViewMotion[], contentToExport: string[], infoToExport: InfoToExport[]): void {
|
||||
const propertyList = ['identifier', 'title'].concat(contentToExport, infoToExport);
|
||||
const exportProperties: CsvColumnDefinitionProperty<ViewMotion>[] = propertyList.map(option => {
|
||||
return { property: option } as CsvColumnDefinitionProperty<ViewMotion>;
|
||||
|
@ -3,7 +3,7 @@ import { Injectable } from '@angular/core';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
|
||||
import { ViewMotion, LineNumberingMode, ChangeRecoMode } from '../models/view-motion';
|
||||
import { MotionPdfService } from './motion-pdf.service';
|
||||
import { MotionPdfService, InfoToExport } from './motion-pdf.service';
|
||||
import { ConfigService } from 'app/core/ui-services/config.service';
|
||||
import { Category } from 'app/shared/models/motions/category';
|
||||
|
||||
@ -52,7 +52,7 @@ export class MotionPdfCatalogService {
|
||||
lnMode?: LineNumberingMode,
|
||||
crMode?: ChangeRecoMode,
|
||||
contentToExport?: string[],
|
||||
infoToExport?: string[]
|
||||
infoToExport?: InfoToExport[]
|
||||
): object {
|
||||
let doc = [];
|
||||
const motionDocList = [];
|
||||
|
@ -2,11 +2,12 @@ import { Injectable } from '@angular/core';
|
||||
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
|
||||
import { MotionPdfService } from './motion-pdf.service';
|
||||
import { MotionPdfService, InfoToExport } from './motion-pdf.service';
|
||||
import { PdfDocumentService } from 'app/core/ui-services/pdf-document.service';
|
||||
import { ViewMotion, LineNumberingMode, ChangeRecoMode } from '../models/view-motion';
|
||||
import { ConfigService } from 'app/core/ui-services/config.service';
|
||||
import { MotionPdfCatalogService } from './motion-pdf-catalog.service';
|
||||
import { PersonalNoteContent } from 'app/shared/models/users/personal-note';
|
||||
|
||||
/**
|
||||
* Export service to handle various kind of exporting necessities.
|
||||
@ -61,7 +62,7 @@ export class MotionPdfExportService {
|
||||
lnMode?: LineNumberingMode,
|
||||
crMode?: ChangeRecoMode,
|
||||
contentToExport?: string[],
|
||||
infoToExport?: string[]
|
||||
infoToExport?: InfoToExport[]
|
||||
): void {
|
||||
const doc = this.pdfCatalogService.motionListToDocDef(motions, lnMode, crMode, contentToExport, infoToExport);
|
||||
const filename = this.translate.instant(this.configService.instant<string>('motions_export_title'));
|
||||
@ -84,4 +85,20 @@ export class MotionPdfExportService {
|
||||
};
|
||||
this.pdfDocumentService.downloadLandscape(doc, filename, metadata);
|
||||
}
|
||||
|
||||
/**
|
||||
* Exports the given personalNote with some short information about the
|
||||
* motion the note refers to
|
||||
*
|
||||
* @param note
|
||||
* @param motion
|
||||
*/
|
||||
public exportPersonalNote(note: PersonalNoteContent, motion: ViewMotion): void {
|
||||
const doc = this.motionPdfService.textToDocDef(note.note, motion, 'Personal note');
|
||||
const filename = `${motion.identifierOrTitle} - ${this.translate.instant('Personal note')}`;
|
||||
const metadata = {
|
||||
title: filename
|
||||
};
|
||||
this.pdfDocumentService.download(doc, filename, metadata);
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,12 @@ import { ConfigService } from 'app/core/ui-services/config.service';
|
||||
import { ChangeRecommendationRepositoryService } from 'app/core/repositories/motions/change-recommendation-repository.service';
|
||||
import { ViewUnifiedChange } from '../models/view-unified-change';
|
||||
import { HtmlToPdfService } from 'app/core/ui-services/html-to-pdf.service';
|
||||
|
||||
/**
|
||||
* Type declaring which strings are valid options for metainfos to be exported into a pdf
|
||||
*/
|
||||
export type InfoToExport = 'submitters' | 'state' | 'recommendation' | 'category' | 'block' | 'origin' | 'polls';
|
||||
|
||||
/**
|
||||
* Converts a motion to pdf. Can be used from the motion detail view or executed on a list of motions
|
||||
* Provides the public method `motionToDocDef(motion: Motion)` which should be convenient to use.
|
||||
@ -55,7 +61,7 @@ export class MotionPdfService {
|
||||
lnMode?: LineNumberingMode,
|
||||
crMode?: ChangeRecoMode,
|
||||
contentToExport?: string[],
|
||||
infoToExport?: string[]
|
||||
infoToExport?: InfoToExport[]
|
||||
): object {
|
||||
let motionPdfContent = [];
|
||||
|
||||
@ -145,7 +151,7 @@ export class MotionPdfService {
|
||||
* @param motion the target motion
|
||||
* @returns doc def for the meta infos
|
||||
*/
|
||||
private createMetaInfoTable(motion: ViewMotion, crMode: ChangeRecoMode, infoToExport?: string[]): object {
|
||||
private createMetaInfoTable(motion: ViewMotion, crMode: ChangeRecoMode, infoToExport?: InfoToExport[]): object {
|
||||
const metaTableBody = [];
|
||||
|
||||
// submitters
|
||||
@ -496,4 +502,30 @@ export class MotionPdfService {
|
||||
{ text: motion.motion_block ? motion.motion_block.title : '' }
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates pdfmake definitions for basic information about the motion and
|
||||
* comments or notes
|
||||
*
|
||||
* @param note string optionally containing html layout
|
||||
* @param motion the ViewMotion this note refers to
|
||||
* @param noteTitle additional heading to be used (will be translated)
|
||||
* @returns pdfMake definitions
|
||||
*/
|
||||
public textToDocDef(note: string, motion: ViewMotion, noteTitle: string): object {
|
||||
const title = this.createTitle(motion);
|
||||
const subtitle = this.createSubtitle(motion);
|
||||
const metaInfo = this.createMetaInfoTable(
|
||||
motion,
|
||||
this.configService.instant('motions_recommendation_text_mode'),
|
||||
['submitters', 'state', 'category']
|
||||
);
|
||||
const noteContent = this.htmlToPdfService.convertHtml(note);
|
||||
|
||||
const subHeading = {
|
||||
text: this.translate.instant(noteTitle),
|
||||
style: 'heading2'
|
||||
};
|
||||
return [title, subtitle, metaInfo, subHeading, noteContent];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user