Fixes saving amendments with deleted paragraphs

This commit is contained in:
GabrielMeyer 2019-09-12 15:43:54 +02:00
parent 15b90579ae
commit 7ad8a40764
2 changed files with 6 additions and 2 deletions

View File

@ -725,7 +725,7 @@
{{ 'Line' | translate }} {{ paragraph.lineFrom }} - {{ paragraph.lineTo - 1 }} {{ 'Line' | translate }} {{ paragraph.lineFrom }} - {{ paragraph.lineTo - 1 }}
</span> </span>
</h3> </h3>
<editor [formControlName]="'text_' + paragraph.paragraphNo" [init]="tinyMceSettings" required></editor> <editor [formControlName]="'text_' + paragraph.paragraphNo" [init]="tinyMceSettings"></editor>
<div <div
*ngIf=" *ngIf="
contentForm.get('text_' + paragraph.paragraphNo).invalid && contentForm.get('text_' + paragraph.paragraphNo).invalid &&

View File

@ -601,6 +601,10 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit,
this.subscriptions.push( this.subscriptions.push(
this.repo.getViewModelObservable(motionId).subscribe(motion => { this.repo.getViewModelObservable(motionId).subscribe(motion => {
if (motion) { if (motion) {
if (motion.isParagraphBasedAmendment()) {
this.contentForm.get('text').clearValidators();
this.contentForm.get('text').updateValueAndValidity();
}
const title = motion.getTitle(); const title = motion.getTitle();
super.setTitle(title); super.setTitle(title);
this.motion = motion; this.motion = motion;
@ -685,7 +689,7 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit,
paragraphsToChoose.forEach((paragraph: ParagraphToChoose, paragraphNo: number): void => { paragraphsToChoose.forEach((paragraph: ParagraphToChoose, paragraphNo: number): void => {
if (formMotion.amendment_paragraphs[paragraphNo] !== null) { if (formMotion.amendment_paragraphs[paragraphNo] !== null) {
this.contentForm.addControl('text_' + paragraphNo, new FormControl('', Validators.required)); this.contentForm.addControl('text_' + paragraphNo, new FormControl(''));
contentPatch.selected_paragraphs.push(paragraph); contentPatch.selected_paragraphs.push(paragraph);
contentPatch.text = formMotion.amendment_paragraphs[paragraphNo]; // Workaround as 'text' is required from the backend contentPatch.text = formMotion.amendment_paragraphs[paragraphNo]; // Workaround as 'text' is required from the backend