Skip to content
Snippets Groups Projects
Commit 1067952e authored by Lukas Mauß's avatar Lukas Mauß
Browse files

Fix form-control

parent 5fe52a34
No related merge requests found
...@@ -40,33 +40,52 @@ export class ContentEditComponent implements OnInit { ...@@ -40,33 +40,52 @@ export class ContentEditComponent implements OnInit {
} }
updateContent() { updateContent() {
let counter = 0;
if (this.content.subject === '' || this.content.body === '') { if (this.content.subject === '' || this.content.body === '') {
this.translateService.get('content.no-empty').subscribe(message => { this.translateService.get('content.no-empty').subscribe(message => {
this.notificationService.show(message); this.notificationService.show(message);
}); });
return; return;
} }
if (this.content.options.length === 0) { if (this.displayAnswers.length === 0) {
this.translateService.get('content.need-answers').subscribe(message => { this.translateService.get('content.need-answers').subscribe(message => {
this.notificationService.show(message); this.notificationService.show(message);
}); });
return; return;
} }
for (let i = 0; i < this.content.options.length; i++) { 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.translateService.get('content.no-empty2').subscribe(message => {
this.notificationService.show(message); this.notificationService.show(message);
}); });
return; return;
} }
if (this.content.options[i].points > 0 && this.content.multiple) { if (this.content.options[i].points > 0) {
this.dialogRef.close('update'); counter++;
} else { }
}
if (counter <= 0) {
if (this.content.multiple) {
this.translateService.get('content.at-least-one').subscribe(message => { this.translateService.get('content.at-least-one').subscribe(message => {
this.notificationService.show(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; return;
} }
this.dialogRef.close('update');
return;
} }
} }
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment