diff --git a/Controller/ActivityController.php b/Controller/ActivityController.php index 9a24cb503..a312bd480 100644 --- a/Controller/ActivityController.php +++ b/Controller/ActivityController.php @@ -295,18 +295,19 @@ class ActivityController extends Controller $this->get('translator') ->trans('Success : activity updated!') ); -//die(); + return $this->redirect($this->generateUrl('chill_activity_activity_show', array('id' => $id, 'person_id' => $person_id))); } $this->get('session') ->getFlashBag() - ->add('danger', + ->add('error', $this->get('translator') - ->trans('The form is not valid. The activity has not been updated !') + ->trans('This form contains errors') ); return $this->render('ChillActivityBundle:Activity:edit.html.twig', array( + 'person' => $entity->getPerson(), 'entity' => $entity, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), diff --git a/Entity/Activity.php b/Entity/Activity.php index 954ae7e34..637438f85 100644 --- a/Entity/Activity.php +++ b/Entity/Activity.php @@ -28,9 +28,15 @@ use Chill\PersonBundle\Entity\Person; use Chill\MainBundle\Entity\HasCenterInterface; use Chill\MainBundle\Entity\HasScopeInterface; use Doctrine\Common\Collections\ArrayCollection; +use Chill\MainBundle\Validator\Constraints\Entity\UserCircleConsistency; /** * Activity + * @UserCircleConsistency( + * "CHILL_ACTIVITY_SEE_DETAILS", + * getUserFunction="getUser", + * path="scope" + * ) */ class Activity implements HasCenterInterface, HasScopeInterface { diff --git a/Form/ActivityType.php b/Form/ActivityType.php index 30f5d2e88..fd4514b56 100644 --- a/Form/ActivityType.php +++ b/Form/ActivityType.php @@ -5,7 +5,6 @@ namespace Chill\ActivityBundle\Form; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; -use Chill\MainBundle\Form\Type\AppendScopeChoiceTypeTrait; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Doctrine\Common\Persistence\ObjectManager; use Chill\MainBundle\Templating\TranslatableStringHelper; @@ -16,16 +15,15 @@ use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvents; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\TextareaType; -use Symfony\Component\Form\Extension\Core\Type\DateTimeType; -use Symfony\Component\Form\Extension\Core\Type\DateType; use Chill\ActivityBundle\Form\Type\TranslatableActivityType; use Chill\ActivityBundle\Form\Type\TranslatableActivityReason; +use Chill\MainBundle\Form\Type\UserPickerType; +use Chill\MainBundle\Form\Type\ScopePickerType; +use Chill\MainBundle\Form\Type\ChillDateType; class ActivityType extends AbstractType { - use AppendScopeChoiceTypeTrait; - /** * the user running this form * @@ -91,11 +89,9 @@ class ActivityType extends AbstractType ); $builder - ->add('date', DateType::class, array( - 'required' => true, - 'widget' => 'single_text', - 'format' => 'dd-MM-yyyy') - ) + ->add('date', ChillDateType::class, array( + 'required' => true + )) ->add('durationTime', ChoiceType::class, $durationTimeOptions) ->add('remark', TextareaType::class, array( 'required' => false, @@ -110,8 +106,14 @@ class ActivityType extends AbstractType 'not present' => false ) )) - ->add('user') - ->add('scope') + ->add('user', UserPickerType::class, [ + 'center' => $options['center'], + 'role' => $options['role'] + ]) + ->add('scope', ScopePickerType::class, [ + 'center' => $options['center'], + 'role' => $options['role'] + ]) ->add('reasons', TranslatableActivityReason::class, array( 'multiple' => true, 'required' => false @@ -122,10 +124,6 @@ class ActivityType extends AbstractType )) ; - $this->appendScopeChoices($builder, $options['role'], - $options['center'], $this->user, $this->authorizationHelper, - $this->translatableStringHelper, $this->om); - $builder->get('durationTime') ->addModelTransformer($durationTimeTransformer); @@ -181,7 +179,11 @@ class ActivityType extends AbstractType 'data_class' => 'Chill\ActivityBundle\Entity\Activity' )); - $this->appendScopeChoicesOptions($resolver); + $resolver + ->setRequired(array('center', 'role')) + ->setAllowedTypes('center', 'Chill\MainBundle\Entity\Center') + ->setAllowedTypes('role', 'Symfony\Component\Security\Core\Role\Role') + ; } /** diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 1546320c5..63620fb49 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -12,6 +12,7 @@ list_reasons: liste des sujets user_username: nom de l'utilisateur circle_name: nom du cercle Remark: Notes +No remarks: Aucune note Add a new activity: Ajouter une nouvelle activité Activity list: Liste des activités present: présent diff --git a/Resources/views/Activity/show.html.twig b/Resources/views/Activity/show.html.twig index 5f3b00b9f..8a9bb3afc 100644 --- a/Resources/views/Activity/show.html.twig +++ b/Resources/views/Activity/show.html.twig @@ -26,7 +26,7 @@
{{ entity.remark|nl2br }}{% endif %}
{{ entity.remark|nl2br }}{% endif %}