mirror of
https://framagit.org/framasoft/framadate/funky-framadate-front.git
synced 2023-08-25 13:53:14 +02:00
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) {
|
||||
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) {
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -102,10 +102,12 @@
|
||||
*ngIf="!storageService.vote_stack || !storageService.vote_stack.id"
|
||||
>
|
||||
<i class="fa fa-paper-plane" aria-hidden="true"></i> Envoyer
|
||||
|
||||
{{ storageService.vote_stack.votes.length }} réponses
|
||||
</button>
|
||||
<button
|
||||
class="btn btn--primary btn-block submit-votestack update"
|
||||
(click)="updateVoteStack(storageService.vote_stack)"
|
||||
(click)="updateVoteStack()"
|
||||
*ngIf="storageService.vote_stack && storageService.vote_stack.id"
|
||||
>
|
||||
<i class="fa fa-edit" aria-hidden="true"></i> Mettre à jour
|
||||
@ -118,9 +120,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<pre class="debug padded warning">
|
||||
storageService.vote_stack :
|
||||
{{ storageService.vote_stack | json }}
|
||||
</pre
|
||||
>
|
||||
</section>
|
||||
|
@ -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) => {
|
||||
|
@ -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',
|
||||
};
|
||||
|
@ -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',
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user