Bugfixes/tasks list

This commit is contained in:
Julien Fastré 2021-11-05 12:31:41 +00:00
parent e1677cd2b6
commit 35d807cab0
11 changed files with 74 additions and 26 deletions

View File

@ -21,6 +21,7 @@ and this project adheres to
* refactor `AuthorizationHelper` and `UserACLAwareRepository` to fix constructor, and separate logic for parent role helper into `ParentRoleHelper` * refactor `AuthorizationHelper` and `UserACLAwareRepository` to fix constructor, and separate logic for parent role helper into `ParentRoleHelper`
* [main]: filter location and locationType in backend: exclude NULL names, only active and availableToUsers * [main]: filter location and locationType in backend: exclude NULL names, only active and availableToUsers
* [activity]: perform client-side validation & show/hide fields in the "new location" modal * [activity]: perform client-side validation & show/hide fields in the "new location" modal
* [tasks]: different layout for task list / my tasks, and fix link to tasks in alert or in warning
* [admin]: links to activity admin section added again. * [admin]: links to activity admin section added again.

View File

@ -33,12 +33,14 @@ class ParentRoleHelper
* Return all the role which give access to the given role. Only the role * Return all the role which give access to the given role. Only the role
* which are registered into Chill are taken into account. * which are registered into Chill are taken into account.
* *
* The array contains always the current $role (which give access to himself)
*
* @param string $role * @param string $role
* @return string[] the role which give access to the given $role * @return string[] the role which give access to the given $role
*/ */
public function getParentRoles(string $role): array public function getParentRoles(string $role): array
{ {
$parentRoles = []; $parentRoles = [$role];
// transform the roles from role hierarchy from string to Role // transform the roles from role hierarchy from string to Role
$roles = \array_keys($this->hierarchy); $roles = \array_keys($this->hierarchy);

View File

@ -14,7 +14,7 @@ class FilterOrderHelper
private ?array $searchBoxFields = null; private ?array $searchBoxFields = null;
private array $checkboxes = []; private array $checkboxes = [];
private ?array $submitted = null; private ?array $submitted = null;
private ?string $formName = 'filter'; private ?string $formName = 'f';
private string $formType = FilterOrderType::class; private string $formType = FilterOrderType::class;
private array $formOptions = []; private array $formOptions = [];

View File

@ -23,9 +23,10 @@ class ParentRoleHelperTest extends KernelTestCase
$parentRoles = $this->parentRoleHelper->getParentRoles(PersonVoter::SEE); $parentRoles = $this->parentRoleHelper->getParentRoles(PersonVoter::SEE);
$this->assertCount(2, $parentRoles); $this->assertCount(3, $parentRoles);
$this->assertContains(PersonVoter::CREATE, $parentRoles); $this->assertContains(PersonVoter::CREATE, $parentRoles);
$this->assertContains(PersonVoter::UPDATE, $parentRoles); $this->assertContains(PersonVoter::UPDATE, $parentRoles);
$this->assertContains(PersonVoter::SEE, $parentRoles);
} }
public function testIsRoleReached() public function testIsRoleReached()

View File

