1
0
mirror of https://framagit.org/tykayn/date-poll-api synced 2023-08-25 08:23:11 +02:00

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 ) { if ( $pollFound ) {
$poll = $pollFound; $poll = $pollFound;
$comments = $poll->getComments();
$stacks = $poll->getStacksOfVotes();
$returnedPoll = [ $returnedPoll = [
'message' => 'your poll config', 'message' => 'your poll config',
'poll' => $poll, 'poll' => $poll->displayForAdmin(),
'stacks_count' => count( $stacks ),
'stacks' => $stacks,
'choices_count' => $poll->computeAnswers(),
'choices' => $poll->getChoices(),
'comments' => $comments,
'comments_count' => count( $comments ),
'token' => $token,
]; ];
$jsonResponse = $serializer->serialize( $returnedPoll, 'json' ); return $this->json( $returnedPoll,
200 );;
$response = new Response( $jsonResponse );
$response->headers->set( 'Content-Type', 'application/json' );
$response->setStatusCode( 200 );
return $response;
} }
return $this->json( [ return $this->json( [

View File

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

View File

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