mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 05:44:24 +00:00
add a button 'new task' in page head and improve voter
This commit is contained in:
parent
9852430b13
commit
066efdc042
@ -8,7 +8,7 @@ Scope: Cercle
|
|||||||
'Start date': 'Date de début'
|
'Start date': 'Date de début'
|
||||||
'End date': "Date d'échéance"
|
'End date': "Date d'échéance"
|
||||||
'Warning date': "Date d'avertissement"
|
'Warning date': "Date d'avertissement"
|
||||||
'Warning interval': "Délai d'avertissement de la date d'échéance"
|
'Warning interval': "Délai d'avertissement avant la date d'échéance"
|
||||||
'Unknown dates': 'Dates non spécifiées'
|
'Unknown dates': 'Dates non spécifiées'
|
||||||
'N': ''
|
'N': ''
|
||||||
'Unit': ''
|
'Unit': ''
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{% macro date_status(title, tasks, count, paginator, status, isSingleStatus, person, user) %}
|
{% macro date_status(title, tasks, count, paginator, status, isSingleStatus, person, user) %}
|
||||||
{% if tasks|length > 0 %}
|
{% if tasks|length > 0 %}
|
||||||
<h2>{{ title|trans }}</h2>
|
<h3>{{ title|trans }}</h3>
|
||||||
|
|
||||||
<table class="records_list">
|
<table class="records_list">
|
||||||
<thead>
|
<thead>
|
||||||
@ -141,10 +141,10 @@
|
|||||||
{% import _self as helper %}
|
{% import _self as helper %}
|
||||||
|
|
||||||
|
|
||||||
<h1>{{ 'Task list'|trans }}</h1>
|
<h1>{{ app.request.title|default('Task list')|trans }}</h1>
|
||||||
|
|
||||||
{% if false == app.request.query.boolean('hide_form', false) %}
|
{% if false == app.request.query.boolean('hide_form', false) %}
|
||||||
<h3>{{ 'Filter the tasks'|trans }}</h3>
|
<h2>{{ 'Filter the tasks'|trans }}</h2>
|
||||||
{{ form_start(form) }}
|
{{ form_start(form) }}
|
||||||
{{ form_row(form.user_id) }}
|
{{ form_row(form.user_id) }}
|
||||||
|
|
||||||
@ -168,18 +168,32 @@
|
|||||||
|
|
||||||
{% if tasks_count == 0 %}
|
{% if tasks_count == 0 %}
|
||||||
<p class="chill-no-data-statement">{{ "There is no tasks."|trans }}</p>
|
<p class="chill-no-data-statement">{{ "There is no tasks."|trans }}</p>
|
||||||
{% if person is not null %}
|
{% if person is not null and is_granted('CHILL_TASK_TASK_CREATE', person) %}
|
||||||
<a href="{{ path('chill_task_single_task_new', {'person_id': person.id}) }}" class="sc-button bt-create">
|
<ul class="record_actions">
|
||||||
{{ 'Add a new task' | trans }}
|
<li>
|
||||||
</a>
|
{% 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 %}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<!-- Pour l'instant, il n'est pas encore possible d'ajouter une tache sans personne liée -->
|
|
||||||
<!-- {% if person is null %}
|
|
||||||
<a href="{{ path('chill_task_single_task_new') }}" class="sc-button bt-create">
|
|
||||||
{{ 'Add a new task' | trans }}
|
|
||||||
</a>
|
|
||||||
{% endif %} -->
|
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
||||||
|
<h2>{{ 'Tasks'|trans }}</h2>
|
||||||
|
|
||||||
|
{% if person is not null and is_granted('CHILL_TASK_TASK_CREATE', person) %}
|
||||||
|
<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 %}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if single_task_ended_tasks is defined %}
|
{% 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, 'ended', isSingleStatus, person) }}
|
{{ helper.date_status('Tasks with expired deadline', single_task_ended_tasks, single_task_ended_count, single_task_ended_paginator, 'ended', isSingleStatus, person) }}
|
||||||
@ -204,17 +218,11 @@
|
|||||||
{% if isSingleStatus == false %}
|
{% if isSingleStatus == false %}
|
||||||
<ul class="record_actions">
|
<ul class="record_actions">
|
||||||
<li>
|
<li>
|
||||||
{% if person is not null %}
|
{% if person is not null and is_granted('CHILL_TASK_TASK_CREATE', person) %}
|
||||||
<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 %}
|
{% endif %}
|
||||||
<!-- Pour l'instant, il n'est pas encore possible d'ajouter une tache sans personne liée -->
|
|
||||||
<!-- {% if person is 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 %}
|
||||||
|
@ -27,6 +27,7 @@ use Psr\Log\LoggerInterface;
|
|||||||
use Chill\MainBundle\Security\ProvideRoleHierarchyInterface;
|
use Chill\MainBundle\Security\ProvideRoleHierarchyInterface;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||||
use Chill\MainBundle\Entity\User;
|
use Chill\MainBundle\Entity\User;
|
||||||
|
use Chill\PersonBundle\Entity\Person;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -77,8 +78,9 @@ class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterf
|
|||||||
|
|
||||||
public function supports($attribute, $subject)
|
public function supports($attribute, $subject)
|
||||||
{
|
{
|
||||||
return $subject instanceof AbstractTask
|
return ($subject instanceof AbstractTask && in_array($attribute, self::ROLES))
|
||||||
&& in_array($attribute, self::ROLES);
|
||
|
||||||
|
($subject instanceof Person && $attribute === self::CREATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -96,12 +98,18 @@ class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterf
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($subject->getPerson() === null) {
|
if ($subject instanceof AbstractTask) {
|
||||||
throw new \LogicException("You should associate a person with task "
|
if ($subject->getPerson() === null) {
|
||||||
. "in order to check autorizations");
|
throw new \LogicException("You should associate a person with task "
|
||||||
|
. "in order to check autorizations");
|
||||||
|
}
|
||||||
|
|
||||||
|
$person = $subject->getPerson();
|
||||||
|
} else {
|
||||||
|
$person = $subject;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->accessDecisionManager->decide($token, [PersonVoter::SEE], $subject->getPerson())) {
|
if (!$this->accessDecisionManager->decide($token, [PersonVoter::SEE], $person)) {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user