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;
step: number = 0; // step 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';
description: string = 'ma description';
myName: string = 'mon pseudo';

View File

@ -8,14 +8,18 @@
</h2 >
<div class="creation" >
créé par
<i class='pseudo' >
{{config.myName}}
</i >
</div >
<div class="description" >
<p >
<cite >
{{config.description}}
</p >
</cite >
</div >
<section >
<section
class='preview type-classic'
*ngIf='config.pollType == "classic"' >
<ul >
<li
markdown
@ -28,19 +32,49 @@
</li >
</ul >
</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 >
<button [routerLink]="'/step/visibility'"
class="btn btn--primary btn--full">
<button
[routerLink]="'/step/visibility'"
class="btn btn--primary btn--full" >
C'est parfait!
</button>
</button >
<div class="back" >
<a
*ngIf='config.pollType == "classic"'
[routerLink]="'/step/answers'"
class="prev" >
Retour
</a >
<a
*ngIf='config.pollType == "dates"'
[routerLink]="'/step/dates'"
class="prev" >
Retour
</a >
</div >

View File

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