From c2c193bfa92129972335d5ee36507c7b0ed43aca Mon Sep 17 00:00:00 2001
From: Tykayn
Date: Mon, 8 Nov 2021 12:36:18 +0100
Subject: [PATCH] success page displays links from form data
---
src/app/core/services/poll.service.ts | 27 ++++++++++++++--
.../steps/step-five/step-five.component.html | 17 ++--------
.../success/success.component.html | 32 ++++---------------
.../success/success.component.scss | 5 ++-
4 files changed, 37 insertions(+), 44 deletions(-)
diff --git a/src/app/core/services/poll.service.ts b/src/app/core/services/poll.service.ts
index 200800ef..d378cc74 100644
--- a/src/app/core/services/poll.service.ts
+++ b/src/app/core/services/poll.service.ts
@@ -356,8 +356,11 @@ export class PollService implements Resolve {
public createPoll(): void {
console.log('this.form', this.form);
const newpoll = this.newPollFromForm(this.form);
- console.log('newpoll', newpoll);
- this.apiService.createPoll(newpoll);
+ this.apiService.createPoll(newpoll).then((resp) => {
+ console.log('poll created resp', resp);
+ console.log('TODO fill admin_key');
+ this.admin_key = resp.data.admin_key;
+ });
}
/**
@@ -537,6 +540,13 @@ export class PollService implements Resolve {
return list;
}
+ public getParticipationUrlFromForm(): string {
+ return `${environment.frontDomain}#/poll/${this.form.value.custom_url}/consultation`;
+ }
+ public getAdministrationUrlFromForm(): string {
+ // admin_key is filled after creation
+ return `${environment.frontDomain}#/admin/${this.admin_key}/consultation`;
+ }
public getParticipationUrl(): string {
// http://localhost:4200/#/poll/dessin-anime/consultation
@@ -549,17 +559,24 @@ export class PollService implements Resolve {
if (polltemp) {
url = `${environment.frontDomain}#/poll/${polltemp.custom_url}/consultation`;
}
+ } else {
+ url = `${environment.frontDomain}#/poll/${this.form.value.custom_url}/consultation`;
}
+
// TODO handle pass access
return url;
}
public getAdministrationUrl(): string {
+ // http://localhost:4200/#/admin/9S75b70ECXI5J5xDc058d3H40H9r2CHfO0Kj8T02EK2U8rY8fYTn-eS659j2Dhp794Oa6R1b9V70e3WGaE30iD9h45zwdm76C85SWB4LcUCrc7e0Ncc0
+
let url = '';
if (this._poll && this._poll.getValue) {
const polltemp = this._poll.getValue();
if (polltemp) {
- url = `${environment.frontDomain}#/poll/admin/${polltemp.admin_key}`;
+ url = `${environment.frontDomain}#/admin/${polltemp.admin_key}`;
}
+ } else {
+ url = `${environment.frontDomain}#/admin/${this.form.value.admin_key}`;
}
return url;
}
@@ -635,9 +652,13 @@ export class PollService implements Resolve {
newpoll.kind = form.value.kind;
newpoll.allow_comments = form.value.allowComments;
// merge choices from storage
+ if (form.value.kind === 'date') {
+ // convert calendar picker dates
+ }
newpoll.choices = Object.assign([], this.storageService.choices);
newpoll.dateChoices = Object.assign([], this.storageService.dateChoices);
newpoll.timeSlices = Object.assign([], this.storageService.timeSlices);
+ console.log('newpoll', newpoll);
return newpoll;
}
}
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 d6309d29..61adef2a 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
@@ -9,30 +9,19 @@
-
- précédent
-
-
-
-
-
- Enregistrer le sondage
+
+
+ modifier le sondage
-
Tout réinitialiser
-
-
- Slug automatique
-
-
{{ pollService.form.value.custom_url }}
diff --git a/src/app/features/administration/success/success.component.html b/src/app/features/administration/success/success.component.html
index 2876aaee..56ccb673 100644
--- a/src/app/features/administration/success/success.component.html
+++ b/src/app/features/administration/success/success.component.html
@@ -32,12 +32,12 @@
Pour accéder au sondage et à tous ses paramètres :
{{ pollService.getAdministrationUrl() }}
+ >{{ pollService.getAdministrationUrlFromForm() }}
-
+
-
+
Voir le sondage coté administrateur·ice
@@ -54,36 +54,16 @@
Pour voir le sondage :
- {{ pollService.getParticipationUrl() }}
+ {{ pollService.getParticipationUrlFromForm() }}
-
+
-
diff --git a/src/app/features/administration/success/success.component.scss b/src/app/features/administration/success/success.component.scss
index 17666849..4b6791ed 100644
--- a/src/app/features/administration/success/success.component.scss
+++ b/src/app/features/administration/success/success.component.scss
@@ -5,7 +5,7 @@ button {
margin-right: 1ch;
}
a {
- max-width: 20em;
+ max-width: 35em;
@extend .truncate;
}
.truncate {
@@ -13,3 +13,6 @@ a {
overflow: hidden;
text-overflow: ellipsis;
}
+:host {
+ padding: 2em;
+}