change preview for dates type

This commit is contained in:
Baptiste Lemoine 2020-01-24 11:10:50 +01:00
parent a66933041f
commit 460e236d60
3 changed files with 63 additions and 23 deletions

View File

@ -25,7 +25,7 @@ export class PollConfig {
deletionDateAfterLastModification = 180; deletionDateAfterLastModification = 180;
step: number = 0; // step in the progress of creating a poll step: number = 0; // step in the progress of creating a poll
stepMax: number = 3; // step max in the progress of creating a poll stepMax: number = 3; // step max in the progress of creating a poll
pollType: string = 'classic';// classic or date pollType: string = 'dates';// classic or dates
title: string = 'titre'; title: string = 'titre';
description: string = 'ma description'; description: string = 'ma description';
myName: string = 'mon pseudo'; myName: string = 'mon pseudo';

View File

@ -8,14 +8,18 @@
</h2 > </h2 >
<div class="creation" > <div class="creation" >
créé par créé par
{{config.myName}} <i class='pseudo' >
{{config.myName}}
</i >
</div > </div >
<div class="description" > <div class="description" >
<p > <cite >
{{config.description}} {{config.description}}
</p > </cite >
</div > </div >
<section > <section
class='preview type-classic'
*ngIf='config.pollType == "classic"' >
<ul > <ul >
<li <li
markdown markdown
@ -28,19 +32,49 @@
</li > </li >
</ul > </ul >
</section > </section >
<section
class='type-date'
*ngIf='config.pollType == "dates"' >
<div
*ngFor="let choice of config.dateList; index as id"
class="date-choice"
>
{{choice.literal}}
<div
*ngIf="'true'==config.allowSeveralHours"
class="several-times"
>
<div
*ngFor="let time of choice.timeList; index as idTime"
class="time-choice"
>
{{time.literal}}
</div >
</div >
</div >
</section >
</div > </div >
<button [routerLink]="'/step/visibility'" <button
class="btn btn--primary btn--full"> [routerLink]="'/step/visibility'"
class="btn btn--primary btn--full" >
C'est parfait! C'est parfait!
</button> </button >
<div class="back" > <div class="back" >
<a <a
*ngIf='config.pollType == "classic"'
[routerLink]="'/step/answers'" [routerLink]="'/step/answers'"
class="prev" > class="prev" >
Retour Retour
</a > </a >
<a
*ngIf='config.pollType == "dates"'
[routerLink]="'/step/dates'"
class="prev" >
Retour
</a >
</div > </div >

View File

@ -278,6 +278,18 @@ export class ConfigService extends PollConfig {
this.createPollFromConfig(this.getPollConfig()) this.createPollFromConfig(this.getPollConfig())
} }
updateCurrentPollFromResponse(res: any) {
this.currentPoll = res.data;
this.currentPoll.admin_key = res.admin_key;
this.pollId = res.data.id;
this.urlPublic = this.baseHref + '#/vote/poll/id/' + res.data.id;
this.urlSlugPublic = this.baseHref + '#/vote/poll/slug/' + res.data.id;
if (res.data.customUrl) {
this.urlSlugPublic = this.baseHref + '#/vote/poll/id/' + res.data.customUrl;
}
this.urlAdmin = this.baseHref + '#/admin/' + res.admin_key;
}
/** /**
* POST * POST
* /api/v1/poll/{id}/poll * /api/v1/poll/{id}/poll
@ -292,15 +304,9 @@ export class ConfigService extends PollConfig {
.subscribe((res: any) => { .subscribe((res: any) => {
// redirect to the page to administrate the new poll // redirect to the page to administrate the new poll
this.messageService.add({severity: 'success', summary: 'Sondage Créé',}); this.messageService.add({severity: 'success', summary: 'Sondage Créé',});
this.currentPoll = res.data;
this.currentPoll.admin_key = res.admin_key; this.updateCurrentPollFromResponse(res);
this.pollId = res.data.id;
this.urlPublic = this.baseHref + '#/vote/poll/id/' + res.data.id;
this.urlSlugPublic = this.baseHref + '#/vote/poll/slug/' + res.data.id;
if (res.data.customUrl) {
this.urlSlugPublic = this.baseHref + '#/vote/poll/id/' + res.data.customUrl;
}
this.urlAdmin = this.baseHref + '#/admin/' + res.admin_key;
this.loading = false; this.loading = false;
if (!this.myPolls) { if (!this.myPolls) {
this.myPolls = []; this.myPolls = [];
@ -355,9 +361,9 @@ export class ConfigService extends PollConfig {
this.messageService.add({severity: 'success', summary: 'Vote ajouté'}); this.messageService.add({severity: 'success', summary: 'Vote ajouté'});
// save modifier token // save modifier token
voteStack['modifier_token'] = res.modifier_token; this.myVoteStack['modifier_token'] = res.modifier_token;
voteStack['id'] = res.vote_stack.id; this.myVoteStack['id'] = res.vote_stack.id;
this.currentPoll = res; this.updateCurrentPollFromResponse(res);
}, (e) => { }, (e) => {
this.handleError(e) this.handleError(e)
} }
@ -382,7 +388,7 @@ export class ConfigService extends PollConfig {
this.makeHeaders()) this.makeHeaders())
.subscribe((res: any) => { .subscribe((res: any) => {
this.messageService.add({severity: 'success', summary: 'Vote mis à jour'}); this.messageService.add({severity: 'success', summary: 'Vote mis à jour'});
this.currentPoll = res; this.updateCurrentPollFromResponse(res);
}, (e) => { }, (e) => {
this.handleError(e) this.handleError(e)
} }
@ -526,7 +532,7 @@ export class ConfigService extends PollConfig {
severity: 'success', severity: 'success',
summary: 'Sondage mis à jour', summary: 'Sondage mis à jour',
}); });
this.currentPoll = res; this.currentPoll = res.data;
}, (e) => { }, (e) => {
this.handleError(e) this.handleError(e)
} }