|
|
|
@ -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)
|
|
|
|
|
}
|
|
|
|
|