success page displays links from form data

This commit is contained in:
Tykayn 2021-11-08 12:36:18 +01:00 committed by tykayn
parent afdaf04a8f
commit c2c193bfa9
4 changed files with 37 additions and 44 deletions

View File

@ -356,8 +356,11 @@ export class PollService implements Resolve<Poll> {
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<Poll> {
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<Poll> {
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<Poll> {
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;
}
}

View File

@ -9,30 +9,19 @@
<div class="columns">
<div class="column">
<button class="button is-secondary is-fullwidth" [routerLink]="['/administration/step/4']">
précédent
</button>
</div>
<div class="column">
<button class="btn is-success" (click)="createPoll()">
<i class="fa fa-save"></i>
Enregistrer le sondage
<button class="button is-primary is-fullwidth" [routerLink]="['/administration/step/1']">
<i class="fa fa-pencil"></i>
modifier le sondage
</button>
</div>
</div>
<section class="supplement">
<img src="assets/img/undraw_Moving_twwf.svg" alt="image WIP" />
<button class="btn btn--warning" (click)="askInitFormDefault()">
<i class="fa fa-refresh"></i>
Tout réinitialiser
</button>
<button class="btn is-default" (click)="pollService.automaticSlug()">
<i class="fa fa-save"></i>
Slug automatique
</button>
<div class="well">
{{ pollService.form.value.custom_url }}
</div>

View File

@ -32,12 +32,12 @@
Pour accéder au sondage et à tous ses paramètres :
<br />
<a class="button is-info" routerLink="/admin/{{ pollService.form.value.admin_key }}"
>{{ pollService.getAdministrationUrl() }}
>{{ pollService.getAdministrationUrlFromForm() }}
</a>
<app-copy-text [textToCopy]="pollService.getAdministrationUrl()"></app-copy-text>
<app-copy-text [textToCopy]="pollService.getAdministrationUrlFromForm()"></app-copy-text>
</p>
<br />
<a class="button is-info" [href]="pollService.getAdministrationUrl()">
<a class="button is-info" [href]="pollService.getAdministrationUrlFromForm()">
Voir le sondage coté administrateur·ice
</a>
<br />
@ -54,36 +54,16 @@
<p>
Pour voir le sondage :
<br />
<a class="button is-info" routerLink="/poll/{{ pollService.form.value.custom_url }}/consultation"
>{{ pollService.getParticipationUrl() }}
<a class="button is-info" [href]="pollService.getParticipationUrlFromForm()"
>{{ pollService.getParticipationUrlFromForm() }}
</a>
</p>
<br />
<app-copy-text [textToCopy]="pollService.getParticipationUrl()"></app-copy-text>
<app-copy-text [textToCopy]="pollService.getParticipationUrlFromForm()"></app-copy-text>
<br />
</div>
<!-- <img src="assets/img/undraw_group_selfie_ijc6.svg" alt="image succès" />-->
</div>
<section class="mail">
<h2 i18n>{{ 'resume.links_mail' | translate }}</h2>
<p>
<label for="email">
Pour être sûr de retrouver ces liens, nous pouvons vous les envoyer sur votre mail :
</label>
<br />
<input type="email" id="email" name="email" [(ngModel)]="poll.creatorEmail" placeholder="email" />
<br />
<button class="btn btn--primary" (click)="sendToEmail()">
Envoyer les liens du sondage
<i class="fa fa-paper-plane" aria-hidden="true"></i>
</button>
<br />
<br />
<a class="button is-info" href="{{ pollService.form.value.custom_url }}">
Voir le sondage côté public
</a>
</p>
</section>
</div>
</div>

View File

@ -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;
}