mirror of
https://framagit.org/framasoft/framadate/funky-framadate-front.git
synced 2023-08-25 13:53:14 +02:00
display stack answer and toggle fluently between answers to votes
This commit is contained in:
parent
f1e6b5955e
commit
4464a0af2c
@ -34,7 +34,7 @@ export class StorageService {
|
||||
toggleAnswer(choice_id: number, value: string) {
|
||||
for (let vote of this.vote_stack.votes) {
|
||||
if (vote.choice_id == choice_id) {
|
||||
if (vote.value) {
|
||||
if (vote.value == value) {
|
||||
vote.value = '';
|
||||
} else {
|
||||
vote.value = value;
|
||||
@ -42,4 +42,15 @@ export class StorageService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
choiceHasAnswerOfValue(choice_id: number, value: any) {
|
||||
for (let vote of this.vote_stack.votes) {
|
||||
if (vote.choice_id == choice_id) {
|
||||
if (vote.value == value) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -24,20 +24,35 @@
|
||||
</div>
|
||||
<div class="column is-narrow">
|
||||
<div class="buttons has-addons is-right">
|
||||
<button class="button is-white" (click)="toggleAnswer(choice.id, 'yes')">
|
||||
<button
|
||||
class="button is-white"
|
||||
[ngClass]="{ 'is-primary': storageService.choiceHasAnswerOfValue(choice.id, 'yes') }"
|
||||
(click)="toggleAnswer(choice.id, 'yes')"
|
||||
*ngIf="poll.allowed_answers.indexOf('yes') !== -1"
|
||||
>
|
||||
<img class="image is-24x24" src="../../../assets/img/icon_voter_YES.svg" />
|
||||
|
||||
<span class="counter" *ngIf="choice[answerEnum.YES].count * 1 > 0">
|
||||
{{ choice[answerEnum.YES].count }}
|
||||
</span>
|
||||
</button>
|
||||
<button class="button is-white" *ngIf="poll.allowed_answers.indexOf('maybe') !== -1">
|
||||
<button
|
||||
class="button is-white"
|
||||
[ngClass]="{ 'is-primary': storageService.choiceHasAnswerOfValue(choice.id, 'maybe') }"
|
||||
(click)="toggleAnswer(choice.id, 'maybe')"
|
||||
*ngIf="poll.allowed_answers.indexOf('maybe') !== -1"
|
||||
>
|
||||
<img class="image is-24x24" src="../../../assets/img/icon_voter_MAYBE.svg" />
|
||||
<span class="counter" *ngIf="choice[answerEnum.YES].count * 1 > 0">
|
||||
{{ choice[answerEnum.MAYBE].count }}
|
||||
</span>
|
||||
</button>
|
||||
<button class="button is-white" *ngIf="poll.allowed_answers.indexOf('no') !== -1">
|
||||
<button
|
||||
class="button is-white"
|
||||
[ngClass]="{ 'is-primary': storageService.choiceHasAnswerOfValue(choice.id, 'no') }"
|
||||
(click)="toggleAnswer(choice.id, 'no')"
|
||||
*ngIf="poll.allowed_answers.indexOf('no') !== -1"
|
||||
>
|
||||
<img class="image is-24x24" src="../../../assets/img/croix.svg" />
|
||||
<span class="counter" *ngIf="choice[answerEnum.YES].count * 1 > 0">
|
||||
{{ choice[answerEnum.NO].count }}
|
||||
|
Loading…
Reference in New Issue
Block a user