35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
import { Component, Input, OnInit } from '@angular/core';
|
|
|
|
import { Answer } from '../../../core/enums/answer.enum';
|
|
import { Poll } from '../../../core/models/poll.model';
|
|
import { PollService } from '../../../core/services/poll.service';
|
|
|
|
@Component({
|
|
selector: 'app-poll-results-detailed',
|
|
templateUrl: './poll-results-detailed.component.html',
|
|
styleUrls: ['./poll-results-detailed.component.scss'],
|
|
})
|
|
export class PollResultsDetailedComponent implements OnInit {
|
|
@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;
|
|
}
|
|
}
|