diff --git a/src/app/vote-choice/vote-choice.component.html b/src/app/vote-choice/vote-choice.component.html index 63f167a4..ef5aae72 100644 --- a/src/app/vote-choice/vote-choice.component.html +++ b/src/app/vote-choice/vote-choice.component.html @@ -1,15 +1,46 @@
-
-

Jeudi 17 aout

-

08:00

-
-
-

14

-

76

-
-
- - - -
-
+
+
+
+ {{choice.date | date:'Y-m-d'}} +
+
+ {{choice.date | date:'H:i:s'}} +
+ +
+ {{choice.text}} +
+

Jeudi 17 aout

+

08:00

+
+
+ +

{{choice.votesCount.yes}}

+
+ +

{{choice.votesCount.maybe}}

+
+ +

{{choice.votesCount.no}}

+
+ +

{{choice.votesCount.notAnswered}}

+
+
+
+ + + + +
+
+ diff --git a/src/app/vote-choice/vote-choice.component.scss b/src/app/vote-choice/vote-choice.component.scss index 5695896c..f33bae66 100644 --- a/src/app/vote-choice/vote-choice.component.scss +++ b/src/app/vote-choice/vote-choice.component.scss @@ -1,26 +1,32 @@ -.choice_container{ - width:320px; - height:172px; - box-shadow: 0 3px 6px 0 rgba(black, 0.2); - overflow: auto; - display:flex; +.choice_container { + width: 320px; + height: 172px; + box-shadow: 0 3px 6px 0 rgba(black, 0.2); + overflow: auto; + display: flex; } -#vote img{ -border: 1px solid #aeafb1; -border-radius: 48px; + +#vote img { + border: 1px solid #aeafb1; + border-radius: 48px; } -h2,h3{ - font-weight: normal; + +h2, h3 { + font-weight: normal; } -span{ - font-weight: bold; - font-size:24px; + +span { + font-weight: bold; + font-size: 24px; } -#nombre_vote{ - vertical-align: middle; - float:left; + +#nombre_vote { + vertical-align: middle; + float: left; } -#nombre_vote p{ - line-height: 20px; + +// TODO intricate selectors +#nombre_vote p { + line-height: 20px; } diff --git a/src/app/vote-choice/vote-choice.component.ts b/src/app/vote-choice/vote-choice.component.ts index 32b684dc..95097f32 100644 --- a/src/app/vote-choice/vote-choice.component.ts +++ b/src/app/vote-choice/vote-choice.component.ts @@ -1,15 +1,55 @@ -import { Component, OnInit } from '@angular/core'; +import {Component, Input} from '@angular/core'; +import {environment} from "../../environments/environment"; +interface VoteChoice { + votesCount: { + yes: number + no: number + maybe: number + notAnswered: number + }; + text: string; + date: Date; + answer: 'yes' | 'no' | 'maybe' | null; + simpleAnswer: boolean; // enable if we display only a togglable "yes" +} + +/** + * each vote choice takes a configuration from the container of all choices. + * this component is used to select a date choice, or a text answer + */ @Component({ - selector: 'framadate-vote-choice', - templateUrl: './vote-choice.component.html', - styleUrls: ['./vote-choice.component.scss'] + selector: 'framadate-vote-choice', + templateUrl: './vote-choice.component.html', + styleUrls: ['./vote-choice.component.scss'] }) -export class VoteChoiceComponent implements OnInit { +export class VoteChoiceComponent { - constructor() { } + @Input() choice: VoteChoice; - ngOnInit() { - } + constructor() { + if (!environment.production) { + // demo content for dev env + this.choice = { + date: new Date(), + text: 'description ', + simpleAnswer: false + } + } + } + + setAnswserTo(newAnswer: 'yes' | 'no' | 'maybe' | null) { + if (this.choice.simpleAnswer) { + // only toggle yes to no + if (this.choice.answer && this.choice.answer === 'yes') { + this.choice.answer = 'no'; + } else { + this.choice.answer = 'yes'; + } + + } else { + this.choice.answer = newAnswer; + } + } }