Activity Form : display field according to the parameters

This commit is contained in:
Jean-Francois Monfort 2021-04-29 16:35:39 +02:00
parent 45671bda52
commit 82d8556f24
8 changed files with 354 additions and 209 deletions

View File

@ -22,11 +22,12 @@
namespace Chill\ActivityBundle\Controller; namespace Chill\ActivityBundle\Controller;
use Chill\ActivityBundle\Form\ActivitySelectTypeType;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Privacy\PrivacyEvent; use Chill\PersonBundle\Privacy\PrivacyEvent;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\SubmitType;
@ -69,7 +70,7 @@ class ActivityController extends AbstractController
* Lists all Activity entities. * Lists all Activity entities.
* *
*/ */
public function listAction($person_id, Request $request) public function listAction($person_id)
{ {
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id);
@ -102,31 +103,21 @@ class ActivityController extends AbstractController
)); ));
} }
public function selectTypeAction(int $person_id, Request $request): Response public function selectTypeAction(int $person_id): Response
{ {
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); $person = $em->getRepository(Person::class)->find($person_id);
if ($person === NULL) { if ($person === NULL) {
throw $this->createNotFoundException('Person not found'); throw $this->createNotFoundException('Person not found');
} }
$form = $this->createForm(ActivitySelectTypeType::class); $activityTypes = $em->getRepository(\Chill\ActivityBundle\Entity\ActivityType::class)
->findBy(['active' => true]);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$activityType = $form->get('type')->getData();
if ($activityType instanceof \Chill\ActivityBundle\Entity\ActivityType) {
return $this->redirectToRoute('chill_activity_activity_new', [
'person_id' => $person->getId(),
'activityType_id' => $activityType->getId(),
]);
}
}
return $this->render('ChillActivityBundle:Activity:selectType.html.twig', [ return $this->render('ChillActivityBundle:Activity:selectType.html.twig', [
'form' => $form->createView(), 'person' => $person,
'person' => $person 'activityTypes' => $activityTypes,
]); ]);
} }
@ -191,20 +182,17 @@ class ActivityController extends AbstractController
* *
* @return \Symfony\Component\Form\Form The form * @return \Symfony\Component\Form\Form The form
*/ */
private function createCreateForm(Activity $entity) private function createCreateForm(Activity $entity): FormInterface
{ {
$form = $this->createForm(ActivityType::class, $entity, return $this->createForm(ActivityType::class, $entity, [
array( 'action' => $this->generateUrl('chill_activity_activity_create', [
'action' => $this->generateUrl('chill_activity_activity_create', [ 'person_id' => $entity->getPerson()->getId(),
'person_id' => $entity->getPerson()->getId(), ]),
]), 'method' => 'POST',
'method' => 'POST', 'center' => $entity->getCenter(),
'center' => $entity->getCenter(), 'role' => new Role('CHILL_ACTIVITY_CREATE'),
'role' => new Role('CHILL_ACTIVITY_CREATE') 'activityType' => $entity->getType(),
) ]);
);
return $form;
} }
/** /**
@ -224,7 +212,8 @@ class ActivityController extends AbstractController
$activityType = $em->getRepository(\Chill\ActivityBundle\Entity\ActivityType::class) $activityType = $em->getRepository(\Chill\ActivityBundle\Entity\ActivityType::class)
->find($activityType_id); ->find($activityType_id);
if (!$activityType instanceof \Chill\ActivityBundle\Entity\ActivityType) { if (!$activityType instanceof \Chill\ActivityBundle\Entity\ActivityType ||
!$activityType->isActive()) {
return $this->redirectToRoute('chill_activity_activity_select_type', [ return $this->redirectToRoute('chill_activity_activity_select_type', [
'person_id' => $person->getId(), 'person_id' => $person->getId(),
]); ]);
@ -240,7 +229,7 @@ class ActivityController extends AbstractController
$this->denyAccessUnlessGranted('CHILL_ACTIVITY_CREATE', $entity); $this->denyAccessUnlessGranted('CHILL_ACTIVITY_CREATE', $entity);
$form = $this->createCreateForm($entity); $form = $this->createCreateForm($entity);
return $this->render('ChillActivityBundle:Activity:new.html.twig', array( return $this->render('ChillActivityBundle:Activity:new.html.twig', array(
'person' => $person, 'person' => $person,
@ -333,24 +322,21 @@ class ActivityController extends AbstractController
* Creates a form to edit a Activity entity. * Creates a form to edit a Activity entity.
* *
* @param Activity $entity The entity * @param Activity $entity The entity
*
* @return \Symfony\Component\Form\Form The form
*/ */
private function createEditForm(Activity $entity) private function createEditForm(Activity $entity): FormInterface
{ {
$form = $this->createForm(ActivityType::class, $entity, array( return $this->createForm(ActivityType::class, $entity, [
'action' => $this->generateUrl('chill_activity_activity_update', 'action' => $this->generateUrl('chill_activity_activity_update', [
array( 'id' => $entity->getId(),
'id' => $entity->getId(), 'person_id' => $entity->getPerson()->getId()
'person_id' => $entity->getPerson()->getId() ]),
)),
'method' => 'PUT', 'method' => 'PUT',
'center' => $entity->getCenter(), 'center' => $entity->getCenter(),
'role' => new Role('CHILL_ACTIVITY_UPDATE') 'role' => new Role('CHILL_ACTIVITY_UPDATE'),
)); 'activityType' => $entity->getType(),
]);
return $form;
} }
/** /**
* Edits an existing Activity entity. * Edits an existing Activity entity.
* *

View File

@ -76,7 +76,7 @@ class Activity implements HasCenterInterface, HasScopeInterface
/** /**
* @ORM\Column(type="time", nullable=true) * @ORM\Column(type="time", nullable=true)
*/ */
private ?\DateTime $travelTime; private ?\DateTime $travelTime = null;
/** /**
* @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityPresence") * @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityPresence")
@ -96,7 +96,7 @@ class Activity implements HasCenterInterface, HasScopeInterface
/** /**
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Scope") * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Scope")
*/ */
private Scope $scope; private ?Scope $scope = null;
/** /**
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\Person") * @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\Person")
@ -217,7 +217,7 @@ class Activity implements HasCenterInterface, HasScopeInterface
return $this; return $this;
} }
public function getTravelTime(): \DateTime public function getTravelTime(): ?\DateTime
{ {
return $this->travelTime; return $this->travelTime;
} }
@ -288,7 +288,7 @@ class Activity implements HasCenterInterface, HasScopeInterface
/** /**
* Get scope * Get scope
*/ */
public function getScope(): Scope public function getScope(): ?Scope
{ {
return $this->scope; return $this->scope;
} }

