From c3bdc1a0152eebdd0d139e01cacfc31670756380 Mon Sep 17 00:00:00 2001 From: Tykayn Date: Mon, 7 Feb 2022 15:33:39 +0100 Subject: [PATCH] display list of date choices in participation --- src/app/core/models/choice.model.ts | 10 ++- .../consultation/consultation.component.html | 33 +++++-- .../consultation/consultation.component.ts | 37 ++++++++ .../poll-results-dinum.component.html | 88 +++++++++++++++---- .../poll-results-dinum.component.scss | 33 ++++++- .../poll-results-dinum.component.ts | 1 + .../comments/comments.component.html | 2 +- 7 files changed, 178 insertions(+), 26 deletions(-) diff --git a/src/app/core/models/choice.model.ts b/src/app/core/models/choice.model.ts index d0edc9c7..1ed62ecc 100644 --- a/src/app/core/models/choice.model.ts +++ b/src/app/core/models/choice.model.ts @@ -6,6 +6,10 @@ export class ChoiceGroup { subSetToYes = false; // to know if all the choices are set to YES, to toggle them all at once without checking them individually choices: Choice[]; } +export class AnswerStats { + count: number; + people: Array; +} export class Choice { public id: number; @@ -14,9 +18,9 @@ export class Choice { public score: number; public enabled: boolean; public url?: string; - public yes?: any; - public no?: any; - public maybe?: any; + public yes?: AnswerStats; + public no?: AnswerStats; + public maybe?: AnswerStats; constructor( public participants: Map> = new Map>([ diff --git a/src/app/features/consultation/consultation.component.html b/src/app/features/consultation/consultation.component.html index a4e69fb1..70ddafed 100644 --- a/src/app/features/consultation/consultation.component.html +++ b/src/app/features/consultation/consultation.component.html @@ -90,12 +90,35 @@
-

- {{ 'participation.poll' | translate }} -

-
- +
+
+

+ {{ 'participation.poll' | translate }} +

+
+
+ +
+ + + + + + + + + +

diff --git a/src/app/features/consultation/consultation.component.ts b/src/app/features/consultation/consultation.component.ts index 0d4b2ece..cc133e24 100644 --- a/src/app/features/consultation/consultation.component.ts +++ b/src/app/features/consultation/consultation.component.ts @@ -26,6 +26,7 @@ export class ConsultationComponent implements OnInit, OnDestroy { private pollSlug: string; private pass_hash: string; maxYesCount: any = 1; + detailledDisplay: boolean = false; constructor( private router: Router, @@ -84,4 +85,40 @@ export class ConsultationComponent implements OnInit, OnDestroy { displayOptions() { alert('TODO'); } + + /** + * create a new vote stack + */ + addVoteStack(): void { + this.storageService.vote_stack.poll_custom_url = this.poll.custom_url; + this.pollService.pass_hash = this.pass_hash; + + this.toastService.display('envoi du vote ....'); + this.api + .sendNewVoteStackOfPoll(this.storageService.vote_stack) + .then((resp: any) => { + console.log('sendNewVoteStackOfPoll resp', resp); + this.storeVoteStackAndReloadPoll(resp); + }) + // eslint-disable-next-line @typescript-eslint/unbound-method + .catch(this.api.ousideHandleError); + } + + /** + * store the updated vote stack + * @param voteStack + */ + storeVoteStackAndReloadPoll(voteStack: any) { + if (voteStack.status == 200) { + this.storageService.mapVotes(voteStack.data); + this.pollService.enrichVoteStackWithCurrentPollChoicesDefaultVotes(this.storageService.vote_stack); + if (this.pass_hash) { + this.pollService.loadPollByCustomUrlWithPasswordHash(this.poll.custom_url, this.pass_hash); + } else { + this.pollService.loadPollByCustomUrl(this.poll.custom_url); + } + } else { + this.toastService.display('erreur à l enregistrement'); + } + } } diff --git a/src/app/features/consultation/poll-results-dinum/poll-results-dinum.component.html b/src/app/features/consultation/poll-results-dinum/poll-results-dinum.component.html index b62abde7..79c59f7f 100644 --- a/src/app/features/consultation/poll-results-dinum/poll-results-dinum.component.html +++ b/src/app/features/consultation/poll-results-dinum/poll-results-dinum.component.html @@ -1,21 +1,79 @@
-
-

+
+
{{ showAsDate(group.date_string) | date: 'fullDate':'Europe/Paris' }} -

-
-

- {{ choice.name }} -

-
-
-
- - - +
+
+
+
+
+
+ {{ choice.name }} +
+
+
+ + + +
+
+
+
-
-
+
+ +
+
+
+ {{ 'participation.yes' | translate }} +
+
+
+ {{ choice.yes.count }} +
+
+
+
+
+ {{ 'participation.maybe' | translate }} +
+
+
+ {{ choice.maybe.count }} +
+
+
+
+
+ {{ 'participation.no' | translate }} +
+
+
+ {{ choice.no.count }} +
+
+
+
+
+

+ {{ 'participation.details' | translate }} + +

+
+
+ icone ok {{ peopleName }} +
+
+
+
+ icone ok {{ peopleName }} +
+
+
+
+ icone ok {{ peopleName }} +
+
diff --git a/src/app/features/consultation/poll-results-dinum/poll-results-dinum.component.scss b/src/app/features/consultation/poll-results-dinum/poll-results-dinum.component.scss index b4d3785d..9aa98043 100644 --- a/src/app/features/consultation/poll-results-dinum/poll-results-dinum.component.scss +++ b/src/app/features/consultation/poll-results-dinum/poll-results-dinum.component.scss @@ -1,3 +1,32 @@ -.max_score { - color: green; +.white-block { + background: white; + margin-bottom: 1rem; + padding: 0.75rem; + border-radius: 0.5rem; +} +.list-of-choices { + .button { + .icon { + margin-right: 1ch !important; + display: inline-block; + } + } + .choice-label { + font-size: 1rem; + color: #383838; + } + .choice-header { + margin-left: -0.75rem; + margin-right: -0.75rem; + border-bottom: 1px solid #e2e0fa; + } + .max_score { + color: green; + } +} +.date-label { + font-size: 1rem; + color: #383838; + font-weight: bold; + margin-bottom: 1.25rem; } diff --git a/src/app/features/consultation/poll-results-dinum/poll-results-dinum.component.ts b/src/app/features/consultation/poll-results-dinum/poll-results-dinum.component.ts index 5185fac0..d22f0ddc 100644 --- a/src/app/features/consultation/poll-results-dinum/poll-results-dinum.component.ts +++ b/src/app/features/consultation/poll-results-dinum/poll-results-dinum.component.ts @@ -11,6 +11,7 @@ import { StorageService } from '../../../core/services/storage.service'; }) export class PollResultsDinumComponent implements OnInit { @Input() public poll: Poll; + @Input() public detailledDisplay: boolean = false; public answerEnum = Answer; constructor(private modalService: ModalService, private storageService: StorageService) {} diff --git a/src/app/shared/components/comments/comments.component.html b/src/app/shared/components/comments/comments.component.html index 6ba589c8..6db50d67 100644 --- a/src/app/shared/components/comments/comments.component.html +++ b/src/app/shared/components/comments/comments.component.html @@ -86,7 +86,7 @@ type="submit" name="add-comment" class="button is-primary is-fullwidth" - value="Ajouter mon commentaire ✉️" + value="{{ 'participation.send_button' | translate }}" (click)="addComment()" />