Catch and show line numbering errors

Makes line number and motion detail more robust
This commit is contained in:
Sean Engelhardt 2019-09-16 11:46:29 +02:00
parent ae55cce605
commit 1cf332b15c
2 changed files with 46 additions and 32 deletions

View File

@ -245,12 +245,20 @@ export class MotionRepositoryService extends BaseIsAgendaItemAndListOfSpeakersCo
foreignViewModel: ViewMotion, foreignViewModel: ViewMotion,
afterSetRelation: (motion: ViewMotion, foreignViewModel: ViewMotion | null) => { afterSetRelation: (motion: ViewMotion, foreignViewModel: ViewMotion | null) => {
if (foreignViewModel) { if (foreignViewModel) {
try {
motion.diffLines = this.getAmendmentParagraphs(motion, this.motionLineLength, false); motion.diffLines = this.getAmendmentParagraphs(motion, this.motionLineLength, false);
} catch (e) {
console.warn('Error with motion or amendment ', motion);
}
} }
}, },
afterDependencyChange: (motion: ViewMotion, parent: ViewMotion) => { afterDependencyChange: (motion: ViewMotion, parent: ViewMotion) => {
if (motion.parent) { if (motion.parent) {
try {
motion.diffLines = this.getAmendmentParagraphs(motion, this.motionLineLength, false); motion.diffLines = this.getAmendmentParagraphs(motion, this.motionLineLength, false);
} catch (e) {
console.warn('Error with motion or amendment: ', motion);
}
} }
} }
}); });

View File

@ -464,10 +464,7 @@
<ng-template #contentTemplate> <ng-template #contentTemplate>
<form class="motion-content" [formGroup]="contentForm" (keydown)="onKeyDown($event)"> <form class="motion-content" [formGroup]="contentForm" (keydown)="onKeyDown($event)">
<!-- Toolbar with text controls and buttonf for managing the (modified) final version--> <!-- Toolbar with text controls and buttonf for managing the (modified) final version-->
<div <div class="motion-text-toolbar-wrapper" *ngIf="!editMotion && !motion.isStatuteAmendment()">
class="motion-text-toolbar-wrapper"
*ngIf="!editMotion && !motion.isStatuteAmendment()"
>
<!-- Line Number and Diff buttons --> <!-- Line Number and Diff buttons -->
<div class="motion-text-controls"> <div class="motion-text-controls">
<mat-form-field class="motion-goto-line" *ngIf="highlightedLineOpened"> <mat-form-field class="motion-goto-line" *ngIf="highlightedLineOpened">
@ -858,11 +855,14 @@
<ng-template #paragraphBasedAmendment> <ng-template #paragraphBasedAmendment>
<section class="text-holder"> <section class="text-holder">
<div class="alert alert-info" *ngIf="this.getAmendmentParagraphs(showAmendmentContext).length === 0"> <!-- If the array exists, we do not have an error -->
<div *ngIf="motion.diffLines">
<!-- <div class="alert alert-info" *ngIf="getAmendmentParagraphs(showAmendmentContext).length === 0"> -->
<div class="alert alert-info" *ngIf="motion.diffLines.length === 0">
<span translate>No changes at the text.</span> <span translate>No changes at the text.</span>
</div> </div>
<div <div
*ngFor="let paragraph of this.getAmendmentParagraphs(showAmendmentContext)" *ngFor="let paragraph of motion.diffLines"
class="motion-text motion-text-diff amendment-view" class="motion-text motion-text-diff amendment-view"
[class.line-numbers-none]="isLineNumberingNone()" [class.line-numbers-none]="isLineNumberingNone()"
[class.line-numbers-inline]="isLineNumberingInline()" [class.line-numbers-inline]="isLineNumberingInline()"
@ -887,6 +887,12 @@
<div [innerHtml]="sanitizedText(paragraph.text)"></div> <div [innerHtml]="sanitizedText(paragraph.text)"></div>
<div class="paragraphcontext" [innerHtml]="sanitizedText(paragraph.textPost)"></div> <div class="paragraphcontext" [innerHtml]="sanitizedText(paragraph.textPost)"></div>
</div> </div>
</div>
<div *ngIf="!motion.diffLines">
<span class="red-warning-text" translate>
There is an error with this amendment. Please manually edit it.
</span>
</div>
</section> </section>
<!-- Show entire motion text --> <!-- Show entire motion text -->