diff --git a/src/app/config/PollConfig.ts b/src/app/config/PollConfig.ts index bd228ad5..a0534918 100644 --- a/src/app/config/PollConfig.ts +++ b/src/app/config/PollConfig.ts @@ -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'; diff --git a/src/app/pages/resume/resume.component.html b/src/app/pages/resume/resume.component.html index 1ab2dfee..08cbf9dc 100644 --- a/src/app/pages/resume/resume.component.html +++ b/src/app/pages/resume/resume.component.html @@ -8,14 +8,18 @@
créé par - {{config.myName}} + + {{config.myName}} +
-

+ {{config.description}} -

+
-
+
+
+
+ {{choice.literal}} + +
+
+ {{time.literal}} + +
+
+
+
- - +
+
diff --git a/src/app/services/config.service.ts b/src/app/services/config.service.ts index e7250368..a3074e05 100644 --- a/src/app/services/config.service.ts +++ b/src/app/services/config.service.ts @@ -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) }