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 { public createPoll(): void {
console.log('this.form', this.form); console.log('this.form', this.form);
const newpoll = this.newPollFromForm(this.form); const newpoll = this.newPollFromForm(this.form);
console.log('newpoll', newpoll); this.apiService.createPoll(newpoll).then((resp) => {
this.apiService.createPoll(newpoll); 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; 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 { public getParticipationUrl(): string {
// http://localhost:4200/#/poll/dessin-anime/consultation // http://localhost:4200/#/poll/dessin-anime/consultation
@ -549,17 +559,24 @@ export class PollService implements Resolve<Poll> {
if (polltemp) { if (polltemp) {
url = `${environment.frontDomain}#/poll/${polltemp.custom_url}/consultation`; url = `${environment.frontDomain}#/poll/${polltemp.custom_url}/consultation`;
} }
} else {
url = `${environment.frontDomain}#/poll/${this.form.value.custom_url}/consultation`;
} }
// TODO handle pass access // TODO handle pass access
return url; return url;
} }
public getAdministrationUrl(): string { public getAdministrationUrl(): string {
// http://localhost:4200/#/admin/9S75b70ECXI5J5xDc058d3H40H9r2CHfO0Kj8T02EK2U8rY8fYTn-eS659j2Dhp794Oa6R1b9V70e3WGaE30iD9h45zwdm76C85SWB4LcUCrc7e0Ncc0
let url = ''; let url = '';
if (this._poll && this._poll.getValue) { if (this._poll && this._poll.getValue) {
const polltemp = this._poll.getValue(); const polltemp = this._poll.getValue();
if (polltemp) { 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; return url;
} }
@ -635,9 +652,13 @@ export class PollService implements Resolve<Poll> {
newpoll.kind = form.value.kind; newpoll.kind = form.value.kind;
newpoll.allow_comments = form.value.allowComments; newpoll.allow_comments = form.value.allowComments;
// merge choices from storage // merge choices from storage
if (form.value.kind === 'date') {
// convert calendar picker dates
}
newpoll.choices = Object.assign([], this.storageService.choices); newpoll.choices = Object.assign([], this.storageService.choices);
newpoll.dateChoices = Object.assign([], this.storageService.dateChoices); newpoll.dateChoices = Object.assign([], this.storageService.dateChoices);
newpoll.timeSlices = Object.assign([], this.storageService.timeSlices); newpoll.timeSlices = Object.assign([], this.storageService.timeSlices);
console.log('newpoll', newpoll);
return newpoll; return newpoll;
} }
} }

View File

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

View File

@ -32,12 +32,12 @@
Pour accéder au sondage et à tous ses paramètres : Pour accéder au sondage et à tous ses paramètres :
<br /> <br />
<a class="button is-info" routerLink="/admin/{{ pollService.form.value.admin_key }}" <a class="button is-info" routerLink="/admin/{{ pollService.form.value.admin_key }}"
>{{ pollService.getAdministrationUrl() }} >{{ pollService.getAdministrationUrlFromForm() }}
</a> </a>
<app-copy-text [textToCopy]="pollService.getAdministrationUrl()"></app-copy-text> <app-copy-text [textToCopy]="pollService.getAdministrationUrlFromForm()"></app-copy-text>
</p> </p>
<br /> <br />
<a class="button is-info" [href]="pollService.getAdministrationUrl()"> <a class="button is-info" [href]="pollService.getAdministrationUrlFromForm()">
Voir le sondage coté administrateur·ice Voir le sondage coté administrateur·ice
</a> </a>
<br /> <br />
@ -54,36 +54,16 @@
<p> <p>
Pour voir le sondage : Pour voir le sondage :
<br /> <br />
<a class="button is-info" routerLink="/poll/{{ pollService.form.value.custom_url }}/consultation" <a class="button is-info" [href]="pollService.getParticipationUrlFromForm()"
>{{ pollService.getParticipationUrl() }} >{{ pollService.getParticipationUrlFromForm() }}
</a> </a>
</p> </p>
<br /> <br />
<app-copy-text [textToCopy]="pollService.getParticipationUrl()"></app-copy-text> <app-copy-text [textToCopy]="pollService.getParticipationUrlFromForm()"></app-copy-text>
<br /> <br />
</div> </div>
<!-- <img src="assets/img/undraw_group_selfie_ijc6.svg" alt="image succès" />--> <!-- <img src="assets/img/undraw_group_selfie_ijc6.svg" alt="image succès" />-->
</div> </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>
</div> </div>

View File

@ -5,7 +5,7 @@ button {
margin-right: 1ch; margin-right: 1ch;
} }
a { a {
max-width: 20em; max-width: 35em;
@extend .truncate; @extend .truncate;
} }
.truncate { .truncate {
@ -13,3 +13,6 @@ a {
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
} }
:host {
padding: 2em;
}