From 765299e1c3ae69bebfbad281592d9460ef4f9aa4 Mon Sep 17 00:00:00 2001 From: Tykayn Date: Fri, 30 Apr 2021 09:26:54 +0200 Subject: [PATCH] toast message on error send vote stack --- src/app/core/services/poll.service.ts | 33 ------------------- .../consultation/consultation.component.ts | 7 ++-- .../poll-results-detailed.component.html | 1 - .../poll-results-detailed.component.ts | 9 +---- 4 files changed, 5 insertions(+), 45 deletions(-) diff --git a/src/app/core/services/poll.service.ts b/src/app/core/services/poll.service.ts index b145f707..94302300 100644 --- a/src/app/core/services/poll.service.ts +++ b/src/app/core/services/poll.service.ts @@ -171,39 +171,6 @@ export class PollService implements Resolve { this.toastService.display('Les commentaires de ce sondage ont été supprimés.'); } - public buildAnswersByChoiceLabelByPseudo(poll: Poll): Map> { - const pseudos: Set = new Set(); - poll.choices.forEach((choice: Choice) => { - // choice.voters.forEach((users: Set) => { - // users.forEach((user: Owner) => { - // pseudos.add(user.pseudo); - // }); - // }); - }); - - const list = new Map>(); - pseudos.forEach((pseudo: string) => { - list.set( - pseudo, - new Map( - poll.choices.map((choice: Choice) => { - return [choice.name, undefined]; - }) - ) - ); - }); - - poll.choices.forEach((choice: Choice) => { - choice.participants.forEach((users: Set, answer: Answer) => { - users.forEach((user: Owner) => { - list.get(user.pseudo).set(choice.name, answer); - }); - }); - }); - - return list; - } - newPollFromForm(form: any): any { const newpoll = new Poll( this.userService.getCurrentUser(), diff --git a/src/app/features/consultation/consultation.component.ts b/src/app/features/consultation/consultation.component.ts index 3ae752ba..94a19b98 100644 --- a/src/app/features/consultation/consultation.component.ts +++ b/src/app/features/consultation/consultation.component.ts @@ -6,12 +6,11 @@ import { ModalService } from '../../core/services/modal.service'; import { PollService } from '../../core/services/poll.service'; import { DateService } from '../../core/services/date.service'; import { PollUtilitiesService } from '../../core/services/poll.utilities.service'; -import { Comment } from '../../core/models/comment.model'; import { StorageService } from '../../core/services/storage.service'; import { ApiService } from '../../core/services/api.service'; import { Stack } from '../../core/models/stack.model'; import { environment } from '../../../environments/environment'; -import { Title } from '@angular/platform-browser'; +import { ToastService } from '../../core/services/toast.service'; @Component({ selector: 'app-consultation', @@ -42,7 +41,7 @@ export class ConsultationComponent implements OnInit, OnDestroy { public api: ApiService, public pollService: PollService, public dateService: DateService, - private modalService: ModalService + public toastService: ToastService ) {} ngOnInit(): void { @@ -91,6 +90,8 @@ export class ConsultationComponent implements OnInit, OnDestroy { if (resp) { this.api.getPollBySlug(this.poll.custom_url); + } else { + this.toastService.display('erreur à la réception du nouveau vote', 'error'); } }); } diff --git a/src/app/features/consultation/poll-results-detailed/poll-results-detailed.component.html b/src/app/features/consultation/poll-results-detailed/poll-results-detailed.component.html index 44e6e7fb..8468857a 100644 --- a/src/app/features/consultation/poll-results-detailed/poll-results-detailed.component.html +++ b/src/app/features/consultation/poll-results-detailed/poll-results-detailed.component.html @@ -19,7 +19,6 @@ Score - {{ choice.score }} diff --git a/src/app/features/consultation/poll-results-detailed/poll-results-detailed.component.ts b/src/app/features/consultation/poll-results-detailed/poll-results-detailed.component.ts index e88994bd..556c2df3 100644 --- a/src/app/features/consultation/poll-results-detailed/poll-results-detailed.component.ts +++ b/src/app/features/consultation/poll-results-detailed/poll-results-detailed.component.ts @@ -9,24 +9,17 @@ import { PollService } from '../../../core/services/poll.service'; templateUrl: './poll-results-detailed.component.html', styleUrls: ['./poll-results-detailed.component.scss'], }) -export class PollResultsDetailedComponent implements OnInit { +export class PollResultsDetailedComponent { @Input() public poll: Poll; constructor(private pollService: PollService) {} - ngOnInit(): void {} - - public buildAnswersByChoiceLabelByPseudo(): Map> { - return this.pollService.buildAnswersByChoiceLabelByPseudo(this.poll); - } - stackHasVotesForChoice(stack, choice: any) { return undefined !== stack.votes[choice]; } getValue(stack, choice: any) { if (this.stackHasVotesForChoice(stack, choice)) { - console.log('stack.votes[choice.id]', stack.votes[choice]); return stack.votes[choice].value; } return null;