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

Refactor yes-no-content-creation

parent 0ff925a4
Branches
Tags
No related merge requests found
......@@ -26,4 +26,7 @@
<app-content-likert-creator *ngIf="format === 'likert'"
[contentSub] = "subject.value" [contentBod]="body.value" [contentCol]="group.value">
</app-content-likert-creator>
<app-content-yes-no-creator *ngIf="format === 'yesno'"
[contentSub] = "subject.value" [contentBod]="body.value" [contentCol]="group.value">
</app-content-yes-no-creator>
</form>
<form (ngSubmit)="submitContent(subject.value, body.value, group.value)">
<mat-form-field class="input-block">
<input matInput #subject [(ngModel)]="content.subject" placeholder="{{ 'content.subject' | translate }}" name="subject">
</mat-form-field>
<mat-form-field class="input-block">
<textarea matInput #body [(ngModel)]="content.body" placeholder="{{ 'content.body' | translate }}" name="body"></textarea>
</mat-form-field>
<mat-radio-group [(ngModel)]="yesno" [ngModelOptions]="{standalone: true}" fxLayout="row" fxLayoutAlign="center" fxLayoutGap="20px">
<mat-radio-button [value]=true [checked]=true>
{{ 'content.yes' | translate }}
</mat-radio-button>
<mat-radio-button [value]=false [checked]=false>
{{ 'content.no' | translate }}
</mat-radio-button>
</mat-radio-group>
<mat-form-field>
<input matInput #group matInput [formControl]="myControl" [matAutocomplete]="auto"
value={{lastCollection}} placeholder="{{'content.collection' | translate}}"/>
<mat-autocomplete #auto="matAutocomplete">
<mat-option *ngFor="let collection of filteredOptions | async" [value]="collection">
{{collection}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
<form (ngSubmit)="submitContent()">
<mat-radio-group [(ngModel)]="yesno" [ngModelOptions]="{standalone: true}" fxLayout="row" fxLayoutAlign="center" fxLayoutGap="20px">
<mat-radio-button [value]=true [checked]=true>
{{ 'content.yes' | translate }}
</mat-radio-button>
<mat-radio-button [value]=false [checked]=false>
{{ 'content.no' | translate }}
</mat-radio-button>
</mat-radio-group>
<div *ngIf="!editDialogMode">
<button mat-raised-button type="submit" color="accent">{{ 'content.create' | translate }}</button>
</div>
......
import { Component, Inject, OnInit } from '@angular/core';
import { Component, Inject, Input, OnInit } from '@angular/core';
import { ContentChoice } from '../../../models/content-choice';
import { DisplayAnswer } from '../content-choice-creator/content-choice-creator.component';
import { AnswerOption } from '../../../models/answer-option';
......@@ -19,6 +19,10 @@ import { TranslateService } from '@ngx-translate/core';
styleUrls: ['./content-yes-no-creator.component.scss']
})
export class ContentYesNoCreatorComponent implements OnInit {
@Input() contentSub;
@Input() contentBod;
@Input() contentCol;
yesno = true;
answerLabels = [
'yes',
......@@ -93,8 +97,8 @@ export class ContentYesNoCreatorComponent implements OnInit {
});
}
submitContent(subject: string, body: string, group: string): void {
if (subject.valueOf() === '' || body.valueOf() === '') {
submitContent(): void {
if (this.contentSub === '' || this.contentBod === '') {
this.translationService.get('content.no-empty').subscribe(message => {
this.notificationService.show(message);
});
......@@ -109,10 +113,10 @@ export class ContentYesNoCreatorComponent implements OnInit {
'',
'',
this.roomId,
subject,
body,
this.contentSub,
this.contentBod,
1,
[group],
[this.contentCol],
this.content.options,
this.content.correctOptionIndexes,
this.content.multiple,
......
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