From 2800bcfd3f4696dd0640faf36048e89e98ca8ad9 Mon Sep 17 00:00:00 2001 From: anbebe Date: Wed, 18 Dec 2024 11:27:12 +0100 Subject: [PATCH] Add pdf export of all avisible mendments in diff view --- .../motion-view/motion-view.component.ts | 11 +++++-- .../motion-format.service.ts | 12 ++++++-- .../motion-export.service.ts | 1 + .../motion-pdf.service/motion-pdf.service.ts | 30 ++++++++++++++----- 4 files changed, 41 insertions(+), 13 deletions(-) diff --git a/client/src/app/site/pages/meetings/pages/motions/pages/motion-detail/pages/motion-view/components/motion-view/motion-view.component.ts b/client/src/app/site/pages/meetings/pages/motions/pages/motion-detail/pages/motion-view/components/motion-view/motion-view.component.ts index f04422a30f..083802dde6 100644 --- a/client/src/app/site/pages/meetings/pages/motions/pages/motion-detail/pages/motion-view/components/motion-view/motion-view.component.ts +++ b/client/src/app/site/pages/meetings/pages/motions/pages/motion-detail/pages/motion-view/components/motion-view/motion-view.component.ts @@ -43,6 +43,7 @@ import { AmendmentListFilterService } from '../../../../../../services/list/amen import { AmendmentListSortService } from '../../../../../../services/list/amendment-list-sort.service/amendment-list-sort.service'; import { MotionListFilterService } from '../../../../../../services/list/motion-list-filter.service/motion-list-filter.service'; import { MotionListSortService } from '../../../../../../services/list/motion-list-sort.service/motion-list-sort.service'; +import { MotionDetailViewService } from '../../../../services/motion-detail-view.service'; import { MotionDetailViewOriginUrlService } from '../../../../services/motion-detail-view-originurl.service'; @Component({ @@ -74,6 +75,10 @@ export class MotionViewComponent extends BaseMeetingComponent implements OnInit, return this.unifiedChanges$.value; } + public get showAllChanges(): boolean { + return this.motionDetailService.currentShowAllAmendmentsState; + } + /** * preloaded next motion for direct navigation */ @@ -143,7 +148,8 @@ export class MotionViewComponent extends BaseMeetingComponent implements OnInit, private changeRecoRepo: MotionChangeRecommendationControllerService, private cd: ChangeDetectorRef, private pdfExport: MotionPdfExportService, - private originUrlService: MotionDetailViewOriginUrlService + private originUrlService: MotionDetailViewOriginUrlService, + private motionDetailService: MotionDetailViewService ) { super(); @@ -321,7 +327,8 @@ export class MotionViewComponent extends BaseMeetingComponent implements OnInit, : this.lineNumberingMode, crMode: this.changeRecoMode, // export all comment fields as well as personal note - comments: this.motion.usedCommentSectionIds.concat([PERSONAL_NOTE_ID]) + comments: this.motion.usedCommentSectionIds.concat([PERSONAL_NOTE_ID]), + showAllChanges: this.showAllChanges }); } diff --git a/client/src/app/site/pages/meetings/pages/motions/services/common/motion-format.service/motion-format.service.ts b/client/src/app/site/pages/meetings/pages/motions/services/common/motion-format.service/motion-format.service.ts index a8038be15c..6508fac6c4 100644 --- a/client/src/app/site/pages/meetings/pages/motions/services/common/motion-format.service/motion-format.service.ts +++ b/client/src/app/site/pages/meetings/pages/motions/services/common/motion-format.service/motion-format.service.ts @@ -42,6 +42,7 @@ interface DifferedViewArguments extends Arguments { * The first line affected for a motion or a unified change */ firstLine: number; + showAllChanges: boolean; } interface FormatMotionConfig extends Arguments { @@ -57,6 +58,7 @@ interface FormatMotionConfig extends Arguments { * The first line affected for a motion or a unified change */ firstLine?: number; + showAllChanges?: boolean; } @Injectable({ @@ -96,7 +98,11 @@ export class MotionFormatService { throw new Error(`unrecognized ChangeRecoMode option (${crMode})`); } - return fn(targetMotion, { ...args, firstLine: args.firstLine || targetMotion.start_line_number }); + return fn(targetMotion, { + ...args, + firstLine: args.firstLine || targetMotion.start_line_number, + showAllChanges: args.showAllChanges + }); } public getUnifiedChanges(motion: ViewMotion, lineLength: number): ViewUnifiedChange[] { @@ -216,9 +222,9 @@ export class MotionFormatService { }; private getDiffView = (targetMotion: MotionFormattingRepresentation, args: DifferedViewArguments): string => { - const { changes, lineLength, highlightedLine, firstLine }: DifferedViewArguments = args; + const { changes, lineLength, highlightedLine, firstLine, showAllChanges }: DifferedViewArguments = args; const text: string[] = []; - const changesToShow = changes.filter(change => change.showInDiffView()); + const changesToShow = changes.filter(change => change.showInDiffView() || showAllChanges); const motionText = this.lineNumberingService.insertLineNumbers({ html: targetMotion.text, lineLength, diff --git a/client/src/app/site/pages/meetings/pages/motions/services/export/motion-export.service/motion-export.service.ts b/client/src/app/site/pages/meetings/pages/motions/services/export/motion-export.service/motion-export.service.ts index 0984f42d49..629323d95f 100644 --- a/client/src/app/site/pages/meetings/pages/motions/services/export/motion-export.service/motion-export.service.ts +++ b/client/src/app/site/pages/meetings/pages/motions/services/export/motion-export.service/motion-export.service.ts @@ -20,6 +20,7 @@ export interface MotionExportInfo { metaInfo?: InfoToExport[]; pdfOptions?: string[]; comments?: number[]; + showAllChanges?: boolean; } @Injectable({ diff --git a/client/src/app/site/pages/meetings/pages/motions/services/export/motion-pdf.service/motion-pdf.service.ts b/client/src/app/site/pages/meetings/pages/motions/services/export/motion-pdf.service/motion-pdf.service.ts index 7c95c52843..78f96ef007 100644 --- a/client/src/app/site/pages/meetings/pages/motions/services/export/motion-pdf.service/motion-pdf.service.ts +++ b/client/src/app/site/pages/meetings/pages/motions/services/export/motion-pdf.service/motion-pdf.service.ts @@ -38,6 +38,7 @@ interface CreateTextData { crMode: ChangeRecoMode; lineHeight: number; onlyChangedLines?: boolean; + showAllChanges?: boolean; } interface MotionToDocDefData { @@ -106,6 +107,7 @@ export class MotionPdfService { const infoToExport = exportInfo ? exportInfo.metaInfo : null; const contentToExport = exportInfo ? exportInfo.content : null; let commentsToExport = exportInfo ? exportInfo.comments : null; + const showAllChanges = exportInfo ? exportInfo.showAllChanges : null; // get the line length from the config const lineLength = this.meetingSettingsService.instant(`motions_line_length`) as number; @@ -140,7 +142,8 @@ export class MotionPdfService { lineLength, crMode, infoToExport, - optionToFollowRecommendation + optionToFollowRecommendation, + showAllChanges ); motionPdfContent.push(metaInfo); } @@ -157,7 +160,8 @@ export class MotionPdfService { lnMode, crMode, lineHeight, - onlyChangedLines + onlyChangedLines, + showAllChanges }); motionPdfContent.push(text); } @@ -251,7 +255,8 @@ export class MotionPdfService { lineLength: number, crMode: ChangeRecoMode, infoToExport: InfoToExport[] | null | undefined, - optionToFollowRecommendation?: boolean + optionToFollowRecommendation?: boolean, + showAllChanges?: boolean ): Content { const metaTableBody = []; @@ -529,13 +534,13 @@ export class MotionPdfService { } else if (change.getChangeType() === ViewUnifiedChangeType.TYPE_AMENDMENT) { const amendment = change as ViewMotionAmendedParagraph; let summaryText = `(${this.translate.instant(`Amendment`)} ${amendment.getNumber()}) -`; - if (amendment.isRejected()) { - summaryText += ` ${this.translate.instant(`Rejected`)}`; - } else if (amendment.isAccepted()) { + if (showAllChanges || amendment.isAccepted()) { summaryText += ` ${this.translate.instant(amendment.stateName)}`; // only append line and change, if the merge of the state of the amendment is accepted. columnLineNumbers.push(`${this.translate.instant(`Line`)} ${line} `); columnChangeType.push(summaryText); + } else if (amendment.isRejected()) { + summaryText += ` ${this.translate.instant(`Rejected`)}`; } } } @@ -635,7 +640,15 @@ export class MotionPdfService { * @param crMode determine the used change Recommendation mode * @returns doc def for the "the assembly may decide" preamble */ - private createText({ crMode, lineHeight, lineLength, lnMode, motion, onlyChangedLines }: CreateTextData): Content { + private createText({ + crMode, + lineHeight, + lineLength, + lnMode, + motion, + onlyChangedLines, + showAllChanges + }: CreateTextData): Content { let htmlText = ``; if (motion.isParagraphBasedAmendment()) { @@ -680,7 +693,8 @@ export class MotionPdfService { crMode, changes: textChanges, lineLength, - firstLine: motion.firstLine + firstLine: motion.firstLine, + showAllChanges: showAllChanges }); // reformat motion text to split long HTML elements to easier convert into PDF htmlText += this.linenumberingService.splitInlineElementsAtLineBreaks(formattedText);