|
|
|
@ -290,6 +290,32 @@ export class ConfigService extends PollConfig {
|
|
|
|
|
this.urlAdmin = this.baseHref + '#/admin/' + res.admin_key;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* update current answers with a previous vote
|
|
|
|
|
* @param voteStack
|
|
|
|
|
*/
|
|
|
|
|
loadVoteStack(voteStack: any) {
|
|
|
|
|
|
|
|
|
|
// load the pseudo and email
|
|
|
|
|
this.myName = voteStack.pseudo;
|
|
|
|
|
this.myEmail = voteStack.pseudo;
|
|
|
|
|
this.voteStackId = voteStack.id;
|
|
|
|
|
this.myVoteStack = voteStack;
|
|
|
|
|
let votesId = Object.keys(voteStack.votes);
|
|
|
|
|
votesId.map((id) => {
|
|
|
|
|
let voteItem = voteStack.votes[id];
|
|
|
|
|
|
|
|
|
|
if (voteItem.choice_id && voteItem.value) {
|
|
|
|
|
let foundChoiceToModify = this.currentPoll.choices.find(choicesItem => {
|
|
|
|
|
return voteItem.choice_id == choicesItem.id
|
|
|
|
|
});
|
|
|
|
|
if (foundChoiceToModify) {
|
|
|
|
|
foundChoiceToModify.answer = voteItem.value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* POST
|
|
|
|
|
* /api/v1/poll/{id}/poll
|
|
|
|
@ -297,7 +323,7 @@ export class ConfigService extends PollConfig {
|
|
|
|
|
*/
|
|
|
|
|
createPollFromConfig(config: any) {
|
|
|
|
|
this.loading = true;
|
|
|
|
|
console.log('config', config)
|
|
|
|
|
console.log('config', config);
|
|
|
|
|
return this.http.post(`${this.baseHref}/poll`,
|
|
|
|
|
config,
|
|
|
|
|
this.makeHeaders())
|
|
|
|
@ -410,17 +436,17 @@ export class ConfigService extends PollConfig {
|
|
|
|
|
text: this.myComment,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
console.log('comment', comment)
|
|
|
|
|
console.log('comment', comment);
|
|
|
|
|
this.http.post(
|
|
|
|
|
`${this.baseHref}/poll/${this.pollId}/comment`,
|
|
|
|
|
comment,
|
|
|
|
|
this.makeHeaders())
|
|
|
|
|
.subscribe((res: any) => {
|
|
|
|
|
this.messageService.add({
|
|
|
|
|
severity: 'success',
|
|
|
|
|
summary: 'Commentaire Créé',
|
|
|
|
|
detail: comment.text
|
|
|
|
|
});
|
|
|
|
|
this.messageService.add({
|
|
|
|
|
severity: 'success',
|
|
|
|
|
summary: 'Commentaire Créé',
|
|
|
|
|
detail: comment.text
|
|
|
|
|
});
|
|
|
|
|
// empty comment after success
|
|
|
|
|
this.myComment = '';
|
|
|
|
|
comment.date = {
|
|
|
|
|