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

View File

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