Merge pull request #4817 from CatoTH/OS3-bugfix-repeated-motion-texts
Bugfix: Amendment with multiple changed paragraphs shows motion text …
This commit is contained in:
commit
ea425996f9
@ -705,25 +705,45 @@ export class MotionRepositoryService extends BaseIsAgendaItemAndListOfSpeakersCo
|
||||
*
|
||||
* @param {ViewMotion} amendment
|
||||
* @param {number} lineLength
|
||||
* @param {boolean} includeUnchanged
|
||||
* @returns {DiffLinesInParagraph}
|
||||
*/
|
||||
public getAmendedParagraphs(amendment: ViewMotion, lineLength: number): DiffLinesInParagraph[] {
|
||||
public getAmendmentParagraphs(
|
||||
amendment: ViewMotion,
|
||||
lineLength: number,
|
||||
includeUnchanged: boolean
|
||||
): DiffLinesInParagraph[] {
|
||||
const motion = this.getAmendmentBaseMotion(amendment);
|
||||
const baseParagraphs = this.getTextParagraphs(motion, true, lineLength);
|
||||
|
||||
return amendment.amendment_paragraphs
|
||||
.map(
|
||||
(newText: string, paraNo: number): DiffLinesInParagraph => {
|
||||
if (newText === null) {
|
||||
return null;
|
||||
}
|
||||
// Hint: can be either DiffLinesInParagraph or null, if no changes are made
|
||||
if (newText !== null) {
|
||||
return this.diff.getAmendmentParagraphsLinesByMode(
|
||||
paraNo,
|
||||
baseParagraphs[paraNo],
|
||||
newText,
|
||||
lineLength
|
||||
);
|
||||
} else {
|
||||
// Nothing has changed in this paragraph
|
||||
if (includeUnchanged) {
|
||||
const paragraph_line_range = this.lineNumbering.getLineNumberRange(baseParagraphs[paraNo]);
|
||||
return {
|
||||
paragraphNo: paraNo,
|
||||
paragraphLineFrom: paragraph_line_range.from,
|
||||
paragraphLineTo: paragraph_line_range.to,
|
||||
diffLineFrom: paragraph_line_range.to,
|
||||
diffLineTo: paragraph_line_range.to,
|
||||
textPre: baseParagraphs[paraNo],
|
||||
text: '',
|
||||
textPost: ''
|
||||
} as DiffLinesInParagraph;
|
||||
} else {
|
||||
return null; // null will make this paragraph filtered out
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
.filter((para: DiffLinesInParagraph) => para !== null);
|
||||
|
@ -865,11 +865,11 @@
|
||||
|
||||
<ng-template #paragraphBasedAmendment>
|
||||
<section class="text-holder">
|
||||
<div class="alert alert-info" *ngIf="this.getAmendedParagraphs().length === 0">
|
||||
<div class="alert alert-info" *ngIf="this.getAmendmentParagraphs(showAmendmentContext).length === 0">
|
||||
<span translate>No changes at the text.</span>
|
||||
</div>
|
||||
<div
|
||||
*ngFor="let paragraph of this.getAmendedParagraphs()"
|
||||
*ngFor="let paragraph of this.getAmendmentParagraphs(showAmendmentContext)"
|
||||
class="motion-text motion-text-diff amendment-view"
|
||||
[class.line-numbers-none]="isLineNumberingNone()"
|
||||
[class.line-numbers-inline]="isLineNumberingInline()"
|
||||
@ -877,10 +877,6 @@
|
||||
[class.amendment-context]="showAmendmentContext"
|
||||
>
|
||||
<!-- TODO: everything here is required for PDF as well. Should be in a service -->
|
||||
<div class="amendment-context" *ngIf="showAmendmentContext">
|
||||
<div [innerHTML]="getParentMotionRange(1, paragraph.paragraphLineFrom)" class="context"></div>
|
||||
</div>
|
||||
|
||||
<h3
|
||||
*ngIf="paragraph.diffLineTo === paragraph.diffLineFrom + 1 && !showAmendmentContext"
|
||||
class="amendment-line-header"
|
||||
@ -897,10 +893,6 @@
|
||||
<div class="paragraphcontext" [innerHtml]="sanitizedText(paragraph.textPre)"></div>
|
||||
<div [innerHtml]="sanitizedText(paragraph.text)"></div>
|
||||
<div class="paragraphcontext" [innerHtml]="sanitizedText(paragraph.textPost)"></div>
|
||||
|
||||
<div class="amendment-context" *ngIf="showAmendmentContext">
|
||||
<div [innerHtml]="getParentMotionRange(paragraph.paragraphLineTo, null)"></div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</ng-template>
|
||||
|
@ -864,10 +864,11 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit,
|
||||
/**
|
||||
* If `this.motion` is an amendment, this returns the list of all changed paragraphs.
|
||||
*
|
||||
* @param {boolean} includeUnchanged
|
||||
* @returns {DiffLinesInParagraph[]}
|
||||
*/
|
||||
public getAmendedParagraphs(): DiffLinesInParagraph[] {
|
||||
return this.repo.getAmendedParagraphs(this.motion, this.lineLength);
|
||||
public getAmendmentParagraphs(includeUnchanged: boolean): DiffLinesInParagraph[] {
|
||||
return this.repo.getAmendmentParagraphs(this.motion, this.lineLength, includeUnchanged);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -553,7 +553,7 @@ export class MotionPdfService {
|
||||
motionText = '';
|
||||
// this is logically redundant with the formation of amendments in the motion-detail html.
|
||||
// Should be refactored in a way that a service returns the correct html for both cases
|
||||
for (const paragraph of this.motionRepo.getAmendedParagraphs(motion, lineLength)) {
|
||||
for (const paragraph of this.motionRepo.getAmendmentParagraphs(motion, lineLength, false)) {
|
||||
if (paragraph.diffLineTo === paragraph.diffLineFrom + 1) {
|
||||
motionText += `<h3>
|
||||
${this.translate.instant('Line')} ${paragraph.diffLineFrom}:
|
||||
|
Loading…
Reference in New Issue
Block a user