View File

@ -632,4 +632,37 @@ class ActivityType
{ {
$this->socialDataLabel = $socialDataLabel; $this->socialDataLabel = $socialDataLabel;
} }
public function isVisible(string $field): bool
{
$property = $field.'Visible';
if (!property_exists($this, $property)) {
throw new \InvalidArgumentException('Field "'.$field.'" not found');
}
return self::FIELD_INVISIBLE !== $this->$property;
}
public function isRequired(string $field): bool
{
$property = $field.'Visible';
if (!property_exists($this, $property)) {
throw new \InvalidArgumentException('Field "'.$field.'" not found');
}
return self::FIELD_REQUIRED === $this->$property;
}
public function getLabel(string $field): ?string
{
$property = $field.'Label';
if (!property_exists($this, $property)) {
throw new \InvalidArgumentException('Field "'.$field.'" not found');
}
return $this->$property;
}
} }

View File

@ -1,19 +0,0 @@
<?php
namespace Chill\ActivityBundle\Form;
use Chill\ActivityBundle\Form\Type\TranslatableActivityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
class ActivitySelectTypeType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('type', TranslatableActivityType::class, array(
'placeholder' => 'Choose a type',
'active_only' => true,
'mapped' => false,
));
}
}

View File

@ -2,8 +2,16 @@
namespace Chill\ActivityBundle\Form; namespace Chill\ActivityBundle\Form;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Entity\ActivityPresence;
use Chill\ActivityBundle\Entity\ActivityReason;
use Chill\MainBundle\Form\Type\CommentType; use Chill\MainBundle\Form\Type\CommentType;
use Chill\PersonBundle\Entity\Person;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Doctrine\ORM\EntityRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
@ -15,51 +23,33 @@ use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTra
use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents; use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Chill\ActivityBundle\Form\Type\TranslatableActivityType;
use Chill\ActivityBundle\Form\Type\TranslatableActivityReason;
use Chill\MainBundle\Form\Type\UserPickerType; use Chill\MainBundle\Form\Type\UserPickerType;
use Chill\MainBundle\Form\Type\ScopePickerType; use Chill\MainBundle\Form\Type\ScopePickerType;
use Chill\MainBundle\Form\Type\ChillDateType; use Chill\MainBundle\Form\Type\ChillDateType;
class ActivityType extends AbstractType class ActivityType extends AbstractType
{ {
/** protected User $user;
* the user running this form
*
* @var User
*/
protected $user;
/**
*
* @var AuthorizationHelper
*/
protected AuthorizationHelper $authorizationHelper; protected AuthorizationHelper $authorizationHelper;
/** protected ObjectManager $om;
*
* @var ObjectManager
*/
protected $om;
/** protected TranslatableStringHelper $translatableStringHelper;
*
* @var TranslatableStringHelper
*/
protected $translatableStringHelper;
protected $timeChoices; protected array $timeChoices;
public function __construct( public function __construct (
TokenStorageInterface $tokenStorage, TokenStorageInterface $tokenStorage,
AuthorizationHelper $authorizationHelper, ObjectManager $om, AuthorizationHelper $authorizationHelper,
TranslatableStringHelper $translatableStringHelper, ObjectManager $om,
array $timeChoices TranslatableStringHelper $translatableStringHelper,
) array $timeChoices
{ ) {
if (!$tokenStorage->getToken()->getUser() instanceof User) { if (!$tokenStorage->getToken()->getUser() instanceof User) {
throw new \RuntimeException("you should have a valid user"); throw new \RuntimeException("you should have a valid user");
} }
$this->user = $tokenStorage->getToken()->getUser(); $this->user = $tokenStorage->getToken()->getUser();
$this->authorizationHelper = $authorizationHelper; $this->authorizationHelper = $authorizationHelper;
$this->om = $om; $this->om = $om;
@ -67,121 +57,219 @@ class ActivityType extends AbstractType
$this->timeChoices = $timeChoices; $this->timeChoices = $timeChoices;
} }
/** public function buildForm(FormBuilderInterface $builder, array $options): void
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{ {
// handle times choices // handle times choices
$timeChoices = array(); $timeChoices = [];
foreach ($this->timeChoices as $e) { foreach ($this->timeChoices as $e) {
$timeChoices[$e['label']] = $e['seconds']; $timeChoices[$e['label']] = $e['seconds'];
}; }
$durationTimeTransformer = new DateTimeToTimestampTransformer('GMT', 'GMT'); $durationTimeTransformer = new DateTimeToTimestampTransformer('GMT', 'GMT');
$durationTimeOptions = array( $durationTimeOptions = [
'choices' => $timeChoices, 'choices' => $timeChoices,
'placeholder' => 'Choose the duration', 'placeholder' => 'Choose the duration',
); ];
$builder /** @var \Chill\ActivityBundle\Entity\ActivityType $activityType */
->add('date', ChillDateType::class, array( $activityType = $options['activityType'];
'required' => true
)) if (!$activityType->isActive()) {
->add('durationTime', ChoiceType::class, $durationTimeOptions) throw new \InvalidArgumentException('Activity type must be active');
->add('attendee', ChoiceType::class, array( }
'expanded' => true,
'required' => false, $builder->add('scope', ScopePickerType::class, [
'choices' => array( 'center' => $options['center'],
'present' => true, 'role' => $options['role']
'not present' => false ]);
)
)) if ($activityType->isVisible('date')) {
->add('user', UserPickerType::class, [ $builder->add('date', ChillDateType::class, [
'label' => $activityType->getLabel('date'),
'required' => $activityType->isRequired('date'),
]);
}
if ($activityType->isVisible('durationTime')) {
$durationTimeOptions['label'] = $activityType->getLabel('durationTime');
$durationTimeOptions['required'] = $activityType->isRequired('durationTime');
$builder->add('durationTime', ChoiceType::class, $durationTimeOptions);
}
if ($activityType->isVisible('travelTime')) {
$durationTimeOptions['label'] = $activityType->getLabel('travelTime');
$durationTimeOptions['required'] = $activityType->isRequired('travelTime');
$builder->add('travelTime', ChoiceType::class, $durationTimeOptions);
}
if ($activityType->isVisible('travelTime')) {
$builder->add('attendee', EntityType::class, [
'label' => $activityType->getLabel('attendee'),
'required' => $activityType->isRequired('attendee'),
'class' => ActivityPresence::class,
'choice_label' => function (ActivityPresence $activityPresence) {
return $this->translatableStringHelper->localize($activityPresence->getName());
},
'query_builder' => function (EntityRepository $er) {
return $er->createQueryBuilder('a')
->where('a.active = true');
},
]);
}
if ($activityType->isVisible('user')) {
$builder->add('user', UserPickerType::class, [
'label' => $activityType->getLabel('user'),
'required' => $activityType->isRequired('user'),
'center' => $options['center'], 'center' => $options['center'],
'role' => $options['role'] 'role' => $options['role']
]) ]);
->add('scope', ScopePickerType::class, [ }
'center' => $options['center'],
'role' => $options['role'] if ($activityType->isVisible('reasons')) {
]) $builder->add('reasons', EntityType::class, [
->add('reasons', TranslatableActivityReason::class, array( 'label' => $activityType->getLabel('reasons'),
'required' => $activityType->isRequired('reasons'),
'class' => ActivityReason::class,
'choice_label' => function (ActivityReason $activityReason) {
return $this->translatableStringHelper->localize($activityReason->getName());
},
'query_builder' => function (EntityRepository $er) {
return $er->createQueryBuilder('a')
->where('a.active = true');
},
]);
}
if ($activityType->isVisible('comment')) {
$builder->add('comment', CommentType::class, [
'label' => $activityType->getLabel('comment'),
'required' => $activityType->isRequired('comment'),
]);
}
if ($activityType->isVisible('persons')) {
// TODO Faire évoluer le selecteur et la query
$builder->add('persons', EntityType::class, [
'label' => $activityType->getLabel('persons'),
'required' => $activityType->isRequired('persons'),
'class' => Person::class,
'multiple' => true, 'multiple' => true,
'required' => false, 'choice_label' => function (Person $person) {
)) return $person->getFullnameCanonical();
->add('comment', CommentType::class, [ },
'required' => false, 'query_builder' => function (EntityRepository $er) {
]) return $er->createQueryBuilder('a');
; },
]);
}
if ($activityType->isVisible('thirdParties')) {
$builder->add('thirdParties', EntityType::class, [
'label' => $activityType->getLabel('thirdParties'),
'required' => $activityType->isRequired('thirdParties'),
'class' => ThirdParty::class,
'choice_label' => function (ThirdParty $thirdParty) {
return $thirdParty->getName();
},
'query_builder' => function (EntityRepository $er) {
return $er->createQueryBuilder('a');
},
]);
}
// TODO : documents
//$documents
if ($activityType->isVisible('users')) {
$builder->add('users', EntityType::class, [
'label' => $activityType->getLabel('users'),
'required' => $activityType->isRequired('users'),
'class' => User::class,
'choice_label' => function (User $user) {
return $user->getUsername();
},
'query_builder' => function (EntityRepository $er) {
return $er->createQueryBuilder('u');
},
]);
}
if ($activityType->isVisible('emergency')) {
$builder->add('emergency', CheckboxType::class, [
'label' => $activityType->getLabel('emergency'),
'required' => $activityType->isRequired('emergency'),
]);
}
if ($activityType->isVisible('sentReceived')) {
$builder->add('sentReceived', ChoiceType::class, [
'label' => $activityType->getLabel('sentReceived'),
'required' => $activityType->isRequired('sentReceived'),
'choices' => [
'Sent' => Activity::SENTRECEIVED_SENT,
'Received' => Activity::SENTRECEIVED_RECEIVED,
],
]);
}
$builder->get('durationTime') $builder->get('durationTime')
->addModelTransformer($durationTimeTransformer); ->addModelTransformer($durationTimeTransformer);
$builder->get('durationTime') $builder->get('durationTime')
->addEventListener( ->addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $formEvent) use (
FormEvents::PRE_SET_DATA, $timeChoices,
function(FormEvent $formEvent) use ( $builder,
$timeChoices, $durationTimeTransformer,
$builder, $durationTimeOptions
$durationTimeTransformer, ) {
$durationTimeOptions // set the timezone to GMT, and fix the difference between current and GMT
) // the datetimetransformer will then handle timezone as GMT
{ $timezoneUTC = new \DateTimeZone('GMT');
// set the timezone to GMT, and fix the difference between current and GMT /* @var $data \DateTime */
// the datetimetransformer will then handle timezone as GMT $data = $formEvent->getData() === NULL ?
$timezoneUTC = new \DateTimeZone('GMT'); \DateTime::createFromFormat('U', 300) :
/* @var $data \DateTime */ $formEvent->getData();
$data = $formEvent->getData() === NULL ? $seconds = $data->getTimezone()->getOffset($data);
\DateTime::createFromFormat('U', 300) : $data->setTimeZone($timezoneUTC);
$formEvent->getData(); $data->add(new \DateInterval('PT'.$seconds.'S'));
$seconds = $data->getTimezone()->getOffset($data);
$data->setTimeZone($timezoneUTC);
$data->add(new \DateInterval('PT'.$seconds.'S'));
// test if the timestamp is in the choices. // test if the timestamp is in the choices.
// If not, recreate the field with the new timestamp // If not, recreate the field with the new timestamp
if (!in_array($data->getTimestamp(), $timeChoices)) { if (!in_array($data->getTimestamp(), $timeChoices)) {
// the data are not in the possible values. add them // the data are not in the possible values. add them
$timeChoices[$data->format('H:i')] = $data->getTimestamp(); $timeChoices[$data->format('H:i')] = $data->getTimestamp();
$form = $builder->create( $form = $builder->create('durationTime', ChoiceType::class, array_merge(
'durationTime', $durationTimeOptions,
ChoiceType::class, [
array_merge( 'choices' => $timeChoices,
$durationTimeOptions, 'auto_initialize' => false
array( ]
'choices' => $timeChoices, ));
'auto_initialize' => false $form->addModelTransformer($durationTimeTransformer);
) $formEvent->getForm()->getParent()->add($form->getForm());
)); }
$form->addModelTransformer($durationTimeTransformer); });
$formEvent->getForm()->getParent()->add($form->getForm());
}
});
} }
/** public function configureOptions(OptionsResolver $resolver): void
* @param OptionsResolverInterface $resolver
*/
public function configureOptions(OptionsResolver $resolver)
{ {
$resolver->setDefaults(array( $resolver->setDefaults([
'data_class' => 'Chill\ActivityBundle\Entity\Activity' 'data_class' => 'Chill\ActivityBundle\Entity\Activity'
)); ]);
$resolver $resolver
->setRequired(array('center', 'role')) ->setRequired(['center', 'role', 'activityType'])
->setAllowedTypes('center', 'Chill\MainBundle\Entity\Center') ->setAllowedTypes('center', 'Chill\MainBundle\Entity\Center')
->setAllowedTypes('role', 'Symfony\Component\Security\Core\Role\Role') ->setAllowedTypes('role', 'Symfony\Component\Security\Core\Role\Role')
; ->setAllowedTypes('activityType', \Chill\ActivityBundle\Entity\ActivityType::class)
;
} }
/** public function getBlockPrefix(): string
* @return string
*/
public function getBlockPrefix()
{ {
return 'chill_activitybundle_activity'; return 'chill_activitybundle_activity';
} }