@ -159,6 +159,12 @@ class HouseholdMember
return $this->shareHousehold; return $this->shareHousehold;
} }
public function setShareHousehold(bool $shareHousehold): self
{
$this->shareHousehold = $shareHousehold;
return $this;
}
public function getPerson(): ?Person public function getPerson(): ?Person
{ {

View File

@ -452,7 +452,7 @@ final class SingleTaskController extends AbstractController
* @return Response * @return Response
* @Route( * @Route(
* "/{_locale}/task/single-task/list/my", * "/{_locale}/task/single-task/list/my",
* name="chill_task_single_my_tasks" * name="chill_task_singletask_my_tasks"
* ) * )
*/ */
public function myTasksAction() public function myTasksAction()
@ -480,7 +480,7 @@ final class SingleTaskController extends AbstractController
] ]
); );
return $this->render('@ChillTask/SingleTask/List/index.html.twig', [ return $this->render('@ChillTask/SingleTask/List/index_my_tasks.html.twig', [
'tasks' => $tasks, 'tasks' => $tasks,
'paginator' => $paginator, 'paginator' => $paginator,
'filter_order' => $filterOrder, 'filter_order' => $filterOrder,

View File

@ -88,27 +88,27 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
if ($ended > 0) { if ($ended > 0) {
$this->addItemInMenu( $this->addItemInMenu(
$menu, $menu,
$user,
'%number% tasks over deadline', '%number% tasks over deadline',
'My tasks over deadline',
SingleTaskRepository::DATE_STATUS_ENDED,
$ended, $ended,
-15); -15,
['new', 'in_progress'],
['alert']
);
} }
if ($warning > 0) { if ($warning > 0) {
$this->addItemInMenu( $this->addItemInMenu(
$menu, $menu,
$user,
'%number% tasks near deadline', '%number% tasks near deadline',
'My tasks near deadline',
SingleTaskRepository::DATE_STATUS_WARNING,
$warning, $warning,
-14); -14,
['new', 'in_progress'],
['warning']
);
} }
$menu->addChild("My tasks", [ $menu->addChild("My tasks", [
'route' => 'chill_task_single_my_tasks' 'route' => 'chill_task_singletask_my_tasks'
]) ])
->setExtras([ ->setExtras([
'order' => -10, 'order' => -10,
@ -117,20 +117,20 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
} }
protected function addItemInMenu(MenuItem $menu, User $u, $message, $title, $status, $number, $order) protected function addItemInMenu(MenuItem $menu, $message, $number, $order, array $states = [], array $status = [])
{ {
if ($number > 0) { if ($number > 0) {
$menu->addChild( $menu->addChild(
$this->translator->transChoice($message, $number), $this->translator->transChoice($message, $number),
[ [
'route' => 'chill_task_singletask_list', 'route' => 'chill_task_singletask_my_tasks',
'routeParameters' => [ 'routeParameters' => [
'user_id' => $u->getId(), 'f' => [
'status' => [ 'checkboxes' => [
$status 'states' => $states,
], 'status' => $status
'hide_form' => true, ]
'title' => $this->translator->trans($title) ]
] ]
]) ])
->setExtras([ ->setExtras([

View File

@ -284,8 +284,8 @@ final class SingleTaskAclAwareRepository implements SingleTaskAclAwareRepository
$qb->expr()->andX( $qb->expr()->andX(
$qb->expr()->not($qb->expr()->isNull('t.endDate')), $qb->expr()->not($qb->expr()->isNull('t.endDate')),
$qb->expr()->not($qb->expr()->isNull('t.warningInterval')), $qb->expr()->not($qb->expr()->isNull('t.warningInterval')),
$qb->expr()->gte('t.endDate - t.warningInterval', ':now'), $qb->expr()->lte('t.endDate - t.warningInterval', ':now'),
$qb->expr()->lt('t.endDate', ':now') $qb->expr()->gt('t.endDate', ':now')
) )
); );
$qb $qb

View File

@ -21,7 +21,7 @@
{{ chill_pagination(paginator) }} {{ chill_pagination(paginator) }}
{% if is_granted('CHILL_TASK_TASK_CREATE_FOR_COURSE', person) %} {% if is_granted('CHILL_TASK_TASK_CREATE_FOR_COURSE', accompanyingCourse) %}
<ul class="record_actions sticky-form-buttons"> <ul class="record_actions sticky-form-buttons">
<li> <li>
{% if accompanyingCourse is not null %} {% if accompanyingCourse is not null %}
@ -37,8 +37,10 @@
{% endblock %} {% endblock %}
{% block css %} {% block css %}
{{ parent() }}
{{ encore_entry_link_tags('page_task_list') }} {{ encore_entry_link_tags('page_task_list') }}
{% endblock %} {% endblock %}
{% block js %} {% block js %}
{{ parent() }}
{{ encore_entry_script_tags('page_task_list') }} {{ encore_entry_script_tags('page_task_list') }}
{% endblock %} {% endblock %}

View File

@ -1,6 +1,6 @@
{% extends 'ChillMainBundle::layout.html.twig' %} {% extends 'ChillMainBundle::layout.html.twig' %}
{% block title 'My tasks'|trans %} {% block title 'Tasks'|trans %}
{% block content %} {% block content %}
<div class="col-md-10 col-xxl"> <div class="col-md-10 col-xxl">
@ -25,8 +25,10 @@
{% endblock %} {% endblock %}
{% block css %} {% block css %}
{{ parent() }}
{{ encore_entry_link_tags('page_task_list') }} {{ encore_entry_link_tags('page_task_list') }}
{% endblock %} {% endblock %}
{% block js %} {% block js %}
{{ parent() }}
{{ encore_entry_script_tags('page_task_list') }} {{ encore_entry_script_tags('page_task_list') }}
{% endblock %} {% endblock %}

View File

@ -0,0 +1,34 @@
{% extends 'ChillMainBundle::layout.html.twig' %}
{% block title 'My tasks'|trans %}
{% block content %}
<div class="col-md-10 col-xxl">
<h1>{{ block('title') }}</h1>
{{ filter_order|chill_render_filter_order_helper }}
{% if tasks|length == 0 %}
<p class="chill-no-data-statement">{{ 'Any tasks'|trans }}</p>
{% else %}
<div class="flex-table chill-task-list">
{% for task in tasks %}
{% include 'ChillTaskBundle:SingleTask/List:index_item.html.twig' with { 'showContext' : true} %}
{% endfor %}
</div>
{% endif %}
{{ chill_pagination(paginator) }}
</div>
{% endblock %}
{% block css %}
{{ parent() }}
{{ encore_entry_link_tags('page_task_list') }}
{% endblock %}
{% block js %}
{{ parent() }}
{{ encore_entry_script_tags('page_task_list') }}
{% endblock %}