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 { export enum Answer {
YES = 'YES', YES = 'yes',
NO = 'NO', NO = 'no',
MAYBE = 'MAYBE', MAYBE = 'maybe',
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,32 +1,46 @@
{{ poll.choices_stats.length }} choix
<div <div
class="box" class="box"
*ngFor="let choice of poll.choices" *ngFor="let choice of poll.choices_stats"
[ngClass]="{ 'active has-background-success': choice.enabled }" [ngClass]="{ 'active has-background-success': choice.enabled }"
(click)="choice.enabled = !choice.enabled" (click)="choice.enabled = !choice.enabled"
> >
<div class="columns is-vcentered is-mobile"> <div class="columns is-vcentered is-mobile">
<div class="column"> <div class="column">
<label class="label">{{ choice.name }}</label> <label class="label">{{ choice.name }} </label>
</div> </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">--> <span class="counter">
<!-- <div class="buttons has-addons is-right" (click)="openModal(choice)">--> {{ choice[answerEnum.YES].count }}
<!-- <button class="button is-white">--> </span>
<!-- <img class="image is-24x24" src="../../../assets/img/icon_voter_YES.svg" />--> </button>
<button class="button is-white" *ngIf="poll.allowed_answers.indexOf('maybe') !== -1">
<!-- <span class="counter" *ngIf="choice.counts">--> <img class="image is-24x24" src="../../../assets/img/icon_voter_MAYBE.svg" />
<!-- {{ choice.counts.get(answerEnum.YES) }}--> <span class="counter">
<!-- </span>--> {{ choice[answerEnum.MAYBE].count }}
<!-- </button>--> </span>
<!-- <button class="button is-white" *ngIf="poll.allowed_answers.indexOf('maybe') !== -1">--> </button>
<!-- <img class="image is-24x24" src="../../../assets/img/icon_voter_MAYBE.svg" />--> <button class="button is-white" *ngIf="poll.allowed_answers.indexOf('no') !== -1">
<!-- &lt;!&ndash; {{ choice.counts.get(answerEnum.MAYBE) }}&ndash;&gt;--> <img class="image is-24x24" src="../../../assets/img/croix.svg" />
<!-- </button>--> <span class="counter">
<!-- <button class="button is-white" *ngIf="poll.allowed_answers.indexOf('no') !== -1">--> {{ choice[answerEnum.NO].count }}
<!-- <img class="image is-24x24" src="../../../assets/img/icon_voter_NO.svg" />--> </span>
<!-- {{ choice.counts.get(answerEnum.MAYBE) }}--> </button>
<!-- </button>--> </div>
<!-- </div>--> </div>
<!-- </div>-->
</div> </div>
</div> </div>