sort table of answers

archived-develop
Baptiste Lemoine 3 years ago
parent 9cf368f550
commit ca69160ea9

@ -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": [
{

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 >
<div class="preferred" >
<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' >
{{preferred}}
</span >
</div >
<table >
<thead >
<tr >
<tr *ngIf='config.currentPoll.choices && config.currentPoll.choices_count' >
<td >
Pseudo
</td >
<td *ngFor='let choice of config.currentPoll.choices' >
{{choice.text}}
<td
*ngFor='let k of getKeys(config.currentPoll.choices_count.counts )'
>
{{k}} )
{{config.currentPoll.choices_count.counts[k].choice_text}}
</td >
</tr >
<!-- somme des points, dont un demi point pour les "peut être" -->
@ -26,13 +31,35 @@
<td >
<i class='fa fa-plus-circle' ></i > points
</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 )' >
{{ 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 >
</tr >
<tr
class='votes-of-the-person'
*ngFor='let voteStack of pollconfig.stacks'
*ngFor='let voteStack of config.currentPoll.stacks'
>
<td >
@ -47,26 +74,12 @@
</td >
<td *ngFor='let v of getKeys(voteStack.votes)' >
<span *ngIf='voteStack.votes[v].value' >
{{voteStack.votes[v].value}}
id {{v}} )
{{voteStack.votes[v].value}}
</span >
</td >
</tr >
<!-- 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 >
</table >

@ -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;
}
}

@ -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[] = [];

@ -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 = {

Loading…
Cancel
Save