mirror of
https://framagit.org/framasoft/framadate/funky-framadate-front.git
synced 2023-08-25 13:53:14 +02:00
update vote in frontend
This commit is contained in:
parent
5ce3984dc9
commit
5c290ea968
@ -81,7 +81,7 @@ export class PollService implements Resolve<Poll> {
|
|||||||
if (custom_url) {
|
if (custom_url) {
|
||||||
const poll: Poll | undefined = await this.apiService.getPollByCustomUrl(custom_url);
|
const poll: Poll | undefined = await this.apiService.getPollByCustomUrl(custom_url);
|
||||||
|
|
||||||
console.log({ loadPollBycustom_urlResponse: poll });
|
console.log('loadPollBycustom_urlResponse', poll);
|
||||||
if (poll) {
|
if (poll) {
|
||||||
this.updateCurrentPoll(poll);
|
this.updateCurrentPoll(poll);
|
||||||
this.titleService.setTitle(`☑️ ${poll.title} - ${environment.appTitle}`);
|
this.titleService.setTitle(`☑️ ${poll.title} - ${environment.appTitle}`);
|
||||||
@ -109,7 +109,11 @@ export class PollService implements Resolve<Poll> {
|
|||||||
public updateCurrentPoll(poll: Poll): void {
|
public updateCurrentPoll(poll: Poll): void {
|
||||||
console.log('update poll with: ', poll);
|
console.log('update poll with: ', poll);
|
||||||
|
|
||||||
this.storageService.setChoicesForVoteStack(poll.choices);
|
if (!this.storageService.vote_stack.id || this.storageService.vote_stack.poll_custom_url !== poll.custom_url) {
|
||||||
|
console.log('set base choices', poll.choices);
|
||||||
|
// set the choices only the first time the poll loads
|
||||||
|
this.storageService.setChoicesForVoteStack(poll.choices);
|
||||||
|
}
|
||||||
|
|
||||||
this.toastService.display('sondage bien mis à jour', 'success');
|
this.toastService.display('sondage bien mis à jour', 'success');
|
||||||
|
|
||||||
|
@ -119,12 +119,8 @@ export class StorageService {
|
|||||||
mapVotes(resp) {
|
mapVotes(resp) {
|
||||||
console.log('data', resp.data);
|
console.log('data', resp.data);
|
||||||
console.log('this.vote_stack', this.vote_stack);
|
console.log('this.vote_stack', this.vote_stack);
|
||||||
this.vote_stack.votes = [];
|
|
||||||
this.vote_stack.owner = resp.data.owner;
|
this.vote_stack.owner = resp.data.owner;
|
||||||
this.vote_stack.id = resp.data.id;
|
this.vote_stack.id = resp.data.id;
|
||||||
for (const vote of resp.data.votes) {
|
|
||||||
this.vote_stack.votes.push(vote);
|
|
||||||
}
|
|
||||||
console.log('this.vote_stack', this.vote_stack);
|
console.log('this.vote_stack', this.vote_stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,6 +86,17 @@
|
|||||||
Detailed
|
Detailed
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="pseudo-land">
|
||||||
|
<label for="vote_pseudo_vote_stack">
|
||||||
|
Votre pseudo:
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="vote_pseudo_vote_stack"
|
||||||
|
placeholder="votre pseudo"
|
||||||
|
[(ngModel)]="storageService.vote_stack.pseudo"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<app-poll-results-compact *ngIf="isCompactMode" [poll]="poll"></app-poll-results-compact>
|
<app-poll-results-compact *ngIf="isCompactMode" [poll]="poll"></app-poll-results-compact>
|
||||||
<app-poll-results-detailed *ngIf="!isCompactMode" [poll]="poll"></app-poll-results-detailed>
|
<app-poll-results-detailed *ngIf="!isCompactMode" [poll]="poll"></app-poll-results-detailed>
|
||||||
</div>
|
</div>
|
||||||
|
@ -85,21 +85,23 @@ export class ConsultationComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* update existing vote stack
|
* update existing vote stack
|
||||||
* @param vote_stack
|
* @param Stack
|
||||||
*/
|
*/
|
||||||
updateVoteStack(): void {
|
updateVoteStack(): void {
|
||||||
const vote_stack = this.storageService.vote_stack;
|
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);
|
console.log('updateVoteStack vote_stack.votes', vote_stack.votes.length, vote_stack.votes);
|
||||||
// const handlingError = this.api.handleError;
|
const handlingError = this.api.ousideHandleError;
|
||||||
|
|
||||||
this.api.sendUpdateVoteStack(vote_stack).then((resp) => {
|
this.api
|
||||||
console.log('sendUpdateVoteStack resp', resp);
|
.sendUpdateVoteStack(vote_stack)
|
||||||
this.storeVoteStackAndReloadPoll(resp);
|
.then((resp) => {
|
||||||
this.toastService.display('vote bien mis à jour', 'success');
|
console.log('sendUpdateVoteStack updated resp', resp);
|
||||||
});
|
// this.storeVoteStackAndReloadPoll(resp);
|
||||||
// .catch(handlingError);
|
this.toastService.display('vote bien mis à jour', 'success');
|
||||||
|
})
|
||||||
|
.catch(handlingError);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
export const backendApiUrlsInDev = {
|
export const backendApiUrlsInDev = {
|
||||||
local: 'http://tktest.lan/api/v1',
|
local: 'http://tktest.lan/api/v1',
|
||||||
// remote: 'http://tktest.lan/api/v1',
|
remote: 'http://tktest.lan/api/v1',
|
||||||
// local: 'http://localhost:8000/api/v1',
|
// local: 'http://localhost:8000/api/v1',
|
||||||
remote: 'http://localhost:8000/api/v1',
|
// remote: 'http://localhost:8000/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://localhost:8000/api/v1',
|
// baseHref: 'http://localhost:8000/api/v1',
|
||||||
// baseHref: 'http://tktest.lan/api/v1',
|
baseHref: 'http://tktest.lan/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}',
|
||||||
|
Loading…
Reference in New Issue
Block a user