display vote stack data in new vote

This commit is contained in:
Baptiste Lemoine 2020-01-21 10:46:29 +01:00
parent d8b745a1d1
commit 585bdc9f19
2 changed files with 19 additions and 3 deletions

View File

@ -407,8 +407,7 @@ class DefaultController extends AbstractController {
return $this->json( [ return $this->json( [
'message' => 'you created a comment', 'message' => 'you created a comment',
'data' => [ 'data' => [
'your_comment' => $comment->display(), 'your_comment' => $comment->display(),
'poll_comments' => $poll->getComments(),
], ],
], ],
201 ); 201 );
@ -444,6 +443,7 @@ class DefaultController extends AbstractController {
} else { } else {
$existingOwner = true; $existingOwner = true;
} }
// TODO anti flood
$foundOwner $foundOwner
->setModifierToken( $poll->generateAdminKey() ); ->setModifierToken( $poll->generateAdminKey() );
$stack = new StackOfVotes(); $stack = new StackOfVotes();
@ -483,7 +483,8 @@ class DefaultController extends AbstractController {
return $this->json( [ return $this->json( [
'message' => 'you created a vote stack' . $precision, 'message' => 'you created a vote stack' . $precision,
'vote_stack' => $stack, 'vote_stack' => $stack->display(),
'vote_count' => count( $poll->getStacksOfVotes() ),
'owner_modifier_token' => $foundOwner->getModifierToken(), 'owner_modifier_token' => $foundOwner->getModifierToken(),
'json_you_sent' => $data, 'json_you_sent' => $data,
], ],

View File

@ -41,6 +41,21 @@ class StackOfVotes {
*/ */
private $owner; private $owner;
public function display() {
$tab = [];
foreach ( $this->getVotes() as $vote ) {
$tab[ $vote->getId() ] = [
'id' => $vote->getId(),
'value' => $vote->getValue(),
'choice_id' => $vote->getChoice()->getId(),
'text' => $vote->getChoice()->getName(),
];
}
return $tab;
}
public function __construct() { public function __construct() {
$this->votes = new ArrayCollection(); $this->votes = new ArrayCollection();
} }