Merge pull request #5551 from FinnStutzenstein/crInProjector

Always include CRs in motion slide
This commit is contained in:
Emanuel Schütze 2020-09-11 11:38:57 +02:00 committed by GitHub
commit 2759f8ce2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 45 additions and 24 deletions

View File

@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';
import { LineNumberedString, LinenumberingService } from './linenumbering.service';
import { LineNumberedString, LinenumberingService, LineNumberRange } from './linenumbering.service';
import { ViewUnifiedChange } from '../../shared/models/motions/view-unified-change';
const ELEMENT_NODE = 1;
@ -2149,11 +2149,24 @@ export class DiffService {
paragraphNo: number,
origText: string,
newText: string,
lineLength: number
lineLength: number,
changeRecos?: ViewUnifiedChange[]
): DiffLinesInParagraph {
const paragraph_line_range = this.lineNumberingService.getLineNumberRange(origText),
diff = this.diff(origText, newText),
affected_lines = this.detectAffectedLineRange(diff);
const paragraph_line_range: LineNumberRange = this.lineNumberingService.getLineNumberRange(origText);
let diff = this.diff(origText, newText);
const affected_lines = this.detectAffectedLineRange(diff);
/**
* If the affect line has change recos, overwirte the diff with the change reco
*/
if (changeRecos && changeRecos.length) {
const recoToThisLine = changeRecos.find(reco => {
return reco.getLineFrom() === affected_lines.from;
});
if (recoToThisLine) {
diff = this.diff(origText, recoToThisLine.getChangeNewText());
}
}
if (affected_lines === null) {
return null;

View File

@ -68,7 +68,6 @@
</td>
</tr>
</table>
</div>
</div>
@ -78,7 +77,8 @@
<span
*ngIf="isStatuteAmendment() || isParagraphBasedAmendment() || !!getFormattedText()"
class="text-prefix-label"
>{{ preamble | translate }}</span
>
{{ preamble | translate }}</span
>
<!-- Regular motions or traditional amendments -->

View File

@ -78,6 +78,9 @@ export class MotionSlideComponent extends BaseMotionSlideComponent<MotionSlideDa
);
}
console.log('cr mode? ', this.crMode);
console.log('the data: ', this._data);
this.recalcUnifiedChanges();
}
@ -410,26 +413,28 @@ export class MotionSlideComponent extends BaseMotionSlideComponent<MotionSlideDa
* @returns {DiffLinesInParagraph[]}
*/
public getAmendedParagraphs(): DiffLinesInParagraph[] {
let baseHtml = this.data.data.base_motion.text;
baseHtml = this.lineNumbering.insertLineNumbers(baseHtml, this.lineLength);
const motion = this.data.data;
const baseHtml = this.lineNumbering.insertLineNumbers(motion.base_motion?.text, this.lineLength);
const baseParagraphs = this.lineNumbering.splitToParagraphs(baseHtml);
return this.data.data.amendment_paragraphs
const amendmentParagraphs = motion.amendment_paragraphs
.map(
(newText: string, paraNo: number): DiffLinesInParagraph => {
if (newText === null) {
(amendmentText: string, paraNo: number): DiffLinesInParagraph => {
if (amendmentText === null) {
return null;
}
// Hint: can be either DiffLinesInParagraph or null, if no changes are made
return this.diff.getAmendmentParagraphsLines(
paraNo,
baseParagraphs[paraNo],
newText,
this.lineLength
amendmentText,
this.lineLength,
this.crMode === ChangeRecoMode.Diff ? this.getAllTextChangingObjects() : undefined
);
}
)
.filter((para: DiffLinesInParagraph) => para !== null);
return amendmentParagraphs;
}
/**

View File

@ -192,7 +192,6 @@ async def motion_slide(
motions_preamble = await get_config(all_data_provider, "motions_preamble")
# Query all change-recommendation and amendment related things.
change_recommendations = [] # type: ignore
amendments = [] # type: ignore
base_motion = None
base_statute = None
@ -201,6 +200,9 @@ async def motion_slide(
elif motion["parent_id"] is not None and motion["amendment_paragraphs"]:
base_motion = await get_amendment_base_motion(motion, all_data_provider)
else:
amendments = await get_amendments_for_motion(motion, all_data_provider)
change_recommendations = [] # type: ignore
for change_recommendation_id in motion["change_recommendations_id"]:
cr = await get_model(
all_data_provider,
@ -209,7 +211,6 @@ async def motion_slide(
)
if cr is not None and not cr["internal"]:
change_recommendations.append(cr)
amendments = await get_amendments_for_motion(motion, all_data_provider)
# The base return value. More fields will get added below.
return_value = {

View File

@ -108,6 +108,7 @@ def all_data_provider():
"created": "2019-01-19T18:37:34.741336+01:00",
"last_modified": "2019-01-19T18:37:34.741368+01:00",
"change_recommendations": [],
"change_recommendations_id": [],
"amendments_id": [],
},
3: {
@ -142,6 +143,7 @@ def all_data_provider():
"created": "2019-01-19T18:37:34.741336+01:00",
"last_modified": "2019-01-19T18:37:34.741368+01:00",
"change_recommendations": [],
"change_recommendations_id": [],
"amendments_id": [],
},
}