disabled button when nothing is selected, detect counts

This commit is contained in:
Baptiste Lemoine 2020-01-29 16:30:07 +01:00
parent e227344647
commit 0369d934bd
10 changed files with 324 additions and 92 deletions

View File

@ -33,6 +33,7 @@ export class PollConfig {
myComment: string = 'wouah trop bien framadate!'; myComment: string = 'wouah trop bien framadate!';
isAdmin: boolean = true; isAdmin: boolean = true;
myVoteStack: any; myVoteStack: any;
myTempVoteStack =0;
myEmail: string = "tktest@tktest.com"; myEmail: string = "tktest@tktest.com";
myPolls: any = [];// list of retrieved polls from the backend api myPolls: any = [];// list of retrieved polls from the backend api
// date specific poll, we have the choice to setup different hours (timeList) for all possible dates (dateList), or use the same hours for all dates // date specific poll, we have the choice to setup different hours (timeList) for all possible dates (dateList), or use the same hours for all dates

View File

@ -1,6 +1,6 @@
export const mockPoll3 = { export const mockPoll3 = {
"message": "your poll config", "message": "your poll config",
"data": { "poll": {
"id": 3, "id": 3,
"title": "dessin animé préféré", "title": "dessin animé préféré",
"customUrl": null, "customUrl": null,
@ -37,7 +37,7 @@ export const mockPoll3 = {
"comments": {}, "comments": {},
"defaultExpiracyDaysFromNow": 60 "defaultExpiracyDaysFromNow": 60
}, },
"stacks_count": 10, "stacks_count": 14,
"stacks": [ "stacks": [
{ {
"id": 3, "id": 3,
@ -351,9 +351,206 @@ export const mockPoll3 = {
"text": "Les mystérieuses cités d'or" "text": "Les mystérieuses cités d'or"
} }
] ]
},
{
"id": 13,
"pseudo": "tk_TEST",
"creation_date": {
"date": "2020-01-23 14:31:07.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
},
"votes": [
{
"id": 13,
"vote_id": 33,
"value": "yes",
"choice_id": 2,
"text": null
}
]
},
{
"id": 14,
"pseudo": "tk_TEST",
"creation_date": {
"date": "2020-01-23 14:33:07.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
},
"votes": [
{
"id": 14,
"vote_id": 34,
"value": "yes",
"choice_id": 2,
"text": null
}
]
},
{
"id": 15,
"pseudo": "tk_TEST",
"creation_date": {
"date": "2020-01-23 14:33:11.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
},
"votes": [
{
"id": 15,
"vote_id": 35,
"value": "yes",
"choice_id": 2,
"text": null
}
]
},
{
"id": 16,
"pseudo": "tk_TEST",
"creation_date": {
"date": "2020-01-23 14:34:11.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
},
"votes": [
{
"id": 16,
"vote_id": 36,
"value": "no",
"choice_id": 1,
"text": "orange"
},
{
"id": 16,
"vote_id": 37,
"value": "yes",
"choice_id": 2,
"text": null
}
]
} }
], ],
"choices_count": 7, "choices_count": {
"counts": {
"7": {
"yes": {
"count": 10,
"people": [
"voting_people_TEST",
"voting_people_TEST",
"voting_people_TEST",
"voting_people_TEST",
"voting_people_TEST",
"voting_people_TEST",
"voting_people_TEST",
"voting_people_TEST",
"voting_people_TEST",
"voting_people_TEST"
]
},
"maybe": {
"count": 0,
"people": []
},
"no": {
"count": 1,
"people": [
"voting_people_TEST"
]
}
},
"6": {
"yes": {
"count": 1,
"people": [
"voting_people_TEST"
]
},
"maybe": {
"count": 9,
"people": [
"voting_people_TEST",
"voting_people_TEST",
"voting_people_TEST",
"voting_people_TEST",
"voting_people_TEST",
"voting_people_TEST",
"voting_people_TEST",
"voting_people_TEST",
"voting_people_TEST"
]
},
"no": {
"count": 0,
"people": []
}
},
"5": {
"yes": {
"count": 0,
"people": []
},
"maybe": {
"count": 0,
"people": []
},
"no": {
"count": 8,
"people": [
"voting_people_TEST",
"voting_people_TEST",
"voting_people_TEST",
"voting_people_TEST",
"voting_people_TEST",
"voting_people_TEST",
"voting_people_TEST",
"voting_people_TEST"
]
}
},
"2": {
"yes": {
"count": 4,
"people": [
"tk_TEST",
"tk_TEST",
"tk_TEST",
"tk_TEST"
]
},
"maybe": {
"count": 0,
"people": []
},
"no": {
"count": 0,
"people": []
}
},
"1": {
"yes": {
"count": 0,
"people": []
},
"maybe": {
"count": 0,
"people": []
},
"no": {
"count": 1,
"people": [
"tk_TEST"
]
}
}
},
"people": {
"voting_people_TEST": "yes",
"tk_TEST": "yes"
}
},
"choices": [ "choices": [
{ {
"id": 5, "id": 5,
@ -362,7 +559,8 @@ export const mockPoll3 = {
"timezone_type": 3, "timezone_type": 3,
"timezone": "Europe/Berlin" "timezone": "Europe/Berlin"
}, },
"text": "Vic le viking" "text": "Vic le viking",
"url": null
}, },
{ {
"id": 6, "id": 6,
@ -371,7 +569,8 @@ export const mockPoll3 = {
"timezone_type": 3, "timezone_type": 3,
"timezone": "Europe/Berlin" "timezone": "Europe/Berlin"
}, },
"text": "Boumbo petite automobile" "text": "Boumbo petite automobile",
"url": null
}, },
{ {
"id": 7, "id": 7,
@ -380,7 +579,8 @@ export const mockPoll3 = {
"timezone_type": 3, "timezone_type": 3,
"timezone": "Europe/Berlin" "timezone": "Europe/Berlin"
}, },
"text": "Les mystérieuses cités d'or" "text": "Les mystérieuses cités d'or",
"url": null
}, },
{ {
"id": 8, "id": 8,
@ -389,7 +589,8 @@ export const mockPoll3 = {
"timezone_type": 3, "timezone_type": 3,
"timezone": "Europe/Berlin" "timezone": "Europe/Berlin"
}, },
"text": "Les mondes engloutis" "text": "Les mondes engloutis",
"url": null
}, },
{ {
"id": 9, "id": 9,
@ -398,7 +599,8 @@ export const mockPoll3 = {
"timezone_type": 3, "timezone_type": 3,
"timezone": "Europe/Berlin" "timezone": "Europe/Berlin"
}, },
"text": "Foot 2 rue" "text": "Foot 2 rue",
"url": null
}, },
{ {
"id": 10, "id": 10,
@ -407,7 +609,8 @@ export const mockPoll3 = {
"timezone_type": 3, "timezone_type": 3,
"timezone": "Europe/Berlin" "timezone": "Europe/Berlin"
}, },
"text": "Le chat, la vache, et l'océan" "text": "Le chat, la vache, et l'océan",
"url": null
}, },
{ {
"id": 11, "id": 11,
@ -416,7 +619,8 @@ export const mockPoll3 = {
"timezone_type": 3, "timezone_type": 3,
"timezone": "Europe/Berlin" "timezone": "Europe/Berlin"
}, },
"text": "Digimon" "text": "Digimon",
"url": null
} }
], ],
"comments": [ "comments": [
@ -562,4 +766,4 @@ export const mockPoll3 = {
} }
], ],
"comments_count": 14 "comments_count": 14
}; }

