Browse Source

start combine choices array

creation-form
Baptiste Lemoine 2 years ago
parent
commit
4bec5828b3
  1. 31
      src/app/features/administration/form/form.component.html
  2. 7
      src/app/features/administration/form/form.component.ts

31
src/app/features/administration/form/form.component.html

@ -33,7 +33,26 @@
<i class="fa fa-close"></i>
</button>
<label for="descr">Description</label>
<br />
<h2>Choix de réponse</h2>
<div formArrayName="choicesFormArray">
<h3>Aliases</h3>
<button (click)="addChoice()">Add Alias</button>
<div *ngFor="let choice of choices.controls; let i = index">
<!-- The repeated alias template -->
<pre class="debug padded warning">
choice :
{{ choice | json }}
</pre
>
<label>
choices:
<input type="text" [formControlName]="i" />
</label>
</div>
</div>
<label for="descr">Description (optionnel)</label>
<textarea
#description
matInput
@ -86,6 +105,16 @@
</div>
<div class="complete" *ngIf="longFormVersionEnabled">
<form [formGroup]="configurationFormGroup">
<h2>
Type de sondage
</h2>
<button class="btn" [ngClass]="{ 'is-primary': isAboutDate.value }" (click)="isAboutDate = true">
Spécial date
</button>
<button [ngClass]="{ 'is-primary': !isAboutDate.value }" (click)="isAboutDate = false">
Classique - textes
</button>
<h2>Version complète du formulaire</h2>
<mat-form-field appearance="outline" class="is-flex">
<mat-label>Nombre de jours avant expiration</mat-label>

7
src/app/features/administration/form/form.component.ts

@ -80,4 +80,11 @@ export class FormComponent implements OnInit {
let newValueFormatted = 'TODO';
this.pollFormGroup.patchValue({ slug: newValueFormatted });
}
get choices() {
return this.choicesFormArray.get('aliases') as FormArray;
}
addChoice() {
this.choices.push(this.fb.control(''));
}
}

Loading…
Cancel
Save