View File

@ -29,12 +29,40 @@
{{ form_row(edit_form.scope) }} {{ form_row(edit_form.scope) }}
<h2>{{ 'Activity data'|trans }}</h2> <h2>{{ 'Activity data'|trans }}</h2>
{{ form_row(edit_form.date) }}
{{ form_row(edit_form.durationTime) }} {%- if form.date is defined -%}
{{ form_row(edit_form.type) }} {{ form_row(form.date) }}
{{ form_row(edit_form.attendee) }} {% endif %}
{{ form_row(edit_form.reasons) }} {%- if form.durationTime is defined -%}
{{ form_row(edit_form.comment) }} {{ form_row(form.durationTime) }}
{% endif %}
{%- if form.travelTime is defined -%}
{{ form_row(form.travelTime) }}
{% endif %}
{%- if form.attendee is defined -%}
{{ form_row(form.attendee) }}
{% endif %}
{%- if form.comment is defined -%}
{{ form_row(form.comment) }}
{% endif %}
{%- if form.reasons is defined -%}
{{ form_row(form.reasons) }}
{% endif %}
{%- if form.persons is defined -%}
{{ form_row(form.persons) }}
{% endif %}
{%- if form.thirdParties is defined -%}
{{ form_row(form.thirdParties) }}
{% endif %}
{%- if form.users is defined -%}
{{ form_row(form.users) }}
{% endif %}
{%- if form.emergency is defined -%}
{{ form_row(form.emergency) }}
{% endif %}
{%- if form.sentReceived is defined -%}
{{ form_row(form.sentReceived) }}
{% endif %}
{{ form_widget(edit_form) }} {{ form_widget(edit_form) }}
<ul class="record_actions sticky-form-buttons"> <ul class="record_actions sticky-form-buttons">

