diff --git a/src/app/config/PollConfig.ts b/src/app/config/PollConfig.ts
index 8dccd035..9c95b220 100644
--- a/src/app/config/PollConfig.ts
+++ b/src/app/config/PollConfig.ts
@@ -31,6 +31,7 @@ export class PollConfig {
myName: string = 'mon pseudo';
myComment: string = 'wouah trop bien framadate!';
isAdmin: boolean = true;
+ myVoteStack: any;
myEmail: string = "tktest@tktest.com";
myPolls: any = [];// list of retrieved polls from the backend api
// date specific poll, we have the choice to setup different hours (timeList) for all possible dates (dateList), or use the same hours for all dates
diff --git a/src/app/pages/poll-display/poll-display.component.html b/src/app/pages/poll-display/poll-display.component.html
index d142edb0..f3750420 100644
--- a/src/app/pages/poll-display/poll-display.component.html
+++ b/src/app/pages/poll-display/poll-display.component.html
@@ -46,52 +46,25 @@
{{config.currentPoll.choices.length}} choix,
-
-
-
- Je veux modifier le vote de quelqu'un
-
-
-
- Supprimer tous les commentaires
-
-
-
- Supprimer tous les votes
-
-
-
- Supprimer ce sondage entièrement
-
-
-
- vérifier la disponibilité de l'url personnalisée
-
-
-
+ (click)='config.addVote()'
+ *ngIf='!config.myVoteStack || !config.myVoteStack.id' >
Envoyer
+
+ Mettre à jour
+
diff --git a/src/app/pages/poll-display/poll-display.component.ts b/src/app/pages/poll-display/poll-display.component.ts
index bf672ced..905e2d19 100644
--- a/src/app/pages/poll-display/poll-display.component.ts
+++ b/src/app/pages/poll-display/poll-display.component.ts
@@ -44,7 +44,7 @@ export class PollDisplayComponent extends BaseComponent implements OnInit {
// store it in the poll property here
this.config.getPollById(id).subscribe(
(res: any) => {
- console.log('res', res)
+ console.log('res', res);
this.config.currentPoll = res;
this.config.loading = false;
diff --git a/src/app/services/config.service.ts b/src/app/services/config.service.ts
index 04867ae7..d419bbdb 100644
--- a/src/app/services/config.service.ts
+++ b/src/app/services/config.service.ts
@@ -285,19 +285,21 @@ export class ConfigService extends PollConfig {
*/
createPollFromConfig(config: any) {
this.loading = true;
+ console.log('config', config)
return this.http.post(`${this.baseHref}/poll`,
config,
this.makeHeaders())
.subscribe((res: any) => {
// redirect to the page to administrate the new poll
this.messageService.add({severity: 'success', summary: 'Sondage Créé',});
- this.currentPoll = res;
- this.pollId = res.pollId;
+ this.currentPoll = res.data;
+ this.currentPoll.admin_key = res.admin_key;
+ this.pollId = res.data.id;
this.loading = false;
if (!this.myPolls) {
this.myPolls = [];
}
- this.myPolls.push(config);
+ this.myPolls.push(res);
this.router.navigate(['step/end']);
// TODO save new poll to localstorage
// reset all fields in current config
@@ -336,14 +338,19 @@ export class ConfigService extends PollConfig {
votes: this.convertChoicesAnsweredToSend(this.currentPoll.choices),
}
}
- console.log('voteStack', voteStack)
+ this.myVoteStack = voteStack;
+
this.http.post(
- `${this.baseHref}/poll/${this.currentPoll.id}/vote`,
+ `${this.baseHref}/poll/${this.pollId}/vote`,
voteStack,
this.makeHeaders())
.subscribe((res: any) => {
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;
}, (e) => {
this.handleError(e)
@@ -356,9 +363,15 @@ export class ConfigService extends PollConfig {
* /api/v1/poll/{id}/vote
* @param voteStack
*/
- updateVote(voteStack: any) {
+ updateVote(voteStack?: any) {
+ if (!this.myVoteStack) {
+ return;
+
+ } else {
+ voteStack = this.myVoteStack;
+ }
this.http.put(
- `${this.baseHref}/vote-stack/${voteStack.id}`,
+ `${this.baseHref}/vote-stack/${voteStack.id}/token/${voteStack.modifierToken}`,
voteStack,
this.makeHeaders())
.subscribe((res: any) => {