Bugfix: Amendment with multiple changed paragraphs shows motion text multiple times when context is shown
This commit is contained in:
parent
47f1ca9691
commit
6b70e8a4ab
@ -705,25 +705,45 @@ export class MotionRepositoryService extends BaseIsAgendaItemAndListOfSpeakersCo
|
|||||||
*
|
*
|
||||||
* @param {ViewMotion} amendment
|
* @param {ViewMotion} amendment
|
||||||
* @param {number} lineLength
|
* @param {number} lineLength
|
||||||
|
* @param {boolean} includeUnchanged
|
||||||
* @returns {DiffLinesInParagraph}
|
* @returns {DiffLinesInParagraph}
|
||||||
*/
|
*/
|
||||||
public getAmendedParagraphs(amendment: ViewMotion, lineLength: number): DiffLinesInParagraph[] {
|
public getAmendmentParagraphs(
|
||||||
|
amendment: ViewMotion,
|
||||||
|
lineLength: number,
|
||||||
|
includeUnchanged: boolean
|
||||||
|
): DiffLinesInParagraph[] {
|
||||||
const motion = this.getAmendmentBaseMotion(amendment);
|
const motion = this.getAmendmentBaseMotion(amendment);
|
||||||
const baseParagraphs = this.getTextParagraphs(motion, true, lineLength);
|
const baseParagraphs = this.getTextParagraphs(motion, true, lineLength);
|
||||||
|
|
||||||
return amendment.amendment_paragraphs
|
return amendment.amendment_paragraphs
|
||||||
.map(
|
.map(
|
||||||
(newText: string, paraNo: number): DiffLinesInParagraph => {
|
(newText: string, paraNo: number): DiffLinesInParagraph => {
|
||||||
if (newText === null) {
|
if (newText !== null) {
|
||||||
return 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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Hint: can be either DiffLinesInParagraph or null, if no changes are made
|
|
||||||
return this.diff.getAmendmentParagraphsLinesByMode(
|
|
||||||
paraNo,
|
|
||||||
baseParagraphs[paraNo],
|
|
||||||
newText,
|
|
||||||
lineLength
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.filter((para: DiffLinesInParagraph) => para !== null);
|
.filter((para: DiffLinesInParagraph) => para !== null);
|
||||||
|
@ -865,11 +865,11 @@
|
|||||||
|
|
||||||
<ng-template #paragraphBasedAmendment>
|
<ng-template #paragraphBasedAmendment>
|
||||||
<section class="text-holder">
|
<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>
|
<span translate>No changes at the text.</span>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
*ngFor="let paragraph of this.getAmendedParagraphs()"
|
*ngFor="let paragraph of this.getAmendmentParagraphs(showAmendmentContext)"
|
||||||
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()"
|
||||||
@ -877,10 +877,6 @@
|
|||||||
[class.amendment-context]="showAmendmentContext"
|
[class.amendment-context]="showAmendmentContext"
|
||||||
>
|
>
|
||||||
<!-- TODO: everything here is required for PDF as well. Should be in a service -->
|
<!-- 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
|
<h3
|
||||||
*ngIf="paragraph.diffLineTo === paragraph.diffLineFrom + 1 && !showAmendmentContext"
|
*ngIf="paragraph.diffLineTo === paragraph.diffLineFrom + 1 && !showAmendmentContext"
|
||||||
class="amendment-line-header"
|
class="amendment-line-header"
|
||||||
@ -897,10 +893,6 @@
|
|||||||
<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 class="amendment-context" *ngIf="showAmendmentContext">
|
|
||||||
<div [innerHtml]="getParentMotionRange(paragraph.paragraphLineTo, null)"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</ng-template>
|
</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.
|
* If `this.motion` is an amendment, this returns the list of all changed paragraphs.
|
||||||
*
|
*
|
||||||
|
* @param {boolean} includeUnchanged
|
||||||
* @returns {DiffLinesInParagraph[]}
|
* @returns {DiffLinesInParagraph[]}
|
||||||
*/
|
*/
|
||||||
public getAmendedParagraphs(): DiffLinesInParagraph[] {
|
public getAmendmentParagraphs(includeUnchanged: boolean): DiffLinesInParagraph[] {
|
||||||
return this.repo.getAmendedParagraphs(this.motion, this.lineLength);
|
return this.repo.getAmendmentParagraphs(this.motion, this.lineLength, includeUnchanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -553,7 +553,7 @@ export class MotionPdfService {
|
|||||||
motionText = '';
|
motionText = '';
|
||||||
// this is logically redundant with the formation of amendments in the motion-detail html.
|
// 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
|
// 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) {
|
if (paragraph.diffLineTo === paragraph.diffLineFrom + 1) {
|
||||||
motionText += `<h3>
|
motionText += `<h3>
|
||||||
${this.translate.instant('Line')} ${paragraph.diffLineFrom}:
|
${this.translate.instant('Line')} ${paragraph.diffLineFrom}:
|
||||||
|
Loading…
Reference in New Issue
Block a user