From 1067952eda60d5e6fe88368c3e23165191b88e25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Mau=C3=9F?= <lukas.mauss@mni.thm.de> Date: Mon, 11 Feb 2019 16:01:31 +0100 Subject: [PATCH] Fix form-control --- .../content-edit/content-edit.component.ts | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/app/components/creator/_dialogs/content-edit/content-edit.component.ts b/src/app/components/creator/_dialogs/content-edit/content-edit.component.ts index fb663831f..e8e77145c 100644 --- a/src/app/components/creator/_dialogs/content-edit/content-edit.component.ts +++ b/src/app/components/creator/_dialogs/content-edit/content-edit.component.ts @@ -40,33 +40,52 @@ export class ContentEditComponent implements OnInit { } updateContent() { + let counter = 0; if (this.content.subject === '' || this.content.body === '') { this.translateService.get('content.no-empty').subscribe(message => { this.notificationService.show(message); }); return; } - if (this.content.options.length === 0) { + if (this.displayAnswers.length === 0) { this.translateService.get('content.need-answers').subscribe(message => { this.notificationService.show(message); }); return; } for (let i = 0; i < this.content.options.length; i++) { - if (this.content.options[i].label === '') { + console.log(i); + if (this.displayAnswers[i].answerOption.label === '') { this.translateService.get('content.no-empty2').subscribe(message => { this.notificationService.show(message); }); return; } - if (this.content.options[i].points > 0 && this.content.multiple) { - this.dialogRef.close('update'); - } else { + if (this.content.options[i].points > 0) { + counter++; + } + } + if (counter <= 0) { + if (this.content.multiple) { this.translateService.get('content.at-least-one').subscribe(message => { this.notificationService.show(message); + return; + }); + } else { + this.translateService.get('content.select-one').subscribe(message => { + this.notificationService.show(message); + return; + }); + } + } else { + if ((!this.content.multiple) && counter > 1) { + this.translateService.get('content.select-one').subscribe(message => { + this.notificationService.show(message); }); return; } + this.dialogRef.close('update'); + return; } } } -- GitLab