mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
add list by person, user and scope + formatting of submit button in edit
This commit is contained in:
parent
4b391d03d5
commit
bf0db0de3f
@ -18,6 +18,8 @@ use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||
use Chill\TaskBundle\Repository\SingleTaskRepository;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||
use Chill\PersonBundle\Entity\PersonRepository;
|
||||
use Chill\MainBundle\Entity\UserRepository;
|
||||
|
||||
class SingleTaskController extends Controller
|
||||
{
|
||||
@ -41,7 +43,7 @@ class SingleTaskController extends Controller
|
||||
->find($personId);
|
||||
|
||||
if ($person === null) {
|
||||
throw $this->createNotFoundException("Invalid person id");
|
||||
$this->createNotFoundException("Invalid person id");
|
||||
}
|
||||
|
||||
$task = (new SingleTask())
|
||||
@ -281,23 +283,75 @@ class SingleTaskController extends Controller
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Route(
|
||||
* "/{_locale}/task/task/list/person/{personId}",
|
||||
* name="chill_task_task_list_by_person"
|
||||
* "/{_locale}/task/singletask/list",
|
||||
* name="chill_task_singletask_list"
|
||||
* )
|
||||
*/
|
||||
public function listAction(
|
||||
Request $request,
|
||||
Person $personId,
|
||||
PaginatorFactory $paginatorFactory,
|
||||
SingleTaskRepository $taskRepository
|
||||
SingleTaskRepository $taskRepository,
|
||||
PersonRepository $personRepository
|
||||
) {
|
||||
$person = $personId;
|
||||
/* @var $viewParams array The parameters for the view */
|
||||
/* @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;
|
||||
// collect parameters for filter
|
||||
$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
|
||||
$possibleStatuses = \array_merge(SingleTaskRepository::DATE_STATUSES, [ 'closed' ]);
|
||||
$statuses = $request->query->get('status', $possibleStatuses);
|
||||
|
||||
@ -331,6 +385,7 @@ class SingleTaskController extends Controller
|
||||
->countByParameters($params, $this->getUser())
|
||||
;
|
||||
$paginator = $paginatorFactory->create($count);
|
||||
|
||||
$viewParams['single_task_'.$status.'_count'] = $count;
|
||||
$viewParams['single_task_'.$status.'_paginator'] = $paginator;
|
||||
$viewParams['single_task_'.$status.'_tasks'] = $taskRepository
|
||||
@ -340,7 +395,13 @@ class SingleTaskController extends Controller
|
||||
;
|
||||
}
|
||||
|
||||
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)
|
||||
|
@ -56,7 +56,7 @@ class TaskController extends Controller
|
||||
}
|
||||
|
||||
if (NULL === $task) {
|
||||
$this->createHttpNotFoundException("task with id '$taskId' and type "
|
||||
$this->createNotFoundException("task with id '$taskId' and type "
|
||||
. "'$type' does not exists");
|
||||
}
|
||||
|
||||
|
@ -67,8 +67,10 @@ class SingleTaskRepository extends \Doctrine\ORM\EntityRepository
|
||||
* Available parameters:
|
||||
*
|
||||
* - `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 :
|
||||
* `ended`, `warning`, `current`, `not_started`
|
||||
* `ended`, `warning`, `current`, `not_started` ;
|
||||
* - `is_closed`: boolean. Indicate if the tasks must be closed (true) or
|
||||
* opened
|
||||
*
|
||||
@ -104,6 +106,17 @@ class SingleTaskRepository extends \Doctrine\ORM\EntityRepository
|
||||
$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'])) {
|
||||
$this->addTypeFilter($qb, $params);
|
||||
}
|
||||
@ -111,6 +124,8 @@ class SingleTaskRepository extends \Doctrine\ORM\EntityRepository
|
||||
if (\array_key_exists('is_closed', $params)) {
|
||||
$qb->andWhere($this->buildIsClosed($qb, !$params['is_closed']));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected function addTypeFilter(QueryBuilder $qb, $params)
|
||||
|
@ -5,9 +5,9 @@ Description: Description
|
||||
Assignee: 'Personne assignée'
|
||||
Scope: Cercle
|
||||
'Start date': 'Date de début'
|
||||
'End date': 'Date de fin'
|
||||
'End date': "Date d'échéance"
|
||||
'Warning date': "Date d'avertissement"
|
||||
'Warning interval': "Délai d'avertissement"
|
||||
'Warning interval': "Délai d'avertissement de la date d'échéance"
|
||||
'N': ''
|
||||
'Unit': ''
|
||||
Task: Tâche
|
||||
@ -17,15 +17,15 @@ Scope: Cercle
|
||||
Date: Date
|
||||
User: Utilisateur
|
||||
'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"
|
||||
'Current tasks': 'Tâches en cours'
|
||||
'Tasks not started': 'Tâches non commencées'
|
||||
'Task start date': 'Date de début de la tâche'
|
||||
'Task warning date': "Date d'avertissement de la tâche"
|
||||
'Task end date': 'Date de fin de la tâche'
|
||||
'Task type': 'Type de tâche'
|
||||
'Task status': 'Status de la tâche'
|
||||
'Task start date': 'Date de début'
|
||||
'Task warning date': "Date d'avertissement"
|
||||
'Task end date': "Date d'échéance"
|
||||
'Task type': 'Type'
|
||||
'Task status': 'Statut'
|
||||
'Edit the task': 'Éditer la tâche'
|
||||
'Edit task': 'Éditer la tâche'
|
||||
'Save task': 'Enregistrer la tâche'
|
||||
|
@ -1,34 +1,4 @@
|
||||
{#
|
||||
* 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) %}
|
||||
{% macro date_status(title, tasks, count, paginator, status, isSingleStatus, person, user) %}
|
||||
{% if tasks|length > 0 %}
|
||||
<h2>{{ title|trans }}</h2>
|
||||
|
||||
@ -91,23 +61,45 @@
|
||||
<!-- lien retour -->
|
||||
<ul class="record_actions">
|
||||
<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 }}
|
||||
</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>
|
||||
{% if person is not null %}
|
||||
<a href="{{ path('chill_task_single_task_new', {'person_id': person.id}) }}" class="sc-button bt-create">
|
||||
{{ 'Add a new task' | trans }}
|
||||
</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>
|
||||
</ul>
|
||||
{% else %}
|
||||
<ul class="record_actions">
|
||||
<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 }}
|
||||
</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>
|
||||
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
@ -116,9 +108,7 @@
|
||||
|
||||
{% import _self as helper %}
|
||||
|
||||
{# filter tasks #}
|
||||
|
||||
{% block personcontent %}
|
||||
<h1>{{ 'Task list'|trans }}</h1>
|
||||
|
||||
{% if single_task_ended_tasks is defined %}
|
||||
@ -144,11 +134,16 @@
|
||||
{% if isSingleStatus == false %}
|
||||
<ul class="record_actions">
|
||||
<li>
|
||||
{% if person is not null %}
|
||||
<a href="{{ path('chill_task_single_task_new', {'person_id': person.id}) }}" class="sc-button bt-create">
|
||||
{{ 'Add a new task' | trans }}
|
||||
</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>
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
@ -34,7 +34,6 @@
|
||||
{{ form_row(form.endDate) }}
|
||||
{{ form_row(form.warningInterval) }}
|
||||
|
||||
{{ form_widget(form) }}
|
||||
<ul class="record_actions sticky-form-buttons">
|
||||
<li class="cancel">
|
||||
<a href="{{ path('chill_task_single_task_show', { 'id': task.id } ) }}" class="sc-button bt-cancel">
|
||||
@ -42,7 +41,7 @@
|
||||
</a>
|
||||
</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>
|
||||
</ul>
|
||||
|
||||
|
43
Resources/views/SingleTask/index.html.twig
Normal file
43
Resources/views/SingleTask/index.html.twig
Normal 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 %}
|
Loading…
x
Reference in New Issue
Block a user