Merge pull request #5012 from GabrielInTheWorld/paragraphDeleted

Fixes saving amendments with deleted paragraphs
This commit is contained in:
Emanuel Schütze 2019-09-12 17:36:18 +02:00 committed by GitHub
commit 11521c4ff2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

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

View File

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