-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(events): add a selector for easier event comparison
- Loading branch information
1 parent
12c0ec8
commit 5a568b2
Showing
7 changed files
with
132 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<div class="ui violet segment"> | ||
{{ form_start(form) }} | ||
<div class="ui form"> | ||
<div class="inline fields"> | ||
<div class="field"> | ||
{{ form_label(form.compared_event_id, 'Comparer à') }} | ||
{{ form_widget(form.compared_event_id, {attr: {onchange:'this.form.submit(); return false;'}}) }} | ||
</div> | ||
</div> | ||
</div> | ||
{{ form_end(form) }} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
|
||
namespace AppBundle\Event\Form; | ||
|
||
use AppBundle\Event\Model\Repository\EventRepository; | ||
use CCMBenchmark\Ting\Exception; | ||
use CCMBenchmark\Ting\Query\QueryException; | ||
use Symfony\Component\Form\AbstractType; | ||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | ||
use Symfony\Component\Form\Extension\Core\Type\HiddenType; | ||
use Symfony\Component\Form\FormBuilderInterface; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
|
||
class EventCompareSelectType extends AbstractType | ||
{ | ||
/** @var EventRepository */ | ||
private $eventRepository; | ||
|
||
public function __construct(EventRepository $eventRepository) | ||
{ | ||
$this->eventRepository = $eventRepository; | ||
} | ||
|
||
/** | ||
* @throws QueryException | ||
* @throws Exception | ||
*/ | ||
public function buildForm(FormBuilderInterface $builder, array $options) | ||
{ | ||
|
||
$eventId = $builder->getData()['id'] ?? null; | ||
$excludedEventId = $builder->getData()['compared_event_id'] ?? null; | ||
$events = $this->eventRepository->getAllEventsExcept($eventId); | ||
|
||
dump($events->first()); | ||
|
||
$builder | ||
->add('compared_event_id', ChoiceType::class, | ||
[ | ||
'choice_label' => 'title', | ||
'choice_value' => 'id', | ||
'data' => "2", | ||
'choices' => $events, | ||
] | ||
) | ||
->setMethod(Request::METHOD_GET) | ||
->add('id', HiddenType::class, [ | ||
'data' => $eventId, | ||
]) | ||
; | ||
} | ||
|
||
public function configureOptions(OptionsResolver $resolver) | ||
{ | ||
$resolver->setDefaults([ | ||
'csrf_protection' => false | ||
]); | ||
} | ||
|
||
public function getBlockPrefix(): string | ||
{ | ||
return 'compare_event'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters