From ca69160ea979c2995a2e5cdc2b825bb05e293fa2 Mon Sep 17 00:00:00 2001 From: Baptiste Lemoine Date: Thu, 30 Jan 2020 11:19:17 +0100 Subject: [PATCH] sort table of answers --- src/app/config/mocks/mock-poll3.ts | 163 ++- src/app/config/mocks/mock-success-vote.ts | 1107 +++++++++++++++++ src/app/config/mocks/mock1.ts | 125 -- .../voting-summary.component.html | 57 +- .../voting-summary.component.scss | 9 + .../poll-graphic/poll-graphic.component.ts | 4 +- src/app/services/config.service.ts | 39 +- 7 files changed, 1332 insertions(+), 172 deletions(-) create mode 100644 src/app/config/mocks/mock-success-vote.ts delete mode 100644 src/app/config/mocks/mock1.ts diff --git a/src/app/config/mocks/mock-poll3.ts b/src/app/config/mocks/mock-poll3.ts index eecaa053..c18e16ad 100644 --- a/src/app/config/mocks/mock-poll3.ts +++ b/src/app/config/mocks/mock-poll3.ts @@ -26,7 +26,7 @@ export const mockPoll3 = { "allowedAnswers": [ "yes" ], - "modificationPolicy": "everybody", + "modificationPolicy": "self", "mailOnComment": null, "mailOnVote": null, "hideResults": null, @@ -37,7 +37,7 @@ export const mockPoll3 = { "comments": {}, "defaultExpiracyDaysFromNow": 60 }, - "stacks_count": 14, + "stacks_count": 16, "stacks": [ { "id": 3, @@ -633,13 +633,113 @@ export const mockPoll3 = { "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, + "text": "Les mondes engloutis" + }, + "9": { + "choice_id": 9 + }, + "10": { + "choice_id": 10 + }, + "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 + } + } } ], "choices_count": { "counts": { "7": { + "choice_id": 7, + "choice_text": "Les mystérieuses cités d'or", + "id": 4, + "score": 12, "yes": { - "count": 10, + "count": 12, "people": [ "voting_people_TEST", "voting_people_TEST", @@ -650,7 +750,9 @@ export const mockPoll3 = { "voting_people_TEST", "voting_people_TEST", "voting_people_TEST", - "voting_people_TEST" + "voting_people_TEST", + "tk_TEST", + "tk_TEST" ] }, "maybe": { @@ -665,10 +767,16 @@ export const mockPoll3 = { } }, "6": { + "choice_id": 6, + "choice_text": "Boumbo petite automobile", + "id": 5, + "score": 7.5, "yes": { - "count": 1, + "count": 3, "people": [ - "voting_people_TEST" + "voting_people_TEST", + "tk_TEST", + "tk_TEST" ] }, "maybe": { @@ -691,9 +799,16 @@ export const mockPoll3 = { } }, "5": { + "choice_id": 5, + "choice_text": "Vic le viking", + "id": 9, + "score": 2, "yes": { - "count": 0, - "people": [] + "count": 2, + "people": [ + "tk_TEST", + "tk_TEST" + ] }, "maybe": { "count": 0, @@ -714,6 +829,10 @@ export const mockPoll3 = { } }, "2": { + "choice_id": 2, + "choice_text": null, + "id": 33, + "score": 4, "yes": { "count": 4, "people": [ @@ -733,6 +852,10 @@ export const mockPoll3 = { } }, "1": { + "choice_id": 1, + "choice_text": "orange", + "id": 36, + "score": 0, "yes": { "count": 0, "people": [] @@ -747,8 +870,30 @@ export const mockPoll3 = { "tk_TEST" ] } + }, + "8": { + "choice_id": 8, + "choice_text": "Les mondes engloutis", + "id": 41, + "score": 2, + "yes": { + "count": 2, + "people": [ + "tk_TEST", + "tk_TEST" + ] + }, + "maybe": { + "count": 0, + "people": [] + }, + "no": { + "count": 0, + "people": [] + } } - } + }, + "maxScore": 12 }, "choices": [ { diff --git a/src/app/config/mocks/mock-success-vote.ts b/src/app/config/mocks/mock-success-vote.ts new file mode 100644 index 00000000..bf9f847b --- /dev/null +++ b/src/app/config/mocks/mock-success-vote.ts @@ -0,0 +1,1107 @@ +export const mockSuccessVote = { + "message": "you created a vote stack from an existing owner : tktest@tktest.com", + "poll": { + "id": 3, + "title": "dessin animé préféré", + "customUrl": null, + "description": "choisissez votre animé préféré", + "creationDate": { + "date": "2020-01-20 16:45:48.000000", + "timezone_type": 3, + "timezone": "Europe/Berlin" + }, + "expiracyDate": { + "date": "2020-01-20 16:45:48.000000", + "timezone_type": 3, + "timezone": "Europe/Berlin" + }, + "owner": { + "__initializer__": null, + "__cloner__": null, + "__isInitialized__": true, + "pseudo": "tk_TEST", + "email": "tktest@tktest.com" + }, + "kind": "text", + "allowedAnswers": [ + "yes" + ], + "modificationPolicy": "self", + "mailOnComment": null, + "mailOnVote": null, + "hideResults": null, + "showResultEvenIfPasswords": null, + "votes": {}, + "stacksOfVotes": {}, + "choices": {}, + "comments": {}, + "defaultExpiracyDaysFromNow": 60 + }, + "vote_stack": { + "id": 17, + "pseudo": "tk_TEST", + "creation_date": { + "date": "2020-01-30 10:31:38.360905", + "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, + "text": "Les mondes engloutis" + }, + "9": { + "choice_id": 9 + }, + "10": { + "choice_id": 10 + }, + "11": { + "choice_id": 11 + } + } + }, + "stacks": [ + { + "id": 3, + "pseudo": "voting_people_TEST", + "creation_date": { + "date": "2020-01-20 16:45:48.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 + }, + "10": { + "choice_id": 10 + }, + "11": { + "choice_id": 11 + } + } + }, + { + "id": 4, + "pseudo": "voting_people_TEST", + "creation_date": { + "date": "2020-01-20 16:45:48.000000", + "timezone_type": 3, + "timezone": "Europe/Berlin" + }, + "votes": { + "5": { + "choice_id": 5 + }, + "6": { + "id": 4, + "vote_id": 6, + "value": "yes", + "choice_id": 6, + "text": "Boumbo petite automobile" + }, + "7": { + "id": 4, + "vote_id": 8, + "value": "no", + "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": 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" + }, + "7": { + "id": 5, + "vote_id": 11, + "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": 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 + } + } + }, + { + "id": 7, + "pseudo": "voting_people_TEST", + "creation_date": { + "date": "2020-01-21 10:39:12.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 + }, + "9": { + "choice_id": 9 + }, + "10": { + "choice_id": 10 + }, + "11": { + "choice_id": 11 + } + } + }, + { + "id": 8, + "pseudo": "voting_people_TEST", + "creation_date": { + "date": "2020-01-21 10:39: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 + }, + "9": { + "choice_id": 9 + }, + "10": { + "choice_id": 10 + }, + "11": { + "choice_id": 11 + } + } + }, + { + "id": 9, + "pseudo": "voting_people_TEST", + "creation_date": { + "date": "2020-01-21 10:42:19.000000", + "timezone_type": 3, + "timezone": "Europe/Berlin" + }, + "votes": { + "5": { + "id": 9, + "vote_id": 21, + "value": "no", + "choice_id": 5, + "text": "Vic le viking" + }, + "6": { + "id": 9, + "vote_id": 22, + "value": "maybe", + "choice_id": 6, + "text": "Boumbo petite automobile" + }, + "7": { + "id": 9, + "vote_id": 23, + "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.360905", + "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, + "text": "Les mondes engloutis" + }, + "9": { + "choice_id": 9 + }, + "10": { + "choice_id": 10 + }, + "11": { + "choice_id": 11 + } + } + } + ], + "comments": [ + { + "id": 3, + "text": "wouah trop bien framadate!", + "pseudo": "tk_TEST", + "date": { + "date": "2020-01-20 16:58:56.000000", + "timezone_type": 3, + "timezone": "Europe/Berlin" + } + }, + { + "id": 4, + "text": "wouah trop bien framadate!", + "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", + "timezone_type": 3, + "timezone": "Europe/Berlin" + } + } + ], + "choices": [ + { + "id": 5, + "date": { + "date": "2020-01-20 16:45:48.000000", + "timezone_type": 3, + "timezone": "Europe/Berlin" + }, + "text": "Vic le viking", + "url": null + }, + { + "id": 6, + "date": { + "date": "2020-01-20 16:45:48.000000", + "timezone_type": 3, + "timezone": "Europe/Berlin" + }, + "text": "Boumbo petite automobile", + "url": null + }, + { + "id": 7, + "date": { + "date": "2020-01-20 16:45:48.000000", + "timezone_type": 3, + "timezone": "Europe/Berlin" + }, + "text": "Les mystérieuses cités d'or", + "url": null + }, + { + "id": 8, + "date": { + "date": "2020-01-20 16:45:48.000000", + "timezone_type": 3, + "timezone": "Europe/Berlin" + }, + "text": "Les mondes engloutis", + "url": null + }, + { + "id": 9, + "date": { + "date": "2020-01-20 16:45:48.000000", + "timezone_type": 3, + "timezone": "Europe/Berlin" + }, + "text": "Foot 2 rue", + "url": null + }, + { + "id": 10, + "date": { + "date": "2020-01-20 16:45:48.000000", + "timezone_type": 3, + "timezone": "Europe/Berlin" + }, + "text": "Le chat, la vache, et l'océan", + "url": null + }, + { + "id": 11, + "date": { + "date": "2020-01-20 16:45:48.000000", + "timezone_type": 3, + "timezone": "Europe/Berlin" + }, + "text": "Digimon", + "url": null + } + ], + "choices_count": { + "counts": { + "7": { + "yes": { + "count": 11, + "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" + ] + }, + "maybe": { + "count": 0, + "people": [] + }, + "no": { + "count": 1, + "people": [ + "voting_people_TEST" + ] + } + }, + "6": { + "yes": { + "count": 2, + "people": [ + "voting_people_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": { + "yes": { + "count": 1, + "people": [ + "tk_TEST" + ] + }, + "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" + ] + } + }, + "8": { + "yes": { + "count": 1, + "people": [ + "tk_TEST" + ] + }, + "maybe": { + "count": 0, + "people": [] + }, + "no": { + "count": 0, + "people": [] + } + } + } + }, + "vote_count": 15, + "owner_modifier_token": "067E22x30y7Vc5FUK9Tld75N4fFRkZwKvT039Te-6N8wOe2925udqBsdQf5iS10kG6Cg6Kr86E972bWSp2chP545b01k84Tc29rntQUy922KcKe0Qbmd", + "admin_key": "1b54w8084llbdmM88c489p12Orf078L9W5lc4vyf6D3fbHaK20flTVqnT5UGc3T308te6V054ru99w538wWN3IG7CvC2O883nv1386O6E9zb56a50b", + "json_you_sent": { + "pseudo": "mon pseudo", + "email": "tktest@tktest.com", + "votes": [ + { + "choice_id": 5, + "value": "yes" + }, + { + "choice_id": 6, + "value": "yes" + }, + { + "choice_id": 7, + "value": "yes" + }, + { + "choice_id": 8, + "value": "yes" + } + ] + } +}; diff --git a/src/app/config/mocks/mock1.ts b/src/app/config/mocks/mock1.ts deleted file mode 100644 index 93cc4a2d..00000000 --- a/src/app/config/mocks/mock1.ts +++ /dev/null @@ -1,125 +0,0 @@ -export const mockPoll1 = { - "message": "your poll config", - "poll": { - "id": 1, - "title": "citron ou orange", - "customUrl": null, - "description": "votre sorbert préféré", - "creationDate": { - "date": "2020-01-20 16:45:48.000000", - "timezone_type": 3, - "timezone": "Europe/Berlin" - }, - "expiracyDate": { - "date": "2020-01-20 16:45:48.000000", - "timezone_type": 3, - "timezone": "Europe/Berlin" - }, - "owner": { - "__initializer__": {}, - "__cloner__": {}, - "__isInitialized__": false - }, - "kind": "text", - "allowedAnswers": [ - "yes" - ], - "modificationPolicy": "nobody", - "mailOnComment": null, - "mailOnVote": true, - "hideResults": null, - "showResultEvenIfPasswords": null, - "votes": {}, - "stacksOfVotes": {}, - "choices": {}, - "comments": {}, - "defaultExpiracyDaysFromNow": 60 - }, - "stacks_count": 2, - "stacks": [ - { - "id": 1, - "pseudo": "voting_people_TEST", - "creation_date": { - "date": "2020-01-20 16:45:48.000000", - "timezone_type": 3, - "timezone": "Europe/Berlin" - }, - "votes": [ - { - "id": 1, - "vote_id": 1, - "value": "yes", - "choice_id": 1, - "text": "orange" - }, - { - "id": 1, - "vote_id": 2, - "value": "yes", - "choice_id": 2, - "text": null - } - ] - }, - { - "id": 2, - "pseudo": "voting_people_TEST", - "creation_date": { - "date": "2020-01-20 16:45:48.000000", - "timezone_type": 3, - "timezone": "Europe/Berlin" - }, - "votes": [ - { - "id": 2, - "vote_id": 3, - "value": "maybe", - "choice_id": 1, - "text": "orange" - } - ] - } - ], - "choices_count": { - "counts": { - "1": { - "yes": 1, - "maybe": 1, - "no": 0 - }, - "2": { - "yes": 1, - "maybe": 0, - "no": 0 - } - }, - "people": { - "voting_people_TEST": "maybe" - } - }, - "choices": [ - { - "id": 1, - "date": { - "date": "2020-01-20 16:45:48.000000", - "timezone_type": 3, - "timezone": "Europe/Berlin" - }, - "text": "orange", - "url": null - }, - { - "id": 2, - "date": { - "date": "2020-01-20 16:45:48.000000", - "timezone_type": 3, - "timezone": "Europe/Berlin" - }, - "text": "citron", - "url": null - } - ], - "comments": [], - "comments_count": 0 -}; 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 60302511..0888f9b2 100644 --- a/src/app/pages/voting/voting-summary/voting-summary.component.html +++ b/src/app/pages/voting/voting-summary/voting-summary.component.html @@ -1,19 +1,24 @@

Résumé

- Pour l'instant, le choix ayant reçu le plus grand nombre de votes est : + Pour l'instant, le choix ayant reçu le plus grand nombre de votes ( {{config.currentPoll.choices_count.maxScore}} ) + est : {{preferred}}
- + - @@ -26,13 +31,35 @@ + + + + - - - -
Pseudo - {{choice.text}} + + {{k}} ) + {{config.currentPoll.choices_count.counts[k].choice_text}}
points + {{config.currentPoll.choices_count.counts[k].score}} +
+ + - {{ 1 * (config.currentPoll.choices_count.counts[k].yes.count) + (config.currentPoll.choices_count.counts[k].yes.count ? config.currentPoll.choices_count.counts[k].maybe.count * 0.5 : 0)}} + id: {{k}} +
+ 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)}} +
@@ -47,26 +74,12 @@ - - {{voteStack.votes[v].value}} +id {{v}} ) + {{voteStack.votes[v].value}}
- - - 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)}} - -
diff --git a/src/app/pages/voting/voting-summary/voting-summary.component.scss b/src/app/pages/voting/voting-summary/voting-summary.component.scss index f549a110..5b75f96c 100644 --- a/src/app/pages/voting/voting-summary/voting-summary.component.scss +++ b/src/app/pages/voting/voting-summary/voting-summary.component.scss @@ -1,3 +1,5 @@ +@import "../../../../assets/scss/variables"; + .person { font-weight: 700; } @@ -15,3 +17,10 @@ thead { tbody { text-align: right; } + +td { + &.has-max-score { + background: $primary_color; + font-weight: 800; + } +} diff --git a/src/app/poll-graphic/poll-graphic.component.ts b/src/app/poll-graphic/poll-graphic.component.ts index 437755f2..9568935b 100644 --- a/src/app/poll-graphic/poll-graphic.component.ts +++ b/src/app/poll-graphic/poll-graphic.component.ts @@ -4,7 +4,7 @@ import {DOCUMENT} from '@angular/common'; import {mockGraphConfig} from "../config/mocks/mock-graph"; import {graphOptions} from "../config/graph-canevas-options"; import {ConfigService} from "../services/config.service"; -import {mockPoll1} from "../config/mocks/mock1"; +import {mockPoll3} from "../config/mocks/mock-poll3"; @Component({ selector: "framadate-poll-graphic", @@ -13,7 +13,7 @@ import {mockPoll1} from "../config/mocks/mock1"; }) export class PollGraphicComponent implements OnInit { isColorblind: boolean = false; - pollConfigRetrieved: any = mockPoll1; + pollConfigRetrieved: any = mockPoll3; graphicConfig: any = mockGraphConfig; preferred: any = "rien"; yesList: number[] = []; diff --git a/src/app/services/config.service.ts b/src/app/services/config.service.ts index cc789fc9..96a1d983 100644 --- a/src/app/services/config.service.ts +++ b/src/app/services/config.service.ts @@ -7,6 +7,7 @@ import {Router} from "@angular/router"; import {mockMyPolls} from "../config/mocks/mockmypolls"; import {defaultAnswers, defaultDates, defaultTimeOfDay} from "../config/defaultConfigs"; import {mockPoll3} from "../config/mocks/mock-poll3"; +import {mockSuccessVote} from "../config/mocks/mock-success-vote"; /** * le service transverse à chaque page qui permet de syncroniser la configuration de sondage souhaitée @@ -353,10 +354,13 @@ export class ConfigService extends PollConfig { * @param choiceList */ convertChoicesAnsweredToSend(choiceList) { + choiceList = choiceList.filter(c => c.answer ? c : null); // remove choices where we did not answer const converted = choiceList.map(elem => { - return { - choice_id: elem.id, - value: elem.answer + if (elem.answer) { + return { + choice_id: elem.id, + value: elem.answer + } } }); console.log('converted', converted); @@ -378,24 +382,31 @@ export class ConfigService extends PollConfig { } this.myVoteStack = voteStack; + if (!environment.production) { + this.handleVoteAdded(mockSuccessVote); + return; + } this.http.post( `${this.baseHref}/poll/${this.pollId}/vote`, voteStack, this.makeHeaders()) .subscribe((res: any) => { - this.messageService.add({severity: 'success', summary: 'Vote ajouté'}); - - // save modifier token - this.myVoteStack['modifier_token'] = res.modifier_token; - this.myVoteStack['id'] = res.vote_stack.id; - this.updateCurrentPollFromResponse(res); + this.handleVoteAdded(res); }, (e) => { this.handleError(e) } ); } + handleVoteAdded(res) { + this.messageService.add({severity: 'success', summary: 'Vote ajouté'}); + // save modifier token + this.myVoteStack['modifier_token'] = res.modifier_token; + this.myVoteStack['id'] = res.vote_stack.id; + this.updateCurrentPollFromResponse(res); + } + /** * UPDATE * /api/v1/poll/{id}/vote @@ -442,11 +453,11 @@ export class ConfigService extends PollConfig { comment, this.makeHeaders()) .subscribe((res: any) => { - this.messageService.add({ - severity: 'success', - summary: 'Commentaire Créé', - detail: comment.text - }); + this.messageService.add({ + severity: 'success', + summary: 'Commentaire Créé', + detail: comment.text + }); // empty comment after success this.myComment = ''; comment.date = {