diff --git a/src/app/core/models/poll.model.ts b/src/app/core/models/poll.model.ts index 8d616c3f..62cfacb1 100644 --- a/src/app/core/models/poll.model.ts +++ b/src/app/core/models/poll.model.ts @@ -8,9 +8,12 @@ import { User } from './user.model'; export class Poll { constructor( public owner: User = new User(), - public slug: string = 'default-slug', - public title: string = 'default title', + public slug: string = '', + public title: string = '', public description?: string, + public creatorPseudo?: string, + public creatorEmail?: string, + public isAboutDate?: boolean, public configuration: PollConfiguration = new PollConfiguration(), public comments: Comment[] = [], public choices: Choice[] = [], diff --git a/src/app/features/administration/administration.module.ts b/src/app/features/administration/administration.module.ts index bdd7c09c..f9bcb2e3 100644 --- a/src/app/features/administration/administration.module.ts +++ b/src/app/features/administration/administration.module.ts @@ -1,6 +1,6 @@ import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; -import { ReactiveFormsModule } from '@angular/forms'; +import { FormBuilder, FormsModule, ReactiveFormsModule } from '@angular/forms'; import { TranslateModule } from '@ngx-translate/core'; import { SharedModule } from '../../shared/shared.module'; @@ -35,6 +35,7 @@ import { AdvancedConfigComponent } from './form/advanced-config/advanced-config. CommonModule, ReactiveFormsModule, SharedModule, + FormsModule, TranslateModule.forChild({ extend: true }), DateValueAccessorModule, ], diff --git a/src/app/features/administration/form/base-config/base-config.component.html b/src/app/features/administration/form/base-config/base-config.component.html index 9346d401..b98a29d8 100644 --- a/src/app/features/administration/form/base-config/base-config.component.html +++ b/src/app/features/administration/form/base-config/base-config.component.html @@ -4,11 +4,12 @@

{{ 'creation.choose_title' | translate }}

+

slug: {{ form.value.slug }}


@@ -35,7 +36,7 @@ - +

-
-
- -
-

- {{ 'choices.title' | translate }} -

- {{ 'dates.add' | translate }} -

- - {{ 'choices.helper' | translate }} - -

- {{ 'choices.answer_preset_1' | translate }} - {{ 'choices.add' | translate }} - {{ 'choices.continue' | translate }} -
-
-
-
- -
- -
- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -
-
- Slug: -
-
-
- {{ poll.slug }} -
-
-
-
+ + + + + + + + + + + diff --git a/src/app/features/administration/form/base-config/base-config.component.ts b/src/app/features/administration/form/base-config/base-config.component.ts index beafa8c3..74aa2626 100644 --- a/src/app/features/administration/form/base-config/base-config.component.ts +++ b/src/app/features/administration/form/base-config/base-config.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectorRef, Component, Inject, Input, OnInit } from '@angular/core'; +import { ChangeDetectorRef, Component, EventEmitter, Inject, Input, OnInit, Output } from '@angular/core'; import { ToastService } from '../../../../core/services/toast.service'; import { FormArray, FormBuilder, FormGroup, Validators } from '@angular/forms'; import { UuidService } from '../../../../core/services/uuid.service'; @@ -30,12 +30,10 @@ export class BaseConfigComponent implements OnInit { @Inject(DOCUMENT) private document: Document ) {} - ngOnInit(): void { - this.initFormDefault(false); - } + ngOnInit(): void {} askInitFormDefault(): void { - this.initFormDefault(false); + // this.initFormDefault(false); this.toastService.display('formulaire réinitialisé'); } @@ -60,29 +58,6 @@ export class BaseConfigComponent implements OnInit { // } } - initFormDefault(showDemoValues = true): void { - this.form = this.fb.group({ - title: ['', [Validators.required, Validators.minLength(12)]], - creatorPseudo: ['', [Validators.required]], - creatorEmail: ['', [Validators.required]], - slug: [this.uuidService.getUUID(), [Validators.required]], - description: ['', [Validators.required]], - choices: new FormArray([]), - whoModifiesAnswers: ['', [Validators.required]], - whoCanChangeAnswers: ['', [Validators.required]], - isAboutDate: [true, [Validators.required]], - startDateInterval: ['', [Validators.required]], - endDateInterval: ['', [Validators.required]], - isProtectedByPassword: [false, [Validators.required]], - isOwnerNotifiedByEmailOnNewVote: [false, [Validators.required]], - isOwnerNotifiedByEmailOnNewComment: [false, [Validators.required]], - isMaybeAnswerAvailable: [false, [Validators.required]], - areResultsPublic: [true, [Validators.required]], - expiracyNumberOfDays: [60, [Validators.required, Validators.min(0)]], - }); - console.log('this.form ', this.form); - } - public updateSlug(): void { const newValueFormatted = 'TODO'; this.form.patchValue({ slug: newValueFormatted }); @@ -94,4 +69,8 @@ export class BaseConfigComponent implements OnInit { automaticSlug() { this.form.patchValue({ slug: this.pollService.makeSlug(this.poll) }); } + + formUpdate() { + this.formChange.emit(this.form); + } } diff --git a/src/app/features/administration/form/form.component.html b/src/app/features/administration/form/form.component.html index 710a95ad..7db1461c 100644 --- a/src/app/features/administration/form/form.component.html +++ b/src/app/features/administration/form/form.component.html @@ -1,13 +1,29 @@
-

- {{ 'creation.title' | translate }} -

-

- {{ 'creation.want' | translate }} -

- - +
+
+

+ {{ 'creation.title' | translate }} +

+

+ {{ 'creation.want' | translate }} +

+ + +
+
+
+				form values :
+					{{ form.value | json }}
+				
+
+				poll initial values :
+					{{ poll | json }}
+				
+
+
diff --git a/src/app/features/administration/form/form.component.ts b/src/app/features/administration/form/form.component.ts index eb5b3939..7733cb45 100644 --- a/src/app/features/administration/form/form.component.ts +++ b/src/app/features/administration/form/form.component.ts @@ -77,20 +77,26 @@ export class FormComponent implements OnInit { */ setDemoValues(): void { this.form.patchValue({ - title: 'mon titre', + title: '', description: 'répondez SVP <3 ! *-* ', slug: this.uuidService.getUUID(), creatorPseudo: 'Chuck Norris', creatorEmail: 'chucknorris@example.com', isAboutDate: true, - whoModifiesAnswers: 'everybody', - whoCanChangeAnswers: 'everybody', - isProtectedByPassword: false, - isOwnerNotifiedByEmailOnNewVote: false, - isOwnerNotifiedByEmailOnNewComment: false, - isMaybeAnswerAvailable: false, - areResultsPublic: true, - expiracyNumberOfDays: 60, + // configuration: { + // whoModifiesAnswers: 'everybody', + // whoCanChangeAnswers: 'everybody' + // isProtectedByPassword: false, + // isOwnerNotifiedByEmailOnNewVote: false, + // isOwnerNotifiedByEmailOnNewComment: false, + // isMaybeAnswerAvailable: false, + // areResultsPublic: true, + // expiracyNumberOfDays: 60, + // }, + comments: [], + choices: [], + dateChoices: [], + timeChoices: [], }); } }