adapt display of choice for timeslice

This commit is contained in:
Tykayn 2021-04-30 14:30:45 +02:00 committed by tykayn
parent 9ff5429051
commit 723c774d51
3 changed files with 4 additions and 27 deletions

View File

@ -480,28 +480,14 @@ class PollController extends EmailsController {
if ( $pollFound ) {
$poll = $pollFound;
$comments = $poll->getComments();
$stacks = $poll->getStacksOfVotes();
$returnedPoll = [
'message' => 'your poll config',
'poll' => $poll,
'stacks_count' => count( $stacks ),
'stacks' => $stacks,
'choices_count' => $poll->computeAnswers(),
'choices' => $poll->getChoices(),
'comments' => $comments,
'comments_count' => count( $comments ),
'token' => $token,
'poll' => $poll->displayForAdmin(),
];
$jsonResponse = $serializer->serialize( $returnedPoll, 'json' );
$response = new Response( $jsonResponse );
$response->headers->set( 'Content-Type', 'application/json' );
$response->setStatusCode( 200 );
return $response;
return $this->json( $returnedPoll,
200 );;
}
return $this->json( [

View File

@ -67,15 +67,6 @@ class Choice {
'name' => $this->getName(),
'url' => $this->getUrl(),
];
if ( $kind === 'date' ) {
try {
$date = new DateTime( $this->getName() );
} catch ( \Exception $e ) {
die($e);
}
$fields[ 'name' ] = $date->format( 'c' );
}
return $fields;
}

View File

@ -244,7 +244,7 @@
}
$displayedChoices = [];
foreach ( $this->getChoices() as $choice ) {
$displayedChoices[] = $choice->display();
$displayedChoices[] = $choice->display($this->getKind());
}
$displayedComments = [];
foreach ( $this->getComments() as $comment ) {