add list by person, user and scope + formatting of submit button in edit

This commit is contained in:
nobohan 2018-04-26 21:54:49 +02:00
parent 4b391d03d5
commit bf0db0de3f
7 changed files with 243 additions and 130 deletions

View File

@ -18,6 +18,8 @@ use Chill\MainBundle\Pagination\PaginatorFactory;
use Chill\TaskBundle\Repository\SingleTaskRepository; use Chill\TaskBundle\Repository\SingleTaskRepository;
use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\Security\Authorization\PersonVoter; use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Chill\PersonBundle\Entity\PersonRepository;
use Chill\MainBundle\Entity\UserRepository;
class SingleTaskController extends Controller class SingleTaskController extends Controller
{ {
@ -41,7 +43,7 @@ class SingleTaskController extends Controller
->find($personId); ->find($personId);
if ($person === null) { if ($person === null) {
throw $this->createNotFoundException("Invalid person id"); $this->createNotFoundException("Invalid person id");
} }
$task = (new SingleTask()) $task = (new SingleTask())
@ -280,44 +282,96 @@ class SingleTaskController extends Controller
return $form; return $form;
} }
/** /**
* @Route( * @Route(
* "/{_locale}/task/task/list/person/{personId}", * "/{_locale}/task/singletask/list",
* name="chill_task_task_list_by_person" * name="chill_task_singletask_list"
* ) * )
*/ */
public function listAction( public function listAction(
Request $request, Request $request,
Person $personId, PaginatorFactory $paginatorFactory,
PaginatorFactory $paginatorFactory, SingleTaskRepository $taskRepository,
SingleTaskRepository $taskRepository PersonRepository $personRepository
) { ) {
$person = $personId;
/* @var $viewParams array The parameters for the view */ /* @var $viewParams array The parameters for the view */
$viewParams['person'] = $person; /* @var $params array The parameters for the query */
$viewParams['person'] = null;
$params['person'] = null;
$viewParams['user'] = null;
$params['user'] = null;
$viewParams['center'] = null;
$params['center'] = null;
// Get parameters from url
if ($request->query->has('person_id')) {
$personId = $request->query->get('person_id');
$person = $personRepository->find($personId);
if ($person === null) {
throw $this->createNotFoundException("This person ' $personId ' does not exist.");
}
$this->denyAccessUnlessGranted(PersonVoter::SEE, $person);
$viewParams['person'] = $person;
$params['person'] = $person;
}
if ($request->query->has('user_id')) {
$userId = $request->query->get('user_id');
$user = $this->getDoctrine()->getManager()
->getRepository('ChillMainBundle:User')
->find($userId);
if ($user === null) {
throw $this->createNotFoundException("This user ' $userId ' does not exist.");
}
$viewParams['user'] = $user;
$params['user'] = $user;
}
if ($request->query->has('scope_id')) {
$scopeId = $request->query->get('scope_id');
$scope = $this->getDoctrine()->getManager()
->getRepository('ChillMainBundle:Scope')
->find($scopeId);
if ($scope === null) {
throw $this->createNotFoundException("This scope' $scopeId 'does not exist.");
}
$viewParams['scope'] = $scope;
$params['scope'] = $scope;
}
// collect parameters for filter // collect parameters for filter
$params['person'] = $person;
$possibleStatuses = \array_merge(SingleTaskRepository::DATE_STATUSES, [ 'closed' ]); $possibleStatuses = \array_merge(SingleTaskRepository::DATE_STATUSES, [ 'closed' ]);
$statuses = $request->query->get('status', $possibleStatuses); $statuses = $request->query->get('status', $possibleStatuses);
// check for invalid statuses // check for invalid statuses
$diff = \array_diff($statuses, $possibleStatuses); $diff = \array_diff($statuses, $possibleStatuses);
if (count($diff) > 0) { if (count($diff) > 0) {
return new Response( return new Response(
'date_status not allowed: '. \implode(', ', $diff), 'date_status not allowed: '. \implode(', ', $diff),
Response::HTTP_BAD_REQUEST Response::HTTP_BAD_REQUEST
); );
} }
$viewParams['isSingleStatus'] = $singleStatus = count($statuses) === 1; $viewParams['isSingleStatus'] = $singleStatus = count($statuses) === 1;
foreach($statuses as $status) { foreach($statuses as $status) {
if($request->query->has('status') if($request->query->has('status')
&& FALSE === \in_array($status, $statuses)) { && FALSE === \in_array($status, $statuses)) {
continue; continue;
} }
// different query if regarding to date or 'closed' // different query if regarding to date or 'closed'
if (in_array($status, SingleTaskRepository::DATE_STATUSES)) { if (in_array($status, SingleTaskRepository::DATE_STATUSES)) {
$params['date_status'] = $status; $params['date_status'] = $status;
@ -326,23 +380,30 @@ class SingleTaskController extends Controller
$params['date_status'] = null; $params['date_status'] = null;
$params['is_closed'] = true; $params['is_closed'] = true;
} }
$count = $taskRepository $count = $taskRepository
->countByParameters($params, $this->getUser()) ->countByParameters($params, $this->getUser())
; ;
$paginator = $paginatorFactory->create($count); $paginator = $paginatorFactory->create($count);
$viewParams['single_task_'.$status.'_count'] = $count; $viewParams['single_task_'.$status.'_count'] = $count;
$viewParams['single_task_'.$status.'_paginator'] = $paginator; $viewParams['single_task_'.$status.'_paginator'] = $paginator;
$viewParams['single_task_'.$status.'_tasks'] = $taskRepository $viewParams['single_task_'.$status.'_tasks'] = $taskRepository
->findByParameters($params, $this->getUser(), ->findByParameters($params, $this->getUser(),
$singleStatus ? $paginator->getCurrentPage()->getFirstItemNumber() : 0, $singleStatus ? $paginator->getCurrentPage()->getFirstItemNumber() : 0,
$singleStatus ? $paginator->getItemsPerPage() : 10) $singleStatus ? $paginator->getItemsPerPage() : 10)
; ;
} }
return $this->render('ChillTaskBundle:Task:index.html.twig', $viewParams); if ($request->query->has('person_id')){
$viewParams['layout'] = 'ChillPersonBundle::layout.html.twig';
} else {
$viewParams['layout'] = 'ChillMainBundle::layout.html.twig';
}
return $this->render('ChillTaskBundle:SingleTask:index.html.twig', $viewParams);
} }
protected function getPersonParam(Request $request, EntityManagerInterface $em) protected function getPersonParam(Request $request, EntityManagerInterface $em)
{ {
$person = $em->getRepository(Person::class) $person = $em->getRepository(Person::class)
@ -358,7 +419,7 @@ class SingleTaskController extends Controller
return $person; return $person;
} }
protected function getUserParam(Request $request, EntityManagerInterface $em) protected function getUserParam(Request $request, EntityManagerInterface $em)
{ {
$user = $em->getRepository(User::class) $user = $em->getRepository(User::class)

View File

@ -16,12 +16,12 @@ class TaskController extends Controller
{ {
/** /**
* Apply a transition to a task * Apply a transition to a task
* *
* @Route( * @Route(
* "/{_locale}/task/transition/{kind}/{taskId}/{transition}", * "/{_locale}/task/transition/{kind}/{taskId}/{transition}",
* name="chill_task_task_transition" * name="chill_task_task_transition"
* ) * )
* *
* @param string $kind * @param string $kind
* @param int $taskId * @param int $taskId
* @param string $transition * @param string $transition
@ -32,7 +32,7 @@ class TaskController extends Controller
* @return Response * @return Response
*/ */
public function applyTransitionAction( public function applyTransitionAction(
$kind, $kind,
$taskId, $taskId,
$transition, $transition,
SingleTaskRepository $singleTaskRepository, SingleTaskRepository $singleTaskRepository,
@ -51,32 +51,32 @@ class TaskController extends Controller
); );
break; break;
default: default:
return new Response("The type '$kind' is not implemented", return new Response("The type '$kind' is not implemented",
Response::HTTP_BAD_REQUEST); Response::HTTP_BAD_REQUEST);
} }
if (NULL === $task) { if (NULL === $task) {
$this->createHttpNotFoundException("task with id '$taskId' and type " $this->createNotFoundException("task with id '$taskId' and type "
. "'$type' does not exists"); . "'$type' does not exists");
} }
// we simply check that the user can see the task. Other ACL checks // we simply check that the user can see the task. Other ACL checks
// should be performed using `guard` events. // should be performed using `guard` events.
$this->denyAccessUnlessGranted(TaskVoter::SHOW, $task); $this->denyAccessUnlessGranted(TaskVoter::SHOW, $task);
$workflow = $registry->get($task); $workflow = $registry->get($task);
if ($workflow->can($task, $transition)) { if ($workflow->can($task, $transition)) {
$workflow->apply($task, $transition); $workflow->apply($task, $transition);
$em->flush(); $em->flush();
$this->addFlash('success', 'The transition is sucessfully appliyed'); $this->addFlash('success', 'The transition is sucessfully appliyed');
} else { } else {
$this->addFlash('error', 'The transition could not be appliyed'); $this->addFlash('error', 'The transition could not be appliyed');
} }
return $this->redirect($request->query->get('return_path', $defaultReturnPath)); return $this->redirect($request->query->get('return_path', $defaultReturnPath));
} }
} }

View File

@ -14,35 +14,35 @@ use Doctrine\DBAL\Types\Type;
*/ */
class SingleTaskRepository extends \Doctrine\ORM\EntityRepository class SingleTaskRepository extends \Doctrine\ORM\EntityRepository
{ {
const DATE_STATUS_ENDED = 'ended'; const DATE_STATUS_ENDED = 'ended';
const DATE_STATUS_WARNING = 'warning'; const DATE_STATUS_WARNING = 'warning';
const DATE_STATUS_CURRENT = 'current'; const DATE_STATUS_CURRENT = 'current';
const DATE_STATUS_NOT_STARTED = 'not_started'; const DATE_STATUS_NOT_STARTED = 'not_started';
const DATE_STATUSES = [ const DATE_STATUSES = [
self::DATE_STATUS_ENDED, self::DATE_STATUS_ENDED,
self::DATE_STATUS_WARNING, self::DATE_STATUS_WARNING,
self::DATE_STATUS_CURRENT, self::DATE_STATUS_CURRENT,
self::DATE_STATUS_NOT_STARTED self::DATE_STATUS_NOT_STARTED
]; ];
/** /**
* *
* @var AuthorizationHelper * @var AuthorizationHelper
*/ */
protected $authorizationHelper; protected $authorizationHelper;
public function setAuthorizationHelper(AuthorizationHelper $authorizationHelper) public function setAuthorizationHelper(AuthorizationHelper $authorizationHelper)
{ {
$this->authorizationHelper = $authorizationHelper; $this->authorizationHelper = $authorizationHelper;
} }
/** /**
* Count the tasks for given parameters. * Count the tasks for given parameters.
* *
* The parameters are describe in @see SingleTaskRepository::filterByParameters. * The parameters are describe in @see SingleTaskRepository::filterByParameters.
* *
* @see SingleTaskRepository::filterByParameters * @see SingleTaskRepository::filterByParameters
* @param array $params * @param array $params
* @param User $currentUser * @param User $currentUser
@ -52,26 +52,28 @@ class SingleTaskRepository extends \Doctrine\ORM\EntityRepository
{ {
$qb = $this->createQueryBuilder('st') $qb = $this->createQueryBuilder('st')
->select('COUNT(st)'); ->select('COUNT(st)');
$this->buildQuery($qb, $params, $currentUser); $this->buildQuery($qb, $params, $currentUser);
return (int) $qb return (int) $qb
->getQuery() ->getQuery()
->getSingleScalarResult() ->getSingleScalarResult()
; ;
} }
/** /**
* Find task for given parameters. * Find task for given parameters.
* *
* Available parameters: * Available parameters:
* *
* - `person` : filter by person associated with the task ; * - `person` : filter by person associated with the task ;
* - `user` : filter by user that created the task ;
* - `scope` : filter by scope associated with the task ;
* - `date_status`: type of task. To choose between : * - `date_status`: type of task. To choose between :
* `ended`, `warning`, `current`, `not_started` * `ended`, `warning`, `current`, `not_started` ;
* - `is_closed`: boolean. Indicate if the tasks must be closed (true) or * - `is_closed`: boolean. Indicate if the tasks must be closed (true) or
* opened * opened
* *
* @param type $params * @param type $params
* @param User $currentUser * @param User $currentUser
* @param int $firstResult * @param int $firstResult
@ -81,56 +83,69 @@ class SingleTaskRepository extends \Doctrine\ORM\EntityRepository
public function findByParameters($params, User $currentUser, int $firstResult = 0, int $maxResults = 50) public function findByParameters($params, User $currentUser, int $firstResult = 0, int $maxResults = 50)
{ {
$qb = $this->createQueryBuilder('st'); $qb = $this->createQueryBuilder('st');
$this->buildQuery($qb, $params, $currentUser); $this->buildQuery($qb, $params, $currentUser);
$qb $qb
->setMaxResults($maxResults) ->setMaxResults($maxResults)
->setFirstResult($firstResult) ->setFirstResult($firstResult)
; ;
return $qb return $qb
->getQuery() ->getQuery()
->getResult() ->getResult()
; ;
} }
protected function buildQuery(QueryBuilder $qb, $params, User $currentUser) protected function buildQuery(QueryBuilder $qb, $params, User $currentUser)
{ {
$this->buildACLQuery($qb, $currentUser); $this->buildACLQuery($qb, $currentUser);
if (\array_key_exists('person', $params) and !empty($params['person'])) { if (\array_key_exists('person', $params) and !empty($params['person'])) {
$qb->andWhere($qb->expr()->eq('st.person', ':person')); $qb->andWhere($qb->expr()->eq('st.person', ':person'));
$qb->setParameter('person', $params['person']); $qb->setParameter('person', $params['person']);
} }
if (\array_key_exists('user', $params) and !empty($params['user'])) {
$qb->andWhere($qb->expr()->eq('st.assignee', ':user'));
$qb->setParameter('user', $params['user']);
}
if (\array_key_exists('scope', $params) and !empty($params['scope'])) {
$qb->andWhere($qb->expr()->eq('st.circle', ':scope'));
$qb->setParameter('scope', $params['scope']);
}
if (\array_key_exists('date_status', $params) and !empty($params['date_status'])) { if (\array_key_exists('date_status', $params) and !empty($params['date_status'])) {
$this->addTypeFilter($qb, $params); $this->addTypeFilter($qb, $params);
} }
if (\array_key_exists('is_closed', $params)) { if (\array_key_exists('is_closed', $params)) {
$qb->andWhere($this->buildIsClosed($qb, !$params['is_closed'])); $qb->andWhere($this->buildIsClosed($qb, !$params['is_closed']));
} }
} }
protected function addTypeFilter(QueryBuilder $qb, $params) protected function addTypeFilter(QueryBuilder $qb, $params)
{ {
$andWhere = $qb->expr()->andX(); $andWhere = $qb->expr()->andX();
switch ($params['date_status']) { switch ($params['date_status']) {
case self::DATE_STATUS_ENDED: case self::DATE_STATUS_ENDED:
$andWhere $andWhere
->add($this->buildNowIsAfterEndDate($qb)) ->add($this->buildNowIsAfterEndDate($qb))
; ;
break; break;
case self::DATE_STATUS_WARNING: case self::DATE_STATUS_WARNING:
$andWhere $andWhere
->add($this->buildNowIsAfterEndDate($qb, true)) ->add($this->buildNowIsAfterEndDate($qb, true))
->add($this->buildNowIsAfterWarningDate($qb)) ->add($this->buildNowIsAfterWarningDate($qb))
; ;
break; break;
case self::DATE_STATUS_CURRENT: case self::DATE_STATUS_CURRENT:
// st.endDate is NULL or (st.endDate is not null and st.endDate < now)) // st.endDate is NULL or (st.endDate is not null and st.endDate < now))
$andWhere $andWhere
@ -139,7 +154,7 @@ class SingleTaskRepository extends \Doctrine\ORM\EntityRepository
->add($this->buildNowIsAfterStartDate($qb, false)) ->add($this->buildNowIsAfterStartDate($qb, false))
; ;
break; break;
case self::DATE_STATUS_NOT_STARTED: case self::DATE_STATUS_NOT_STARTED:
$andWhere $andWhere
->add($this->buildNowIsAfterEndDate($qb, true)) ->add($this->buildNowIsAfterEndDate($qb, true))
@ -150,7 +165,7 @@ class SingleTaskRepository extends \Doctrine\ORM\EntityRepository
$qb->setParameter('now', new \DateTime('today'), Type::DATE); $qb->setParameter('now', new \DateTime('today'), Type::DATE);
$qb->andWhere($andWhere); $qb->andWhere($andWhere);
} }
private function buildNowIsAfterEndDate(QueryBuilder $qb, $negative = false) private function buildNowIsAfterEndDate(QueryBuilder $qb, $negative = false)
{ {
if ($negative === false) { if ($negative === false) {
@ -169,7 +184,7 @@ class SingleTaskRepository extends \Doctrine\ORM\EntityRepository
; ;
} }
} }
private function buildNowIsAfterWarningDate(QueryBuilder $qb, bool $negative = false) private function buildNowIsAfterWarningDate(QueryBuilder $qb, bool $negative = false)
{ {
if ($negative === false) { if ($negative === false) {
@ -195,7 +210,7 @@ class SingleTaskRepository extends \Doctrine\ORM\EntityRepository
; ;
} }
} }
private function buildNowIsAfterStartDate(QueryBuilder $qb, bool $negative = false) private function buildNowIsAfterStartDate(QueryBuilder $qb, bool $negative = false)
{ {
if ($negative === false) { if ($negative === false) {
@ -211,7 +226,7 @@ class SingleTaskRepository extends \Doctrine\ORM\EntityRepository
; ;
} }
} }
private function buildIsClosed(QueryBuilder $qb, bool $negative = false) private function buildIsClosed(QueryBuilder $qb, bool $negative = false)
{ {
if ($negative === false) { if ($negative === false) {
@ -220,8 +235,8 @@ class SingleTaskRepository extends \Doctrine\ORM\EntityRepository
return $qb->expr()->eq('st.closed', "'FALSE'"); return $qb->expr()->eq('st.closed', "'FALSE'");
} }
} }
protected function buildACLQuery(QueryBuilder $qb, User $currentUser) protected function buildACLQuery(QueryBuilder $qb, User $currentUser)
{ {
if (NULL === $this->authorizationHelper) { if (NULL === $this->authorizationHelper) {
@ -230,23 +245,23 @@ class SingleTaskRepository extends \Doctrine\ORM\EntityRepository
. "to initialize this repository or use the method " . "to initialize this repository or use the method "
. "`setAuthorizationHelper`"); . "`setAuthorizationHelper`");
} }
$role = new Role(TaskVoter::SHOW); $role = new Role(TaskVoter::SHOW);
$qb->join('st.person', 'p'); $qb->join('st.person', 'p');
$centers = $this->authorizationHelper $centers = $this->authorizationHelper
->getReachableCenters($currentUser, $role) ->getReachableCenters($currentUser, $role)
; ;
$i = 0; $i = 0;
$where = $qb->expr()->orX(); $where = $qb->expr()->orX();
foreach($centers as $center) { foreach($centers as $center) {
$circles = $this->authorizationHelper $circles = $this->authorizationHelper
->getReachableCircles($currentUser, $role, $center); ->getReachableCircles($currentUser, $role, $center);
$centerWhere = $qb->expr()->andX(); $centerWhere = $qb->expr()->andX();
$centerWhere->add($qb->expr()->eq('p.center', ':center_'.$i)); $centerWhere->add($qb->expr()->eq('p.center', ':center_'.$i));
$qb->setParameter('center_'.$i, $center); $qb->setParameter('center_'.$i, $center);
$centerWhere->add($qb->expr()->in('st.circle', ':circles_'.$i)); $centerWhere->add($qb->expr()->in('st.circle', ':circles_'.$i));
@ -254,7 +269,7 @@ class SingleTaskRepository extends \Doctrine\ORM\EntityRepository
$where->add($centerWhere); $where->add($centerWhere);
$i ++; $i ++;
} }
$qb->where($where); $qb->where($where);
} }
} }

View File

@ -5,9 +5,9 @@ Description: Description
Assignee: 'Personne assignée' Assignee: 'Personne assignée'
Scope: Cercle Scope: Cercle
'Start date': 'Date de début' 'Start date': 'Date de début'
'End date': 'Date de fin' 'End date': "Date d'échéance"
'Warning date': "Date d'avertissement" 'Warning date': "Date d'avertissement"
'Warning interval': "Délai d'avertissement" 'Warning interval': "Délai d'avertissement de la date d'échéance"
'N': '' 'N': ''
'Unit': '' 'Unit': ''
Task: Tâche Task: Tâche
@ -17,15 +17,15 @@ Scope: Cercle
Date: Date Date: Date
User: Utilisateur User: Utilisateur
'Task list': 'Liste de tâches' 'Task list': 'Liste de tâches'
'Tasks with expired deadline': 'Tâches avec une date limite dépassée' '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" 'Tasks with warning deadline reached': "Tâches avec une date d'avertissement atteinte"
'Current tasks': 'Tâches en cours' 'Current tasks': 'Tâches en cours'
'Tasks not started': 'Tâches non commencées' 'Tasks not started': 'Tâches non commencées'
'Task start date': 'Date de début de la tâche' 'Task start date': 'Date de début'
'Task warning date': "Date d'avertissement de la tâche" 'Task warning date': "Date d'avertissement"
'Task end date': 'Date de fin de la tâche' 'Task end date': "Date d'échéance"
'Task type': 'Type de tâche' 'Task type': 'Type'
'Task status': 'Status de la tâche' 'Task status': 'Statut'
'Edit the task': 'Éditer la tâche' 'Edit the task': 'Éditer la tâche'
'Edit task': 'Éditer la tâche' 'Edit task': 'Éditer la tâche'
'Save task': 'Enregistrer la tâche' 'Save task': 'Enregistrer la tâche'

View File

@ -1,34 +1,4 @@
{# {% macro date_status(title, tasks, count, paginator, status, isSingleStatus, person, user) %}
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
*
* 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 <http://www.gnu.org/licenses/>.
#}
{% extends "ChillPersonBundle::layout.html.twig" %}
{% set activeRouteKey = 'chill_task_single_task_new' %}
{% block title %}{{ 'Task list'|trans }}{% endblock %}
{% macro thead() %}
{% endmacro %}
{% macro row(task) %}
{% endmacro %}
{% macro date_status(title, tasks, count, paginator, status, isSingleStatus, person) %}
{% if tasks|length > 0 %} {% if tasks|length > 0 %}
<h2>{{ title|trans }}</h2> <h2>{{ title|trans }}</h2>
@ -52,7 +22,7 @@
{% for place in workflow_marked_places(task) %} {% for place in workflow_marked_places(task) %}
<span class="">{{ place }}</span> <span class="">{{ place }}</span>
{% endfor %} {% endfor %}
{% for transition in workflow_transitions(task) %} {% for transition in workflow_transitions(task) %}
<a href="{{ path('chill_task_task_transition', { 'taskId': task.id, 'transition': transition.name, 'kind': 'single-task', 'return_path': app.request.uri }) }}" style="background-color: {{ task_workflow_metadata(task, 'transition.background-color', transition)|e('html_attr') }}; color: {{ task_workflow_metadata(task, 'transition.text-color', transition)|e('html_attr') }}">{{ task_workflow_metadata(task, 'transition.verb', transition) }}</a> <a href="{{ path('chill_task_task_transition', { 'taskId': task.id, 'transition': transition.name, 'kind': 'single-task', 'return_path': app.request.uri }) }}" style="background-color: {{ task_workflow_metadata(task, 'transition.background-color', transition)|e('html_attr') }}; color: {{ task_workflow_metadata(task, 'transition.text-color', transition)|e('html_attr') }}">{{ task_workflow_metadata(task, 'transition.verb', transition) }}</a>
{% endfor %} {% endfor %}
@ -82,7 +52,7 @@
</tbody> </tbody>
</table> </table>
{% if isSingleStatus %} {% if isSingleStatus %}
{% if tasks|length > paginator.getTotalItems %} {% if tasks|length > paginator.getTotalItems %}
{{ chill_pagination(paginator) }} {{ chill_pagination(paginator) }}
@ -91,23 +61,45 @@
<!-- lien retour --> <!-- lien retour -->
<ul class="record_actions"> <ul class="record_actions">
<li> <li>
<a href="{{ path('chill_task_task_list_by_person', {'personId': person.id}) }}" class="sc-button bt-cancel"> {% if person is not null %}
<a href="{{ path('chill_task_singletask_list', {'personId': person.id}) }}" class="sc-button bt-cancel">
{{ 'Back to the list' | trans }} {{ 'Back to the list' | trans }}
</a> </a>
{% endif %}
{% if user is not null %}
<a href="{{ path('chill_task_singletask_list') }}" class="sc-button bt-cancel">
{{ 'Back to the list' | trans }}
</a>
{% endif %}
</li> </li>
<li> <li>
{% if person is not null %}
<a href="{{ path('chill_task_single_task_new', {'person_id': person.id}) }}" class="sc-button bt-create"> <a href="{{ path('chill_task_single_task_new', {'person_id': person.id}) }}" class="sc-button bt-create">
{{ 'Add a new task' | trans }} {{ 'Add a new task' | trans }}
</a> </a>
{% endif %}
{% if user is not null %}
<a href="{{ path('chill_task_single_task_new') }}" class="sc-button bt-create">
{{ 'Add a new task' | trans }}
</a>
{% endif %}
</li> </li>
</ul> </ul>
{% else %} {% else %}
<ul class="record_actions"> <ul class="record_actions">
<li> <li>
<a href="{{ path('chill_task_task_list_by_person', {'personId': person.id, 'status' : [ status ] }) }}" class="sc-button bt-cancel"> {% if person is not null %}
<a href="{{ path('chill_task_singletask_list', {'personId': person.id, 'status' : [ status ] }) }}" class="sc-button bt-cancel">
{{ 'See more' | trans }} {{ 'See more' | trans }}
</a> </a>
{% endif %}
{% if user is not null %}
<a href="{{ path('chill_task_singletask_list', {'status' : [ status ] }) }}" class="sc-button bt-cancel">
{{ 'See more' | trans }}
</a>
{% endif %}
</li> </li>
</ul> </ul>
{% endif %} {% endif %}
@ -116,9 +108,7 @@
{% import _self as helper %} {% import _self as helper %}
{# filter tasks #}
{% block personcontent %}
<h1>{{ 'Task list'|trans }}</h1> <h1>{{ 'Task list'|trans }}</h1>
{% if single_task_ended_tasks is defined %} {% if single_task_ended_tasks is defined %}
@ -136,7 +126,7 @@
{% if single_task_not_started_tasks is defined %} {% 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) }} {{ 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 %} {% endif %}
{% if single_task_closed_tasks is defined %} {% if single_task_closed_tasks is defined %}
{{ helper.date_status('Closed', single_task_closed_tasks, single_task_closed_count, single_task_closed_paginator, 'closed', isSingleStatus, person) }} {{ helper.date_status('Closed', single_task_closed_tasks, single_task_closed_count, single_task_closed_paginator, 'closed', isSingleStatus, person) }}
{% endif %} {% endif %}
@ -144,11 +134,16 @@
{% if isSingleStatus == false %} {% if isSingleStatus == false %}
<ul class="record_actions"> <ul class="record_actions">
<li> <li>
{% if person is not null %}
<a href="{{ path('chill_task_single_task_new', {'person_id': person.id}) }}" class="sc-button bt-create"> <a href="{{ path('chill_task_single_task_new', {'person_id': person.id}) }}" class="sc-button bt-create">
{{ 'Add a new task' | trans }} {{ 'Add a new task' | trans }}
</a> </a>
{% endif %}
{% if user is not null %}
<a href="{{ path('chill_task_single_task_new') }}" class="sc-button bt-create">
{{ 'Add a new task' | trans }}
</a>
{% endif %}
</li> </li>
</ul> </ul>
{% endif %} {% endif %}
{% endblock %}

View File

@ -34,7 +34,6 @@
{{ form_row(form.endDate) }} {{ form_row(form.endDate) }}
{{ form_row(form.warningInterval) }} {{ form_row(form.warningInterval) }}
{{ form_widget(form) }}
<ul class="record_actions sticky-form-buttons"> <ul class="record_actions sticky-form-buttons">
<li class="cancel"> <li class="cancel">
<a href="{{ path('chill_task_single_task_show', { 'id': task.id } ) }}" class="sc-button bt-cancel"> <a href="{{ path('chill_task_single_task_show', { 'id': task.id } ) }}" class="sc-button bt-cancel">
@ -42,7 +41,7 @@
</a> </a>
</li> </li>
<li> <li>
<button class="sc-button bt-update" type="submit">{{ 'Save task'|trans }}</button> {{ form_widget(form.submit, { 'label': 'Save task', 'attr': {'class' : 'sc-button bt-update'}})}}
</li> </li>
</ul> </ul>

View File

@ -0,0 +1,43 @@
{#
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
*
* 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 <http://www.gnu.org/licenses/>.
#}
{% extends layout %}
{% set activeRouteKey = 'chill_task_single_task_new' %}
{% block title %}{{ 'Task list'|trans }}{% endblock %}
{% macro thead() %}
{% endmacro %}
{% macro row(task) %}
{% endmacro %}
{# filter tasks #}
{% if person is not null and user is null %}
{% block personcontent %}
{% include 'ChillTaskBundle:SingleTask:_list.html.twig' %}
{% endblock %}
{% elseif user is not null and person is null %}
{% block content %}
{% include 'ChillTaskBundle:SingleTask:_list.html.twig' %}
{% endblock %}
{% endif %}