mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-14 06:14:23 +00:00
add a first step to pick center in new event form
This commit is contained in:
parent
6d2ea8caab
commit
fda14a52e0
@ -16,6 +16,10 @@ use Symfony\Component\Security\Core\Role\Role;
|
|||||||
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||||
|
use Chill\EventBundle\Form\Type\PickCenterType;
|
||||||
|
use Chill\MainBundle\Entity\Center;
|
||||||
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
|
use Symfony\Component\Form\FormFactoryInterface;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,15 +38,25 @@ class EventController extends Controller
|
|||||||
*/
|
*/
|
||||||
protected $authorizationHelper;
|
protected $authorizationHelper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var FormFactoryInterface
|
||||||
|
*/
|
||||||
|
protected $formFactoryInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EventController constructor.
|
* EventController constructor.
|
||||||
*
|
*
|
||||||
* @param EventDispatcherInterface $eventDispatcher
|
* @param EventDispatcherInterface $eventDispatcher
|
||||||
*/
|
*/
|
||||||
public function __construct(EventDispatcherInterface $eventDispatcher, AuthorizationHelper $authorizationHelper)
|
public function __construct(
|
||||||
|
EventDispatcherInterface $eventDispatcher,
|
||||||
|
AuthorizationHelper $authorizationHelper,
|
||||||
|
FormFactoryInterface $formFactoryInterface
|
||||||
|
)
|
||||||
{
|
{
|
||||||
$this->eventDispatcher = $eventDispatcher;
|
$this->eventDispatcher = $eventDispatcher;
|
||||||
$this->authorizationHelper = $authorizationHelper;
|
$this->authorizationHelper = $authorizationHelper;
|
||||||
|
$this->formFactoryInterface = $formFactoryInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -98,14 +112,63 @@ class EventController extends Controller
|
|||||||
|
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* First step of new Event form
|
||||||
|
*/
|
||||||
|
public function newPickCenterAction()
|
||||||
|
{
|
||||||
|
$role = new Role('CHILL_EVENT_CREATE');
|
||||||
|
|
||||||
|
/** @var Center $centers */
|
||||||
|
$centers = $this->authorizationHelper->getReachableCenters($this->getUser(), $role);
|
||||||
|
|
||||||
|
$form = $this->formFactoryInterface
|
||||||
|
->createNamedBuilder(null)
|
||||||
|
->setMethod('GET')
|
||||||
|
->setAction(
|
||||||
|
$this->generateUrl('chill_event__event_new'))
|
||||||
|
->add('center_id', EntityType::class, array(
|
||||||
|
'class' => Center::class,
|
||||||
|
'choices' => $centers,
|
||||||
|
'placeholder' => '',
|
||||||
|
'label' => 'To which centre should the event be associated ?'
|
||||||
|
))
|
||||||
|
->add('submit', SubmitType::class, array(
|
||||||
|
'label' => 'Next step'
|
||||||
|
))
|
||||||
|
->getForm();
|
||||||
|
|
||||||
|
if (count($centers) === 1)
|
||||||
|
{
|
||||||
|
return $this->redirectToRoute('chill_event__event_new', array(
|
||||||
|
'center_id' => $centers[0]->getId()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render('ChillEventBundle:Event:newPickCenter.html.twig', array(
|
||||||
|
'form' => $form->createView()
|
||||||
|
));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a form to create a new Event entity.
|
* Displays a form to create a new Event entity.
|
||||||
*
|
* @param Center $center
|
||||||
|
* @param Request $request
|
||||||
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
*/
|
*/
|
||||||
public function newAction()
|
public function newAction(Center $center = null, Request $request)
|
||||||
{
|
{
|
||||||
|
if ($center === null)
|
||||||
|
{
|
||||||
|
$center_id = $request->query->get('center_id');
|
||||||
|
$center = $this->getDoctrine()->getRepository(Center::class)->find($center_id);
|
||||||
|
}
|
||||||
|
|
||||||
$entity = new Event();
|
$entity = new Event();
|
||||||
|
$entity->setCenter($center);
|
||||||
|
|
||||||
$form = $this->createCreateForm($entity);
|
$form = $this->createCreateForm($entity);
|
||||||
|
|
||||||
return $this->render('ChillEventBundle:Event:new.html.twig', array(
|
return $this->render('ChillEventBundle:Event:new.html.twig', array(
|
||||||
|
@ -12,9 +12,9 @@ chill_event__event_show:
|
|||||||
path: /{event_id}/show
|
path: /{event_id}/show
|
||||||
defaults: { _controller: "ChillEventBundle:Event:show" }
|
defaults: { _controller: "ChillEventBundle:Event:show" }
|
||||||
|
|
||||||
chill_event__event_new:
|
chill_event__event_new_pickcenter:
|
||||||
path: /new
|
path: /new/pick-center
|
||||||
defaults: { _controller: "ChillEventBundle:Event:new" }
|
defaults: { _controller: "ChillEventBundle:Event:newPickCenter" }
|
||||||
options:
|
options:
|
||||||
menus:
|
menus:
|
||||||
section:
|
section:
|
||||||
@ -22,6 +22,10 @@ chill_event__event_new:
|
|||||||
label: Add an event
|
label: Add an event
|
||||||
icons: [plus, calendar-o]
|
icons: [plus, calendar-o]
|
||||||
|
|
||||||
|
chill_event__event_new:
|
||||||
|
path: /new
|
||||||
|
defaults: { _controller: "ChillEventBundle:Event:new" }
|
||||||
|
|
||||||
chill_event__event_create:
|
chill_event__event_create:
|
||||||
path: /create
|
path: /create
|
||||||
defaults: { _controller: "ChillEventBundle:Event:create" }
|
defaults: { _controller: "ChillEventBundle:Event:create" }
|
||||||
|
@ -3,4 +3,5 @@ services:
|
|||||||
arguments:
|
arguments:
|
||||||
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
|
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
|
||||||
$authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper'
|
$authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper'
|
||||||
|
$formFactoryInterface: '@Symfony\Component\Form\FormFactoryInterface'
|
||||||
tags: ['controller.service_arguments']
|
tags: ['controller.service_arguments']
|
||||||
|
@ -56,3 +56,8 @@ CHILL_EVENT_PARTICIPATION_CREATE: Créer une participation à un événement
|
|||||||
CHILL_EVENT_PARTICIPATION_UPDATE: Modifier une participation à un événement
|
CHILL_EVENT_PARTICIPATION_UPDATE: Modifier une participation à un événement
|
||||||
CHILL_EVENT_SEE: Voir un événement
|
CHILL_EVENT_SEE: Voir un événement
|
||||||
CHILL_EVENT_SEE_DETAILS: Voir les détails d'un événement
|
CHILL_EVENT_SEE_DETAILS: Voir les détails d'un événement
|
||||||
|
|
||||||
|
# TODO check place to put this
|
||||||
|
Next step: Étape suivante
|
||||||
|
To which centre should the event be associated ?: À quel centre doit être associé l'événement ?
|
||||||
|
|
||||||
|
26
Resources/views/Event/newPickCenter.html.twig
Normal file
26
Resources/views/Event/newPickCenter.html.twig
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{% extends 'ChillEventBundle::layout.html.twig' %}
|
||||||
|
|
||||||
|
{% block title 'Event creation'|trans %}
|
||||||
|
|
||||||
|
{% block event_content -%}
|
||||||
|
<h1>{{ 'Event creation'|trans }}</h1>
|
||||||
|
|
||||||
|
{{ form_start(form) }}
|
||||||
|
{{ form_errors(form) }}
|
||||||
|
|
||||||
|
{{ form_row(form.center_id) }}
|
||||||
|
|
||||||
|
<ul class="record_actions">
|
||||||
|
<li class="cancel">
|
||||||
|
<a href="{{ path('chill_event_list_most_recent') }}" class="sc-button bt-cancel">
|
||||||
|
{{ 'Back to the most recent events'|trans }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
{{ form_widget(form.submit, { 'attr' : { 'class' : 'sc-button green' } }) }}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
{{ form_end(form) }}
|
||||||
|
|
||||||
|
{% endblock %}
|
Loading…
x
Reference in New Issue
Block a user