View File

@ -1,19 +1,19 @@
export const mockPoll1 = { export const mockPoll1 = {
"message": "your poll config", "message": "your poll config",
"data": { "poll": {
"id": 1, "id": 1,
"title": "citron ou orange", "title": "citron ou orange",
"customUrl": null, "customUrl": null,
"description": "votre sorbert préféré", "description": "votre sorbert préféré",
"creationDate": { "creationDate": {
"date": "2020-01-22 14:28:19.000000", "date": "2020-01-20 16:45:48.000000",
"timezone_type": 3, "timezone_type": 3,
"timezone": "Europe/Paris" "timezone": "Europe/Berlin"
}, },
"expiracyDate": { "expiracyDate": {
"date": "2020-01-22 14:28:19.000000", "date": "2020-01-20 16:45:48.000000",
"timezone_type": 3, "timezone_type": 3,
"timezone": "Europe/Paris" "timezone": "Europe/Berlin"
}, },
"owner": { "owner": {
"__initializer__": {}, "__initializer__": {},
@ -41,9 +41,9 @@ export const mockPoll1 = {
"id": 1, "id": 1,
"pseudo": "voting_people_TEST", "pseudo": "voting_people_TEST",
"creation_date": { "creation_date": {
"date": "2020-01-22 14:28:19.000000", "date": "2020-01-20 16:45:48.000000",
"timezone_type": 3, "timezone_type": 3,
"timezone": "Europe/Paris" "timezone": "Europe/Berlin"
}, },
"votes": [ "votes": [
{ {
@ -66,9 +66,9 @@ export const mockPoll1 = {
"id": 2, "id": 2,
"pseudo": "voting_people_TEST", "pseudo": "voting_people_TEST",
"creation_date": { "creation_date": {
"date": "2020-01-22 14:28:19.000000", "date": "2020-01-20 16:45:48.000000",
"timezone_type": 3, "timezone_type": 3,
"timezone": "Europe/Paris" "timezone": "Europe/Berlin"
}, },
"votes": [ "votes": [
{ {
@ -81,14 +81,30 @@ export const mockPoll1 = {
] ]
} }
], ],
"choices_count": 2, "choices_count": {
"counts": {
"1": {
"yes": 1,
"maybe": 1,
"no": 0
},
"2": {
"yes": 1,
"maybe": 0,
"no": 0
}
},
"people": {
"voting_people_TEST": "maybe"
}
},
"choices": [ "choices": [
{ {
"id": 1, "id": 1,
"date": { "date": {
"date": "2020-01-22 14:28:19.000000", "date": "2020-01-20 16:45:48.000000",
"timezone_type": 3, "timezone_type": 3,
"timezone": "Europe/Paris" "timezone": "Europe/Berlin"
}, },
"text": "orange", "text": "orange",
"url": null "url": null
@ -96,23 +112,14 @@ export const mockPoll1 = {
{ {
"id": 2, "id": 2,
"date": { "date": {
"date": "2020-01-22 14:28:19.000000", "date": "2020-01-20 16:45:48.000000",
"timezone_type": 3, "timezone_type": 3,
"timezone": "Europe/Paris" "timezone": "Europe/Berlin"
}, },
"text": "citron", "text": "citron",
"url": null "url": null
} }
], ],
"comments": [{ "comments": [],
"id": 4,
"text": "wouah trop bien framadate HOUHOUUUU!",
"pseudo": "tk_TEST",
"date": {
"date": "2020-01-22 16:00:22.000000",
"timezone_type": 3,
"timezone": "Europe/Paris"
}
},],
"comments_count": 0 "comments_count": 0
}; };

View File

@ -73,18 +73,22 @@
<framadate-vote-choice <framadate-vote-choice
[choice]="choice" [choice]="choice"
[choices_count]="config.currentPoll.choices_count"
[pollIsSpecialDate]="config.currentPoll.poll.kind == 'date'" [pollIsSpecialDate]="config.currentPoll.poll.kind == 'date'"
[poll]='config.currentPoll' ></framadate-vote-choice > [poll]='config.currentPoll' ></framadate-vote-choice >
</div > </div >
</div > </div >
<button <button
class='btn btn--primary btn-block' class='btn btn-block submit-votestack'
(click)='config.addVote()' (click)='config.addVote()'
[disabled]='!config.myTempVoteStack'
[ngClass]='{"btn--primary" : config.myTempVoteStack } '
*ngIf='!config.myVoteStack || !config.myVoteStack.id' > *ngIf='!config.myVoteStack || !config.myVoteStack.id' >
<i class='fa fa-paper-plane' ></i > Envoyer <i class='fa fa-paper-plane' ></i > Envoyer
<!-- ( {{config.myTempVoteStack}} )-->
</button > </button >
<button <button
class='btn btn--primary btn-block' class='btn btn--primary btn-block submit-votestack update'
(click)='config.updateVote(config.myVoteStack)' (click)='config.updateVote(config.myVoteStack)'
*ngIf='config.myVoteStack && config.myVoteStack.id' > *ngIf='config.myVoteStack && config.myVoteStack.id' >
<i class='fa fa-pencil' ></i > Mettre à jour <i class='fa fa-pencil' ></i > Mettre à jour

View File

@ -1 +1,7 @@
@import "../../../assets/scss/variables"; @import "../../../assets/scss/variables";
.submit-votestack {
position: fixed;
bottom: 5px;
right: 5px;
}

View File

@ -3,6 +3,8 @@ import {BaseComponent} from "../base-page/base.component";
import {ConfigService} from "../../services/config.service"; import {ConfigService} from "../../services/config.service";
import {mockComments} from "../../config/mocks/mock-comments"; import {mockComments} from "../../config/mocks/mock-comments";
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {environment} from "../../../environments/environment";
import {mockPoll3} from "../../config/mocks/mock-poll3";
@Component({ @Component({
selector: 'framadate-poll-display', selector: 'framadate-poll-display',
@ -38,6 +40,11 @@ export class PollDisplayComponent extends BaseComponent implements OnInit {
const id = this.activeRoute.snapshot.params.poll; const id = this.activeRoute.snapshot.params.poll;
const pollSlug = this.activeRoute.snapshot.params.pollSlug; const pollSlug = this.activeRoute.snapshot.params.pollSlug;
if (!environment.production) {
console.log('mockPoll3', mockPoll3)
this.config.currentPoll = mockPoll3;
return;
}
if (id) { if (id) {
this.config.loading = true; this.config.loading = true;
this.config.pollId = id; this.config.pollId = id;
@ -46,6 +53,7 @@ export class PollDisplayComponent extends BaseComponent implements OnInit {
(res: any) => { (res: any) => {
console.log('res', res); console.log('res', res);
this.config.currentPoll = res; this.config.currentPoll = res;
this.config.loading = false; this.config.loading = false;
}, (e) => { }, (e) => {

View File

@ -6,7 +6,7 @@ import {ConfirmationService, MessageService} from 'primeng/api';
import {Router} from "@angular/router"; import {Router} from "@angular/router";
import {mockMyPolls} from "../config/mocks/mockmypolls"; import {mockMyPolls} from "../config/mocks/mockmypolls";
import {defaultAnswers, defaultDates, defaultTimeOfDay} from "../config/defaultConfigs"; import {defaultAnswers, defaultDates, defaultTimeOfDay} from "../config/defaultConfigs";
import {mockPoll1} from "../config/mocks/mock1"; import {mockPoll3} from "../config/mocks/mock-poll3";
/** /**
* le service transverse à chaque page qui permet de syncroniser la configuration de sondage souhaitée * le service transverse à chaque page qui permet de syncroniser la configuration de sondage souhaitée
@ -29,7 +29,7 @@ export class ConfigService extends PollConfig {
// fill in mock values if we are not in production environment // fill in mock values if we are not in production environment
if (!environment.production) { if (!environment.production) {
console.info(' ######### framadate ######### we are not in production env, filling with mock values'); console.info(' ######### framadate ######### we are not in production env, filling with mock values');
this.currentPoll = mockPoll1; this.currentPoll = mockPoll3;
this.myPolls = mockMyPolls; this.myPolls = mockMyPolls;
this.dateList = defaultDates; this.dateList = defaultDates;
this.timeList = defaultTimeOfDay; this.timeList = defaultTimeOfDay;
@ -279,8 +279,8 @@ export class ConfigService extends PollConfig {
} }
updateCurrentPollFromResponse(res: any) { updateCurrentPollFromResponse(res: any) {
this.currentPoll = res.poll; console.log('update res', res);
this.currentPoll.admin_key = res.admin_key; this.currentPoll = res;
this.pollId = res.poll.id; this.pollId = res.poll.id;
this.urlPublic = this.baseHref + '#/vote/poll/id/' + res.poll.id; this.urlPublic = this.baseHref + '#/vote/poll/id/' + res.poll.id;
this.urlSlugPublic = this.baseHref + '#/vote/poll/slug/' + res.poll.id; this.urlSlugPublic = this.baseHref + '#/vote/poll/slug/' + res.poll.id;
@ -520,6 +520,7 @@ export class ConfigService extends PollConfig {
* UPDATE * UPDATE
* /api/v1/poll/{id}/vote * /api/v1/poll/{id}/vote
* @param voteStack * @param voteStack
* TODO
*/ */
updatePoll(voteStack: any) { updatePoll(voteStack: any) {
this.http.put( this.http.put(
@ -540,11 +541,12 @@ export class ConfigService extends PollConfig {
} }
/** /**
* TODO
* export all the poll data available to the public as a CSV single file * export all the poll data available to the public as a CSV single file
*/ */
exportCSV() { exportCSV() {
// TODO
const rows = [ const rows = [
["name1", "city1", "some other info"], ["name1", "city1", "some other info"],
["name2", "city2", "more info"] ["name2", "city2", "more info"]

View File

@ -6,14 +6,14 @@
(click)=' choice.simpleAnswer = !choice.simpleAnswer' > (click)=' choice.simpleAnswer = !choice.simpleAnswer' >
<i class='fa fa-gears' ></i > <i class='fa fa-gears' ></i >
</button > </button >
<div
class="text title clickable"
(click)="setAnswserTo('yes')" >
{{choice.text}}
</div >
<div class="choicebox__subject" > <div class="choicebox__subject" >
<div
class="text title clickable"
(click)="setAnswserTo('yes')" >
<!-- {{choice.id}} )-->
{{choice.text}}
</div >
<!-- TEXT CASE --><!-- <!-- TEXT CASE --><!--
<p class="choicebox__txt"> <p class="choicebox__txt">
Lorem ipsum dolor sit amet consectetur, adipisicing elit. Nulla nobis nam culpa ! Lorem ipsum dolor sit amet consectetur, adipisicing elit. Nulla nobis nam culpa !
@ -82,13 +82,19 @@
</div > </div >
<div class="choicebox__count" > <div class="choicebox__count" >
<div
class='no-votes'
*ngIf='! poll.choices_count.counts[choice.id] ' >
aucun vote
</div >
<button <button
type="button" type="button"
aria-describedby="choicebox-tooltip" aria-describedby="choicebox-tooltip"
class="choicebox__votes" class="choicebox__votes"
*ngIf="choice.votes" > *ngIf="poll.choices_count && choice && poll.choices_count.counts[choice.id]" >
<div class="choicebox__vote" > <div class="choicebox__vote" >
{{choice.votes.count.yes}} {{poll.choices_count.counts[choice.id].yes.count}}
<img <img
width="20px" width="20px"
height="21px" height="21px"
@ -96,7 +102,7 @@
alt="" > alt="" >
</div > </div >
<div class="choicebox__vote" > <div class="choicebox__vote" >
{{choice.votes.count.maybe}} {{poll.choices_count.counts[choice.id].maybe.count}}
<img <img
width="22px" width="22px"
height="24px" height="24px"
@ -113,33 +119,37 @@
height="21px" height="21px"
src="../../../assets/img/votant-sur.svg" src="../../../assets/img/votant-sur.svg"
alt="" > alt="" >
{{choice.votes.count.yes}} "Oui" {{poll.choices_count.counts[choice.id].yes.count}} "Oui"
</div > </div >
<!-- liste des gens qui ont répondu oui-->
<ul > <ul >
<li >Lorem</li > <li *ngFor='let pseudo of choices_count.counts[choice.id].yes.people ' >{{pseudo}}</li >
<li >Ipsum dolor</li >
<li >Sit amet</li >
<li >Consectetur</li >
</ul > </ul >
</div > </div >
<div class="choicebox__tooltiplist" > <div
class="choicebox__tooltiplist"
*ngIf='!simpleAnswer' >
<div class="choicebox__tooltipttl" > <div class="choicebox__tooltipttl" >
<img <img
width="22px" width="22px"
height="24px" height="24px"
src="../../../assets/img/votant-pas-sur.svg" src="../../../assets/img/votant-pas-sur.svg"
alt="" > alt="" >
{{choice.votes.count.maybe}} "Peut-être" {{poll.choices_count.counts[choice.id].maybe.count}} "Peut-être"
</div > </div >
<ul > <ul >
<li >Lorem</li > <li *ngFor='let pseudo of choices_count.counts[choice.id].maybe.people ' >{{pseudo}}</li >
<li >Ipsum dolor</li > </ul >
<li >Sit amet</li > </div >
<li >Consectetur</li > <div
<li >Lorem</li > class="choicebox__tooltiplist"
<li >Ipsum dolor</li > *ngIf='!simpleAnswer' >
<li >Sit amet</li > <div class="choicebox__tooltipttl" >
<li >Consectetur</li > <i class='fa fa-times' ></i >
{{poll.choices_count.counts[choice.id].no.count}} "Non"
</div >
<ul >
<li *ngFor='let pseudo of choices_count.counts[choice.id].no.people ' >{{pseudo}}</li >
</ul > </ul >
</div > </div >
</div > </div >

View File

@ -44,7 +44,6 @@ $breakpoint-responsive: 640px; // à définir
} }
@media (min-width: $breakpoint-responsive) { @media (min-width: $breakpoint-responsive) {
display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
min-height: auto; min-height: auto;
@ -109,24 +108,20 @@ $breakpoint-responsive: 640px; // à définir
.choicebox__actions { .choicebox__actions {
position: absolute; position: absolute;
z-index: 1; z-index: 1;
display: flex;
max-width: $btn-wrap-size; max-width: $btn-wrap-size;
top: 50%; top: 50%;
right: $box-padding; right: $box-padding;
flex-flow: row-reverse wrap;
transform: translateY(-50%);
@media (min-width: $breakpoint-responsive) { @media (min-width: $breakpoint-responsive) {
position: static; position: static;
max-width: none; max-width: none;
flex-flow: row nowrap;
transform: none; transform: none;
margin: 0 1.5rem; margin: 0 1.5rem;
} }
} }
.choicebox__btn { .choicebox__btn {
display: flex;
width: $btn-size; width: $btn-size;
height: $btn-size; height: $btn-size;
align-items: center; align-items: center;
@ -136,17 +131,6 @@ $breakpoint-responsive: 640px; // à définir
background-color: transparent; background-color: transparent;
border-radius: 50%; border-radius: 50%;
cursor: pointer; cursor: pointer;
//&:focus,
//&:hover,
//&:active {
//
// border-color: #ccc9c9;
// background-color: #f7f7f7;
//
// &--active {
// border-color: #bf83c2 !important;
// }
//}
&--maybe { &--maybe {
position: relative; position: relative;
@ -176,7 +160,6 @@ $breakpoint-responsive: 640px; // à définir
position: relative; position: relative;
padding-right: $btn-wrap-size; padding-right: $btn-wrap-size;
@media (min-width: $breakpoint-responsive) { @media (min-width: $breakpoint-responsive) {
flex-shrink: 0;
text-align: right; text-align: right;
padding-right: 0; padding-right: 0;
} }
@ -189,13 +172,6 @@ $breakpoint-responsive: 640px; // à définir
background-color: transparent; background-color: transparent;
@media (min-width: $breakpoint-responsive) { @media (min-width: $breakpoint-responsive) {
padding: 1.5rem; padding: 1.5rem;
&:focus,
&:hover,
&:active {
& .choicebox__tooltip {
display: flex;
}
}
} }
} }

View File

@ -1,4 +1,5 @@
import {Component, ElementRef, Input} from '@angular/core'; import {Component, ElementRef, Input} from '@angular/core';
import {ConfigService} from "../../services/config.service";
interface VoteChoice { interface VoteChoice {
votes?: { votes?: {
@ -27,11 +28,14 @@ export class VoteChoiceComponent {
public showChangeChoicebutton = false; public showChangeChoicebutton = false;
@Input() public choice: any; @Input() public choice: any;
@Input() public choices_count: any;
@Input() public choice_id: any;
@Input() public poll: any; @Input() public poll: any;
@Input() public simpleAnswer: boolean = true; @Input() public simpleAnswer: boolean = true;
@Input() public pollIsSpecialDate: boolean = false; @Input() public pollIsSpecialDate: boolean = false;
constructor(private el: ElementRef) { constructor(private el: ElementRef,
private config: ConfigService) {
if (this.poll && this.poll.data && this.poll.data.allowedAnswers) { if (this.poll && this.poll.data && this.poll.data.allowedAnswers) {
this.simpleAnswer = this.poll.data.allowedAnswers.length == 1 this.simpleAnswer = this.poll.data.allowedAnswers.length == 1
@ -43,12 +47,22 @@ export class VoteChoiceComponent {
// only toggle yes to no // only toggle yes to no
if (this.choice.answer && this.choice.answer === 'yes') { if (this.choice.answer && this.choice.answer === 'yes') {
this.choice.answer = 'no'; this.choice.answer = 'no';
this.config.myTempVoteStack--;
} else { } else {
this.choice.answer = 'yes'; this.choice.answer = 'yes';
this.config.myTempVoteStack++;
} }
} else { } else {
this.choice.answer = newAnswer; this.choice.answer = newAnswer;
if (this.choice.answer !== newAnswer) {
if (newAnswer == 'maybe' || newAnswer == 'yes') {
this.config.myTempVoteStack++;
}
} else {
console.info('same answer as before')
}
} }
this.el.nativeElement.blur(); this.el.nativeElement.blur();
} }