mirror of
https://framagit.org/framasoft/framadate/funky-framadate-front.git
synced 2023-08-25 13:53:14 +02:00
sort table of answers
This commit is contained in:
parent
9cf368f550
commit
ca69160ea9
@ -26,7 +26,7 @@ export const mockPoll3 = {
|
|||||||
"allowedAnswers": [
|
"allowedAnswers": [
|
||||||
"yes"
|
"yes"
|
||||||
],
|
],
|
||||||
"modificationPolicy": "everybody",
|
"modificationPolicy": "self",
|
||||||
"mailOnComment": null,
|
"mailOnComment": null,
|
||||||
"mailOnVote": null,
|
"mailOnVote": null,
|
||||||
"hideResults": null,
|
"hideResults": null,
|
||||||
@ -37,7 +37,7 @@ export const mockPoll3 = {
|
|||||||
"comments": {},
|
"comments": {},
|
||||||
"defaultExpiracyDaysFromNow": 60
|
"defaultExpiracyDaysFromNow": 60
|
||||||
},
|
},
|
||||||
"stacks_count": 14,
|
"stacks_count": 16,
|
||||||
"stacks": [
|
"stacks": [
|
||||||
{
|
{
|
||||||
"id": 3,
|
"id": 3,
|
||||||
@ -633,13 +633,113 @@ export const mockPoll3 = {
|
|||||||
"text": null
|
"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": {
|
"choices_count": {
|
||||||
"counts": {
|
"counts": {
|
||||||
"7": {
|
"7": {
|
||||||
|
"choice_id": 7,
|
||||||
|
"choice_text": "Les mystérieuses cités d'or",
|
||||||
|
"id": 4,
|
||||||
|
"score": 12,
|
||||||
"yes": {
|
"yes": {
|
||||||
"count": 10,
|
"count": 12,
|
||||||
"people": [
|
"people": [
|
||||||
"voting_people_TEST",
|
"voting_people_TEST",
|
||||||
"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",
|
"voting_people_TEST",
|
||||||
"voting_people_TEST"
|
"voting_people_TEST",
|
||||||
|
"tk_TEST",
|
||||||
|
"tk_TEST"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"maybe": {
|
"maybe": {
|
||||||
@ -665,10 +767,16 @@ export const mockPoll3 = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"6": {
|
"6": {
|
||||||
|
"choice_id": 6,
|
||||||
|
"choice_text": "Boumbo petite automobile",
|
||||||
|
"id": 5,
|
||||||
|
"score": 7.5,
|
||||||
"yes": {
|
"yes": {
|
||||||
"count": 1,
|
"count": 3,
|
||||||
"people": [
|
"people": [
|
||||||
"voting_people_TEST"
|
"voting_people_TEST",
|
||||||
|
"tk_TEST",
|
||||||
|
"tk_TEST"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"maybe": {
|
"maybe": {
|
||||||
@ -691,9 +799,16 @@ export const mockPoll3 = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"5": {
|
"5": {
|
||||||
|
"choice_id": 5,
|
||||||
|
"choice_text": "Vic le viking",
|
||||||
|
"id": 9,
|
||||||
|
"score": 2,
|
||||||
"yes": {
|
"yes": {
|
||||||
"count": 0,
|
"count": 2,
|
||||||
"people": []
|
"people": [
|
||||||
|
"tk_TEST",
|
||||||
|
"tk_TEST"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"maybe": {
|
"maybe": {
|
||||||
"count": 0,
|
"count": 0,
|
||||||
@ -714,6 +829,10 @@ export const mockPoll3 = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"2": {
|
"2": {
|
||||||
|
"choice_id": 2,
|
||||||
|
"choice_text": null,
|
||||||
|
"id": 33,
|
||||||
|
"score": 4,
|
||||||
"yes": {
|
"yes": {
|
||||||
"count": 4,
|
"count": 4,
|
||||||
"people": [
|
"people": [
|
||||||
@ -733,6 +852,10 @@ export const mockPoll3 = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"1": {
|
"1": {
|
||||||
|
"choice_id": 1,
|
||||||
|
"choice_text": "orange",
|
||||||
|
"id": 36,
|
||||||
|
"score": 0,
|
||||||
"yes": {
|
"yes": {
|
||||||
"count": 0,
|
"count": 0,
|
||||||
"people": []
|
"people": []
|
||||||
@ -747,8 +870,30 @@ export const mockPoll3 = {
|
|||||||
"tk_TEST"
|
"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": [
|
"choices": [
|
||||||
{
|
{
|
||||||
|
1107
src/app/config/mocks/mock-success-vote.ts
Normal file
1107
src/app/config/mocks/mock-success-vote.ts
Normal file
File diff suppressed because it is too large
Load Diff
@ -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
|
|
||||||
};
|
|
@ -1,19 +1,24 @@
|
|||||||
<h2 >Résumé</h2 >
|
<h2 >Résumé</h2 >
|
||||||
<div class="preferred" >
|
<div class="preferred" >
|
||||||
<i class='fa fa-star' ></i >
|
<i class='fa fa-star' ></i >
|
||||||
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 :
|
||||||
<span class='preferred-result' >
|
<span class='preferred-result' >
|
||||||
{{preferred}}
|
{{preferred}}
|
||||||
</span >
|
</span >
|
||||||
</div >
|
</div >
|
||||||
<table >
|
<table >
|
||||||
<thead >
|
<thead >
|
||||||
<tr >
|
<tr *ngIf='config.currentPoll.choices && config.currentPoll.choices_count' >
|
||||||
<td >
|
<td >
|
||||||
Pseudo
|
Pseudo
|
||||||
</td >
|
</td >
|
||||||
<td *ngFor='let choice of config.currentPoll.choices' >
|
<td
|
||||||
{{choice.text}}
|
*ngFor='let k of getKeys(config.currentPoll.choices_count.counts )'
|
||||||
|
|
||||||
|
>
|
||||||
|
{{k}} )
|
||||||
|
{{config.currentPoll.choices_count.counts[k].choice_text}}
|
||||||
</td >
|
</td >
|
||||||
</tr >
|
</tr >
|
||||||
<!-- somme des points, dont un demi point pour les "peut être" -->
|
<!-- somme des points, dont un demi point pour les "peut être" -->
|
||||||
@ -26,13 +31,35 @@
|
|||||||
<td >
|
<td >
|
||||||
<i class='fa fa-plus-circle' ></i > points
|
<i class='fa fa-plus-circle' ></i > points
|
||||||
</td >
|
</td >
|
||||||
|
<td
|
||||||
|
*ngFor='let k of getKeys(config.currentPoll.choices_count.counts )'
|
||||||
|
[ngClass]='{"has-max-score" : config.currentPoll.choices_count.maxScore === config.currentPoll.choices_count.counts[k].score}' >
|
||||||
|
{{config.currentPoll.choices_count.counts[k].score}}
|
||||||
|
</td >
|
||||||
|
</tr >
|
||||||
|
<tr class='details' >
|
||||||
|
<td >
|
||||||
|
<i class='fa fa-eye' ></i >
|
||||||
|
</td >
|
||||||
<td *ngFor='let k of getKeys(config.currentPoll.choices_count.counts )' >
|
<td *ngFor='let k of getKeys(config.currentPoll.choices_count.counts )' >
|
||||||
{{ 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}}
|
||||||
|
<br >
|
||||||
|
yes {{config.currentPoll.choices_count.counts[k].yes.count}}
|
||||||
|
<br >
|
||||||
|
maybe
|
||||||
|
{{(config.currentPoll.choices_count.counts[k].yes.maybe ? config.currentPoll.choices_count.counts[k].yes.count * 0.5 : 0)}}
|
||||||
|
|
||||||
|
<br >
|
||||||
|
no {{(config.currentPoll.choices_count.counts[k].yes.maybe ? config.currentPoll.choices_count.counts[k].maybe.count * 0.5 : 0)}}
|
||||||
|
<br >
|
||||||
|
score :
|
||||||
|
{{(config.currentPoll.choices_count.counts[k].score)}}
|
||||||
|
|
||||||
</td >
|
</td >
|
||||||
</tr >
|
</tr >
|
||||||
<tr
|
<tr
|
||||||
class='votes-of-the-person'
|
class='votes-of-the-person'
|
||||||
*ngFor='let voteStack of pollconfig.stacks'
|
*ngFor='let voteStack of config.currentPoll.stacks'
|
||||||
>
|
>
|
||||||
<td >
|
<td >
|
||||||
|
|
||||||
@ -47,26 +74,12 @@
|
|||||||
</td >
|
</td >
|
||||||
<td *ngFor='let v of getKeys(voteStack.votes)' >
|
<td *ngFor='let v of getKeys(voteStack.votes)' >
|
||||||
<span *ngIf='voteStack.votes[v].value' >
|
<span *ngIf='voteStack.votes[v].value' >
|
||||||
|
id {{v}} )
|
||||||
{{voteStack.votes[v].value}}
|
{{voteStack.votes[v].value}}
|
||||||
</span >
|
</span >
|
||||||
</td >
|
</td >
|
||||||
</tr >
|
</tr >
|
||||||
<!-- bottom line shows each answer details-->
|
<!-- bottom line shows each answer details-->
|
||||||
<tr class='details' >
|
|
||||||
<td >
|
|
||||||
<i class='fa fa-eye' ></i >
|
|
||||||
</td >
|
|
||||||
<td *ngFor='let k of getKeys(config.currentPoll.choices_count.counts )' >
|
|
||||||
yes {{config.currentPoll.choices_count.counts[k].yes.count}}
|
|
||||||
<br >
|
|
||||||
maybe
|
|
||||||
{{(config.currentPoll.choices_count.counts[k].yes.maybe ? config.currentPoll.choices_count.counts[k].yes.count * 0.5 : 0)}}
|
|
||||||
|
|
||||||
<br >
|
|
||||||
no {{(config.currentPoll.choices_count.counts[k].yes.maybe ? config.currentPoll.choices_count.counts[k].maybe.count * 0.5 : 0)}}
|
|
||||||
|
|
||||||
</td >
|
|
||||||
</tr >
|
|
||||||
</tbody >
|
</tbody >
|
||||||
</table >
|
</table >
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
@import "../../../../assets/scss/variables";
|
||||||
|
|
||||||
.person {
|
.person {
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
}
|
}
|
||||||
@ -15,3 +17,10 @@ thead {
|
|||||||
tbody {
|
tbody {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
td {
|
||||||
|
&.has-max-score {
|
||||||
|
background: $primary_color;
|
||||||
|
font-weight: 800;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -4,7 +4,7 @@ import {DOCUMENT} from '@angular/common';
|
|||||||
import {mockGraphConfig} from "../config/mocks/mock-graph";
|
import {mockGraphConfig} from "../config/mocks/mock-graph";
|
||||||
import {graphOptions} from "../config/graph-canevas-options";
|
import {graphOptions} from "../config/graph-canevas-options";
|
||||||
import {ConfigService} from "../services/config.service";
|
import {ConfigService} from "../services/config.service";
|
||||||
import {mockPoll1} from "../config/mocks/mock1";
|
import {mockPoll3} from "../config/mocks/mock-poll3";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "framadate-poll-graphic",
|
selector: "framadate-poll-graphic",
|
||||||
@ -13,7 +13,7 @@ import {mockPoll1} from "../config/mocks/mock1";
|
|||||||
})
|
})
|
||||||
export class PollGraphicComponent implements OnInit {
|
export class PollGraphicComponent implements OnInit {
|
||||||
isColorblind: boolean = false;
|
isColorblind: boolean = false;
|
||||||
pollConfigRetrieved: any = mockPoll1;
|
pollConfigRetrieved: any = mockPoll3;
|
||||||
graphicConfig: any = mockGraphConfig;
|
graphicConfig: any = mockGraphConfig;
|
||||||
preferred: any = "rien";
|
preferred: any = "rien";
|
||||||
yesList: number[] = [];
|
yesList: number[] = [];
|
||||||
|
@ -7,6 +7,7 @@ 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 {mockPoll3} from "../config/mocks/mock-poll3";
|
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
|
* 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
|
* @param choiceList
|
||||||
*/
|
*/
|
||||||
convertChoicesAnsweredToSend(choiceList) {
|
convertChoicesAnsweredToSend(choiceList) {
|
||||||
|
choiceList = choiceList.filter(c => c.answer ? c : null); // remove choices where we did not answer
|
||||||
const converted = choiceList.map(elem => {
|
const converted = choiceList.map(elem => {
|
||||||
return {
|
if (elem.answer) {
|
||||||
choice_id: elem.id,
|
return {
|
||||||
value: elem.answer
|
choice_id: elem.id,
|
||||||
|
value: elem.answer
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
console.log('converted', converted);
|
console.log('converted', converted);
|
||||||
@ -378,24 +382,31 @@ export class ConfigService extends PollConfig {
|
|||||||
}
|
}
|
||||||
this.myVoteStack = voteStack;
|
this.myVoteStack = voteStack;
|
||||||
|
|
||||||
|
if (!environment.production) {
|
||||||
|
this.handleVoteAdded(mockSuccessVote);
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.http.post(
|
this.http.post(
|
||||||
`${this.baseHref}/poll/${this.pollId}/vote`,
|
`${this.baseHref}/poll/${this.pollId}/vote`,
|
||||||
voteStack,
|
voteStack,
|
||||||
this.makeHeaders())
|
this.makeHeaders())
|
||||||
.subscribe((res: any) => {
|
.subscribe((res: any) => {
|
||||||
|
|
||||||
this.messageService.add({severity: 'success', summary: 'Vote ajouté'});
|
this.handleVoteAdded(res);
|
||||||
|
|
||||||
// save modifier token
|
|
||||||
this.myVoteStack['modifier_token'] = res.modifier_token;
|
|
||||||
this.myVoteStack['id'] = res.vote_stack.id;
|
|
||||||
this.updateCurrentPollFromResponse(res);
|
|
||||||
}, (e) => {
|
}, (e) => {
|
||||||
this.handleError(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
|
* UPDATE
|
||||||
* /api/v1/poll/{id}/vote
|
* /api/v1/poll/{id}/vote
|
||||||
@ -442,11 +453,11 @@ export class ConfigService extends PollConfig {
|
|||||||
comment,
|
comment,
|
||||||
this.makeHeaders())
|
this.makeHeaders())
|
||||||
.subscribe((res: any) => {
|
.subscribe((res: any) => {
|
||||||
this.messageService.add({
|
this.messageService.add({
|
||||||
severity: 'success',
|
severity: 'success',
|
||||||
summary: 'Commentaire Créé',
|
summary: 'Commentaire Créé',
|
||||||
detail: comment.text
|
detail: comment.text
|
||||||
});
|
});
|
||||||
// empty comment after success
|
// empty comment after success
|
||||||
this.myComment = '';
|
this.myComment = '';
|
||||||
comment.date = {
|
comment.date = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user