From 938a8e72d916b88e6d9780aef72aae8cce5aa183 Mon Sep 17 00:00:00 2001 From: Tykayn Date: Sun, 7 Nov 2021 21:08:38 +0100 Subject: [PATCH] confirm before reinit --- src/app/core/services/api.service.ts | 4 +- src/app/core/services/poll.service.ts | 5 +- .../administration/form/form.component.html | 2 +- .../administration/form/form.component.scss | 10 ++++ .../steps/step-five/step-five.component.html | 51 ++++++++++++------- .../steps/step-five/step-five.component.ts | 14 +++-- src/styles/partials/global.scss | 4 ++ 7 files changed, 66 insertions(+), 24 deletions(-) diff --git a/src/app/core/services/api.service.ts b/src/app/core/services/api.service.ts index 3f69f88b..05ce4cc8 100644 --- a/src/app/core/services/api.service.ts +++ b/src/app/core/services/api.service.ts @@ -16,6 +16,8 @@ const apiBaseHref = environment.api.version[apiVersion].baseHref; const apiEndpoints = environment.api.endpoints; +class PollDTO {} + @Injectable({ providedIn: 'root', }) @@ -78,7 +80,7 @@ export class ApiService { }; } - public async createPoll(poll: Poll): Promise { + public async createPoll(poll: PollDTO): Promise { // this.loaderService.setStatus(true); console.log('createPoll config', poll); return this.axiosInstance.post( diff --git a/src/app/core/services/poll.service.ts b/src/app/core/services/poll.service.ts index 44cf869c..19acaf5f 100644 --- a/src/app/core/services/poll.service.ts +++ b/src/app/core/services/poll.service.ts @@ -23,7 +23,7 @@ import { Stack } from '../models/stack.model'; providedIn: 'root', }) export class PollService implements Resolve { - private _poll: BehaviorSubject = new BehaviorSubject(undefined); + public _poll: BehaviorSubject = new BehaviorSubject(undefined); public readonly poll: Observable = this._poll.asObservable(); public form: FormGroup; public startDateInterval: string; @@ -38,7 +38,8 @@ export class PollService implements Resolve { public step_max: number = 5; public round: Function; public pass_hash: string; - public urlPrefix: string = window.location.origin + '/participation/'; + public admin_key: string; + public urlPrefix: string = window.location.origin; public advancedDisplayEnabled = false; public showDateInterval = false; public allowSeveralHours = false; diff --git a/src/app/features/administration/form/form.component.html b/src/app/features/administration/form/form.component.html index 820437ed..b63a41e6 100644 --- a/src/app/features/administration/form/form.component.html +++ b/src/app/features/administration/form/form.component.html @@ -4,7 +4,7 @@ {{ 'creation.title' | translate }} -
+
diff --git a/src/app/features/administration/form/form.component.scss b/src/app/features/administration/form/form.component.scss index e69de29b..7974fca8 100644 --- a/src/app/features/administration/form/form.component.scss +++ b/src/app/features/administration/form/form.component.scss @@ -0,0 +1,10 @@ +@import '../../../../styles/variables'; +.admin-form { + padding: 1em; +} + +textarea { + border: solid 1px $border-color; + width: 100%; + display: block; +} diff --git a/src/app/features/administration/form/steps/step-five/step-five.component.html b/src/app/features/administration/form/steps/step-five/step-five.component.html index daa5d9bd..8d476bc0 100644 --- a/src/app/features/administration/form/steps/step-five/step-five.component.html +++ b/src/app/features/administration/form/steps/step-five/step-five.component.html @@ -1,9 +1,7 @@

- Félicitations, votre sondage " - {{ pollService.form.value.title }} " est créé + Félicitations, votre sondage " {{ pollService.form.value.title }} " est créé

Un récapitulatif par email vous a été envoyé. Partagez-le au monde avec ce lien: Administrez-le avec cet autre lien: @@ -30,8 +28,8 @@ Pour accéder au sondage et à tous ses paramètres : {{ pollService.form.value.urlAdmin }}

- - + + Voir le sondage coté administrateur·ice

@@ -43,16 +41,20 @@

{{ 'resume.users' | translate }}

Pour accéder au sondage : - {{ pollService.form.value.urlPublic }} + {{ pollService.urlPrefix + '/#/poll/' + pollService.form.value.custom_url + '/consultation' }} +

- - + + Voir le sondage

{{ 'resume.links_mail' | translate }}

- + Voir le sondage
@@ -60,7 +62,25 @@
- +
+
+ +
+
+ +
+
+ @@ -73,20 +93,17 @@ Tout réinitialiser - +
- {{ poll.custom_url }} + {{ pollService.form.value.custom_url }}
-
+
le formulaire est invalide -
  {{ form.errors | json }}
+
  {{ pollService.form.errors | json }}
diff --git a/src/app/features/administration/form/steps/step-five/step-five.component.ts b/src/app/features/administration/form/steps/step-five/step-five.component.ts index cf46cab1..04f429d2 100644 --- a/src/app/features/administration/form/steps/step-five/step-five.component.ts +++ b/src/app/features/administration/form/steps/step-five/step-five.component.ts @@ -1,6 +1,7 @@ import { Component, Input, OnInit } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { PollService } from '../../../../../core/services/poll.service'; +import { ApiService } from '../../../../../core/services/api.service'; @Component({ selector: 'app-step-five', @@ -11,12 +12,19 @@ export class StepFiveComponent implements OnInit { @Input() step_max: any; @Input() public form: FormGroup; poll: any; - constructor(public pollService: PollService) {} + constructor(public pollService: PollService, private apiService: ApiService) {} ngOnInit(): void {} - askInitFormDefault() {} + askInitFormDefault() { + if (window.confirm('réinitialiser le formulaire ?')) { + this.pollService.askInitFormDefault(); + } + } - createPoll() {} + createPoll() { + let apiData = this.pollService.newPollFromForm(this.pollService._poll); + this.apiService.createPoll(apiData); + } automaticSlug() {} } diff --git a/src/styles/partials/global.scss b/src/styles/partials/global.scss index 0c7f03c8..568e45b7 100644 --- a/src/styles/partials/global.scss +++ b/src/styles/partials/global.scss @@ -7,3 +7,7 @@ html { main { min-height: 90vh; } + +.content { + padding: 1em; +}