Merge pull request #5023 from tsiegleauq/catch-broken-line-numbers

Catch and show line numbering errors
This commit is contained in:
Sean 2019-09-16 12:23:17 +02:00 committed by GitHub
commit c538179904
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 -->