diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index 94e4cc85f..4ae8fe7d0 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -23,10 +23,12 @@ namespace Chill\ActivityBundle\Controller; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Privacy\PrivacyEvent; use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\Form\Form; use Symfony\Component\HttpFoundation\Request; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Form\Extension\Core\Type\SubmitType; @@ -61,46 +63,57 @@ class ActivityController extends AbstractController /** * Lists all Activity entities. */ - public function listAction($person_id): Response + public function listAction(Request $request): Response { $em = $this->getDoctrine()->getManager(); - $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); + $view = null; - if ($person === NULL) { - throw $this->createNotFoundException('Person not found'); + [$person, $accompanyingPeriod] = $this->getEntity($request); + + if ($person instanceof Person) { + $reachableScopes = $this->authorizationHelper + ->getReachableCircles($this->getUser(), new Role('CHILL_ACTIVITY_SEE'), + $person->getCenter()); + + $activities = $em->getRepository('ChillActivityBundle:Activity')->findBy( + ['person' => $person, 'scope' => $reachableScopes], + ['date' => 'DESC'], + ); + + $event = new PrivacyEvent($person, array( + 'element_class' => Activity::class, + 'action' => 'list' + )); + $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); + + $view = 'ChillActivityBundle:Activity:listPerson.html.twig'; + } elseif ($accompanyingPeriod instanceof AccompanyingPeriod) { + $activities = $em->getRepository('ChillActivityBundle:Activity')->findBy( + ['accompanyingPeriod' => $accompanyingPeriod], + ['date' => 'DESC'], + ); + + $view = 'ChillActivityBundle:Activity:listAccompanyingCourse.html.twig'; } - $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); - - $reachableScopes = $this->authorizationHelper - ->getReachableCircles($this->getUser(), new Role('CHILL_ACTIVITY_SEE'), - $person->getCenter()); - - $activities = $em->getRepository('ChillActivityBundle:Activity') - ->findBy( - array('person' => $person, 'scope' => $reachableScopes), - array('date' => 'DESC') - ); - - $event = new PrivacyEvent($person, array( - 'element_class' => Activity::class, - 'action' => 'list' - )); - $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); - - return $this->render('ChillActivityBundle:Activity:list.html.twig', array( + return $this->render($view, array( 'activities' => $activities, - 'person' => $person + 'person' => $person, + 'accompanyingCourse' => $accompanyingPeriod, )); } - public function selectTypeAction(int $person_id): Response + public function selectTypeAction(Request $request): Response { $em = $this->getDoctrine()->getManager(); - $person = $em->getRepository(Person::class)->find($person_id); + $view = null; - if ($person === NULL) { - throw $this->createNotFoundException('Person not found'); + [$person, $accompanyingPeriod] = $this->getEntity($request); + + if ($accompanyingPeriod instanceof AccompanyingPeriod) { + $view = 'ChillActivityBundle:Activity:selectTypeAccompanyingCourse.html.twig'; + } elseif ($person instanceof Person) { + $view = 'ChillActivityBundle:Activity:selectTypePerson.html.twig'; } $data = []; @@ -118,19 +131,27 @@ class ActivityController extends AbstractController ]; } - return $this->render('ChillActivityBundle:Activity:selectType.html.twig', [ - 'person' => $person, + if ($view === null) { + throw $this->createNotFoundException('Template not found'); + } + + return $this->render($view, [ + 'person' => $person, + 'accompanyingCourse' => $accompanyingPeriod, 'data' => $data, ]); } - public function newAction($person_id, Request $request): Response + public function newAction(Request $request): Response { $em = $this->getDoctrine()->getManager(); - $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); - if (null === $person) { - throw $this->createNotFoundException('Person not found'); + [$person, $accompanyingPeriod] = $this->getEntity($request); + + if ($accompanyingPeriod instanceof AccompanyingPeriod) { + $view = 'ChillActivityBundle:Activity:newAccompanyingCourse.html.twig'; + } elseif ($person instanceof Person) { + $view = 'ChillActivityBundle:Activity:newPerson.html.twig'; } $activityType_id = $request->get('activityType_id', 0); @@ -139,20 +160,27 @@ class ActivityController extends AbstractController if (!$activityType instanceof \Chill\ActivityBundle\Entity\ActivityType || !$activityType->isActive()) { - return $this->redirectToRoute('chill_activity_activity_select_type', [ - 'person_id' => $person->getId(), - ]); - } - $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); + $params = $this->buildParamsToUrl($person, $accompanyingPeriod); + return $this->redirectToRoute('chill_activity_activity_select_type', $params); + } $entity = new Activity(); $entity->setUser($this->getUser()); - $entity->setPerson($person); + + if ($person instanceof Person) { + $entity->setPerson($person); + } + + if ($accompanyingPeriod instanceof AccompanyingPeriod) { + $entity->setAccompanyingPeriod($accompanyingPeriod); + } + $entity->setType($activityType); $entity->setDate(new \DateTime('now')); - $this->denyAccessUnlessGranted('CHILL_ACTIVITY_CREATE', $entity); + // TODO revoir le Voter de Activity pour tenir compte qu'une activité peut appartenir a une période + // $this->denyAccessUnlessGranted('CHILL_ACTIVITY_CREATE', $entity); $form = $this->createForm(ActivityType::class, $entity, [ 'center' => $entity->getCenter(), @@ -166,49 +194,64 @@ class ActivityController extends AbstractController $this->addFlash('success', $this->get('translator')->trans('Success : activity created!')); - return $this->redirectToRoute('chill_activity_activity_show', [ - 'id' => $entity->getId(), - 'person_id' => $person_id - ]); + $params = $this->buildParamsToUrl($person, $accompanyingPeriod); + $params['id'] = $entity->getId(); + + return $this->redirectToRoute('chill_activity_activity_show', $params); } - return $this->render('ChillActivityBundle:Activity:new.html.twig', array( + if ($view === null) { + throw $this->createNotFoundException('Template not found'); + } + + return $this->render($view, [ 'person' => $person, + 'accompanyingCourse' => $accompanyingPeriod, 'entity' => $entity, - 'form' => $form->createView(), - )); + 'form' => $form->createView(), + ]); } - public function showAction($person_id, $id): Response + public function showAction(Request $request, $id): Response { $em = $this->getDoctrine()->getManager(); - $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); - if (!$person) { - throw $this->createNotFoundException('person not found'); + [$person, $accompanyingPeriod] = $this->getEntity($request); + + if ($accompanyingPeriod instanceof AccompanyingPeriod) { + $view = 'ChillActivityBundle:Activity:showAccompanyingCourse.html.twig'; + } elseif ($person instanceof Person) { + $view = 'ChillActivityBundle:Activity:showPerson.html.twig'; } - $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); - $entity = $em->getRepository('ChillActivityBundle:Activity')->find($id); if (!$entity) { throw $this->createNotFoundException('Unable to find Activity entity.'); } - $this->denyAccessUnlessGranted('CHILL_ACTIVITY_SEE', $entity); + // TODO revoir le Voter de Activity pour tenir compte qu'une activité peut appartenir a une période + // $this->denyAccessUnlessGranted('CHILL_ACTIVITY_SEE', $entity); - $deleteForm = $this->createDeleteForm($id, $person); + $deleteForm = $this->createDeleteForm($id, $person, $accompanyingPeriod); + // TODO + /* $event = new PrivacyEvent($person, array( 'element_class' => Activity::class, 'element_id' => $entity->getId(), 'action' => 'show' )); $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); + */ - return $this->render('ChillActivityBundle:Activity:show.html.twig', array( + if ($view === null) { + throw $this->createNotFoundException('Template not found'); + } + + return $this->render($view, array( 'person' => $person, + 'accompanyingCourse' => $accompanyingPeriod, 'entity' => $entity, 'delete_form' => $deleteForm->createView(), )); @@ -218,24 +261,26 @@ class ActivityController extends AbstractController * Displays a form to edit an existing Activity entity. * */ - public function editAction($person_id, $id, Request $request): Response + public function editAction($id, Request $request): Response { $em = $this->getDoctrine()->getManager(); - $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); - if (!$person) { - throw $this->createNotFoundException('person not found'); + [$person, $accompanyingPeriod] = $this->getEntity($request); + + if ($accompanyingPeriod instanceof AccompanyingPeriod) { + $view = 'ChillActivityBundle:Activity:editAccompanyingCourse.html.twig'; + } elseif ($person instanceof Person) { + $view = 'ChillActivityBundle:Activity:editPerson.html.twig'; } - $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); - $entity = $em->getRepository('ChillActivityBundle:Activity')->find($id); if (!$entity) { throw $this->createNotFoundException('Unable to find Activity entity.'); } - $this->denyAccessUnlessGranted('CHILL_ACTIVITY_UPDATE', $entity); + // TODO + // $this->denyAccessUnlessGranted('CHILL_ACTIVITY_UPDATE', $entity); $form = $this->createForm(ActivityType::class, $entity, [ 'center' => $entity->getCenter(), @@ -249,23 +294,29 @@ class ActivityController extends AbstractController $this->addFlash('success', $this->get('translator')->trans('Success : activity updated!')); - return $this->redirect($this->generateUrl('chill_activity_activity_show', array('id' => $id, 'person_id' => $person_id))); + $params = $this->buildParamsToUrl($person, $accompanyingPeriod); + $params['id'] = $id; + return $this->redirectToRoute('chill_activity_activity_show', $params); } - $deleteForm = $this->createDeleteForm($id, $person); + $deleteForm = $this->createDeleteForm($id, $person, $accompanyingPeriod); + /* + * TODO $event = new PrivacyEvent($person, array( 'element_class' => Activity::class, 'element_id' => $entity->getId(), 'action' => 'edit' )); $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); + */ - return $this->render('ChillActivityBundle:Activity:edit.html.twig', array( + return $this->render($view, array( 'entity' => $entity, 'edit_form' => $form->createView(), 'delete_form' => $deleteForm->createView(), - 'person' => $person + 'person' => $person, + 'accompanyingCourse' => $accompanyingPeriod, )); } @@ -273,22 +324,29 @@ class ActivityController extends AbstractController * Deletes a Activity entity. * */ - public function deleteAction(Request $request, $id, $person_id) + public function deleteAction(Request $request, $id) { $em = $this->getDoctrine()->getManager(); + [$person, $accompanyingPeriod] = $this->getEntity($request); + + if ($accompanyingPeriod instanceof AccompanyingPeriod) { + $view = 'ChillActivityBundle:Activity:confirm_deleteAccompanyingCourse.html.twig'; + } elseif ($person instanceof Person) { + $view = 'ChillActivityBundle:Activity:confirm_deletePerson.html.twig'; + } + /* @var $activity Activity */ - $activity = $em->getRepository('ChillActivityBundle:Activity') - ->find($id); - $person = $activity->getPerson(); + $activity = $em->getRepository('ChillActivityBundle:Activity')->find($id); if (!$activity) { throw $this->createNotFoundException('Unable to find Activity entity.'); } - $this->denyAccessUnlessGranted('CHILL_ACTIVITY_DELETE', $activity); + // TODO + // $this->denyAccessUnlessGranted('CHILL_ACTIVITY_DELETE', $activity); - $form = $this->createDeleteForm($id, $person); + $form = $this->createDeleteForm($id, $person, $accompanyingPeriod); if ($request->getMethod() === Request::METHOD_DELETE) { $form->handleRequest($request); @@ -298,14 +356,14 @@ class ActivityController extends AbstractController $this->logger->notice("An activity has been removed", array( 'by_user' => $this->getUser()->getUsername(), 'activity_id' => $activity->getId(), - 'person_id' => $activity->getPerson()->getId(), + 'person_id' => $activity->getPerson() ? $activity->getPerson()->getId() : null, 'comment' => $activity->getComment()->getComment(), - 'scope_id' => $activity->getScope()->getId(), + 'scope_id' => $activity->getScope() ? $activity->getScope()->getId() : null, 'reasons_ids' => $activity->getReasons() ->map(function ($ar) { return $ar->getId(); }) ->toArray(), 'type_id' => $activity->getType()->getId(), - 'duration' => $activity->getDurationTime()->format('U'), + 'duration' => $activity->getDurationTime() ? $activity->getDurationTime()->format('U') : null, 'date' => $activity->getDate()->format('Y-m-d'), 'attendee' => $activity->getAttendee() )); @@ -316,37 +374,82 @@ class ActivityController extends AbstractController $this->addFlash('success', $this->get('translator') ->trans("The activity has been successfully removed.")); - return $this->redirect($this->generateUrl( - 'chill_activity_activity_list', array( - 'person_id' => $person_id - ))); + $params = $this->buildParamsToUrl($person, $accompanyingPeriod); + return $this->redirectToRoute('chill_activity_activity_list', $params); } } - return $this->render('ChillActivityBundle:Activity:confirm_delete.html.twig', array( + return $this->render($view, array( 'activity' => $activity, - 'delete_form' => $form->createView() + 'delete_form' => $form->createView(), + 'person' => $person, + 'accompanyingCourse' => $accompanyingPeriod, )); - - } /** * Creates a form to delete a Activity entity by id. - * - * @param mixed $id The entity id - * - * @return \Symfony\Component\Form\Form The form */ - private function createDeleteForm($id, $person) + private function createDeleteForm(int $id, ?Person $person, ?AccompanyingPeriod $accompanyingPeriod): Form { + $params = $this->buildParamsToUrl($person, $accompanyingPeriod); + $params['id'] = $id; + return $this->createFormBuilder() - ->setAction($this->generateUrl( - 'chill_activity_activity_delete', - array('id' => $id, 'person_id' => $person->getId()))) + ->setAction($this->generateUrl('chill_activity_activity_delete', $params)) ->setMethod('DELETE') ->add('submit', SubmitType::class, array('label' => 'Delete')) ->getForm() ; } + + private function getEntity(Request $request): array + { + $em = $this->getDoctrine()->getManager(); + $person = $accompanyingPeriod = null; + + if ($request->query->has('person_id')) { + $person_id = $request->get('person_id'); + $person = $em->getRepository(Person::class)->find($person_id); + + if ($person === null) { + throw $this->createNotFoundException('Person not found'); + } + + $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); + } elseif ($request->query->has('accompanying_period_id')) { + $accompanying_period_id = $request->get('accompanying_period_id'); + $accompanyingPeriod = $em->getRepository(AccompanyingPeriod::class)->find($accompanying_period_id); + + if ($accompanyingPeriod === null) { + throw $this->createNotFoundException('Accompanying Period not found'); + } + + // TODO Add permission + // $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); + } else { + throw $this->createNotFoundException("Person or Accompanying Period not found"); + } + + return [ + $person, $accompanyingPeriod + ]; + } + + private function buildParamsToUrl( + ?Person $person, + ?AccompanyingPeriod $accompanyingPeriod + ): array { + $params = []; + + if ($person) { + $params['person_id'] = $person->getId(); + } + + if ($accompanyingPeriod) { + $params['accompanying_period_id'] = $accompanyingPeriod->getId(); + } + + return $params; + } } diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index d66737ff6..0b35d961e 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -22,6 +22,7 @@ namespace Chill\ActivityBundle\Entity; use Chill\DocStoreBundle\Entity\Document; use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\ThirdPartyBundle\Entity\ThirdParty; use Doctrine\ORM\Mapping as ORM; use Chill\MainBundle\Entity\Scope; @@ -41,11 +42,16 @@ use Chill\MainBundle\Validator\Constraints\Entity\UserCircleConsistency; * @ORM\Entity() * @ORM\Table(name="activity") * @ORM\HasLifecycleCallbacks() + */ + +/* + * TODO : revoir * @UserCircleConsistency( * "CHILL_ACTIVITY_SEE_DETAILS", * getUserFunction="getUser", * path="scope") */ + class Activity implements HasCenterInterface, HasScopeInterface { const SENTRECEIVED_SENT = 'sent'; @@ -101,7 +107,12 @@ class Activity implements HasCenterInterface, HasScopeInterface /** * @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\Person") */ - private Person $person; + private ?Person $person = null; + + /** + * @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod") + */ + private ?AccompanyingPeriod $accompanyingPeriod = null; /** * @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="comment_") @@ -261,25 +272,41 @@ class Activity implements HasCenterInterface, HasScopeInterface return $this->scope; } - public function setPerson(Person $person): self + public function setPerson(?Person $person): self { $this->person = $person; return $this; } - public function getPerson(): Person + public function getPerson(): ?Person { return $this->person; } + public function getAccompanyingPeriod(): ?AccompanyingPeriod + { + return $this->accompanyingPeriod; + } + + public function setAccompanyingPeriod(?AccompanyingPeriod $accompanyingPeriod): self + { + $this->accompanyingPeriod = $accompanyingPeriod; + + return $this; + } + /** * get the center * center is extracted from person */ - public function getCenter(): Center + public function getCenter(): ?Center { - return $this->person->getCenter(); + if ($this->person instanceof Person) { + return $this->person->getCenter(); + } + + return null; } public function getComment(): CommentEmbeddable @@ -422,4 +449,3 @@ class Activity implements HasCenterInterface, HasScopeInterface return $this; } } - diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityType.php b/src/Bundle/ChillActivityBundle/Form/ActivityType.php index c4f918396..99279b099 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityType.php @@ -82,10 +82,13 @@ class ActivityType extends AbstractType throw new \InvalidArgumentException('Activity type must be active'); } - $builder->add('scope', ScopePickerType::class, [ - 'center' => $options['center'], - 'role' => $options['role'] - ]); + // TODO revoir la gestion des center au niveau du form des activité. + if ($options['center']) { + $builder->add('scope', ScopePickerType::class, [ + 'center' => $options['center'], + 'role' => $options['role'] + ]); + } if ($activityType->isVisible('date')) { $builder->add('date', ChillDateType::class, [ @@ -108,7 +111,7 @@ class ActivityType extends AbstractType $builder->add('travelTime', ChoiceType::class, $durationTimeOptions); } - if ($activityType->isVisible('travelTime')) { + if ($activityType->isVisible('attendee')) { $builder->add('attendee', EntityType::class, [ 'label' => $activityType->getLabel('attendee'), 'required' => $activityType->isRequired('attendee'), @@ -123,7 +126,7 @@ class ActivityType extends AbstractType ]); } - if ($activityType->isVisible('user')) { + if ($activityType->isVisible('user') && $options['center']) { $builder->add('user', UserPickerType::class, [ 'label' => $activityType->getLabel('user'), 'required' => $activityType->isRequired('user'), @@ -229,6 +232,10 @@ class ActivityType extends AbstractType } foreach (['durationTime', 'travelTime'] as $fieldName) { + if (!$activityType->isVisible($fieldName)) { + continue; + } + $builder->get($fieldName) ->addModelTransformer($durationTimeTransformer); @@ -279,7 +286,7 @@ class ActivityType extends AbstractType $resolver ->setRequired(['center', 'role', 'activityType']) - ->setAllowedTypes('center', 'Chill\MainBundle\Entity\Center') + ->setAllowedTypes('center', ['null', 'Chill\MainBundle\Entity\Center']) ->setAllowedTypes('role', 'Symfony\Component\Security\Core\Role\Role') ->setAllowedTypes('activityType', \Chill\ActivityBundle\Entity\ActivityType::class) ; diff --git a/src/Bundle/ChillActivityBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillActivityBundle/Menu/AccompanyingCourseMenuBuilder.php new file mode 100644 index 000000000..ba0672bb0 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Menu/AccompanyingCourseMenuBuilder.php @@ -0,0 +1,48 @@ +translator = $translator; + $this->authorizationHelper = $authorizationHelper; + $this->tokenStorage = $tokenStorage; + } + public static function getMenuIds(): array + { + return ['accompanyingCourse']; + } + + public function buildMenu($menuId, MenuItem $menu, array $parameters) + { + $period = $parameters['accompanyingCourse']; + + $menu->addChild($this->translator->trans('Add a new activity'), [ + 'route' => 'chill_activity_activity_select_type', + 'routeParameters' => [ + 'accompanying_period_id' => $period->getId() + ]]) + ->setExtras(['order' => 40]); + } +} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/confirm_deleteAccompanyingCourse.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/confirm_deleteAccompanyingCourse.html.twig new file mode 100644 index 000000000..fbdf45c23 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/confirm_deleteAccompanyingCourse.html.twig @@ -0,0 +1,16 @@ +{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %} + +{% set activeRouteKey = 'chill_activity_activity_list' %} + +{% block title 'Remove activity'|trans %} + +{% block content %} + {{ include('@ChillMain/Util/confirmation_template.html.twig', + { + 'title' : 'Remove activity'|trans, + 'confirm_question' : 'Are you sure you want to remove the activity about "%name%" ?'|trans({ '%name%' : accompanyingCourse.id } ), + 'cancel_route' : 'chill_activity_activity_list', + 'cancel_parameters' : { 'accompanying_course_id' : accompanyingCourse.id, 'id' : activity.id }, + 'form' : delete_form + } ) }} +{% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/confirm_delete.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/confirm_deletePerson.html.twig similarity index 99% rename from src/Bundle/ChillActivityBundle/Resources/views/Activity/confirm_delete.html.twig rename to src/Bundle/ChillActivityBundle/Resources/views/Activity/confirm_deletePerson.html.twig index 5cd8f15a0..2d8e2affc 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/confirm_delete.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/confirm_deletePerson.html.twig @@ -6,7 +6,6 @@ {% block title 'Remove activity'|trans %} {% block personcontent %} - {{ include('@ChillMain/Util/confirmation_template.html.twig', { 'title' : 'Remove activity'|trans, @@ -15,5 +14,4 @@ 'cancel_parameters' : { 'person_id' : activity.person.id, 'id' : activity.id }, 'form' : delete_form } ) }} - {% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig index fb84ae725..0625174ac 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig @@ -1,95 +1,75 @@ -{# - * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . -#} -{% extends "@ChillPerson/layout.html.twig" %} +

{{ "Update activity"|trans }}

-{% set activeRouteKey = 'chill_activity_activity_list' %} - -{% block title 'Update activity'|trans %} - -{% block personcontent %} -

{{ "Update activity"|trans }}

- - {{ form_start(edit_form) }} +{{ form_start(edit_form) }} +{%- if edit_form.user is defined -%} {{ form_row(edit_form.user) }} +{% endif %} + +{%- if edit_form.scope is defined -%} {{ form_row(edit_form.scope) }} +{% endif %} -

{{ 'Activity data'|trans }}

+

{{ 'Activity data'|trans }}

- {%- if form.date is defined -%} - {{ form_row(form.date) }} - {% endif %} - {%- if form.durationTime is defined -%} - {{ 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 %} - {%- if form.documents is defined -%} - {{ form_row(form.documents) }} - {% endif %} +{%- if form.date is defined -%} + {{ form_row(form.date) }} +{% endif %} +{%- if form.durationTime is defined -%} + {{ 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 %} +{%- if form.documents is defined -%} + {{ form_row(form.documents) }} +{% endif %} - {{ form_widget(edit_form) }} - - {{ form_end(edit_form) }} +{% set person_id = null %} +{% if entity.person %} + {% set person_id = entity.person.id %} +{% endif %} - {# {{ form(delete_form) }} #} -{% endblock %} +{% set accompanying_course_id = null %} +{% if accompanyingCourse %} + {% set accompanying_course_id = accompanyingCourse.id %} +{% endif %} -{% block js %} - - -{% endblock %} +{{ form_widget(edit_form) }} + +{{ form_end(edit_form) }} -{% block css %} - -{% endblock %} +{# {{ form(delete_form) }} #} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/editAccompanyingCourse.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/editAccompanyingCourse.html.twig new file mode 100644 index 000000000..b9a812b09 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/editAccompanyingCourse.html.twig @@ -0,0 +1,20 @@ +{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %} + +{% set activeRouteKey = 'chill_activity_activity_list' %} + +{% block title 'Update activity'|trans %} + +{% block content %} + {% include 'ChillActivityBundle:Activity:edit.html.twig' %} +{% endblock %} + +{% block js %} + + +{% endblock %} + +{% block css %} + +{% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/editPerson.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/editPerson.html.twig new file mode 100644 index 000000000..fc32dab49 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/editPerson.html.twig @@ -0,0 +1,36 @@ +{# + * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . +#} +{% extends "@ChillPerson/layout.html.twig" %} + +{% set activeRouteKey = 'chill_activity_activity_list' %} + +{% block title 'Update activity'|trans %} + +{% block personcontent %} + {% include 'ChillActivityBundle:Activity:edit.html.twig' %} +{% endblock %} + +{% block js %} + + +{% endblock %} + +{% block css %} + +{% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/list.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/list.html.twig index 94a9d9a82..de30d5366 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/list.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/list.html.twig @@ -1,87 +1,79 @@ -{# - * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . -#} -{% extends "@ChillPerson/layout.html.twig" %} +{% set person_id = null %} +{% if person %} + {% set person_id = person.id %} +{% endif %} -{% set activeRouteKey = 'chill_activity_activity_list' %} +{% set accompanying_course_id = null %} +{% if accompanyingCourse %} + {% set accompanying_course_id = accompanyingCourse.id %} +{% endif %} -{% block title %}{{ 'Activity list' |trans }}{% endblock title %} +

{{ 'Activity list' |trans }}

-{% block personcontent %} -

{{ 'Activity list' |trans }}

- - {% if activities|length == 0 %} -

- {{ "There isn't any activities."|trans }} - -

- {% else %} - - - - - - - - - - - - {% for activity in activities %} - - - - + + {% endfor %} + +
{{'Date' | trans }}{{'Duration Time' | trans }}{{'Reasons' | trans}}{{'Type' | trans}} 
{% if activity.date %}{{ activity.date|format_date('long') }}{% endif %}{{ activity.durationTime|date('H:i') }} - {% if activity.comment.comment is not empty %} - {{ activity.comment|chill_entity_render_box( { 'limit_lines': 3, 'metadata': false } ) }} +{% if activities|length == 0 %} +

+ {{ "There isn't any activities."|trans }} + +

+{% else %} + + + + + + + + + + + + {% for activity in activities %} + + + + + + - - - - {% endfor %} - -
{{'Date' | trans }}{{'Duration Time' | trans }}{{'Reasons' | trans}}{{'Type' | trans}} 
{% if activity.date %}{{ activity.date|format_date('long') }}{% endif %}{{ activity.durationTime|date('H:i') }} + {% if activity.comment.comment is not empty %} + {{ activity.comment|chill_entity_render_box( { 'limit_lines': 3, 'metadata': false } ) }} + {% endif %} + {%- if activity.reasons is empty -%} + {{ 'No reason associated'|trans }} + {%- else -%} + {% for r in activity.reasons %}{{ r|chill_entity_render_box }} {% endfor %} + {%- endif -%} + {{ activity.type.name | localize_translatable_string }} +
    +
  • + +
  • + {# TOOD + {% if is_granted('CHILL_ACTIVITY_UPDATE', activity) %} + #} +
  • + +
  • + {# TOOD {% endif %} - {%- if activity.reasons is empty -%} - {{ 'No reason associated'|trans }} - {%- else -%} - {% for r in activity.reasons %}{{ r|chill_entity_render_box }} {% endfor %} - {%- endif -%} -
{{ activity.type.name | localize_translatable_string }} -
    -
  • - -
  • - {% if is_granted('CHILL_ACTIVITY_UPDATE', activity) %} -
  • - -
  • - {% endif %} - {% if is_granted('CHILL_ACTIVITY_DELETE', activity) %} -
  • - -
  • - {% endif %} -
- {% endif %} + {% if is_granted('CHILL_ACTIVITY_DELETE', activity) %} + #} +
  • + +
  • + {# + {% endif %} + #} +
    +{% endif %} - -{% endblock %} + diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/listAccompanyingCourse.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/listAccompanyingCourse.html.twig new file mode 100644 index 000000000..7607ac79a --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/listAccompanyingCourse.html.twig @@ -0,0 +1,9 @@ +{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %} + +{% set activeRouteKey = 'chill_activity_activity_list' %} + +{% block title %}{{ 'Activity list' |trans }}{% endblock title %} + +{% block content %} + {% include 'ChillActivityBundle:Activity:list.html.twig' %} +{% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/listPerson.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/listPerson.html.twig new file mode 100644 index 000000000..db441ee69 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/listPerson.html.twig @@ -0,0 +1,25 @@ +{# + * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . +#} +{% extends "@ChillPerson/layout.html.twig" %} + +{% set activeRouteKey = 'chill_activity_activity_list' %} + +{% block title %}{{ 'Activity list' |trans }}{% endblock title %} + +{% block personcontent %} + {% include 'ChillActivityBundle:Activity:list.html.twig' %} +{% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig index 5323815fd..b166a4a9e 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig @@ -1,87 +1,57 @@ -{# - * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . -#} -{% extends "@ChillPerson/layout.html.twig" %} +

    {{ "Activity creation"|trans }}

    -{% set activeRouteKey = 'chill_activity_activity_new' %} - -{% block title 'Activity creation' |trans %} - -{% block personcontent %} -

    {{ "Activity creation"|trans }}

    - - {{ form_start(form) }} - {{ form_errors(form) }} +{{ form_start(form) }} +{{ form_errors(form) }} +{%- if form.user is defined -%} {{ form_row(form.user) }} +{% endif %} + +{%- if form.scope is defined -%} {{ form_row(form.scope) }} +{% endif %} -

    {{ 'Activity data'|trans }}

    +

    {{ 'Activity data'|trans }}

    - {%- if form.date is defined -%} - {{ form_row(form.date) }} - {% endif %} - {%- if form.durationTime is defined -%} - {{ 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 %} +{%- if form.date is defined -%} + {{ form_row(form.date) }} +{% endif %} +{%- if form.durationTime is defined -%} + {{ 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 %} - {%- if form.documents is defined -%} - {{ form_row(form.documents) }} - {% endif %} +{%- if form.documents is defined -%} + {{ form_row(form.documents) }} +{% endif %} -
    - -
    - {{ form_end(form) }} -{% endblock %} - -{% block js %} - - -{% endblock %} - -{% block css %} - -{% endblock %} +
    + +
    +{{ form_end(form) }} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/newAccompanyingCourse.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/newAccompanyingCourse.html.twig new file mode 100644 index 000000000..74152659f --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/newAccompanyingCourse.html.twig @@ -0,0 +1,20 @@ +{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %} + +{% set activeRouteKey = 'chill_activity_activity_new' %} + +{% block title 'Activity creation' |trans %} + +{% block content %} + {% include 'ChillActivityBundle:Activity:new.html.twig' %} +{% endblock %} + +{% block js %} + + +{% endblock %} + +{% block css %} + +{% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/newPerson.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/newPerson.html.twig new file mode 100644 index 000000000..9cb89d917 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/newPerson.html.twig @@ -0,0 +1,20 @@ +{% extends "@ChillPerson/layout.html.twig" %} + +{% set activeRouteKey = 'chill_activity_activity_new' %} + +{% block title 'Activity creation' |trans %} + +{% block personcontent %} + {% include 'ChillActivityBundle:Activity:new.html.twig' %} +{% endblock %} + +{% block js %} + + +{% endblock %} + +{% block css %} + +{% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectType.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectType.html.twig index dfd26bad1..76e3f25ad 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectType.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectType.html.twig @@ -1,24 +1,28 @@ -{% extends "@ChillPerson/layout.html.twig" %} +

    {{ "Activity creation"|trans }}

    -{% set activeRouteKey = 'chill_activity_activity_new' %} +{# TODO: refaire l'html css des tuilles #} -{% block title 'Activity creation'|trans %} +{% for row in data %} +

    {{ row.activityTypeCategory.name|localize_translatable_string }}

    +
    + {% for activityType in row.activityTypes %} -{% block personcontent %} -

    {{ "Activity creation"|trans }}

    + {% set person_id = null %} + {% if person %} + {% set person_id = person.id %} + {% endif %} - {# TODO: refaire l'html css des tuilles #} + {% set accompanying_course_id = null %} + {% if accompanyingCourse %} + {% set accompanying_course_id = accompanyingCourse.id %} + {% endif %} - {% for row in data %} -

    {{ row.activityTypeCategory.name|localize_translatable_string }}

    -
    - {% for activityType in row.activityTypes %} - -
    - {{ activityType.name|localize_translatable_string }} -
    -
    - {% endfor %} -
    - {% endfor %} -{% endblock %} + + +
    + {{ activityType.name|localize_translatable_string }} +
    +
    + {% endfor %} +
    +{% endfor %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectTypeAccompanyingCourse.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectTypeAccompanyingCourse.html.twig new file mode 100644 index 000000000..5e73db597 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectTypeAccompanyingCourse.html.twig @@ -0,0 +1,9 @@ +{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %} + +{% set activeRouteKey = 'chill_activity_activity_new' %} + +{% block title 'Activity creation'|trans %} + +{% block content %} + {% include 'ChillActivityBundle:Activity:selectType.html.twig' %} +{% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectTypePerson.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectTypePerson.html.twig new file mode 100644 index 000000000..cb31749fd --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectTypePerson.html.twig @@ -0,0 +1,9 @@ +{% extends "@ChillPerson/layout.html.twig" %} + +{% set activeRouteKey = 'chill_activity_activity_new' %} + +{% block title 'Activity creation'|trans %} + +{% block personcontent %} + {% include 'ChillActivityBundle:Activity:selectType.html.twig' %} +{% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig index 73e91e8c5..f0cb5928b 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig @@ -1,68 +1,77 @@ -{% extends "@ChillPerson/layout.html.twig" %} +

    {{ "Activity"|trans }}

    -{% set activeRouteKey = 'chill_activity_activity_list' %} +
    +
    {{ 'User'|trans }}
    +
    {{ entity.user }}
    -{% block title 'Activity'|trans %} - -{% import 'ChillActivityBundle:ActivityReason:macro.html.twig' as m %} - -{% block personcontent -%} -

    {{ "Activity"|trans }}

    - -
    -
    {{ 'User'|trans }}
    -
    {{ entity.user }}
    + {%- if entity.scope -%}
    {{ 'Scope'|trans }}
    {{ entity.scope.name|localize_translatable_string }}
    + {% endif %} -

    {{ 'Activity data'|trans }}

    +

    {{ 'Activity data'|trans }}

    + + {%- if entity.person is defined -%}
    {{ 'Person'|trans }}
    {{ entity.person }}
    + {% endif %} -
    {{ 'Date'|trans }}
    -
    {{ entity.date|format_date('long') }}
    -
    {{ 'Duration Time'|trans }}
    -
    {{ entity.durationTime|date('H:i') }}
    -
    {{ 'Type'|trans }}
    -
    {{ entity.type.name | localize_translatable_string }}
    +
    {{ 'Date'|trans }}
    +
    {{ entity.date|format_date('long') }}
    +
    {{ 'Duration Time'|trans }}
    +
    {{ entity.durationTime|date('H:i') }}
    +
    {{ 'Type'|trans }}
    +
    {{ entity.type.name | localize_translatable_string }}
    -
    {{ 'Attendee'|trans }}
    -
    {% if entity.attendee is not null %}{% if entity.attendee %}{{ 'present'|trans|capitalize }} {% else %} {{ 'not present'|trans|capitalize }}{% endif %}{% else %}{{ 'None'|trans|capitalize }}{% endif %}
    +
    {{ 'Attendee'|trans }}
    +
    {% if entity.attendee is not null %}{% if entity.attendee %}{{ 'present'|trans|capitalize }} {% else %} {{ 'not present'|trans|capitalize }}{% endif %}{% else %}{{ 'None'|trans|capitalize }}{% endif %}
    -
    {{ 'Reasons'|trans }}
    - {%- if entity.reasons is empty -%} -
    {{ 'No reason associated'|trans }}
    - {%- else -%} -
    {% for r in entity.reasons %}{{ r|chill_entity_render_box }} {% endfor %}
    - {%- endif -%} +
    {{ 'Reasons'|trans }}
    + {%- if entity.reasons is empty -%} +
    {{ 'No reason associated'|trans }}
    + {%- else -%} +
    {% for r in entity.reasons %}{{ r|chill_entity_render_box }} {% endfor %}
    + {%- endif -%} -
    {{ 'Comment'|trans }}
    - {%- if entity.comment is empty -%} -
    {{ 'No comment associated'|trans }}
    - {%- else -%} -
    {{ entity.comment|chill_entity_render_box }}
    - {%- endif -%} +
    {{ 'Comment'|trans }}
    + {%- if entity.comment is empty -%} +
    {{ 'No comment associated'|trans }}
    + {%- else -%} +
    {{ entity.comment|chill_entity_render_box }}
    + {%- endif -%} -
    +
    - diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/showAccompanyingCourse.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/showAccompanyingCourse.html.twig new file mode 100644 index 000000000..a55b318a7 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/showAccompanyingCourse.html.twig @@ -0,0 +1,11 @@ +{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %} + +{% set activeRouteKey = 'chill_activity_activity_list' %} + +{% block title 'Activity'|trans %} + +{% import 'ChillActivityBundle:ActivityReason:macro.html.twig' as m %} + +{% block content -%} + {% include 'ChillActivityBundle:Activity:show.html.twig' %} +{% endblock content %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/showPerson.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/showPerson.html.twig new file mode 100644 index 000000000..f7d641b75 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/showPerson.html.twig @@ -0,0 +1,11 @@ +{% extends "@ChillPerson/layout.html.twig" %} + +{% set activeRouteKey = 'chill_activity_activity_list' %} + +{% block title 'Activity'|trans %} + +{% import 'ChillActivityBundle:ActivityReason:macro.html.twig' as m %} + +{% block personcontent -%} + {% include 'ChillActivityBundle:Activity:show.html.twig' %} +{% endblock personcontent %} diff --git a/src/Bundle/ChillActivityBundle/config/routes/activity.yaml b/src/Bundle/ChillActivityBundle/config/routes/activity.yaml index 62459db5d..179de905b 100644 --- a/src/Bundle/ChillActivityBundle/config/routes/activity.yaml +++ b/src/Bundle/ChillActivityBundle/config/routes/activity.yaml @@ -1,26 +1,26 @@ chill_activity_activity_list: - path: /{_locale}/person/{person_id}/activity/ + path: /{_locale}/activity/ controller: Chill\ActivityBundle\Controller\ActivityController::listAction chill_activity_activity_show: - path: /{_locale}/person/{person_id}/activity/{id}/show + path: /{_locale}/activity/{id}/show controller: Chill\ActivityBundle\Controller\ActivityController::showAction chill_activity_activity_select_type: - path: /{_locale}/person/{person_id}/activity/select-type + path: /{_locale}/activity/select-type controller: Chill\ActivityBundle\Controller\ActivityController::selectTypeAction chill_activity_activity_new: - path: /{_locale}/person/{person_id}/activity/new + path: /{_locale}/activity/new controller: Chill\ActivityBundle\Controller\ActivityController::newAction methods: [POST, GET] chill_activity_activity_edit: - path: /{_locale}/person/{person_id}/activity/{id}/edit + path: /{_locale}/activity/{id}/edit controller: Chill\ActivityBundle\Controller\ActivityController::editAction methods: [GET, POST, PUT] chill_activity_activity_delete: - path: /{_locale}/person/{person_id}/activity/{id}/delete + path: /{_locale}/activity/{id}/delete controller: Chill\ActivityBundle\Controller\ActivityController::deleteAction methods: [GET, POST, DELETE] diff --git a/src/Bundle/ChillActivityBundle/config/services/menu.yaml b/src/Bundle/ChillActivityBundle/config/services/menu.yaml index 2a0434996..8e60d3b2e 100644 --- a/src/Bundle/ChillActivityBundle/config/services/menu.yaml +++ b/src/Bundle/ChillActivityBundle/config/services/menu.yaml @@ -6,3 +6,11 @@ services: $translator: '@Symfony\Component\Translation\TranslatorInterface' tags: - { name: 'chill.menu_builder' } + + Chill\ActivityBundle\Menu\AccompanyingCourseMenuBuilder: + arguments: + $tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface' + $authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper' + $translator: '@Symfony\Contracts\Translation\TranslatorInterface' + tags: + - { name: 'chill.menu_builder' } diff --git a/src/Bundle/ChillActivityBundle/migrations/Version20210520095626.php b/src/Bundle/ChillActivityBundle/migrations/Version20210520095626.php new file mode 100644 index 000000000..f5a0abda6 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/migrations/Version20210520095626.php @@ -0,0 +1,31 @@ +addSql('ALTER TABLE activity ADD accompanyingPeriod_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE activity ADD CONSTRAINT FK_AC74095AD7FA8EF0 FOREIGN KEY (accompanyingPeriod_id) REFERENCES chill_person_accompanying_period (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE activity DROP CONSTRAINT FK_AC74095AD7FA8EF0'); + $this->addSql('ALTER TABLE activity DROP accompanyingPeriod_id'); + } +}