From fa534af3ab200835a16f38c2e7b5998cbadb45f6 Mon Sep 17 00:00:00 2001 From: tykayn Date: Tue, 3 Nov 2020 16:13:47 +0100 Subject: [PATCH] multiple choices for creation --- .../administration/form/form.component.html | 15 ++++++---- .../administration/form/form.component.scss | 7 +++++ .../administration/form/form.component.ts | 30 ++++++++++++++++--- 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/src/app/features/administration/form/form.component.html b/src/app/features/administration/form/form.component.html index e9c212f7..afa9fff5 100644 --- a/src/app/features/administration/form/form.component.html +++ b/src/app/features/administration/form/form.component.html @@ -5,7 +5,10 @@ {{ 'creation.want' | translate }} - +
@@ -22,13 +25,15 @@
- - - +
+ + + + - +
diff --git a/src/app/features/administration/form/form.component.scss b/src/app/features/administration/form/form.component.scss index a9730dd5..05b9c0fa 100644 --- a/src/app/features/administration/form/form.component.scss +++ b/src/app/features/administration/form/form.component.scss @@ -1,3 +1,4 @@ +@import '../../../../styles/variables'; :host { input, textarea { @@ -10,7 +11,13 @@ display: block; margin-top: 1em; } + .form-row { + margin-top: 0.5em; + border-left: solid 3px $primary_color; + padding-left: 1em; + } .fa { margin-right: 1em; + color: $primary_color; } } diff --git a/src/app/features/administration/form/form.component.ts b/src/app/features/administration/form/form.component.ts index 700e1eb8..da288898 100644 --- a/src/app/features/administration/form/form.component.ts +++ b/src/app/features/administration/form/form.component.ts @@ -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'); } }