Merge pull request #5497 from tsiegleauq/fix-parent-motion-title-change-error

Cleaner pdf getUnifiedChanges solution
This commit is contained in:
Emanuel Schütze 2020-08-12 14:49:33 +02:00 committed by GitHub
commit a48592af50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -164,7 +164,7 @@ export class MotionPdfService {
private createTitle(motion: ViewMotion, crMode: ChangeRecoMode, lineLength: number): object { private createTitle(motion: ViewMotion, crMode: ChangeRecoMode, lineLength: number): object {
// summary of change recommendations (for motion diff version only) // summary of change recommendations (for motion diff version only)
const changes = this.getUnifiedChanges(motion, lineLength); const changes = this.getUnifiedChanges(motion, lineLength);
const titleChange = changes.find(change => change.isTitleChange()); const titleChange = changes.find(change => change?.isTitleChange());
const changedTitle = this.changeRecoRepo.getTitleWithChanges(motion.title, titleChange, crMode); const changedTitle = this.changeRecoRepo.getTitleWithChanges(motion.title, titleChange, crMode);
const identifier = motion.identifier ? ' ' + motion.identifier : ''; const identifier = motion.identifier ? ' ' + motion.identifier : '';
@ -630,26 +630,19 @@ export class MotionPdfService {
* @returns * @returns
*/ */
private getUnifiedChanges(motion: ViewMotion, lineLength: number): ViewUnifiedChange[] { private getUnifiedChanges(motion: ViewMotion, lineLength: number): ViewUnifiedChange[] {
const changeRecosOfMotion = this.changeRecoRepo.getChangeRecoOfMotion(motion.id); const motionChangeRecos = this.changeRecoRepo.getChangeRecoOfMotion(motion.id);
if (changeRecosOfMotion && changeRecosOfMotion.length) { const motionAmendments = this.motionRepo.getAmendmentsInstantly(motion.id).flatMap((amendment: ViewMotion) => {
return changeRecosOfMotion const changeRecos = this.changeRecoRepo
.concat( .getChangeRecoOfMotion(amendment.id)
this.motionRepo.getAmendmentsInstantly(motion.id).flatMap((amendment: ViewMotion) => { .filter(reco => reco.showInFinalView());
const changeRecos = this.changeRecoRepo return this.motionRepo.getAmendmentAmendedParagraphs(amendment, lineLength, changeRecos);
.getChangeRecoOfMotion(amendment.id) });
.filter(reco => reco.showInFinalView());
if (changeRecos && changeRecos.length) { return motionChangeRecos
return this.motionRepo.getAmendmentAmendedParagraphs(amendment, lineLength, changeRecos); .concat(motionAmendments)
} .filter(change => !!change)
}) .sort((a, b) => a.getLineFrom() - b.getLineFrom()) as ViewUnifiedChange[];
)
.sort((a, b) => {
return a.getLineFrom() - b.getLineFrom();
});
} else {
return [];
}
} }
/** /**