forked from tykayn/funky-framadate-front
⚡ update current answers with a previous vote
This commit is contained in:
parent
f976d65d20
commit
9cf368f550
@ -43,6 +43,7 @@ export class PollConfig {
|
|||||||
voteChoices = 'only_yes'; // possible answers to a vote choice: only "yes", "yes, maybe, no"
|
voteChoices = 'only_yes'; // possible answers to a vote choice: only "yes", "yes, maybe, no"
|
||||||
creationDate = new Date();
|
creationDate = new Date();
|
||||||
expirationDate = ''; // expiracy date
|
expirationDate = ''; // expiracy date
|
||||||
|
voteStackId = null; // id of the vote stack to update
|
||||||
pollId = null; // id of the current poll when created. data given by the backend api
|
pollId = null; // id of the current poll when created. data given by the backend api
|
||||||
pollSlug = null; // id of the current poll when created. data given by the backend api
|
pollSlug = null; // id of the current poll when created. data given by the backend api
|
||||||
currentPoll; // current poll selected with createPoll or getPoll of ConfigService
|
currentPoll; // current poll selected with createPoll or getPoll of ConfigService
|
||||||
|
@ -26,7 +26,7 @@ export const mockPoll3 = {
|
|||||||
"allowedAnswers": [
|
"allowedAnswers": [
|
||||||
"yes"
|
"yes"
|
||||||
],
|
],
|
||||||
"modificationPolicy": "self",
|
"modificationPolicy": "everybody",
|
||||||
"mailOnComment": null,
|
"mailOnComment": null,
|
||||||
"mailOnVote": null,
|
"mailOnVote": null,
|
||||||
"hideResults": null,
|
"hideResults": null,
|
||||||
@ -965,4 +965,4 @@ export const mockPoll3 = {
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"comments_count": 14
|
"comments_count": 14
|
||||||
}
|
};
|
||||||
|
@ -35,16 +35,24 @@
|
|||||||
*ngFor='let voteStack of pollconfig.stacks'
|
*ngFor='let voteStack of pollconfig.stacks'
|
||||||
>
|
>
|
||||||
<td >
|
<td >
|
||||||
|
|
||||||
|
<button
|
||||||
|
(click)='config.loadVoteStack(voteStack)'
|
||||||
|
*ngIf="config.currentPoll.poll.modificationPolicy === 'everybody'"
|
||||||
|
class='btn btn--primary pull-left btn--small'
|
||||||
|
>
|
||||||
|
<i class='fa fa-pencil' ></i >
|
||||||
|
</button >
|
||||||
{{voteStack.pseudo}}
|
{{voteStack.pseudo}}
|
||||||
</td >
|
</td >
|
||||||
<td *ngFor='let v of getKeys(voteStack.votes)' >
|
<td *ngFor='let v of getKeys(voteStack.votes)' >
|
||||||
<!-- {{voteStack.votes[v].choice_id}}-->
|
|
||||||
<span *ngIf='voteStack.votes[v].value' >
|
<span *ngIf='voteStack.votes[v].value' >
|
||||||
|
|
||||||
{{voteStack.votes[v].value}}
|
{{voteStack.votes[v].value}}
|
||||||
</span >
|
</span >
|
||||||
</td >
|
</td >
|
||||||
</tr >
|
</tr >
|
||||||
|
<!-- bottom line shows each answer details-->
|
||||||
<tr class='details' >
|
<tr class='details' >
|
||||||
<td >
|
<td >
|
||||||
<i class='fa fa-eye' ></i >
|
<i class='fa fa-eye' ></i >
|
||||||
|
@ -10,9 +10,6 @@ import {mockPoll3} from "../../../config/mocks/mock-poll3";
|
|||||||
export class VotingSummaryComponent implements OnInit {
|
export class VotingSummaryComponent implements OnInit {
|
||||||
|
|
||||||
preferred: string = 'rien';
|
preferred: string = 'rien';
|
||||||
counters: any = {};
|
|
||||||
orderedListOfChoices: any = {};
|
|
||||||
enrichedStacks: any = []; // a list of vote stacks with the missing ids of what has not been voted
|
|
||||||
|
|
||||||
@Input() pollconfig = mockPoll3;
|
@Input() pollconfig = mockPoll3;
|
||||||
|
|
||||||
|
@ -290,6 +290,32 @@ export class ConfigService extends PollConfig {
|
|||||||
this.urlAdmin = this.baseHref + '#/admin/' + res.admin_key;
|
this.urlAdmin = this.baseHref + '#/admin/' + res.admin_key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* update current answers with a previous vote
|
||||||
|
* @param voteStack
|
||||||
|
*/
|
||||||
|
loadVoteStack(voteStack: any) {
|
||||||
|
|
||||||
|
// load the pseudo and email
|
||||||
|
this.myName = voteStack.pseudo;
|
||||||
|
this.myEmail = voteStack.pseudo;
|
||||||
|
this.voteStackId = voteStack.id;
|
||||||
|
this.myVoteStack = voteStack;
|
||||||
|
let votesId = Object.keys(voteStack.votes);
|
||||||
|
votesId.map((id) => {
|
||||||
|
let voteItem = voteStack.votes[id];
|
||||||
|
|
||||||
|
if (voteItem.choice_id && voteItem.value) {
|
||||||
|
let foundChoiceToModify = this.currentPoll.choices.find(choicesItem => {
|
||||||
|
return voteItem.choice_id == choicesItem.id
|
||||||
|
});
|
||||||
|
if (foundChoiceToModify) {
|
||||||
|
foundChoiceToModify.answer = voteItem.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* POST
|
* POST
|
||||||
* /api/v1/poll/{id}/poll
|
* /api/v1/poll/{id}/poll
|
||||||
@ -297,7 +323,7 @@ export class ConfigService extends PollConfig {
|
|||||||
*/
|
*/
|
||||||
createPollFromConfig(config: any) {
|
createPollFromConfig(config: any) {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
console.log('config', config)
|
console.log('config', config);
|
||||||
return this.http.post(`${this.baseHref}/poll`,
|
return this.http.post(`${this.baseHref}/poll`,
|
||||||
config,
|
config,
|
||||||
this.makeHeaders())
|
this.makeHeaders())
|
||||||
@ -410,7 +436,7 @@ export class ConfigService extends PollConfig {
|
|||||||
text: this.myComment,
|
text: this.myComment,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log('comment', comment)
|
console.log('comment', comment);
|
||||||
this.http.post(
|
this.http.post(
|
||||||
`${this.baseHref}/poll/${this.pollId}/comment`,
|
`${this.baseHref}/poll/${this.pollId}/comment`,
|
||||||
comment,
|
comment,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user