mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 22:04:23 +00:00
improve filter form
- hide form in some places ; - i18n - hide status filtering with a parameter (redundant)
This commit is contained in:
parent
650f2c8e18
commit
69eb9648c9
@ -315,15 +315,27 @@ class SingleTaskController extends Controller
|
|||||||
public function myTasksAction()
|
public function myTasksAction()
|
||||||
{
|
{
|
||||||
return $this->redirectToRoute('chill_task_singletask_list', [
|
return $this->redirectToRoute('chill_task_singletask_list', [
|
||||||
'user_id' => $this->getUser()->getId()
|
'user_id' => $this->getUser()->getId(),
|
||||||
|
'hide_form' => true
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* - user_id
|
||||||
|
* - scope_id
|
||||||
|
* - person_id
|
||||||
|
* - hide_form (hide the form to filter the tasks)
|
||||||
|
* - status: date state, amongst SingleTaskRepository::DATE_STATUSES, or 'closed'
|
||||||
|
*
|
||||||
* @Route(
|
* @Route(
|
||||||
* "/{_locale}/task/singletask/list",
|
* "/{_locale}/task/singletask/list",
|
||||||
* name="chill_task_singletask_list",
|
* name="chill_task_singletask_list",
|
||||||
* options={ "menus": { "person" : { "order": 400, "label": "Associated tasks" } } }
|
* options={ "menus": {
|
||||||
|
* "person" : { "order": 400, "label": "Associated tasks" } ,
|
||||||
|
* "section": { "order": 400, "label": "Tasks", "icons": "tasks" }
|
||||||
|
* }}
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
public function listAction(
|
public function listAction(
|
||||||
@ -359,7 +371,9 @@ class SingleTaskController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($request->query->get('user_id', null))) {
|
if (!empty($request->query->get('user_id', null))) {
|
||||||
|
if ($request->query->get('user_id') === '_unassigned') {
|
||||||
|
$params['unassigned'] = true;
|
||||||
|
} else {
|
||||||
$userId = $request->query->getInt('user_id', null);
|
$userId = $request->query->getInt('user_id', null);
|
||||||
$user = $this->getDoctrine()->getManager()
|
$user = $this->getDoctrine()->getManager()
|
||||||
->getRepository('ChillMainBundle:User')
|
->getRepository('ChillMainBundle:User')
|
||||||
@ -372,6 +386,7 @@ class SingleTaskController extends Controller
|
|||||||
$viewParams['user'] = $user;
|
$viewParams['user'] = $user;
|
||||||
$params['user'] = $user;
|
$params['user'] = $user;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($request->query->get('scope_id'))) {
|
if (!empty($request->query->get('scope_id'))) {
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface
|
|||||||
return $this->circle;
|
return $this->circle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setAssignee(User $assignee)
|
public function setAssignee(User $assignee = null)
|
||||||
{
|
{
|
||||||
$this->assignee = $assignee;
|
$this->assignee = $assignee;
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -73,22 +73,33 @@ class SingleTaskListType extends AbstractType
|
|||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
$statuses = \array_merge(SingleTaskRepository::DATE_STATUSES, [ 'closed' ]);
|
$statuses = [
|
||||||
|
'Tasks not started' => SingleTaskRepository::DATE_STATUS_NOT_STARTED,
|
||||||
|
'Tasks with expired deadline' => SingleTaskRepository::DATE_STATUS_ENDED,
|
||||||
|
'Tasks with warning deadline reached' => SingleTaskRepository::DATE_STATUS_WARNING,
|
||||||
|
'Current tasks' => SingleTaskRepository::DATE_STATUS_CURRENT,
|
||||||
|
'Closed tasks' => 'closed'
|
||||||
|
];
|
||||||
|
|
||||||
$builder
|
$builder
|
||||||
->add('user_id', EntityType::class, [
|
->add('user_id', ChoiceType::class, [
|
||||||
'class' => User::class,
|
'choices' => $this->getUserChoices($options),
|
||||||
'choices' => $this->getUsersAssigneedToTask($options),
|
'placeholder' => 'Any user',
|
||||||
'placeholder' => 'Choose a user',
|
'required' => false,
|
||||||
'required' => false
|
'label' => 'Assignee'
|
||||||
])
|
|
||||||
->add('status', ChoiceType::class, [
|
|
||||||
'choices' => array_combine($statuses, $statuses),
|
|
||||||
'expanded' => true,
|
|
||||||
'multiple' => true
|
|
||||||
])
|
])
|
||||||
;
|
;
|
||||||
|
|
||||||
|
if ($options['add_status'] === true) {
|
||||||
|
$builder
|
||||||
|
->add('status', ChoiceType::class, [
|
||||||
|
'choices' => $statuses,
|
||||||
|
'expanded' => true,
|
||||||
|
'multiple' => true,
|
||||||
|
'label' => 'status'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
if ($options['person'] === null) {
|
if ($options['person'] === null) {
|
||||||
$builder
|
$builder
|
||||||
->add('person_id', PickPersonType::class, [
|
->add('person_id', PickPersonType::class, [
|
||||||
@ -97,7 +108,8 @@ class SingleTaskListType extends AbstractType
|
|||||||
$this->tokenStorage->getToken()->getUser(),
|
$this->tokenStorage->getToken()->getUser(),
|
||||||
new Role(TaskVoter::SHOW)
|
new Role(TaskVoter::SHOW)
|
||||||
),
|
),
|
||||||
'required' => false
|
'required' => false,
|
||||||
|
'label' => 'Associated person'
|
||||||
])
|
])
|
||||||
;
|
;
|
||||||
} else {
|
} else {
|
||||||
@ -110,6 +122,20 @@ class SingleTaskListType extends AbstractType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getUserChoices($options)
|
||||||
|
{
|
||||||
|
$users = $this->getUsersAssigneedToTask($options);
|
||||||
|
$choices = \array_combine(
|
||||||
|
// get usernames
|
||||||
|
\array_map(function(User $user) { return $user->getUsername(); }, $users),
|
||||||
|
// get ids
|
||||||
|
\array_map(function(User $user) { return $user->getId(); }, $users)
|
||||||
|
);
|
||||||
|
$choices['Unassigned'] = '_unassigned';
|
||||||
|
|
||||||
|
return $choices;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a list of user having a task assigned.
|
* Return a list of user having a task assigned.
|
||||||
*
|
*
|
||||||
@ -162,6 +188,9 @@ class SingleTaskListType extends AbstractType
|
|||||||
->setDefined('person')
|
->setDefined('person')
|
||||||
->setDefault('person', null)
|
->setDefault('person', null)
|
||||||
->setAllowedTypes('person', [Person::class, 'null'])
|
->setAllowedTypes('person', [Person::class, 'null'])
|
||||||
|
->setDefined('add_status')
|
||||||
|
->setDefault('add_status', false)
|
||||||
|
->setAllowedTypes('add_status', ['bool'])
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,8 @@ class SingleTaskType extends AbstractType
|
|||||||
->add('assignee', UserPickerType::class, [
|
->add('assignee', UserPickerType::class, [
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'center' => $options['center'],
|
'center' => $options['center'],
|
||||||
'role' => $options['role']
|
'role' => $options['role'],
|
||||||
|
'placeholder' => 'Not assigned'
|
||||||
])
|
])
|
||||||
->add('circle', ScopePickerType::class, [
|
->add('circle', ScopePickerType::class, [
|
||||||
'center' => $options['center'],
|
'center' => $options['center'],
|
||||||
|
@ -82,7 +82,8 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
'status' => [
|
'status' => [
|
||||||
SingleTaskRepository::DATE_STATUS_WARNING,
|
SingleTaskRepository::DATE_STATUS_WARNING,
|
||||||
SingleTaskRepository::DATE_STATUS_ENDED
|
SingleTaskRepository::DATE_STATUS_ENDED
|
||||||
]
|
],
|
||||||
|
'hide_form' => true
|
||||||
]
|
]
|
||||||
])
|
])
|
||||||
->setExtras([
|
->setExtras([
|
||||||
|
@ -108,6 +108,15 @@ class SingleTaskRepository extends \Doctrine\ORM\EntityRepository
|
|||||||
$qb->setParameter('person', $params['person']);
|
$qb->setParameter('person', $params['person']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (\array_key_exists('unassigned', $params) and $params['unassigned'] === true) {
|
||||||
|
if (\array_key_exists('user', $params) and !empty($params['user'])) {
|
||||||
|
throw new \UnexpectedValueException("You should not require for "
|
||||||
|
. "unassigned tasks and tasks assigned to some user.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$qb->andWhere($qb->expr()->isNull('st.assignee'));
|
||||||
|
}
|
||||||
|
|
||||||
if (\array_key_exists('user', $params) and !empty($params['user'])) {
|
if (\array_key_exists('user', $params) and !empty($params['user'])) {
|
||||||
$qb->andWhere($qb->expr()->eq('st.assignee', ':user'));
|
$qb->andWhere($qb->expr()->eq('st.assignee', ':user'));
|
||||||
$qb->setParameter('user', $params['user']);
|
$qb->setParameter('user', $params['user']);
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
Tasks: 'Tâches'
|
||||||
'New task': 'Nouvelle tâche'
|
'New task': 'Nouvelle tâche'
|
||||||
'Add a new task': 'Ajouter une nouvelle tâche'
|
'Add a new task': 'Ajouter une nouvelle tâche'
|
||||||
Title: Titre
|
Title: Titre
|
||||||
@ -22,6 +23,7 @@ User: Utilisateur
|
|||||||
'Tasks with expired deadline': "Tâches avec une date d'échéance 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'
|
||||||
|
'Closed tasks': Tâches terminées
|
||||||
'Tasks not started': 'Tâches non commencées'
|
'Tasks not started': 'Tâches non commencées'
|
||||||
'Task start date': 'Date de début'
|
'Task start date': 'Date de début'
|
||||||
'Task warning date': "Date d'avertissement"
|
'Task warning date': "Date d'avertissement"
|
||||||
@ -50,7 +52,11 @@ Days: Jour(s)
|
|||||||
Weeks: Semaine(s)
|
Weeks: Semaine(s)
|
||||||
Months: Mois
|
Months: Mois
|
||||||
Year: Année(s)
|
Year: Année(s)
|
||||||
|
Filter the tasks: Filtrer les tâches
|
||||||
|
Filter: Filtrer
|
||||||
|
Any user: Tous les utilisateurs
|
||||||
|
Unassigned: Non assigné
|
||||||
|
Associated person: Personne associée
|
||||||
|
|
||||||
|
|
||||||
# transitions
|
# transitions
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="chill-red">{{ 'Title'|trans }}</th>
|
<th class="chill-red">{{ 'Title'|trans }}</th>
|
||||||
<th class="chill-green">{{ 'Task type'|trans }}</th>
|
{# <th class="chill-green">{{ 'Task type'|trans }}</th> #}
|
||||||
{% if person is null %}
|
{% if person is null %}
|
||||||
<th>{{ 'Person'|trans }}</th>
|
<th>{{ 'Person'|trans }}</th>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -18,7 +18,7 @@
|
|||||||
{% for task in tasks %}
|
{% for task in tasks %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ task.title }}</td>
|
<td>{{ task.title }}</td>
|
||||||
<td>{{ task.type }}</td>
|
{# <td>{{ task.type }}</td> #}
|
||||||
{% if person is null %}
|
{% if person is null %}
|
||||||
<td><a href="{{ path('chill_person_view', {person_id : task.person.Id}) }}">{{ task.person}}</a></td>
|
<td><a href="{{ path('chill_person_view', {person_id : task.person.Id}) }}">{{ task.person}}</a></td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -141,16 +141,26 @@
|
|||||||
|
|
||||||
<h1>{{ 'Task list'|trans }}</h1>
|
<h1>{{ 'Task list'|trans }}</h1>
|
||||||
|
|
||||||
<p>Filter the tasks</p>
|
{% if false == app.request.query.boolean('hide_form', false) %}
|
||||||
|
<h3>{{ 'Filter the tasks'|trans }}</h3>
|
||||||
{{ form_start(form) }}
|
{{ form_start(form) }}
|
||||||
{{ form_row(form.user_id) }}
|
{{ form_row(form.user_id) }}
|
||||||
|
|
||||||
|
{% if form.status is defined %}
|
||||||
{{ form_row(form.status) }}
|
{{ form_row(form.status) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if form.person_id is defined %}
|
{% if form.person_id is defined %}
|
||||||
{{ form_row(form.person_id) }}
|
{{ form_row(form.person_id) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<button type="submit">{{ 'Filter'|trans }}</button>
|
|
||||||
|
<ul class="record_actions">
|
||||||
|
<li>
|
||||||
|
<button type="submit" class="sc-button">{{ 'Filter'|trans }}</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
{{ form_end(form)}}
|
{{ form_end(form)}}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user