|
|
|
@ -3,6 +3,7 @@ import { Poll } from '../../../core/models/poll.model';
|
|
|
|
|
import { FormArray, FormBuilder, FormGroup, Validators } from '@angular/forms';
|
|
|
|
|
import { UuidService } from '../../../core/services/uuid.service';
|
|
|
|
|
import { ApiService } from '../../../core/services/api.service';
|
|
|
|
|
import { ToastService } from '../../../core/services/toast.service';
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-admin-form',
|
|
|
|
@ -18,7 +19,12 @@ export class FormComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
public urlPrefix: string = window.location.origin + '/participation/';
|
|
|
|
|
|
|
|
|
|
constructor(private fb: FormBuilder, private uuidService: UuidService, private apiService: ApiService) {}
|
|
|
|
|
constructor(
|
|
|
|
|
private fb: FormBuilder,
|
|
|
|
|
private uuidService: UuidService,
|
|
|
|
|
private toastService: ToastService,
|
|
|
|
|
private apiService: ApiService
|
|
|
|
|
) {}
|
|
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
|
this.initFormDefault();
|
|
|
|
@ -58,10 +64,9 @@ export class FormComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
reinitChoices() {
|
|
|
|
|
this.choices.setValue([]);
|
|
|
|
|
this.addChoice();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private initFormDefault() {
|
|
|
|
|
initFormDefault() {
|
|
|
|
|
this.form = this.fb.group({
|
|
|
|
|
title: ['', [Validators.required, Validators.minLength(12)]],
|
|
|
|
|
creatorPseudo: ['', [Validators.required]],
|
|
|
|
@ -79,11 +84,28 @@ export class FormComponent implements OnInit {
|
|
|
|
|
});
|
|
|
|
|
console.log('this.form ', this.form);
|
|
|
|
|
|
|
|
|
|
this.addChoice();
|
|
|
|
|
this.addChoice();
|
|
|
|
|
this.addChoice();
|
|
|
|
|
|
|
|
|
|
this.form.patchValue({
|
|
|
|
|
title: 'mon titre',
|
|
|
|
|
description: 'répondez SVP <3 ! *-* ',
|
|
|
|
|
slug: this.uuidService.getUUID(),
|
|
|
|
|
creatorPseudo: 'Chuck Norris',
|
|
|
|
|
creatorEmail: '',
|
|
|
|
|
choices: ['matin', 'midi'],
|
|
|
|
|
isAboutDate: true,
|
|
|
|
|
isProtectedByPassword: false,
|
|
|
|
|
isOwnerNotifiedByEmailOnNewVote: false,
|
|
|
|
|
isOwnerNotifiedByEmailOnNewComment: false,
|
|
|
|
|
isMaybeAnswerAvailable: false,
|
|
|
|
|
areResultsPublic: true,
|
|
|
|
|
expiracyNumberOfDays: 60,
|
|
|
|
|
});
|
|
|
|
|
// this.addChoice();
|
|
|
|
|
}
|
|
|
|
|
askInitFormDefault() {
|
|
|
|
|
this.initFormDefault();
|
|
|
|
|
this.toastService.display('formulaire réinitialisé', 'info');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|