From 995fa7af321f256ee92f0deb1752091ca312f33d Mon Sep 17 00:00:00 2001 From: Sean Engelhardt Date: Thu, 4 Apr 2019 13:22:12 +0200 Subject: [PATCH] Motion Amendments into PDF Support Amendments of initial motions in PDF --- .../motions/motion-repository.service.ts | 9 +++++++++ .../motion-detail/motion-detail.component.ts | 4 +++- .../app/site/motions/services/motion-pdf.service.ts | 12 ++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/client/src/app/core/repositories/motions/motion-repository.service.ts b/client/src/app/core/repositories/motions/motion-repository.service.ts index 884493ff4..e89011518 100644 --- a/client/src/app/core/repositories/motions/motion-repository.service.ts +++ b/client/src/app/core/repositories/motions/motion-repository.service.ts @@ -429,6 +429,15 @@ export class MotionRepositoryService extends BaseAgendaContentObjectRepository motion.parent_id === motionId); + } + /** * Format the motion text using the line numbering and change * reco algorithm. diff --git a/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.ts b/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.ts index 14ce9e3d8..23d844b4b 100644 --- a/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.ts +++ b/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.ts @@ -515,9 +515,11 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit, * Merges amendments and change recommendations and sorts them by the line numbers. * Called each time one of these arrays changes. * - * TODO: 1. Having logic in a service is bad practice + * TODO: 1. Having logic outside of a service is bad practice * 2. Manipulating class parameters without an subscription should * be avoided. It's safer and simpler to return values than to manipulate the scope + * 3. This have been used three times so far. Here, in the projector and in the PDF. Find an own + * service to put the logic into. */ private recalcUnifiedChanges(): void { if (!this.lineLength) { diff --git a/client/src/app/site/motions/services/motion-pdf.service.ts b/client/src/app/site/motions/services/motion-pdf.service.ts index 4f62ecb0f..3dc5149fe 100644 --- a/client/src/app/site/motions/services/motion-pdf.service.ts +++ b/client/src/app/site/motions/services/motion-pdf.service.ts @@ -504,6 +504,18 @@ export class MotionPdfService { [], this.changeRecoRepo.getChangeRecoOfMotion(motion.id) ); + + // TODO: Cleanup, everything change reco and amendment based needs a unified structure. + const amendments = this.motionRepo.getAmendmentsInstantly(motion.id); + if (amendments) { + for (const amendment of amendments) { + const changedParagraphs = this.motionRepo.getAmendmentAmendedParagraphs(amendment, lineLength); + for (const change of changedParagraphs) { + changes.push(change as ViewUnifiedChange); + } + } + } + // changes need to be sorted, by "line from". // otherwise, formatMotion will make unexpected results by messing up the // order of changes applied to the motion