forked from tykayn/funky-framadate-front
keep stack of vote after creation
This commit is contained in:
parent
e4ed956970
commit
748eb48125
@ -206,7 +206,7 @@ export class ApiService {
|
|||||||
public async sendUpdateVoteStack(vote_stack: Stack) {
|
public async sendUpdateVoteStack(vote_stack: Stack) {
|
||||||
try {
|
try {
|
||||||
return await this.axiosInstance.patch(
|
return await this.axiosInstance.patch(
|
||||||
`${this.baseHref}/vote-stack/${vote_stack.id}/token/${vote_stack.owner.modifier_token}/`,
|
`${this.baseHref}/vote-stack/${vote_stack.id}/token/${vote_stack.owner.modifier_token}`,
|
||||||
vote_stack
|
vote_stack
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -45,11 +45,7 @@ export class StorageService {
|
|||||||
@LocalStorage()
|
@LocalStorage()
|
||||||
public choices: Choice[] = [];
|
public choices: Choice[] = [];
|
||||||
|
|
||||||
constructor(
|
constructor(public dateUtilities: DateUtilitiesService, private toastService: ToastService) {
|
||||||
public dateUtilities: DateUtilitiesService,
|
|
||||||
|
|
||||||
private toastService: ToastService
|
|
||||||
) {
|
|
||||||
if (environment.autofill) {
|
if (environment.autofill) {
|
||||||
this.toastService.display('autofill des sondages utilisateur');
|
this.toastService.display('autofill des sondages utilisateur');
|
||||||
this.userPolls.push(new Poll(new Owner(), 'Démo: Anniversaire de tonton Patrick', 'aujourdhui-ou-demain'));
|
this.userPolls.push(new Poll(new Owner(), 'Démo: Anniversaire de tonton Patrick', 'aujourdhui-ou-demain'));
|
||||||
@ -68,13 +64,16 @@ export class StorageService {
|
|||||||
this.vote_stack.votes = [];
|
this.vote_stack.votes = [];
|
||||||
|
|
||||||
// text choices
|
// text choices
|
||||||
for (const choice of choices_list) {
|
if (!this.vote_stack.id) {
|
||||||
if (environment.autofill) {
|
for (const choice of choices_list) {
|
||||||
this.toastService.display('autofill au hasard des votes à ce sondage');
|
if (environment.autofill) {
|
||||||
const defaultvalue = Math.random() > 0.75 ? 'yes' : '';
|
console.log('autofill au hasard des votes à ce sondage');
|
||||||
this.vote_stack.votes.push(new Vote(choice.id, defaultvalue));
|
this.toastService.display('autofill au hasard des votes à ce sondage');
|
||||||
} else {
|
const defaultvalue = Math.random() > 0.75 ? 'yes' : '';
|
||||||
this.vote_stack.votes.push(new Vote(choice.id));
|
this.vote_stack.votes.push(new Vote(choice.id, defaultvalue));
|
||||||
|
} else {
|
||||||
|
this.vote_stack.votes.push(new Vote(choice.id));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,10 +102,12 @@
|
|||||||
*ngIf="!storageService.vote_stack || !storageService.vote_stack.id"
|
*ngIf="!storageService.vote_stack || !storageService.vote_stack.id"
|
||||||
>
|
>
|
||||||
<i class="fa fa-paper-plane" aria-hidden="true"></i> Envoyer
|
<i class="fa fa-paper-plane" aria-hidden="true"></i> Envoyer
|
||||||
|
|
||||||
|
{{ storageService.vote_stack.votes.length }} réponses
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="btn btn--primary btn-block submit-votestack update"
|
class="btn btn--primary btn-block submit-votestack update"
|
||||||
(click)="updateVoteStack(storageService.vote_stack)"
|
(click)="updateVoteStack()"
|
||||||
*ngIf="storageService.vote_stack && storageService.vote_stack.id"
|
*ngIf="storageService.vote_stack && storageService.vote_stack.id"
|
||||||
>
|
>
|
||||||
<i class="fa fa-edit" aria-hidden="true"></i> Mettre à jour
|
<i class="fa fa-edit" aria-hidden="true"></i> Mettre à jour
|
||||||
@ -118,9 +120,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<pre class="debug padded warning">
|
|
||||||
storageService.vote_stack :
|
|
||||||
{{ storageService.vote_stack | json }}
|
|
||||||
</pre
|
|
||||||
>
|
|
||||||
</section>
|
</section>
|
||||||
|
@ -87,9 +87,11 @@ export class ConsultationComponent implements OnInit, OnDestroy {
|
|||||||
* update existing vote stack
|
* update existing vote stack
|
||||||
* @param vote_stack
|
* @param vote_stack
|
||||||
*/
|
*/
|
||||||
updateVoteStack(vote_stack: Stack): void {
|
updateVoteStack(): void {
|
||||||
|
const vote_stack = this.storageService.vote_stack;
|
||||||
vote_stack.poll_custom_url = this.poll.custom_url;
|
vote_stack.poll_custom_url = this.poll.custom_url;
|
||||||
|
|
||||||
|
console.log('updateVoteStack vote_stack', vote_stack);
|
||||||
// const handlingError = this.api.handleError;
|
// const handlingError = this.api.handleError;
|
||||||
|
|
||||||
this.api.sendUpdateVoteStack(vote_stack).then((resp) => {
|
this.api.sendUpdateVoteStack(vote_stack).then((resp) => {
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
export const backendApiUrlsInDev = {
|
export const backendApiUrlsInDev = {
|
||||||
local: 'http://localhost:8000/api/v1',
|
local: 'http://tktest.lan/api/v1',
|
||||||
remote: 'http://localhost:8000/api/v1',
|
remote: 'http://tktest.lan/api/v1',
|
||||||
// remote: 'https://framadate-api.cipherbliss.com/api/v1',
|
// remote: 'https://framadate-api.cipherbliss.com/api/v1',
|
||||||
};
|
};
|
||||||
export const apiV1 = {
|
export const apiV1 = {
|
||||||
baseHref: 'http://tktest.lan/api/v1',
|
baseHref: 'http://localhost:8000/api/v1',
|
||||||
// baseHref: 'https://framadate-api.cipherbliss.com/api/v1',
|
// baseHref: 'https://framadate-api.cipherbliss.com/api/v1',
|
||||||
api_new_poll: '/poll/',
|
api_new_poll: '/poll/',
|
||||||
api_get_poll: '/poll/{id}',
|
api_get_poll: '/poll/{id}',
|
||||||
api_new_vote_stack: '/poll/{id}/answer',
|
api_new_vote_stack: '/vote-stack',
|
||||||
'api_test-mail-poll': '/api/v1/poll/mail/test-mail-poll/{emailChoice}',
|
'api_test-mail-poll': '/api/v1/poll/mail/test-mail-poll/{emailChoice}',
|
||||||
'app.swagger': '/api/doc.json',
|
'app.swagger': '/api/doc.json',
|
||||||
};
|
};
|
||||||
|
@ -6,6 +6,7 @@ const apiV1 = {
|
|||||||
baseHref: 'https://framadate-api.cipherbliss.com/api/v1',
|
baseHref: 'https://framadate-api.cipherbliss.com/api/v1',
|
||||||
api_new_poll: '/poll/',
|
api_new_poll: '/poll/',
|
||||||
api_get_poll: '/poll/{id}',
|
api_get_poll: '/poll/{id}',
|
||||||
|
api_new_vote_stack: '/vote-stack',
|
||||||
'api_test-mail-poll': '/api/v1/poll/mail/test-mail-poll/{emailChoice}',
|
'api_test-mail-poll': '/api/v1/poll/mail/test-mail-poll/{emailChoice}',
|
||||||
'app.swagger': '/api/doc.json',
|
'app.swagger': '/api/doc.json',
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user