forked from tykayn/funky-framadate-front
toast message on error send vote stack
This commit is contained in:
parent
9e4d5187b5
commit
765299e1c3
@ -171,39 +171,6 @@ export class PollService implements Resolve<Poll> {
|
||||
this.toastService.display('Les commentaires de ce sondage ont été supprimés.');
|
||||
}
|
||||
|
||||
public buildAnswersByChoiceLabelByPseudo(poll: Poll): Map<string, Map<string, Answer>> {
|
||||
const pseudos: Set<string> = new Set();
|
||||
poll.choices.forEach((choice: Choice) => {
|
||||
// choice.voters.forEach((users: Set<Owner>) => {
|
||||
// users.forEach((user: Owner) => {
|
||||
// pseudos.add(user.pseudo);
|
||||
// });
|
||||
// });
|
||||
});
|
||||
|
||||
const list = new Map<string, Map<string, Answer>>();
|
||||
pseudos.forEach((pseudo: string) => {
|
||||
list.set(
|
||||
pseudo,
|
||||
new Map<string, Answer>(
|
||||
poll.choices.map((choice: Choice) => {
|
||||
return [choice.name, undefined];
|
||||
})
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
poll.choices.forEach((choice: Choice) => {
|
||||
choice.participants.forEach((users: Set<Owner>, 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(),
|
||||
|
@ -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');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -19,7 +19,6 @@
|
||||
Score
|
||||
</td>
|
||||
<td *ngFor="let choice of poll.choices">
|
||||
<!-- {{choice.id}} )-->
|
||||
{{ choice.score }}
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -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<string, Map<string, Answer>> {
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user