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) {
motion.diffLines = this.getAmendmentParagraphs(motion, this.motionLineLength, false); try {
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) {
motion.diffLines = this.getAmendmentParagraphs(motion, this.motionLineLength, false); try {
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,34 +855,43 @@
<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 -->
<span translate>No changes at the text.</span> <div *ngIf="motion.diffLines">
</div> <!-- <div class="alert alert-info" *ngIf="getAmendmentParagraphs(showAmendmentContext).length === 0"> -->
<div <div class="alert alert-info" *ngIf="motion.diffLines.length === 0">
*ngFor="let paragraph of this.getAmendmentParagraphs(showAmendmentContext)" <span translate>No changes at the text.</span>
class="motion-text motion-text-diff amendment-view" </div>
[class.line-numbers-none]="isLineNumberingNone()" <div
[class.line-numbers-inline]="isLineNumberingInline()" *ngFor="let paragraph of motion.diffLines"
[class.line-numbers-outside]="isLineNumberingOutside()" class="motion-text motion-text-diff amendment-view"
[class.amendment-context]="showAmendmentContext" [class.line-numbers-none]="isLineNumberingNone()"
> [class.line-numbers-inline]="isLineNumberingInline()"
<!-- TODO: everything here is required for PDF as well. Should be in a service --> [class.line-numbers-outside]="isLineNumberingOutside()"
<h3 [class.amendment-context]="showAmendmentContext"
*ngIf="paragraph.diffLineTo === paragraph.diffLineFrom + 1 && !showAmendmentContext"
class="amendment-line-header"
> >
{{ 'Line' | translate }} {{ paragraph.diffLineFrom }}: <!-- TODO: everything here is required for PDF as well. Should be in a service -->
</h3> <h3
<h3 *ngIf="paragraph.diffLineTo === paragraph.diffLineFrom + 1 && !showAmendmentContext"
*ngIf="paragraph.diffLineTo !== paragraph.diffLineFrom + 1 && !showAmendmentContext" class="amendment-line-header"
class="amendment-line-header" >
> {{ 'Line' | translate }} {{ paragraph.diffLineFrom }}:
{{ 'Line' | translate }} {{ paragraph.diffLineFrom }} - {{ paragraph.diffLineTo - 1 }}: </h3>
</h3> <h3
*ngIf="paragraph.diffLineTo !== paragraph.diffLineFrom + 1 && !showAmendmentContext"
class="amendment-line-header"
>
{{ 'Line' | translate }} {{ paragraph.diffLineFrom }} - {{ paragraph.diffLineTo - 1 }}:
</h3>
<div class="paragraphcontext" [innerHtml]="sanitizedText(paragraph.textPre)"></div> <div class="paragraphcontext" [innerHtml]="sanitizedText(paragraph.textPre)"></div>
<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 *ngIf="!motion.diffLines">
<span class="red-warning-text" translate>
There is an error with this amendment. Please manually edit it.
</span>
</div> </div>
</section> </section>