From 8a3871252583072e82012ee24b3c1533a2c9c378 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 9 Sep 2021 17:43:35 +0200 Subject: [PATCH 001/209] relation between task and accompanyingcourse created --- .../ChillTaskBundle/Entity/AbstractTask.php | 21 +++++++++- .../migrations/Version20210909153533.php | 38 +++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 src/Bundle/ChillTaskBundle/migrations/Version20210909153533.php diff --git a/src/Bundle/ChillTaskBundle/Entity/AbstractTask.php b/src/Bundle/ChillTaskBundle/Entity/AbstractTask.php index 73e98c0dd..649de0422 100644 --- a/src/Bundle/ChillTaskBundle/Entity/AbstractTask.php +++ b/src/Bundle/ChillTaskBundle/Entity/AbstractTask.php @@ -10,6 +10,7 @@ use Chill\MainBundle\Entity\HasScopeInterface; use Chill\MainBundle\Entity\HasCenterInterface; use Symfony\Component\Validator\Constraints as Assert; use Chill\MainBundle\Validator\Constraints\Entity\UserCircleConsistency; +use Chill\PersonBundle\Entity\AccompanyingPeriod; /** * AbstractTask @@ -67,9 +68,16 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface * @ORM\ManyToOne( * targetEntity="\Chill\PersonBundle\Entity\Person" * ) - * @Assert\NotNull() */ private $person; + + + /** + * @var AccompanyingPeriod + * @ORM\ManyToOne(targetEntity="\Chill\PersonBundle\Entity\AccompanyingPeriod") + */ + + private $course; /** * @@ -202,6 +210,11 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface return $this->person; } + public function getCourse(): ?AccompanyingPeriod + { + return $this->course; + } + public function getCircle(): ?Scope { return $this->circle; @@ -219,6 +232,12 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface return $this; } + public function setCourse(AccompanyingPeriod $course) + { + $this->course = $course; + return $this; + } + public function setCircle(Scope $circle) { $this->circle = $circle; diff --git a/src/Bundle/ChillTaskBundle/migrations/Version20210909153533.php b/src/Bundle/ChillTaskBundle/migrations/Version20210909153533.php new file mode 100644 index 000000000..e2f59621b --- /dev/null +++ b/src/Bundle/ChillTaskBundle/migrations/Version20210909153533.php @@ -0,0 +1,38 @@ +addSql('ALTER TABLE chill_task.recurring_task ADD course_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_task.recurring_task ADD CONSTRAINT FK_9F663B90591CC992 FOREIGN KEY (course_id) REFERENCES chill_person_accompanying_period (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE INDEX IDX_9F663B90591CC992 ON chill_task.recurring_task (course_id)'); + $this->addSql('ALTER TABLE chill_task.single_task ADD course_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_task.single_task ADD CONSTRAINT FK_194CB3D8591CC992 FOREIGN KEY (course_id) REFERENCES chill_person_accompanying_period (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE INDEX IDX_194CB3D8591CC992 ON chill_task.single_task (course_id)'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_task.recurring_task DROP CONSTRAINT FK_9F663B90591CC992'); + $this->addSql('ALTER TABLE chill_task.recurring_task DROP course_id'); + $this->addSql('ALTER TABLE chill_task.single_task DROP CONSTRAINT FK_194CB3D8591CC992'); + $this->addSql('ALTER TABLE chill_task.single_task DROP course_id'); + } +} From 27077c9d96f68b444b7807aa74f84fe3e8eb15d9 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 9 Sep 2021 18:21:41 +0200 Subject: [PATCH 002/209] adaptation of newTask() method in singleTaskController --- .../Controller/SingleTaskController.php | 64 +++++++++++++++---- 1 file changed, 51 insertions(+), 13 deletions(-) diff --git a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php index bc76dacd4..8c742c627 100644 --- a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php @@ -86,24 +86,52 @@ class SingleTaskController extends AbstractController ->setType('task_default') ; - if ($request->query->has('person_id')) { + if($request->query->has('person_id')){ + $entityType = 'person'; + } else if ($request->query->has('course_id')) { + $entityType = 'course'; + } else { + $entityType = null; + } + + if ($entityType !== null) { - $personId = $request->query->getInt('person_id', 0); // sf4 check: + $entityId = $request->query->getInt("{$entityType}_id", 0); // sf4 check: // prevent error: `Argument 2 passed to ::getInt() must be of the type int, null given` - if ($personId === null) { - return new Response("You must provide a person_id", Response::HTTP_BAD_REQUEST); + if ($entityId === null) { + return new Response("You must provide a {$entityType}_id", Response::HTTP_BAD_REQUEST); } - $person = $this->getDoctrine()->getManager() - ->getRepository(Person::class) - ->find($personId); + if($entityType === 'person') + { + $person = $this->getDoctrine()->getManager() + ->getRepository(Person::class) + ->find($entityId); - if ($person === null) { - $this->createNotFoundException("Invalid person id"); + if ($person === null) { + $this->createNotFoundException("Invalid person id"); + } + + $task->setPerson($person); } - $task->setPerson($person); + if($entityType === 'course') + { + + $course = $this->getDoctrine()->getManager() + ->getRepository(AccompanyingPeriod::class) + ->find($entityId); + + if($course === null) { + $this->createNotFoundException("Invalid accompanying course id"); + } + + $task->setCourse($course); + + } + + } $this->denyAccessUnlessGranted(TaskVoter::CREATE, $task, 'You are not ' @@ -124,9 +152,19 @@ class SingleTaskController extends AbstractController $this->addFlash('success', $translator->trans("The task is created")); - return $this->redirectToRoute('chill_task_singletask_list', [ - 'person_id' => $task->getPerson()->getId() - ]); + if($entityType === 'person') + { + return $this->redirectToRoute('chill_task_singletask_list', [ + 'person_id' => $task->getPerson()->getId() + ]); + } + + if($entityType === 'course') + { + return $this->redirectToRoute('chill_task_singletask_list', [ + 'course_id' => $task->getCourse()->getId() + ]); + } } else { $this->addFlash('error', $translator->trans("This form contains errors")); From ead96f38361510856d12167fb12c4ec1c1c93a9e Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 10 Sep 2021 14:57:41 +0200 Subject: [PATCH 003/209] tasks added to accompanyingCourse menu --- .../Menu/AccompanyingCourseMenuBuilder.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php index 744e5dbbe..1ac0f8008 100644 --- a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php @@ -67,6 +67,13 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface 'id' => $period->getId() ]]) ->setExtras(['order' => 40]); + + $menu->addChild($this->translator->trans('Tasks'), [ + 'route' => 'chill_task_singletask_list', + 'routeParameters' => [ + 'course_id' => $period->getId() + ]]) + ->setExtras(['order' => 50]); } From b28b4e5fba42177fbc775870707913f6c69af1f0 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 10 Sep 2021 15:19:41 +0200 Subject: [PATCH 004/209] templates + controller further adapted to work with accompanyingCourse. new and show methods don't work yet due to authorization/voter issues templates adapted for use with accompanyingCourse tasks also --- .../Controller/SingleTaskController.php | 165 +++++-- .../views/SingleTask/_list.html.twig | 428 +++++++++--------- .../views/SingleTask/index.html.twig | 38 +- .../config/services/controller.yaml | 19 +- 4 files changed, 365 insertions(+), 285 deletions(-) diff --git a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php index 8c742c627..aed805bcf 100644 --- a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php @@ -29,6 +29,10 @@ use Symfony\Component\Translation\TranslatorInterface; use Chill\TaskBundle\Event\UI\UIEvent; use Chill\MainBundle\Repository\CenterRepository; use Chill\MainBundle\Timeline\TimelineBuilder; +use Chill\PersonBundle\Entity\AccompanyingPeriod; +use Chill\PersonBundle\Repository\AccompanyingPeriodRepository; +use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; +use Symfony\Component\HttpFoundation\RequestStack; /** * Class SingleTaskController @@ -53,6 +57,11 @@ class SingleTaskController extends AbstractController * @var LoggerInterface */ protected $logger; + + /** + * @var RequestStack + */ + protected $request; /** * SingleTaskController constructor. @@ -62,11 +71,25 @@ class SingleTaskController extends AbstractController public function __construct( EventDispatcherInterface $eventDispatcher, TimelineBuilder $timelineBuilder, - LoggerInterface $logger + LoggerInterface $logger, + RequestStack $requestStack ) { $this->eventDispatcher = $eventDispatcher; $this->timelineBuilder = $timelineBuilder; $this->logger = $logger; + $this->request = $requestStack->getCurrentRequest(); + } + + + public function getEntity() + { + if($this->request->query->has('person_id')){ + return 'person'; + } else if ($this->request->query->has('course_id')) { + return 'course'; + } else { + return null; + } } @@ -77,7 +100,6 @@ class SingleTaskController extends AbstractController * ) */ public function newAction( - Request $request, TranslatorInterface $translator ) { @@ -85,18 +107,12 @@ class SingleTaskController extends AbstractController ->setAssignee($this->getUser()) ->setType('task_default') ; - - if($request->query->has('person_id')){ - $entityType = 'person'; - } else if ($request->query->has('course_id')) { - $entityType = 'course'; - } else { - $entityType = null; - } + + $entityType = $this->getEntity(); if ($entityType !== null) { - $entityId = $request->query->getInt("{$entityType}_id", 0); // sf4 check: + $entityId = $this->request->query->getInt("{$entityType}_id", 0); // sf4 check: // prevent error: `Argument 2 passed to ::getInt() must be of the type int, null given` if ($entityId === null) { @@ -134,12 +150,18 @@ class SingleTaskController extends AbstractController } + // error message: You should associate a person with task in order to check autorizations. + // consequently adapting TaskVoter to take into account accompanyinCourse throws new errors linked to authorizationHelper on line 151 + $this->denyAccessUnlessGranted(TaskVoter::CREATE, $task, 'You are not ' . 'allowed to create this task'); + // error message: An error has occurred resolving the options of the form "Chill\TaskBundle\Form\SingleTaskType": + //The option "center" with value null is expected to be of type "Chill\MainBundle\Entity\Center", but is of type "null". + $form = $this->setCreateForm($task, new Role(TaskVoter::CREATE)); - $form->handleRequest($request); + $form->handleRequest($this->request); if ($form->isSubmitted()) { if ($form->isValid()) { @@ -184,13 +206,22 @@ class SingleTaskController extends AbstractController * name="chill_task_single_task_show" * ) */ - public function showAction(Request $request, $id) + public function showAction($id) { $em = $this->getDoctrine()->getManager(); $task = $em->getRepository(SingleTask::class)->find($id); + // In case no task is found + + if (!$task) { + throw $this->createNotFoundException('Unable to find Task entity.'); + } + + // In case task belongs to person + if ($task->getPerson() !== null) { + $personId = $task->getPerson()->getId(); if ($personId === null) { @@ -204,23 +235,42 @@ class SingleTaskController extends AbstractController if ($person === null) { throw $this->createNotFoundException("Invalid person id"); } - } - $this->denyAccessUnlessGranted(TaskVoter::SHOW, $task, 'You are not ' - . 'allowed to view this task'); - if (!$task) { - throw $this->createNotFoundException('Unable to find Task entity.'); - } - - $timeline = $this->timelineBuilder - ->getTimelineHTML('task', array('task' => $task)); - - $event = new PrivacyEvent($person, array( + $event = new PrivacyEvent($person, array( 'element_class' => SingleTask::class, 'element_id' => $task->getId(), 'action' => 'show' - )); - $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); + )); + $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); + + } + + // In case task belongs to accompanying course + + if ($task->getCourse() !== null) + { + $courseId = $task->getCourse()->getId(); + + if ($courseId === null) { + return new Response("You must provide a course_id", Response::HTTP_BAD_REQUEST); + } + + $course = $this->getDoctrine()->getManager() + ->getRepository(AccompanyingPeriod::class) + ->find($courseId); + + if ($course === null) + { + throw $this->createNotFoundException("Invalid course id"); + } + } + + + $this->denyAccessUnlessGranted(TaskVoter::SHOW, $task, 'You are not ' + . 'allowed to view this task'); + + $timeline = $this->timelineBuilder + ->getTimelineHTML('task', array('task' => $task)); return $this->render('ChillTaskBundle:SingleTask:show.html.twig', array( 'task' => $task, @@ -236,7 +286,6 @@ class SingleTaskController extends AbstractController * ) */ public function editAction( - Request $request, $id, TranslatorInterface $translator ) { @@ -273,7 +322,7 @@ class SingleTaskController extends AbstractController $form = $event->getForm(); - $form->handleRequest($request); + $form->handleRequest($this->request); if ($form->isSubmitted()) { if ($form->isValid()) { @@ -294,7 +343,7 @@ class SingleTaskController extends AbstractController return $this->redirectToRoute( 'chill_task_singletask_list', - $request->query->get('list_params', []) + $this->request->query->get('list_params', []) ); } else { @@ -440,6 +489,7 @@ class SingleTaskController extends AbstractController * Arguments: * - user_id * - scope_id + * - course_id * - person_id * - hide_form (hide the form to filter the tasks) * - status: date state, amongst SingleTaskRepository::DATE_STATUSES, or 'closed' @@ -450,10 +500,10 @@ class SingleTaskController extends AbstractController * ) */ public function listAction( - Request $request, PaginatorFactory $paginatorFactory, SingleTaskRepository $taskRepository, PersonRepository $personRepository, + AccompanyingPeriodRepository $courseRepository, CenterRepository $centerRepository, FormFactoryInterface $formFactory ) { @@ -466,12 +516,13 @@ class SingleTaskController extends AbstractController $params['user'] = null; $viewParams['center'] = null; $params['types'] = null; + $viewParams['accompanyingCourse'] = null; // Get parameters from url - if (!empty($request->query->get('person_id', NULL))) { + if (!empty($this->request->query->get('person_id', NULL))) { - $personId = $request->query->getInt('person_id', 0); + $personId = $this->request->query->getInt('person_id', 0); $person = $personRepository->find($personId); if ($person === null) { @@ -482,28 +533,42 @@ class SingleTaskController extends AbstractController $viewParams['person'] = $person; $params['person'] = $person; } + + if (!empty($this->request->query->get('course_id', NULL))) { + + $courseId = $this->request->query->getInt('course_id', 0); + $course = $courseRepository->find($courseId); + + if ($course === null) { + throw $this->createNotFoundException("This accompanying course ' $courseId ' does not exist."); + } + $this->denyAccessUnlessGranted(AccompanyingPeriodVoter::SEE, $course); + + $viewParams['accompanyingCourse'] = $course; + $params['accompanyingCourse'] = $course; + } - if (!empty($request->query->get('center_id', NULL))) { - $center = $centerRepository->find($request->query->getInt('center_id')); + if (!empty($this->request->query->get('center_id', NULL))) { + $center = $centerRepository->find($this->request->query->getInt('center_id')); if ($center === null) { throw $this->createNotFoundException('center not found'); } $params['center'] = $center; } - if(!empty($request->query->get('types', []))) { - $types = $request->query->get('types', []); + if(!empty($this->request->query->get('types', []))) { + $types = $this->request->query->get('types', []); if (count($types) > 0) { $params['types'] = $types; } } - if (!empty($request->query->get('user_id', null))) { - if ($request->query->get('user_id') === '_unassigned') { + if (!empty($this->request->query->get('user_id', null))) { + if ($this->request->query->get('user_id') === '_unassigned') { $params['unassigned'] = true; } else { - $userId = $request->query->getInt('user_id', 0); + $userId = $this->request->query->getInt('user_id', 0); $user = $this->getDoctrine()->getManager() ->getRepository('ChillMainBundle:User') ->find($userId); @@ -517,9 +582,9 @@ class SingleTaskController extends AbstractController } } - if (!empty($request->query->get('scope_id'))) { + if (!empty($this->request->query->get('scope_id'))) { - $scopeId = $request->query->getInt('scope_id', 0); + $scopeId = $this->request->query->getInt('scope_id', 0); $scope = $this->getDoctrine()->getManager() ->getRepository('ChillMainBundle:Scope') @@ -535,7 +600,7 @@ class SingleTaskController extends AbstractController // collect parameters for filter $possibleStatuses = \array_merge(SingleTaskRepository::DATE_STATUSES, [ 'closed' ]); - $statuses = $request->query->get('status', $possibleStatuses); + $statuses = $this->request->query->get('status', $possibleStatuses); // check for invalid statuses $diff = \array_diff($statuses, $possibleStatuses); @@ -551,7 +616,7 @@ class SingleTaskController extends AbstractController $tasks_count = 0; foreach($statuses as $status) { - if($request->query->has('status') + if($this->request->query->has('status') && FALSE === \in_array($status, $statuses)) { continue; } @@ -586,6 +651,8 @@ class SingleTaskController extends AbstractController if ($viewParams['person'] !== null){ $viewParams['layout'] = '@ChillPerson/Person/layout.html.twig'; + } else if ($viewParams['accompanyingCourse'] !== null){ + $viewParams['layout'] = '@ChillPerson/AccompanyingCourse/layout.html.twig'; } else { $viewParams['layout'] = '@ChillMain/layout.html.twig'; } @@ -598,7 +665,7 @@ class SingleTaskController extends AbstractController 'add_type' => true ]); - $form->handleRequest($request); + $form->handleRequest($this->request); if (isset($person)) { $event = new PrivacyEvent($person, array( @@ -609,14 +676,14 @@ class SingleTaskController extends AbstractController } return $this->render('ChillTaskBundle:SingleTask:index.html.twig', - \array_merge($viewParams, [ 'form' => $form->createView() ])); + array_merge($viewParams, [ 'form' => $form->createView() ])); } - protected function getPersonParam(Request $request, EntityManagerInterface $em) + protected function getPersonParam(EntityManagerInterface $em) { $person = $em->getRepository(Person::class) - ->find($request->query->getInt('person_id')) + ->find($this->request->query->getInt('person_id')) ; if (NULL === $person) { @@ -629,10 +696,10 @@ class SingleTaskController extends AbstractController return $person; } - protected function getUserParam(Request $request, EntityManagerInterface $em) + protected function getUserParam(EntityManagerInterface $em) { $user = $em->getRepository(User::class) - ->find($request->query->getInt('user_id')) + ->find($this->request->query->getInt('user_id')) ; if (NULL === $user) { diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_list.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_list.html.twig index a5a867dcc..e80e45e8c 100644 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_list.html.twig +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_list.html.twig @@ -1,244 +1,256 @@ {% macro date_status(title, tasks, count, paginator, status, isSingleStatus, person, user) %} - {% if tasks|length > 0 %} -

{{ title|trans }}

+ {% if tasks|length > 0 %} +

{{ title|trans }}

- - - {% for task in tasks %} - - + + {% endfor %} + +
-
- {{ task.title }} -
+ + + {% for task in tasks %} + + - + - - {% endfor %} - -
+
+ {{ task.title }} +
- {% if person is null %} -
- {{ 'For person'|trans }} : {{ task.person}} -
- {% endif %} + {% if person is null %} +
+ {{ 'For person'|trans }} : + + {{ task.person}} + +
+ {% endif %} -
- {{ task_workflow_metadata(task, 'definition.name')|trans }} -
+
+ {{ task_workflow_metadata(task, 'definition.name')|trans }} +
-
- {% for place in workflow_marked_places(task) %} - {{ place|trans }} - {% endfor %} - {% if task.assignee is not null %} -
{{ 'By'|trans }} : {{ task.assignee.username }}
- {% endif %} -
+
+ {% for place in workflow_marked_places(task) %} + {{ place|trans }} + {% endfor %} + {% if task.assignee is not null %} +
+ {{ 'By'|trans }} : + {{ task.assignee.username }}
+ {% endif %} +
- {% if task.startDate is not null or task.warningDate is not null or task.endDate is not null %} -
-
    - {% if task.startDate is not null %} -
  • - {{ task.startDate|format_date('medium') }} -
  • - {% endif %} - {% if task.warningDate is not null %} -
  • - {{ task.warningDate|format_date('medium') }} -
  • - {% endif %} - {% if task.endDate is not null %} -
  • - {{ task.endDate|format_date('medium') }} -
  • - {% endif %} -
-
- {% endif %} + {% if task.startDate is not null or task.warningDate is not null or task.endDate is not null %} +
+
    + {% if task.startDate is not null %} +
  • + + {{ task.startDate|format_date('medium') }} +
  • + {% endif %} + {% if task.warningDate is not null %} +
  • + + {{ task.warningDate|format_date('medium') }} +
  • + {% endif %} + {% if task.endDate is not null %} +
  • + + {{ task.endDate|format_date('medium') }} +
  • + {% endif %} +
+
+ {% endif %} -
- + -
+ {% if is_granted('CHILL_TASK_TASK_DELETE', task) %} +
  • + +
  • + {% endif %} + +
    - {% if isSingleStatus %} - {% if tasks|length < paginator.getTotalItems %} - {{ chill_pagination(paginator) }} - {% endif %} + {% if isSingleStatus %} + {% if tasks|length < paginator.getTotalItems %} + {{ chill_pagination(paginator) }} + {% endif %} - - - {% else %} - + {% endif %} - {% endif %} + {% endif %} {% endmacro %} {% import _self as helper %} -

    {{ app.request.query.get('title', null)|escape('html')|default('Task list'|trans) }}

    +

    {{ app.request.query.get('title', null)|escape('html')|default('Task list'|trans) }}

    - {% if false == app.request.query.boolean('hide_form', false) %} -

    {{ 'Filter the tasks'|trans }}

    - {{ form_start(form) }} - {{ form_row(form.user_id) }} +{% if false == app.request.query.boolean('hide_form', false) %} +

    {{ 'Filter the tasks'|trans }}

    + {{ form_start(form) }} + {{ form_row(form.user_id) }} - {% if form.status is defined %} - {{ form_row(form.status) }} - {% endif %} + {% if form.status is defined %} + {{ form_row(form.status) }} + {% endif %} - {% if form.types is defined %} - {{ form_row(form.types) }} - {% endif %} + {% if form.types is defined %} + {{ form_row(form.types) }} + {% endif %} - {% if form.person_id is defined %} - {{ form_row(form.person_id) }} - {% endif %} + {% if form.person_id is defined %} + {{ form_row(form.person_id) }} + {% endif %} - {% if form.center_id is defined %} - {{ form_row(form.center_id) }} - {% endif %} + {% if form.center_id is defined %} + {{ form_row(form.center_id) }} + {% endif %} -
      -
    • - -
    • -
    +
      +
    • + +
    • +
    - {{ form_end(form)}} - {% endif %} + {{ form_end(form)}} +{% endif %} - {% if tasks_count == 0 %} -

    {{ "There is no tasks."|trans }}

    - {% if person is not null and is_granted('CHILL_TASK_TASK_CREATE', person) %} - - {% endif %} - {% else %} +{% if tasks_count == 0 %} +

    {{ "There is no tasks."|trans }}

    + {% if person is not null and is_granted('CHILL_TASK_TASK_CREATE', person) %} + + {% endif %} +{% else %} - {% if false == app.request.query.boolean('hide_form', false) %} -

    {{ 'Tasks'|trans }}

    - {% endif %} + {% if false == app.request.query.boolean('hide_form', false) %} +

    {{ 'Tasks'|trans }}

    + {% endif %} - {% if person is not null and is_granted('CHILL_TASK_TASK_CREATE', person) %} - - {% endif %} + {% if person is not null and is_granted('CHILL_TASK_TASK_CREATE', person) %} + + {% endif %} - {% if single_task_ended_tasks is defined %} - {{ helper.date_status('Tasks with expired deadline', single_task_ended_tasks, single_task_ended_count, single_task_ended_paginator, 'ended', isSingleStatus, person) }} - {% endif %} + {% if single_task_ended_tasks is defined %} + {{ helper.date_status('Tasks with expired deadline', single_task_ended_tasks, single_task_ended_count, single_task_ended_paginator, 'ended', isSingleStatus, person) }} + {% endif %} - {% if single_task_warning_tasks is defined %} - {{ helper.date_status('Tasks with warning deadline reached', single_task_warning_tasks, single_task_warning_count, single_task_warning_paginator, 'warning', isSingleStatus, person) }} - {% endif %} + {% if single_task_warning_tasks is defined %} + {{ helper.date_status('Tasks with warning deadline reached', single_task_warning_tasks, single_task_warning_count, single_task_warning_paginator, 'warning', isSingleStatus, person) }} + {% endif %} - {% if single_task_current_tasks is defined %} - {{ helper.date_status('Current tasks', single_task_current_tasks, single_task_current_count, single_task_current_paginator, 'current', isSingleStatus, person) }} - {% endif %} + {% if single_task_current_tasks is defined %} + {{ helper.date_status('Current tasks', single_task_current_tasks, single_task_current_count, single_task_current_paginator, 'current', isSingleStatus, person) }} + {% endif %} - {% if single_task_not_started_tasks is defined %} - {{ helper.date_status('Tasks not started', single_task_not_started_tasks, single_task_not_started_count, single_task_not_started_paginator, 'not_started', isSingleStatus, person) }} - {% endif %} + {% if single_task_not_started_tasks is defined %} + {{ helper.date_status('Tasks not started', single_task_not_started_tasks, single_task_not_started_count, single_task_not_started_paginator, 'not_started', isSingleStatus, person) }} + {% endif %} - {% if single_task_closed_tasks is defined %} - {{ helper.date_status('Closed tasks', single_task_closed_tasks, single_task_closed_count, single_task_closed_paginator, 'closed', isSingleStatus, person) }} - {% endif %} + {% if single_task_closed_tasks is defined %} + {{ helper.date_status('Closed tasks', single_task_closed_tasks, single_task_closed_count, single_task_closed_paginator, 'closed', isSingleStatus, person) }} + {% endif %} - {% if isSingleStatus == false %} - - {% endif %} + {% if isSingleStatus == false %} + + {% endif %} {% endif %} diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/index.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/index.html.twig index 2a33fc10c..1932d7525 100644 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/index.html.twig +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/index.html.twig @@ -15,30 +15,30 @@ * along with this program. If not, see . #} -{% extends '@ChillPerson/Person/layout.html.twig' %} +{% extends layout %} {% set activeRouteKey = 'chill_task_single_task_new' %} -{% block title %}{{ 'Task list'|trans }}{% endblock %} +{% block title %} + {{ 'Task list'|trans }} +{% endblock %} -{% macro thead() %} -{% endmacro %} +{% macro thead() %}{% endmacro %} -{% macro row(task) %} -{% endmacro %} +{% macro row(task) %}{% endmacro %} {% block filtertasks %} -{% if person is not null %} - {% block personcontent %} -
    - {% include 'ChillTaskBundle:SingleTask:_list.html.twig' %} -
    - {% endblock %} -{% else %} - {% block content %} -
    - {% include 'ChillTaskBundle:SingleTask:_list.html.twig' %} -
    - {% endblock %} -{% endif %} + {% if person is not null %} + {% block personcontent %} +
    + {% include 'ChillTaskBundle:SingleTask:_list.html.twig' %} +
    + {% endblock %} + {% else %} + {% block content %} +
    + {% include 'ChillTaskBundle:SingleTask:_list.html.twig' %} +
    + {% endblock %} + {% endif %} {% endblock %} diff --git a/src/Bundle/ChillTaskBundle/config/services/controller.yaml b/src/Bundle/ChillTaskBundle/config/services/controller.yaml index 533c57f47..cfe083e07 100644 --- a/src/Bundle/ChillTaskBundle/config/services/controller.yaml +++ b/src/Bundle/ChillTaskBundle/config/services/controller.yaml @@ -1,11 +1,12 @@ services: - Chill\TaskBundle\Controller\: - resource: '../../Controller' - tags: ['controller.service_arguments'] + Chill\TaskBundle\Controller\: + resource: "../../Controller" + tags: ["controller.service_arguments"] - Chill\TaskBundle\Controller\SingleTaskController: - arguments: - $eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface' - $timelineBuilder: '@chill_main.timeline_builder' - $logger: '@chill.main.logger' - tags: ['controller.service_arguments'] + Chill\TaskBundle\Controller\SingleTaskController: + arguments: + $eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface' + $timelineBuilder: "@chill_main.timeline_builder" + $logger: "@chill.main.logger" + $requestStack: '@Symfony\Component\HttpFoundation\RequestStack' + tags: ["controller.service_arguments"] From b1dbd8b0111f06a5481d47b4dfb264d9bc5a9344 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 15 Sep 2021 11:13:09 +0200 Subject: [PATCH 005/209] Menu entry added in PersonMenuBuilder of taskbundle. Removed from menubuilder in Personbundle. Rename file, PersonMenuBuilder to MenuBuilder? --- .../Menu/AccompanyingCourseMenuBuilder.php | 7 --- .../Menu/PersonMenuBuilder.php | 49 ++++++++++++++----- 2 files changed, 38 insertions(+), 18 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php index 1ac0f8008..744e5dbbe 100644 --- a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php @@ -67,13 +67,6 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface 'id' => $period->getId() ]]) ->setExtras(['order' => 40]); - - $menu->addChild($this->translator->trans('Tasks'), [ - 'route' => 'chill_task_singletask_list', - 'routeParameters' => [ - 'course_id' => $period->getId() - ]]) - ->setExtras(['order' => 50]); } diff --git a/src/Bundle/ChillTaskBundle/Menu/PersonMenuBuilder.php b/src/Bundle/ChillTaskBundle/Menu/PersonMenuBuilder.php index ee0afa497..8c45b0beb 100644 --- a/src/Bundle/ChillTaskBundle/Menu/PersonMenuBuilder.php +++ b/src/Bundle/ChillTaskBundle/Menu/PersonMenuBuilder.php @@ -53,28 +53,55 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface public function buildMenu($menuId, MenuItem $menu, array $parameters) { - /* @var $person \Chill\PersonBundle\Entity\Person */ + switch($menuId) { + case 'person': + $this->buildPersonMenu($menu, $parameters); + break; + case 'accompanyingCourse': + $this->buildAccompanyingCourseMenu($menu, $parameters); + break; + case 'section': + $menu->setExtras('icons', 'tasks'); + break; + default: + throw new \LogicException("this menuid $menuId is not implemented"); + } + } + + public function buildPersonMenu($menu, $parameters){ + + //var $person \Chill\PersonBundle\Entity\Person */ $person = $parameters['person'] ?? null; if ($this->authorizationChecker->isGranted(TaskVoter::SHOW, $person)) { $menu->addChild( $this->translator->trans('Tasks'), [ 'route' => 'chill_task_singletask_list', - 'routeParameters' => $menuId === 'person' ? + 'routeParameters' => [ 'person_id' => $person->getId() ] - : - null, - ]) - ->setExtra('order', 400) - ; - if ($menuId === 'section') { - $menu->setExtra('icons', 'tasks'); - } + ]) + ->setExtra('order', 400); } } + public function buildAccompanyingCourseMenu($menu, $parameters){ + + //var $person \Chill\PersonBundle\Entity\Person */ + $course = $parameters['accompanyingCourse']; + + // if ($this->authorizationChecker->isGranted(TaskVoter::SHOW, $course)) { + $menu->addChild( + $this->translator->trans('Tasks'), [ + 'route' => 'chill_task_singletask_list', + 'routeParameters' => + [ 'course_id' => $course->getId() ] + ]) + ->setExtra('order', 400); + // } + } + public static function getMenuIds(): array { - return ['person']; + return ['person', 'accompanyingCourse']; } } From a156bd08636f3ae35b07a2f4e58fa75984cbe376 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 16 Sep 2021 15:55:09 +0200 Subject: [PATCH 006/209] controller and templates adapted to display list of accompanying period tasks + detailpage of task --- .../Controller/SingleTaskController.php | 150 ++++++++++++++---- .../Menu/PersonMenuBuilder.php | 4 +- .../views/SingleTask/_listCourse.html.twig | 107 +++++++++++++ .../views/SingleTask/_show.html.twig | 110 +++++++++++++ .../views/SingleTask/index.html.twig | 2 +- .../Resources/views/SingleTask/show.html.twig | 119 +------------- .../views/SingleTask/showCourseTask.html.twig | 16 ++ .../translations/messages.fr.yml | 117 +++++++------- 8 files changed, 423 insertions(+), 202 deletions(-) create mode 100644 src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_listCourse.html.twig create mode 100644 src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_show.html.twig create mode 100644 src/Bundle/ChillTaskBundle/Resources/views/SingleTask/showCourseTask.html.twig diff --git a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php index aed805bcf..e98688aa6 100644 --- a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php @@ -32,6 +32,8 @@ use Chill\MainBundle\Timeline\TimelineBuilder; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Repository\AccompanyingPeriodRepository; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; +use Chill\TaskBundle\Form\SingleTaskCourseType; +use Chill\TaskBundle\Repository\AbstractTaskRepository; use Symfony\Component\HttpFoundation\RequestStack; /** @@ -81,7 +83,7 @@ class SingleTaskController extends AbstractController } - public function getEntity() + private function getEntityContext() { if($this->request->query->has('person_id')){ return 'person'; @@ -108,7 +110,7 @@ class SingleTaskController extends AbstractController ->setType('task_default') ; - $entityType = $this->getEntity(); + $entityType = $this->getEntityContext(); if ($entityType !== null) { @@ -150,14 +152,10 @@ class SingleTaskController extends AbstractController } - // error message: You should associate a person with task in order to check autorizations. - // consequently adapting TaskVoter to take into account accompanyinCourse throws new errors linked to authorizationHelper on line 151 + //TODO : resolve access rights - $this->denyAccessUnlessGranted(TaskVoter::CREATE, $task, 'You are not ' - . 'allowed to create this task'); - - // error message: An error has occurred resolving the options of the form "Chill\TaskBundle\Form\SingleTaskType": - //The option "center" with value null is expected to be of type "Chill\MainBundle\Entity\Center", but is of type "null". + // $this->denyAccessUnlessGranted(TaskVoter::CREATE, $task, 'You are not ' + // . 'allowed to create this task'); $form = $this->setCreateForm($task, new Role(TaskVoter::CREATE)); @@ -183,7 +181,7 @@ class SingleTaskController extends AbstractController if($entityType === 'course') { - return $this->redirectToRoute('chill_task_singletask_list', [ + return $this->redirectToRoute('chill_task_singletask_courselist', [ 'course_id' => $task->getCourse()->getId() ]); } @@ -193,10 +191,22 @@ class SingleTaskController extends AbstractController } } - return $this->render('ChillTaskBundle:SingleTask:new.html.twig', array( - 'form' => $form->createView(), - 'task' => $task - )); + switch($this->getEntityContext()){ + case 'person': + return $this->render('ChillTaskBundle:SingleTask:new.html.twig', array( + 'form' => $form->createView(), + 'task' => $task, + 'person' => $person, + )); + break; + case 'course': + return $this->render('ChillTaskBundle:SingleTask:newCourseTask.html.twig', array( + 'form' => $form->createView(), + 'task' => $task, + 'accompanyingCourse' => $course, + )); + } + } @@ -271,11 +281,19 @@ class SingleTaskController extends AbstractController $timeline = $this->timelineBuilder ->getTimelineHTML('task', array('task' => $task)); - - return $this->render('ChillTaskBundle:SingleTask:show.html.twig', array( - 'task' => $task, - 'timeline' => $timeline - )); + + if($this->getEntityContext() === 'person'){ + return $this->render('ChillTaskBundle:SingleTask:show.html.twig', array( + 'task' => $task, + 'timeline' => $timeline + )); + } else { + return $this->render('ChillTaskBundle:SingleTask:showCourseTask.html.twig', array( + 'task' => $task, + 'timeline' => $timeline + )); + } + } @@ -457,10 +475,18 @@ class SingleTaskController extends AbstractController */ protected function setCreateForm(SingleTask $task, Role $role) { - $form = $this->createForm(SingleTaskType::class, $task, [ - 'center' => $task->getCenter(), - 'role' => $role - ]); + if($this->getEntityContext() === 'person'){ + $form = $this->createForm(SingleTaskType::class, $task, [ + 'center' => $task->getCenter(), + 'role' => $role, + ]); + } + + if($this->getEntityContext() === 'course'){ + $form = $this->createForm(SingleTaskCourseType::class, $task, [ + 'center' => $task->getCenter(), + ]); + } $form->add('submit', SubmitType::class); @@ -517,6 +543,7 @@ class SingleTaskController extends AbstractController $viewParams['center'] = null; $params['types'] = null; $viewParams['accompanyingCourse'] = null; + $params['accompanyingCourse'] = null; // Get parameters from url @@ -658,12 +685,23 @@ class SingleTaskController extends AbstractController } // Form for filtering tasks - $form = $formFactory->createNamed(null, SingleTaskListType::class, null, [ - 'person' => $viewParams['person'], - 'method' => Request::METHOD_GET, - 'csrf_protection' => false, - 'add_type' => true - ]); + if($this->getEntityContext() === 'person'){ + $form = $formFactory->createNamed(null, SingleTaskListType::class, null, [ + 'person' => $viewParams['person'], + 'method' => Request::METHOD_GET, + 'csrf_protection' => false, + 'add_type' => true + ]); + } + + if($this->getEntityContext() === 'course'){ + $form = $formFactory->createNamed(null, SingleTaskListType::class, null, [ + 'accompanyingCourse' => $viewParams['accompanyingCourse'], + 'method' => Request::METHOD_GET, + 'csrf_protection' => false, + 'add_type' => true + ]); + } $form->handleRequest($this->request); @@ -728,4 +766,58 @@ class SingleTaskController extends AbstractController ; } + /** + * @Route( + * "/{_locale}/task/singletask/courselist", + * name="chill_task_singletask_courselist") + */ + + public function listCourseTasks( + AccompanyingPeriodRepository $courseRepository, + SingleTaskRepository $taskRepository, + FormFactoryInterface $formFactory, + TranslatorInterface $translator + ): Response + { + + if (!empty($this->request->query->get('course_id', NULL))) { + + $courseId = $this->request->query->getInt('course_id', 0); + $course = $courseRepository->find($courseId); + + if ($course === null) { + throw $this->createNotFoundException("This accompanying course ' $courseId ' does not exist."); + } + + } + + $em = $this->getDoctrine()->getManager(); + + if($course === NULL) { + throw $this->createNotFoundException('Accompanying course not found'); + } + + $tasks = $taskRepository + ->findBy( + array('course' => $course) + ); + + $form = $formFactory->createNamed(null, SingleTaskListType::class, null, [ + 'accompanyingCourse' => $course, + 'method' => Request::METHOD_GET, + 'csrf_protection' => false, + 'add_type' => true + ]); + + return $this->render( + 'ChillTaskBundle:SingleTask:index.html.twig', + [ + 'tasks' => $tasks, + 'accompanyingCourse' => $course, + 'layout' => '@ChillPerson/AccompanyingCourse/layout.html.twig', + 'form' => $form->createView(), + 'title' => $translator->trans('Tasks for this accompanying period') + ]); + } + } diff --git a/src/Bundle/ChillTaskBundle/Menu/PersonMenuBuilder.php b/src/Bundle/ChillTaskBundle/Menu/PersonMenuBuilder.php index 8c45b0beb..26f06d1b2 100644 --- a/src/Bundle/ChillTaskBundle/Menu/PersonMenuBuilder.php +++ b/src/Bundle/ChillTaskBundle/Menu/PersonMenuBuilder.php @@ -89,10 +89,12 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface //var $person \Chill\PersonBundle\Entity\Person */ $course = $parameters['accompanyingCourse']; + //TODO: implement voter again? + // if ($this->authorizationChecker->isGranted(TaskVoter::SHOW, $course)) { $menu->addChild( $this->translator->trans('Tasks'), [ - 'route' => 'chill_task_singletask_list', + 'route' => 'chill_task_singletask_courselist', 'routeParameters' => [ 'course_id' => $course->getId() ] ]) diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_listCourse.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_listCourse.html.twig new file mode 100644 index 000000000..16c907e4c --- /dev/null +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_listCourse.html.twig @@ -0,0 +1,107 @@ +{% if tasks|length > 0 %} +

    {{ title|trans }}

    + + + + {% for task in tasks %} + + + + + {% endfor %} + +
    +
    + {{ task.title }} +
    + +
    + {{ task_workflow_metadata(task, 'definition.name')|trans }} +
    + +
    + {% for place in workflow_marked_places(task) %} + {{ place|trans }} + {% endfor %} + {% if task.assignee is not null %} +
    + {{ 'By'|trans }} : + {{ task.assignee.username }}
    + {% endif %} +
    + + {% if task.startDate is not null or task.warningDate is not null or task.endDate is not null %} +
    +
      + {% if task.startDate is not null %} +
    • + + {{ task.startDate|format_date('medium') }} +
    • + {% endif %} + {% if task.warningDate is not null %} +
    • + + {{ task.warningDate|format_date('medium') }} +
    • + {% endif %} + {% if task.endDate is not null %} +
    • + + {{ task.endDate|format_date('medium') }} +
    • + {% endif %} +
    +
    + {% endif %} + +
    + +
    +{% endif %} + + diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_show.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_show.html.twig new file mode 100644 index 000000000..a8905285a --- /dev/null +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_show.html.twig @@ -0,0 +1,110 @@ +
    + +

    {{ 'Task'|trans }}

    + +

    {{ task.title }} + {% for place in workflow_marked_places(task) %} + {{ place|trans }} + {% endfor %} +

    + +
    + +
    {{ 'Description'|trans }}
    +
    + {% if task.description is empty %} + {{"No description"|trans}} + {% else %} +
    + {{ task.description|chill_markdown_to_html }} +
    + {% endif %} +
    + +
    {{ 'Assignee'|trans }}
    +
    + {% if task.assignee is null %} + {{"No one assignee"|trans}} + {% else %} + {{ task.assignee }} + {% endif %} +
    + +
    {{ 'Scope'|trans }}
    +
    + {{ task.scope.name|localize_translatable_string }} +
    + +

    {{"Dates"|trans}}

    + {% if task.startDate is null and task.endDate is null and task.warningDate is null %} +
    +
    + {{"No dates specified"|trans}} +
    + + {% else %} + {% if task.startDate is not null %} +
    {{ 'Start'|trans }}
    +
    {{ task.startDate|format_date('long') }}
    + {% endif %} + + {% if task.endDate is not null %} +
    {{ 'End'|trans }}
    +
    {{ task.endDate|format_date('long') }}
    + {% endif %} + + {% if task.warningDate is not null %} +
    {{ 'Warning'|trans }}
    +
    {{ task.warningDate|format_date('long') }}
    + {% endif %} + + {% endif %} +
    + +{% if timeline is not null %} +

    {{"Timeline"|trans}}

    + {{ timeline|raw }} +{% endif %} + +
    diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/index.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/index.html.twig index 1932d7525..4c0b9dc84 100644 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/index.html.twig +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/index.html.twig @@ -37,7 +37,7 @@ {% else %} {% block content %}
    - {% include 'ChillTaskBundle:SingleTask:_list.html.twig' %} + {% include 'ChillTaskBundle:SingleTask:_listCourse.html.twig' %}
    {% endblock %} {% endif %} diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/show.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/show.html.twig index 8cfa1ea33..19bf70777 100644 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/show.html.twig +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/show.html.twig @@ -16,124 +16,17 @@ #} {% extends "@ChillPerson/Person/layout.html.twig" %} + {% set activeRouteKey = 'chill_task_single_task_show' %} {% set person = task.person %} -{% block title %}{{ 'Task'|trans }}{% endblock %} +{% block title %} + {{ 'Task'|trans }} +{% endblock %} {% block personcontent %} -
    - -

    {{ 'Task'|trans }}

    - -

    {{ task.title }} {% for place in workflow_marked_places(task) %} - {{ place|trans }} - {% endfor %}

    - -
    - -
    {{ 'Description'|trans }}
    -
    - {% if task.description is empty %} - {{"No description"|trans}} - {% else %} -
    - {{ task.description|chill_markdown_to_html }} -
    - {% endif %} -
    - -
    {{ 'Assignee'|trans }}
    -
    - {% if task.assignee is null %} - {{"No one assignee"|trans}} - {% else %} - {{ task.assignee }} - {% endif %} -
    - -
    {{ 'Scope'|trans }}
    -
    {{ task.scope.name|localize_translatable_string }}
    - -

    {{"Dates"|trans}}

    - {% if task.startDate is null and task.endDate is null and task.warningDate is null %} -
    -
    {{"No dates specified"|trans}}
    - - {% else %} - {% if task.startDate is not null %} -
    {{ 'Start'|trans }}
    -
    {{ task.startDate|format_date('long') }}
    - {% endif %} - - {% if task.endDate is not null %} -
    {{ 'End'|trans }}
    -
    {{ task.endDate|format_date('long') }}
    - {% endif %} - - {% if task.warningDate is not null %} -
    {{ 'Warning'|trans }}
    -
    {{ task.warningDate|format_date('long') }}
    - {% endif %} - - {% endif %} -
    - - {% if timeline is not null %} -

    {{"Timeline"|trans}}

    - {{ timeline|raw }} - {% endif %} - - - -
    + + {% include 'ChillTaskBundle:SingleTask:_show.html.twig' %} {% endblock %} diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/showCourseTask.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/showCourseTask.html.twig new file mode 100644 index 000000000..643617a55 --- /dev/null +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/showCourseTask.html.twig @@ -0,0 +1,16 @@ +{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %} + + +{% set activeRouteKey = 'chill_task_single_task_show' %} +{% set accompanyingCourse = task.course %} + +{% block title %} + {{ 'Task'|trans }} +{% endblock %} + + +{% block content %} + + {% include 'ChillTaskBundle:SingleTask:_show.html.twig' %} + +{% endblock %} diff --git a/src/Bundle/ChillTaskBundle/translations/messages.fr.yml b/src/Bundle/ChillTaskBundle/translations/messages.fr.yml index 71bc22612..7af9d450d 100644 --- a/src/Bundle/ChillTaskBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillTaskBundle/translations/messages.fr.yml @@ -1,53 +1,54 @@ -Tasks: 'Tâches' -'New task': 'Nouvelle tâche' -'Add a new task': 'Ajouter une nouvelle tâche' +Tasks: "Tâches" +"New task": "Nouvelle tâche" +"Add a new task": "Ajouter une nouvelle tâche" Title: Titre Description: Description -Assignee: 'Personne assignée' +Assignee: "Personne assignée" Scope: Cercle -'Start date': 'Date de début' -'End date': "Date d'échéance" -'Warning date': "Date d'avertissement" -'Warning interval': "Délai d'avertissement avant la date d'échéance" -'Unknown dates': 'Dates non spécifiées' -'N': '' -'Unit': '' +"Start date": "Date de début" +"End date": "Date d'échéance" +"Warning date": "Date d'avertissement" +"Warning interval": "Délai d'avertissement avant la date d'échéance" +"Unknown dates": "Dates non spécifiées" +"N": "" +"Unit": "" Task: Tâche Details: Détails Person: Personne Date: Date Dates: Dates User: Utilisateur -'Task list': 'Liste des tâches' -'Tasks with expired deadline': "Tâches avec une date d'échéance dépassée" -'Tasks with warning deadline reached': "Tâches avec une date d'avertissement atteinte" -'Current tasks': 'Tâches en cours' -'Closed tasks': Tâches terminées -'Tasks not started': 'Tâches non commencées' -'Task start date': 'Date de début' -'Task warning date': "Date d'avertissement" -'Task end date': "Date d'échéance" -'Start': 'Début' -'Warning': 'Avertissement' -'End': 'Échéance' -'Task type': 'Type' -'Task status': 'Statut' -'Edit the task': 'Modifier la tâche' -'Edit task': 'Modifier la tâche' -'Save task': 'Enregistrer la tâche' -'View the task': 'Voir la tâche' -'Update the task': 'Mettre à jour la tâche' -'Remove task': 'Supprimer la tâche' -'Delete': 'Supprimer' -'Change task status': 'Changer le statut' +"Task list": "Liste des tâches" +"Tasks with expired deadline": "Tâches avec une date d'échéance dépassée" +"Tasks with warning deadline reached": "Tâches avec une date d'avertissement atteinte" +"Current tasks": "Tâches en cours" +"Closed tasks": Tâches terminées +"Tasks not started": "Tâches non commencées" +"Task start date": "Date de début" +"Task warning date": "Date d'avertissement" +"Task end date": "Date d'échéance" +"Start": "Début" +"Warning": "Avertissement" +"End": "Échéance" +"Task type": "Type" +"Task status": "Statut" +"Edit the task": "Modifier la tâche" +"Edit task": "Modifier la tâche" +"Save task": "Enregistrer la tâche" +"View the task": "Voir la tâche" +"Update the task": "Mettre à jour la tâche" +"Remove task": "Supprimer la tâche" +"Delete": "Supprimer" +"Change task status": "Changer le statut" 'Are you sure you want to remove the task about "%name%" ?': 'Êtes-vous sûr·e de vouloir supprimer la tâche de "%name%"?' -'See more': 'Voir plus' -'Associated tasks': 'Tâches associées' -'My tasks': 'Mes tâches' -'No description': 'Pas de description' -'No dates specified': 'Dates non spécifiées' -'No one assignee': 'Aucune personne assignée' -'Task types': Types de tâches +"See more": "Voir plus" +"Associated tasks": "Tâches associées" +"My tasks": "Mes tâches" +"Tasks for this accompanying period": "Tâches pour ce parcours d'accompagnement" +"No description": "Pas de description" +"No dates specified": "Dates non spécifiées" +"No one assignee": "Aucune personne assignée" +"Task types": Types de tâches Days: Jour(s) Weeks: Semaine(s) Months: Mois @@ -63,36 +64,36 @@ For person: Pour By: Par # transitions - default task definition -'new': 'nouvelle' -'in_progress': 'en cours' -'closed': 'fermée' -'canceled': 'supprimée' +"new": "nouvelle" +"in_progress": "en cours" +"closed": "fermée" +"canceled": "supprimée" start: démarrer close: clotûrer cancel: annuler Start_verb: Démarrer Close_verb: Clotûrer Set this task to cancel state: Marquer cette tâche comme annulée -'%user% has closed the task': '%user% a fermé la tâche' -'%user% has canceled the task': '%user% a annulé la tâche' -'%user% has started the task': '%user% a commencé la tâche' -'%user% has created the task': '%user% a introduit la tâche' +"%user% has closed the task": "%user% a fermé la tâche" +"%user% has canceled the task": "%user% a annulé la tâche" +"%user% has started the task": "%user% a commencé la tâche" +"%user% has created the task": "%user% a introduit la tâche" Are you sure you want to close this task ?: Êtes-vous sûrs de vouloir clotûrer cette tâche ? Are you sure you want to cancel this task ?: Êtes-vous sûrs de vouloir annuler cette tâche ? Are you sure you want to start this task ?: Êtes-vous sûrs de vouloir démarrer cette tâche ? #Flash messages -'The task is created': 'La tâche a été créée' -'There is no tasks.': Aucune tâche. -'The task has been successfully removed.': 'La tâche a bien été supprimée' -'This form contains errors': 'Ce formulaire contient des erreurs' -'The task has been updated': 'La tâche a été mise à jour' -'The transition is successfully applied': 'La transition a bien été effectuée' -'The transition could not be applied': "La transition n'a pas pu être appliquée" +"The task is created": "La tâche a été créée" +"There is no tasks.": Aucune tâche. +"The task has been successfully removed.": "La tâche a bien été supprimée" +"This form contains errors": "Ce formulaire contient des erreurs" +"The task has been updated": "La tâche a été mise à jour" +"The transition is successfully applied": "La transition a bien été effectuée" +"The transition could not be applied": "La transition n'a pas pu être appliquée" #widget -'%number% tasks over deadline': '{0} Aucune tâche dépassée|{1} Une tâche dépassée | ]1,Inf[ %count% tâches dépassées' -'%number% tasks near deadline': '{0} Aucune tâche en rappel|{1} Une tâche en rappel | ]1,Inf[ %count% tâches en rappel' +"%number% tasks over deadline": "{0} Aucune tâche dépassée|{1} Une tâche dépassée | ]1,Inf[ %count% tâches dépassées" +"%number% tasks near deadline": "{0} Aucune tâche en rappel|{1} Une tâche en rappel | ]1,Inf[ %count% tâches en rappel" #title My tasks near deadline: Mes tâches à échéance proche @@ -107,4 +108,4 @@ All centers: Tous les centres CHILL_TASK_TASK_CREATE: Ajouter une tâche CHILL_TASK_TASK_DELETE: Supprimer une tâche CHILL_TASK_TASK_SHOW: Voir une tâche -CHILL_TASK_TASK_UPDATE: Modifier une tâche \ No newline at end of file +CHILL_TASK_TASK_UPDATE: Modifier une tâche From 01ae50aca75122d3c53d8d983d880c5c1a726aed Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 17 Sep 2021 14:33:42 +0200 Subject: [PATCH 007/209] new/show/edit/delete/list functionality added for accompanyingperiod task --- .../Entity/AccompanyingPeriod.php | 10 ++ .../Controller/SingleTaskController.php | 143 ++++++++++++------ .../ChillTaskBundle/Entity/AbstractTask.php | 12 ++ .../ChillTaskBundle/Form/SingleTaskType.php | 7 +- ...{PersonMenuBuilder.php => MenuBuilder.php} | 0 .../views/SingleTask/_edit.html.twig | 25 +++ .../Resources/views/SingleTask/_new.html.twig | 30 ++++ .../views/SingleTask/_show.html.twig | 4 +- .../confirm_deleteCourseTask.html.twig | 19 +++ .../Resources/views/SingleTask/edit.html.twig | 39 +---- .../views/SingleTask/editCourseTask.html.twig | 14 ++ .../Resources/views/SingleTask/new.html.twig | 33 +--- .../views/SingleTask/newCourseTask.html.twig | 12 ++ .../Security/Authorization/TaskVoter.php | 13 +- .../translations/messages.fr.yml | 1 + 15 files changed, 243 insertions(+), 119 deletions(-) rename src/Bundle/ChillTaskBundle/Menu/{PersonMenuBuilder.php => MenuBuilder.php} (100%) create mode 100644 src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_edit.html.twig create mode 100644 src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_new.html.twig create mode 100644 src/Bundle/ChillTaskBundle/Resources/views/SingleTask/confirm_deleteCourseTask.html.twig create mode 100644 src/Bundle/ChillTaskBundle/Resources/views/SingleTask/editCourseTask.html.twig create mode 100644 src/Bundle/ChillTaskBundle/Resources/views/SingleTask/newCourseTask.html.twig diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php index 1c375d051..0458a1e74 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php @@ -26,6 +26,7 @@ use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface; use Chill\MainBundle\Doctrine\Model\TrackCreationInterface; use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Entity\Address; +use Chill\MainBundle\Entity\Center; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork; use Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive; use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment; @@ -967,6 +968,15 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface return $this->addressLocation; } + public function getCenter(): ?Center + { + if (count($this->getPersons()) === 0){ + return null; + } else { + return $this->getPersons()->first()->getCenter(); + } + } + /** * @Groups({"write"}) */ diff --git a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php index e98688aa6..456699091 100644 --- a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php @@ -6,7 +6,6 @@ use Chill\PersonBundle\Privacy\PrivacyEvent; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Routing\Annotation\Route; -use Doctrine\ORM\EntityManager; use Chill\PersonBundle\Entity\Person; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -22,7 +21,6 @@ use Chill\TaskBundle\Repository\SingleTaskRepository; use Chill\MainBundle\Entity\User; use Chill\PersonBundle\Security\Authorization\PersonVoter; use Chill\PersonBundle\Repository\PersonRepository; -use Chill\MainBundle\Entity\UserRepository; use Chill\TaskBundle\Event\TaskEvent; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\Translation\TranslatorInterface; @@ -32,8 +30,6 @@ use Chill\MainBundle\Timeline\TimelineBuilder; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Repository\AccompanyingPeriodRepository; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; -use Chill\TaskBundle\Form\SingleTaskCourseType; -use Chill\TaskBundle\Repository\AbstractTaskRepository; use Symfony\Component\HttpFoundation\RequestStack; /** @@ -205,6 +201,7 @@ class SingleTaskController extends AbstractController 'task' => $task, 'accompanyingCourse' => $course, )); + break; } } @@ -281,8 +278,9 @@ class SingleTaskController extends AbstractController $timeline = $this->timelineBuilder ->getTimelineHTML('task', array('task' => $task)); + - if($this->getEntityContext() === 'person'){ + if($task->getContext() instanceof Person){ return $this->render('ChillTaskBundle:SingleTask:show.html.twig', array( 'task' => $task, 'timeline' => $timeline @@ -311,7 +309,7 @@ class SingleTaskController extends AbstractController $em = $this->getDoctrine()->getManager(); $task = $em->getRepository(SingleTask::class)->find($id); - if ($task->getPerson() !== null) { + if ($task->getContext() instanceof Person) { $personId = $task->getPerson()->getId(); if ($personId === null) { return new Response("You must provide a person_id", Response::HTTP_BAD_REQUEST); @@ -324,7 +322,21 @@ class SingleTaskController extends AbstractController if ($person === null) { throw $this->createNotFoundException("Invalid person id"); } + } else { + $courseId = $task->getCourse()->getId(); + if ($courseId === null) { + return new Response("You must provide a course_id", Response::HTTP_BAD_REQUEST); + } + + $course = $this->getDoctrine()->getManager() + ->getRepository(AccompanyingPeriod::class) + ->find($courseId); + + if ($course === null) { + throw $this->createNotFoundException("Invalid accompanying period id"); + } } + $this->denyAccessUnlessGranted(TaskVoter::UPDATE, $task, 'You are not ' . 'allowed to edit this task'); @@ -351,19 +363,25 @@ class SingleTaskController extends AbstractController $this->addFlash('success', $translator ->trans("The task has been updated")); - - $event = new PrivacyEvent($person, array( + + if($task->getContext() instanceof Person){ + $event = new PrivacyEvent($person, array( 'element_class' => SingleTask::class, 'element_id' => $task->getId(), 'action' => 'update' - )); - $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); - - return $this->redirectToRoute( - 'chill_task_singletask_list', - $this->request->query->get('list_params', []) - ); + )); + $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); + return $this->redirectToRoute( + 'chill_task_singletask_list', + $this->request->query->get('list_params', []) + ); + } else { + return $this->redirectToRoute( + 'chill_task_singletask_courselist', + $this->request->query->get('list_params', []) + ); + } } else { $this->addFlash('error', $translator->trans("This form contains errors")); } @@ -375,17 +393,26 @@ class SingleTaskController extends AbstractController return $event->getResponse(); } - $event = new PrivacyEvent($person, array( - 'element_class' => SingleTask::class, - 'element_id' => $task->getId(), - 'action' => 'edit' - )); - $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); - - return $this->render('ChillTaskBundle:SingleTask:edit.html.twig', array( - 'task' => $task, - 'form' => $form->createView() - )); + if($task->getContext() instanceof Person){ + $event = new PrivacyEvent($person, array( + 'element_class' => SingleTask::class, + 'element_id' => $task->getId(), + 'action' => 'edit' + )); + $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); + + return $this->render('ChillTaskBundle:SingleTask:edit.html.twig', array( + 'task' => $task, + 'form' => $form->createView() + )); + } else { + return $this->render('ChillTaskBundle:SingleTask:editCourseTask.html.twig', array( + 'task' => $task, + 'form' => $form->createView(), + 'accompanyingCourse' => $course + )); + } + } @@ -422,8 +449,22 @@ class SingleTaskController extends AbstractController throw $this->createNotFoundException("Invalid person id"); } + } else { + $courseId = $task->getCourse()->getId(); + if ($courseId === null){ + return new Response("You must provide a course_id", Response::HTTP_BAD_REQUEST); + } + + $course = $this->getDoctrine()->getManager() + ->getRepository(AccompanyingPeriod::class) + ->find($courseId); + + if($course === null){ + throw $this->createNotFoundException("Invalid accompanying period id"); + } } + $this->denyAccessUnlessGranted(TaskVoter::DELETE, $task, 'You are not ' . 'allowed to delete this task'); @@ -452,19 +493,35 @@ class SingleTaskController extends AbstractController $this->addFlash('success', $translator ->trans("The task has been successfully removed.")); - return $this->redirect($this->generateUrl( - 'chill_task_singletask_list', - $request->query->get('list_params', [ - 'person_id' => $person->getId() - ]))); + if($task->getContext() instanceof Person){ + return $this->redirect($this->generateUrl( + 'chill_task_singletask_list', + $request->query->get('list_params', [ + 'person_id' => $person->getId() + ]))); + } else { + return $this->redirect($this->generateUrl( + 'chill_task_singletask_courselist', + $request->query->get('list_params', [ + 'course_id' => $course->getId() + ]))); + } } } + if($task->getContext() instanceof Person){ + return $this->render('ChillTaskBundle:SingleTask:confirm_delete.html.twig', array( + 'task' => $task, + 'delete_form' => $form->createView() + )); + } else { + return $this->render('ChillTaskBundle:SingleTask:confirm_deleteCourseTask.html.twig', array( + 'task' => $task, + 'delete_form' => $form->createView(), + 'accompanyingCourse' => $course + )); + } - return $this->render('ChillTaskBundle:SingleTask:confirm_delete.html.twig', array( - 'task' => $task, - 'delete_form' => $form->createView() - )); } /** @@ -475,18 +532,10 @@ class SingleTaskController extends AbstractController */ protected function setCreateForm(SingleTask $task, Role $role) { - if($this->getEntityContext() === 'person'){ - $form = $this->createForm(SingleTaskType::class, $task, [ - 'center' => $task->getCenter(), - 'role' => $role, - ]); - } - - if($this->getEntityContext() === 'course'){ - $form = $this->createForm(SingleTaskCourseType::class, $task, [ - 'center' => $task->getCenter(), - ]); - } + $form = $this->createForm(SingleTaskType::class, $task, [ + 'center' => $task->getCenter(), + 'role' => $role, + ]); $form->add('submit', SubmitType::class); diff --git a/src/Bundle/ChillTaskBundle/Entity/AbstractTask.php b/src/Bundle/ChillTaskBundle/Entity/AbstractTask.php index 649de0422..57a194ef8 100644 --- a/src/Bundle/ChillTaskBundle/Entity/AbstractTask.php +++ b/src/Bundle/ChillTaskBundle/Entity/AbstractTask.php @@ -248,11 +248,23 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface { if ($this->getPerson() instanceof Person) { return $this->getPerson()->getCenter(); + } else { + return $this->getCourse()->getCenter(); } return null; } + + public function getContext() + { + // if ($this->getCourse() instanceof AccompanyingPeriod){ + // return $this->getCourse(); + // } else { + // return $this->getPerson(); + // } + return $this->getPerson() ?? $this->getCourse(); + } public function getScope(): ?\Chill\MainBundle\Entity\Scope { diff --git a/src/Bundle/ChillTaskBundle/Form/SingleTaskType.php b/src/Bundle/ChillTaskBundle/Form/SingleTaskType.php index 16f000aa2..5802512b7 100644 --- a/src/Bundle/ChillTaskBundle/Form/SingleTaskType.php +++ b/src/Bundle/ChillTaskBundle/Form/SingleTaskType.php @@ -48,11 +48,11 @@ class SingleTaskType extends AbstractType 'center' => $options['center'], 'role' => $options['role'], 'placeholder' => 'Not assigned' - ]) + ]) ->add('circle', ScopePickerType::class, [ 'center' => $options['center'], 'role' => $options['role'] - ]) + ]) ->add('startDate', ChillDateType::class, [ 'required' => false ]) @@ -61,8 +61,7 @@ class SingleTaskType extends AbstractType ]) ->add('warningInterval', DateIntervalType::class, [ 'required' => false - ]) - ; + ]); } public function configureOptions(OptionsResolver $resolver) diff --git a/src/Bundle/ChillTaskBundle/Menu/PersonMenuBuilder.php b/src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php similarity index 100% rename from src/Bundle/ChillTaskBundle/Menu/PersonMenuBuilder.php rename to src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_edit.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_edit.html.twig new file mode 100644 index 000000000..98b070114 --- /dev/null +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_edit.html.twig @@ -0,0 +1,25 @@ +
    + +

    {{ 'Edit task'|trans }}

    + + {{ form_start(form) }} + + {{ form_row(form.title) }} + {{ form_row(form.description) }} + {{ form_row(form.assignee) }} + {{ form_row(form.circle) }} + {{ form_row(form.startDate) }} + {{ form_row(form.endDate) }} + {{ form_row(form.warningInterval) }} + +
      +
    • + + {{ 'Cancel'|trans }} +
    • +
    • + {{ form_widget(form.submit, { 'label': 'Save task', 'attr': {'class' : 'btn btn-update'}})}} +
    • +
    + {{ form_end(form) }} +
    diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_new.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_new.html.twig new file mode 100644 index 000000000..7cb19b19f --- /dev/null +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_new.html.twig @@ -0,0 +1,30 @@ +
    + +

    {{ 'New task'|trans }}

    + + {{ form_start(form) }} + + {{ form_errors(form) }} + + {{ form_row(form.title) }} + {{ form_row(form.description) }} + {{ form_row(form.assignee) }} + {{ form_row(form.circle) }} + {{ form_row(form.startDate) }} + {{ form_row(form.endDate) }} + {{ form_row(form.warningInterval) }} + +
      +
    • + + {{'Cancel'|trans}} + +
    • +
    • + {{ form_widget(form.submit, { 'label': 'Add a new task'|trans, 'attr': {'class': 'btn btn-save'} }) }} +
    • +
    + + {{ form_end(form) }} + +
    diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_show.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_show.html.twig index a8905285a..f73f2740d 100644 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_show.html.twig +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_show.html.twig @@ -68,8 +68,8 @@
    • - - {{ app.request.query.get('returnLabel')|default('Back to the list'|trans) }} + + {{'Back to the list'|trans}}
    • diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/confirm_deleteCourseTask.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/confirm_deleteCourseTask.html.twig new file mode 100644 index 000000000..49857188c --- /dev/null +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/confirm_deleteCourseTask.html.twig @@ -0,0 +1,19 @@ +{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %} + +{% set activeRouteKey = 'chill_task_task_list' %} +{% set course = task.course %} + +{% block title 'Remove task'|trans %} + +{% block content %} + + {{ include('@ChillMain/Util/confirmation_template.html.twig', + { + 'title' : 'Remove task'|trans, + 'confirm_question' : 'Are you sure you want to remove the task about accompanying period "%id%" ?'|trans({ '%id%' : course.id } ), + 'cancel_route' : 'chill_task_singletask_courselist', + 'cancel_parameters' : app.request.query.get('list_params', { } ), + 'form' : delete_form, + } ) }} + +{% endblock %} diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/edit.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/edit.html.twig index 67604f015..590740cf0 100644 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/edit.html.twig +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/edit.html.twig @@ -14,46 +14,17 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . #} -{% extends "@ChillPerson/Person/layout.html.twig" %} +{% extends person is defined ? "@ChillPerson/Person/layout.html.twig" %} {% set activeRouteKey = 'chill_task_single_task_edit' %} {% set person = task.person %} -{% block title %}{{ 'Edit task'|trans }}{% endblock %} +{% block title %} + {{ 'Edit task'|trans }} +{% endblock %} {% block personcontent %} -
      - -

      {{ 'Edit task'|trans }}

      - {{ form_start(form) }} + {% include 'ChillTaskBundle:SingleTask:_edit.html.twig' %} - {{ form_row(form.title) }} - {{ form_row(form.description) }} - {{ form_row(form.assignee) }} - {{ form_row(form.circle) }} - {{ form_row(form.startDate) }} - {{ form_row(form.endDate) }} - {{ form_row(form.warningInterval) }} - - - - {{ form_end(form) }} - -
      {% endblock %} diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/editCourseTask.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/editCourseTask.html.twig new file mode 100644 index 000000000..1805761ae --- /dev/null +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/editCourseTask.html.twig @@ -0,0 +1,14 @@ +{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %} + +{% set activeRouteKey = 'chill_task_single_task_edit' %} +{% set course = task.course %} + +{% block title %} + {{ 'Edit task'|trans }} +{% endblock %} + +{% block content %} + + {% include 'ChillTaskBundle:SingleTask:_edit.html.twig' %} + +{% endblock %} diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/new.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/new.html.twig index 8f6ba2a4b..2b59fd5bf 100644 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/new.html.twig +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/new.html.twig @@ -14,37 +14,16 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . #} -{% extends "@ChillPerson/Person/layout.html.twig" %} +{% extends person is defined ? "@ChillPerson/Person/layout.html.twig" : "@ChillPerson/AccompanyingCourse/layout.html.twig" %} {% set activeRouteKey = 'chill_task_single_task_new' %} {% set person = task.person %} -{% block title %}{{ 'New task'|trans }}{% endblock %} +{% block title %} + {{ 'New task'|trans }} +{% endblock %} + {% block personcontent %} -
      - -

      {{ 'New task'|trans }}

      - - {{ form_start(form) }} - - {{ form_errors(form) }} - - {{ form_row(form.title) }} - {{ form_row(form.description) }} - {{ form_row(form.assignee) }} - {{ form_row(form.circle) }} - {{ form_row(form.startDate) }} - {{ form_row(form.endDate) }} - {{ form_row(form.warningInterval) }} - -
        -
      • - {{ form_widget(form.submit, { 'label': 'Add a new task'|trans, 'attr': {'class': 'btn btn-save'} }) }} -
      • -
      - - {{ form_end(form) }} - -
      + {% include 'ChillTaskBundle:SingleTask:_new.html.twig' %} {% endblock %} diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/newCourseTask.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/newCourseTask.html.twig new file mode 100644 index 000000000..083c0795c --- /dev/null +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/newCourseTask.html.twig @@ -0,0 +1,12 @@ +{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %} + +{% set activeRouteKey = 'chill_task_single_task_new' %} +{# {% set person = task.person %} #} + +{% block title %} + {{ 'New task'|trans }} +{% endblock %} + +{% block content %} + {% include 'ChillTaskBundle:SingleTask:_new.html.twig' %} +{% endblock %} diff --git a/src/Bundle/ChillTaskBundle/Security/Authorization/TaskVoter.php b/src/Bundle/ChillTaskBundle/Security/Authorization/TaskVoter.php index 8b8bce839..1da58c5ce 100644 --- a/src/Bundle/ChillTaskBundle/Security/Authorization/TaskVoter.php +++ b/src/Bundle/ChillTaskBundle/Security/Authorization/TaskVoter.php @@ -27,7 +27,9 @@ use Psr\Log\LoggerInterface; use Chill\MainBundle\Security\ProvideRoleHierarchyInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Chill\MainBundle\Entity\User; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; +use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Chill\TaskBundle\Security\Authorization\AuthorizationEvent; @@ -128,14 +130,13 @@ class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterf } if ($subject instanceof AbstractTask) { - if ($subject->getPerson() === null) { + $associated = $subject->getPerson() ?? $subject->getCourse(); + if ($associated === null) { throw new \LogicException("You should associate a person with task " . "in order to check autorizations"); } - - $person = $subject->getPerson(); } elseif ($subject instanceof Person) { - $person = $subject; + $associated = $subject; } else { // subject is null. We check that at least one center is reachable $centers = $this->authorizationHelper->getReachableCenters($token->getUser(), new Role($attribute)); @@ -143,8 +144,10 @@ class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterf return count($centers) > 0; } - if (!$this->accessDecisionManager->decide($token, [PersonVoter::SEE], $person)) { + if ($associated instanceof Person && !$this->accessDecisionManager->decide($token, [PersonVoter::SEE], $associated)) { + return false; + } elseif ($associated instanceof AccompanyingPeriod && !$this->accessDecisionManager->decide($token, [AccompanyingPeriodVoter::SEE], $associated)) { return false; } diff --git a/src/Bundle/ChillTaskBundle/translations/messages.fr.yml b/src/Bundle/ChillTaskBundle/translations/messages.fr.yml index 7af9d450d..50af895e7 100644 --- a/src/Bundle/ChillTaskBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillTaskBundle/translations/messages.fr.yml @@ -41,6 +41,7 @@ User: Utilisateur "Delete": "Supprimer" "Change task status": "Changer le statut" 'Are you sure you want to remove the task about "%name%" ?': 'Êtes-vous sûr·e de vouloir supprimer la tâche de "%name%"?' +'Are you sure you want to remove the task about accompanying period "%id%" ?': 'Êtes-vous sûr·e de vouloir supprimer la tâche du parcours "%id%"?' "See more": "Voir plus" "Associated tasks": "Tâches associées" "My tasks": "Mes tâches" From 17b6f287dc03f77f43ba3e30e4ede8ef0a7165a5 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 17 Sep 2021 14:49:43 +0200 Subject: [PATCH 008/209] Changed name of PersonMenuBuilder More general name since it also contains the AccompanyingPeriod task menu entry now. --- .../ChillTaskBundle/Menu/MenuBuilder.php | 8 ++-- .../ChillTaskBundle/config/services/menu.yaml | 44 +++++++++---------- 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php b/src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php index 26f06d1b2..9b1890958 100644 --- a/src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php +++ b/src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php @@ -28,7 +28,7 @@ use Symfony\Component\Translation\TranslatorInterface; * * @author Julien Fastré */ -class PersonMenuBuilder implements LocalMenuBuilderInterface +class MenuBuilder implements LocalMenuBuilderInterface { /** * @@ -86,12 +86,10 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface public function buildAccompanyingCourseMenu($menu, $parameters){ - //var $person \Chill\PersonBundle\Entity\Person */ $course = $parameters['accompanyingCourse']; - //TODO: implement voter again? - // if ($this->authorizationChecker->isGranted(TaskVoter::SHOW, $course)) { + if ($this->authorizationChecker->isGranted(TaskVoter::SHOW, $course)) { $menu->addChild( $this->translator->trans('Tasks'), [ 'route' => 'chill_task_singletask_courselist', @@ -99,7 +97,7 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface [ 'course_id' => $course->getId() ] ]) ->setExtra('order', 400); - // } + } } public static function getMenuIds(): array diff --git a/src/Bundle/ChillTaskBundle/config/services/menu.yaml b/src/Bundle/ChillTaskBundle/config/services/menu.yaml index b4ff7a421..75726fcf4 100644 --- a/src/Bundle/ChillTaskBundle/config/services/menu.yaml +++ b/src/Bundle/ChillTaskBundle/config/services/menu.yaml @@ -1,23 +1,23 @@ services: - Chill\TaskBundle\Menu\UserMenuBuilder: - arguments: - $tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface' - $counter: '@Chill\TaskBundle\Templating\UI\CountNotificationTask' - $translator: '@Symfony\Component\Translation\TranslatorInterface' - $authorizationChecker: '@Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface' - tags: - - { name: 'chill.menu_builder' } - - Chill\TaskBundle\Menu\PersonMenuBuilder: - arguments: - $authorizationChecker: '@Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface' - $translator: '@Symfony\Component\Translation\TranslatorInterface' - tags: - - { name: 'chill.menu_builder' } - - Chill\TaskBundle\Menu\SectionMenuBuilder: - arguments: - $authorizationChecker: '@Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface' - $translator: '@Symfony\Component\Translation\TranslatorInterface' - tags: - - { name: 'chill.menu_builder' } + Chill\TaskBundle\Menu\UserMenuBuilder: + arguments: + $tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface' + $counter: '@Chill\TaskBundle\Templating\UI\CountNotificationTask' + $translator: '@Symfony\Component\Translation\TranslatorInterface' + $authorizationChecker: '@Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface' + tags: + - { name: "chill.menu_builder" } + + Chill\TaskBundle\Menu\MenuBuilder: + arguments: + $authorizationChecker: '@Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface' + $translator: '@Symfony\Component\Translation\TranslatorInterface' + tags: + - { name: "chill.menu_builder" } + + Chill\TaskBundle\Menu\SectionMenuBuilder: + arguments: + $authorizationChecker: '@Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface' + $translator: '@Symfony\Component\Translation\TranslatorInterface' + tags: + - { name: "chill.menu_builder" } From 27a52ce1666637ebefd0d6438a8383ba7ec20995 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 17 Sep 2021 14:53:15 +0200 Subject: [PATCH 009/209] Fix SingleTaskListType accompanyingCourse also defined as a form option --- src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php b/src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php index 99e8ddb42..634035f96 100644 --- a/src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php +++ b/src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php @@ -284,6 +284,7 @@ class SingleTaskListType extends AbstractType ->setDefined('person') ->setDefault('person', null) ->setAllowedTypes('person', [Person::class, 'null']) + ->setDefined('accompanyingCourse') ->setDefined('add_status') ->setDefault('add_status', false) ->setAllowedTypes('add_status', ['bool']) From 7515415888f4f99060de05f6ed8e9731eb7d58ec Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 17 Sep 2021 15:17:13 +0200 Subject: [PATCH 010/209] autowire and configure MenuBuilder --- src/Bundle/ChillTaskBundle/config/services/menu.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillTaskBundle/config/services/menu.yaml b/src/Bundle/ChillTaskBundle/config/services/menu.yaml index 75726fcf4..a9e1948d6 100644 --- a/src/Bundle/ChillTaskBundle/config/services/menu.yaml +++ b/src/Bundle/ChillTaskBundle/config/services/menu.yaml @@ -9,9 +9,8 @@ services: - { name: "chill.menu_builder" } Chill\TaskBundle\Menu\MenuBuilder: - arguments: - $authorizationChecker: '@Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface' - $translator: '@Symfony\Component\Translation\TranslatorInterface' + autowire: true + autoconfigure: true tags: - { name: "chill.menu_builder" } From 8318458805d2e18935d2b11304564b7cd2b271c9 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 9 Sep 2021 17:43:35 +0200 Subject: [PATCH 011/209] relation between task and accompanyingcourse created --- .../ChillTaskBundle/Entity/AbstractTask.php | 21 +++++++++- .../migrations/Version20210909153533.php | 38 +++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 src/Bundle/ChillTaskBundle/migrations/Version20210909153533.php diff --git a/src/Bundle/ChillTaskBundle/Entity/AbstractTask.php b/src/Bundle/ChillTaskBundle/Entity/AbstractTask.php index 73e98c0dd..649de0422 100644 --- a/src/Bundle/ChillTaskBundle/Entity/AbstractTask.php +++ b/src/Bundle/ChillTaskBundle/Entity/AbstractTask.php @@ -10,6 +10,7 @@ use Chill\MainBundle\Entity\HasScopeInterface; use Chill\MainBundle\Entity\HasCenterInterface; use Symfony\Component\Validator\Constraints as Assert; use Chill\MainBundle\Validator\Constraints\Entity\UserCircleConsistency; +use Chill\PersonBundle\Entity\AccompanyingPeriod; /** * AbstractTask @@ -67,9 +68,16 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface * @ORM\ManyToOne( * targetEntity="\Chill\PersonBundle\Entity\Person" * ) - * @Assert\NotNull() */ private $person; + + + /** + * @var AccompanyingPeriod + * @ORM\ManyToOne(targetEntity="\Chill\PersonBundle\Entity\AccompanyingPeriod") + */ + + private $course; /** * @@ -202,6 +210,11 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface return $this->person; } + public function getCourse(): ?AccompanyingPeriod + { + return $this->course; + } + public function getCircle(): ?Scope { return $this->circle; @@ -219,6 +232,12 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface return $this; } + public function setCourse(AccompanyingPeriod $course) + { + $this->course = $course; + return $this; + } + public function setCircle(Scope $circle) { $this->circle = $circle; diff --git a/src/Bundle/ChillTaskBundle/migrations/Version20210909153533.php b/src/Bundle/ChillTaskBundle/migrations/Version20210909153533.php new file mode 100644 index 000000000..e2f59621b --- /dev/null +++ b/src/Bundle/ChillTaskBundle/migrations/Version20210909153533.php @@ -0,0 +1,38 @@ +addSql('ALTER TABLE chill_task.recurring_task ADD course_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_task.recurring_task ADD CONSTRAINT FK_9F663B90591CC992 FOREIGN KEY (course_id) REFERENCES chill_person_accompanying_period (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE INDEX IDX_9F663B90591CC992 ON chill_task.recurring_task (course_id)'); + $this->addSql('ALTER TABLE chill_task.single_task ADD course_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_task.single_task ADD CONSTRAINT FK_194CB3D8591CC992 FOREIGN KEY (course_id) REFERENCES chill_person_accompanying_period (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE INDEX IDX_194CB3D8591CC992 ON chill_task.single_task (course_id)'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_task.recurring_task DROP CONSTRAINT FK_9F663B90591CC992'); + $this->addSql('ALTER TABLE chill_task.recurring_task DROP course_id'); + $this->addSql('ALTER TABLE chill_task.single_task DROP CONSTRAINT FK_194CB3D8591CC992'); + $this->addSql('ALTER TABLE chill_task.single_task DROP course_id'); + } +} From 53fc5b83993e5a04d60cc3da568dae6c9367fec3 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 9 Sep 2021 18:21:41 +0200 Subject: [PATCH 012/209] adaptation of newTask() method in singleTaskController --- .../Controller/SingleTaskController.php | 64 +++++++++++++++---- 1 file changed, 51 insertions(+), 13 deletions(-) diff --git a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php index bc76dacd4..8c742c627 100644 --- a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php @@ -86,24 +86,52 @@ class SingleTaskController extends AbstractController ->setType('task_default') ; - if ($request->query->has('person_id')) { + if($request->query->has('person_id')){ + $entityType = 'person'; + } else if ($request->query->has('course_id')) { + $entityType = 'course'; + } else { + $entityType = null; + } + + if ($entityType !== null) { - $personId = $request->query->getInt('person_id', 0); // sf4 check: + $entityId = $request->query->getInt("{$entityType}_id", 0); // sf4 check: // prevent error: `Argument 2 passed to ::getInt() must be of the type int, null given` - if ($personId === null) { - return new Response("You must provide a person_id", Response::HTTP_BAD_REQUEST); + if ($entityId === null) { + return new Response("You must provide a {$entityType}_id", Response::HTTP_BAD_REQUEST); } - $person = $this->getDoctrine()->getManager() - ->getRepository(Person::class) - ->find($personId); + if($entityType === 'person') + { + $person = $this->getDoctrine()->getManager() + ->getRepository(Person::class) + ->find($entityId); - if ($person === null) { - $this->createNotFoundException("Invalid person id"); + if ($person === null) { + $this->createNotFoundException("Invalid person id"); + } + + $task->setPerson($person); } - $task->setPerson($person); + if($entityType === 'course') + { + + $course = $this->getDoctrine()->getManager() + ->getRepository(AccompanyingPeriod::class) + ->find($entityId); + + if($course === null) { + $this->createNotFoundException("Invalid accompanying course id"); + } + + $task->setCourse($course); + + } + + } $this->denyAccessUnlessGranted(TaskVoter::CREATE, $task, 'You are not ' @@ -124,9 +152,19 @@ class SingleTaskController extends AbstractController $this->addFlash('success', $translator->trans("The task is created")); - return $this->redirectToRoute('chill_task_singletask_list', [ - 'person_id' => $task->getPerson()->getId() - ]); + if($entityType === 'person') + { + return $this->redirectToRoute('chill_task_singletask_list', [ + 'person_id' => $task->getPerson()->getId() + ]); + } + + if($entityType === 'course') + { + return $this->redirectToRoute('chill_task_singletask_list', [ + 'course_id' => $task->getCourse()->getId() + ]); + } } else { $this->addFlash('error', $translator->trans("This form contains errors")); From 1fb14834b72adc06e0a0eda56643fc1a3131a134 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 10 Sep 2021 14:57:41 +0200 Subject: [PATCH 013/209] tasks added to accompanyingCourse menu --- .../Menu/AccompanyingCourseMenuBuilder.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php index d82f8604b..4d1245f42 100644 --- a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php @@ -66,6 +66,13 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface 'routeParameters' => [ 'id' => $period->getId() ]]) + ->setExtras(['order' => 40]); + + $menu->addChild($this->translator->trans('Tasks'), [ + 'route' => 'chill_task_singletask_list', + 'routeParameters' => [ + 'course_id' => $period->getId() + ]]) ->setExtras(['order' => 50]); } From 5a936cd20b7ea900f762e5570d4062a54c825fe6 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 10 Sep 2021 15:19:41 +0200 Subject: [PATCH 014/209] templates + controller further adapted to work with accompanyingCourse. new and show methods don't work yet due to authorization/voter issues templates adapted for use with accompanyingCourse tasks also --- .../Controller/SingleTaskController.php | 165 +++++-- .../views/SingleTask/_list.html.twig | 428 +++++++++--------- .../views/SingleTask/index.html.twig | 38 +- .../config/services/controller.yaml | 19 +- 4 files changed, 365 insertions(+), 285 deletions(-) diff --git a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php index 8c742c627..aed805bcf 100644 --- a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php @@ -29,6 +29,10 @@ use Symfony\Component\Translation\TranslatorInterface; use Chill\TaskBundle\Event\UI\UIEvent; use Chill\MainBundle\Repository\CenterRepository; use Chill\MainBundle\Timeline\TimelineBuilder; +use Chill\PersonBundle\Entity\AccompanyingPeriod; +use Chill\PersonBundle\Repository\AccompanyingPeriodRepository; +use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; +use Symfony\Component\HttpFoundation\RequestStack; /** * Class SingleTaskController @@ -53,6 +57,11 @@ class SingleTaskController extends AbstractController * @var LoggerInterface */ protected $logger; + + /** + * @var RequestStack + */ + protected $request; /** * SingleTaskController constructor. @@ -62,11 +71,25 @@ class SingleTaskController extends AbstractController public function __construct( EventDispatcherInterface $eventDispatcher, TimelineBuilder $timelineBuilder, - LoggerInterface $logger + LoggerInterface $logger, + RequestStack $requestStack ) { $this->eventDispatcher = $eventDispatcher; $this->timelineBuilder = $timelineBuilder; $this->logger = $logger; + $this->request = $requestStack->getCurrentRequest(); + } + + + public function getEntity() + { + if($this->request->query->has('person_id')){ + return 'person'; + } else if ($this->request->query->has('course_id')) { + return 'course'; + } else { + return null; + } } @@ -77,7 +100,6 @@ class SingleTaskController extends AbstractController * ) */ public function newAction( - Request $request, TranslatorInterface $translator ) { @@ -85,18 +107,12 @@ class SingleTaskController extends AbstractController ->setAssignee($this->getUser()) ->setType('task_default') ; - - if($request->query->has('person_id')){ - $entityType = 'person'; - } else if ($request->query->has('course_id')) { - $entityType = 'course'; - } else { - $entityType = null; - } + + $entityType = $this->getEntity(); if ($entityType !== null) { - $entityId = $request->query->getInt("{$entityType}_id", 0); // sf4 check: + $entityId = $this->request->query->getInt("{$entityType}_id", 0); // sf4 check: // prevent error: `Argument 2 passed to ::getInt() must be of the type int, null given` if ($entityId === null) { @@ -134,12 +150,18 @@ class SingleTaskController extends AbstractController } + // error message: You should associate a person with task in order to check autorizations. + // consequently adapting TaskVoter to take into account accompanyinCourse throws new errors linked to authorizationHelper on line 151 + $this->denyAccessUnlessGranted(TaskVoter::CREATE, $task, 'You are not ' . 'allowed to create this task'); + // error message: An error has occurred resolving the options of the form "Chill\TaskBundle\Form\SingleTaskType": + //The option "center" with value null is expected to be of type "Chill\MainBundle\Entity\Center", but is of type "null". + $form = $this->setCreateForm($task, new Role(TaskVoter::CREATE)); - $form->handleRequest($request); + $form->handleRequest($this->request); if ($form->isSubmitted()) { if ($form->isValid()) { @@ -184,13 +206,22 @@ class SingleTaskController extends AbstractController * name="chill_task_single_task_show" * ) */ - public function showAction(Request $request, $id) + public function showAction($id) { $em = $this->getDoctrine()->getManager(); $task = $em->getRepository(SingleTask::class)->find($id); + // In case no task is found + + if (!$task) { + throw $this->createNotFoundException('Unable to find Task entity.'); + } + + // In case task belongs to person + if ($task->getPerson() !== null) { + $personId = $task->getPerson()->getId(); if ($personId === null) { @@ -204,23 +235,42 @@ class SingleTaskController extends AbstractController if ($person === null) { throw $this->createNotFoundException("Invalid person id"); } - } - $this->denyAccessUnlessGranted(TaskVoter::SHOW, $task, 'You are not ' - . 'allowed to view this task'); - if (!$task) { - throw $this->createNotFoundException('Unable to find Task entity.'); - } - - $timeline = $this->timelineBuilder - ->getTimelineHTML('task', array('task' => $task)); - - $event = new PrivacyEvent($person, array( + $event = new PrivacyEvent($person, array( 'element_class' => SingleTask::class, 'element_id' => $task->getId(), 'action' => 'show' - )); - $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); + )); + $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); + + } + + // In case task belongs to accompanying course + + if ($task->getCourse() !== null) + { + $courseId = $task->getCourse()->getId(); + + if ($courseId === null) { + return new Response("You must provide a course_id", Response::HTTP_BAD_REQUEST); + } + + $course = $this->getDoctrine()->getManager() + ->getRepository(AccompanyingPeriod::class) + ->find($courseId); + + if ($course === null) + { + throw $this->createNotFoundException("Invalid course id"); + } + } + + + $this->denyAccessUnlessGranted(TaskVoter::SHOW, $task, 'You are not ' + . 'allowed to view this task'); + + $timeline = $this->timelineBuilder + ->getTimelineHTML('task', array('task' => $task)); return $this->render('ChillTaskBundle:SingleTask:show.html.twig', array( 'task' => $task, @@ -236,7 +286,6 @@ class SingleTaskController extends AbstractController * ) */ public function editAction( - Request $request, $id, TranslatorInterface $translator ) { @@ -273,7 +322,7 @@ class SingleTaskController extends AbstractController $form = $event->getForm(); - $form->handleRequest($request); + $form->handleRequest($this->request); if ($form->isSubmitted()) { if ($form->isValid()) { @@ -294,7 +343,7 @@ class SingleTaskController extends AbstractController return $this->redirectToRoute( 'chill_task_singletask_list', - $request->query->get('list_params', []) + $this->request->query->get('list_params', []) ); } else { @@ -440,6 +489,7 @@ class SingleTaskController extends AbstractController * Arguments: * - user_id * - scope_id + * - course_id * - person_id * - hide_form (hide the form to filter the tasks) * - status: date state, amongst SingleTaskRepository::DATE_STATUSES, or 'closed' @@ -450,10 +500,10 @@ class SingleTaskController extends AbstractController * ) */ public function listAction( - Request $request, PaginatorFactory $paginatorFactory, SingleTaskRepository $taskRepository, PersonRepository $personRepository, + AccompanyingPeriodRepository $courseRepository, CenterRepository $centerRepository, FormFactoryInterface $formFactory ) { @@ -466,12 +516,13 @@ class SingleTaskController extends AbstractController $params['user'] = null; $viewParams['center'] = null; $params['types'] = null; + $viewParams['accompanyingCourse'] = null; // Get parameters from url - if (!empty($request->query->get('person_id', NULL))) { + if (!empty($this->request->query->get('person_id', NULL))) { - $personId = $request->query->getInt('person_id', 0); + $personId = $this->request->query->getInt('person_id', 0); $person = $personRepository->find($personId); if ($person === null) { @@ -482,28 +533,42 @@ class SingleTaskController extends AbstractController $viewParams['person'] = $person; $params['person'] = $person; } + + if (!empty($this->request->query->get('course_id', NULL))) { + + $courseId = $this->request->query->getInt('course_id', 0); + $course = $courseRepository->find($courseId); + + if ($course === null) { + throw $this->createNotFoundException("This accompanying course ' $courseId ' does not exist."); + } + $this->denyAccessUnlessGranted(AccompanyingPeriodVoter::SEE, $course); + + $viewParams['accompanyingCourse'] = $course; + $params['accompanyingCourse'] = $course; + } - if (!empty($request->query->get('center_id', NULL))) { - $center = $centerRepository->find($request->query->getInt('center_id')); + if (!empty($this->request->query->get('center_id', NULL))) { + $center = $centerRepository->find($this->request->query->getInt('center_id')); if ($center === null) { throw $this->createNotFoundException('center not found'); } $params['center'] = $center; } - if(!empty($request->query->get('types', []))) { - $types = $request->query->get('types', []); + if(!empty($this->request->query->get('types', []))) { + $types = $this->request->query->get('types', []); if (count($types) > 0) { $params['types'] = $types; } } - if (!empty($request->query->get('user_id', null))) { - if ($request->query->get('user_id') === '_unassigned') { + if (!empty($this->request->query->get('user_id', null))) { + if ($this->request->query->get('user_id') === '_unassigned') { $params['unassigned'] = true; } else { - $userId = $request->query->getInt('user_id', 0); + $userId = $this->request->query->getInt('user_id', 0); $user = $this->getDoctrine()->getManager() ->getRepository('ChillMainBundle:User') ->find($userId); @@ -517,9 +582,9 @@ class SingleTaskController extends AbstractController } } - if (!empty($request->query->get('scope_id'))) { + if (!empty($this->request->query->get('scope_id'))) { - $scopeId = $request->query->getInt('scope_id', 0); + $scopeId = $this->request->query->getInt('scope_id', 0); $scope = $this->getDoctrine()->getManager() ->getRepository('ChillMainBundle:Scope') @@ -535,7 +600,7 @@ class SingleTaskController extends AbstractController // collect parameters for filter $possibleStatuses = \array_merge(SingleTaskRepository::DATE_STATUSES, [ 'closed' ]); - $statuses = $request->query->get('status', $possibleStatuses); + $statuses = $this->request->query->get('status', $possibleStatuses); // check for invalid statuses $diff = \array_diff($statuses, $possibleStatuses); @@ -551,7 +616,7 @@ class SingleTaskController extends AbstractController $tasks_count = 0; foreach($statuses as $status) { - if($request->query->has('status') + if($this->request->query->has('status') && FALSE === \in_array($status, $statuses)) { continue; } @@ -586,6 +651,8 @@ class SingleTaskController extends AbstractController if ($viewParams['person'] !== null){ $viewParams['layout'] = '@ChillPerson/Person/layout.html.twig'; + } else if ($viewParams['accompanyingCourse'] !== null){ + $viewParams['layout'] = '@ChillPerson/AccompanyingCourse/layout.html.twig'; } else { $viewParams['layout'] = '@ChillMain/layout.html.twig'; } @@ -598,7 +665,7 @@ class SingleTaskController extends AbstractController 'add_type' => true ]); - $form->handleRequest($request); + $form->handleRequest($this->request); if (isset($person)) { $event = new PrivacyEvent($person, array( @@ -609,14 +676,14 @@ class SingleTaskController extends AbstractController } return $this->render('ChillTaskBundle:SingleTask:index.html.twig', - \array_merge($viewParams, [ 'form' => $form->createView() ])); + array_merge($viewParams, [ 'form' => $form->createView() ])); } - protected function getPersonParam(Request $request, EntityManagerInterface $em) + protected function getPersonParam(EntityManagerInterface $em) { $person = $em->getRepository(Person::class) - ->find($request->query->getInt('person_id')) + ->find($this->request->query->getInt('person_id')) ; if (NULL === $person) { @@ -629,10 +696,10 @@ class SingleTaskController extends AbstractController return $person; } - protected function getUserParam(Request $request, EntityManagerInterface $em) + protected function getUserParam(EntityManagerInterface $em) { $user = $em->getRepository(User::class) - ->find($request->query->getInt('user_id')) + ->find($this->request->query->getInt('user_id')) ; if (NULL === $user) { diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_list.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_list.html.twig index a5a867dcc..e80e45e8c 100644 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_list.html.twig +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_list.html.twig @@ -1,244 +1,256 @@ {% macro date_status(title, tasks, count, paginator, status, isSingleStatus, person, user) %} - {% if tasks|length > 0 %} -

      {{ title|trans }}

      + {% if tasks|length > 0 %} +

      {{ title|trans }}

      - - - {% for task in tasks %} - - + + {% endfor %} + +
      -
      - {{ task.title }} -
      + + + {% for task in tasks %} + + - + - - {% endfor %} - -
      +
      + {{ task.title }} +
      - {% if person is null %} -
      - {{ 'For person'|trans }} : {{ task.person}} -
      - {% endif %} + {% if person is null %} +
      + {{ 'For person'|trans }} : + + {{ task.person}} + +
      + {% endif %} -
      - {{ task_workflow_metadata(task, 'definition.name')|trans }} -
      +
      + {{ task_workflow_metadata(task, 'definition.name')|trans }} +
      -
      - {% for place in workflow_marked_places(task) %} - {{ place|trans }} - {% endfor %} - {% if task.assignee is not null %} -
      {{ 'By'|trans }} : {{ task.assignee.username }}
      - {% endif %} -
      +
      + {% for place in workflow_marked_places(task) %} + {{ place|trans }} + {% endfor %} + {% if task.assignee is not null %} +
      + {{ 'By'|trans }} : + {{ task.assignee.username }}
      + {% endif %} +
      - {% if task.startDate is not null or task.warningDate is not null or task.endDate is not null %} -
      -
        - {% if task.startDate is not null %} -
      • - {{ task.startDate|format_date('medium') }} -
      • - {% endif %} - {% if task.warningDate is not null %} -
      • - {{ task.warningDate|format_date('medium') }} -
      • - {% endif %} - {% if task.endDate is not null %} -
      • - {{ task.endDate|format_date('medium') }} -
      • - {% endif %} -
      -
      - {% endif %} + {% if task.startDate is not null or task.warningDate is not null or task.endDate is not null %} +
      +
        + {% if task.startDate is not null %} +
      • + + {{ task.startDate|format_date('medium') }} +
      • + {% endif %} + {% if task.warningDate is not null %} +
      • + + {{ task.warningDate|format_date('medium') }} +
      • + {% endif %} + {% if task.endDate is not null %} +
      • + + {{ task.endDate|format_date('medium') }} +
      • + {% endif %} +
      +
      + {% endif %} -
      - + -
      + {% if is_granted('CHILL_TASK_TASK_DELETE', task) %} +
    • + +
    • + {% endif %} + +
      - {% if isSingleStatus %} - {% if tasks|length < paginator.getTotalItems %} - {{ chill_pagination(paginator) }} - {% endif %} + {% if isSingleStatus %} + {% if tasks|length < paginator.getTotalItems %} + {{ chill_pagination(paginator) }} + {% endif %} - - - {% else %} - + {% endif %} - {% endif %} + {% endif %} {% endmacro %} {% import _self as helper %} -

      {{ app.request.query.get('title', null)|escape('html')|default('Task list'|trans) }}

      +

      {{ app.request.query.get('title', null)|escape('html')|default('Task list'|trans) }}

      - {% if false == app.request.query.boolean('hide_form', false) %} -

      {{ 'Filter the tasks'|trans }}

      - {{ form_start(form) }} - {{ form_row(form.user_id) }} +{% if false == app.request.query.boolean('hide_form', false) %} +

      {{ 'Filter the tasks'|trans }}

      + {{ form_start(form) }} + {{ form_row(form.user_id) }} - {% if form.status is defined %} - {{ form_row(form.status) }} - {% endif %} + {% if form.status is defined %} + {{ form_row(form.status) }} + {% endif %} - {% if form.types is defined %} - {{ form_row(form.types) }} - {% endif %} + {% if form.types is defined %} + {{ form_row(form.types) }} + {% endif %} - {% if form.person_id is defined %} - {{ form_row(form.person_id) }} - {% endif %} + {% if form.person_id is defined %} + {{ form_row(form.person_id) }} + {% endif %} - {% if form.center_id is defined %} - {{ form_row(form.center_id) }} - {% endif %} + {% if form.center_id is defined %} + {{ form_row(form.center_id) }} + {% endif %} -
        -
      • - -
      • -
      +
        +
      • + +
      • +
      - {{ form_end(form)}} - {% endif %} + {{ form_end(form)}} +{% endif %} - {% if tasks_count == 0 %} -

      {{ "There is no tasks."|trans }}

      - {% if person is not null and is_granted('CHILL_TASK_TASK_CREATE', person) %} - - {% endif %} - {% else %} +{% if tasks_count == 0 %} +

      {{ "There is no tasks."|trans }}

      + {% if person is not null and is_granted('CHILL_TASK_TASK_CREATE', person) %} + + {% endif %} +{% else %} - {% if false == app.request.query.boolean('hide_form', false) %} -

      {{ 'Tasks'|trans }}

      - {% endif %} + {% if false == app.request.query.boolean('hide_form', false) %} +

      {{ 'Tasks'|trans }}

      + {% endif %} - {% if person is not null and is_granted('CHILL_TASK_TASK_CREATE', person) %} - - {% endif %} + {% if person is not null and is_granted('CHILL_TASK_TASK_CREATE', person) %} + + {% endif %} - {% if single_task_ended_tasks is defined %} - {{ helper.date_status('Tasks with expired deadline', single_task_ended_tasks, single_task_ended_count, single_task_ended_paginator, 'ended', isSingleStatus, person) }} - {% endif %} + {% if single_task_ended_tasks is defined %} + {{ helper.date_status('Tasks with expired deadline', single_task_ended_tasks, single_task_ended_count, single_task_ended_paginator, 'ended', isSingleStatus, person) }} + {% endif %} - {% if single_task_warning_tasks is defined %} - {{ helper.date_status('Tasks with warning deadline reached', single_task_warning_tasks, single_task_warning_count, single_task_warning_paginator, 'warning', isSingleStatus, person) }} - {% endif %} + {% if single_task_warning_tasks is defined %} + {{ helper.date_status('Tasks with warning deadline reached', single_task_warning_tasks, single_task_warning_count, single_task_warning_paginator, 'warning', isSingleStatus, person) }} + {% endif %} - {% if single_task_current_tasks is defined %} - {{ helper.date_status('Current tasks', single_task_current_tasks, single_task_current_count, single_task_current_paginator, 'current', isSingleStatus, person) }} - {% endif %} + {% if single_task_current_tasks is defined %} + {{ helper.date_status('Current tasks', single_task_current_tasks, single_task_current_count, single_task_current_paginator, 'current', isSingleStatus, person) }} + {% endif %} - {% if single_task_not_started_tasks is defined %} - {{ helper.date_status('Tasks not started', single_task_not_started_tasks, single_task_not_started_count, single_task_not_started_paginator, 'not_started', isSingleStatus, person) }} - {% endif %} + {% if single_task_not_started_tasks is defined %} + {{ helper.date_status('Tasks not started', single_task_not_started_tasks, single_task_not_started_count, single_task_not_started_paginator, 'not_started', isSingleStatus, person) }} + {% endif %} - {% if single_task_closed_tasks is defined %} - {{ helper.date_status('Closed tasks', single_task_closed_tasks, single_task_closed_count, single_task_closed_paginator, 'closed', isSingleStatus, person) }} - {% endif %} + {% if single_task_closed_tasks is defined %} + {{ helper.date_status('Closed tasks', single_task_closed_tasks, single_task_closed_count, single_task_closed_paginator, 'closed', isSingleStatus, person) }} + {% endif %} - {% if isSingleStatus == false %} - - {% endif %} + {% if isSingleStatus == false %} + + {% endif %} {% endif %} diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/index.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/index.html.twig index 2a33fc10c..1932d7525 100644 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/index.html.twig +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/index.html.twig @@ -15,30 +15,30 @@ * along with this program. If not, see . #} -{% extends '@ChillPerson/Person/layout.html.twig' %} +{% extends layout %} {% set activeRouteKey = 'chill_task_single_task_new' %} -{% block title %}{{ 'Task list'|trans }}{% endblock %} +{% block title %} + {{ 'Task list'|trans }} +{% endblock %} -{% macro thead() %} -{% endmacro %} +{% macro thead() %}{% endmacro %} -{% macro row(task) %} -{% endmacro %} +{% macro row(task) %}{% endmacro %} {% block filtertasks %} -{% if person is not null %} - {% block personcontent %} -
      - {% include 'ChillTaskBundle:SingleTask:_list.html.twig' %} -
      - {% endblock %} -{% else %} - {% block content %} -
      - {% include 'ChillTaskBundle:SingleTask:_list.html.twig' %} -
      - {% endblock %} -{% endif %} + {% if person is not null %} + {% block personcontent %} +
      + {% include 'ChillTaskBundle:SingleTask:_list.html.twig' %} +
      + {% endblock %} + {% else %} + {% block content %} +
      + {% include 'ChillTaskBundle:SingleTask:_list.html.twig' %} +
      + {% endblock %} + {% endif %} {% endblock %} diff --git a/src/Bundle/ChillTaskBundle/config/services/controller.yaml b/src/Bundle/ChillTaskBundle/config/services/controller.yaml index 533c57f47..cfe083e07 100644 --- a/src/Bundle/ChillTaskBundle/config/services/controller.yaml +++ b/src/Bundle/ChillTaskBundle/config/services/controller.yaml @@ -1,11 +1,12 @@ services: - Chill\TaskBundle\Controller\: - resource: '../../Controller' - tags: ['controller.service_arguments'] + Chill\TaskBundle\Controller\: + resource: "../../Controller" + tags: ["controller.service_arguments"] - Chill\TaskBundle\Controller\SingleTaskController: - arguments: - $eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface' - $timelineBuilder: '@chill_main.timeline_builder' - $logger: '@chill.main.logger' - tags: ['controller.service_arguments'] + Chill\TaskBundle\Controller\SingleTaskController: + arguments: + $eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface' + $timelineBuilder: "@chill_main.timeline_builder" + $logger: "@chill.main.logger" + $requestStack: '@Symfony\Component\HttpFoundation\RequestStack' + tags: ["controller.service_arguments"] From 4ad9714e8b7bfa745fdf185d991420ec7ae584fb Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 15 Sep 2021 11:13:09 +0200 Subject: [PATCH 015/209] Menu entry added in PersonMenuBuilder of taskbundle. Removed from menubuilder in Personbundle. Rename file, PersonMenuBuilder to MenuBuilder? --- .../Menu/AccompanyingCourseMenuBuilder.php | 7 --- .../Menu/PersonMenuBuilder.php | 49 ++++++++++++++----- 2 files changed, 38 insertions(+), 18 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php index 4d1245f42..df70b9e64 100644 --- a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php @@ -67,13 +67,6 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface 'id' => $period->getId() ]]) ->setExtras(['order' => 40]); - - $menu->addChild($this->translator->trans('Tasks'), [ - 'route' => 'chill_task_singletask_list', - 'routeParameters' => [ - 'course_id' => $period->getId() - ]]) - ->setExtras(['order' => 50]); } diff --git a/src/Bundle/ChillTaskBundle/Menu/PersonMenuBuilder.php b/src/Bundle/ChillTaskBundle/Menu/PersonMenuBuilder.php index ee0afa497..8c45b0beb 100644 --- a/src/Bundle/ChillTaskBundle/Menu/PersonMenuBuilder.php +++ b/src/Bundle/ChillTaskBundle/Menu/PersonMenuBuilder.php @@ -53,28 +53,55 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface public function buildMenu($menuId, MenuItem $menu, array $parameters) { - /* @var $person \Chill\PersonBundle\Entity\Person */ + switch($menuId) { + case 'person': + $this->buildPersonMenu($menu, $parameters); + break; + case 'accompanyingCourse': + $this->buildAccompanyingCourseMenu($menu, $parameters); + break; + case 'section': + $menu->setExtras('icons', 'tasks'); + break; + default: + throw new \LogicException("this menuid $menuId is not implemented"); + } + } + + public function buildPersonMenu($menu, $parameters){ + + //var $person \Chill\PersonBundle\Entity\Person */ $person = $parameters['person'] ?? null; if ($this->authorizationChecker->isGranted(TaskVoter::SHOW, $person)) { $menu->addChild( $this->translator->trans('Tasks'), [ 'route' => 'chill_task_singletask_list', - 'routeParameters' => $menuId === 'person' ? + 'routeParameters' => [ 'person_id' => $person->getId() ] - : - null, - ]) - ->setExtra('order', 400) - ; - if ($menuId === 'section') { - $menu->setExtra('icons', 'tasks'); - } + ]) + ->setExtra('order', 400); } } + public function buildAccompanyingCourseMenu($menu, $parameters){ + + //var $person \Chill\PersonBundle\Entity\Person */ + $course = $parameters['accompanyingCourse']; + + // if ($this->authorizationChecker->isGranted(TaskVoter::SHOW, $course)) { + $menu->addChild( + $this->translator->trans('Tasks'), [ + 'route' => 'chill_task_singletask_list', + 'routeParameters' => + [ 'course_id' => $course->getId() ] + ]) + ->setExtra('order', 400); + // } + } + public static function getMenuIds(): array { - return ['person']; + return ['person', 'accompanyingCourse']; } } From 537518b66f073ef500ad58984b2b32a9af76495e Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 16 Sep 2021 15:55:09 +0200 Subject: [PATCH 016/209] controller and templates adapted to display list of accompanying period tasks + detailpage of task --- .../Controller/SingleTaskController.php | 150 ++++++++++++++---- .../Menu/PersonMenuBuilder.php | 4 +- .../views/SingleTask/_listCourse.html.twig | 107 +++++++++++++ .../views/SingleTask/_show.html.twig | 110 +++++++++++++ .../views/SingleTask/index.html.twig | 2 +- .../Resources/views/SingleTask/show.html.twig | 119 +------------- .../views/SingleTask/showCourseTask.html.twig | 16 ++ .../translations/messages.fr.yml | 117 +++++++------- 8 files changed, 423 insertions(+), 202 deletions(-) create mode 100644 src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_listCourse.html.twig create mode 100644 src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_show.html.twig create mode 100644 src/Bundle/ChillTaskBundle/Resources/views/SingleTask/showCourseTask.html.twig diff --git a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php index aed805bcf..e98688aa6 100644 --- a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php @@ -32,6 +32,8 @@ use Chill\MainBundle\Timeline\TimelineBuilder; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Repository\AccompanyingPeriodRepository; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; +use Chill\TaskBundle\Form\SingleTaskCourseType; +use Chill\TaskBundle\Repository\AbstractTaskRepository; use Symfony\Component\HttpFoundation\RequestStack; /** @@ -81,7 +83,7 @@ class SingleTaskController extends AbstractController } - public function getEntity() + private function getEntityContext() { if($this->request->query->has('person_id')){ return 'person'; @@ -108,7 +110,7 @@ class SingleTaskController extends AbstractController ->setType('task_default') ; - $entityType = $this->getEntity(); + $entityType = $this->getEntityContext(); if ($entityType !== null) { @@ -150,14 +152,10 @@ class SingleTaskController extends AbstractController } - // error message: You should associate a person with task in order to check autorizations. - // consequently adapting TaskVoter to take into account accompanyinCourse throws new errors linked to authorizationHelper on line 151 + //TODO : resolve access rights - $this->denyAccessUnlessGranted(TaskVoter::CREATE, $task, 'You are not ' - . 'allowed to create this task'); - - // error message: An error has occurred resolving the options of the form "Chill\TaskBundle\Form\SingleTaskType": - //The option "center" with value null is expected to be of type "Chill\MainBundle\Entity\Center", but is of type "null". + // $this->denyAccessUnlessGranted(TaskVoter::CREATE, $task, 'You are not ' + // . 'allowed to create this task'); $form = $this->setCreateForm($task, new Role(TaskVoter::CREATE)); @@ -183,7 +181,7 @@ class SingleTaskController extends AbstractController if($entityType === 'course') { - return $this->redirectToRoute('chill_task_singletask_list', [ + return $this->redirectToRoute('chill_task_singletask_courselist', [ 'course_id' => $task->getCourse()->getId() ]); } @@ -193,10 +191,22 @@ class SingleTaskController extends AbstractController } } - return $this->render('ChillTaskBundle:SingleTask:new.html.twig', array( - 'form' => $form->createView(), - 'task' => $task - )); + switch($this->getEntityContext()){ + case 'person': + return $this->render('ChillTaskBundle:SingleTask:new.html.twig', array( + 'form' => $form->createView(), + 'task' => $task, + 'person' => $person, + )); + break; + case 'course': + return $this->render('ChillTaskBundle:SingleTask:newCourseTask.html.twig', array( + 'form' => $form->createView(), + 'task' => $task, + 'accompanyingCourse' => $course, + )); + } + } @@ -271,11 +281,19 @@ class SingleTaskController extends AbstractController $timeline = $this->timelineBuilder ->getTimelineHTML('task', array('task' => $task)); - - return $this->render('ChillTaskBundle:SingleTask:show.html.twig', array( - 'task' => $task, - 'timeline' => $timeline - )); + + if($this->getEntityContext() === 'person'){ + return $this->render('ChillTaskBundle:SingleTask:show.html.twig', array( + 'task' => $task, + 'timeline' => $timeline + )); + } else { + return $this->render('ChillTaskBundle:SingleTask:showCourseTask.html.twig', array( + 'task' => $task, + 'timeline' => $timeline + )); + } + } @@ -457,10 +475,18 @@ class SingleTaskController extends AbstractController */ protected function setCreateForm(SingleTask $task, Role $role) { - $form = $this->createForm(SingleTaskType::class, $task, [ - 'center' => $task->getCenter(), - 'role' => $role - ]); + if($this->getEntityContext() === 'person'){ + $form = $this->createForm(SingleTaskType::class, $task, [ + 'center' => $task->getCenter(), + 'role' => $role, + ]); + } + + if($this->getEntityContext() === 'course'){ + $form = $this->createForm(SingleTaskCourseType::class, $task, [ + 'center' => $task->getCenter(), + ]); + } $form->add('submit', SubmitType::class); @@ -517,6 +543,7 @@ class SingleTaskController extends AbstractController $viewParams['center'] = null; $params['types'] = null; $viewParams['accompanyingCourse'] = null; + $params['accompanyingCourse'] = null; // Get parameters from url @@ -658,12 +685,23 @@ class SingleTaskController extends AbstractController } // Form for filtering tasks - $form = $formFactory->createNamed(null, SingleTaskListType::class, null, [ - 'person' => $viewParams['person'], - 'method' => Request::METHOD_GET, - 'csrf_protection' => false, - 'add_type' => true - ]); + if($this->getEntityContext() === 'person'){ + $form = $formFactory->createNamed(null, SingleTaskListType::class, null, [ + 'person' => $viewParams['person'], + 'method' => Request::METHOD_GET, + 'csrf_protection' => false, + 'add_type' => true + ]); + } + + if($this->getEntityContext() === 'course'){ + $form = $formFactory->createNamed(null, SingleTaskListType::class, null, [ + 'accompanyingCourse' => $viewParams['accompanyingCourse'], + 'method' => Request::METHOD_GET, + 'csrf_protection' => false, + 'add_type' => true + ]); + } $form->handleRequest($this->request); @@ -728,4 +766,58 @@ class SingleTaskController extends AbstractController ; } + /** + * @Route( + * "/{_locale}/task/singletask/courselist", + * name="chill_task_singletask_courselist") + */ + + public function listCourseTasks( + AccompanyingPeriodRepository $courseRepository, + SingleTaskRepository $taskRepository, + FormFactoryInterface $formFactory, + TranslatorInterface $translator + ): Response + { + + if (!empty($this->request->query->get('course_id', NULL))) { + + $courseId = $this->request->query->getInt('course_id', 0); + $course = $courseRepository->find($courseId); + + if ($course === null) { + throw $this->createNotFoundException("This accompanying course ' $courseId ' does not exist."); + } + + } + + $em = $this->getDoctrine()->getManager(); + + if($course === NULL) { + throw $this->createNotFoundException('Accompanying course not found'); + } + + $tasks = $taskRepository + ->findBy( + array('course' => $course) + ); + + $form = $formFactory->createNamed(null, SingleTaskListType::class, null, [ + 'accompanyingCourse' => $course, + 'method' => Request::METHOD_GET, + 'csrf_protection' => false, + 'add_type' => true + ]); + + return $this->render( + 'ChillTaskBundle:SingleTask:index.html.twig', + [ + 'tasks' => $tasks, + 'accompanyingCourse' => $course, + 'layout' => '@ChillPerson/AccompanyingCourse/layout.html.twig', + 'form' => $form->createView(), + 'title' => $translator->trans('Tasks for this accompanying period') + ]); + } + } diff --git a/src/Bundle/ChillTaskBundle/Menu/PersonMenuBuilder.php b/src/Bundle/ChillTaskBundle/Menu/PersonMenuBuilder.php index 8c45b0beb..26f06d1b2 100644 --- a/src/Bundle/ChillTaskBundle/Menu/PersonMenuBuilder.php +++ b/src/Bundle/ChillTaskBundle/Menu/PersonMenuBuilder.php @@ -89,10 +89,12 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface //var $person \Chill\PersonBundle\Entity\Person */ $course = $parameters['accompanyingCourse']; + //TODO: implement voter again? + // if ($this->authorizationChecker->isGranted(TaskVoter::SHOW, $course)) { $menu->addChild( $this->translator->trans('Tasks'), [ - 'route' => 'chill_task_singletask_list', + 'route' => 'chill_task_singletask_courselist', 'routeParameters' => [ 'course_id' => $course->getId() ] ]) diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_listCourse.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_listCourse.html.twig new file mode 100644 index 000000000..16c907e4c --- /dev/null +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_listCourse.html.twig @@ -0,0 +1,107 @@ +{% if tasks|length > 0 %} +

      {{ title|trans }}

      + + + + {% for task in tasks %} + + + + + {% endfor %} + +
      +
      + {{ task.title }} +
      + +
      + {{ task_workflow_metadata(task, 'definition.name')|trans }} +
      + +
      + {% for place in workflow_marked_places(task) %} + {{ place|trans }} + {% endfor %} + {% if task.assignee is not null %} +
      + {{ 'By'|trans }} : + {{ task.assignee.username }}
      + {% endif %} +
      + + {% if task.startDate is not null or task.warningDate is not null or task.endDate is not null %} +
      +
        + {% if task.startDate is not null %} +
      • + + {{ task.startDate|format_date('medium') }} +
      • + {% endif %} + {% if task.warningDate is not null %} +
      • + + {{ task.warningDate|format_date('medium') }} +
      • + {% endif %} + {% if task.endDate is not null %} +
      • + + {{ task.endDate|format_date('medium') }} +
      • + {% endif %} +
      +
      + {% endif %} + +
      + +
      +{% endif %} + + diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_show.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_show.html.twig new file mode 100644 index 000000000..a8905285a --- /dev/null +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_show.html.twig @@ -0,0 +1,110 @@ +
      + +

      {{ 'Task'|trans }}

      + +

      {{ task.title }} + {% for place in workflow_marked_places(task) %} + {{ place|trans }} + {% endfor %} +

      + +
      + +
      {{ 'Description'|trans }}
      +
      + {% if task.description is empty %} + {{"No description"|trans}} + {% else %} +
      + {{ task.description|chill_markdown_to_html }} +
      + {% endif %} +
      + +
      {{ 'Assignee'|trans }}
      +
      + {% if task.assignee is null %} + {{"No one assignee"|trans}} + {% else %} + {{ task.assignee }} + {% endif %} +
      + +
      {{ 'Scope'|trans }}
      +
      + {{ task.scope.name|localize_translatable_string }} +
      + +

      {{"Dates"|trans}}

      + {% if task.startDate is null and task.endDate is null and task.warningDate is null %} +
      +
      + {{"No dates specified"|trans}} +
      + + {% else %} + {% if task.startDate is not null %} +
      {{ 'Start'|trans }}
      +
      {{ task.startDate|format_date('long') }}
      + {% endif %} + + {% if task.endDate is not null %} +
      {{ 'End'|trans }}
      +
      {{ task.endDate|format_date('long') }}
      + {% endif %} + + {% if task.warningDate is not null %} +
      {{ 'Warning'|trans }}
      +
      {{ task.warningDate|format_date('long') }}
      + {% endif %} + + {% endif %} +
      + +{% if timeline is not null %} +

      {{"Timeline"|trans}}

      + {{ timeline|raw }} +{% endif %} + +
      diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/index.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/index.html.twig index 1932d7525..4c0b9dc84 100644 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/index.html.twig +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/index.html.twig @@ -37,7 +37,7 @@ {% else %} {% block content %}
      - {% include 'ChillTaskBundle:SingleTask:_list.html.twig' %} + {% include 'ChillTaskBundle:SingleTask:_listCourse.html.twig' %}
      {% endblock %} {% endif %} diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/show.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/show.html.twig index 8cfa1ea33..19bf70777 100644 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/show.html.twig +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/show.html.twig @@ -16,124 +16,17 @@ #} {% extends "@ChillPerson/Person/layout.html.twig" %} + {% set activeRouteKey = 'chill_task_single_task_show' %} {% set person = task.person %} -{% block title %}{{ 'Task'|trans }}{% endblock %} +{% block title %} + {{ 'Task'|trans }} +{% endblock %} {% block personcontent %} -
      - -

      {{ 'Task'|trans }}

      - -

      {{ task.title }} {% for place in workflow_marked_places(task) %} - {{ place|trans }} - {% endfor %}

      - -
      - -
      {{ 'Description'|trans }}
      -
      - {% if task.description is empty %} - {{"No description"|trans}} - {% else %} -
      - {{ task.description|chill_markdown_to_html }} -
      - {% endif %} -
      - -
      {{ 'Assignee'|trans }}
      -
      - {% if task.assignee is null %} - {{"No one assignee"|trans}} - {% else %} - {{ task.assignee }} - {% endif %} -
      - -
      {{ 'Scope'|trans }}
      -
      {{ task.scope.name|localize_translatable_string }}
      - -

      {{"Dates"|trans}}

      - {% if task.startDate is null and task.endDate is null and task.warningDate is null %} -
      -
      {{"No dates specified"|trans}}
      - - {% else %} - {% if task.startDate is not null %} -
      {{ 'Start'|trans }}
      -
      {{ task.startDate|format_date('long') }}
      - {% endif %} - - {% if task.endDate is not null %} -
      {{ 'End'|trans }}
      -
      {{ task.endDate|format_date('long') }}
      - {% endif %} - - {% if task.warningDate is not null %} -
      {{ 'Warning'|trans }}
      -
      {{ task.warningDate|format_date('long') }}
      - {% endif %} - - {% endif %} -
      - - {% if timeline is not null %} -

      {{"Timeline"|trans}}

      - {{ timeline|raw }} - {% endif %} - - - -
      + + {% include 'ChillTaskBundle:SingleTask:_show.html.twig' %} {% endblock %} diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/showCourseTask.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/showCourseTask.html.twig new file mode 100644 index 000000000..643617a55 --- /dev/null +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/showCourseTask.html.twig @@ -0,0 +1,16 @@ +{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %} + + +{% set activeRouteKey = 'chill_task_single_task_show' %} +{% set accompanyingCourse = task.course %} + +{% block title %} + {{ 'Task'|trans }} +{% endblock %} + + +{% block content %} + + {% include 'ChillTaskBundle:SingleTask:_show.html.twig' %} + +{% endblock %} diff --git a/src/Bundle/ChillTaskBundle/translations/messages.fr.yml b/src/Bundle/ChillTaskBundle/translations/messages.fr.yml index 71bc22612..7af9d450d 100644 --- a/src/Bundle/ChillTaskBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillTaskBundle/translations/messages.fr.yml @@ -1,53 +1,54 @@ -Tasks: 'Tâches' -'New task': 'Nouvelle tâche' -'Add a new task': 'Ajouter une nouvelle tâche' +Tasks: "Tâches" +"New task": "Nouvelle tâche" +"Add a new task": "Ajouter une nouvelle tâche" Title: Titre Description: Description -Assignee: 'Personne assignée' +Assignee: "Personne assignée" Scope: Cercle -'Start date': 'Date de début' -'End date': "Date d'échéance" -'Warning date': "Date d'avertissement" -'Warning interval': "Délai d'avertissement avant la date d'échéance" -'Unknown dates': 'Dates non spécifiées' -'N': '' -'Unit': '' +"Start date": "Date de début" +"End date": "Date d'échéance" +"Warning date": "Date d'avertissement" +"Warning interval": "Délai d'avertissement avant la date d'échéance" +"Unknown dates": "Dates non spécifiées" +"N": "" +"Unit": "" Task: Tâche Details: Détails Person: Personne Date: Date Dates: Dates User: Utilisateur -'Task list': 'Liste des tâches' -'Tasks with expired deadline': "Tâches avec une date d'échéance dépassée" -'Tasks with warning deadline reached': "Tâches avec une date d'avertissement atteinte" -'Current tasks': 'Tâches en cours' -'Closed tasks': Tâches terminées -'Tasks not started': 'Tâches non commencées' -'Task start date': 'Date de début' -'Task warning date': "Date d'avertissement" -'Task end date': "Date d'échéance" -'Start': 'Début' -'Warning': 'Avertissement' -'End': 'Échéance' -'Task type': 'Type' -'Task status': 'Statut' -'Edit the task': 'Modifier la tâche' -'Edit task': 'Modifier la tâche' -'Save task': 'Enregistrer la tâche' -'View the task': 'Voir la tâche' -'Update the task': 'Mettre à jour la tâche' -'Remove task': 'Supprimer la tâche' -'Delete': 'Supprimer' -'Change task status': 'Changer le statut' +"Task list": "Liste des tâches" +"Tasks with expired deadline": "Tâches avec une date d'échéance dépassée" +"Tasks with warning deadline reached": "Tâches avec une date d'avertissement atteinte" +"Current tasks": "Tâches en cours" +"Closed tasks": Tâches terminées +"Tasks not started": "Tâches non commencées" +"Task start date": "Date de début" +"Task warning date": "Date d'avertissement" +"Task end date": "Date d'échéance" +"Start": "Début" +"Warning": "Avertissement" +"End": "Échéance" +"Task type": "Type" +"Task status": "Statut" +"Edit the task": "Modifier la tâche" +"Edit task": "Modifier la tâche" +"Save task": "Enregistrer la tâche" +"View the task": "Voir la tâche" +"Update the task": "Mettre à jour la tâche" +"Remove task": "Supprimer la tâche" +"Delete": "Supprimer" +"Change task status": "Changer le statut" 'Are you sure you want to remove the task about "%name%" ?': 'Êtes-vous sûr·e de vouloir supprimer la tâche de "%name%"?' -'See more': 'Voir plus' -'Associated tasks': 'Tâches associées' -'My tasks': 'Mes tâches' -'No description': 'Pas de description' -'No dates specified': 'Dates non spécifiées' -'No one assignee': 'Aucune personne assignée' -'Task types': Types de tâches +"See more": "Voir plus" +"Associated tasks": "Tâches associées" +"My tasks": "Mes tâches" +"Tasks for this accompanying period": "Tâches pour ce parcours d'accompagnement" +"No description": "Pas de description" +"No dates specified": "Dates non spécifiées" +"No one assignee": "Aucune personne assignée" +"Task types": Types de tâches Days: Jour(s) Weeks: Semaine(s) Months: Mois @@ -63,36 +64,36 @@ For person: Pour By: Par # transitions - default task definition -'new': 'nouvelle' -'in_progress': 'en cours' -'closed': 'fermée' -'canceled': 'supprimée' +"new": "nouvelle" +"in_progress": "en cours" +"closed": "fermée" +"canceled": "supprimée" start: démarrer close: clotûrer cancel: annuler Start_verb: Démarrer Close_verb: Clotûrer Set this task to cancel state: Marquer cette tâche comme annulée -'%user% has closed the task': '%user% a fermé la tâche' -'%user% has canceled the task': '%user% a annulé la tâche' -'%user% has started the task': '%user% a commencé la tâche' -'%user% has created the task': '%user% a introduit la tâche' +"%user% has closed the task": "%user% a fermé la tâche" +"%user% has canceled the task": "%user% a annulé la tâche" +"%user% has started the task": "%user% a commencé la tâche" +"%user% has created the task": "%user% a introduit la tâche" Are you sure you want to close this task ?: Êtes-vous sûrs de vouloir clotûrer cette tâche ? Are you sure you want to cancel this task ?: Êtes-vous sûrs de vouloir annuler cette tâche ? Are you sure you want to start this task ?: Êtes-vous sûrs de vouloir démarrer cette tâche ? #Flash messages -'The task is created': 'La tâche a été créée' -'There is no tasks.': Aucune tâche. -'The task has been successfully removed.': 'La tâche a bien été supprimée' -'This form contains errors': 'Ce formulaire contient des erreurs' -'The task has been updated': 'La tâche a été mise à jour' -'The transition is successfully applied': 'La transition a bien été effectuée' -'The transition could not be applied': "La transition n'a pas pu être appliquée" +"The task is created": "La tâche a été créée" +"There is no tasks.": Aucune tâche. +"The task has been successfully removed.": "La tâche a bien été supprimée" +"This form contains errors": "Ce formulaire contient des erreurs" +"The task has been updated": "La tâche a été mise à jour" +"The transition is successfully applied": "La transition a bien été effectuée" +"The transition could not be applied": "La transition n'a pas pu être appliquée" #widget -'%number% tasks over deadline': '{0} Aucune tâche dépassée|{1} Une tâche dépassée | ]1,Inf[ %count% tâches dépassées' -'%number% tasks near deadline': '{0} Aucune tâche en rappel|{1} Une tâche en rappel | ]1,Inf[ %count% tâches en rappel' +"%number% tasks over deadline": "{0} Aucune tâche dépassée|{1} Une tâche dépassée | ]1,Inf[ %count% tâches dépassées" +"%number% tasks near deadline": "{0} Aucune tâche en rappel|{1} Une tâche en rappel | ]1,Inf[ %count% tâches en rappel" #title My tasks near deadline: Mes tâches à échéance proche @@ -107,4 +108,4 @@ All centers: Tous les centres CHILL_TASK_TASK_CREATE: Ajouter une tâche CHILL_TASK_TASK_DELETE: Supprimer une tâche CHILL_TASK_TASK_SHOW: Voir une tâche -CHILL_TASK_TASK_UPDATE: Modifier une tâche \ No newline at end of file +CHILL_TASK_TASK_UPDATE: Modifier une tâche From 6e3ce06fcf9faaf9c50c1953e9150cebcca55b06 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 17 Sep 2021 14:33:42 +0200 Subject: [PATCH 017/209] new/show/edit/delete/list functionality added for accompanyingperiod task --- .../Entity/AccompanyingPeriod.php | 10 ++ .../Controller/SingleTaskController.php | 143 ++++++++++++------ .../ChillTaskBundle/Entity/AbstractTask.php | 12 ++ .../ChillTaskBundle/Form/SingleTaskType.php | 7 +- ...{PersonMenuBuilder.php => MenuBuilder.php} | 0 .../views/SingleTask/_edit.html.twig | 25 +++ .../Resources/views/SingleTask/_new.html.twig | 30 ++++ .../views/SingleTask/_show.html.twig | 4 +- .../confirm_deleteCourseTask.html.twig | 19 +++ .../Resources/views/SingleTask/edit.html.twig | 39 +---- .../views/SingleTask/editCourseTask.html.twig | 14 ++ .../Resources/views/SingleTask/new.html.twig | 33 +--- .../views/SingleTask/newCourseTask.html.twig | 12 ++ .../Security/Authorization/TaskVoter.php | 9 +- .../translations/messages.fr.yml | 1 + 15 files changed, 242 insertions(+), 116 deletions(-) rename src/Bundle/ChillTaskBundle/Menu/{PersonMenuBuilder.php => MenuBuilder.php} (100%) create mode 100644 src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_edit.html.twig create mode 100644 src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_new.html.twig create mode 100644 src/Bundle/ChillTaskBundle/Resources/views/SingleTask/confirm_deleteCourseTask.html.twig create mode 100644 src/Bundle/ChillTaskBundle/Resources/views/SingleTask/editCourseTask.html.twig create mode 100644 src/Bundle/ChillTaskBundle/Resources/views/SingleTask/newCourseTask.html.twig diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php index 14fb26f1a..82b2ee10c 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php @@ -28,6 +28,7 @@ use Chill\MainBundle\Entity\HasCentersInterface; use Chill\MainBundle\Entity\HasScopesInterface; use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Entity\Address; +use Chill\MainBundle\Entity\Center; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork; use Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive; use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment; @@ -977,6 +978,15 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface return $this->addressLocation; } + public function getCenter(): ?Center + { + if (count($this->getPersons()) === 0){ + return null; + } else { + return $this->getPersons()->first()->getCenter(); + } + } + /** * @Groups({"write"}) */ diff --git a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php index e98688aa6..456699091 100644 --- a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php @@ -6,7 +6,6 @@ use Chill\PersonBundle\Privacy\PrivacyEvent; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Routing\Annotation\Route; -use Doctrine\ORM\EntityManager; use Chill\PersonBundle\Entity\Person; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -22,7 +21,6 @@ use Chill\TaskBundle\Repository\SingleTaskRepository; use Chill\MainBundle\Entity\User; use Chill\PersonBundle\Security\Authorization\PersonVoter; use Chill\PersonBundle\Repository\PersonRepository; -use Chill\MainBundle\Entity\UserRepository; use Chill\TaskBundle\Event\TaskEvent; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\Translation\TranslatorInterface; @@ -32,8 +30,6 @@ use Chill\MainBundle\Timeline\TimelineBuilder; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Repository\AccompanyingPeriodRepository; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; -use Chill\TaskBundle\Form\SingleTaskCourseType; -use Chill\TaskBundle\Repository\AbstractTaskRepository; use Symfony\Component\HttpFoundation\RequestStack; /** @@ -205,6 +201,7 @@ class SingleTaskController extends AbstractController 'task' => $task, 'accompanyingCourse' => $course, )); + break; } } @@ -281,8 +278,9 @@ class SingleTaskController extends AbstractController $timeline = $this->timelineBuilder ->getTimelineHTML('task', array('task' => $task)); + - if($this->getEntityContext() === 'person'){ + if($task->getContext() instanceof Person){ return $this->render('ChillTaskBundle:SingleTask:show.html.twig', array( 'task' => $task, 'timeline' => $timeline @@ -311,7 +309,7 @@ class SingleTaskController extends AbstractController $em = $this->getDoctrine()->getManager(); $task = $em->getRepository(SingleTask::class)->find($id); - if ($task->getPerson() !== null) { + if ($task->getContext() instanceof Person) { $personId = $task->getPerson()->getId(); if ($personId === null) { return new Response("You must provide a person_id", Response::HTTP_BAD_REQUEST); @@ -324,7 +322,21 @@ class SingleTaskController extends AbstractController if ($person === null) { throw $this->createNotFoundException("Invalid person id"); } + } else { + $courseId = $task->getCourse()->getId(); + if ($courseId === null) { + return new Response("You must provide a course_id", Response::HTTP_BAD_REQUEST); + } + + $course = $this->getDoctrine()->getManager() + ->getRepository(AccompanyingPeriod::class) + ->find($courseId); + + if ($course === null) { + throw $this->createNotFoundException("Invalid accompanying period id"); + } } + $this->denyAccessUnlessGranted(TaskVoter::UPDATE, $task, 'You are not ' . 'allowed to edit this task'); @@ -351,19 +363,25 @@ class SingleTaskController extends AbstractController $this->addFlash('success', $translator ->trans("The task has been updated")); - - $event = new PrivacyEvent($person, array( + + if($task->getContext() instanceof Person){ + $event = new PrivacyEvent($person, array( 'element_class' => SingleTask::class, 'element_id' => $task->getId(), 'action' => 'update' - )); - $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); - - return $this->redirectToRoute( - 'chill_task_singletask_list', - $this->request->query->get('list_params', []) - ); + )); + $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); + return $this->redirectToRoute( + 'chill_task_singletask_list', + $this->request->query->get('list_params', []) + ); + } else { + return $this->redirectToRoute( + 'chill_task_singletask_courselist', + $this->request->query->get('list_params', []) + ); + } } else { $this->addFlash('error', $translator->trans("This form contains errors")); } @@ -375,17 +393,26 @@ class SingleTaskController extends AbstractController return $event->getResponse(); } - $event = new PrivacyEvent($person, array( - 'element_class' => SingleTask::class, - 'element_id' => $task->getId(), - 'action' => 'edit' - )); - $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); - - return $this->render('ChillTaskBundle:SingleTask:edit.html.twig', array( - 'task' => $task, - 'form' => $form->createView() - )); + if($task->getContext() instanceof Person){ + $event = new PrivacyEvent($person, array( + 'element_class' => SingleTask::class, + 'element_id' => $task->getId(), + 'action' => 'edit' + )); + $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); + + return $this->render('ChillTaskBundle:SingleTask:edit.html.twig', array( + 'task' => $task, + 'form' => $form->createView() + )); + } else { + return $this->render('ChillTaskBundle:SingleTask:editCourseTask.html.twig', array( + 'task' => $task, + 'form' => $form->createView(), + 'accompanyingCourse' => $course + )); + } + } @@ -422,8 +449,22 @@ class SingleTaskController extends AbstractController throw $this->createNotFoundException("Invalid person id"); } + } else { + $courseId = $task->getCourse()->getId(); + if ($courseId === null){ + return new Response("You must provide a course_id", Response::HTTP_BAD_REQUEST); + } + + $course = $this->getDoctrine()->getManager() + ->getRepository(AccompanyingPeriod::class) + ->find($courseId); + + if($course === null){ + throw $this->createNotFoundException("Invalid accompanying period id"); + } } + $this->denyAccessUnlessGranted(TaskVoter::DELETE, $task, 'You are not ' . 'allowed to delete this task'); @@ -452,19 +493,35 @@ class SingleTaskController extends AbstractController $this->addFlash('success', $translator ->trans("The task has been successfully removed.")); - return $this->redirect($this->generateUrl( - 'chill_task_singletask_list', - $request->query->get('list_params', [ - 'person_id' => $person->getId() - ]))); + if($task->getContext() instanceof Person){ + return $this->redirect($this->generateUrl( + 'chill_task_singletask_list', + $request->query->get('list_params', [ + 'person_id' => $person->getId() + ]))); + } else { + return $this->redirect($this->generateUrl( + 'chill_task_singletask_courselist', + $request->query->get('list_params', [ + 'course_id' => $course->getId() + ]))); + } } } + if($task->getContext() instanceof Person){ + return $this->render('ChillTaskBundle:SingleTask:confirm_delete.html.twig', array( + 'task' => $task, + 'delete_form' => $form->createView() + )); + } else { + return $this->render('ChillTaskBundle:SingleTask:confirm_deleteCourseTask.html.twig', array( + 'task' => $task, + 'delete_form' => $form->createView(), + 'accompanyingCourse' => $course + )); + } - return $this->render('ChillTaskBundle:SingleTask:confirm_delete.html.twig', array( - 'task' => $task, - 'delete_form' => $form->createView() - )); } /** @@ -475,18 +532,10 @@ class SingleTaskController extends AbstractController */ protected function setCreateForm(SingleTask $task, Role $role) { - if($this->getEntityContext() === 'person'){ - $form = $this->createForm(SingleTaskType::class, $task, [ - 'center' => $task->getCenter(), - 'role' => $role, - ]); - } - - if($this->getEntityContext() === 'course'){ - $form = $this->createForm(SingleTaskCourseType::class, $task, [ - 'center' => $task->getCenter(), - ]); - } + $form = $this->createForm(SingleTaskType::class, $task, [ + 'center' => $task->getCenter(), + 'role' => $role, + ]); $form->add('submit', SubmitType::class); diff --git a/src/Bundle/ChillTaskBundle/Entity/AbstractTask.php b/src/Bundle/ChillTaskBundle/Entity/AbstractTask.php index 649de0422..57a194ef8 100644 --- a/src/Bundle/ChillTaskBundle/Entity/AbstractTask.php +++ b/src/Bundle/ChillTaskBundle/Entity/AbstractTask.php @@ -248,11 +248,23 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface { if ($this->getPerson() instanceof Person) { return $this->getPerson()->getCenter(); + } else { + return $this->getCourse()->getCenter(); } return null; } + + public function getContext() + { + // if ($this->getCourse() instanceof AccompanyingPeriod){ + // return $this->getCourse(); + // } else { + // return $this->getPerson(); + // } + return $this->getPerson() ?? $this->getCourse(); + } public function getScope(): ?\Chill\MainBundle\Entity\Scope { diff --git a/src/Bundle/ChillTaskBundle/Form/SingleTaskType.php b/src/Bundle/ChillTaskBundle/Form/SingleTaskType.php index 16f000aa2..5802512b7 100644 --- a/src/Bundle/ChillTaskBundle/Form/SingleTaskType.php +++ b/src/Bundle/ChillTaskBundle/Form/SingleTaskType.php @@ -48,11 +48,11 @@ class SingleTaskType extends AbstractType 'center' => $options['center'], 'role' => $options['role'], 'placeholder' => 'Not assigned' - ]) + ]) ->add('circle', ScopePickerType::class, [ 'center' => $options['center'], 'role' => $options['role'] - ]) + ]) ->add('startDate', ChillDateType::class, [ 'required' => false ]) @@ -61,8 +61,7 @@ class SingleTaskType extends AbstractType ]) ->add('warningInterval', DateIntervalType::class, [ 'required' => false - ]) - ; + ]); } public function configureOptions(OptionsResolver $resolver) diff --git a/src/Bundle/ChillTaskBundle/Menu/PersonMenuBuilder.php b/src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php similarity index 100% rename from src/Bundle/ChillTaskBundle/Menu/PersonMenuBuilder.php rename to src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_edit.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_edit.html.twig new file mode 100644 index 000000000..98b070114 --- /dev/null +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_edit.html.twig @@ -0,0 +1,25 @@ +
      + +

      {{ 'Edit task'|trans }}

      + + {{ form_start(form) }} + + {{ form_row(form.title) }} + {{ form_row(form.description) }} + {{ form_row(form.assignee) }} + {{ form_row(form.circle) }} + {{ form_row(form.startDate) }} + {{ form_row(form.endDate) }} + {{ form_row(form.warningInterval) }} + +
        +
      • + + {{ 'Cancel'|trans }} +
      • +
      • + {{ form_widget(form.submit, { 'label': 'Save task', 'attr': {'class' : 'btn btn-update'}})}} +
      • +
      + {{ form_end(form) }} +
      diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_new.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_new.html.twig new file mode 100644 index 000000000..7cb19b19f --- /dev/null +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_new.html.twig @@ -0,0 +1,30 @@ +
      + +

      {{ 'New task'|trans }}

      + + {{ form_start(form) }} + + {{ form_errors(form) }} + + {{ form_row(form.title) }} + {{ form_row(form.description) }} + {{ form_row(form.assignee) }} + {{ form_row(form.circle) }} + {{ form_row(form.startDate) }} + {{ form_row(form.endDate) }} + {{ form_row(form.warningInterval) }} + +
        +
      • + + {{'Cancel'|trans}} + +
      • +
      • + {{ form_widget(form.submit, { 'label': 'Add a new task'|trans, 'attr': {'class': 'btn btn-save'} }) }} +
      • +
      + + {{ form_end(form) }} + +
      diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_show.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_show.html.twig index a8905285a..f73f2740d 100644 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_show.html.twig +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_show.html.twig @@ -68,8 +68,8 @@
      • - - {{ app.request.query.get('returnLabel')|default('Back to the list'|trans) }} + + {{'Back to the list'|trans}}
      • diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/confirm_deleteCourseTask.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/confirm_deleteCourseTask.html.twig new file mode 100644 index 000000000..49857188c --- /dev/null +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/confirm_deleteCourseTask.html.twig @@ -0,0 +1,19 @@ +{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %} + +{% set activeRouteKey = 'chill_task_task_list' %} +{% set course = task.course %} + +{% block title 'Remove task'|trans %} + +{% block content %} + + {{ include('@ChillMain/Util/confirmation_template.html.twig', + { + 'title' : 'Remove task'|trans, + 'confirm_question' : 'Are you sure you want to remove the task about accompanying period "%id%" ?'|trans({ '%id%' : course.id } ), + 'cancel_route' : 'chill_task_singletask_courselist', + 'cancel_parameters' : app.request.query.get('list_params', { } ), + 'form' : delete_form, + } ) }} + +{% endblock %} diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/edit.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/edit.html.twig index 67604f015..590740cf0 100644 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/edit.html.twig +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/edit.html.twig @@ -14,46 +14,17 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . #} -{% extends "@ChillPerson/Person/layout.html.twig" %} +{% extends person is defined ? "@ChillPerson/Person/layout.html.twig" %} {% set activeRouteKey = 'chill_task_single_task_edit' %} {% set person = task.person %} -{% block title %}{{ 'Edit task'|trans }}{% endblock %} +{% block title %} + {{ 'Edit task'|trans }} +{% endblock %} {% block personcontent %} -
        - -

        {{ 'Edit task'|trans }}

        - {{ form_start(form) }} + {% include 'ChillTaskBundle:SingleTask:_edit.html.twig' %} - {{ form_row(form.title) }} - {{ form_row(form.description) }} - {{ form_row(form.assignee) }} - {{ form_row(form.circle) }} - {{ form_row(form.startDate) }} - {{ form_row(form.endDate) }} - {{ form_row(form.warningInterval) }} - - - - {{ form_end(form) }} - -
        {% endblock %} diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/editCourseTask.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/editCourseTask.html.twig new file mode 100644 index 000000000..1805761ae --- /dev/null +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/editCourseTask.html.twig @@ -0,0 +1,14 @@ +{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %} + +{% set activeRouteKey = 'chill_task_single_task_edit' %} +{% set course = task.course %} + +{% block title %} + {{ 'Edit task'|trans }} +{% endblock %} + +{% block content %} + + {% include 'ChillTaskBundle:SingleTask:_edit.html.twig' %} + +{% endblock %} diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/new.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/new.html.twig index 8f6ba2a4b..2b59fd5bf 100644 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/new.html.twig +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/new.html.twig @@ -14,37 +14,16 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . #} -{% extends "@ChillPerson/Person/layout.html.twig" %} +{% extends person is defined ? "@ChillPerson/Person/layout.html.twig" : "@ChillPerson/AccompanyingCourse/layout.html.twig" %} {% set activeRouteKey = 'chill_task_single_task_new' %} {% set person = task.person %} -{% block title %}{{ 'New task'|trans }}{% endblock %} +{% block title %} + {{ 'New task'|trans }} +{% endblock %} + {% block personcontent %} -
        - -

        {{ 'New task'|trans }}

        - - {{ form_start(form) }} - - {{ form_errors(form) }} - - {{ form_row(form.title) }} - {{ form_row(form.description) }} - {{ form_row(form.assignee) }} - {{ form_row(form.circle) }} - {{ form_row(form.startDate) }} - {{ form_row(form.endDate) }} - {{ form_row(form.warningInterval) }} - -
          -
        • - {{ form_widget(form.submit, { 'label': 'Add a new task'|trans, 'attr': {'class': 'btn btn-save'} }) }} -
        • -
        - - {{ form_end(form) }} - -
        + {% include 'ChillTaskBundle:SingleTask:_new.html.twig' %} {% endblock %} diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/newCourseTask.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/newCourseTask.html.twig new file mode 100644 index 000000000..083c0795c --- /dev/null +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/newCourseTask.html.twig @@ -0,0 +1,12 @@ +{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %} + +{% set activeRouteKey = 'chill_task_single_task_new' %} +{# {% set person = task.person %} #} + +{% block title %} + {{ 'New task'|trans }} +{% endblock %} + +{% block content %} + {% include 'ChillTaskBundle:SingleTask:_new.html.twig' %} +{% endblock %} diff --git a/src/Bundle/ChillTaskBundle/Security/Authorization/TaskVoter.php b/src/Bundle/ChillTaskBundle/Security/Authorization/TaskVoter.php index 2f760a84b..f5e1d167f 100644 --- a/src/Bundle/ChillTaskBundle/Security/Authorization/TaskVoter.php +++ b/src/Bundle/ChillTaskBundle/Security/Authorization/TaskVoter.php @@ -32,7 +32,9 @@ use Psr\Log\LoggerInterface; use Chill\MainBundle\Security\ProvideRoleHierarchyInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Chill\MainBundle\Entity\User; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; +use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Chill\TaskBundle\Security\Authorization\AuthorizationEvent; @@ -146,14 +148,15 @@ final class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchy /* if ($subject instanceof AbstractTask) { - if ($subject->getPerson() === null) { + $associated = $subject->getPerson() ?? $subject->getCourse(); + if ($associated === null) { throw new \LogicException("You should associate a person with task " . "in order to check autorizations"); } $person = $subject->getPerson(); } elseif ($subject instanceof Person) { - $person = $subject; + $associated = $subject; } else { // subject is null. We check that at least one center is reachable $centers = $this->authorizationHelper->getReachableCenters($token->getUser(), new Role($attribute)); @@ -168,6 +171,8 @@ final class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchy if (NULL === $center) { return false; + } elseif ($associated instanceof AccompanyingPeriod && !$this->accessDecisionManager->decide($token, [AccompanyingPeriodVoter::SEE], $associated)) { + return false; } return $this->authorizationHelper->userHasAccess( diff --git a/src/Bundle/ChillTaskBundle/translations/messages.fr.yml b/src/Bundle/ChillTaskBundle/translations/messages.fr.yml index 7af9d450d..50af895e7 100644 --- a/src/Bundle/ChillTaskBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillTaskBundle/translations/messages.fr.yml @@ -41,6 +41,7 @@ User: Utilisateur "Delete": "Supprimer" "Change task status": "Changer le statut" 'Are you sure you want to remove the task about "%name%" ?': 'Êtes-vous sûr·e de vouloir supprimer la tâche de "%name%"?' +'Are you sure you want to remove the task about accompanying period "%id%" ?': 'Êtes-vous sûr·e de vouloir supprimer la tâche du parcours "%id%"?' "See more": "Voir plus" "Associated tasks": "Tâches associées" "My tasks": "Mes tâches" From 34dd35f2e266a232556b74be4a41492a63cd7037 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 17 Sep 2021 14:49:43 +0200 Subject: [PATCH 018/209] Changed name of PersonMenuBuilder More general name since it also contains the AccompanyingPeriod task menu entry now. --- .../ChillTaskBundle/Menu/MenuBuilder.php | 8 ++-- .../ChillTaskBundle/config/services/menu.yaml | 44 +++++++++---------- 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php b/src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php index 26f06d1b2..9b1890958 100644 --- a/src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php +++ b/src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php @@ -28,7 +28,7 @@ use Symfony\Component\Translation\TranslatorInterface; * * @author Julien Fastré */ -class PersonMenuBuilder implements LocalMenuBuilderInterface +class MenuBuilder implements LocalMenuBuilderInterface { /** * @@ -86,12 +86,10 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface public function buildAccompanyingCourseMenu($menu, $parameters){ - //var $person \Chill\PersonBundle\Entity\Person */ $course = $parameters['accompanyingCourse']; - //TODO: implement voter again? - // if ($this->authorizationChecker->isGranted(TaskVoter::SHOW, $course)) { + if ($this->authorizationChecker->isGranted(TaskVoter::SHOW, $course)) { $menu->addChild( $this->translator->trans('Tasks'), [ 'route' => 'chill_task_singletask_courselist', @@ -99,7 +97,7 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface [ 'course_id' => $course->getId() ] ]) ->setExtra('order', 400); - // } + } } public static function getMenuIds(): array diff --git a/src/Bundle/ChillTaskBundle/config/services/menu.yaml b/src/Bundle/ChillTaskBundle/config/services/menu.yaml index b4ff7a421..75726fcf4 100644 --- a/src/Bundle/ChillTaskBundle/config/services/menu.yaml +++ b/src/Bundle/ChillTaskBundle/config/services/menu.yaml @@ -1,23 +1,23 @@ services: - Chill\TaskBundle\Menu\UserMenuBuilder: - arguments: - $tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface' - $counter: '@Chill\TaskBundle\Templating\UI\CountNotificationTask' - $translator: '@Symfony\Component\Translation\TranslatorInterface' - $authorizationChecker: '@Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface' - tags: - - { name: 'chill.menu_builder' } - - Chill\TaskBundle\Menu\PersonMenuBuilder: - arguments: - $authorizationChecker: '@Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface' - $translator: '@Symfony\Component\Translation\TranslatorInterface' - tags: - - { name: 'chill.menu_builder' } - - Chill\TaskBundle\Menu\SectionMenuBuilder: - arguments: - $authorizationChecker: '@Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface' - $translator: '@Symfony\Component\Translation\TranslatorInterface' - tags: - - { name: 'chill.menu_builder' } + Chill\TaskBundle\Menu\UserMenuBuilder: + arguments: + $tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface' + $counter: '@Chill\TaskBundle\Templating\UI\CountNotificationTask' + $translator: '@Symfony\Component\Translation\TranslatorInterface' + $authorizationChecker: '@Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface' + tags: + - { name: "chill.menu_builder" } + + Chill\TaskBundle\Menu\MenuBuilder: + arguments: + $authorizationChecker: '@Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface' + $translator: '@Symfony\Component\Translation\TranslatorInterface' + tags: + - { name: "chill.menu_builder" } + + Chill\TaskBundle\Menu\SectionMenuBuilder: + arguments: + $authorizationChecker: '@Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface' + $translator: '@Symfony\Component\Translation\TranslatorInterface' + tags: + - { name: "chill.menu_builder" } From 4c47a354572054f7f4f5bb0dbe8b419e05dbd752 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 17 Sep 2021 14:53:15 +0200 Subject: [PATCH 019/209] Fix SingleTaskListType accompanyingCourse also defined as a form option --- src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php b/src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php index 99e8ddb42..634035f96 100644 --- a/src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php +++ b/src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php @@ -284,6 +284,7 @@ class SingleTaskListType extends AbstractType ->setDefined('person') ->setDefault('person', null) ->setAllowedTypes('person', [Person::class, 'null']) + ->setDefined('accompanyingCourse') ->setDefined('add_status') ->setDefault('add_status', false) ->setAllowedTypes('add_status', ['bool']) From cb5b45cbe8b4754ac9f8bb6f671bd4f7dd0f5183 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 17 Sep 2021 15:17:13 +0200 Subject: [PATCH 020/209] autowire and configure MenuBuilder --- src/Bundle/ChillTaskBundle/config/services/menu.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillTaskBundle/config/services/menu.yaml b/src/Bundle/ChillTaskBundle/config/services/menu.yaml index 75726fcf4..a9e1948d6 100644 --- a/src/Bundle/ChillTaskBundle/config/services/menu.yaml +++ b/src/Bundle/ChillTaskBundle/config/services/menu.yaml @@ -9,9 +9,8 @@ services: - { name: "chill.menu_builder" } Chill\TaskBundle\Menu\MenuBuilder: - arguments: - $authorizationChecker: '@Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface' - $translator: '@Symfony\Component\Translation\TranslatorInterface' + autowire: true + autoconfigure: true tags: - { name: "chill.menu_builder" } From 41fc41b1da87274c664ea912c5b3f9cdd0b0896b Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 28 Sep 2021 11:45:56 +0200 Subject: [PATCH 021/209] migration namespace adjusted --- src/Bundle/ChillTaskBundle/migrations/Version20210909153533.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillTaskBundle/migrations/Version20210909153533.php b/src/Bundle/ChillTaskBundle/migrations/Version20210909153533.php index e2f59621b..8a81b4ab9 100644 --- a/src/Bundle/ChillTaskBundle/migrations/Version20210909153533.php +++ b/src/Bundle/ChillTaskBundle/migrations/Version20210909153533.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Chill\TaskBundle\Migrations; +namespace Chill\Migrations\Task; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; From 8411c909fffb9a57a017be64791afe4e8bffd04e Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 28 Sep 2021 11:53:19 +0200 Subject: [PATCH 022/209] notation modifications --- .../Controller/SingleTaskController.php | 21 ++++++++++--------- .../Resources/views/SingleTask/edit.html.twig | 3 ++- .../views/SingleTask/editCourseTask.html.twig | 3 ++- .../views/SingleTask/index.html.twig | 6 ++++-- .../Resources/views/SingleTask/new.html.twig | 3 ++- .../views/SingleTask/newCourseTask.html.twig | 3 ++- .../Resources/views/SingleTask/show.html.twig | 3 ++- .../views/SingleTask/showCourseTask.html.twig | 3 ++- 8 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php index 456699091..0af61e55c 100644 --- a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php @@ -2,6 +2,7 @@ namespace Chill\TaskBundle\Controller; +use Chill\MainBundle\Entity\Scope; use Chill\PersonBundle\Privacy\PrivacyEvent; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; @@ -281,12 +282,12 @@ class SingleTaskController extends AbstractController if($task->getContext() instanceof Person){ - return $this->render('ChillTaskBundle:SingleTask:show.html.twig', array( + return $this->render('@ChillTask/SingleTask/show.html.twig', array( 'task' => $task, 'timeline' => $timeline )); } else { - return $this->render('ChillTaskBundle:SingleTask:showCourseTask.html.twig', array( + return $this->render('@ChillTask/SingleTask/showCourseTask.html.twig', array( 'task' => $task, 'timeline' => $timeline )); @@ -401,12 +402,12 @@ class SingleTaskController extends AbstractController )); $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); - return $this->render('ChillTaskBundle:SingleTask:edit.html.twig', array( + return $this->render('@ChillTask/SingleTask/edit.html.twig', array( 'task' => $task, 'form' => $form->createView() )); } else { - return $this->render('ChillTaskBundle:SingleTask:editCourseTask.html.twig', array( + return $this->render('@ChillTask/SingleTask/editCourseTask.html.twig', array( 'task' => $task, 'form' => $form->createView(), 'accompanyingCourse' => $course @@ -510,12 +511,12 @@ class SingleTaskController extends AbstractController } if($task->getContext() instanceof Person){ - return $this->render('ChillTaskBundle:SingleTask:confirm_delete.html.twig', array( + return $this->render('@ChillTask/SingleTask/confirm_delete.html.twig', array( 'task' => $task, 'delete_form' => $form->createView() )); } else { - return $this->render('ChillTaskBundle:SingleTask:confirm_deleteCourseTask.html.twig', array( + return $this->render('@ChillTask/SingleTask/confirm_deleteCourseTask.html.twig', array( 'task' => $task, 'delete_form' => $form->createView(), 'accompanyingCourse' => $course @@ -646,7 +647,7 @@ class SingleTaskController extends AbstractController $userId = $this->request->query->getInt('user_id', 0); $user = $this->getDoctrine()->getManager() - ->getRepository('ChillMainBundle:User') + ->getRepository(User::class) ->find($userId); if ($user === null) { @@ -663,7 +664,7 @@ class SingleTaskController extends AbstractController $scopeId = $this->request->query->getInt('scope_id', 0); $scope = $this->getDoctrine()->getManager() - ->getRepository('ChillMainBundle:Scope') + ->getRepository(Scope::class) ->find($scopeId); if ($scope === null) { @@ -762,7 +763,7 @@ class SingleTaskController extends AbstractController $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); } - return $this->render('ChillTaskBundle:SingleTask:index.html.twig', + return $this->render('@ChillTask/SingleTask/index.html.twig', array_merge($viewParams, [ 'form' => $form->createView() ])); } @@ -859,7 +860,7 @@ class SingleTaskController extends AbstractController ]); return $this->render( - 'ChillTaskBundle:SingleTask:index.html.twig', + '@ChillTask/SingleTask/index.html.twig', [ 'tasks' => $tasks, 'accompanyingCourse' => $course, diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/edit.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/edit.html.twig index 590740cf0..6188bd859 100644 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/edit.html.twig +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/edit.html.twig @@ -25,6 +25,7 @@ {% block personcontent %} - {% include 'ChillTaskBundle:SingleTask:_edit.html.twig' %} + {% include '@ChillTask/SingleTask/_edit.html.twig' %} + {% endblock %} diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/editCourseTask.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/editCourseTask.html.twig index 1805761ae..ccf0bab04 100644 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/editCourseTask.html.twig +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/editCourseTask.html.twig @@ -9,6 +9,7 @@ {% block content %} - {% include 'ChillTaskBundle:SingleTask:_edit.html.twig' %} + {% include '@ChillTask/SingleTask/_edit.html.twig' %} + {% endblock %} diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/index.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/index.html.twig index 4c0b9dc84..2f5819388 100644 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/index.html.twig +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/index.html.twig @@ -31,13 +31,15 @@ {% if person is not null %} {% block personcontent %}
        - {% include 'ChillTaskBundle:SingleTask:_list.html.twig' %} + {% include '@ChillTask/SingleTask/_list.html.twig' %} +
        {% endblock %} {% else %} {% block content %}
        - {% include 'ChillTaskBundle:SingleTask:_listCourse.html.twig' %} + {% include '@ChillTask/SingleTask/_listCourse.html.twig' %} +
        {% endblock %} {% endif %} diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/new.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/new.html.twig index 2b59fd5bf..226956aec 100644 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/new.html.twig +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/new.html.twig @@ -25,5 +25,6 @@ {% block personcontent %} - {% include 'ChillTaskBundle:SingleTask:_new.html.twig' %} + {% include '@ChillTask/SingleTask/_new.html.twig' %} + {% endblock %} diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/newCourseTask.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/newCourseTask.html.twig index 083c0795c..b8f810540 100644 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/newCourseTask.html.twig +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/newCourseTask.html.twig @@ -8,5 +8,6 @@ {% endblock %} {% block content %} - {% include 'ChillTaskBundle:SingleTask:_new.html.twig' %} + {% include '@ChillTask/SingleTask/_new.html.twig' %} + {% endblock %} diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/show.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/show.html.twig index 19bf70777..d9792ebde 100644 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/show.html.twig +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/show.html.twig @@ -27,6 +27,7 @@ {% block personcontent %} - {% include 'ChillTaskBundle:SingleTask:_show.html.twig' %} + {% include '@ChillTask/SingleTask/_show.html.twig' %} + {% endblock %} diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/showCourseTask.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/showCourseTask.html.twig index 643617a55..06ff62a60 100644 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/showCourseTask.html.twig +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/showCourseTask.html.twig @@ -11,6 +11,7 @@ {% block content %} - {% include 'ChillTaskBundle:SingleTask:_show.html.twig' %} + {% include '@ChillTask/SingleTask/_show.html.twig' %} + {% endblock %} From cb4059e5c3e95c63c2ead7fbf4865c093631c019 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 28 Sep 2021 14:37:27 +0200 Subject: [PATCH 023/209] comment out use of voter for menu entry, new way of handling rights? --- src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php b/src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php index 9b1890958..ac0990433 100644 --- a/src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php +++ b/src/Bundle/ChillTaskBundle/Menu/MenuBuilder.php @@ -89,7 +89,7 @@ class MenuBuilder implements LocalMenuBuilderInterface $course = $parameters['accompanyingCourse']; - if ($this->authorizationChecker->isGranted(TaskVoter::SHOW, $course)) { + // if ($this->authorizationChecker->isGranted(TaskVoter::SHOW, $course)) { $menu->addChild( $this->translator->trans('Tasks'), [ 'route' => 'chill_task_singletask_courselist', @@ -97,7 +97,7 @@ class MenuBuilder implements LocalMenuBuilderInterface [ 'course_id' => $course->getId() ] ]) ->setExtra('order', 400); - } + // } } public static function getMenuIds(): array From 5d69e48787f8abb1930c74e6895c4f31bd3d9e2f Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 30 Sep 2021 14:22:20 +0200 Subject: [PATCH 024/209] more conformity between URL's single-task --- .../ChillTaskBundle/Controller/SingleTaskController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php index 0af61e55c..b16b15bd1 100644 --- a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php @@ -571,7 +571,7 @@ class SingleTaskController extends AbstractController * - status: date state, amongst SingleTaskRepository::DATE_STATUSES, or 'closed' * * @Route( - * "/{_locale}/task/singletask/list", + * "/{_locale}/task/single-task/list", * name="chill_task_singletask_list" * ) */ @@ -818,7 +818,7 @@ class SingleTaskController extends AbstractController /** * @Route( - * "/{_locale}/task/singletask/courselist", + * "/{_locale}/task/single-task/courselist", * name="chill_task_singletask_courselist") */ From cc258ba1648371897acb7a2eb081617afc18d07e Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 30 Sep 2021 14:22:55 +0200 Subject: [PATCH 025/209] templates added for transition of course task and taskcontroller adapted to show correct template --- .../Controller/TaskController.php | 2 +- .../views/SingleTask/_transition.html.twig | 23 ++++++++++++++++++ .../views/SingleTask/transition.html.twig | 24 +------------------ .../SingleTask/transitionCourseTask.html.twig | 12 ++++++++++ 4 files changed, 37 insertions(+), 24 deletions(-) create mode 100644 src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_transition.html.twig create mode 100644 src/Bundle/ChillTaskBundle/Resources/views/SingleTask/transitionCourseTask.html.twig diff --git a/src/Bundle/ChillTaskBundle/Controller/TaskController.php b/src/Bundle/ChillTaskBundle/Controller/TaskController.php index 0c2b1f8d2..23f4ba51f 100644 --- a/src/Bundle/ChillTaskBundle/Controller/TaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/TaskController.php @@ -64,7 +64,7 @@ class TaskController extends AbstractController 'id' => $task->getId(), 'list_params' => $request->query->get('list_params', []) ]); - $defaultTemplate = '@ChillTask/SingleTask/transition.html.twig'; + $task->getCourse() === null ? $defaultTemplate = '@ChillTask/SingleTask/transition.html.twig' : $defaultTemplate = '@ChillTask/SingleTask/transitionCourseTask.html.twig'; break; default: return new Response("The type '$kind' is not implemented", diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_transition.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_transition.html.twig new file mode 100644 index 000000000..8f6345352 --- /dev/null +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_transition.html.twig @@ -0,0 +1,23 @@ +

        {{ 'Apply transition on task %title%'|trans({ '%title%': task.title } )|raw }}

        + + +{% if task_workflow_metadata(task, 'transition.sentence_confirmation', transition) is not empty %} +

        {{ task_workflow_metadata(task, 'transition.sentence_confirmation', transition)|trans }}

        +{% else %} +

        {{ 'Are you sure to apply the transition %name% on this task ?'|trans({ '%name%': task_workflow_metadata(task, 'transition.name', transition)|default(transition.name)|trans }) }}

        +{% endif %} + +{{ form_start(form) }} + +
          +
        • + + {{ 'Back to the list'|trans }} + +
        • +
        • + {{ form_widget(form.submit, { 'attr' : { 'class' : "btn btn-task-exchange green" }, 'label': task_workflow_metadata(task, 'transition.apply_transition_submit_label', transition)|default('apply')|trans } ) }} +
        • +
        + +{{ form_end(form) }} diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/transition.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/transition.html.twig index 617816e4c..05009a2f0 100644 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/transition.html.twig +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/transition.html.twig @@ -7,28 +7,6 @@ {% block personcontent %} -

        {{ 'Apply transition on task %title%'|trans({ '%title%': task.title } )|raw }}

        - - -{% if task_workflow_metadata(task, 'transition.sentence_confirmation', transition) is not empty %} -

        {{ task_workflow_metadata(task, 'transition.sentence_confirmation', transition)|trans }}

        -{% else %} -

        {{ 'Are you sure to apply the transition %name% on this task ?'|trans({ '%name%': task_workflow_metadata(task, 'transition.name', transition)|default(transition.name)|trans }) }}

        -{% endif %} - -{{ form_start(form) }} - -
          -
        • - - {{ 'Back to the list'|trans }} - -
        • -
        • - {{ form_widget(form.submit, { 'attr' : { 'class' : "btn btn-task-exchange green" }, 'label': task_workflow_metadata(task, 'transition.apply_transition_submit_label', transition)|default('apply')|trans } ) }} -
        • -
        - -{{ form_end(form) }} +{% include '@ChillTask/SingleTask/_transition.html.twig' %} {% endblock %} diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/transitionCourseTask.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/transitionCourseTask.html.twig new file mode 100644 index 000000000..08bedd31c --- /dev/null +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/transitionCourseTask.html.twig @@ -0,0 +1,12 @@ +{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %} + +{% set activeRouteKey = 'chill_task_task_list' %} +{% set accompanyingCourse = task.course %} + +{% block title 'Remove task'|trans %} + +{% block content %} + + {% include '@ChillTask/SingleTask/_transition.html.twig' %} + +{% endblock %} From 88b8ff86d163ac48c83b6aa6061e7d3d1405fe92 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 1 Oct 2021 10:45:04 +0200 Subject: [PATCH 026/209] reorganize templates for a better structure --- .../confirm_delete.html.twig} | 0 .../edit.html.twig} | 0 .../{_listCourse.html.twig => AccompanyingCourse/list.html.twig} | 0 .../{newCourseTask.html.twig => AccompanyingCourse/new.html.twig} | 0 .../show.html.twig} | 0 .../transition.html.twig} | 0 .../views/SingleTask/{ => Person}/confirm_delete.html.twig | 0 .../Resources/views/SingleTask/{ => Person}/edit.html.twig | 0 .../views/SingleTask/{_list.html.twig => Person/list.html.twig} | 0 .../Resources/views/SingleTask/{ => Person}/new.html.twig | 0 .../Resources/views/SingleTask/{ => Person}/show.html.twig | 0 .../Resources/views/SingleTask/{ => Person}/transition.html.twig | 0 12 files changed, 0 insertions(+), 0 deletions(-) rename src/Bundle/ChillTaskBundle/Resources/views/SingleTask/{confirm_deleteCourseTask.html.twig => AccompanyingCourse/confirm_delete.html.twig} (100%) rename src/Bundle/ChillTaskBundle/Resources/views/SingleTask/{editCourseTask.html.twig => AccompanyingCourse/edit.html.twig} (100%) rename src/Bundle/ChillTaskBundle/Resources/views/SingleTask/{_listCourse.html.twig => AccompanyingCourse/list.html.twig} (100%) rename src/Bundle/ChillTaskBundle/Resources/views/SingleTask/{newCourseTask.html.twig => AccompanyingCourse/new.html.twig} (100%) rename src/Bundle/ChillTaskBundle/Resources/views/SingleTask/{showCourseTask.html.twig => AccompanyingCourse/show.html.twig} (100%) rename src/Bundle/ChillTaskBundle/Resources/views/SingleTask/{transitionCourseTask.html.twig => AccompanyingCourse/transition.html.twig} (100%) rename src/Bundle/ChillTaskBundle/Resources/views/SingleTask/{ => Person}/confirm_delete.html.twig (100%) rename src/Bundle/ChillTaskBundle/Resources/views/SingleTask/{ => Person}/edit.html.twig (100%) rename src/Bundle/ChillTaskBundle/Resources/views/SingleTask/{_list.html.twig => Person/list.html.twig} (100%) rename src/Bundle/ChillTaskBundle/Resources/views/SingleTask/{ => Person}/new.html.twig (100%) rename src/Bundle/ChillTaskBundle/Resources/views/SingleTask/{ => Person}/show.html.twig (100%) rename src/Bundle/ChillTaskBundle/Resources/views/SingleTask/{ => Person}/transition.html.twig (100%) diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/confirm_deleteCourseTask.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/AccompanyingCourse/confirm_delete.html.twig similarity index 100% rename from src/Bundle/ChillTaskBundle/Resources/views/SingleTask/confirm_deleteCourseTask.html.twig rename to src/Bundle/ChillTaskBundle/Resources/views/SingleTask/AccompanyingCourse/confirm_delete.html.twig diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/editCourseTask.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/AccompanyingCourse/edit.html.twig similarity index 100% rename from src/Bundle/ChillTaskBundle/Resources/views/SingleTask/editCourseTask.html.twig rename to src/Bundle/ChillTaskBundle/Resources/views/SingleTask/AccompanyingCourse/edit.html.twig diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_listCourse.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/AccompanyingCourse/list.html.twig similarity index 100% rename from src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_listCourse.html.twig rename to src/Bundle/ChillTaskBundle/Resources/views/SingleTask/AccompanyingCourse/list.html.twig diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/newCourseTask.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/AccompanyingCourse/new.html.twig similarity index 100% rename from src/Bundle/ChillTaskBundle/Resources/views/SingleTask/newCourseTask.html.twig rename to src/Bundle/ChillTaskBundle/Resources/views/SingleTask/AccompanyingCourse/new.html.twig diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/showCourseTask.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/AccompanyingCourse/show.html.twig similarity index 100% rename from src/Bundle/ChillTaskBundle/Resources/views/SingleTask/showCourseTask.html.twig rename to src/Bundle/ChillTaskBundle/Resources/views/SingleTask/AccompanyingCourse/show.html.twig diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/transitionCourseTask.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/AccompanyingCourse/transition.html.twig similarity index 100% rename from src/Bundle/ChillTaskBundle/Resources/views/SingleTask/transitionCourseTask.html.twig rename to src/Bundle/ChillTaskBundle/Resources/views/SingleTask/AccompanyingCourse/transition.html.twig diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/confirm_delete.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/Person/confirm_delete.html.twig similarity index 100% rename from src/Bundle/ChillTaskBundle/Resources/views/SingleTask/confirm_delete.html.twig rename to src/Bundle/ChillTaskBundle/Resources/views/SingleTask/Person/confirm_delete.html.twig diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/edit.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/Person/edit.html.twig similarity index 100% rename from src/Bundle/ChillTaskBundle/Resources/views/SingleTask/edit.html.twig rename to src/Bundle/ChillTaskBundle/Resources/views/SingleTask/Person/edit.html.twig diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_list.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/Person/list.html.twig similarity index 100% rename from src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_list.html.twig rename to src/Bundle/ChillTaskBundle/Resources/views/SingleTask/Person/list.html.twig diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/new.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/Person/new.html.twig similarity index 100% rename from src/Bundle/ChillTaskBundle/Resources/views/SingleTask/new.html.twig rename to src/Bundle/ChillTaskBundle/Resources/views/SingleTask/Person/new.html.twig diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/show.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/Person/show.html.twig similarity index 100% rename from src/Bundle/ChillTaskBundle/Resources/views/SingleTask/show.html.twig rename to src/Bundle/ChillTaskBundle/Resources/views/SingleTask/Person/show.html.twig diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/transition.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/Person/transition.html.twig similarity index 100% rename from src/Bundle/ChillTaskBundle/Resources/views/SingleTask/transition.html.twig rename to src/Bundle/ChillTaskBundle/Resources/views/SingleTask/Person/transition.html.twig From 6a34046e937180c0d38c156c11217af41fd429d5 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 1 Oct 2021 10:47:32 +0200 Subject: [PATCH 027/209] comments deleted, notations adjusted, ... --- .../Controller/SingleTaskController.php | 77 +++++++------------ 1 file changed, 26 insertions(+), 51 deletions(-) diff --git a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php index b16b15bd1..5bcc8f53c 100644 --- a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php @@ -31,7 +31,9 @@ use Chill\MainBundle\Timeline\TimelineBuilder; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Repository\AccompanyingPeriodRepository; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; +use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\HttpFoundation\RequestStack; +use Symfony\Contracts\Translation\TranslatorInterface as TranslationTranslatorInterface; /** * Class SingleTaskController @@ -78,7 +80,6 @@ class SingleTaskController extends AbstractController $this->logger = $logger; $this->request = $requestStack->getCurrentRequest(); } - private function getEntityContext() { @@ -99,7 +100,7 @@ class SingleTaskController extends AbstractController * ) */ public function newAction( - TranslatorInterface $translator + TranslationTranslatorInterface $translator ) { $task = (new SingleTask()) @@ -190,14 +191,14 @@ class SingleTaskController extends AbstractController switch($this->getEntityContext()){ case 'person': - return $this->render('ChillTaskBundle:SingleTask:new.html.twig', array( + return $this->render('@ChillTask/SingleTask/Person/new.html.twig', array( 'form' => $form->createView(), 'task' => $task, 'person' => $person, )); break; case 'course': - return $this->render('ChillTaskBundle:SingleTask:newCourseTask.html.twig', array( + return $this->render('@ChillTask/SingleTask/AccompanyingCourse/show.html.twig', array( 'form' => $form->createView(), 'task' => $task, 'accompanyingCourse' => $course, @@ -207,7 +208,6 @@ class SingleTaskController extends AbstractController } - /** * @Route( * "/{_locale}/task/single-task/{id}/show", @@ -220,14 +220,10 @@ class SingleTaskController extends AbstractController $em = $this->getDoctrine()->getManager(); $task = $em->getRepository(SingleTask::class)->find($id); - // In case no task is found - if (!$task) { throw $this->createNotFoundException('Unable to find Task entity.'); } - // In case task belongs to person - if ($task->getPerson() !== null) { $personId = $task->getPerson()->getId(); @@ -253,8 +249,6 @@ class SingleTaskController extends AbstractController } - // In case task belongs to accompanying course - if ($task->getCourse() !== null) { $courseId = $task->getCourse()->getId(); @@ -282,12 +276,12 @@ class SingleTaskController extends AbstractController if($task->getContext() instanceof Person){ - return $this->render('@ChillTask/SingleTask/show.html.twig', array( + return $this->render('@ChillTask/SingleTask/Person/show.html.twig', array( 'task' => $task, 'timeline' => $timeline )); } else { - return $this->render('@ChillTask/SingleTask/showCourseTask.html.twig', array( + return $this->render('@ChillTask/SingleTask/AccompanyingCourse/show.html.twig', array( 'task' => $task, 'timeline' => $timeline )); @@ -304,7 +298,7 @@ class SingleTaskController extends AbstractController */ public function editAction( $id, - TranslatorInterface $translator + TranslationTranslatorInterface $translator ) { $em = $this->getDoctrine()->getManager(); @@ -402,12 +396,12 @@ class SingleTaskController extends AbstractController )); $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); - return $this->render('@ChillTask/SingleTask/edit.html.twig', array( + return $this->render('@ChillTask/SingleTask/Person/edit.html.twig', array( 'task' => $task, 'form' => $form->createView() )); } else { - return $this->render('@ChillTask/SingleTask/editCourseTask.html.twig', array( + return $this->render('@ChillTask/SingleTask/AccompanyingCourse/edit.html.twig', array( 'task' => $task, 'form' => $form->createView(), 'accompanyingCourse' => $course @@ -426,7 +420,7 @@ class SingleTaskController extends AbstractController public function deleteAction( Request $request, $id, - TranslatorInterface $translator + TranslationTranslatorInterface $translator ) { $em = $this->getDoctrine()->getManager(); @@ -465,9 +459,10 @@ class SingleTaskController extends AbstractController } } + // TODO: reactivate right to delete - $this->denyAccessUnlessGranted(TaskVoter::DELETE, $task, 'You are not ' - . 'allowed to delete this task'); + // $this->denyAccessUnlessGranted(TaskVoter::DELETE, $task, 'You are not ' + // . 'allowed to delete this task'); $form = $this->createDeleteForm($id); @@ -481,10 +476,8 @@ class SingleTaskController extends AbstractController 'task_id' => $task->getId(), 'description' => $task->getDescription(), 'assignee' => $task->getAssignee(), - 'scope_id' => $task->getScope()->getId(), - //'start_date' => $task->getStartDate()->format('Y-m-d'), - //'end_date' => $task->getEndDate()->format('Y-m-d'), - //'warning_interval' => $task->getWarningInterval()->format('Y-m-d') + // TODO reimplement scope + // 'scope_id' => $task->getScope()->getId(), )); $em = $this->getDoctrine()->getManager(); @@ -511,12 +504,12 @@ class SingleTaskController extends AbstractController } if($task->getContext() instanceof Person){ - return $this->render('@ChillTask/SingleTask/confirm_delete.html.twig', array( + return $this->render('@ChillTask/SingleTask/Person/confirm_delete.html.twig', array( 'task' => $task, 'delete_form' => $form->createView() )); } else { - return $this->render('@ChillTask/SingleTask/confirm_deleteCourseTask.html.twig', array( + return $this->render('@ChillTask/SingleTask/AccompanyingCourse/confirm_delete.html.twig', array( 'task' => $task, 'delete_form' => $form->createView(), 'accompanyingCourse' => $course @@ -551,7 +544,7 @@ class SingleTaskController extends AbstractController * name="chill_task_single_my_tasks" * ) */ - public function myTasksAction(TranslatorInterface $translator) + public function myTasksAction(TranslationTranslatorInterface $translator) { return $this->redirectToRoute('chill_task_singletask_list', [ 'user_id' => $this->getUser()->getId(), @@ -595,8 +588,6 @@ class SingleTaskController extends AbstractController $viewParams['accompanyingCourse'] = null; $params['accompanyingCourse'] = null; - - // Get parameters from url if (!empty($this->request->query->get('person_id', NULL))) { $personId = $this->request->query->getInt('person_id', 0); @@ -675,11 +666,9 @@ class SingleTaskController extends AbstractController $params['scope'] = $scope; } - // collect parameters for filter $possibleStatuses = \array_merge(SingleTaskRepository::DATE_STATUSES, [ 'closed' ]); $statuses = $this->request->query->get('status', $possibleStatuses); - // check for invalid statuses $diff = \array_diff($statuses, $possibleStatuses); if (count($diff) > 0) { return new Response( @@ -698,7 +687,6 @@ class SingleTaskController extends AbstractController continue; } - // different query if regarding to date or 'closed' if (in_array($status, SingleTaskRepository::DATE_STATUSES)) { $params['date_status'] = $status; $params['is_closed'] = false; @@ -723,7 +711,6 @@ class SingleTaskController extends AbstractController $tasks_count = $tasks_count + $count; } - // total number of tasks $viewParams['tasks_count'] = $tasks_count; if ($viewParams['person'] !== null){ @@ -734,24 +721,12 @@ class SingleTaskController extends AbstractController $viewParams['layout'] = '@ChillMain/layout.html.twig'; } - // Form for filtering tasks - if($this->getEntityContext() === 'person'){ - $form = $formFactory->createNamed(null, SingleTaskListType::class, null, [ - 'person' => $viewParams['person'], - 'method' => Request::METHOD_GET, - 'csrf_protection' => false, - 'add_type' => true - ]); - } - - if($this->getEntityContext() === 'course'){ - $form = $formFactory->createNamed(null, SingleTaskListType::class, null, [ - 'accompanyingCourse' => $viewParams['accompanyingCourse'], - 'method' => Request::METHOD_GET, - 'csrf_protection' => false, - 'add_type' => true - ]); - } + $form = $formFactory->createNamed(null, SingleTaskListType::class, null, [ + 'person' => $viewParams['person'], + 'method' => Request::METHOD_GET, + 'csrf_protection' => false, + 'add_type' => true + ]); $form->handleRequest($this->request); @@ -826,7 +801,7 @@ class SingleTaskController extends AbstractController AccompanyingPeriodRepository $courseRepository, SingleTaskRepository $taskRepository, FormFactoryInterface $formFactory, - TranslatorInterface $translator + TranslationTranslatorInterface $translator ): Response { From 548247188f78c9f88b990f0e12bc5fa06e78f501 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 1 Oct 2021 10:49:07 +0200 Subject: [PATCH 028/209] temporarily lifted scope validation, currently no scopes in select list to be selected --- src/Bundle/ChillTaskBundle/Entity/AbstractTask.php | 1 - src/Bundle/ChillTaskBundle/Form/SingleTaskType.php | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillTaskBundle/Entity/AbstractTask.php b/src/Bundle/ChillTaskBundle/Entity/AbstractTask.php index 57a194ef8..ce2de5a6f 100644 --- a/src/Bundle/ChillTaskBundle/Entity/AbstractTask.php +++ b/src/Bundle/ChillTaskBundle/Entity/AbstractTask.php @@ -85,7 +85,6 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface * @ORM\ManyToOne( * targetEntity="\Chill\MainBundle\Entity\Scope" * ) - * @Assert\NotNull() */ private $circle; diff --git a/src/Bundle/ChillTaskBundle/Form/SingleTaskType.php b/src/Bundle/ChillTaskBundle/Form/SingleTaskType.php index 5802512b7..e0bae1608 100644 --- a/src/Bundle/ChillTaskBundle/Form/SingleTaskType.php +++ b/src/Bundle/ChillTaskBundle/Form/SingleTaskType.php @@ -51,7 +51,8 @@ class SingleTaskType extends AbstractType ]) ->add('circle', ScopePickerType::class, [ 'center' => $options['center'], - 'role' => $options['role'] + 'role' => $options['role'], + 'required' => false ]) ->add('startDate', ChillDateType::class, [ 'required' => false From 1403ee2ba5578d043c01044bea18aa57b01dabe4 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 1 Oct 2021 10:49:55 +0200 Subject: [PATCH 029/209] redirect after submit bug fixed for edit and delete when coming from show.html.twig --- .../Resources/views/SingleTask/_show.html.twig | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_show.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_show.html.twig index f73f2740d..1186fb125 100644 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_show.html.twig +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_show.html.twig @@ -30,10 +30,12 @@ {% endif %} -
        {{ 'Scope'|trans }}
        -
        - {{ task.scope.name|localize_translatable_string }} -
        + {% if task.scope is not null %} +
        {{ 'Scope'|trans }}
        +
        + {{ task.scope.name|localize_translatable_string }} +
        + {% endif %}

        {{"Dates"|trans}}

        {% if task.startDate is null and task.endDate is null and task.warningDate is null %} @@ -94,7 +96,7 @@ {% if is_granted('CHILL_TASK_TASK_UPDATE', task) %}
      • - + {{ 'Edit the task'|trans }}
      • @@ -102,7 +104,7 @@ {% if is_granted('CHILL_TASK_TASK_CREATE', task) %}
      • - + {{ 'Delete'|trans }}
      • From 262fefa92f998f80a737aa201af02e5995ff2a31 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 1 Oct 2021 10:51:02 +0200 Subject: [PATCH 030/209] access granted condition lifted temporarily to show the 'add new task' button on index page for Person --- .../views/SingleTask/Person/list.html.twig | 23 ++++++++++--------- .../views/SingleTask/index.html.twig | 4 ++-- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/Person/list.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/Person/list.html.twig index e80e45e8c..1163ee4ef 100644 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/Person/list.html.twig +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/Person/list.html.twig @@ -203,17 +203,18 @@

        {{ 'Tasks'|trans }}

        {% endif %} - {% if person is not null and is_granted('CHILL_TASK_TASK_CREATE', person) %} - - {% endif %} + {# TODO reimplement right to create task. #} + {# {% if person is not null and is_granted('CHILL_TASK_TASK_CREATE', person) %} #} + + {# {% endif %} #} {% if single_task_ended_tasks is defined %} {{ helper.date_status('Tasks with expired deadline', single_task_ended_tasks, single_task_ended_count, single_task_ended_paginator, 'ended', isSingleStatus, person) }} diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/index.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/index.html.twig index 2f5819388..3cd2a1971 100644 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/index.html.twig +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/index.html.twig @@ -31,14 +31,14 @@ {% if person is not null %} {% block personcontent %}
        - {% include '@ChillTask/SingleTask/_list.html.twig' %} + {% include '@ChillTask/SingleTask/Person/list.html.twig' %}
        {% endblock %} {% else %} {% block content %}
        - {% include '@ChillTask/SingleTask/_listCourse.html.twig' %} + {% include '@ChillTask/SingleTask/AccompanyingCourse/list.html.twig' %}
        {% endblock %} From 43daab1f7b2cd81775c82c45cad1a190e82b4446 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 1 Oct 2021 11:32:05 +0200 Subject: [PATCH 031/209] transition button added to listitems of course tasks --- .../Controller/TaskController.php | 2 +- .../AccompanyingCourse/list.html.twig | 39 +++++++++---------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/Bundle/ChillTaskBundle/Controller/TaskController.php b/src/Bundle/ChillTaskBundle/Controller/TaskController.php index 23f4ba51f..c137c166d 100644 --- a/src/Bundle/ChillTaskBundle/Controller/TaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/TaskController.php @@ -64,7 +64,7 @@ class TaskController extends AbstractController 'id' => $task->getId(), 'list_params' => $request->query->get('list_params', []) ]); - $task->getCourse() === null ? $defaultTemplate = '@ChillTask/SingleTask/transition.html.twig' : $defaultTemplate = '@ChillTask/SingleTask/transitionCourseTask.html.twig'; + $task->getCourse() === null ? $defaultTemplate = '@ChillTask/SingleTask/Person/transition.html.twig' : $defaultTemplate = '@ChillTask/SingleTask/AccompanyingCourse/transition.html.twig'; break; default: return new Response("The type '$kind' is not implemented", diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/AccompanyingCourse/list.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/AccompanyingCourse/list.html.twig index 16c907e4c..493fab920 100644 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/AccompanyingCourse/list.html.twig +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/AccompanyingCourse/list.html.twig @@ -52,26 +52,25 @@ -
          - {# {% if workflow_transitions(task)|length > 0 %} -
        • -
          - - -
          -
        • - {% endif %} #} +
            + {% if workflow_transitions(task)|length > 0 %} +
          • +
            + + +
            +
          • + {% endif %}
          • From fc237db98aa404934e7cd1e4a8f80c046d652471 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 1 Oct 2021 11:32:32 +0200 Subject: [PATCH 032/209] fix: wrong template rendered for new course task --- src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php index 76f12acda..be39f4900 100644 --- a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php @@ -199,7 +199,7 @@ class SingleTaskController extends AbstractController )); break; case 'course': - return $this->render('@ChillTask/SingleTask/AccompanyingCourse/show.html.twig', array( + return $this->render('@ChillTask/SingleTask/AccompanyingCourse/new.html.twig', array( 'form' => $form->createView(), 'task' => $task, 'accompanyingCourse' => $course, From 461b96ea37c78d67edeaae13378675fe22c1994a Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 1 Oct 2021 11:32:46 +0200 Subject: [PATCH 033/209] duplicate templates deleted --- .../views/SingleTask/_list.html.twig | 256 ------------------ .../views/SingleTask/_listCourse.html.twig | 107 -------- .../confirm_deleteCourseTask.html.twig | 19 -- .../Resources/views/SingleTask/edit.html.twig | 30 -- .../views/SingleTask/editCourseTask.html.twig | 14 - .../views/SingleTask/newCourseTask.html.twig | 12 - .../Resources/views/SingleTask/show.html.twig | 32 --- .../views/SingleTask/showCourseTask.html.twig | 16 -- 8 files changed, 486 deletions(-) delete mode 100644 src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_list.html.twig delete mode 100644 src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_listCourse.html.twig delete mode 100644 src/Bundle/ChillTaskBundle/Resources/views/SingleTask/confirm_deleteCourseTask.html.twig delete mode 100644 src/Bundle/ChillTaskBundle/Resources/views/SingleTask/edit.html.twig delete mode 100644 src/Bundle/ChillTaskBundle/Resources/views/SingleTask/editCourseTask.html.twig delete mode 100644 src/Bundle/ChillTaskBundle/Resources/views/SingleTask/newCourseTask.html.twig delete mode 100644 src/Bundle/ChillTaskBundle/Resources/views/SingleTask/show.html.twig delete mode 100644 src/Bundle/ChillTaskBundle/Resources/views/SingleTask/showCourseTask.html.twig diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_list.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_list.html.twig deleted file mode 100644 index e80e45e8c..000000000 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_list.html.twig +++ /dev/null @@ -1,256 +0,0 @@ -{% macro date_status(title, tasks, count, paginator, status, isSingleStatus, person, user) %} - {% if tasks|length > 0 %} -

            {{ title|trans }}

            - - - - {% for task in tasks %} - - - - - {% endfor %} - -
            -
            - {{ task.title }} -
            - - {% if person is null %} -
            - {{ 'For person'|trans }} : - - {{ task.person}} - -
            - {% endif %} - -
            - {{ task_workflow_metadata(task, 'definition.name')|trans }} -
            - -
            - {% for place in workflow_marked_places(task) %} - {{ place|trans }} - {% endfor %} - {% if task.assignee is not null %} -
            - {{ 'By'|trans }} : - {{ task.assignee.username }}
            - {% endif %} -
            - - {% if task.startDate is not null or task.warningDate is not null or task.endDate is not null %} -
            -
              - {% if task.startDate is not null %} -
            • - - {{ task.startDate|format_date('medium') }} -
            • - {% endif %} - {% if task.warningDate is not null %} -
            • - - {{ task.warningDate|format_date('medium') }} -
            • - {% endif %} - {% if task.endDate is not null %} -
            • - - {{ task.endDate|format_date('medium') }} -
            • - {% endif %} -
            -
            - {% endif %} - -
            - -
            - - {% if isSingleStatus %} - {% if tasks|length < paginator.getTotalItems %} - {{ chill_pagination(paginator) }} - {% endif %} - - - - {% else %} - - {% endif %} - - {% endif %} -{% endmacro %} - -{% import _self as helper %} - -

            {{ app.request.query.get('title', null)|escape('html')|default('Task list'|trans) }}

            - -{% if false == app.request.query.boolean('hide_form', false) %} -

            {{ 'Filter the tasks'|trans }}

            - {{ form_start(form) }} - {{ form_row(form.user_id) }} - - {% if form.status is defined %} - {{ form_row(form.status) }} - {% endif %} - - {% if form.types is defined %} - {{ form_row(form.types) }} - {% endif %} - - {% if form.person_id is defined %} - {{ form_row(form.person_id) }} - {% endif %} - - {% if form.center_id is defined %} - {{ form_row(form.center_id) }} - {% endif %} - -
              -
            • - -
            • -
            - - {{ form_end(form)}} -{% endif %} - -{% if tasks_count == 0 %} -

            {{ "There is no tasks."|trans }}

            - {% if person is not null and is_granted('CHILL_TASK_TASK_CREATE', person) %} - - {% endif %} -{% else %} - - {% if false == app.request.query.boolean('hide_form', false) %} -

            {{ 'Tasks'|trans }}

            - {% endif %} - - {% if person is not null and is_granted('CHILL_TASK_TASK_CREATE', person) %} - - {% endif %} - - {% if single_task_ended_tasks is defined %} - {{ helper.date_status('Tasks with expired deadline', single_task_ended_tasks, single_task_ended_count, single_task_ended_paginator, 'ended', isSingleStatus, person) }} - {% endif %} - - {% if single_task_warning_tasks is defined %} - {{ helper.date_status('Tasks with warning deadline reached', single_task_warning_tasks, single_task_warning_count, single_task_warning_paginator, 'warning', isSingleStatus, person) }} - {% endif %} - - {% if single_task_current_tasks is defined %} - {{ helper.date_status('Current tasks', single_task_current_tasks, single_task_current_count, single_task_current_paginator, 'current', isSingleStatus, person) }} - {% endif %} - - {% if single_task_not_started_tasks is defined %} - {{ helper.date_status('Tasks not started', single_task_not_started_tasks, single_task_not_started_count, single_task_not_started_paginator, 'not_started', isSingleStatus, person) }} - {% endif %} - - {% if single_task_closed_tasks is defined %} - {{ helper.date_status('Closed tasks', single_task_closed_tasks, single_task_closed_count, single_task_closed_paginator, 'closed', isSingleStatus, person) }} - {% endif %} - - {% if isSingleStatus == false %} - - {% endif %} - -{% endif %} diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_listCourse.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_listCourse.html.twig deleted file mode 100644 index 16c907e4c..000000000 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/_listCourse.html.twig +++ /dev/null @@ -1,107 +0,0 @@ -{% if tasks|length > 0 %} -

            {{ title|trans }}

            - - - - {% for task in tasks %} - - - - - {% endfor %} - -
            -
            - {{ task.title }} -
            - -
            - {{ task_workflow_metadata(task, 'definition.name')|trans }} -
            - -
            - {% for place in workflow_marked_places(task) %} - {{ place|trans }} - {% endfor %} - {% if task.assignee is not null %} -
            - {{ 'By'|trans }} : - {{ task.assignee.username }}
            - {% endif %} -
            - - {% if task.startDate is not null or task.warningDate is not null or task.endDate is not null %} -
            -
              - {% if task.startDate is not null %} -
            • - - {{ task.startDate|format_date('medium') }} -
            • - {% endif %} - {% if task.warningDate is not null %} -
            • - - {{ task.warningDate|format_date('medium') }} -
            • - {% endif %} - {% if task.endDate is not null %} -
            • - - {{ task.endDate|format_date('medium') }} -
            • - {% endif %} -
            -
            - {% endif %} - -
            - -
            -{% endif %} - - diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/confirm_deleteCourseTask.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/confirm_deleteCourseTask.html.twig deleted file mode 100644 index 49857188c..000000000 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/confirm_deleteCourseTask.html.twig +++ /dev/null @@ -1,19 +0,0 @@ -{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %} - -{% set activeRouteKey = 'chill_task_task_list' %} -{% set course = task.course %} - -{% block title 'Remove task'|trans %} - -{% block content %} - - {{ include('@ChillMain/Util/confirmation_template.html.twig', - { - 'title' : 'Remove task'|trans, - 'confirm_question' : 'Are you sure you want to remove the task about accompanying period "%id%" ?'|trans({ '%id%' : course.id } ), - 'cancel_route' : 'chill_task_singletask_courselist', - 'cancel_parameters' : app.request.query.get('list_params', { } ), - 'form' : delete_form, - } ) }} - -{% endblock %} diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/edit.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/edit.html.twig deleted file mode 100644 index 590740cf0..000000000 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/edit.html.twig +++ /dev/null @@ -1,30 +0,0 @@ -{# - * 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 person is defined ? "@ChillPerson/Person/layout.html.twig" %} - -{% set activeRouteKey = 'chill_task_single_task_edit' %} -{% set person = task.person %} - -{% block title %} - {{ 'Edit task'|trans }} -{% endblock %} - -{% block personcontent %} - - {% include 'ChillTaskBundle:SingleTask:_edit.html.twig' %} - -{% endblock %} diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/editCourseTask.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/editCourseTask.html.twig deleted file mode 100644 index 1805761ae..000000000 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/editCourseTask.html.twig +++ /dev/null @@ -1,14 +0,0 @@ -{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %} - -{% set activeRouteKey = 'chill_task_single_task_edit' %} -{% set course = task.course %} - -{% block title %} - {{ 'Edit task'|trans }} -{% endblock %} - -{% block content %} - - {% include 'ChillTaskBundle:SingleTask:_edit.html.twig' %} - -{% endblock %} diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/newCourseTask.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/newCourseTask.html.twig deleted file mode 100644 index 083c0795c..000000000 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/newCourseTask.html.twig +++ /dev/null @@ -1,12 +0,0 @@ -{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %} - -{% set activeRouteKey = 'chill_task_single_task_new' %} -{# {% set person = task.person %} #} - -{% block title %} - {{ 'New task'|trans }} -{% endblock %} - -{% block content %} - {% include 'ChillTaskBundle:SingleTask:_new.html.twig' %} -{% endblock %} diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/show.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/show.html.twig deleted file mode 100644 index 19bf70777..000000000 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/show.html.twig +++ /dev/null @@ -1,32 +0,0 @@ -{# - * 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/Person/layout.html.twig" %} - - -{% set activeRouteKey = 'chill_task_single_task_show' %} -{% set person = task.person %} - -{% block title %} - {{ 'Task'|trans }} -{% endblock %} - - -{% block personcontent %} - - {% include 'ChillTaskBundle:SingleTask:_show.html.twig' %} - -{% endblock %} diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/showCourseTask.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/showCourseTask.html.twig deleted file mode 100644 index 643617a55..000000000 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/showCourseTask.html.twig +++ /dev/null @@ -1,16 +0,0 @@ -{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %} - - -{% set activeRouteKey = 'chill_task_single_task_show' %} -{% set accompanyingCourse = task.course %} - -{% block title %} - {{ 'Task'|trans }} -{% endblock %} - - -{% block content %} - - {% include 'ChillTaskBundle:SingleTask:_show.html.twig' %} - -{% endblock %} From 1ded5b7c01fc6e4e3b2e18af695731e73901c4c9 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 7 Oct 2021 14:18:25 +0200 Subject: [PATCH 034/209] first commit --- .../lib/blur_confidential/blur_confidential.js | 13 +++++++++++++ .../Resources/public/lib/blur_confidential/index.js | 1 + 2 files changed, 14 insertions(+) create mode 100644 src/Bundle/ChillMainBundle/Resources/public/lib/blur_confidential/blur_confidential.js create mode 100644 src/Bundle/ChillMainBundle/Resources/public/lib/blur_confidential/index.js diff --git a/src/Bundle/ChillMainBundle/Resources/public/lib/blur_confidential/blur_confidential.js b/src/Bundle/ChillMainBundle/Resources/public/lib/blur_confidential/blur_confidential.js new file mode 100644 index 000000000..70a12736b --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/public/lib/blur_confidential/blur_confidential.js @@ -0,0 +1,13 @@ +var infos = document.querySelectorAll("confidential"); +var toggles = document.querySelectorAll("confidential-toggle"); + +var toggleBlur = function(){ + var isBlurred = true; + if(isBlurred === true){ + + } +} + +for(var i=0; i < toggles.length; i++){ + toggles[i].addEventListener("click", toggleBlur) +} \ No newline at end of file diff --git a/src/Bundle/ChillMainBundle/Resources/public/lib/blur_confidential/index.js b/src/Bundle/ChillMainBundle/Resources/public/lib/blur_confidential/index.js new file mode 100644 index 000000000..bb47be73c --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/public/lib/blur_confidential/index.js @@ -0,0 +1 @@ +require("./blur_confidential.js"); \ No newline at end of file From 1ffff1f72c96f7cfe0fbc075e9c38ef67e5893fe Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 7 Oct 2021 17:10:52 +0200 Subject: [PATCH 035/209] restructuring files to /module --- .../Resources/public/lib/blur_confidential/index.js | 1 - .../blur_confidential.js => module/blur/index.js} | 0 2 files changed, 1 deletion(-) delete mode 100644 src/Bundle/ChillMainBundle/Resources/public/lib/blur_confidential/index.js rename src/Bundle/ChillMainBundle/Resources/public/{lib/blur_confidential/blur_confidential.js => module/blur/index.js} (100%) diff --git a/src/Bundle/ChillMainBundle/Resources/public/lib/blur_confidential/index.js b/src/Bundle/ChillMainBundle/Resources/public/lib/blur_confidential/index.js deleted file mode 100644 index bb47be73c..000000000 --- a/src/Bundle/ChillMainBundle/Resources/public/lib/blur_confidential/index.js +++ /dev/null @@ -1 +0,0 @@ -require("./blur_confidential.js"); \ No newline at end of file diff --git a/src/Bundle/ChillMainBundle/Resources/public/lib/blur_confidential/blur_confidential.js b/src/Bundle/ChillMainBundle/Resources/public/module/blur/index.js similarity index 100% rename from src/Bundle/ChillMainBundle/Resources/public/lib/blur_confidential/blur_confidential.js rename to src/Bundle/ChillMainBundle/Resources/public/module/blur/index.js From acbd6e761a030fe2832b5a7dcc5e2734e2cbf3b5 Mon Sep 17 00:00:00 2001 From: nobohan Date: Fri, 8 Oct 2021 15:51:51 +0200 Subject: [PATCH 036/209] address: zoom on postal code on select city --- .../vuejs/Address/components/AddAddress/CitySelection.vue | 5 ++++- .../Resources/public/vuejs/Address/components/EditPane.vue | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CitySelection.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CitySelection.vue index 9b6a7b87f..ece0e8c65 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CitySelection.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CitySelection.vue @@ -50,7 +50,7 @@ import VueMultiselect from 'vue-multiselect'; export default { name: 'CitySelection', components: { VueMultiselect }, - props: ['entity', 'focusOnAddress'], + props: ['entity', 'focusOnAddress', 'updateMapCenter'], emits: ['getReferenceAddresses'], data() { return { @@ -102,6 +102,9 @@ export default { console.log('writeNew.postcode false, in selectCity'); this.$emit('getReferenceAddresses', value); this.focusOnAddress(); + if (value.center) { + this.updateMapCenter(value.center); + } }, listenInputSearch(query) { //console.log('listenInputSearch', query, this.isCitySelectorOpen); diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/EditPane.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/EditPane.vue index 9e257fe4a..921914977 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/EditPane.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/EditPane.vue @@ -31,6 +31,7 @@ From 487103375d2e13c3cfe5d98584619d3af30ce8d7 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 8 Oct 2021 22:21:40 +0200 Subject: [PATCH 037/209] blur logic implemented on view.html.twig of Person by means of example --- .../Resources/public/module/blur/index.js | 22 +++++++---- .../Resources/views/layout.html.twig | 17 ++++++++- .../ChillMainBundle/chill.webpack.config.js | 1 + .../Resources/views/Person/view.html.twig | 38 +++++++++++++------ 4 files changed, 57 insertions(+), 21 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/module/blur/index.js b/src/Bundle/ChillMainBundle/Resources/public/module/blur/index.js index 70a12736b..691059f36 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/module/blur/index.js +++ b/src/Bundle/ChillMainBundle/Resources/public/module/blur/index.js @@ -1,13 +1,19 @@ -var infos = document.querySelectorAll("confidential"); -var toggles = document.querySelectorAll("confidential-toggle"); +var toggleBlur = function(e){ + + var btn = e.target; + + btn.previousElementSibling.classList.toggle("blur"); + btn.classList.toggle("fa-eye"); + btn.classList.toggle("fa-eye-slash"); -var toggleBlur = function(){ - var isBlurred = true; - if(isBlurred === true){ - - } } +var infos = document.getElementsByClassName("confidential"); +for(var i=0; i < infos.length; i++){ + infos[i].insertAdjacentHTML('beforeend', ''); +} + +var toggles = document.getElementsByClassName("toggle"); for(var i=0; i < toggles.length; i++){ - toggles[i].addEventListener("click", toggleBlur) + toggles[i].addEventListener("click", toggleBlur); } \ No newline at end of file diff --git a/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig b/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig index 8bee2983e..154a625f6 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig @@ -12,7 +12,22 @@ {{ encore_entry_link_tags('mod_forkawesome') }} {{ encore_entry_link_tags('mod_ckeditor5') }} {{ encore_entry_link_tags('chill') }} - {% block css%}{% endblock %} + {% block css%} + + {% endblock %} diff --git a/src/Bundle/ChillMainBundle/chill.webpack.config.js b/src/Bundle/ChillMainBundle/chill.webpack.config.js index 0204166d0..2c093c70b 100644 --- a/src/Bundle/ChillMainBundle/chill.webpack.config.js +++ b/src/Bundle/ChillMainBundle/chill.webpack.config.js @@ -58,6 +58,7 @@ module.exports = function(encore, entries) encore.addEntry('mod_forkawesome', __dirname + '/Resources/public/module/forkawesome/index.js'); encore.addEntry('mod_bootstrap', __dirname + '/Resources/public/module/bootstrap/index.js'); encore.addEntry('mod_ckeditor5', __dirname + '/Resources/public/module/ckeditor5/index.js'); + encore.addEntry('mod_blur', __dirname + '/Resources/public/module/blur/index.js'); // Vue entrypoints encore.addEntry('vue_address', __dirname + '/Resources/public/vuejs/Address/index.js'); diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Person/view.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Person/view.html.twig index c5cc8478c..d5c69229d 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Person/view.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Person/view.html.twig @@ -94,14 +94,18 @@ This view should receive those arguments: {%- endif -%} {%- if chill_person.fields.country_of_birth == 'visible' -%} -
            {{ 'Country of birth'|trans }} :
            -
            {% apply spaceless %} - {% if person.countryOfBirth is not null %} - {{ person.countryOfBirth.name|localize_translatable_string }} - {% else %} - {{ 'Unknown country of birth'|trans }} - {% endif %} - {% endapply %}
            +
            +
            +
            {{ 'Country of birth'|trans }} :
            +
            {% apply spaceless %} + {% if person.countryOfBirth is not null %} + {{ person.countryOfBirth.name|localize_translatable_string }} + {% else %} + {{ 'Unknown country of birth'|trans }} + {% endif %} + {% endapply %}
            +
            +
            {%- endif -%} @@ -199,10 +203,14 @@ This view should receive those arguments: {%- endif -%} {%- if chill_person.fields.phonenumber == 'visible' -%} -
            -
            {{ 'Phonenumber'|trans }} :
            -
            {% if person.phonenumber is not empty %}
            {{ person.phonenumber|chill_format_phonenumber }}
            {% else %}{{ 'No data given'|trans }}{% endif %}
            -
            +
            +
            +
            +
            {{ 'Phonenumber'|trans }} :
            +
            {% if person.phonenumber is not empty %}
            {{ person.phonenumber|chill_format_phonenumber }}
            {% else %}{{ 'No data given'|trans }}{% endif %}
            +
            +
            +
            {% endif %} {%- if chill_person.fields.mobilenumber == 'visible' -%} @@ -263,3 +271,9 @@ This view should receive those arguments: {% endblock %} + +{% block js %} + + {{ encore_entry_script_tags('mod_blur') }} + +{% endblock js %} \ No newline at end of file From 78b651bdc40708e55d5dff0870363dcd12ed4b05 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 8 Oct 2021 23:44:06 +0200 Subject: [PATCH 038/209] blur added to requestor in twig template --- .../Resources/views/layout.html.twig | 5 +++-- .../views/AccompanyingPeriod/_list.html.twig | 16 ++++++++++------ .../Resources/views/Person/view.html.twig | 16 +--------------- 3 files changed, 14 insertions(+), 23 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig b/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig index 154a625f6..aaa5af914 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig @@ -16,10 +16,10 @@ \ No newline at end of file diff --git a/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig b/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig index aaa5af914..5f819f7f7 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig @@ -20,6 +20,7 @@ } .toggle{ margin-left: 10px; + cursor: pointer; } .blur { -webkit-filter: blur(5px); diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated/ParticipationItem.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated/ParticipationItem.vue index e19dfa05e..7b5fabfbd 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated/ParticipationItem.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated/ParticipationItem.vue @@ -9,6 +9,7 @@ addAltNames: true, addAge : true, hLevel : 3, + isConfidential : true, }" :person="participation.person" :returnPath="getAccompanyingCourseReturnPath"> diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources/ResourceItem.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources/ResourceItem.vue index bd70fa090..7f209f0d4 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources/ResourceItem.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources/ResourceItem.vue @@ -2,7 +2,7 @@ diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js index 52f3f6c36..c372ac7a7 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js @@ -86,7 +86,8 @@ const postParticipation = (id, payload, method) => { }) .then(response => { if (response.ok) { return response.json(); } - throw { msg: 'Error while sending AccompanyingPeriod Course participation.', sta: response.status, txt: response.statusText, err: new Error(), body: response.body }; + // TODO: adjust message according to status code? Or how to access the message from the violation array? + throw { msg: 'Error while sending AccompanyingPeriod Course participation', sta: response.status, txt: response.statusText, err: new Error(), body: response.body }; }); }; diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/OriginDemand.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/OriginDemand.vue index 30001028c..30ad6afe0 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/OriginDemand.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/OriginDemand.vue @@ -10,13 +10,13 @@ @@ -47,18 +47,18 @@ export default { }, methods: { getOptions() { - //console.log('loading origins list'); getListOrigins().then(response => new Promise((resolve, reject) => { this.options = response.results; resolve(); })); }, updateOrigin(value) { - //console.log('value', value); + console.log('value', value); this.$store.dispatch('updateOrigin', value); }, transText ({ text }) { - return text.fr //TODO multilang + const parsedText = JSON.parse(text); + return parsedText.fr; }, } } diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/index.js index e3fdec4a3..ace482d79 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/index.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/index.js @@ -2,6 +2,8 @@ import { createApp } from 'vue' import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n' import { appMessages } from './js/i18n' import { initPromise } from './store' +import VueToast from 'vue-toast-notification'; +import 'vue-toast-notification/dist/theme-sugar.css'; import App from './App.vue'; import Banner from './components/Banner.vue'; @@ -21,6 +23,7 @@ if (root === 'app') { }) .use(store) .use(i18n) + .use(VueToast) .component('app', App) .mount('#accompanying-course'); }); diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js index 9b69845cf..41e341dd8 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js @@ -77,7 +77,7 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise]) }, mutations: { catchError(state, error) { - console.log('### mutation: a new error have been catched and pushed in store !', error); + // console.log('### mutation: a new error have been catched and pushed in store !', error); state.errorMsg.push(error); }, removeParticipation(state, participation) { diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/LocationValidity.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/LocationValidity.php index 75c10ca75..b1b660596 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/LocationValidity.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/LocationValidity.php @@ -11,7 +11,7 @@ class LocationValidity extends Constraint { public $messagePersonLocatedMustBeAssociated = "The person where the course is located must be associated to the course. Change course's location before removing the person."; - public $messagePeriodMustRemainsLocated = "The period must remains located"; + public $messagePeriodMustRemainsLocated = "The period must remain located"; public function getTargets() { diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ParticipationOverlap.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ParticipationOverlap.php new file mode 100644 index 000000000..38d5516b5 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ParticipationOverlap.php @@ -0,0 +1,15 @@ +getStartDate()->getTimezone()); + + foreach ($participations as $participation) { + + if (!$participation instanceof AccompanyingPeriodParticipation) { + throw new UnexpectedTypeException($participation, AccompanyingPeriodParticipation::class); + } + + $personId = $participation->getPerson()->getId(); + + $particpationList[$personId][] = $participation; + + } + + foreach ($particpationList as $group) { + if (count($group) > 1) { + foreach ($group as $p) { + $overlaps->add($p->getStartDate(), $p->getEndDate(), $p->getId()); + } + } + } + + $overlaps->compute(); + + if ($overlaps->hasIntersections()) { + foreach ($overlaps->getIntersections() as list($start, $end, $ids)) { + $msg = $end === null ? $constraint->message : + $constraint->message; + + $this->context->buildViolation($msg) + ->setParameters([ + '{{ start }}' => $start->format('d-m-Y'), + '{{ end }}' => $end === null ? null : $end->format('d-m-Y'), + '{{ ids }}' => $ids, + ]) + ->addViolation(); + } + } + + } +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ResourceDuplicateCheck.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ResourceDuplicateCheck.php new file mode 100644 index 000000000..bfc9d62af --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ResourceDuplicateCheck.php @@ -0,0 +1,16 @@ +personRender = $personRender; + $this->thirdpartyRender = $thirdPartyRender; + } + + public function validate($resources, Constraint $constraint) + { + if (!$constraint instanceof ResourceDuplicateCheck) { + throw new UnexpectedTypeException($constraint, ParticipationOverlap::class); + } + + if (!$resources instanceof Collection) { + throw new UnexpectedTypeException($resources, Collection::class); + } + + $resourceList = []; + + foreach ($resources as $resource) { + $id = ($resource->getResource() instanceof Person ? 'p' : + 't').$resource->getResource()->getId(); + + if (\in_array($id, $resourceList, true)) { + $this->context->buildViolation($constraint->message) + ->setParameter('{{ name }}', $resource->getResource() instanceof Person ? $this->personRender->renderString($resource->getResource(), []) : + $this->thirdpartyRender->renderString($resource->getResource(), [])) + ->addViolation(); + } + + $resourceList[] = $id; + + } + + } + +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/config/services/validator.yaml b/src/Bundle/ChillPersonBundle/config/services/validator.yaml new file mode 100644 index 000000000..435f2f5b5 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/config/services/validator.yaml @@ -0,0 +1,6 @@ +services: + Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod: + autowire: true + autoconfigure: true + tags: ['validator.service_arguments'] + \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20211020131133.php b/src/Bundle/ChillPersonBundle/migrations/Version20211020131133.php new file mode 100644 index 000000000..031356cd3 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/migrations/Version20211020131133.php @@ -0,0 +1,31 @@ +addSql('CREATE UNIQUE INDEX person_unique ON chill_person_accompanying_period_resource (person_id, accompanyingperiod_id) WHERE person_id IS NOT NULL'); + $this->addSql('CREATE UNIQUE INDEX thirdparty_unique ON chill_person_accompanying_period_resource (thirdparty_id, accompanyingperiod_id) WHERE thirdparty_id IS NOT NULL'); + } + + public function down(Schema $schema): void + { + $this->addSql('DROP INDEX person_unique'); + $this->addSql('DROP INDEX thirdparty_unique'); + } +} diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20211021125359.php b/src/Bundle/ChillPersonBundle/migrations/Version20211021125359.php new file mode 100644 index 000000000..a4ed54254 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/migrations/Version20211021125359.php @@ -0,0 +1,36 @@ +addSql('ALTER TABLE chill_person_accompanying_period_participation ADD CONSTRAINT '. + "participations_no_overlap EXCLUDE USING GIST( + -- extension btree_gist required to include comparaison with integer + person_id WITH =, accompanyingperiod_id WITH =, + daterange(startdate, enddate) WITH && + ) + INITIALLY DEFERRED"); + } + + public function down(Schema $schema): void + { + $this->addSql('CREATE UNIQUE INDEX participation_unique ON chill_person_accompanying_period_participation (accompanyingperiod_id, person_id)'); + } +} diff --git a/src/Bundle/ChillPersonBundle/translations/validators.fr.yml b/src/Bundle/ChillPersonBundle/translations/validators.fr.yml index 0e77dae0c..6d2ccb3cb 100644 --- a/src/Bundle/ChillPersonBundle/translations/validators.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/validators.fr.yml @@ -41,3 +41,6 @@ household: household_membership: The end date must be after start date: La date de la fin de l'appartenance doit être postérieure à la date de début. Person with membership covering: Une personne ne peut pas appartenir à deux ménages simultanément. Or, avec cette modification, %person_name% appartiendrait à %nbHousehold% ménages à partir du %from%. + +# Accompanying period +'{{ name }} is already associated to this accompanying course.': '{{ name }} est déjà associé avec ce parcours.' \ No newline at end of file From 2b0093a351d8cd01c8b3c8f80d95018ae1af0fd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 12 Nov 2021 12:08:48 +0000 Subject: [PATCH 209/209] fix typo --- src/Bundle/ChillMainBundle/translations/messages.fr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index 7f7801805..082e4c83f 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -74,7 +74,7 @@ Choose a postal code: Choisir un code postal address: address_homeless: L'adresse est-elle celle d'un domicile fixe ? real address: Adresse d'un domicile - consider homeless: Cette addresse est incomplète + consider homeless: Cette adresse est incomplète address more: floor: ét corridor: coul