From 0e8d18cd8000b2b9a9fb3d74277bf24a26c8b380 Mon Sep 17 00:00:00 2001 From: Baptiste Lemoine Date: Thu, 30 Jan 2020 12:55:40 +0100 Subject: [PATCH] :zap: show preferred texts in summary, icons for votes --- src/app/config/mocks/mock-poll3.ts | 1036 +++-------------- .../voting-summary.component.html | 64 +- .../voting-summary.component.ts | 22 +- 3 files changed, 252 insertions(+), 870 deletions(-) diff --git a/src/app/config/mocks/mock-poll3.ts b/src/app/config/mocks/mock-poll3.ts index c18e16ad..80c46059 100644 --- a/src/app/config/mocks/mock-poll3.ts +++ b/src/app/config/mocks/mock-poll3.ts @@ -1,17 +1,17 @@ export const mockPoll3 = { "message": "your poll config", "poll": { - "id": 3, + "id": 4, "title": "dessin animé préféré", "customUrl": null, "description": "choisissez votre animé préféré", "creationDate": { - "date": "2020-01-20 16:45:48.000000", + "date": "2020-01-30 12:25:13.000000", "timezone_type": 3, "timezone": "Europe/Berlin" }, "expiracyDate": { - "date": "2020-01-20 16:45:48.000000", + "date": "2020-01-30 12:25:13.000000", "timezone_type": 3, "timezone": "Europe/Berlin" }, @@ -37,45 +37,45 @@ export const mockPoll3 = { "comments": {}, "defaultExpiracyDaysFromNow": 60 }, - "stacks_count": 16, + "stacks_count": 5, "stacks": [ { "id": 3, "pseudo": "voting_people_TEST", "creation_date": { - "date": "2020-01-20 16:45:48.000000", + "date": "2020-01-30 12:25:13.000000", "timezone_type": 3, "timezone": "Europe/Berlin" }, "votes": { - "5": { - "choice_id": 5 - }, - "6": { - "id": 3, - "vote_id": 5, - "value": "maybe", - "choice_id": 6, - "text": "Boumbo petite automobile" - }, - "7": { - "id": 3, - "vote_id": 4, - "value": "yes", - "choice_id": 7, - "text": "Les mystérieuses cités d'or" - }, "8": { "choice_id": 8 }, "9": { - "choice_id": 9 + "id": 3, + "vote_id": 5, + "value": "maybe", + "choice_id": 9, + "text": "Boumbo petite automobile" }, "10": { - "choice_id": 10 + "id": 3, + "vote_id": 4, + "value": "yes", + "choice_id": 10, + "text": "Les mystérieuses cités d'or" }, "11": { "choice_id": 11 + }, + "12": { + "choice_id": 12 + }, + "13": { + "choice_id": 13 + }, + "14": { + "choice_id": 14 } } }, @@ -83,160 +83,51 @@ export const mockPoll3 = { "id": 4, "pseudo": "voting_people_TEST", "creation_date": { - "date": "2020-01-20 16:45:48.000000", + "date": "2020-01-30 12:25:13.000000", "timezone_type": 3, "timezone": "Europe/Berlin" }, "votes": { - "5": { - "choice_id": 5 + "8": { + "choice_id": 8 }, - "6": { + "9": { "id": 4, "vote_id": 6, "value": "yes", - "choice_id": 6, + "choice_id": 9, "text": "Boumbo petite automobile" }, - "7": { + "10": { "id": 4, "vote_id": 8, "value": "no", - "choice_id": 7, + "choice_id": 10, "text": "Les mystérieuses cités d'or" }, - "8": { - "choice_id": 8 - }, - "9": { - "choice_id": 9 - }, - "10": { - "choice_id": 10 - }, "11": { "choice_id": 11 - } - } - }, - { - "id": 5, - "pseudo": "voting_people_TEST", - "creation_date": { - "date": "2020-01-21 10:33:26.000000", - "timezone_type": 3, - "timezone": "Europe/Berlin" - }, - "votes": { - "5": { - "id": 5, - "vote_id": 9, - "value": "no", - "choice_id": 5, - "text": "Vic le viking" }, - "6": { - "id": 5, - "vote_id": 10, - "value": "maybe", - "choice_id": 6, - "text": "Boumbo petite automobile" + "12": { + "choice_id": 12 }, - "7": { - "id": 5, - "vote_id": 11, - "value": "yes", - "choice_id": 7, - "text": "Les mystérieuses cités d'or" + "13": { + "choice_id": 13 }, - "8": { - "choice_id": 8 - }, - "9": { - "choice_id": 9 - }, - "10": { - "choice_id": 10 - }, - "11": { - "choice_id": 11 - } - } - }, - { - "id": 6, - "pseudo": "voting_people_TEST", - "creation_date": { - "date": "2020-01-21 10:36:58.000000", - "timezone_type": 3, - "timezone": "Europe/Berlin" - }, - "votes": { - "5": { - "id": 6, - "vote_id": 12, - "value": "no", - "choice_id": 5, - "text": "Vic le viking" - }, - "6": { - "id": 6, - "vote_id": 13, - "value": "maybe", - "choice_id": 6, - "text": "Boumbo petite automobile" - }, - "7": { - "id": 6, - "vote_id": 14, - "value": "yes", - "choice_id": 7, - "text": "Les mystérieuses cités d'or" - }, - "8": { - "choice_id": 8 - }, - "9": { - "choice_id": 9 - }, - "10": { - "choice_id": 10 - }, - "11": { - "choice_id": 11 + "14": { + "choice_id": 14 } } }, { "id": 7, - "pseudo": "voting_people_TEST", + "pseudo": "Nikolas Edison", "creation_date": { - "date": "2020-01-21 10:39:12.000000", + "date": "2020-01-30 12:25:13.000000", "timezone_type": 3, "timezone": "Europe/Berlin" }, "votes": { - "5": { - "id": 7, - "vote_id": 15, - "value": "no", - "choice_id": 5, - "text": "Vic le viking" - }, - "6": { - "id": 7, - "vote_id": 16, - "value": "maybe", - "choice_id": 6, - "text": "Boumbo petite automobile" - }, - "7": { - "id": 7, - "vote_id": 17, - "value": "yes", - "choice_id": 7, - "text": "Les mystérieuses cités d'or" - }, "8": { "choice_id": 8 }, @@ -244,43 +135,39 @@ export const mockPoll3 = { "choice_id": 9 }, "10": { - "choice_id": 10 + "id": 7, + "vote_id": 13, + "value": "maybe", + "choice_id": 10, + "text": "Les mystérieuses cités d'or" }, "11": { "choice_id": 11 + }, + "12": { + "id": 7, + "vote_id": 14, + "value": "maybe", + "choice_id": 12, + "text": "Foot 2 rue" + }, + "13": { + "choice_id": 13 + }, + "14": { + "choice_id": 14 } } }, { "id": 8, - "pseudo": "voting_people_TEST", + "pseudo": "Wulfila", "creation_date": { - "date": "2020-01-21 10:39:13.000000", + "date": "2020-01-30 12:25:13.000000", "timezone_type": 3, "timezone": "Europe/Berlin" }, "votes": { - "5": { - "id": 8, - "vote_id": 18, - "value": "no", - "choice_id": 5, - "text": "Vic le viking" - }, - "6": { - "id": 8, - "vote_id": 19, - "value": "maybe", - "choice_id": 6, - "text": "Boumbo petite automobile" - }, - "7": { - "id": 8, - "vote_id": 20, - "value": "yes", - "choice_id": 7, - "text": "Les mystérieuses cités d'or" - }, "8": { "choice_id": 8 }, @@ -291,473 +178,87 @@ export const mockPoll3 = { "choice_id": 10 }, "11": { - "choice_id": 11 + "id": 8, + "vote_id": 15, + "value": "maybe", + "choice_id": 11, + "text": "Les mondes engloutis" + }, + "12": { + "choice_id": 12 + }, + "13": { + "id": 8, + "vote_id": 16, + "value": "yes", + "choice_id": 13, + "text": "Le chat, la vache, et l'océan" + }, + "14": { + "choice_id": 14 } } }, { "id": 9, - "pseudo": "voting_people_TEST", + "pseudo": "Billie Jean", "creation_date": { - "date": "2020-01-21 10:42:19.000000", + "date": "2020-01-30 12:25:13.000000", "timezone_type": 3, "timezone": "Europe/Berlin" }, "votes": { - "5": { + "8": { + "choice_id": 8 + }, + "9": { "id": 9, - "vote_id": 21, - "value": "no", - "choice_id": 5, - "text": "Vic le viking" + "vote_id": 17, + "value": "yes", + "choice_id": 9, + "text": "Boumbo petite automobile" }, - "6": { + "10": { + "choice_id": 10 + }, + "11": { "id": 9, - "vote_id": 22, - "value": "maybe", - "choice_id": 6, - "text": "Boumbo petite automobile" - }, - "7": { - "id": 9, - "vote_id": 23, + "vote_id": 18, "value": "yes", - "choice_id": 7, - "text": "Les mystérieuses cités d'or" - }, - "8": { - "choice_id": 8 - }, - "9": { - "choice_id": 9 - }, - "10": { - "choice_id": 10 - }, - "11": { - "choice_id": 11 - } - } - }, - { - "id": 10, - "pseudo": "voting_people_TEST", - "creation_date": { - "date": "2020-01-21 10:42:32.000000", - "timezone_type": 3, - "timezone": "Europe/Berlin" - }, - "votes": { - "5": { - "id": 10, - "vote_id": 24, - "value": "no", - "choice_id": 5, - "text": "Vic le viking" - }, - "6": { - "id": 10, - "vote_id": 25, - "value": "maybe", - "choice_id": 6, - "text": "Boumbo petite automobile" - }, - "7": { - "id": 10, - "vote_id": 26, - "value": "yes", - "choice_id": 7, - "text": "Les mystérieuses cités d'or" - }, - "8": { - "choice_id": 8 - }, - "9": { - "choice_id": 9 - }, - "10": { - "choice_id": 10 - }, - "11": { - "choice_id": 11 - } - } - }, - { - "id": 11, - "pseudo": "voting_people_TEST", - "creation_date": { - "date": "2020-01-21 10:43:46.000000", - "timezone_type": 3, - "timezone": "Europe/Berlin" - }, - "votes": { - "5": { - "id": 11, - "vote_id": 27, - "value": "no", - "choice_id": 5, - "text": "Vic le viking" - }, - "6": { - "id": 11, - "vote_id": 28, - "value": "maybe", - "choice_id": 6, - "text": "Boumbo petite automobile" - }, - "7": { - "id": 11, - "vote_id": 29, - "value": "yes", - "choice_id": 7, - "text": "Les mystérieuses cités d'or" - }, - "8": { - "choice_id": 8 - }, - "9": { - "choice_id": 9 - }, - "10": { - "choice_id": 10 - }, - "11": { - "choice_id": 11 - } - } - }, - { - "id": 12, - "pseudo": "voting_people_TEST", - "creation_date": { - "date": "2020-01-21 10:44:35.000000", - "timezone_type": 3, - "timezone": "Europe/Berlin" - }, - "votes": { - "5": { - "id": 12, - "vote_id": 30, - "value": "no", - "choice_id": 5, - "text": "Vic le viking" - }, - "6": { - "id": 12, - "vote_id": 31, - "value": "maybe", - "choice_id": 6, - "text": "Boumbo petite automobile" - }, - "7": { - "id": 12, - "vote_id": 32, - "value": "yes", - "choice_id": 7, - "text": "Les mystérieuses cités d'or" - }, - "8": { - "choice_id": 8 - }, - "9": { - "choice_id": 9 - }, - "10": { - "choice_id": 10 - }, - "11": { - "choice_id": 11 - } - } - }, - { - "id": 13, - "pseudo": "tk_TEST", - "creation_date": { - "date": "2020-01-23 14:31:07.000000", - "timezone_type": 3, - "timezone": "Europe/Berlin" - }, - "votes": { - "5": { - "choice_id": 5 - }, - "6": { - "choice_id": 6 - }, - "7": { - "choice_id": 7 - }, - "8": { - "choice_id": 8 - }, - "9": { - "choice_id": 9 - }, - "10": { - "choice_id": 10 - }, - "11": { - "choice_id": 11 - }, - "2": { - "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": { - "5": { - "choice_id": 5 - }, - "6": { - "choice_id": 6 - }, - "7": { - "choice_id": 7 - }, - "8": { - "choice_id": 8 - }, - "9": { - "choice_id": 9 - }, - "10": { - "choice_id": 10 - }, - "11": { - "choice_id": 11 - }, - "2": { - "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": { - "5": { - "choice_id": 5 - }, - "6": { - "choice_id": 6 - }, - "7": { - "choice_id": 7 - }, - "8": { - "choice_id": 8 - }, - "9": { - "choice_id": 9 - }, - "10": { - "choice_id": 10 - }, - "11": { - "choice_id": 11 - }, - "2": { - "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": { - "5": { - "choice_id": 5 - }, - "6": { - "choice_id": 6 - }, - "7": { - "choice_id": 7 - }, - "8": { - "choice_id": 8 - }, - "9": { - "choice_id": 9 - }, - "10": { - "choice_id": 10 - }, - "11": { - "choice_id": 11 - }, - "1": { - "id": 16, - "vote_id": 36, - "value": "no", - "choice_id": 1, - "text": "orange" - }, - "2": { - "id": 16, - "vote_id": 37, - "value": "yes", - "choice_id": 2, - "text": null - } - } - }, - { - "id": 17, - "pseudo": "tk_TEST", - "creation_date": { - "date": "2020-01-30 10:31:38.000000", - "timezone_type": 3, - "timezone": "Europe/Berlin" - }, - "votes": { - "5": { - "id": 17, - "vote_id": 38, - "value": "yes", - "choice_id": 5, - "text": "Vic le viking" - }, - "6": { - "id": 17, - "vote_id": 39, - "value": "yes", - "choice_id": 6, - "text": "Boumbo petite automobile" - }, - "7": { - "id": 17, - "vote_id": 40, - "value": "yes", - "choice_id": 7, - "text": "Les mystérieuses cités d'or" - }, - "8": { - "id": 17, - "vote_id": 41, - "value": "yes", - "choice_id": 8, + "choice_id": 11, "text": "Les mondes engloutis" }, - "9": { - "choice_id": 9 + "12": { + "choice_id": 12 }, - "10": { - "choice_id": 10 + "13": { + "choice_id": 13 }, - "11": { - "choice_id": 11 - } - } - }, - { - "id": 18, - "pseudo": "tk_TEST", - "creation_date": { - "date": "2020-01-30 10:39:30.000000", - "timezone_type": 3, - "timezone": "Europe/Berlin" - }, - "votes": { - "5": { - "id": 18, - "vote_id": 42, - "value": "yes", - "choice_id": 5, - "text": "Vic le viking" - }, - "6": { - "id": 18, - "vote_id": 43, - "value": "yes", - "choice_id": 6, - "text": "Boumbo petite automobile" - }, - "7": { - "id": 18, - "vote_id": 44, - "value": "yes", - "choice_id": 7, - "text": "Les mystérieuses cités d'or" - }, - "8": { - "id": 18, - "vote_id": 45, - "value": "yes", - "choice_id": 8, - "text": "Les mondes engloutis" - }, - "9": { - "choice_id": 9 - }, - "10": { - "choice_id": 10 - }, - "11": { - "choice_id": 11 + "14": { + "choice_id": 14 } } } ], "choices_count": { "counts": { - "7": { - "choice_id": 7, + "10": { + "choice_id": 10, "choice_text": "Les mystérieuses cités d'or", "id": 4, - "score": 12, + "score": 2.5, "yes": { - "count": 12, + "count": 2, "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", - "tk_TEST", - "tk_TEST" + "voting_people_TEST" ] }, "maybe": { - "count": 0, - "people": [] + "count": 1, + "people": [ + "Nikolas Edison" + ] }, "no": { "count": 1, @@ -766,121 +267,80 @@ export const mockPoll3 = { ] } }, - "6": { - "choice_id": 6, + "9": { + "choice_id": 9, "choice_text": "Boumbo petite automobile", "id": 5, - "score": 7.5, - "yes": { - "count": 3, - "people": [ - "voting_people_TEST", - "tk_TEST", - "tk_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": { - "choice_id": 5, - "choice_text": "Vic le viking", - "id": 9, - "score": 2, + "score": 2.5, "yes": { "count": 2, "people": [ - "tk_TEST", - "tk_TEST" + "voting_people_TEST", + "Billie Jean" ] }, "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": { - "choice_id": 2, - "choice_text": null, - "id": 33, - "score": 4, - "yes": { - "count": 4, - "people": [ - "tk_TEST", - "tk_TEST", - "tk_TEST", - "tk_TEST" - ] - }, - "maybe": { - "count": 0, - "people": [] - }, - "no": { - "count": 0, - "people": [] - } - }, - "1": { - "choice_id": 1, - "choice_text": "orange", - "id": 36, - "score": 0, - "yes": { - "count": 0, - "people": [] - }, - "maybe": { - "count": 0, - "people": [] - }, - "no": { "count": 1, "people": [ - "tk_TEST" + "voting_people_TEST" ] + }, + "no": { + "count": 0, + "people": [] } }, - "8": { - "choice_id": 8, - "choice_text": "Les mondes engloutis", - "id": 41, - "score": 2, + "12": { + "choice_id": 12, + "choice_text": "Foot 2 rue", + "id": 14, + "score": 0.5, "yes": { - "count": 2, + "count": 0, + "people": [] + }, + "maybe": { + "count": 1, "people": [ - "tk_TEST", - "tk_TEST" + "Nikolas Edison" + ] + }, + "no": { + "count": 0, + "people": [] + } + }, + "11": { + "choice_id": 11, + "choice_text": "Les mondes engloutis", + "id": 15, + "score": 1.5, + "yes": { + "count": 1, + "people": [ + "Billie Jean" + ] + }, + "maybe": { + "count": 1, + "people": [ + "Wulfila" + ] + }, + "no": { + "count": 0, + "people": [] + } + }, + "13": { + "choice_id": 13, + "choice_text": "Le chat, la vache, et l'océan", + "id": 16, + "score": 1, + "yes": { + "count": 1, + "people": [ + "Wulfila" ] }, "maybe": { @@ -893,13 +353,13 @@ export const mockPoll3 = { } } }, - "maxScore": 12 + "maxScore": 2.5 }, "choices": [ { - "id": 5, + "id": 8, "date": { - "date": "2020-01-20 16:45:48.000000", + "date": "2020-01-30 12:25:13.000000", "timezone_type": 3, "timezone": "Europe/Berlin" }, @@ -907,9 +367,9 @@ export const mockPoll3 = { "url": null }, { - "id": 6, + "id": 9, "date": { - "date": "2020-01-20 16:45:48.000000", + "date": "2020-01-30 12:25:13.000000", "timezone_type": 3, "timezone": "Europe/Berlin" }, @@ -917,9 +377,9 @@ export const mockPoll3 = { "url": null }, { - "id": 7, + "id": 10, "date": { - "date": "2020-01-20 16:45:48.000000", + "date": "2020-01-30 12:25:13.000000", "timezone_type": 3, "timezone": "Europe/Berlin" }, @@ -927,9 +387,9 @@ export const mockPoll3 = { "url": null }, { - "id": 8, + "id": 11, "date": { - "date": "2020-01-20 16:45:48.000000", + "date": "2020-01-30 12:25:13.000000", "timezone_type": 3, "timezone": "Europe/Berlin" }, @@ -937,9 +397,9 @@ export const mockPoll3 = { "url": null }, { - "id": 9, + "id": 12, "date": { - "date": "2020-01-20 16:45:48.000000", + "date": "2020-01-30 12:25:13.000000", "timezone_type": 3, "timezone": "Europe/Berlin" }, @@ -947,9 +407,9 @@ export const mockPoll3 = { "url": null }, { - "id": 10, + "id": 13, "date": { - "date": "2020-01-20 16:45:48.000000", + "date": "2020-01-30 12:25:13.000000", "timezone_type": 3, "timezone": "Europe/Berlin" }, @@ -957,9 +417,9 @@ export const mockPoll3 = { "url": null }, { - "id": 11, + "id": 14, "date": { - "date": "2020-01-20 16:45:48.000000", + "date": "2020-01-30 12:25:13.000000", "timezone_type": 3, "timezone": "Europe/Berlin" }, @@ -970,144 +430,24 @@ export const mockPoll3 = { "comments": [ { "id": 3, - "text": "wouah trop bien framadate!", - "pseudo": "tk_TEST", + "text": "allez boumbo!", + "pseudo": "tk_TEST_commentateur", "date": { - "date": "2020-01-20 16:58:56.000000", + "date": "2020-01-30 12:25:13.000000", "timezone_type": 3, "timezone": "Europe/Berlin" } }, { "id": 4, - "text": "wouah trop bien framadate!", + "text": "je suis pour la team rocket de digimon", "pseudo": "tk_TEST", "date": { - "date": "2020-01-20 16:59:48.000000", - "timezone_type": 3, - "timezone": "Europe/Berlin" - } - }, - { - "id": 5, - "text": "wouah trop bien framadate!", - "pseudo": "tk_TEST", - "date": { - "date": "2020-01-21 10:12:02.000000", - "timezone_type": 3, - "timezone": "Europe/Berlin" - } - }, - { - "id": 6, - "text": "wouah trop bien framadate!", - "pseudo": "tk_TEST", - "date": { - "date": "2020-01-21 10:12:34.000000", - "timezone_type": 3, - "timezone": "Europe/Berlin" - } - }, - { - "id": 7, - "text": "wouah trop bien framadate!", - "pseudo": "tk_TEST", - "date": { - "date": "2020-01-21 10:14:20.000000", - "timezone_type": 3, - "timezone": "Europe/Berlin" - } - }, - { - "id": 8, - "text": "wouah trop bien framadate!", - "pseudo": "tk_TEST", - "date": { - "date": "2020-01-21 10:15:09.000000", - "timezone_type": 3, - "timezone": "Europe/Berlin" - } - }, - { - "id": 9, - "text": "wouah trop bien framadate!", - "pseudo": "tk_TEST", - "date": { - "date": "2020-01-21 10:15:10.000000", - "timezone_type": 3, - "timezone": "Europe/Berlin" - } - }, - { - "id": 10, - "text": "wouah trop bien framadate!", - "pseudo": "tk_TEST", - "date": { - "date": "2020-01-21 10:15:35.000000", - "timezone_type": 3, - "timezone": "Europe/Berlin" - } - }, - { - "id": 11, - "text": "wouah trop bien framadate!", - "pseudo": "tk_TEST", - "date": { - "date": "2020-01-21 10:26:58.000000", - "timezone_type": 3, - "timezone": "Europe/Berlin" - } - }, - { - "id": 12, - "text": "wouah trop bien framadate!", - "pseudo": "tk_TEST", - "date": { - "date": "2020-01-21 10:27:03.000000", - "timezone_type": 3, - "timezone": "Europe/Berlin" - } - }, - { - "id": 13, - "text": "wouah trop bien framadate!", - "pseudo": "tk_TEST", - "date": { - "date": "2020-01-21 10:27:10.000000", - "timezone_type": 3, - "timezone": "Europe/Berlin" - } - }, - { - "id": 14, - "text": "wouah trop bien framadate wouhouuu!", - "pseudo": "tk_TEST", - "date": { - "date": "2020-01-21 10:34:04.000000", - "timezone_type": 3, - "timezone": "Europe/Berlin" - } - }, - { - "id": 15, - "text": "wouah trop bien framadate wouhouucghfdghu!", - "pseudo": "tk_TEST", - "date": { - "date": "2020-01-21 10:36:33.000000", - "timezone_type": 3, - "timezone": "Europe/Berlin" - } - }, - { - "id": 16, - "text": "wouah trop bien framadate woudghdghhouucghfdghu!", - "pseudo": "tk_TEST", - "date": { - "date": "2020-01-21 10:50:43.000000", + "date": "2020-01-30 12:25:13.000000", "timezone_type": 3, "timezone": "Europe/Berlin" } } ], - "comments_count": 14 + "comments_count": 2 }; diff --git a/src/app/pages/voting/voting-summary/voting-summary.component.html b/src/app/pages/voting/voting-summary/voting-summary.component.html index 0888f9b2..ce4d7e3a 100644 --- a/src/app/pages/voting/voting-summary/voting-summary.component.html +++ b/src/app/pages/voting/voting-summary/voting-summary.component.html @@ -1,8 +1,19 @@

Résumé

- Pour l'instant, le choix ayant reçu le plus grand nombre de votes ( {{config.currentPoll.choices_count.maxScore}} ) - est : + Pour l'instant, + + les + + le + + choix ayant reçu le plus grand nombre de votes ( {{config.currentPoll.choices_count.maxScore}} points ) + + sont à égalité + + est + + : {{preferred}} @@ -14,11 +25,11 @@ Pseudo - {{k}} ) - {{config.currentPoll.choices_count.counts[k].choice_text}} + + {{choice.text}} @@ -31,29 +42,35 @@ points + + + + + - {{config.currentPoll.choices_count.counts[k].score}} + *ngFor='let choice of config.currentPoll.choices' + > + id: {{choice.id}} + - - id: {{k}} + + id: {{choice.id}}
- yes {{config.currentPoll.choices_count.counts[k].yes.count}} -
- maybe - {{(config.currentPoll.choices_count.counts[k].yes.maybe ? config.currentPoll.choices_count.counts[k].yes.count * 0.5 : 0)}} + + + + + +
- no {{(config.currentPoll.choices_count.counts[k].yes.maybe ? config.currentPoll.choices_count.counts[k].maybe.count * 0.5 : 0)}} -
- score : - {{(config.currentPoll.choices_count.counts[k].score)}} + + @@ -74,8 +91,15 @@ -id {{v}} ) - {{voteStack.votes[v].value}} + + yes + yes diff --git a/src/app/pages/voting/voting-summary/voting-summary.component.ts b/src/app/pages/voting/voting-summary/voting-summary.component.ts index 0f9b9778..73bb56aa 100644 --- a/src/app/pages/voting/voting-summary/voting-summary.component.ts +++ b/src/app/pages/voting/voting-summary/voting-summary.component.ts @@ -10,6 +10,7 @@ import {mockPoll3} from "../../../config/mocks/mock-poll3"; export class VotingSummaryComponent implements OnInit { preferred: string = 'rien'; + severalPreferred: boolean = false; @Input() pollconfig = mockPoll3; @@ -19,6 +20,11 @@ export class VotingSummaryComponent implements OnInit { ngOnInit() { this.computePreferred(); + console.log(' this.pollconfig.choices', this.pollconfig.choices) + console.log(' this.pollconfig.choices_count', this.pollconfig.choices_count.counts) + console.log('this.pollconfig.choices_count.counts[10]', this.pollconfig.choices_count.counts[10]) + console.log('this.pollconfig.choices[2].id', this.pollconfig.choices[2].id) + console.log('this.pollconfig.choices_count.counts[]', this.pollconfig.choices_count.counts[this.pollconfig.choices[2].id].score) } getKeys(obj) { @@ -29,9 +35,21 @@ export class VotingSummaryComponent implements OnInit { * find the most "yes" */ computePreferred() { + let keys = Object.keys(this.pollconfig.choices_count.counts); + this.preferred = ''; + this.severalPreferred = false; + let maxScore = this.pollconfig.choices_count.maxScore; + + keys.forEach(item => { + if (maxScore === this.pollconfig.choices_count.counts[item].score) { + if (this.preferred.length) { + this.preferred += ', ' + this.severalPreferred = true; + } + // find the favourite + this.preferred += this.pollconfig.choices_count.counts[item].choice_text; + } - this.pollconfig.stacks.forEach(stack => { - // find the favourite }); }