From d4f211e34446c5ef6ee4dd5239f0bcebdd4f826d Mon Sep 17 00:00:00 2001 From: Sean Date: Mon, 8 Jun 2020 16:24:21 +0200 Subject: [PATCH] Fix error for freely editable amendments Recent changes to amendment had various bugs. This one regarded the amendment list, where amendments without amendmend paragraphs returned several errors. --- .../core/repositories/motions/motion-repository.service.ts | 6 +++--- .../modules/amendment-list/amendment-list.component.ts | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) 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 206d96f50..117e630d9 100644 --- a/client/src/app/core/repositories/motions/motion-repository.service.ts +++ b/client/src/app/core/repositories/motions/motion-repository.service.ts @@ -798,7 +798,7 @@ export class MotionRepositoryService extends BaseIsAgendaItemAndListOfSpeakersCo } }); - return amendment.amendment_paragraphs.map((newText: string, paraNo: number) => { + return amendment.amendment_paragraphs?.map((newText: string, paraNo: number) => { let paragraph: string; let paragraphHasChanges; @@ -866,7 +866,7 @@ export class MotionRepositoryService extends BaseIsAgendaItemAndListOfSpeakersCo } return amendmentParagraphs - .map( + ?.map( (newText: string, paraNo: number): DiffLinesInParagraph => { if (newText !== null) { return this.diff.getAmendmentParagraphsLines( @@ -937,7 +937,7 @@ export class MotionRepositoryService extends BaseIsAgendaItemAndListOfSpeakersCo const changedAmendmentParagraphs = this.applyChangesToAmendment(amendment, lineLength, changeRecos, false); return changedAmendmentParagraphs - .map( + ?.map( (newText: string, paraNo: number): ViewMotionAmendedParagraph => { if (newText === null) { return null; diff --git a/client/src/app/site/motions/modules/amendment-list/amendment-list.component.ts b/client/src/app/site/motions/modules/amendment-list/amendment-list.component.ts index 3f7fdf6ad..1fc8adfbd 100644 --- a/client/src/app/site/motions/modules/amendment-list/amendment-list.component.ts +++ b/client/src/app/site/motions/modules/amendment-list/amendment-list.component.ts @@ -134,12 +134,14 @@ export class AmendmentListComponent extends BaseListViewComponent im */ public getAmendmentSummary(amendment: ViewMotion): string { const diffLines = amendment.diffLines; - if (diffLines) { + if (diffLines.length) { return diffLines .map(diffLine => { return this.linenumberingService.stripLineNumbers(diffLine.text); }) .join('[...]'); + } else { + return amendment.text; } }