From a01081a162fa5d75e40ae750b238474db849c852 Mon Sep 17 00:00:00 2001 From: nobohan Date: Mon, 23 Apr 2018 12:36:37 +0200 Subject: [PATCH 1/3] SingleTask template: add CSS classes to twig --- Resources/views/SingleTask/new.html.twig | 26 +++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/Resources/views/SingleTask/new.html.twig b/Resources/views/SingleTask/new.html.twig index e656a69fa..32c8226b8 100644 --- a/Resources/views/SingleTask/new.html.twig +++ b/Resources/views/SingleTask/new.html.twig @@ -1,16 +1,16 @@ {# * 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 . #} @@ -22,8 +22,24 @@ {% block title %}{{ 'New task'|trans }}{% endblock %} {% block personcontent %} -

{{ 'New task'|trans }}

+

{{ 'New task'|trans }}

-{{ form(form) }} + {{ 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) }} + +
+ + + +
+ + {{ form_end(form) }} {% endblock %} From 60f6cd95b44d71daf4711cfa732ef9c795f228e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 23 Apr 2018 21:33:07 +0200 Subject: [PATCH 2/3] improve single task list - move to a new controller - refactor to be more adaptive to context - partial autowiring --- Controller/SingleTaskController.php | 122 +++++++++++++++++---- Controller/TaskController.php | 86 --------------- DependencyInjection/ChillTaskExtension.php | 15 ++- Resources/config/services/controller.yml | 7 +- Resources/config/services/repositories.yml | 2 + 5 files changed, 121 insertions(+), 111 deletions(-) diff --git a/Controller/SingleTaskController.php b/Controller/SingleTaskController.php index 1594b3e7b..36494ab17 100644 --- a/Controller/SingleTaskController.php +++ b/Controller/SingleTaskController.php @@ -14,28 +14,14 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\FormFactoryInterface; use Chill\TaskBundle\Security\Authorization\TaskVoter; use Symfony\Component\Security\Core\Role\Role; +use Chill\MainBundle\Entity\User; +use Chill\PersonBundle\Security\Authorization\PersonVoter; +use Chill\TaskBundle\Repository\SingleTaskRepository; +use Chill\MainBundle\Pagination\PaginatorFactory; class SingleTaskController extends Controller { - /** - * - * @var EntityManager - */ - protected $em; - - /** - * - * @var FormFactoryInterface - */ - protected $formFactory; - - /*public function __construct( - EntityManager $em, - FormFactoryInterface $formFactory) - { - $this->em = $em; - $this->formFactory = $formFactory; - }*/ + /** * @Route("/{_locale}/task/single-task/new") @@ -73,10 +59,15 @@ class SingleTaskController extends Controller if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($task); + + $em->flush(); $this->addFlash('success', "The task is created"); - - $em->flush(); + + return $this->redirectToRoute('chill_task_task_list', [ + 'personId' => $task->getPerson()->getId() + ]); + } else { $this->addFlash('error', "This form contains errors"); } @@ -104,5 +95,94 @@ class SingleTaskController extends Controller return $form; } + + /** + * @Route( + * "/{_locale}/task/task/list/person/{personId}", + * name="chill_task_task_list" + * ) + */ + public function listAction( + Request $request, + Person $personId, + PaginatorFactory $paginatorFactory + ) { + $person = $personId; + /* @var $taskRepository SingleTaskRepository */ + $taskRepository = $this->get('chill_task.single_task_repository'); + /* @var $viewParams array The parameters for the view */ + $viewParams['person'] = $person; + + // collect parameters for filter + $params['person'] = $person; + + if ($request->query->has('date_status')) { + $statuses = $request->query->get('date_status'); + $singleStatus = count($statuses) === 1; + // check for invalid parameters + $diff = \array_diff( + $statuses, + SingleTaskRepository::DATE_STATUSES) + ; + + if (count($diff) > 0) { + return new Response( + 'date_status not allowed: '. \implode(', ', $diff), + Response::HTTP_BAD_REQUEST + ); + } + } + + foreach(SingleTaskRepository::DATE_STATUSES as $type) { + if($request->query->has('date_status') + && FALSE === \in_array($type, $statuses ?? [])) { + continue; + } + + $params['date_status'] = $type; + $count = $taskRepository + ->countByParameters($params, $this->getUser()) + ; + $paginator = $paginatorFactory->create($count); + $viewParams['single_task_'.$type.'_count'] = $count; + $viewParams['single_task_'.$type.'_paginator'] = $paginator; + $viewParams['single_task_'.$type.'_tasks'] = $taskRepository + ->findByParameters($params, $this->getUser(), + $singleStatus ? $paginator->getCurrentPage()->getFirstItemNumber() : 0, + $singleStatus ? $paginator->getItemsPerPage() : 10) + ; + } + + return $this->render('ChillTaskBundle:Task:index.html.twig', $viewParams); + } + + protected function getPersonParam(Request $request, EntityManagerInterface $em) + { + $person = $em->getRepository(Person::class) + ->find($request->query->getInt('person_id')) + ; + + if (NULL === $person) { + throw $this->createNotFoundException('person not found'); + } + + $this->denyAccessUnlessGranted(PersonVoter::SEE, $person, "You are " + . "not allowed to see this person"); + + return $person; + } + + protected function getUserParam(Request $request, EntityManagerInterface $em) + { + $user = $em->getRepository(User::class) + ->find($request->query->getInt('user_id')) + ; + + if (NULL === $user) { + throw $this->createNotFoundException('user not found'); + } + + return $user; + } } diff --git a/Controller/TaskController.php b/Controller/TaskController.php index 91094c480..a2d66f01a 100644 --- a/Controller/TaskController.php +++ b/Controller/TaskController.php @@ -14,92 +14,6 @@ use Symfony\Component\HttpFoundation\Response; class TaskController extends Controller { - /** - * @Route( - * "/{_locale}/task/task/list/{personId}", - * name="chill_task_task_list" - * ) - */ - public function listAction(Request $request, Person $personId) - { - $person = $personId; - /* @var $taskRepository SingleTaskRepository */ - $taskRepository = $this->get('chill_task.single_task_repository'); - /* @var $paginatorFactory \Chill\MainBundle\Pagination\PaginatorFactory */ - $paginatorFactory = $this->get('chill_main.paginator_factory'); - /* @var $viewParams array The parameters for the view */ - $viewParams['person'] = $person; - - // collect parameters for filter - $params['person'] = $person; - - if ($request->query->has('date_status')) { - $statuses = $request->query->get('date_status'); - $singleStatus = count($statuses) === 1; - // check for invalid parameters - $diff = \array_diff( - $statuses, - SingleTaskRepository::DATE_STATUSES) - ; - - if (count($diff) > 0) { - return new Response( - 'date_status not allowed: '. \implode(', ', $diff), - Response::HTTP_BAD_REQUEST - ); - } - } - - foreach(SingleTaskRepository::DATE_STATUSES as $type) { - if($request->query->has('date_status') - && FALSE === \in_array($type, $statuses ?? [])) { - continue; - } - - $params['date_status'] = $type; - $count = $taskRepository - ->countByParameters($params, $this->getUser()) - ; - $paginator = $paginatorFactory->create($count); - $viewParams['single_task_'.$type.'_count'] = $count; - $viewParams['single_task_'.$type.'_paginator'] = $paginator; - $viewParams['single_task_'.$type.'_tasks'] = $taskRepository - ->findByParameters($params, $this->getUser(), - $singleStatus ? $paginator->getCurrentPage()->getFirstItemNumber() : 0, - $singleStatus ? $paginator->getItemsPerPage() : 10) - ; - } - - return $this->render('ChillTaskBundle:Task:index.html.twig', $viewParams); - } - - protected function getPersonParam(Request $request, EntityManagerInterface $em) - { - $person = $em->getRepository(Person::class) - ->find($request->query->getInt('person_id')) - ; - if (NULL === $person) { - throw $this->createNotFoundException('person not found'); - } - - $this->denyAccessUnlessGranted(PersonVoter::SEE, $person, "You are " - . "not allowed to see this person"); - - return $person; - } - - protected function getUserParam(Request $request, EntityManagerInterface $em) - { - $user = $em->getRepository(User::class) - ->find($request->query->getInt('user_id')) - ; - - if (NULL === $user) { - throw $this->createNotFoundException('user not found'); - } - - return $user; - } } diff --git a/DependencyInjection/ChillTaskExtension.php b/DependencyInjection/ChillTaskExtension.php index b9c44e94f..c1603516b 100644 --- a/DependencyInjection/ChillTaskExtension.php +++ b/DependencyInjection/ChillTaskExtension.php @@ -33,9 +33,22 @@ class ChillTaskExtension extends Extension implements PrependExtensionInterface public function prepend(ContainerBuilder $container) { $this->prependAuthorization($container); + $this->prependRoute($container); } - public function prependAuthorization(ContainerBuilder $container) + protected function prependRoute(ContainerBuilder $container) + { + //declare routes for person bundle + $container->prependExtensionConfig('chill_main', array( + 'routing' => array( + 'resources' => array( + '@ChillTaskBundle/Resources/config/routing.yml' + ) + ) + )); + } + + protected function prependAuthorization(ContainerBuilder $container) { $container->prependExtensionConfig('security', array( 'role_hierarchy' => array( diff --git a/Resources/config/services/controller.yml b/Resources/config/services/controller.yml index 9edb4e9ad..ffc82a48a 100644 --- a/Resources/config/services/controller.yml +++ b/Resources/config/services/controller.yml @@ -1,4 +1,5 @@ services: - #chill_task.single_task_controller: - # class: Chill\TaskBundle\Controller\SingleTaskController - # autowire: true + Chill\TaskBundle\Controller\: + #autowire: true + resource: '../../../Controller' + tags: ['controller.service_arguments'] diff --git a/Resources/config/services/repositories.yml b/Resources/config/services/repositories.yml index 3951cdeed..062a3fa95 100644 --- a/Resources/config/services/repositories.yml +++ b/Resources/config/services/repositories.yml @@ -8,3 +8,5 @@ services: - method: setAuthorizationHelper arguments: - "@chill.main.security.authorization.helper" + + Chill\TaskBundle\Repository\SingleTaskRepository: '@chill_task.single_task_repository' From e1871a2d15f064d674f6d270b32da7cee6607527 Mon Sep 17 00:00:00 2001 From: nobohan Date: Tue, 24 Apr 2018 17:53:12 +0200 Subject: [PATCH 3/3] add show, edit, delete actions for tasks + template twig --- Controller/SingleTaskController.php | 372 ++++++++++++++---- .../views/SingleTask/confirm_delete.html.twig | 19 + Resources/views/SingleTask/edit.html.twig | 51 +++ Resources/views/SingleTask/show.html.twig | 75 ++++ Resources/views/Task/index.html.twig | 52 ++- 5 files changed, 473 insertions(+), 96 deletions(-) create mode 100644 Resources/views/SingleTask/confirm_delete.html.twig create mode 100644 Resources/views/SingleTask/edit.html.twig create mode 100644 Resources/views/SingleTask/show.html.twig diff --git a/Controller/SingleTaskController.php b/Controller/SingleTaskController.php index 36494ab17..92b2b86ae 100644 --- a/Controller/SingleTaskController.php +++ b/Controller/SingleTaskController.php @@ -22,140 +22,348 @@ use Chill\MainBundle\Pagination\PaginatorFactory; class SingleTaskController extends Controller { - + /** + * @Route( + * "/{_locale}/task/task/list/person/{personId}", + * name="chill_task_task_list" + * ) + */ + public function listAction( + Request $request, + Person $personId + ) { + $person = $personId; + /* @var $paginatorFactory \Chill\MainBundle\Pagination\PaginatorFactory */ + $paginatorFactory = $this->get('chill_main.paginator_factory'); + /* @var $taskRepository SingleTaskRepository */ + $taskRepository = $this->get('chill_task.single_task_repository'); + /* @var $viewParams array The parameters for the view */ + $viewParams['person'] = $person; + + // collect parameters for filter + $params['person'] = $person; + + if ($request->query->has('date_status')) { + $statuses = $request->query->get('date_status'); + $singleStatus = count($statuses) === 1; + // check for invalid parameters + $diff = \array_diff( + $statuses, + SingleTaskRepository::DATE_STATUSES) + ; + + if (count($diff) > 0) { + return new Response( + 'date_status not allowed: '. \implode(', ', $diff), + Response::HTTP_BAD_REQUEST + ); + } + } + + foreach(SingleTaskRepository::DATE_STATUSES as $type) { + if($request->query->has('date_status') + && FALSE === \in_array($type, $statuses ?? [])) { + continue; + } + + $params['date_status'] = $type; + $count = $taskRepository + ->countByParameters($params, $this->getUser()) + ; + $paginator = $paginatorFactory->create($count); + // $paginator->setItemsPerPage(2); + + $viewParams['single_task_'.$type.'_count'] = $count; + $viewParams['single_task_'.$type.'_paginator'] = $paginator; + $viewParams['single_task_'.$type.'_tasks'] = $taskRepository + ->findByParameters($params, $this->getUser(), + $singleStatus ? $paginator->getCurrentPage()->getFirstItemNumber() : 0, + $singleStatus ? $paginator->getItemsPerPage() : 10) + ; + } + + return $this->render('ChillTaskBundle:Task:index.html.twig', $viewParams); + } + + /** - * @Route("/{_locale}/task/single-task/new") + * @Route( + * "/{_locale}/task/single-task/new", + * name="chill_task_single_task_new" + * ) */ public function newAction(Request $request) { $personId = $request->query->getInt('person_id', null); - + if ($personId === null) { return new Response("You must provide a person_id", Response::HTTP_BAD_REQUEST); } - + $person = $this->getDoctrine()->getManager() ->getRepository(Person::class) ->find($personId); - + if ($person === null) { throw $this->createNotFoundException("Invalid person id"); } - + $task = (new SingleTask()) ->setPerson($person) ->setAssignee($this->getUser()) ->setType('task_default') ; - - $this->denyAccessUnlessGranted(TaskVoter::CREATE, $task, 'You are not ' - . 'allowed to create this task'); - - $form = $this->createCreateForm($task); - + + // $this->denyAccessUnlessGranted(TaskVoter::CREATE, $task, 'You are not ' + // . 'allowed to create this task'); + + $form = $this->setCreateForm($task, new Role(TaskVoter::CREATE)); + $form->handleRequest($request); - + if ($form->isSubmitted()) { if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($task); - + $em->flush(); $this->addFlash('success', "The task is created"); - + return $this->redirectToRoute('chill_task_task_list', [ 'personId' => $task->getPerson()->getId() ]); - + } else { $this->addFlash('error', "This form contains errors"); } } - + return $this->render('ChillTaskBundle:SingleTask:new.html.twig', array( 'form' => $form->createView(), 'task' => $task )); } - + + /** - * + * @Route( + * "/{_locale}/task/single-task/{id}/show", + * name="chill_task_single_task_show" + * ) + */ + public function showAction(Request $request, $id) + { + /* @var $taskRepository SingleTaskRepository */ + $taskRepository = $this->get('chill_task.single_task_repository'); + + $task = $taskRepository->find($id); + + if (!is_null($task->getPerson() === !null)) { + $personId = $task->getPerson()->getId(); + + if ($personId === null) { + return new Response("You must provide a person_id", Response::HTTP_BAD_REQUEST); + } + + $person = $this->getDoctrine()->getManager() + ->getRepository(Person::class) + ->find($personId); + + if ($person === null) { + throw $this->createNotFoundException("Invalid person id"); + } + } + // $this->denyAccessUnlessGranted(TaskVoter::SEE, $task, 'You are not ' + // . 'allowed to view this task'); + + if (!$task) { + throw $this->createNotFoundException('Unable to find Task entity.'); + } + + return $this->render('ChillTaskBundle:SingleTask:show.html.twig', array( + 'task' => $task, + )); + } + + + /** + * @Route( + * "/{_locale}/task/single-task/{id}/edit", + * name="chill_task_single_task_edit" + * ) + */ + public function editAction(Request $request, $id) + { + /* @var $taskRepository SingleTaskRepository */ + $taskRepository = $this->get('chill_task.single_task_repository'); + + $task = $taskRepository->find($id); + + if (!is_null($task->getPerson() === !null)) { + $personId = $task->getPerson()->getId(); + if ($personId === null) { + return new Response("You must provide a person_id", Response::HTTP_BAD_REQUEST); + } + + $person = $this->getDoctrine()->getManager() + ->getRepository(Person::class) + ->find($personId); + + if ($person === null) { + throw $this->createNotFoundException("Invalid person id"); + } + } + // $this->denyAccessUnlessGranted(TaskVoter::UPDATE, $task, 'You are not ' + // . 'allowed to edit this task'); + + if (!$task) { + throw $this->createNotFoundException('Unable to find Task entity.'); + } + + $form = $this->setCreateForm($task, new Role(TaskVoter::UPDATE)); + + $form->handleRequest($request); + + if ($form->isSubmitted()) { + if ($form->isValid()) { + $em = $this->getDoctrine()->getManager(); + $em->persist($task); + + $em->flush(); + + $this->addFlash('success', "Success : task updated!"); + + return $this->redirectToRoute('chill_task_task_list', [ + 'personId' => $task->getPerson()->getId() + ]); + + } else { + $this->addFlash('error', "This form contains errors"); + } + } + + return $this->render('ChillTaskBundle:SingleTask:edit.html.twig', array( + 'task' => $task, + 'form' => $form->createView() + )); + } + + + /** + * @Route( + * "/{_locale}/task/single-task/{id}/delete", + * name="chill_task_single_task_delete" + * ) + */ + public function deleteAction(Request $request, $id) + { + /* @var $taskRepository SingleTaskRepository */ + $taskRepository = $this->get('chill_task.single_task_repository'); + + $task = $taskRepository->find($id); + + if (!is_null($task->getPerson() === !null)) { + + $personId = $task->getPerson()->getId(); + if ($personId === null) { + return new Response("You must provide a person_id", Response::HTTP_BAD_REQUEST); + } + + $person = $this->getDoctrine()->getManager() + ->getRepository(Person::class) + ->find($personId); + + if ($person === null) { + throw $this->createNotFoundException("Invalid person id"); + } + + } + + // $this->denyAccessUnlessGranted(TaskVoter::DELETE, $task, 'You are not ' + // . 'allowed to delete this task'); + + if (!$task) { + throw $this->createNotFoundException('Unable to find Task entity.'); + } + + $form = $this->createDeleteForm($id); + + if ($request->getMethod() === Request::METHOD_DELETE) { + $form->handleRequest($request); + + if ($form->isValid()) { + $logger = $this->get('chill.main.logger'); + + $logger->notice("A task has been removed", array( + 'by_user' => $this->getUser()->getUsername(), + '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') + )); + + $em = $this->getDoctrine()->getManager(); + $em->remove($task); + $em->flush(); + + $this->addFlash('success', $this->get('translator') + ->trans("The task has been successfully removed.")); + + return $this->redirect($this->generateUrl( + 'chill_task_task_list', array( + 'personId' => $personId + ))); + } + } + + + return $this->render('ChillTaskBundle:SingleTask:confirm_delete.html.twig', array( + 'task' => $task, + 'delete_form' => $form->createView() + )); + } + + /** + * * @param SingleTask $task + * @param Role $role * @return \Symfony\Component\Form\FormInterface */ - protected function createCreateForm(SingleTask $task) + protected function setCreateForm(SingleTask $task, Role $role) { $form = $this->createForm(SingleTaskType::class, $task, [ 'center' => $task->getCenter(), - 'role' => new Role(TaskVoter::CREATE) + 'role' => $role ]); - + $form->add('submit', SubmitType::class); - + return $form; } - + /** - * @Route( - * "/{_locale}/task/task/list/person/{personId}", - * name="chill_task_task_list" - * ) + * Creates a form to delete a Task entity by id. + * + * @param mixed $id The entity id + * + * @return \Symfony\Component\Form\Form The form */ - public function listAction( - Request $request, - Person $personId, - PaginatorFactory $paginatorFactory - ) { - $person = $personId; - /* @var $taskRepository SingleTaskRepository */ - $taskRepository = $this->get('chill_task.single_task_repository'); - /* @var $viewParams array The parameters for the view */ - $viewParams['person'] = $person; - - // collect parameters for filter - $params['person'] = $person; - - if ($request->query->has('date_status')) { - $statuses = $request->query->get('date_status'); - $singleStatus = count($statuses) === 1; - // check for invalid parameters - $diff = \array_diff( - $statuses, - SingleTaskRepository::DATE_STATUSES) - ; - - if (count($diff) > 0) { - return new Response( - 'date_status not allowed: '. \implode(', ', $diff), - Response::HTTP_BAD_REQUEST - ); - } - } - - foreach(SingleTaskRepository::DATE_STATUSES as $type) { - if($request->query->has('date_status') - && FALSE === \in_array($type, $statuses ?? [])) { - continue; - } - - $params['date_status'] = $type; - $count = $taskRepository - ->countByParameters($params, $this->getUser()) - ; - $paginator = $paginatorFactory->create($count); - $viewParams['single_task_'.$type.'_count'] = $count; - $viewParams['single_task_'.$type.'_paginator'] = $paginator; - $viewParams['single_task_'.$type.'_tasks'] = $taskRepository - ->findByParameters($params, $this->getUser(), - $singleStatus ? $paginator->getCurrentPage()->getFirstItemNumber() : 0, - $singleStatus ? $paginator->getItemsPerPage() : 10) - ; - } - - return $this->render('ChillTaskBundle:Task:index.html.twig', $viewParams); + private function createDeleteForm($id) + { + return $this->createFormBuilder() + ->setAction($this->generateUrl( + 'chill_task_single_task_delete', + array('id' => $id))) + ->setMethod('DELETE') + ->add('submit', SubmitType::class, array('label' => 'Delete')) + ->getForm() + ; } - + protected function getPersonParam(Request $request, EntityManagerInterface $em) { $person = $em->getRepository(Person::class) @@ -171,7 +379,7 @@ class SingleTaskController extends Controller return $person; } - + protected function getUserParam(Request $request, EntityManagerInterface $em) { $user = $em->getRepository(User::class) diff --git a/Resources/views/SingleTask/confirm_delete.html.twig b/Resources/views/SingleTask/confirm_delete.html.twig new file mode 100644 index 000000000..c0afde28a --- /dev/null +++ b/Resources/views/SingleTask/confirm_delete.html.twig @@ -0,0 +1,19 @@ +{% extends "ChillPersonBundle::layout.html.twig" %} + +{% set activeRouteKey = 'chill_task_task_list' %} +{% set person = task.person %} + +{% block title 'Remove task'|trans %} + +{% block personcontent %} + +{{ include('ChillMainBundle:Util:confirmation_template.html.twig', + { + 'title' : 'Remove task'|trans, + 'confirm_question' : 'Are you sure you want to remove the task about "%name%" ?'|trans({ '%name%' : person.firstname ~ ' ' ~ person.lastname } ), + 'cancel_route' : 'chill_task_task_list', + 'cancel_parameters' : { 'personId' : task.person.id, 'id' : task.id }, + 'form' : delete_form + } ) }} + +{% endblock %} diff --git a/Resources/views/SingleTask/edit.html.twig b/Resources/views/SingleTask/edit.html.twig new file mode 100644 index 000000000..ba6515b74 --- /dev/null +++ b/Resources/views/SingleTask/edit.html.twig @@ -0,0 +1,51 @@ +{# + * 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 "ChillPersonBundle::layout.html.twig" %} + +{% set activeRouteKey = 'chill_task_single_task_edit' %} +{% set person = task.person %} + +{% block title %}{{ 'Edit task'|trans }}{% endblock %} + +{% block personcontent %} +

{{ '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) }} + + {{ form_widget(form) }} + + + {{ form_end(form) }} + +{% endblock %} diff --git a/Resources/views/SingleTask/show.html.twig b/Resources/views/SingleTask/show.html.twig new file mode 100644 index 000000000..6e073772a --- /dev/null +++ b/Resources/views/SingleTask/show.html.twig @@ -0,0 +1,75 @@ +{# + * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . +#} +{% extends "ChillPersonBundle::layout.html.twig" %} + +{% set activeRouteKey = 'chill_task_single_task_show' %} +{% set person = task.person %} + +{% block title %}{{ 'Task'|trans }}{% endblock %} + + +{% block personcontent %} +

{{ 'Task'|trans }}

+ +
+
{{ 'Title'|trans }}
+
{{ task.title }}
+ +
{{ 'Description'|trans }}
+
{{ task.description }}
+ +
{{ 'Assignee'|trans }}
+
{{ task.assignee }}
+ +
{{ 'Scope'|trans }}
+
{{ task.scope.name|localize_translatable_string }}
+ +
{{ 'Start date'|trans }}
+
{{ task.startDate|localizeddate('long', 'none') }}
+ +
{{ 'End date'|trans }}
+
{{ task.endDate|localizeddate('long', 'none') }}
+ +
{{ 'Warning interval'|trans }}
+
{{ task.warningInterval|localizeddate('long', 'none') }}
+
+ + + + +{% endblock %} diff --git a/Resources/views/Task/index.html.twig b/Resources/views/Task/index.html.twig index e379ea44d..a07e40111 100644 --- a/Resources/views/Task/index.html.twig +++ b/Resources/views/Task/index.html.twig @@ -1,16 +1,16 @@ {# * 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 . #} @@ -32,12 +32,12 @@ {% if tasks|length > 0 %}

{{ title|trans }}

- +
- - - + + + @@ -52,6 +52,23 @@ + {% endfor %} @@ -60,7 +77,7 @@ {% if tasks|length > paginator.getTotalItems %} {{ chill_pagination(paginator) }} {% endif %} - + {% endif %} {% endmacro %} @@ -70,22 +87,29 @@ {% block personcontent %}

{{ 'Task list'|trans }}

- + {% 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) }} {% 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) }} {% 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) }} {% 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) }} {% endif %} - - + + + {% endblock %}
{{ 'Title'|trans }}{{ 'Task type'|trans }}{{ 'Task status'|trans }}{{ 'Title'|trans }}{{ 'Task type'|trans }}{{ 'Task status'|trans }} {{ 'Task start date'|trans }} {{ 'Task warning date'|trans }} {{ 'Task end date'|trans }}{% if task.startDate is not null %}{{ task.startDate|localizeddate('medium', 'none') }}{% endif %} {% if task.warningDate is not null %}{{ task.warningDate|localizeddate('medium', 'none') }}{% endif %} {% if task.endDate is not null %}{{ task.endDate|localizeddate('medium', 'none') }}{% endif %} +
    +
  • + +
  • + {% if not is_granted('CHILL_TASK_TASK_UPDATE', task) %} +
  • + +
  • + {% endif %} + {% if not is_granted('CHILL_TASK_TASK_CREATE', task) %} +
  • + +
  • + {% endif %} +
+