🐛 handle no current poll

This commit is contained in:
Baptiste Lemoine 2020-01-24 12:11:28 +01:00
parent 22736f709e
commit f9d1cfff3a
2 changed files with 27 additions and 20 deletions

View File

@ -3,7 +3,7 @@
<ul > <ul >
<li > <li >
<a href='#title' > <a href='#title' >
{{config.currentPoll.data.title}} {{config.currentPoll.poll.title}}
</a > </a >
</li > </li >
<li > <li >
@ -32,13 +32,13 @@
</nav > </nav >
<div class='heading' > <div class='heading' >
<div class='col-xs-6' > <div class='col-xs-6' >
<h1 id='title' >{{config.currentPoll.data.title}}</h1 > <h1 id='title' >{{config.currentPoll.poll.title}}</h1 >
<p >{{config.currentPoll.data.description}}</p > <p >{{config.currentPoll.poll.description}}</p >
<span class="creationDate" > <span class="creationDate" >
Créé le {{config.currentPoll.data.creationDate.date}} Créé le {{config.currentPoll.poll.creationDate.date}}
</span > </span >
<span class="expiracyDate" > <span class="expiracyDate" >
Expire le {{config.currentPoll.data.expiracyDate.date}} Expire le {{config.currentPoll.poll.expiracyDate.date}}
</span > </span >
<div class="votants" > <div class="votants" >
<i class='fa fa-users' ></i > <i class='fa fa-users' ></i >
@ -73,7 +73,7 @@
<framadate-vote-choice <framadate-vote-choice
[choice]="choice" [choice]="choice"
[pollIsSpecialDate]="config.currentPoll.data.kind == 'date'" [pollIsSpecialDate]="config.currentPoll.poll.kind == 'date'"
[poll]='config.currentPoll' ></framadate-vote-choice > [poll]='config.currentPoll' ></framadate-vote-choice >
</div > </div >
</div > </div >
@ -132,12 +132,19 @@
class="btn btn--primary btn--outline" class="btn btn--primary btn--outline"
value="Ajouter mon commentaire" value="Ajouter mon commentaire"
(click)='config.addComment()' > (click)='config.addComment()' >
<div
class='comments-part'
*ngIf='config.currentPoll' >
<framadate-voting-comment <framadate-voting-comment
[comment]="c" [comment]="c"
*ngFor="let c of config.currentPoll.comments " > *ngFor="let c of config.currentPoll.comments " >
</framadate-voting-comment > </framadate-voting-comment >
</div >
</div > </div >
<div class="sharing" > <div
class="sharing"
*ngIf='config.currentPoll' >
<h3 class="margin-top-x8" >Partager le sondage <h3 class="margin-top-x8" >Partager le sondage
<i class='fa fa-share' ></i ></h3 > <i class='fa fa-share' ></i ></h3 >

View File

@ -163,7 +163,7 @@ export class ConfigService extends PollConfig {
) )
.subscribe((res: any) => { .subscribe((res: any) => {
this.customUrlIsUnique = res.data.isUnique; this.customUrlIsUnique = res.poll.isUnique;
this.loading = false; this.loading = false;
}, },
(e) => this.handleError(e)) (e) => this.handleError(e))
@ -262,7 +262,7 @@ export class ConfigService extends PollConfig {
) )
.subscribe( .subscribe(
(res: any) => { (res: any) => {
this.myPolls = res.data; // this.myPolls = res.poll;
}, (e) => { }, (e) => {
this.handleError(e) this.handleError(e)
} }
@ -279,13 +279,13 @@ export class ConfigService extends PollConfig {
} }
updateCurrentPollFromResponse(res: any) { updateCurrentPollFromResponse(res: any) {
this.currentPoll = res.data; this.currentPoll = res.poll;
this.currentPoll.admin_key = res.admin_key; this.currentPoll.admin_key = res.admin_key;
this.pollId = res.data.id; this.pollId = res.poll.id;
this.urlPublic = this.baseHref + '#/vote/poll/id/' + res.data.id; this.urlPublic = this.baseHref + '#/vote/poll/id/' + res.poll.id;
this.urlSlugPublic = this.baseHref + '#/vote/poll/slug/' + res.data.id; this.urlSlugPublic = this.baseHref + '#/vote/poll/slug/' + res.poll.id;
if (res.data.customUrl) { if (res.poll.customUrl) {
this.urlSlugPublic = this.baseHref + '#/vote/poll/id/' + res.data.customUrl; this.urlSlugPublic = this.baseHref + '#/vote/poll/id/' + res.poll.customUrl;
} }
this.urlAdmin = this.baseHref + '#/admin/' + res.admin_key; this.urlAdmin = this.baseHref + '#/admin/' + res.admin_key;
} }
@ -532,7 +532,7 @@ export class ConfigService extends PollConfig {
severity: 'success', severity: 'success',
summary: 'Sondage mis à jour', summary: 'Sondage mis à jour',
}); });
this.currentPoll = res.data; this.updateCurrentPollFromResponse(res);
}, (e) => { }, (e) => {
this.handleError(e) this.handleError(e)
} }