diff --git a/src/app/core/services/api.service.ts b/src/app/core/services/api.service.ts index 5a19a830..c737a2c0 100644 --- a/src/app/core/services/api.service.ts +++ b/src/app/core/services/api.service.ts @@ -206,7 +206,7 @@ export class ApiService { public async sendUpdateVoteStack(vote_stack: Stack) { try { 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 ); } catch (error) { diff --git a/src/app/core/services/storage.service.ts b/src/app/core/services/storage.service.ts index 03fd6cc7..4a37ee61 100644 --- a/src/app/core/services/storage.service.ts +++ b/src/app/core/services/storage.service.ts @@ -45,11 +45,7 @@ export class StorageService { @LocalStorage() public choices: Choice[] = []; - constructor( - public dateUtilities: DateUtilitiesService, - - private toastService: ToastService - ) { + constructor(public dateUtilities: DateUtilitiesService, private toastService: ToastService) { if (environment.autofill) { this.toastService.display('autofill des sondages utilisateur'); 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 = []; // text choices - for (const choice of choices_list) { - if (environment.autofill) { - this.toastService.display('autofill au hasard des votes à ce sondage'); - const defaultvalue = Math.random() > 0.75 ? 'yes' : ''; - this.vote_stack.votes.push(new Vote(choice.id, defaultvalue)); - } else { - this.vote_stack.votes.push(new Vote(choice.id)); + if (!this.vote_stack.id) { + for (const choice of choices_list) { + if (environment.autofill) { + console.log('autofill au hasard des votes à ce sondage'); + this.toastService.display('autofill au hasard des votes à ce sondage'); + const defaultvalue = Math.random() > 0.75 ? 'yes' : ''; + this.vote_stack.votes.push(new Vote(choice.id, defaultvalue)); + } else { + this.vote_stack.votes.push(new Vote(choice.id)); + } } } } diff --git a/src/app/features/consultation/consultation.component.html b/src/app/features/consultation/consultation.component.html index 5ef24a44..570bc090 100644 --- a/src/app/features/consultation/consultation.component.html +++ b/src/app/features/consultation/consultation.component.html @@ -102,10 +102,12 @@ *ngIf="!storageService.vote_stack || !storageService.vote_stack.id" > Envoyer + + {{ storageService.vote_stack.votes.length }} réponses Mettre à jour @@ -118,9 +120,4 @@ - - storageService.vote_stack : - {{ storageService.vote_stack | json }} - diff --git a/src/app/features/consultation/consultation.component.ts b/src/app/features/consultation/consultation.component.ts index 6d4fcd26..5f22a37e 100644 --- a/src/app/features/consultation/consultation.component.ts +++ b/src/app/features/consultation/consultation.component.ts @@ -87,9 +87,11 @@ export class ConsultationComponent implements OnInit, OnDestroy { * update existing 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; + console.log('updateVoteStack vote_stack', vote_stack); // const handlingError = this.api.handleError; this.api.sendUpdateVoteStack(vote_stack).then((resp) => { diff --git a/src/environments/endpoints.ts b/src/environments/endpoints.ts index eb97a2dd..ecc5eccf 100644 --- a/src/environments/endpoints.ts +++ b/src/environments/endpoints.ts @@ -1,14 +1,14 @@ export const backendApiUrlsInDev = { - local: 'http://localhost:8000/api/v1', - remote: 'http://localhost:8000/api/v1', + local: 'http://tktest.lan/api/v1', + remote: 'http://tktest.lan/api/v1', // remote: 'https://framadate-api.cipherbliss.com/api/v1', }; export const apiV1 = { - baseHref: 'http://tktest.lan/api/v1', + baseHref: 'http://localhost:8000/api/v1', // baseHref: 'https://framadate-api.cipherbliss.com/api/v1', api_new_poll: '/poll/', 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}', 'app.swagger': '/api/doc.json', }; diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 288fd6a7..37df09aa 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -6,6 +6,7 @@ const apiV1 = { baseHref: 'https://framadate-api.cipherbliss.com/api/v1', api_new_poll: '/poll/', api_get_poll: '/poll/{id}', + api_new_vote_stack: '/vote-stack', 'api_test-mail-poll': '/api/v1/poll/mail/test-mail-poll/{emailChoice}', 'app.swagger': '/api/doc.json', };
- storageService.vote_stack : - {{ storageService.vote_stack | json }} -