View File

@ -30,11 +30,39 @@
<h2 class="chill-red">{{ 'Activity data'|trans }}</h2> <h2 class="chill-red">{{ 'Activity data'|trans }}</h2>
{{ form_row(form.date) }} {%- if form.date is defined -%}
{{ form_row(form.durationTime) }} {{ form_row(form.date) }}
{{ form_row(form.attendee) }} {% endif %}
{{ form_row(form.reasons) }} {%- if form.durationTime is defined -%}
{{ form_row(form.comment) }} {{ form_row(form.durationTime) }}
{% endif %}
{%- if form.travelTime is defined -%}
{{ form_row(form.travelTime) }}
{% endif %}
{%- if form.attendee is defined -%}
{{ form_row(form.attendee) }}
{% endif %}
{%- if form.comment is defined -%}
{{ form_row(form.comment) }}
{% endif %}
{%- if form.reasons is defined -%}
{{ form_row(form.reasons) }}
{% endif %}
{%- if form.persons is defined -%}
{{ form_row(form.persons) }}
{% endif %}
{%- if form.thirdParties is defined -%}
{{ form_row(form.thirdParties) }}
{% endif %}
{%- if form.users is defined -%}
{{ form_row(form.users) }}
{% endif %}
{%- if form.emergency is defined -%}
{{ form_row(form.emergency) }}
{% endif %}
{%- if form.sentReceived is defined -%}
{{ form_row(form.sentReceived) }}
{% endif %}
<div class="grid-12 centered sticky-form-buttons"> <div class="grid-12 centered sticky-form-buttons">
<button class="sc-button green margin-10" type="submit"><i class="fa fa-save"></i> {{ 'Add a new activity'|trans }}</button> <button class="sc-button green margin-10" type="submit"><i class="fa fa-save"></i> {{ 'Add a new activity'|trans }}</button>

View File

@ -7,13 +7,14 @@
{% block personcontent %} {% block personcontent %}
<h2 class="chill-red">{{ "Activity creation"|trans }}</h2> <h2 class="chill-red">{{ "Activity creation"|trans }}</h2>
{{ form_start(form) }} {# TODO: refaire l'html css des tuilles #}
<div style="display:flex;justify-content:center;gap:12px;flex-wrap:wrap;">
{{ form_row(form.type) }} {% for activityType in activityTypes %}
<a href="{{ path('chill_activity_activity_new', {'person_id': person.id, 'activityType_id': activityType.id }) }}">
<div class="grid-12 centered sticky-form-buttons"> <div style="width:200px;height:200px;border:1px dotted red;display:flex;justify-content:center;align-items:center;align-content:center;">
<button class="sc-button green margin-10" type="submit"><i class="fa fa-save"></i> {{ 'Next Step'|trans }}</button> {{ activityType.name|localize_translatable_string }}
</div>
</a>
{% endfor %}
</div> </div>
{{ form_end(form) }}
{% endblock %} {% endblock %}