show counters on answers and favourite answer

This commit is contained in:
Tykayn 2021-04-27 11:06:17 +02:00 committed by tykayn
parent 2d3457cf6f
commit 0abf924cae
7 changed files with 46 additions and 29 deletions

View File

@ -1,5 +1,5 @@
export enum Answer {
YES = 'YES',
NO = 'NO',
MAYBE = 'MAYBE',
YES = 'yes',
NO = 'no',
MAYBE = 'maybe',
}

View File

@ -5,8 +5,9 @@ export class Choice {
constructor(
public id: number,
public name: string,
public created_at: string,
public enabled: boolean,
public imageUrl?: string,
public url?: string,
public participants: Map<Answer, Set<User>> = new Map<Answer, Set<User>>([
[Answer.YES, new Set<User>()],
[Answer.NO, new Set<User>()],

View File

@ -30,6 +30,7 @@ export class Poll {
public allowSeveralHours?: boolean;
public archiveNumberOfDays?: number;
public max_score?: number;
public configuration: PollConfiguration = new PollConfiguration();
@ -66,8 +67,8 @@ export class Poll {
// new Comment(c.author, c.content, new Date(c.dateCreated))
// )
// .sort(Comment.sortChronologically),
// item.choices.map((c: Pick<Choice, 'label' | 'imageUrl' | 'participants' | 'counts'>) => {
// const choice = new Choice(c.label, c.imageUrl, new Map(c.participants));
// item.choices.map((c: Pick<Choice, 'label' | 'url' | 'participants' | 'counts'>) => {
// const choice = new Choice(c.label, c.url, new Map(c.participants));
// choice.participants.forEach((value, key) => {
// choice.participants.set(key, new Set(value));
// });

View File

@ -86,6 +86,7 @@ export class PollService implements Resolve<Poll> {
}
public updateCurrentPoll(poll: Poll): void {
console.log('poll', poll);
this._poll.next(poll);
}

View File

@ -107,7 +107,7 @@ export class DateSelectComponent implements OnInit {
// this.dateList.forEach(elem=>{
// const newControlGroup = this.fb.group({
// label: this.fb.control('', [Validators.required]),
// imageUrl: ['', [Validators.required]],
// url: ['', [Validators.required]],
// });
//
// this.choices.push(newControlGroup);

View File

@ -82,7 +82,7 @@
Detailed
</button>
</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>
</div>
</div>

View File

@ -1,6 +1,7 @@
{{ poll.choices_stats.length }} choix
<div
class="box"
*ngFor="let choice of poll.choices"
*ngFor="let choice of poll.choices_stats"
[ngClass]="{ 'active has-background-success': choice.enabled }"
(click)="choice.enabled = !choice.enabled"
>
@ -8,25 +9,38 @@
<div class="column">
<label class="label">{{ choice.name }} </label>
</div>
<div class="column is-narrow">
<span class="max_score" *ngIf="choice.score == poll.max_score">
<i class="fa fa-star fa-2x"></i>
</span>
</div>
<div class="column is-narrow">
<button class="button is-white" (click)="openModal(choice)">
<i class="fa fa-info-circle"></i>
</button>
</div>
<div class="column is-narrow">
<div class="buttons has-addons is-right">
<button class="button is-white">
<img class="image is-24x24" src="../../../assets/img/icon_voter_YES.svg" />
<!-- <div class="column is-narrow">-->
<!-- <div class="buttons has-addons is-right" (click)="openModal(choice)">-->
<!-- <button class="button is-white">-->
<!-- <img class="image is-24x24" src="../../../assets/img/icon_voter_YES.svg" />-->
<!-- <span class="counter" *ngIf="choice.counts">-->
<!-- {{ choice.counts.get(answerEnum.YES) }}-->
<!-- </span>-->
<!-- </button>-->
<!-- <button class="button is-white" *ngIf="poll.allowed_answers.indexOf('maybe') !== -1">-->
<!-- <img class="image is-24x24" src="../../../assets/img/icon_voter_MAYBE.svg" />-->
<!-- &lt;!&ndash; {{ choice.counts.get(answerEnum.MAYBE) }}&ndash;&gt;-->
<!-- </button>-->
<!-- <button class="button is-white" *ngIf="poll.allowed_answers.indexOf('no') !== -1">-->
<!-- <img class="image is-24x24" src="../../../assets/img/icon_voter_NO.svg" />-->
<!-- {{ choice.counts.get(answerEnum.MAYBE) }}-->
<!-- </button>-->
<!-- </div>-->
<!-- </div>-->
<span class="counter">
{{ choice[answerEnum.YES].count }}
</span>
</button>
<button class="button is-white" *ngIf="poll.allowed_answers.indexOf('maybe') !== -1">
<img class="image is-24x24" src="../../../assets/img/icon_voter_MAYBE.svg" />
<span class="counter">
{{ choice[answerEnum.MAYBE].count }}
</span>
</button>
<button class="button is-white" *ngIf="poll.allowed_answers.indexOf('no') !== -1">
<img class="image is-24x24" src="../../../assets/img/croix.svg" />
<span class="counter">
{{ choice[answerEnum.NO].count }}
</span>
</button>
</div>
</div>
</div>
</div>