Bugfix: errors with non-paragraph-based amendments

This commit is contained in:
Tobias Hößl 2020-06-07 10:43:05 +02:00
parent 8451cd2d88
commit 18bc495bd8
No known key found for this signature in database
GPG Key ID: 1D780C7599C2D2A2
2 changed files with 23 additions and 23 deletions

View File

@ -324,7 +324,7 @@ export class MotionRepositoryService extends BaseIsAgendaItemAndListOfSpeakersCo
type: 'custom', type: 'custom',
ownKey: 'diffLines', ownKey: 'diffLines',
get: (motion: Motion, viewMotion: ViewMotion) => { get: (motion: Motion, viewMotion: ViewMotion) => {
if (viewMotion.parent) { if (viewMotion.parent && viewMotion.isParagraphBasedAmendment()) {
const changeRecos = viewMotion.changeRecommendations.filter(changeReco => const changeRecos = viewMotion.changeRecommendations.filter(changeReco =>
changeReco.showInFinalView() changeReco.showInFinalView()
); );
@ -335,6 +335,8 @@ export class MotionRepositoryService extends BaseIsAgendaItemAndListOfSpeakersCo
changeRecos, changeRecos,
false false
); );
} else {
return [];
} }
}, },
getCacheObjectToCheck: (viewMotion: ViewMotion) => viewMotion.parent getCacheObjectToCheck: (viewMotion: ViewMotion) => viewMotion.parent
@ -835,7 +837,9 @@ export class MotionRepositoryService extends BaseIsAgendaItemAndListOfSpeakersCo
} }
/** /**
* Returns all paragraph lines that are affected by the given amendment in diff-format, including context * Returns all paragraph lines that are affected by the given amendment in diff-format, including context.
*
* Should only be called for paragraph-based amendments.
* *
* @param {ViewMotion} amendment * @param {ViewMotion} amendment
* @param {number} lineLength * @param {number} lineLength

View File

@ -322,11 +322,6 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit,
*/ */
public showAmendmentContext = false; public showAmendmentContext = false;
/**
* Sets the current amendment text mode from the settings
*/
private amendmentTextMode: string;
/** /**
* Show all amendments in the text, not only the ones with the apropriate state * Show all amendments in the text, not only the ones with the apropriate state
*/ */
@ -540,9 +535,6 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit,
this.configService this.configService
.get<boolean>('motions_show_sequential_numbers') .get<boolean>('motions_show_sequential_numbers')
.subscribe(shown => (this.showSequential = shown)); .subscribe(shown => (this.showSequential = shown));
this.configService
.get<string>('motions_amendments_text_mode')
.subscribe(amendmentTextMode => (this.amendmentTextMode = amendmentTextMode));
// Update statute paragraphs // Update statute paragraphs
this.statuteRepo.getViewModelListObservable().subscribe(newViewStatuteParagraphs => { this.statuteRepo.getViewModelListObservable().subscribe(newViewStatuteParagraphs => {
@ -649,17 +641,19 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit,
}); });
} }
if (this.amendments) { if (this.amendments) {
this.amendments.forEach((amendment: ViewMotion): void => { this.amendments
const toApplyChanges = (this.amendmentChangeRecos[amendment.id] || []).filter( .filter(amendment => amendment.isParagraphBasedAmendment())
// The rejected change recommendations for amendments should not be considered .forEach((amendment: ViewMotion): void => {
change => change.showInFinalView() const toApplyChanges = (this.amendmentChangeRecos[amendment.id] || []).filter(
); // The rejected change recommendations for amendments should not be considered
this.repo change => change.showInFinalView()
.getAmendmentAmendedParagraphs(amendment, this.lineLength, toApplyChanges) );
.forEach((change: ViewUnifiedChange): void => { this.repo
this.allChangingObjects.push(change); .getAmendmentAmendedParagraphs(amendment, this.lineLength, toApplyChanges)
}); .forEach((change: ViewUnifiedChange): void => {
}); this.allChangingObjects.push(change);
});
});
} }
this.allChangingObjects.sort((a: ViewUnifiedChange, b: ViewUnifiedChange) => { this.allChangingObjects.sort((a: ViewUnifiedChange, b: ViewUnifiedChange) => {
if (a.getLineFrom() < b.getLineFrom()) { if (a.getLineFrom() < b.getLineFrom()) {
@ -750,7 +744,8 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit,
tags_id: parentMotion.tags_id tags_id: parentMotion.tags_id
}); });
if (this.amendmentTextMode === 'fulltext') { const amendmentTextMode = this.configService.instant<string>('motions_amendments_text_mode');
if (amendmentTextMode === 'fulltext') {
defaultMotion.text = parentMotion.text; defaultMotion.text = parentMotion.text;
this.contentForm.patchValue({ text: defaultMotion.text }); this.contentForm.patchValue({ text: defaultMotion.text });
} }
@ -1219,7 +1214,8 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit,
* Goes to the amendment creation wizard. Executed via click. * Goes to the amendment creation wizard. Executed via click.
*/ */
public createAmendment(): void { public createAmendment(): void {
if (this.amendmentTextMode === 'paragraph') { const amendmentTextMode = this.configService.instant<string>('motions_amendments_text_mode');
if (amendmentTextMode === 'paragraph') {
this.router.navigate(['./create-amendment'], { relativeTo: this.route }); this.router.navigate(['./create-amendment'], { relativeTo: this.route });
} else { } else {
this.router.navigate(['./motions/new-amendment'], { this.router.navigate(['./motions/new-amendment'], {