Merge branch '106_tasks_to_parcours'

This commit is contained in:
Julien Fastré 2021-11-03 11:45:40 +01:00
commit 2d33ae26d8
66 changed files with 2211 additions and 1247 deletions

View File

@ -11,7 +11,8 @@ and this project adheres to
## Unreleased ## Unreleased
<!-- write down unreleased development here --> <!-- write down unreleased development here -->
* [tasks] improve tasks with filter order
* [tasks] refactor singleControllerTasks: limit the number of conditions from the context
## Test releases ## Test releases

View File

@ -17,6 +17,7 @@
*/ */
namespace Chill\CalendarBundle\Menu; namespace Chill\CalendarBundle\Menu;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Routing\LocalMenuBuilderInterface; use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
use Knp\Menu\MenuItem; use Knp\Menu\MenuItem;
use Chill\TaskBundle\Templating\UI\CountNotificationTask; use Chill\TaskBundle\Templating\UI\CountNotificationTask;
@ -72,17 +73,19 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
{ {
$user = $this->tokenStorage->getToken()->getUser(); $user = $this->tokenStorage->getToken()->getUser();
if ($this->authorizationChecker->isGranted('ROLE_USER')){ if ($this->authorizationChecker->isGranted('ROLE_USER')
$menu->addChild("My calendar list", [ && $user instanceof User
'route' => 'chill_calendar_calendar_list', ) {
'routeParameters' => [ $menu->addChild("My calendar list", [
'user_id' => $user->getId(), 'route' => 'chill_calendar_calendar_list',
] 'routeParameters' => [
]) 'user_id' => $user->getId(),
->setExtras([ ]
'order' => 9, ])
'icon' => 'tasks' ->setExtras([
]); 'order' => 9,
'icon' => 'tasks'
]);
} }
} }
@ -90,5 +93,5 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
{ {
return [ 'user' ]; return [ 'user' ];
} }
} }

View File

@ -23,6 +23,7 @@ use Chill\MainBundle\Controller\AddressApiController;
use Chill\MainBundle\Controller\LocationController; use Chill\MainBundle\Controller\LocationController;
use Chill\MainBundle\Controller\LocationTypeController; use Chill\MainBundle\Controller\LocationTypeController;
use Chill\MainBundle\Controller\UserController; use Chill\MainBundle\Controller\UserController;
use Chill\MainBundle\Doctrine\DQL\JsonbArrayLength;
use Chill\MainBundle\Doctrine\DQL\STContains; use Chill\MainBundle\Doctrine\DQL\STContains;
use Chill\MainBundle\Doctrine\DQL\StrictWordSimilarityOPS; use Chill\MainBundle\Doctrine\DQL\StrictWordSimilarityOPS;
use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\User;
@ -96,6 +97,10 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
$configuration = $this->getConfiguration($configs, $container); $configuration = $this->getConfiguration($configs, $container);
$config = $this->processConfiguration($configuration, $configs); $config = $this->processConfiguration($configuration, $configs);
// replace all config with a main key:
$container->setParameter('chill_main', $config);
// legacy config
$container->setParameter('chill_main.installation_name', $container->setParameter('chill_main.installation_name',
$config['installation_name']); $config['installation_name']);
@ -199,6 +204,7 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
'OVERLAPSI' => OverlapsI::class, 'OVERLAPSI' => OverlapsI::class,
'STRICT_WORD_SIMILARITY_OPS' => StrictWordSimilarityOPS::class, 'STRICT_WORD_SIMILARITY_OPS' => StrictWordSimilarityOPS::class,
'ST_CONTAINS' => STContains::class, 'ST_CONTAINS' => STContains::class,
'JSONB_ARRAY_LENGTH' => JsonbArrayLength::class,
], ],
], ],
'hydrators' => [ 'hydrators' => [

View File

@ -16,23 +16,23 @@ use Symfony\Component\HttpFoundation\Request;
*/ */
class Configuration implements ConfigurationInterface class Configuration implements ConfigurationInterface
{ {
use AddWidgetConfigurationTrait; use AddWidgetConfigurationTrait;
/** /**
* *
* @var ContainerBuilder * @var ContainerBuilder
*/ */
private $containerBuilder; private $containerBuilder;
public function __construct(array $widgetFactories = array(), public function __construct(array $widgetFactories = array(),
ContainerBuilder $containerBuilder) ContainerBuilder $containerBuilder)
{ {
$this->setWidgetFactories($widgetFactories); $this->setWidgetFactories($widgetFactories);
$this->containerBuilder = $containerBuilder; $this->containerBuilder = $containerBuilder;
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -97,6 +97,14 @@ class Configuration implements ConfigurationInterface
->end() ->end()
->end() ->end()
->end() ->end()
->arrayNode('acl')
->addDefaultsIfNotSet()
->children()
->booleanNode('form_show_scopes')
->defaultTrue()
->end()
->end()
->end()
->arrayNode('redis') ->arrayNode('redis')
->children() ->children()
->scalarNode('host') ->scalarNode('host')
@ -247,7 +255,7 @@ class Configuration implements ConfigurationInterface
->end() // end of root ->end() // end of root
; ;
return $treeBuilder; return $treeBuilder;
} }
} }

View File

@ -0,0 +1,35 @@
<?php
/*
*
*
*/
namespace Chill\MainBundle\Doctrine\DQL;
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;
/**
* Return the length of an array
*/
class JsonbArrayLength extends FunctionNode
{
private $expr1;
public function getSql(SqlWalker $sqlWalker): string
{
return sprintf(
'jsonb_array_length(%s)',
$this->expr1->dispatch($sqlWalker),
);
}
public function parse(Parser $parser): void
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$this->expr1 = $parser->StringPrimary();
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
}
}

View File

@ -1,7 +1,7 @@
<?php <?php
/* /*
* *
* *
*/ */
namespace Chill\MainBundle\Doctrine\DQL; namespace Chill\MainBundle\Doctrine\DQL;
@ -11,19 +11,18 @@ use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker; use Doctrine\ORM\Query\SqlWalker;
/** /**
*
* *
* @author Julien Fastré <julien.fastre@champs-libres.coop> @author Julien Fastré <julien.fastre@champs-libres.coop>
*/ */
class JsonbExistsInArray extends FunctionNode class JsonbExistsInArray extends FunctionNode
{ {
private $expr1; private $expr1;
private $expr2; private $expr2;
public function getSql(SqlWalker $sqlWalker): string public function getSql(SqlWalker $sqlWalker): string
{ {
return sprintf( return sprintf(
'jsonb_exists(%s, %s)', '%s ?? %s',
$this->expr1->dispatch($sqlWalker), $this->expr1->dispatch($sqlWalker),
$sqlWalker->walkInputParameter($this->expr2) $sqlWalker->walkInputParameter($this->expr2)
); );

View File

@ -3,9 +3,12 @@
namespace Chill\MainBundle\Form\Type\Listing; namespace Chill\MainBundle\Form\Type\Listing;
use Chill\MainBundle\Templating\Listing\FilterOrderHelper; use Chill\MainBundle\Templating\Listing\FilterOrderHelper;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\SearchType; use Symfony\Component\Form\Extension\Core\Type\SearchType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\RequestStack;
final class FilterOrderType extends \Symfony\Component\Form\AbstractType final class FilterOrderType extends \Symfony\Component\Form\AbstractType
@ -29,9 +32,32 @@ final class FilterOrderType extends \Symfony\Component\Form\AbstractType
]); ]);
} }
$checkboxesBuilder = $builder->create('checkboxes', null, [ 'compound' => true ]);
foreach ($helper->getCheckboxes() as $name => $c) {
$choices = \array_combine(
\array_map(function($c, $t) {
if ($t !== NULL) { return $t; }
else { return $c; }
}, $c['choices'], $c['trans']),
$c['choices']
);
$checkboxesBuilder->add($name, ChoiceType::class, [
'choices' => $choices,
'expanded' => true,
'multiple' => true,
]);
}
if (0 < count($helper->getCheckboxes())) {
$builder->add($checkboxesBuilder);
}
foreach ($this->requestStack->getCurrentRequest()->query->getIterator() as $key => $value) { foreach ($this->requestStack->getCurrentRequest()->query->getIterator() as $key => $value) {
switch($key) { switch($key) {
case 'q': case 'q':
case 'checkboxes'.$key:
break; break;
case 'page': case 'page':
$builder->add($key, HiddenType::class, [ $builder->add($key, HiddenType::class, [
@ -47,6 +73,17 @@ final class FilterOrderType extends \Symfony\Component\Form\AbstractType
} }
} }
public function buildView(FormView $view, FormInterface $form, array $options)
{
/** @var FilterOrderHelper $helper */
$helper = $options['helper'];
$view->vars['has_search_box'] = $helper->hasSearchBox();
$view->vars['checkboxes'] = [];
foreach ($helper->getCheckboxes() as $name => $c) {
$view->vars['checkboxes'][$name] = [];
}
}
public function configureOptions(\Symfony\Component\OptionsResolver\OptionsResolver $resolver) public function configureOptions(\Symfony\Component\OptionsResolver\OptionsResolver $resolver)
{ {
$resolver->setRequired('helper') $resolver->setRequired('helper')

View File

@ -23,7 +23,9 @@ use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Form\DataMapper\ScopePickerDataMapper; use Chill\MainBundle\Form\DataMapper\ScopePickerDataMapper;
use Chill\MainBundle\Repository\ScopeRepository; use Chill\MainBundle\Repository\ScopeRepository;
use Chill\MainBundle\Repository\UserACLAwareRepositoryInterface;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\MainBundle\Templating\TranslatableStringHelper;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
@ -36,6 +38,7 @@ use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Security\Core\Security;
/** /**
* Allow to pick amongst available scope for the current * Allow to pick amongst available scope for the current
@ -46,14 +49,10 @@ use Symfony\Component\Security\Core\Role\Role;
* - `center`: the center of the entity * - `center`: the center of the entity
* - `role` : the role of the user * - `role` : the role of the user
* *
* @author Julien Fastré <julien.fastre@champs-libres.coop>
*/ */
class ScopePickerType extends AbstractType class ScopePickerType extends AbstractType
{ {
/** protected AuthorizationHelperInterface $authorizationHelper;
* @var AuthorizationHelper
*/
protected $authorizationHelper;
/** /**
* @var TokenStorageInterface * @var TokenStorageInterface
@ -70,22 +69,26 @@ class ScopePickerType extends AbstractType
*/ */
protected $translatableStringHelper; protected $translatableStringHelper;
protected Security $security;
public function __construct( public function __construct(
AuthorizationHelper $authorizationHelper, AuthorizationHelperInterface $authorizationHelper,
TokenStorageInterface $tokenStorage, TokenStorageInterface $tokenStorage,
ScopeRepository $scopeRepository, ScopeRepository $scopeRepository,
Security $security,
TranslatableStringHelper $translatableStringHelper TranslatableStringHelper $translatableStringHelper
) { ) {
$this->authorizationHelper = $authorizationHelper; $this->authorizationHelper = $authorizationHelper;
$this->tokenStorage = $tokenStorage; $this->tokenStorage = $tokenStorage;
$this->scopeRepository = $scopeRepository; $this->scopeRepository = $scopeRepository;
$this->security = $security;
$this->translatableStringHelper = $translatableStringHelper; $this->translatableStringHelper = $translatableStringHelper;
} }
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
{ {
$query = $this->buildAccessibleScopeQuery($options['center'], $options['role']); $items = $this->authorizationHelper->getReachableScopes($this->security->getUser(),
$items = $query->getQuery()->execute(); $options['role'], $options['center']);
if (1 !== count($items)) { if (1 !== count($items)) {
$builder->add('scope', EntityType::class, [ $builder->add('scope', EntityType::class, [
@ -94,9 +97,7 @@ class ScopePickerType extends AbstractType
'choice_label' => function (Scope $c) { 'choice_label' => function (Scope $c) {
return $this->translatableStringHelper->localize($c->getName()); return $this->translatableStringHelper->localize($c->getName());
}, },
'query_builder' => function () use ($options) { 'choices' => $items,
return $this->buildAccessibleScopeQuery($options['center'], $options['role']);
},
]); ]);
$builder->setDataMapper(new ScopePickerDataMapper()); $builder->setDataMapper(new ScopePickerDataMapper());
} else { } else {
@ -121,19 +122,22 @@ class ScopePickerType extends AbstractType
$resolver $resolver
// create `center` option // create `center` option
->setRequired('center') ->setRequired('center')
->setAllowedTypes('center', [Center::class]) ->setAllowedTypes('center', [Center::class, 'array', 'null'])
// create ``role` option // create ``role` option
->setRequired('role') ->setRequired('role')
->setAllowedTypes('role', ['string', Role::class]); ->setAllowedTypes('role', ['string', Role::class]);
} }
/** /**
* @param Center|array|Center[] $center
* @param string $role
* @return \Doctrine\ORM\QueryBuilder * @return \Doctrine\ORM\QueryBuilder
*/ */
protected function buildAccessibleScopeQuery(Center $center, Role $role) protected function buildAccessibleScopeQuery($center, $role)
{ {
$roles = $this->authorizationHelper->getParentRoles($role); $roles = $this->authorizationHelper->getParentRoles($role);
$roles[] = $role; $roles[] = $role;
$centers = $center instanceof Center ? [$center]: $center;
$qb = $this->scopeRepository->createQueryBuilder('s'); $qb = $this->scopeRepository->createQueryBuilder('s');
$qb $qb
@ -142,8 +146,8 @@ class ScopePickerType extends AbstractType
->join('rs.permissionsGroups', 'pg') ->join('rs.permissionsGroups', 'pg')
->join('pg.groupCenters', 'gc') ->join('pg.groupCenters', 'gc')
// add center constraint // add center constraint
->where($qb->expr()->eq('IDENTITY(gc.center)', ':center')) ->where($qb->expr()->in('IDENTITY(gc.center)', ':centers'))
->setParameter('center', $center->getId()) ->setParameter('centers', \array_map(fn(Center $c) => $c->getId(), $centers))
// role constraints // role constraints
->andWhere($qb->expr()->in('rs.role', ':roles')) ->andWhere($qb->expr()->in('rs.role', ':roles'))
->setParameter('roles', $roles) ->setParameter('roles', $roles)

View File

@ -17,6 +17,8 @@
*/ */
namespace Chill\MainBundle\Form\Type; namespace Chill\MainBundle\Form\Type;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Repository\UserACLAwareRepositoryInterface;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
@ -56,14 +58,18 @@ class UserPickerType extends AbstractType
protected UserRepository $userRepository; protected UserRepository $userRepository;
protected UserACLAwareRepositoryInterface $userACLAwareRepository;
public function __construct( public function __construct(
AuthorizationHelper $authorizationHelper, AuthorizationHelper $authorizationHelper,
TokenStorageInterface $tokenStorage, TokenStorageInterface $tokenStorage,
UserRepository $userRepository UserRepository $userRepository,
UserACLAwareRepositoryInterface $userACLAwareRepository
) { ) {
$this->authorizationHelper = $authorizationHelper; $this->authorizationHelper = $authorizationHelper;
$this->tokenStorage = $tokenStorage; $this->tokenStorage = $tokenStorage;
$this->userRepository = $userRepository; $this->userRepository = $userRepository;
$this->userACLAwareRepository = $userACLAwareRepository;
} }
@ -72,7 +78,7 @@ class UserPickerType extends AbstractType
$resolver $resolver
// create `center` option // create `center` option
->setRequired('center') ->setRequired('center')
->setAllowedTypes('center', [\Chill\MainBundle\Entity\Center::class ]) ->setAllowedTypes('center', [\Chill\MainBundle\Entity\Center::class, 'null', 'array' ])
// create ``role` option // create ``role` option
->setRequired('role') ->setRequired('role')
->setAllowedTypes('role', ['string', \Symfony\Component\Security\Core\Role\Role::class ]) ->setAllowedTypes('role', ['string', \Symfony\Component\Security\Core\Role\Role::class ])
@ -86,17 +92,19 @@ class UserPickerType extends AbstractType
->setDefault('choice_label', function(User $u) { ->setDefault('choice_label', function(User $u) {
return $u->getUsername(); return $u->getUsername();
}) })
->setDefault('scope', null)
->setAllowedTypes('scope', [Scope::class, 'array', 'null'])
->setNormalizer('choices', function(Options $options) { ->setNormalizer('choices', function(Options $options) {
$users = $this->authorizationHelper $users = $this->userACLAwareRepository
->findUsersReaching($options['role'], $options['center']); ->findUsersByReachedACL($options['role'], $options['center'], $options['scope'], true);
if (NULL !== $options['having_permissions_group_flag']) { if (NULL !== $options['having_permissions_group_flag']) {
return $this->userRepository return $this->userRepository
->findUsersHavingFlags($options['having_permissions_group_flag'], $users) ->findUsersHavingFlags($options['having_permissions_group_flag'], $users)
; ;
} }
return $users; return $users;
}) })
; ;

View File

@ -0,0 +1,54 @@
<?php
namespace Chill\MainBundle\Repository;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
class UserACLAwareRepository implements UserACLAwareRepositoryInterface
{
private AuthorizationHelper $authorizationHelper;
public function findUsersByReachedACL(string $role, $center, $scope = null, bool $onlyEnabled = true): array
{
$parents = $this->authorizationHelper->getParentRoles($role);
$parents[] = $role;
$qb = $this->em->createQueryBuilder();
$qb
->select('u')
->from(User::class, 'u')
->join('u.groupCenters', 'gc')
->join('gc.permissionsGroup', 'pg')
->join('pg.roleScopes', 'rs')
->where($qb->expr()->in('rs.role', $parents))
;
if ($onlyEnabled) {
$qb->andWhere($qb->expr()->eq('u.enabled', "'TRUE'"));
}
if (NULL !== $center) {
$centers = $center instanceof Center ? [$center] : $center;
$qb
->andWhere($qb->expr()->in('gc.center', ':centers'))
->setParameter('centers', $centers)
;
}
if (NULL !== $scope) {
$scopes = $scope instanceof Scope ? [$scope] : $scope;
$qb
->andWhere($qb->expr()->in('rs.scope', ':scopes'))
->setParameter('scopes', $scopes)
;
}
return $qb->getQuery()->getResult();
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace Chill\MainBundle\Repository;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\User;
interface UserACLAwareRepositoryInterface
{
/**
* Find the users reaching the given center and scope, for the given role
*
* @param string $role
* @param Center|Center[]|array $center
* @param Scope|Scope[]|array|null $scope
* @param bool $onlyActive true if get only active users
*
* @return User[]
*/
public function findUsersByReachedACL(string $role, $center, $scope = null, bool $onlyActive = true): array;
}

View File

@ -1,12 +1,39 @@
{{ form_start(form) }} {{ form_start(form) }}
<div class="chill_filter_order container"> <div class="chill_filter_order container">
<div class="row"> <div class="row">
<div class="col-md-12"> {% if form.vars.has_search_box %}
<div class="input-group mb-3"> <div class="col-md-12">
{{ form_widget(form.q)}} <div class="input-group mb-3">
<button type="submit" class="btn btn-chill-l-gray"><i class="fa fa-search"></i></button> {{ form_widget(form.q)}}
<button type="submit" class="btn btn-chill-l-gray"><i class="fa fa-search"></i></button>
</div>
</div> </div>
</div> {% endif %}
</div> </div>
{% if form.checkboxes|length > 0 %}
{% for checkbox_name, options in form.checkboxes %}
<div class="row gx-0">
<div class="col-md-12">
{% for c in form['checkboxes'][checkbox_name].children %}
<div class="form-check form-check-inline">
{{ form_widget(c) }}
{{ form_label(c) }}
</div>
{% endfor %}
</div>
</div>
{% if loop.last %}
<div class="row gx-0">
<div class="col-md-12">
<ul class="record_actions">
<li>
<button type="submit" class="btn btn-misc"><i class="fa fa-filter"></i></button>
</li>
</ul>
</div>
</div>
{% endif %}
{% endfor %}
{% endif %}
</div> </div>
{{ form_end(form) }} {{ form_end(form) }}

View File

@ -8,7 +8,7 @@
{{ form_start(form) }} {{ form_start(form) }}
<ul class="record_actions"> <ul class="record_actions sticky-form-buttons">
<li class="cancel"> <li class="cancel">
<a href="{{ path(cancel_route, cancel_parameters|default( { } ) ) }}" class="btn btn-cancel"> <a href="{{ path(cancel_route, cancel_parameters|default( { } ) ) }}" class="btn btn-cancel">
{{ 'Cancel'|trans }} {{ 'Cancel'|trans }}
@ -18,5 +18,5 @@
{{ form_widget(form.submit, { 'attr' : { 'class' : "btn btn-delete" } } ) }} {{ form_widget(form.submit, { 'attr' : { 'class' : "btn btn-delete" } } ) }}
</li> </li>
</ul> </ul>
{{ form_end(form) }} {{ form_end(form) }}

View File

@ -23,6 +23,8 @@ use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Entity\Center; use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\HasCenterInterface; use Chill\MainBundle\Entity\HasCenterInterface;
use Chill\MainBundle\Entity\HasScopeInterface; use Chill\MainBundle\Entity\HasScopeInterface;
use Chill\MainBundle\Repository\UserACLAwareRepository;
use Chill\MainBundle\Repository\UserACLAwareRepositoryInterface;
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcher; use Chill\MainBundle\Security\Resolver\CenterResolverDispatcher;
use Chill\MainBundle\Security\Resolver\ScopeResolverDispatcher; use Chill\MainBundle\Security\Resolver\ScopeResolverDispatcher;
use Chill\MainBundle\Security\Resolver\ScopeResolverInterface; use Chill\MainBundle\Security\Resolver\ScopeResolverInterface;
@ -62,6 +64,8 @@ class AuthorizationHelper implements AuthorizationHelperInterface
protected LoggerInterface $logger; protected LoggerInterface $logger;
private UserACLAwareRepositoryInterface $userACLAwareRepository;
public function __construct( public function __construct(
RoleHierarchyInterface $roleHierarchy, RoleHierarchyInterface $roleHierarchy,
ParameterBagInterface $parameterBag, ParameterBagInterface $parameterBag,
@ -320,33 +324,15 @@ class AuthorizationHelper implements AuthorizationHelperInterface
/** /**
* *
* @deprecated use UserACLAwareRepositoryInterface::findUsersByReachedACL instead
* @param Center|Center[]|array $center
* @param Scope|Scope[]|array|null $scope
* @param bool $onlyActive true if get only active users
* @return User[] * @return User[]
*/ */
public function findUsersReaching(string $role, Center $center, Scope $circle = null): array public function findUsersReaching(string $role, $center, $scope = null, bool $onlyEnabled = true): array
{ {
$parents = $this->getParentRoles($role); return $this->userACLAwareRepository->findUsersByReachedACL($role, $center, $scope, $onlyEnabled);
$parents[] = $role;
$qb = $this->em->createQueryBuilder();
$qb
->select('u')
->from(User::class, 'u')
->join('u.groupCenters', 'gc')
->join('gc.permissionsGroup', 'pg')
->join('pg.roleScopes', 'rs')
->where('gc.center = :center')
->andWhere($qb->expr()->in('rs.role', $parents))
;
$qb->setParameter('center', $center);
if ($circle !== null) {
$qb->andWhere('rs.scope = :circle')
->setParameter('circle', $circle)
;
}
return $qb->getQuery()->getResult();
} }
/** /**

View File

@ -12,6 +12,12 @@ class FilterOrderHelper
private FormFactoryInterface $formFactory; private FormFactoryInterface $formFactory;
private RequestStack $requestStack; private RequestStack $requestStack;
private ?array $searchBoxFields = null; private ?array $searchBoxFields = null;
private array $checkboxes = [];
private ?array $submitted = null;
private ?string $formName = 'filter';
private string $formType = FilterOrderType::class;
private array $formOptions = [];
public function __construct( public function __construct(
FormFactoryInterface $formFactory, FormFactoryInterface $formFactory,
@ -28,6 +34,32 @@ class FilterOrderHelper
return $this; return $this;
} }
public function addCheckbox(string $name, array $choices, ?array $default = [], ?array $trans = []): self
{
$missing = count($choices) - count($trans) - 1;
$this->checkboxes[$name] = [
'choices' => $choices, 'default' => $default,
'trans' =>
\array_merge(
$trans,
0 < $missing ?
array_fill(0, $missing, null) : []
)
];
return $this;
}
public function getCheckboxData(string $name): array
{
return $this->getFormData()['checkboxes'][$name];
}
public function getCheckboxes(): array
{
return $this->checkboxes;
}
public function hasSearchBox(): bool public function hasSearchBox(): bool
{ {
return $this->searchBoxFields !== null; return $this->searchBoxFields !== null;
@ -35,26 +67,41 @@ class FilterOrderHelper
private function getFormData(): array private function getFormData(): array
{ {
return [ if (NULL === $this->submitted) {
'q' => $this->getQueryString() $this->submitted = $this->buildForm()
]; ->getData();
}
return $this->submitted;
}
private function getDefaultData(): array
{
$r = [];
if ($this->hasSearchBox()) {
$r['q'] = '';
}
foreach ($this->checkboxes as $name => $c) {
$r['checkboxes'][$name] = $c['default'];
}
return $r;
} }
public function getQueryString(): ?string public function getQueryString(): ?string
{ {
$q = $this->requestStack->getCurrentRequest() return $this->getFormData()['q'];
->query->get('q', null);
return empty($q) ? NULL : $q;
} }
public function buildForm($name = null, string $type = FilterOrderType::class, array $options = []): FormInterface public function buildForm(): FormInterface
{ {
return $this->formFactory return $this->formFactory
->createNamed($name, $type, $this->getFormData(), \array_merge([ ->createNamed($this->formName, $this->formType, $this->getDefaultData(), \array_merge([
'helper' => $this, 'helper' => $this,
'method' => 'GET', 'method' => 'GET',
'csrf_protection' => false, 'csrf_protection' => false,
], $options)); ], $this->formOptions))
->handleRequest($this->requestStack->getCurrentRequest());
} }
} }

View File

@ -8,6 +8,7 @@ use Symfony\Component\HttpFoundation\RequestStack;
class FilterOrderHelperBuilder class FilterOrderHelperBuilder
{ {
private ?array $searchBoxFields = null; private ?array $searchBoxFields = null;
private array $checkboxes = [];
private FormFactoryInterface $formFactory; private FormFactoryInterface $formFactory;
private RequestStack $requestStack; private RequestStack $requestStack;
@ -26,6 +27,13 @@ class FilterOrderHelperBuilder
return $this; return $this;
} }
public function addCheckbox(string $name, array $choices, ?array $default = [], ?array $trans = []): self
{
$this->checkboxes[$name] = [ 'choices' => $choices, 'default' => $default, 'trans' => $trans];
return $this;
}
public function build(): FilterOrderHelper public function build(): FilterOrderHelper
{ {
$helper = new FilterOrderHelper( $helper = new FilterOrderHelper(
@ -34,6 +42,13 @@ class FilterOrderHelperBuilder
); );
$helper->setSearchBox($this->searchBoxFields); $helper->setSearchBox($this->searchBoxFields);
foreach ($this->checkboxes as $name => [
'choices' => $choices,
'default' => $default,
'trans' => $trans
]) {
$helper->addCheckbox($name, $choices, $default, $trans);
}
return $helper; return $helper;
} }

View File

@ -11,6 +11,8 @@ services:
autowire: true autowire: true
autoconfigure: true autoconfigure: true
Chill\MainBundle\Repository\UserACLAwareRepositoryInterface: '@Chill\MainBundle\Repository\UserACLAwareRepository'
Chill\MainBundle\Serializer\Normalizer\: Chill\MainBundle\Serializer\Normalizer\:
resource: '../Serializer/Normalizer' resource: '../Serializer/Normalizer'
autoconfigure: true autoconfigure: true

View File

@ -28,6 +28,7 @@ use Chill\MainBundle\Entity\HasCentersInterface;
use Chill\MainBundle\Entity\HasScopesInterface; use Chill\MainBundle\Entity\HasScopesInterface;
use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\Address; use Chill\MainBundle\Entity\Address;
use Chill\MainBundle\Entity\Center;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
use Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive; use Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive;
use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment; use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment;
@ -502,7 +503,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
return $collection->count() > 0 ? $collection->first() : NULL; return $collection->count() > 0 ? $collection->first() : NULL;
} }
public function getOPenParticipations(): Collection public function getOpenParticipations(): Collection
{ {
return $this return $this
->getParticipations() ->getParticipations()
@ -513,6 +514,11 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
); );
} }
public function getCurrentParticipations(): Collection
{
return $this->getOpenParticipations();
}
/** /**
* Return an array with open participations sorted by household * Return an array with open participations sorted by household
* [ * [
@ -1015,6 +1021,15 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
return $this->addressLocation; return $this->addressLocation;
} }
public function getCenter(): ?Center
{
if (count($this->getPersons()) === 0){
return null;
} else {
return $this->getPersons()->first()->getCenter();
}
}
/** /**
* @Groups({"write"}) * @Groups({"write"})
*/ */

View File

@ -66,7 +66,7 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface
'routeParameters' => [ 'routeParameters' => [
'id' => $period->getId() 'id' => $period->getId()
]]) ]])
->setExtras(['order' => 50]); ->setExtras(['order' => 40]);
} }

View File

@ -2,11 +2,17 @@
namespace Chill\TaskBundle\Controller; namespace Chill\TaskBundle\Controller;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcher;
use Chill\MainBundle\Security\Resolver\CenterResolverInterface;
use Chill\MainBundle\Templating\Listing\FilterOrderHelper;
use Chill\MainBundle\Templating\Listing\FilterOrderHelperFactoryInterface;
use Chill\PersonBundle\Privacy\PrivacyEvent; use Chill\PersonBundle\Privacy\PrivacyEvent;
use Chill\TaskBundle\Repository\SingleTaskAclAwareRepositoryInterface;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use Doctrine\ORM\EntityManager;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
@ -22,97 +28,129 @@ 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\Repository\PersonRepository; use Chill\PersonBundle\Repository\PersonRepository;
use Chill\MainBundle\Entity\UserRepository;
use Chill\TaskBundle\Event\TaskEvent; use Chill\TaskBundle\Event\TaskEvent;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Translation\TranslatorInterface;
use Chill\TaskBundle\Event\UI\UIEvent; use Chill\TaskBundle\Event\UI\UIEvent;
use Chill\MainBundle\Repository\CenterRepository; use Chill\MainBundle\Repository\CenterRepository;
use Chill\MainBundle\Timeline\TimelineBuilder; use Chill\MainBundle\Timeline\TimelineBuilder;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Repository\AccompanyingPeriodRepository;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Contracts\Translation\TranslatorInterface;
use Symfony\Contracts\Translation\TranslatorInterface as TranslationTranslatorInterface;
/** /**
* Class SingleTaskController * Class SingleTaskController
* *
* @package Chill\TaskBundle\Controller * @package Chill\TaskBundle\Controller
*/ */
class SingleTaskController extends AbstractController final class SingleTaskController extends AbstractController
{ {
/** private EventDispatcherInterface $eventDispatcher;
* @var EventDispatcherInterface private TimelineBuilder $timelineBuilder;
*/ private LoggerInterface $logger;
protected $eventDispatcher; private CenterResolverDispatcher $centerResolverDispatcher;
private TranslatorInterface $translator;
/** private PaginatorFactory $paginatorFactory;
* private SingleTaskAclAwareRepositoryInterface $singleTaskAclAwareRepository;
* @var TimelineBuilder private FilterOrderHelperFactoryInterface $filterOrderHelperFactory;
*/
protected $timelineBuilder;
/**
* @var LoggerInterface
*/
protected $logger;
/**
* SingleTaskController constructor.
*
* @param EventDispatcherInterface $eventDispatcher
*/
public function __construct( public function __construct(
CenterResolverDispatcher $centerResolverDispatcher,
PaginatorFactory $paginatorFactory,
SingleTaskAclAwareRepositoryInterface $singleTaskAclAwareRepository,
TranslatorInterface $translator,
EventDispatcherInterface $eventDispatcher, EventDispatcherInterface $eventDispatcher,
TimelineBuilder $timelineBuilder, TimelineBuilder $timelineBuilder,
LoggerInterface $logger LoggerInterface $logger,
FilterOrderHelperFactoryInterface $filterOrderHelperFactory
) { ) {
$this->eventDispatcher = $eventDispatcher; $this->eventDispatcher = $eventDispatcher;
$this->timelineBuilder = $timelineBuilder; $this->timelineBuilder = $timelineBuilder;
$this->logger = $logger; $this->logger = $logger;
$this->translator = $translator;
$this->centerResolverDispatcher = $centerResolverDispatcher;
$this->paginatorFactory = $paginatorFactory;
$this->singleTaskAclAwareRepository = $singleTaskAclAwareRepository;
$this->filterOrderHelperFactory = $filterOrderHelperFactory;
} }
private function getEntityContext(Request $request)
{
if ($request->query->has('person_id')) {
return 'person';
} else if ($request->query->has('course_id')) {
return 'course';
} else {
return null;
}
}
/** /**
* @Route( * @Route(
* "/{_locale}/task/single-task/new", * "/{_locale}/task/single-task/new",
* name="chill_task_single_task_new" * name="chill_task_single_task_new"
* ) * )
*/ */
public function newAction( public function newAction(Request $request) {
Request $request,
TranslatorInterface $translator
) {
$task = (new SingleTask()) $task = (new SingleTask())
->setAssignee($this->getUser()) ->setAssignee($this->getUser())
->setType('task_default') ->setType('task_default')
; ;
if ($request->query->has('person_id')) { $entityType = $this->getEntityContext($request);
$personId = $request->query->getInt('person_id', 0); // sf4 check:
// prevent error: `Argument 2 passed to ::getInt() must be of the type int, null given`
if ($personId === null) { if (NULL === $entityType) {
return new Response("You must provide a person_id", Response::HTTP_BAD_REQUEST); throw new BadRequestHttpException("You must provide a entity_type");
}
$person = $this->getDoctrine()->getManager()
->getRepository(Person::class)
->find($personId);
if ($person === null) {
$this->createNotFoundException("Invalid person id");
}
$task->setPerson($person);
} }
$this->denyAccessUnlessGranted(TaskVoter::CREATE, $task, 'You are not ' $entityId = $request->query->getInt("{$entityType}_id", 0);
. 'allowed to create this task');
$form = $this->setCreateForm($task, new Role(TaskVoter::CREATE)); if ($entityId === null) {
return new BadRequestHttpException("You must provide a {$entityType}_id");
}
switch ($entityType) {
case 'person':
$person = $this->getDoctrine()->getManager()
->getRepository(Person::class)
->find($entityId);
if ($person === null) {
$this->createNotFoundException("Invalid person id");
}
$task->setPerson($person);
$role = TaskVoter::CREATE_PERSON;
break;
case 'course':
$course = $this->getDoctrine()->getManager()
->getRepository(AccompanyingPeriod::class)
->find($entityId);
if ($course === null) {
$this->createNotFoundException("Invalid accompanying course id");
}
$task->setCourse($course);
$role = TaskVoter::CREATE_COURSE;
break;
default:
return new BadRequestHttpException("context with {$entityType} is not supported");
}
$this->denyAccessUnlessGranted($role, $task, 'You are not '
. 'allowed to create this task');
$form = $this->setCreateForm($task, new Role($role));
$form->handleRequest($request); $form->handleRequest($request);
if ($form->isSubmitted()) { if ($form->isSubmitted()) {
if ($form->isValid()) { if ($form->isValid()) {
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
@ -122,72 +160,78 @@ class SingleTaskController extends AbstractController
$em->flush(); $em->flush();
$this->addFlash('success', $translator->trans("The task is created")); $this->addFlash('success', $this->translator->trans("The task is created"));
return $this->redirectToRoute('chill_task_singletask_list', [ if ($request->query->has('returnPath')) {
'person_id' => $task->getPerson()->getId() return $this->redirect($request->query->get('returnPath'));
]); }
if ($entityType === 'person') {
return $this->redirectToRoute('chill_task_singletask_by-person_list', [
'id' => $task->getPerson()->getId()
]);
} elseif ($entityType === 'course') {
return $this->redirectToRoute('chill_task_singletask_by-course_list', [
'id' => $task->getCourse()->getId()
]);
}
} else { } else {
$this->addFlash('error', $translator->trans("This form contains errors")); $this->addFlash('error', $this->translator->trans("This form contains errors"));
} }
} }
return $this->render('ChillTaskBundle:SingleTask:new.html.twig', array( switch ($entityType) {
'form' => $form->createView(), case 'person':
'task' => $task return $this->render('@ChillTask/SingleTask/Person/new.html.twig', array(
)); 'form' => $form->createView(),
'task' => $task,
'person' => $task->getPerson(),
));
case 'course':
return $this->render('@ChillTask/SingleTask/AccompanyingCourse/new.html.twig', array(
'form' => $form->createView(),
'task' => $task,
'accompanyingCourse' => $task->getCourse(),
));
default:
throw new \LogicException("entity context not supported");
}
} }
/** /**
* @Route( * @Route(
* "/{_locale}/task/single-task/{id}/show", * "/{_locale}/task/single-task/{id}/show",
* name="chill_task_single_task_show" * name="chill_task_single_task_show"
* ) * )
*/ */
public function showAction(Request $request, $id) public function showAction(SingleTask $task, Request $request)
{ {
$this->denyAccessUnlessGranted(TaskVoter::SHOW, $task);
$em = $this->getDoctrine()->getManager();
$task = $em->getRepository(SingleTask::class)->find($id);
if ($task->getPerson() !== null) { if ($person = $task->getContext() instanceof Person) {
$personId = $task->getPerson()->getId(); $event = new PrivacyEvent($person, array(
'element_class' => SingleTask::class,
if ($personId === null) { 'element_id' => $task->getId(),
return new Response("You must provide a person_id", Response::HTTP_BAD_REQUEST); 'action' => 'show'
} ));
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
$person = $this->getDoctrine()->getManager()
->getRepository(Person::class)
->find($personId);
if ($person === null) {
throw $this->createNotFoundException("Invalid person id");
}
}
$this->denyAccessUnlessGranted(TaskVoter::SHOW, $task, 'You are not '
. 'allowed to view this task');
if (!$task) {
throw $this->createNotFoundException('Unable to find Task entity.');
} }
$timeline = $this->timelineBuilder $timeline = $this->timelineBuilder
->getTimelineHTML('task', array('task' => $task)); ->getTimelineHTML('task', array('task' => $task));
$event = new PrivacyEvent($person, array( if ($task->getContext() instanceof Person) {
'element_class' => SingleTask::class, return $this->render('@ChillTask/SingleTask/Person/show.html.twig', array(
'element_id' => $task->getId(), 'task' => $task,
'action' => 'show' 'timeline' => $timeline
)); ));
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); } else {
return $this->render('@ChillTask/SingleTask/AccompanyingCourse/show.html.twig', array(
return $this->render('ChillTaskBundle:SingleTask:show.html.twig', array( 'task' => $task,
'task' => $task, 'timeline' => $timeline
'timeline' => $timeline ));
)); }
} }
@ -198,41 +242,18 @@ class SingleTaskController extends AbstractController
* ) * )
*/ */
public function editAction( public function editAction(
Request $request, SingleTask $task,
$id, Request $request
TranslatorInterface $translator
) { ) {
$em = $this->getDoctrine()->getManager();
$task = $em->getRepository(SingleTask::class)->find($id);
if ($task->getPerson() !== null) {
$personId = $task->getPerson()->getId();
if ($personId === null) {
return new Response("You must provide a person_id", Response::HTTP_BAD_REQUEST);
}
$person = $this->getDoctrine()->getManager()
->getRepository(Person::class)
->find($personId);
if ($person === null) {
throw $this->createNotFoundException("Invalid person id");
}
}
$this->denyAccessUnlessGranted(TaskVoter::UPDATE, $task, 'You are not ' $this->denyAccessUnlessGranted(TaskVoter::UPDATE, $task, 'You are not '
. 'allowed to edit this task'); . 'allowed to edit this task');
if (!$task) {
throw $this->createNotFoundException('Unable to find Task entity.');
}
$event = (new UIEvent('single-task', $task)) $event = (new UIEvent('single-task', $task))
->setForm($this->setCreateForm($task, new Role(TaskVoter::UPDATE))) ->setForm($this->setCreateForm($task, new Role(TaskVoter::UPDATE)))
; ;
$this->eventDispatcher->dispatch(UIEvent::EDIT_FORM, $event); $this->eventDispatcher->dispatch(UIEvent::EDIT_FORM, $event);
$form = $event->getForm(); $form = $event->getForm();
$form->handleRequest($request); $form->handleRequest($request);
@ -244,43 +265,64 @@ class SingleTaskController extends AbstractController
$em->flush(); $em->flush();
$this->addFlash('success', $translator $this->addFlash('success', $this->translator
->trans("The task has been updated")); ->trans("The task has been updated"));
$event = new PrivacyEvent($person, array( if ($task->getContext() instanceof Person) {
$event = new PrivacyEvent($task->getPerson(), array(
'element_class' => SingleTask::class, 'element_class' => SingleTask::class,
'element_id' => $task->getId(), 'element_id' => $task->getId(),
'action' => 'update' 'action' => 'update'
)); ));
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
return $this->redirectToRoute( if ($request->query->has('returnPath')) {
'chill_task_singletask_list', return $this->redirect($request->query->get('returnPath'));
$request->query->get('list_params', []) }
);
return $this->redirectToRoute(
'chill_task_singletask_list',
);
} else {
if ($request->query->has('returnPath')) {
return $this->redirect($request->query->get('returnPath'));
}
return $this->redirectToRoute(
'chill_task_singletask_by-course_list', ['id' => $task->getCourse()->getId()]
);
}
} else { } else {
$this->addFlash('error', $translator->trans("This form contains errors")); $this->addFlash('error', $this->translator->trans("This form contains errors"));
} }
} }
$this->eventDispatcher->dispatch(UIEvent::EDIT_PAGE, $event); $this->eventDispatcher->dispatch(UIEvent::EDIT_PAGE, $event);
if ($event->hasResponse()) { if ($event->hasResponse()) {
return $event->getResponse(); return $event->getResponse();
} }
$event = new PrivacyEvent($person, array( if ($task->getContext() instanceof Person) {
'element_class' => SingleTask::class, $event = new PrivacyEvent($task->getPerson(), array(
'element_id' => $task->getId(), 'element_class' => SingleTask::class,
'action' => 'edit' 'element_id' => $task->getId(),
)); 'action' => 'edit'
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); ));
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
return $this->render('ChillTaskBundle:SingleTask:edit.html.twig', array(
'task' => $task, return $this->render('@ChillTask/SingleTask/Person/edit.html.twig', array(
'form' => $form->createView() 'task' => $task,
)); 'form' => $form->createView()
));
} else {
return $this->render('@ChillTask/SingleTask/AccompanyingCourse/edit.html.twig', array(
'task' => $task,
'form' => $form->createView(),
'accompanyingCourse' => $task->getCourse()
));
}
} }
@ -292,10 +334,9 @@ class SingleTaskController extends AbstractController
*/ */
public function deleteAction( public function deleteAction(
Request $request, Request $request,
$id, $id
TranslatorInterface $translator
) { ) {
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$task = $em->getRepository(SingleTask::class)->find($id); $task = $em->getRepository(SingleTask::class)->find($id);
@ -317,10 +358,25 @@ class SingleTaskController extends AbstractController
throw $this->createNotFoundException("Invalid person id"); throw $this->createNotFoundException("Invalid person id");
} }
} else {
$courseId = $task->getCourse()->getId();
if ($courseId === null){
return new Response("You must provide a course_id", Response::HTTP_BAD_REQUEST);
}
$course = $this->getDoctrine()->getManager()
->getRepository(AccompanyingPeriod::class)
->find($courseId);
if($course === null){
throw $this->createNotFoundException("Invalid accompanying period id");
}
} }
$this->denyAccessUnlessGranted(TaskVoter::DELETE, $task, 'You are not ' // TODO: reactivate right to delete
. 'allowed to delete this task');
// $this->denyAccessUnlessGranted(TaskVoter::DELETE, $task, 'You are not '
// . 'allowed to delete this task');
$form = $this->createDeleteForm($id); $form = $this->createDeleteForm($id);
@ -328,38 +384,50 @@ class SingleTaskController extends AbstractController
$form->handleRequest($request); $form->handleRequest($request);
if ($form->isValid()) { if ($form->isValid()) {
$this->logger->notice("A task has been removed", array( $this->logger->notice("A task has been removed", array(
'by_user' => $this->getUser()->getUsername(), 'by_user' => $this->getUser()->getUsername(),
'task_id' => $task->getId(), 'task_id' => $task->getId(),
'description' => $task->getDescription(), 'description' => $task->getDescription(),
'assignee' => $task->getAssignee(), 'assignee' => $task->getAssignee(),
'scope_id' => $task->getScope()->getId(), // TODO reimplement scope
//'start_date' => $task->getStartDate()->format('Y-m-d'), // 'scope_id' => $task->getScope()->getId(),
//'end_date' => $task->getEndDate()->format('Y-m-d'),
//'warning_interval' => $task->getWarningInterval()->format('Y-m-d')
)); ));
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$em->remove($task); $em->remove($task);
$em->flush(); $em->flush();
$this->addFlash('success', $translator $this->addFlash('success', $this->translator
->trans("The task has been successfully removed.")); ->trans("The task has been successfully removed."));
return $this->redirect($this->generateUrl( if ($task->getContext() instanceof Person) {
'chill_task_singletask_list', return $this->redirect($this->generateUrl(
$request->query->get('list_params', [ 'chill_task_singletask_by-person_list',
'person_id' => $person->getId() [ 'id' => $task->getPerson()->getId() ]
]))); ));
} else {
return $this->redirect($this->generateUrl(
'chill_task_singletask_by-course_list',
['id' => $task->getCourse()->getId()]
));
}
} }
} }
if($task->getContext() instanceof Person){
return $this->render('@ChillTask/SingleTask/Person/confirm_delete.html.twig', array(
'task' => $task,
'delete_form' => $form->createView()
));
} else {
return $this->render('@ChillTask/SingleTask/AccompanyingCourse/confirm_delete.html.twig', array(
'task' => $task,
'delete_form' => $form->createView(),
'accompanyingCourse' => $course
));
}
return $this->render('ChillTaskBundle:SingleTask:confirm_delete.html.twig', array(
'task' => $task,
'delete_form' => $form->createView()
));
} }
/** /**
@ -371,8 +439,7 @@ class SingleTaskController extends AbstractController
protected function setCreateForm(SingleTask $task, Role $role) protected function setCreateForm(SingleTask $task, Role $role)
{ {
$form = $this->createForm(SingleTaskType::class, $task, [ $form = $this->createForm(SingleTaskType::class, $task, [
'center' => $task->getCenter(), 'role' => $role,
'role' => $role
]); ]);
$form->add('submit', SubmitType::class); $form->add('submit', SubmitType::class);
@ -388,220 +455,111 @@ class SingleTaskController extends AbstractController
* name="chill_task_single_my_tasks" * name="chill_task_single_my_tasks"
* ) * )
*/ */
public function myTasksAction(TranslatorInterface $translator) public function myTasksAction()
{ {
return $this->redirectToRoute('chill_task_singletask_list', [ $this->denyAccessUnlessGranted('ROLE_USER');
'user_id' => $this->getUser()->getId(),
'hide_form' => true, $filterOrder = $this->buildFilterOrder();
'title' => $translator->trans('My tasks') $flags = \array_merge(
$filterOrder->getCheckboxData('status'),
\array_map(fn ($i) => 'state_'.$i, $filterOrder->getCheckboxData('states'))
);
$nb = $this->singleTaskAclAwareRepository->countByCurrentUsersTasks(
$filterOrder->getQueryString(),
$flags
);
$paginator = $this->paginatorFactory->create($nb);
$tasks = $this->singleTaskAclAwareRepository->findByCurrentUsersTasks(
$filterOrder->getQueryString(),
$flags,
$paginator->getCurrentPageFirstItemNumber(),
$paginator->getItemsPerPage(),
[
'startDate' => 'DESC',
'endDate' => 'DESC',
]
);
return $this->render('@ChillTask/SingleTask/List/index.html.twig', [
'tasks' => $tasks,
'paginator' => $paginator,
'filter_order' => $filterOrder,
]); ]);
} }
private function buildFilterOrder(): FilterOrderHelper
{
$statuses = ['no-alert', 'warning', 'alert'];
$statusTrans = [
'Tasks without alert',
'Tasks near deadline',
'Tasks over deadline',
];
$states = [
// todo: get a list of possible states dynamically
'new', 'in_progress', 'closed', 'canceled'
];
return $this->filterOrderHelperFactory
->create(self::class)
->addSearchBox()
->addCheckbox('status', $statuses, $statuses, $statusTrans)
->addCheckbox('states', $states, ['new', 'in_progress'])
->build()
;
}
/** /**
* *
* Arguments: * Arguments:
* - user_id * - user_id
* - scope_id * - scope_id
* - s
* - person_id * - person_id
* - hide_form (hide the form to filter the tasks) * - hide_form (hide the form to filter the tasks)
* - status: date state, amongst SingleTaskRepository::DATE_STATUSES, or 'closed' * - status: date state, amongst SingleTaskRepository::DATE_STATUSES, or 'closed'
* *
* @Route( * @Route(
* "/{_locale}/task/singletask/list", * "/{_locale}/task/single-task/list",
* name="chill_task_singletask_list" * name="chill_task_singletask_list"
* ) * )
*/ */
public function listAction( public function listAction(
Request $request, Request $request
PaginatorFactory $paginatorFactory,
SingleTaskRepository $taskRepository,
PersonRepository $personRepository,
CenterRepository $centerRepository,
FormFactoryInterface $formFactory
) { ) {
/* @var $viewParams array The parameters for the view */ $this->denyAccessUnlessGranted(TaskVoter::SHOW, null);
/* @var $params array The parameters for the query */
$viewParams['person'] = null; $filterOrder = $this->buildFilterOrder();
$params['person'] = null; $flags = \array_merge(
$viewParams['user'] = null; $filterOrder->getCheckboxData('status'),
$params['user'] = null; \array_map(fn ($i) => 'state_'.$i, $filterOrder->getCheckboxData('states'))
$viewParams['center'] = null; );
$params['types'] = null; $nb = $this->singleTaskAclAwareRepository->countByAllViewable(
$filterOrder->getQueryString(),
$flags
);
$paginator = $this->paginatorFactory->create($nb);
if (0 < $nb) {
// Get parameters from url $tasks = $this->singleTaskAclAwareRepository->findByAllViewable(
if (!empty($request->query->get('person_id', NULL))) { $filterOrder->getQueryString(),
$flags,
$personId = $request->query->getInt('person_id', 0); $paginator->getCurrentPageFirstItemNumber(),
$person = $personRepository->find($personId); $paginator->getItemsPerPage(),
[
if ($person === null) { 'startDate' => 'DESC',
throw $this->createNotFoundException("This person ' $personId ' does not exist."); 'endDate' => 'DESC',
} ]
$this->denyAccessUnlessGranted(PersonVoter::SEE, $person); );
$viewParams['person'] = $person;
$params['person'] = $person;
}
if (!empty($request->query->get('center_id', NULL))) {
$center = $centerRepository->find($request->query->getInt('center_id'));
if ($center === null) {
throw $this->createNotFoundException('center not found');
}
$params['center'] = $center;
}
if(!empty($request->query->get('types', []))) {
$types = $request->query->get('types', []);
if (count($types) > 0) {
$params['types'] = $types;
}
}
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', 0);
$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 (!empty($request->query->get('scope_id'))) {
$scopeId = $request->query->getInt('scope_id', 0);
$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);
// check for invalid statuses
$diff = \array_diff($statuses, $possibleStatuses);
if (count($diff) > 0) {
return new Response(
'date_status not allowed: '. \implode(', ', $diff),
Response::HTTP_BAD_REQUEST
);
}
$viewParams['isSingleStatus'] = $singleStatus = count($statuses) === 1;
$tasks_count = 0;
foreach($statuses as $status) {
if($request->query->has('status')
&& FALSE === \in_array($status, $statuses)) {
continue;
}
// different query if regarding to date or 'closed'
if (in_array($status, SingleTaskRepository::DATE_STATUSES)) {
$params['date_status'] = $status;
$params['is_closed'] = false;
} else {
$params['date_status'] = null;
$params['is_closed'] = true;
}
$count = $taskRepository
->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
->findByParameters($params, $this->getUser(),
$singleStatus ? $paginator->getCurrentPage()->getFirstItemNumber() : 0,
$singleStatus ? $paginator->getItemsPerPage() : 10)
;
$tasks_count = $tasks_count + $count;
}
// total number of tasks
$viewParams['tasks_count'] = $tasks_count;
if ($viewParams['person'] !== null){
$viewParams['layout'] = '@ChillPerson/Person/layout.html.twig';
} else { } else {
$viewParams['layout'] = '@ChillMain/layout.html.twig'; $tasks = [];
} }
// Form for filtering tasks return $this->render('@ChillTask/SingleTask/List/index.html.twig', [
$form = $formFactory->createNamed(null, SingleTaskListType::class, null, [ 'tasks' => $tasks,
'person' => $viewParams['person'], 'paginator' => $paginator,
'method' => Request::METHOD_GET, 'filter_order' => $filterOrder
'csrf_protection' => false, ]);
'add_type' => true
]);
$form->handleRequest($request);
if (isset($person)) {
$event = new PrivacyEvent($person, array(
'element_class' => SingleTask::class,
'action' => 'list'
));
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
}
return $this->render('ChillTaskBundle:SingleTask:index.html.twig',
\array_merge($viewParams, [ 'form' => $form->createView() ]));
}
protected function getPersonParam(Request $request, EntityManagerInterface $em)
{
$person = $em->getRepository(Person::class)
->find($request->query->getInt('person_id'))
;
if (NULL === $person) {
throw $this->createNotFoundException('person not found');
}
$this->denyAccessUnlessGranted(PersonVoter::SEE, $person, "You are "
. "not allowed to see this person");
return $person;
}
protected function getUserParam(Request $request, EntityManagerInterface $em)
{
$user = $em->getRepository(User::class)
->find($request->query->getInt('user_id'))
;
if (NULL === $user) {
throw $this->createNotFoundException('user not found');
}
return $user;
} }
/** /**
@ -623,4 +581,103 @@ class SingleTaskController extends AbstractController
; ;
} }
/**
* @Route(
* "/{_locale}/task/single-task/by-course/{id}",
* name="chill_task_singletask_by-course_list")
*/
public function listCourseTasks(
AccompanyingPeriod $course,
FormFactoryInterface $formFactory,
Request $request
): Response
{
$this->denyAccessUnlessGranted(TaskVoter::SHOW, $course);
$filterOrder = $this->buildFilterOrder();
$flags = \array_merge(
$filterOrder->getCheckboxData('status'),
\array_map(fn ($i) => 'state_'.$i, $filterOrder->getCheckboxData('states'))
);
$nb = $this->singleTaskAclAwareRepository->countByCourse(
$course,
$filterOrder->getQueryString(),
$flags
);
$paginator = $this->paginatorFactory->create($nb);
if (0 < $nb) {
$tasks = $this->singleTaskAclAwareRepository->findByCourse(
$course,
$filterOrder->getQueryString(),
$flags,
$paginator->getCurrentPageFirstItemNumber(),
$paginator->getItemsPerPage(),
[
'startDate' => 'DESC',
'endDate' => 'DESC',
]
);
} else {
$tasks = [];
}
return $this->render(
'@ChillTask/SingleTask/AccompanyingCourse/list.html.twig',
[
'tasks' => $tasks,
'accompanyingCourse' => $course,
'paginator' => $paginator,
'filter_order' => $filterOrder
]);
}
/**
* @Route(
* "/{_locale}/task/single-task/by-person/{id}",
* name="chill_task_singletask_by-person_list")
*/
public function listPersonTasks(
Person $person
): Response {
$this->denyAccessUnlessGranted(TaskVoter::SHOW, $person);
$filterOrder = $this->buildFilterOrder();
$flags = \array_merge(
$filterOrder->getCheckboxData('status'),
\array_map(fn ($i) => 'state_'.$i, $filterOrder->getCheckboxData('states'))
);
$nb = $this->singleTaskAclAwareRepository->countByPerson(
$person,
$filterOrder->getQueryString(),
$flags
);
$paginator = $this->paginatorFactory->create($nb);
if (0 < $nb) {
$tasks = $this->singleTaskAclAwareRepository->findByPerson(
$person,
$filterOrder->getQueryString(),
$flags,
$paginator->getCurrentPageFirstItemNumber(),
$paginator->getItemsPerPage(),
[
'startDate' => 'DESC',
'endDate' => 'DESC',
]
);
} else {
$tasks = [];
}
return $this->render(
'@ChillTask/SingleTask/Person/list.html.twig',
[
'tasks' => $tasks,
'person' => $person,
'paginator' => $paginator,
'filter_order' => $filterOrder
]);
}
} }

View File

@ -64,7 +64,7 @@ class TaskController extends AbstractController
'id' => $task->getId(), 'id' => $task->getId(),
'list_params' => $request->query->get('list_params', []) 'list_params' => $request->query->get('list_params', [])
]); ]);
$defaultTemplate = '@ChillTask/SingleTask/transition.html.twig'; $task->getCourse() === null ? $defaultTemplate = '@ChillTask/SingleTask/Person/transition.html.twig' : $defaultTemplate = '@ChillTask/SingleTask/AccompanyingCourse/transition.html.twig';
break; break;
default: default:
return new Response("The type '$kind' is not implemented", return new Response("The type '$kind' is not implemented",

View File

@ -40,7 +40,7 @@ class LoadTaskACL extends AbstractFixture implements OrderedFixtureInterface
return 16000; return 16000;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager)
{ {
foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) { foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) {
@ -58,33 +58,38 @@ class LoadTaskACL extends AbstractFixture implements OrderedFixtureInterface
case 'direction': case 'direction':
if (in_array($scope->getName()['en'], array('administrative', 'social'))) { if (in_array($scope->getName()['en'], array('administrative', 'social'))) {
break 2; // we do not want any power on social or administrative break 2; // we do not want any power on social or administrative
} }
break; break;
} }
printf("Adding CHILL_TASK_TASK_UPDATE & CHILL_TASK_TASK_CREATE & Chill_TASK_TASK_DELETE permissions to %s " printf("Adding CHILL_TASK_TASK_UPDATE & CHILL_TASK_TASK_CREATE & Chill_TASK_TASK_DELETE permissions to %s "
. "permission group, scope '%s' \n", . "permission group, scope '%s' \n",
$permissionsGroup->getName(), $scope->getName()['en']); $permissionsGroup->getName(), $scope->getName()['en']);
$roleScopeUpdate = (new RoleScope()) $roleScopeUpdate = (new RoleScope())
->setRole(TaskVoter::UPDATE) ->setRole(TaskVoter::UPDATE)
->setScope($scope); ->setScope($scope);
$permissionsGroup->addRoleScope($roleScopeUpdate); $permissionsGroup->addRoleScope($roleScopeUpdate);
$roleScopeCreate = (new RoleScope()) $roleScopeCreateP = (new RoleScope())
->setRole(TaskVoter::CREATE) ->setRole(TaskVoter::CREATE_PERSON)
->setScope($scope); ->setScope($scope);
$permissionsGroup->addRoleScope($roleScopeCreate); $permissionsGroup->addRoleScope($roleScopeCreateP);
$roleScopeCreateC = (new RoleScope())
->setRole(TaskVoter::CREATE_COURSE)
->setScope($scope);
$permissionsGroup->addRoleScope($roleScopeCreateC);
$roleScopeDelete = (new RoleScope()) $roleScopeDelete = (new RoleScope())
->setRole(TaskVoter::DELETE) ->setRole(TaskVoter::DELETE)
->setScope($scope); ->setScope($scope);
$permissionsGroup->addRoleScope($roleScopeDelete); $permissionsGroup->addRoleScope($roleScopeDelete);
$manager->persist($roleScopeUpdate); $manager->persist($roleScopeUpdate);
$manager->persist($roleScopeCreate); $manager->persist($roleScopeCreateP);
$manager->persist($roleScopeCreateC);
$manager->persist($roleScopeDelete); $manager->persist($roleScopeDelete);
} }
} }
$manager->flush(); $manager->flush();
} }

View File

@ -44,7 +44,7 @@ class ChillTaskExtension extends Extension implements PrependExtensionInterface
$this->prependRoute($container); $this->prependRoute($container);
$this->prependWorkflows($container); $this->prependWorkflows($container);
} }
protected function prependRoute(ContainerBuilder $container) protected function prependRoute(ContainerBuilder $container)
{ {
//declare routes for task bundle //declare routes for task bundle
@ -56,17 +56,18 @@ class ChillTaskExtension extends Extension implements PrependExtensionInterface
) )
)); ));
} }
protected function prependAuthorization(ContainerBuilder $container) protected function prependAuthorization(ContainerBuilder $container)
{ {
$container->prependExtensionConfig('security', array( $container->prependExtensionConfig('security', array(
'role_hierarchy' => array( 'role_hierarchy' => array(
TaskVoter::UPDATE => [TaskVoter::SHOW], TaskVoter::UPDATE => [TaskVoter::SHOW],
TaskVoter::CREATE => [TaskVoter::SHOW] TaskVoter::CREATE_COURSE => [TaskVoter::SHOW],
TaskVoter::CREATE_PERSON => [TaskVoter::SHOW],
) )
)); ));
} }
protected function prependWorkflows(ContainerBuilder $container) protected function prependWorkflows(ContainerBuilder $container)
{ {
$container->prependExtensionConfig('framework', [ $container->prependExtensionConfig('framework', [

View File

@ -10,15 +10,12 @@ use Chill\MainBundle\Entity\HasScopeInterface;
use Chill\MainBundle\Entity\HasCenterInterface; use Chill\MainBundle\Entity\HasCenterInterface;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
use Chill\MainBundle\Validator\Constraints\Entity\UserCircleConsistency; use Chill\MainBundle\Validator\Constraints\Entity\UserCircleConsistency;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
/** /**
* AbstractTask * AbstractTask
* *
* @ORM\MappedSuperclass() * @ORM\MappedSuperclass()
* @UserCircleConsistency(
* "CHILL_TASK_TASK_SHOW",
* getUserFunction="getAssignee"
* )
*/ */
abstract class AbstractTask implements HasScopeInterface, HasCenterInterface abstract class AbstractTask implements HasScopeInterface, HasCenterInterface
{ {
@ -51,7 +48,7 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface
* @ORM\Column(name="description", type="text") * @ORM\Column(name="description", type="text")
*/ */
private $description = ''; private $description = '';
/** /**
* *
* @var User * @var User
@ -60,36 +57,42 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface
* ) * )
*/ */
private $assignee; private $assignee;
/** /**
* *
* @var Person * @var Person
* @ORM\ManyToOne( * @ORM\ManyToOne(
* targetEntity="\Chill\PersonBundle\Entity\Person" * targetEntity="\Chill\PersonBundle\Entity\Person"
* ) * )
* @Assert\NotNull()
*/ */
private $person; private $person;
/**
* @var AccompanyingPeriod
* @ORM\ManyToOne(targetEntity="\Chill\PersonBundle\Entity\AccompanyingPeriod")
*/
private $course;
/** /**
* *
* @var Scope * @var Scope
* @ORM\ManyToOne( * @ORM\ManyToOne(
* targetEntity="\Chill\MainBundle\Entity\Scope" * targetEntity="\Chill\MainBundle\Entity\Scope"
* ) * )
* @Assert\NotNull()
*/ */
private $circle; private $circle;
/** /**
* @var boolean * @var boolean
* @ORM\Column(name="closed", type="boolean", options={ "default"=false }) * @ORM\Column(name="closed", type="boolean", options={ "default"=false })
*/ */
private $closed = false; private $closed = false;
public function __construct() public function __construct()
{ {
} }
/** /**
@ -118,7 +121,7 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface
/** /**
* Set currentStates * Set currentStates
* *
* The current states are sorted in a single array, non associative. * The current states are sorted in a single array, non associative.
* *
* @param $currentStates * @param $currentStates
@ -134,8 +137,8 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface
/** /**
* Get currentStates * Get currentStates
* *
* The states are returned as required by marking store format. * The states are returned as required by marking store format.
* *
* @return array * @return array
*/ */
@ -191,7 +194,7 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface
{ {
return $this->description; return $this->description;
} }
public function getAssignee(): ?User public function getAssignee(): ?User
{ {
return $this->assignee; return $this->assignee;
@ -202,11 +205,16 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface
return $this->person; return $this->person;
} }
public function getCourse(): ?AccompanyingPeriod
{
return $this->course;
}
public function getCircle(): ?Scope public function getCircle(): ?Scope
{ {
return $this->circle; return $this->circle;
} }
public function setAssignee(User $assignee = null) public function setAssignee(User $assignee = null)
{ {
$this->assignee = $assignee; $this->assignee = $assignee;
@ -219,6 +227,12 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface
return $this; return $this;
} }
public function setCourse(AccompanyingPeriod $course)
{
$this->course = $course;
return $this;
}
public function setCircle(Scope $circle) public function setCircle(Scope $circle)
{ {
$this->circle = $circle; $this->circle = $circle;
@ -229,12 +243,19 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface
{ {
if ($this->getPerson() instanceof Person) { if ($this->getPerson() instanceof Person) {
return $this->getPerson()->getCenter(); return $this->getPerson()->getCenter();
} else {
return $this->getCourse()->getCenter();
} }
return null; return null;
} }
public function getContext()
{
return $this->getPerson() ?? $this->getCourse();
}
public function getScope(): ?\Chill\MainBundle\Entity\Scope public function getScope(): ?\Chill\MainBundle\Entity\Scope
{ {
return $this->getCircle(); return $this->getCircle();
@ -247,9 +268,9 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface
{ {
return $this->closed; return $this->closed;
} }
/** /**
* *
* @param bool $closed * @param bool $closed
*/ */
public function setClosed(bool $closed) public function setClosed(bool $closed)

View File

@ -19,6 +19,10 @@ use Doctrine\Common\Collections\Collection;
* @ORM\Index( * @ORM\Index(
* name="by_current_state", * name="by_current_state",
* columns={ "current_states" } * columns={ "current_states" }
* ),
* @ORM\Index(
* name="by_end_date",
* columns={ "end_date" }
* ) * )
* } * }
* ) * )
@ -40,12 +44,12 @@ class SingleTask extends AbstractTask
* *
* @ORM\Column(name="start_date", type="date", nullable=true) * @ORM\Column(name="start_date", type="date", nullable=true)
* @Assert\Date() * @Assert\Date()
* *
* @Assert\Expression( * @Assert\Expression(
* "value === null or this.getEndDate() === null or value < this.getEndDate()", * "value === null or this.getEndDate() === null or value < this.getEndDate()",
* message="The start date must be before the end date" * message="The start date must be before the end date"
* ) * )
* *
* @Assert\Expression( * @Assert\Expression(
* "value === null or this.getWarningDate() === null or this.getWarningDate() > this.getStartDate()", * "value === null or this.getWarningDate() === null or this.getWarningDate() > this.getStartDate()",
* message="The start date must be before warning date" * message="The start date must be before warning date"
@ -66,16 +70,16 @@ class SingleTask extends AbstractTask
* and this.getEndDate() === null * and this.getEndDate() === null
* *
* @ORM\Column(name="warning_interval", type="dateinterval", nullable=true) * @ORM\Column(name="warning_interval", type="dateinterval", nullable=true)
* *
* @Assert\Expression( * @Assert\Expression(
* "!(value != null and this.getEndDate() == null)", * "!(value != null and this.getEndDate() == null)",
* message="An end date is required if a warning interval is set" * message="An end date is required if a warning interval is set"
* ) * )
* *
* *
*/ */
private $warningInterval; private $warningInterval;
/** /**
* *
* @var RecurringTask * @var RecurringTask
@ -85,7 +89,7 @@ class SingleTask extends AbstractTask
* ) * )
*/ */
private $recurringTask; private $recurringTask;
/** /**
* *
* @var \Doctrine\Common\Collections\Collection * @var \Doctrine\Common\Collections\Collection
@ -96,15 +100,15 @@ class SingleTask extends AbstractTask
* ) * )
*/ */
private $taskPlaceEvents; private $taskPlaceEvents;
public function __construct() public function __construct()
{ {
$this->taskPlaceEvents = $events = new \Doctrine\Common\Collections\ArrayCollection; $this->taskPlaceEvents = $events = new \Doctrine\Common\Collections\ArrayCollection;
parent::__construct(); parent::__construct();
} }
/** /**
* Get id * Get id
* *
@ -186,13 +190,13 @@ class SingleTask extends AbstractTask
{ {
return $this->warningInterval; return $this->warningInterval;
} }
/** /**
* Get the Warning date, computed from the difference between the * Get the Warning date, computed from the difference between the
* end date and the warning interval * end date and the warning interval
* *
* Return null if warningDate or endDate is null * Return null if warningDate or endDate is null
* *
* @return \DateTimeImmutable * @return \DateTimeImmutable
*/ */
public function getWarningDate() public function getWarningDate()
@ -200,15 +204,15 @@ class SingleTask extends AbstractTask
if ($this->getWarningInterval() === null) { if ($this->getWarningInterval() === null) {
return null; return null;
} }
if ($this->getEndDate() === null) { if ($this->getEndDate() === null) {
return null; return null;
} }
return \DateTimeImmutable::createFromMutable($this->getEndDate()) return \DateTimeImmutable::createFromMutable($this->getEndDate())
->sub($this->getWarningInterval()); ->sub($this->getWarningInterval());
} }
function getRecurringTask(): RecurringTask function getRecurringTask(): RecurringTask
{ {
return $this->recurringTask; return $this->recurringTask;
@ -227,7 +231,7 @@ class SingleTask extends AbstractTask
public function setTaskPlaceEvents(Collection $taskPlaceEvents) public function setTaskPlaceEvents(Collection $taskPlaceEvents)
{ {
$this->taskPlaceEvents = $taskPlaceEvents; $this->taskPlaceEvents = $taskPlaceEvents;
return $this; return $this;
} }
} }

View File

@ -284,6 +284,7 @@ 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('accompanyingCourse')
->setDefined('add_status') ->setDefined('add_status')
->setDefault('add_status', false) ->setDefault('add_status', false)
->setAllowedTypes('add_status', ['bool']) ->setAllowedTypes('add_status', ['bool'])

View File

@ -17,6 +17,10 @@
*/ */
namespace Chill\TaskBundle\Form; namespace Chill\TaskBundle\Form;
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcher;
use Chill\MainBundle\Security\Resolver\ScopeResolverDispatcher;
use Chill\TaskBundle\Security\Authorization\TaskVoter;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Chill\MainBundle\Form\Type\ChillDateType; use Chill\MainBundle\Form\Type\ChillDateType;
@ -29,15 +33,26 @@ use Symfony\Component\Security\Core\Role\Role;
use Chill\MainBundle\Form\Type\DateIntervalType; use Chill\MainBundle\Form\Type\DateIntervalType;
use Chill\MainBundle\Form\Type\ChillTextareaType; use Chill\MainBundle\Form\Type\ChillTextareaType;
/**
*
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
*/
class SingleTaskType extends AbstractType class SingleTaskType extends AbstractType
{ {
private ParameterBagInterface $parameterBag;
private CenterResolverDispatcher $centerResolverDispatcher;
private ScopeResolverDispatcher $scopeResolverDispatcher;
public function __construct(ParameterBagInterface $parameterBag, CenterResolverDispatcher $centerResolverDispatcher, ScopeResolverDispatcher $scopeResolverDispatcher)
{
$this->parameterBag = $parameterBag;
$this->centerResolverDispatcher = $centerResolverDispatcher;
$this->scopeResolverDispatcher = $scopeResolverDispatcher;
}
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
{ {
if (NULL !== $task = $options['data']) {
$center = $this->centerResolverDispatcher->resolveCenter($task);
$isScopeConcerned = $this->scopeResolverDispatcher->isConcerned($task);
}
$builder $builder
->add('title', TextType::class) ->add('title', TextType::class)
->add('description', ChillTextareaType::class, [ ->add('description', ChillTextareaType::class, [
@ -45,14 +60,10 @@ class SingleTaskType extends AbstractType
]) ])
->add('assignee', UserPickerType::class, [ ->add('assignee', UserPickerType::class, [
'required' => false, 'required' => false,
'center' => $options['center'], 'center' => $center,
'role' => $options['role'], 'role' => TaskVoter::SHOW,
'placeholder' => 'Not assigned' 'placeholder' => 'Not assigned'
]) ])
->add('circle', ScopePickerType::class, [
'center' => $options['center'],
'role' => $options['role']
])
->add('startDate', ChillDateType::class, [ ->add('startDate', ChillDateType::class, [
'required' => false 'required' => false
]) ])
@ -61,17 +72,24 @@ class SingleTaskType extends AbstractType
]) ])
->add('warningInterval', DateIntervalType::class, [ ->add('warningInterval', DateIntervalType::class, [
'required' => false 'required' => false
]) ]);
;
if ($this->parameterBag->get('chill_main')['acl']['form_show_scopes']
&& $isScopeConcerned) {
$builder
->add('circle', ScopePickerType::class, [
'center' => $center,
'role' => $options['role'],
'required' => false
]);
}
} }
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver)
{ {
$resolver $resolver
->setRequired('center')
->setAllowedTypes('center', [ Center::class ])
->setRequired('role') ->setRequired('role')
->setAllowedTypes('role', [ Role::class ]) ->setAllowedTypes('role', [ Role::class, 'string' ])
; ;
} }
} }

View File

@ -24,24 +24,24 @@ use Chill\TaskBundle\Security\Authorization\TaskVoter;
use Symfony\Component\Translation\TranslatorInterface; use Symfony\Component\Translation\TranslatorInterface;
/** /**
* *
* *
* @author Julien Fastré <julien.fastre@champs-libres.coop> * @author Julien Fastré <julien.fastre@champs-libres.coop>
*/ */
class PersonMenuBuilder implements LocalMenuBuilderInterface class MenuBuilder implements LocalMenuBuilderInterface
{ {
/** /**
* *
* @var TranslatorInterface * @var TranslatorInterface
*/ */
protected $translator; protected $translator;
/** /**
* *
* @var AuthorizationCheckerInterface * @var AuthorizationCheckerInterface
*/ */
protected $authorizationChecker; protected $authorizationChecker;
public function __construct( public function __construct(
AuthorizationCheckerInterface $authorizationChecker, AuthorizationCheckerInterface $authorizationChecker,
TranslatorInterface $translator) TranslatorInterface $translator)
@ -50,31 +50,58 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface
$this->authorizationChecker = $authorizationChecker; $this->authorizationChecker = $authorizationChecker;
} }
public function buildMenu($menuId, MenuItem $menu, array $parameters) public function buildMenu($menuId, MenuItem $menu, array $parameters)
{ {
/* @var $person \Chill\PersonBundle\Entity\Person */ switch($menuId) {
$person = $parameters['person'] ?? null; case 'person':
$this->buildPersonMenu($menu, $parameters);
if ($this->authorizationChecker->isGranted(TaskVoter::SHOW, $person)) { break;
$menu->addChild( case 'accompanyingCourse':
$this->translator->trans('Tasks'), [ $this->buildAccompanyingCourseMenu($menu, $parameters);
'route' => 'chill_task_singletask_list', break;
'routeParameters' => $menuId === 'person' ? case 'section':
[ 'person_id' => $person->getId() ] $menu->setExtras('icons', 'tasks');
: break;
null, default:
]) throw new \LogicException("this menuid $menuId is not implemented");
->setExtra('order', 400)
;
if ($menuId === 'section') {
$menu->setExtra('icons', 'tasks');
}
} }
} }
public function buildPersonMenu($menu, $parameters){
//var $person \Chill\PersonBundle\Entity\Person */
$person = $parameters['person'] ?? null;
if ($this->authorizationChecker->isGranted(TaskVoter::SHOW, $person)) {
$menu->addChild(
$this->translator->trans('Tasks'), [
'route' => 'chill_task_singletask_by-person_list',
'routeParameters' =>
[ 'id' => $person->getId() ]
])
->setExtra('order', 400);
}
}
public function buildAccompanyingCourseMenu($menu, $parameters){
$course = $parameters['accompanyingCourse'];
if ($this->authorizationChecker->isGranted(TaskVoter::SHOW, $course)) {
$menu->addChild(
$this->translator->trans('Tasks'), [
'route' => 'chill_task_singletask_by-course_list',
'routeParameters' =>
[ 'id' => $course->getId() ]
])
->setExtra('order', 400);
}
}
public static function getMenuIds(): array public static function getMenuIds(): array
{ {
return ['person']; return ['person', 'accompanyingCourse'];
} }
} }

View File

@ -0,0 +1,335 @@
<?php
namespace Chill\TaskBundle\Repository;
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcher;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person;
use Chill\TaskBundle\Entity\SingleTask;
use Chill\TaskBundle\Security\Authorization\TaskVoter;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Security\Core\Security;
final class SingleTaskAclAwareRepository implements SingleTaskAclAwareRepositoryInterface
{
private AuthorizationHelperInterface $authorizationHelper;
private EntityManagerInterface $em;
private Security $security;
private CenterResolverDispatcher $centerResolverDispatcher;
public function __construct(
CenterResolverDispatcher $centerResolverDispatcher,
EntityManagerInterface $em,
Security $security,
AuthorizationHelperInterface $authorizationHelper
) {
$this->centerResolverDispatcher = $centerResolverDispatcher;
$this->em = $em;
$this->security = $security;
$this->authorizationHelper = $authorizationHelper;
}
public function findByCurrentUsersTasks(
?string $pattern = null,
?array $flags = [],
?int $start = 0,
?int $limit = 50,
?array $orderBy = []
): array {
$qb = $this->buildQueryMyTasks($pattern, $flags);
return $this->getResult($qb, $start, $limit, $orderBy);
}
public function countByCurrentUsersTasks(
?string $pattern = null,
?array $flags = []
): int {
return $this->buildQueryMyTasks($pattern, $flags)
->select('COUNT(t)')
->getQuery()->getSingleScalarResult();
}
public function findByCourse(
AccompanyingPeriod $course,
?string $pattern = null,
?array $flags = [],
?int $start = 0,
?int $limit = 50,
?array $orderBy = []
): array {
$qb = $this->buildQueryByCourse($course, $pattern, $flags);
$qb = $this->addACL($qb, $course);
return $this->getResult($qb, $start, $limit, $orderBy);
}
public function countByCourse(
AccompanyingPeriod $course,
?string $pattern = null,
?array $flags = []
): int {
$qb = $this->buildQueryByCourse($course, $pattern, $flags);
return $this
->addACL($qb, $course)
->select('COUNT(t)')
->getQuery()->getSingleScalarResult();
}
public function findByPerson(
Person $person,
?string $pattern = null,
?array $flags = [],
?int $start = 0,
?int $limit = 50,
?array $orderBy = []
): array {
$qb = $this->buildQueryByPerson($person, $pattern, $flags);
$qb = $this->addACL($qb, $person);
return $this->getResult($qb, $start, $limit, $orderBy);
}
public function countByPerson(
Person $person,
?string $pattern = null,
?array $flags = []
): int {
$qb = $this->buildQueryByPerson($person, $pattern, $flags);
return $this
->addACL($qb, $person)
->select('COUNT(t)')
->getQuery()->getSingleScalarResult();
}
public function countByAllViewable(
?string $pattern = null,
?array $flags = []
): int {
$qb = $this->buildBaseQuery($pattern, $flags);
return $this
->addACLGlobal($qb)
->select('COUNT(t)')
->getQuery()->getSingleScalarResult();
}
public function findByAllViewable(
?string $pattern = null,
?array $flags = [],
?int $start = 0,
?int $limit = 50,
?array $orderBy = []
): array {
$qb = $this->buildBaseQuery($pattern, $flags);
$qb = $this->addACLGlobal($qb);
return $this->getResult($qb, $start, $limit, $orderBy);
}
public function buildQueryByCourse(
AccompanyingPeriod $course,
?string $pattern = null,
?array $flags = []
) : QueryBuilder {
$qb = $this->buildBaseQuery($pattern, $flags);
return $qb
->andWhere($qb->expr()->eq('t.course', ':course'))
->setParameter('course', $course)
;
}
public function buildQueryByPerson(
Person $person,
?string $pattern = null,
?array $flags = []
): QueryBuilder
{
$qb = $this->buildBaseQuery($pattern, $flags);
return $qb
->andWhere($qb->expr()->eq('t.person', ':person'))
->setParameter('person', $person);
}
public function buildQueryMyTasks(
?string $pattern = null,
?array $flags = []
): QueryBuilder {
$qb = $this->buildBaseQuery($pattern, $flags);
return $qb
->andWhere($qb->expr()->eq('t.assignee', ':user'))
->setParameter('user', $this->security->getUser())
;
}
public function getResult(
QueryBuilder $qb,
?int $start = 0,
?int $limit = 50,
?array $orderBy = []
): array {
$qb->select('t');
$qb
->setFirstResult($start)
->setMaxResults($limit)
;
foreach ($orderBy as $field => $direction) {
$qb->addOrderBy('t.'.$field, $direction);
}
return $qb->getQuery()->getResult();
}
private function addACL(
QueryBuilder $qb,
$entity
): QueryBuilder {
$scopes = $this->authorizationHelper->getReachableScopes($this->security->getUser(),
TaskVoter::SHOW, $this->centerResolverDispatcher->resolveCenter($entity));
return $qb->andWhere($qb->expr()->in('t.circle', ':scopes'))
->setParameter('scopes', $scopes);
}
private function addACLGlobal(
QueryBuilder $qb
): QueryBuilder {
$allowedCenters = $this->authorizationHelper
->getReachableCenters($this->security->getUser(), TaskVoter::SHOW);
if ([] === $allowedCenters) {
$qb
->andWhere($qb->expr()->lt('t.id', ':falseid'))
->setParameter('falseid', -1);
}
$qb->leftJoin('t.person', 'person')
->leftJoin('t.course', 'course')
->leftJoin('course.participations', 'participation')
->leftJoin('participation.person', 'person_p')
;
$qb->distinct(true);
$k = 0;
$orX = $qb->expr()->orX();
foreach ($allowedCenters as $center) {
$allowedScopes = $this->authorizationHelper->getReachableScopes($this->security->getUser(),
TaskVoter::SHOW, $center);
$and = $qb->expr()->andX(
$qb->expr()->orX(
$qb->expr()->eq('person.center', ':center_'.$k),
$qb->expr()->eq('person_p.center', ':center_'.$k)
),
$qb->expr()->in('t.circle', ':scopes_'.$k)
);
$qb
->setParameter('center_'.$k, $center)
->setParameter('scopes_'.$k, $allowedScopes);
$orX->add($and);
$k++;
}
$qb->andWhere($orX);
return $qb;
}
public function buildBaseQuery (
?string $pattern = null,
?array $flags = []
): QueryBuilder {
$qb = $this->em->createQueryBuilder();
$qb
->from(SingleTask::class, 't')
;
if (!empty($pattern)) {
$qb->andWhere($qb->expr()->like('LOWER(UNACCENT(t.title))', 'LOWER(UNACCENT(:pattern))'))
->setParameter('pattern', '%'.$pattern.'%')
;
}
if (count($flags) > 0) {
$orXDate = $qb->expr()->orX();
$orXState = $qb->expr()->orX();
$now = new \DateTime();
foreach ($flags as $key => $flag) {
switch ($flag) {
case 'no-alert':
$orXDate
->add(
$qb->expr()->orX(
$qb->expr()->isNull('t.endDate'),
$qb->expr()->gte('t.endDate - COALESCE(t.warningInterval, :intervalBlank)', ':now')
)
);
$qb
->setParameter('intervalBlank', new \DateInterval('P0D'))
->setParameter('now', $now);
break;
case 'warning':
$orXDate
->add(
$qb->expr()->andX(
$qb->expr()->not($qb->expr()->isNull('t.endDate')),
$qb->expr()->not($qb->expr()->isNull('t.warningInterval')),
$qb->expr()->gte('t.endDate - t.warningInterval', ':now'),
$qb->expr()->lt('t.endDate', ':now')
)
);
$qb
->setParameter('now', $now);
break;
case 'alert':
$orXDate
->add(
$qb->expr()->andX(
$qb->expr()->not($qb->expr()->isNull('t.endDate')),
$qb->expr()->lte('t.endDate', ':now')
)
);
$qb
->setParameter('now', $now);
break;
case 'state_new':
$orXState
->add(
"JSONB_ARRAY_LENGTH(t.currentStates) = 0"
);
break;
case \substr($flag, 0, 6) === 'state_':
$state = \substr($flag, 6);
$orXState
->add(
"JSONB_EXISTS_IN_ARRAY(t.currentStates, :state_$key) = 'TRUE'"
);
$qb->setParameter("state_$key", $state);
break;
default:
throw new \LogicException("this flag is not supported: $flag");
}
}
if ($orXDate->count() > 0) {
$qb->andWhere($orXDate);
}
if ($orXState->count() > 0) {
$qb->andWhere($orXState);
}
}
return $qb;
}
}

View File

@ -0,0 +1,56 @@
<?php
namespace Chill\TaskBundle\Repository;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person;
interface SingleTaskAclAwareRepositoryInterface
{
public function findByCurrentUsersTasks(?string $pattern = null, ?array $flags = [], ?int $start = 0, ?int $limit = 50, ?array $orderBy = []): array;
public function countByCurrentUsersTasks(?string $pattern = null, ?array $flags = []): int;
public function findByCourse(
AccompanyingPeriod $course,
?string $pattern = null,
?array $flags = [],
?int $start = 0,
?int $limit = 50,
?array $orderBy = []
): array;
public function countByCourse(
AccompanyingPeriod $course,
?string $pattern = null,
?array $flags = []
): int;
public function findByPerson(
Person $person,
?string $pattern = null,
?array $flags = [],
?int $start = 0,
?int $limit = 50,
?array $orderBy = []
): array;
public function countByPerson(
Person $person,
?string $pattern = null,
?array $flags = []
): int;
public function countByAllViewable(
?string $pattern = null,
?array $flags = []
): int;
public function findByAllViewable(
?string $pattern = null,
?array $flags = [],
?int $start = 0,
?int $limit = 50,
?array $orderBy = []
): array;
}

View File

@ -1,13 +1,21 @@
/*
!!!!!!!
This is a legacy version for task list. The new task are now
layed out in page/tile_list/index.js
!!!!!!
*/
table.chill-task-list { table.chill-task-list {
.chill-task-list__row > div { .chill-task-list__row > div {
margin-bottom: 0.50rem; margin-bottom: 0.50rem;
} }
.chill-task-list__row__title { .chill-task-list__row__title {
font-weight: bold; font-weight: bold;
font-size: 1.40rem; font-size: 1.40rem;
} }
.chill-task-list__row__type { .chill-task-list__row__type {
font-variant: small-caps; font-variant: small-caps;
display: inline; display: inline;
@ -21,31 +29,31 @@ table.chill-task-list {
border: 1px solid var(--chill-dark-gray); border: 1px solid var(--chill-dark-gray);
color: var(--chill-dark-gray); color: var(--chill-dark-gray);
} }
.chill-task-list__row__person-for { .chill-task-list__row__person-for {
display: inline; display: inline;
font-weight: bold; font-weight: bold;
} }
.chill-task-list__row__assignee { .chill-task-list__row__assignee {
display: inline; display: inline;
} }
.chill_task-list__row__assignee_by { .chill_task-list__row__assignee_by {
display: inline; display: inline;
font-weight: bold; font-weight: bold;
} }
.chill-task-list__row__dates { .chill-task-list__row__dates {
& > ul { & > ul {
display: inline; display: inline;
list-style: none; list-style: none;
& > li { & > li {
display: inline; display: inline;
margin-right: 0.25rem; margin-right: 0.25rem;
} }
} }
} }

View File

@ -1,34 +1,22 @@
// Access to Bootstrap variables and mixins
@import '~ChillMainAssets/module/bootstrap/shared';
.task-status { .task-status {
&.box {
font-variant: small-caps; // 'new', 'in_progress', 'closed', 'canceled'
display: inline; &.place-new {
padding: .2em .6em .3em; background-color: $chill-yellow;
font-size: 0.88rem;
font-weight: bold;
line-height: 1;
text-align: center;
white-space: nowrap;
vertical-align: baseline;
border-radius: .25em;
color: white;
} }
&.type-task_default {
// 'new', 'in_progress', 'closed', 'canceled'
&.place-new {
background-color: var(--chill-yellow);
}
&.place-in_progress { &.place-in_progress {
background-color: var(--chill-green); background-color: $chill-green;
} }
&.place-closed { &.place-closed {
background-color: var(--chill-blue); background-color: $chill-blue;
} }
&.place-canceled { &.place-canceled {
background-color: var(--chill-beige); background-color: $chill-beige;
}
} }
} }

View File

@ -0,0 +1 @@
require("./task_list.scss");

View File

@ -0,0 +1,24 @@
.chill-task-list {
.task-type {
font-variant: small-caps;
display: inline;
padding: 0.05rem .15rem;
font-size: 0.88rem;
font-weight: light;
line-height: 1;
text-align: center;
white-space: nowrap;
vertical-align: baseline;
border: 1px solid var(--chill-dark-gray);
color: var(--chill-dark-gray);
}
.assignee {
text-align: right;
}
.dates {
text-align: right;
}
}

View File

@ -0,0 +1,19 @@
{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %}
{% set activeRouteKey = 'chill_task_task_list' %}
{% set course = task.course %}
{% block title 'Remove task'|trans %}
{% block content %}
{{ include('@ChillMain/Util/confirmation_template.html.twig',
{
'title' : 'Remove task'|trans,
'confirm_question' : 'Are you sure you want to remove the task "%title%" ?'|trans({ '%title%' : task.title } ),
'cancel_route' : 'chill_task_singletask_by-course_list',
'cancel_parameters' : {'id' : task.course.id },
'form' : delete_form,
} ) }}
{% endblock %}

View File

@ -0,0 +1,15 @@
{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %}
{% set activeRouteKey = 'chill_task_single_task_edit' %}
{% set course = task.course %}
{% block title %}
{{ 'Edit task'|trans }}
{% endblock %}
{% block content %}
{% include '@ChillTask/SingleTask/_edit.html.twig' %}
{% endblock %}

View File

@ -0,0 +1,44 @@
{% extends '@ChillPerson/AccompanyingCourse/layout.html.twig' %}
{% block title 'Tasks for this accompanying period'|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' : false } %}
{% endfor %}
</div>
{% endif %}
{{ chill_pagination(paginator) }}
{% if is_granted('CHILL_TASK_TASK_CREATE_FOR_COURSE', person) %}
<ul class="record_actions sticky-form-buttons">
<li>
{% if accompanyingCourse is not null %}
<a href="{{ path('chill_task_single_task_new', {'course_id': accompanyingCourse.id}) }}" class="btn btn-create">
{{ 'Create' | trans }}
</a>
{% endif %}
</li>
</ul>
{% endif %}
</div>
{% endblock %}
{% block css %}
{{ encore_entry_link_tags('page_task_list') }}
{% endblock %}
{% block js %}
{{ encore_entry_script_tags('page_task_list') }}
{% endblock %}

View File

@ -0,0 +1,13 @@
{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %}
{% set activeRouteKey = 'chill_task_single_task_new' %}
{# {% set person = task.person %} #}
{% block title %}
{{ 'New task'|trans }}
{% endblock %}
{% block content %}
{% include '@ChillTask/SingleTask/_new.html.twig' %}
{% endblock %}

View File

@ -0,0 +1,17 @@
{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %}
{% set activeRouteKey = 'chill_task_single_task_show' %}
{% set accompanyingCourse = task.course %}
{% block title %}
{{ 'Task'|trans }}
{% endblock %}
{% block content %}
{% include '@ChillTask/SingleTask/_show.html.twig' %}
{% endblock %}

View File

@ -0,0 +1,12 @@
{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %}
{% set activeRouteKey = 'chill_task_task_list' %}
{% set accompanyingCourse = task.course %}
{% block title 'Remove task'|trans %}
{% block content %}
{% include '@ChillTask/SingleTask/_transition.html.twig' %}
{% endblock %}

View File

@ -0,0 +1,32 @@
{% 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 %}
{{ encore_entry_link_tags('page_task_list') }}
{% endblock %}
{% block js %}
{{ encore_entry_script_tags('page_task_list') }}
{% endblock %}

View File

@ -0,0 +1,125 @@
<div class="item-bloc">
<div class="item-row">
<div class="item-col">
<div class="denomination h2">
{{ task.title }}
{% for place in workflow_marked_places(task) %}
<span class="task-status badge type-{{ task.type }} place-{{ place }}">
{{ place|trans }}
</span>
{% endfor %}
</div>
{% if task.type != 'task_default'%}
<span class="task-type">
{{ task_workflow_metadata(task, 'definition.name')|trans }}
</span>
{% endif %}
{% if showContext %}
<div>
{% if task.person is not null %}
<span class="chill-task-list__row__person">
{% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with {
targetEntity: { name: 'person', id: task.person.id },
action: 'show',
displayBadge: true,
buttonText: task.person|chill_entity_render_string
} %}
</span>
{% elseif task.course is not null %}
<a href="{{ path('chill_person_accompanying_course_index', { 'accompanying_period_id': task.course.id }) }}"
class="btn btn-sm btn-outline-primary" title="{{ 'See accompanying period'|trans }}">
<i class="fa fa-random fa-fw"></i>
</a>
{% for part in task.course.currentParticipations %}
{% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with {
targetEntity: { name: 'person', id: part.person.id },
action: 'show',
displayBadge: true,
buttonText: part.person|chill_entity_render_string
} %}
{% endfor %}
{% endif %}
</div>
{% endif %}
</div>
<div class="item-col">
<div class="container">
{% if task.assignee is not null %}
<div class="assignee row">
<span>{{ task.assignee|chill_entity_render_box }}</span>
</div>
{% endif %}
{% if task.startDate is not null or task.warningDate is not null or task.endDate is not null %}
<div class="dates row">
<ul class="column">
{% if task.startDate is not null %}
<li title="{{ 'Start'|trans|escape('html_attr') }}">
<i class="fa fa-play"></i>
{{ task.startDate|format_date('medium') }}
</li>
{% endif %}
{% if task.warningDate is not null %}
<li title="{{ 'Warning'|trans|escape('html_attr') }}">
<i class="fa fa-exclamation-triangle"></i>
{{ task.warningDate|format_date('medium') }}
</li>
{% endif %}
{% if task.endDate is not null %}
<li title="{{ 'End'|trans|escape('html_attr') }}">
<i class="fa fa-hourglass-end"></i>
{{ task.endDate|format_date('medium') }}
</li>
{% endif %}
</ul>
</div>
{% endif %}
</div>
</div>
</div>
<div class="item-row separator">
<ul class="record_actions">
{% if workflow_transitions(task)|length > 0 %}
<li>
<div class="btn-group">
<a class="btn btn-task-exchange dropdown-toggle" href="#" role="button" id="taskExchange" data-bs-toggle="dropdown" aria-expanded="false">
{{'Change task status'|trans}}
</a>
<ul class="dropdown-menu" aria-labelledby="taskExchange">
{% for transition in workflow_transitions(task) %}
<li>
<a class="dropdown-item" href="{{ path('chill_task_task_transition', { 'taskId': task.id, 'transition': transition.name, 'kind': 'single-task', 'list_params': app.request.query.all }) }}" class="{{ task_workflow_metadata(task, 'transition.class', transition)|e('html_attr') }}">
{{ task_workflow_metadata(task, 'transition.verb', transition)|trans }}
</a>
</li>
{% endfor %}
</ul>
</div>
</li>
{% endif %}
<li>
<a href="{{ chill_path_add_return_path('chill_task_single_task_show', { 'id': task.id }) }}" class="btn btn-show "></a>
</li>
{% if is_granted('CHILL_TASK_TASK_UPDATE', task) %}
<li>
<a href="{{ chill_path_add_return_path('chill_task_single_task_edit', { 'id': task.id }) }}" class="btn btn-update "></a>
</li>
{% endif %}
{% if is_granted('CHILL_TASK_TASK_DELETE', task) %}
<li>
<a href="{{ chill_path_add_return_path('chill_task_single_task_delete', { 'id': task.id } ) }}" class="btn btn-delete "></a>
</li>
{% endif %}
</ul>
</div>
</div>

View File

@ -0,0 +1,31 @@
{#
* 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 person is defined ? "@ChillPerson/Person/layout.html.twig" %}
{% set activeRouteKey = 'chill_task_single_task_edit' %}
{% set person = task.person %}
{% block title %}
{{ 'Edit task'|trans }}
{% endblock %}
{% block personcontent %}
{% include '@ChillTask/SingleTask/_edit.html.twig' %}
{% endblock %}

View File

@ -0,0 +1,44 @@
{% extends '@ChillPerson/Person/layout.html.twig' %}
{% set activeRouteKey = '' %}
{% block title 'Tasks for {{ name }}'|trans({ '{{ name }}' : person|chill_entity_render_string }) %}
{% block personcontent %}
<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' : false } %}
{% endfor %}
</div>
{% endif %}
{{ chill_pagination(paginator) }}
{% if is_granted('CHILL_TASK_TASK_CREATE_FOR_PERSON', person) %}
<ul class="record_actions sticky-form-buttons">
<li>
<a href="{{ path('chill_task_single_task_new', {'person_id': person.id}) }}" class="btn btn-create">
{{ 'Create' | trans }}
</a>
</li>
</ul>
{% endif %}
</div>
{% endblock %}
{% block css %}
{{ encore_entry_link_tags('page_task_list') }}
{% endblock %}
{% block js %}
{{ encore_entry_script_tags('page_task_list') }}
{% endblock %}

View File

@ -14,37 +14,17 @@
* You should have received a copy of the GNU Affero General Public License * 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/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
#} #}
{% extends "@ChillPerson/Person/layout.html.twig" %} {% extends person is defined ? "@ChillPerson/Person/layout.html.twig" : "@ChillPerson/AccompanyingCourse/layout.html.twig" %}
{% set activeRouteKey = 'chill_task_single_task_new' %} {% set activeRouteKey = 'chill_task_single_task_new' %}
{% set person = task.person %} {% set person = task.person %}
{% block title %}{{ 'New task'|trans }}{% endblock %} {% block title %}
{{ 'New task'|trans }}
{% endblock %}
{% block personcontent %} {% block personcontent %}
<div class="task-new"> {% include '@ChillTask/SingleTask/_new.html.twig' %}
<h1>{{ 'New task'|trans }}</h1>
{{ form_start(form) }}
{{ form_errors(form) }}
{{ form_row(form.title) }}
{{ form_row(form.description) }}
{{ form_row(form.assignee) }}
{{ form_row(form.circle) }}
{{ form_row(form.startDate) }}
{{ form_row(form.endDate) }}
{{ form_row(form.warningInterval) }}
<ul class="record_actions sticky-form-buttons">
<li>
{{ form_widget(form.submit, { 'label': 'Add a new task'|trans, 'attr': {'class': 'btn btn-save'} }) }}
</li>
</ul>
{{ form_end(form) }}
</div>
{% endblock %} {% endblock %}

View File

@ -0,0 +1,33 @@
{#
* 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 person is defined ? "@ChillPerson/Person/layout.html.twig" : "@ChillPerson/AccompanyingCourse/layout.html.twig" %}
{% set activeRouteKey = 'chill_task_single_task_show' %}
{% set person = task.person %}
{% block title %}
{{ 'Task'|trans }}
{% endblock %}
{% block personcontent %}
{% include '@ChillTask/SingleTask/_show.html.twig' %}
{% endblock %}

View File

@ -0,0 +1,12 @@
{% extends "@ChillPerson/Person/layout.html.twig" %}
{% set activeRouteKey = 'chill_task_task_list' %}
{% set person = task.person %}
{% block title 'Remove task'|trans %}
{% block personcontent %}
{% include '@ChillTask/SingleTask/_transition.html.twig' %}
{% endblock %}

View File

@ -0,0 +1,27 @@
<div class="task-edit">
<h1>{{ 'Edit task'|trans }}</h1>
{{ form_start(form) }}
{{ form_row(form.title) }}
{{ form_row(form.description) }}
{{ form_row(form.assignee) }}
{% if form.circle is defined %}
{{ form_row(form.circle) }}
{% endif %}
{{ form_row(form.startDate) }}
{{ form_row(form.endDate) }}
{{ form_row(form.warningInterval) }}
<ul class="record_actions sticky-form-buttons">
<li class="cancel">
<a class="btn btn-cancel" href={% if task.person is not null %}"{{ chill_return_path_or('chill_task_singletask_list', { 'person_id': task.person.id } ) }}"{% else %}"{{ chill_return_path_or('chill_task_singletask_courselist', {'course_id': task.course.id}) }}" {% endif %}>
{{ 'Cancel'|trans }}</a>
</li>
<li>
{{ form_widget(form.submit, { 'label': 'Save task', 'attr': {'class' : 'btn btn-update'}})}}
</li>
</ul>
{{ form_end(form) }}
</div>

View File

@ -1,244 +0,0 @@
{% macro date_status(title, tasks, count, paginator, status, isSingleStatus, person, user) %}
{% if tasks|length > 0 %}
<h3>{{ title|trans }}</h3>
<table class="table table-bordered border-dark chill-task-list">
<tbody>
{% for task in tasks %}
<tr>
<td>
<div>
<span class="chill-task-list__row__title">{{ task.title }}</span>
</div>
{% if person is null %}
<div>
<span class="chill-task-list__row__person-for">{{ 'For person'|trans }}&nbsp;:</span> <span class="chill-task-list__row__person"><a href="{{ path('chill_person_view', {person_id : task.person.Id}) }}">{{ task.person}}</a></span>
</div>
{% endif %}
<div>
<span class="chill-task-list__row__type">{{ task_workflow_metadata(task, 'definition.name')|trans }}</span>
</div>
<div>
{% for place in workflow_marked_places(task) %}
<span class="task-status box type-{{ task.type }} place-{{ place }}">{{ place|trans }}</span>
{% endfor %}
{% if task.assignee is not null %}
<div class="chill-task-list__row__assignee"><span class="chill_task-list__row__assignee_by">{{ 'By'|trans }}&nbsp;:</span> {{ task.assignee.username }}</div>
{% endif %}
</div>
{% if task.startDate is not null or task.warningDate is not null or task.endDate is not null %}
<div class="chill-task-list__row__dates">
<ul class="record_actions column">
{% if task.startDate is not null %}
<li title="{{ 'Start'|trans|escape('html_attr') }}">
<i class="fa fa-play" ></i> {{ task.startDate|format_date('medium') }}
</li>
{% endif %}
{% if task.warningDate is not null %}
<li title="{{ 'Warning'|trans|escape('html_attr') }}">
<i class="fa fa-exclamation-triangle"></i> {{ task.warningDate|format_date('medium') }}
</li>
{% endif %}
{% if task.endDate is not null %}
<li title="{{ 'End'|trans|escape('html_attr') }}">
<i class="fa fa-hourglass-end"></i> {{ task.endDate|format_date('medium') }}
</li>
{% endif %}
</ul>
</div>
{% endif %}
</td>
<td>
<ul class="record_actions">
{% if workflow_transitions(task)|length > 0 %}
<li>
<div class="btn-group">
<a class="btn btn-task-exchange dropdown-toggle" href="#" role="button"
id="taskExchange" data-bs-toggle="dropdown" aria-expanded="false">
{{'Change task status'|trans}}
</a>
<ul class="dropdown-menu" aria-labelledby="taskExchange">
{% for transition in workflow_transitions(task) %}
<li>
<a class="dropdown-item"
href="{{ path('chill_task_task_transition', { 'taskId': task.id, 'transition': transition.name, 'kind': 'single-task', 'list_params': app.request.query.all }) }}" class="{{ task_workflow_metadata(task, 'transition.class', transition)|e('html_attr') }}">
{{ task_workflow_metadata(task, 'transition.verb', transition)|trans }}
</a>
</li>
{% endfor %}
</ul>
</div>
</li>
{% endif %}
<li>
<a href="{{ path('chill_task_single_task_show', { 'id': task.id, 'list_params': app.request.query.all }) }}" class="btn btn-show "></a>
</li>
{% if is_granted('CHILL_TASK_TASK_UPDATE', task) %}
<li>
<a href="{{ path('chill_task_single_task_edit', { 'id': task.id, 'list_params': app.request.query.all }) }}" class="btn btn-update "></a>
</li>
{% endif %}
{% if is_granted('CHILL_TASK_TASK_DELETE', task) %}
<li>
<a href="{{ path('chill_task_single_task_delete', { 'id': task.id, 'list_params': app.request.query.all } ) }}" class="btn btn-delete "></a>
</li>
{% endif %}
</ul>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% if isSingleStatus %}
{% if tasks|length < paginator.getTotalItems %}
{{ chill_pagination(paginator) }}
{% endif %}
<!-- lien retour -->
<ul class="record_actions">
<li>
{% if person is not null %}
<a href="{{ path('chill_task_singletask_list', {'person_id': person.id}) }}" class="btn btn-cancel">
{{ 'Back to the list' | trans }}
</a>
{% endif %}
{% if user is not null %}
<a href="{{ path('chill_task_singletask_list') }}" class="btn btn-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="btn btn-create">
{{ 'Add a new task' | trans }}
</a>
{% endif %}
{% if user is not null %}
<a href="{{ path('chill_task_single_task_new') }}" class="btn btn-create">
{{ 'Add a new task' | trans }}
</a>
{% endif %}
</li>
</ul>
{% else %}
<ul class="record_actions">
<li>
<a href="{{ path('chill_task_singletask_list', app.request.query.all|merge({ 'status': [ status ] })) }}" class="btn btn-misc">
{{ 'See more' | trans }}
</a>
</li>
</ul>
{% endif %}
{% endif %}
{% endmacro %}
{% import _self as helper %}
<h1>{{ app.request.query.get('title', null)|escape('html')|default('Task list'|trans) }}</h1>
{% if false == app.request.query.boolean('hide_form', false) %}
<h2>{{ 'Filter the tasks'|trans }}</h2>
{{ form_start(form) }}
{{ form_row(form.user_id) }}
{% if form.status is defined %}
{{ form_row(form.status) }}
{% endif %}
{% if form.types is defined %}
{{ form_row(form.types) }}
{% endif %}
{% if form.person_id is defined %}
{{ form_row(form.person_id) }}
{% endif %}
{% if form.center_id is defined %}
{{ form_row(form.center_id) }}
{% endif %}
<ul class="record_actions">
<li>
<button type="submit" class="btn btn-submit">{{ 'Filter'|trans }}</button>
</li>
</ul>
{{ form_end(form)}}
{% endif %}
{% if tasks_count == 0 %}
<p class="chill-no-data-statement">{{ "There is no tasks."|trans }}</p>
{% 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="btn btn-create">
{{ 'Add a new task' | trans }}
</a>
{% endif %}
</li>
</ul>
{% endif %}
{% else %}
{% if false == app.request.query.boolean('hide_form', false) %}
<h2>{{ 'Tasks'|trans }}</h2>
{% endif %}
{% 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="btn btn-create">
{{ 'Add a new task' | trans }}
</a>
{% endif %}
</li>
</ul>
{% endif %}
{% 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) }}
{% endif %}
{% if single_task_warning_tasks is defined %}
{{ helper.date_status('Tasks with warning deadline reached', single_task_warning_tasks, single_task_warning_count, single_task_warning_paginator, 'warning', isSingleStatus, person) }}
{% endif %}
{% if single_task_current_tasks is defined %}
{{ helper.date_status('Current tasks', single_task_current_tasks, single_task_current_count, single_task_current_paginator, 'current', isSingleStatus, person) }}
{% endif %}
{% 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) }}
{% endif %}
{% if single_task_closed_tasks is defined %}
{{ helper.date_status('Closed tasks', single_task_closed_tasks, single_task_closed_count, single_task_closed_paginator, 'closed', isSingleStatus, person) }}
{% endif %}
{% if isSingleStatus == false %}
<ul class="record_actions">
<li>
{% 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="btn btn-create">
{{ 'Add a new task' | trans }}
</a>
{% endif %}
</li>
</ul>
{% endif %}
{% endif %}

View File

@ -0,0 +1,32 @@
<div class="task-new">
<h1>{{ 'New task'|trans }}</h1>
{{ form_start(form) }}
{{ form_errors(form) }}
{{ form_row(form.title) }}
{{ form_row(form.description) }}
{{ form_row(form.assignee) }}
{% if form.circle is defined %}
{{ form_row(form.circle) }}
{% endif %}
{{ form_row(form.startDate) }}
{{ form_row(form.endDate) }}
{{ form_row(form.warningInterval) }}
<ul class="record_actions sticky-form-buttons">
<li class="cancel">
<a class="btn btn-cancel" href={% if task.person is not null %} "{{ path('chill_task_singletask_list', { 'person_id': task.person.id, 'list_params': app.request.query.get('list_params', {} )} ) }}" {% else %} "{{ chill_return_path_or('chill_task_singletask_by-course_list', {'id': task.course.id}) }}" {% endif %}>
{{'Cancel'|trans}}
</a>
</li>
<li>
{{ form_widget(form.submit, { 'label': 'Add a new task'|trans, 'attr': {'class': 'btn btn-save'} }) }}
</li>
</ul>
{{ form_end(form) }}
</div>

View File

@ -0,0 +1,113 @@
<div class="task-show">
<h1>{{ 'Task'|trans }}</h1>
<h2>{{ task.title }}
{% for place in workflow_marked_places(task) %}
<span class="task-status box type-{{ task.type }} place-{{ place }}">{{ place|trans }}</span>
{% endfor %}
</h2>
<dl class="chill_view_data">
<dt class="inline">{{ 'Description'|trans }}</dt>
<dd>
{% if task.description is empty %}
<span class="chill-no-data-statement">{{"No description"|trans}}</span>
{% else %}
<blockquote class="chill-user-quote">
{{ task.description|chill_markdown_to_html }}
</blockquote>
{% endif %}
</dd>
<dt class="inline">{{ 'Assignee'|trans }}</dt>
<dd>
{% if task.assignee is null %}
<span class="chill-no-data-statement">{{"No one assignee"|trans}}</span>
{% else %}
{{ task.assignee }}
{% endif %}
</dd>
{% if task.scope is not null %}
<dt class="inline">{{ 'Scope'|trans }}</dt>
<dd>
<span class="scope">{{ task.scope.name|localize_translatable_string }}</span>
</dd>
{% endif %}
<h3>{{"Dates"|trans}}</h3>
{% if task.startDate is null and task.endDate is null and task.warningDate is null %}
<dt></dt>
<dd>
<span class="chill-no-data-statement">{{"No dates specified"|trans}}</span>
</dd>
</dt>
{% else %}
{% if task.startDate is not null %}
<dt class="inline">{{ 'Start'|trans }}</dt>
<dd>{{ task.startDate|format_date('long') }}</dd>
{% endif %}
{% if task.endDate is not null %}
<dt class="inline">{{ 'End'|trans }}</dt>
<dd>{{ task.endDate|format_date('long') }}</dd>
{% endif %}
{% if task.warningDate is not null %}
<dt class="inline">{{ 'Warning'|trans }}</dt>
<dd>{{ task.warningDate|format_date('long') }}</dd>
{% endif %}
{% endif %}
</dl>
{% if timeline is not null %}
<h3>{{"Timeline"|trans}}</h3>
{{ timeline|raw }}
{% endif %}
<ul class="record_actions sticky-form-buttons">
<li class="cancel">
<a class="btn btn-cancel" href={% if task.person is not null %} "{{ chill_return_path_or('chill_task_singletask_list', { 'person_id': task.person.id } ) }}" {% else %} "{{ chill_return_path_or('chill_task_singletask_by-course_list', {'id': task.course.id}) }}" {% endif %}>
{{'Cancel'|trans}}
</a>
</li>
{% if workflow_transitions(task)|length > 0 %}
<li>
<div class="btn-group">
<a class="btn btn-task-exchange dropdown-toggle" href="#" role="button" id="taskExchange" data-bs-toggle="dropdown" aria-expanded="false">
{{'Change task status'|trans}}
</a>
<ul class="dropdown-menu" aria-labelledby="taskExchange">
{% for transition in workflow_transitions(task) %}
<li>
<a class="dropdown-item" href="{{ path('chill_task_task_transition', { 'taskId': task.id, 'transition': transition.name, 'kind': 'single-task', 'return_path': app.request.uri }) }}" class="{{ task_workflow_metadata(task, 'transition.class', transition)|e('html_attr') }}">
{{ task_workflow_metadata(task, 'transition.verb', transition)|trans }}
</a>
</li>
{% endfor %}
</ul>
</div>
</li>
{% endif %}
{% if is_granted('CHILL_TASK_TASK_DELETE', task) %}
<li>
<a href="{{ chill_path_forward_return_path('chill_task_single_task_delete', { 'id': task.id } ) }}" class="btn btn-delete">
{{ 'Delete'|trans }}
</a>
</li>
{% endif %}
{% if is_granted('CHILL_TASK_TASK_UPDATE', task) %}
<li>
<a class="btn btn-update" href="{{ chill_path_forward_return_path('chill_task_single_task_edit', { 'id': task.id }) }}">
{{ 'Edit the task'|trans }}
</a>
</li>
{% endif %}
</ul></div>

View File

@ -0,0 +1,23 @@
<h2>{{ 'Apply transition on task <em>%title%</em>'|trans({ '%title%': task.title } )|raw }}</h2>
{% if task_workflow_metadata(task, 'transition.sentence_confirmation', transition) is not empty %}
<p class="message-confirm">{{ task_workflow_metadata(task, 'transition.sentence_confirmation', transition)|trans }}</p>
{% else %}
<p>{{ 'Are you sure to apply the transition %name% on this task ?'|trans({ '%name%': task_workflow_metadata(task, 'transition.name', transition)|default(transition.name)|trans }) }}</p>
{% endif %}
{{ form_start(form) }}
<ul class="record_actions">
<li class="cancel">
<a href="{{ path('chill_task_singletask_list', app.request.query.get('list_params', { }) ) }}" class="btn btn-cancel">
{{ 'Back to the list'|trans }}
</a>
</li>
<li>
{{ form_widget(form.submit, { 'attr' : { 'class' : "btn btn-task-exchange green" }, 'label': task_workflow_metadata(task, 'transition.apply_transition_submit_label', transition)|default('apply')|trans } ) }}
</li>
</ul>
{{ form_end(form) }}

View File

@ -1,59 +0,0 @@
{#
* 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 "@ChillPerson/Person/layout.html.twig" %}
{% set activeRouteKey = 'chill_task_single_task_edit' %}
{% set person = task.person %}
{% block title %}{{ 'Edit task'|trans }}{% endblock %}
{% block personcontent %}
<div class="task-edit">
<h1>{{ 'Edit task'|trans }}</h1>
{{ form_start(form) }}
{{ form_row(form.title) }}
{{ form_row(form.description) }}
{{ form_row(form.assignee) }}
{{ form_row(form.circle) }}
{{ form_row(form.startDate) }}
{{ form_row(form.endDate) }}
{{ form_row(form.warningInterval) }}
<ul class="record_actions sticky-form-buttons">
<li class="cancel">
<a class="btn btn-cancel" href="{% apply spaceless %}
{% if app.request.query.has('returnPath') %}
{{ app.request.query.get('returnPath')|escape('html_attr') }}">
{% else %}
{{ path('chill_task_single_task_show', { 'id': task.id, 'list_params': app.request.query.get('list_params', { } )} ) }}
{% endif %}
{% endapply %}">
{{ app.request.query.get('returnLabel')|default('Cancel'|trans) }}
</a>
</li>
<li>
{{ form_widget(form.submit, { 'label': 'Save task', 'attr': {'class' : 'btn btn-update'}})}}
</li>
</ul>
{{ form_end(form) }}
</div>
{% endblock %}

View File

@ -15,30 +15,32 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
#} #}
{% extends '@ChillPerson/Person/layout.html.twig' %} {% extends layout %}
{% set activeRouteKey = 'chill_task_single_task_new' %} {% set activeRouteKey = 'chill_task_single_task_new' %}
{% block title %}{{ 'Task list'|trans }}{% endblock %} {% block title %}
{{ 'Task list'|trans }}
{% endblock %}
{% macro thead() %} {% macro thead() %}{% endmacro %}
{% endmacro %}
{% macro row(task) %} {% macro row(task) %}{% endmacro %}
{% endmacro %}
{% block filtertasks %} {% block filtertasks %}
{% if person is not null %} {% if person is not null %}
{% block personcontent %} {% block personcontent %}
<div class="tasks"> <div class="tasks">
{% include 'ChillTaskBundle:SingleTask:_list.html.twig' %} {% include '@ChillTask/SingleTask/Person/list.html.twig' %}
</div>
{% endblock %} </div>
{% else %} {% endblock %}
{% block content %} {% else %}
<div class="col-md-10 col-xxl tasks"> {% block content %}
{% include 'ChillTaskBundle:SingleTask:_list.html.twig' %} <div class="col-md-10 col-xxl tasks">
</div> {% include '@ChillTask/SingleTask/AccompanyingCourse/list.html.twig' %}
{% endblock %}
{% endif %} </div>
{% endblock %}
{% endif %}
{% endblock %} {% endblock %}

View File

@ -1,139 +0,0 @@
{#
* 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 "@ChillPerson/Person/layout.html.twig" %}
{% set activeRouteKey = 'chill_task_single_task_show' %}
{% set person = task.person %}
{% block title %}{{ 'Task'|trans }}{% endblock %}
{% block personcontent %}
<div class="task-show">
<h1>{{ 'Task'|trans }}</h1>
<h2>{{ task.title }} {% for place in workflow_marked_places(task) %}
<span class="task-status box type-{{ task.type }} place-{{ place }}">{{ place|trans }}</span>
{% endfor %}</h2>
<dl class="chill_view_data">
<dt class="inline">{{ 'Description'|trans }}</dt>
<dd>
{% if task.description is empty %}
<span class="chill-no-data-statement">{{"No description"|trans}}</span>
{% else %}
<blockquote class="chill-user-quote">
{{ task.description|chill_markdown_to_html }}
</blockquote>
{% endif %}
</dd>
<dt class="inline">{{ 'Assignee'|trans }}</dt>
<dd>
{% if task.assignee is null %}
<span class="chill-no-data-statement">{{"No one assignee"|trans}}</span>
{% else %}
{{ task.assignee }}
{% endif %}
</dd>
<dt class="inline">{{ 'Scope'|trans }}</dt>
<dd><span class="scope">{{ task.scope.name|localize_translatable_string }}</span></dd>
<h3>{{"Dates"|trans}}</h3>
{% if task.startDate is null and task.endDate is null and task.warningDate is null %}
<dt>
<dd><span class="chill-no-data-statement">{{"No dates specified"|trans}}</span></dd>
</dt>
{% else %}
{% if task.startDate is not null %}
<dt class="inline">{{ 'Start'|trans }}</dt>
<dd>{{ task.startDate|format_date('long') }}</dd>
{% endif %}
{% if task.endDate is not null %}
<dt class="inline">{{ 'End'|trans }}</dt>
<dd>{{ task.endDate|format_date('long') }}</dd>
{% endif %}
{% if task.warningDate is not null %}
<dt class="inline">{{ 'Warning'|trans }}</dt>
<dd>{{ task.warningDate|format_date('long') }}</dd>
{% endif %}
{% endif %}
</dl>
{% if timeline is not null %}
<h3>{{"Timeline"|trans}}</h3>
{{ timeline|raw }}
{% endif %}
<ul class="record_actions sticky-form-buttons">
<li class="cancel">
<a class="btn btn-cancel" href="{%- if app.request.query.has('returnPath') -%}
{{ app.request.query.get('returnPath')|escape('html_attr') }}
{%- else -%}
{{ path('chill_task_singletask_list', app.request.query.get('list_params', {}) ) }}
{%- endif -%}">
{{ app.request.query.get('returnLabel')|default('Back to the list'|trans) }}
</a>
</li>
{% if workflow_transitions(task)|length > 0 %}
<li>
<div class="btn-group">
<a class="btn btn-task-exchange dropdown-toggle" href="#" role="button"
id="taskExchange" data-bs-toggle="dropdown" aria-expanded="false">
{{'Change task status'|trans}}
</a>
<ul class="dropdown-menu" aria-labelledby="taskExchange">
{% for transition in workflow_transitions(task) %}
<li>
<a class="dropdown-item"
href="{{ path('chill_task_task_transition', { 'taskId': task.id, 'transition': transition.name, 'kind': 'single-task', 'return_path': app.request.uri }) }}" class="{{ task_workflow_metadata(task, 'transition.class', transition)|e('html_attr') }}">
{{ task_workflow_metadata(task, 'transition.verb', transition)|trans }}
</a>
</li>
{% endfor %}
</ul>
</div>
</li>
{% endif %}
{% if is_granted('CHILL_TASK_TASK_UPDATE', task) %}
<li>
<a class="btn btn-update" href="{{ path('chill_task_single_task_edit', { 'id': task.id }) }}">
{{ 'Edit the task'|trans }}
</a>
</li>
{% endif %}
{% if is_granted('CHILL_TASK_TASK_CREATE', task) %}
<li>
<a href="{{ path('chill_task_single_task_delete', { 'id': task.id } ) }}" class="btn btn-delete">
{{ 'Delete'|trans }}
</a>
</li>
{% endif %}
</ul>
</div>
{% endblock %}

View File

@ -1,34 +0,0 @@
{% extends "@ChillPerson/Person/layout.html.twig" %}
{% set activeRouteKey = 'chill_task_task_list' %}
{% set person = task.person %}
{% block title 'Remove task'|trans %}
{% block personcontent %}
<h2>{{ 'Apply transition on task <em>%title%</em>'|trans({ '%title%': task.title } )|raw }}</h2>
{% if task_workflow_metadata(task, 'transition.sentence_confirmation', transition) is not empty %}
<p class="message-confirm">{{ task_workflow_metadata(task, 'transition.sentence_confirmation', transition)|trans }}</p>
{% else %}
<p>{{ 'Are you sure to apply the transition %name% on this task ?'|trans({ '%name%': task_workflow_metadata(task, 'transition.name', transition)|default(transition.name)|trans }) }}</p>
{% endif %}
{{ form_start(form) }}
<ul class="record_actions">
<li class="cancel">
<a href="{{ path('chill_task_singletask_list', app.request.query.get('list_params', { }) ) }}" class="btn btn-cancel">
{{ 'Back to the list'|trans }}
</a>
</li>
<li>
{{ form_widget(form.submit, { 'attr' : { 'class' : "btn btn-task-exchange green" }, 'label': task_workflow_metadata(task, 'transition.apply_transition_submit_label', transition)|default('apply')|trans } ) }}
</li>
</ul>
{{ form_end(form) }}
{% endblock %}

View File

@ -32,23 +32,27 @@ 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\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Chill\TaskBundle\Security\Authorization\AuthorizationEvent; use Chill\TaskBundle\Security\Authorization\AuthorizationEvent;
final class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface final class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface
{ {
const CREATE = 'CHILL_TASK_TASK_CREATE'; const CREATE_COURSE = 'CHILL_TASK_TASK_CREATE_FOR_COURSE';
const UPDATE = 'CHILL_TASK_TASK_UPDATE'; const CREATE_PERSON = 'CHILL_TASK_TASK_CREATE_FOR_PERSON';
const SHOW = 'CHILL_TASK_TASK_SHOW';
const DELETE = 'CHILL_TASK_TASK_DELETE'; const DELETE = 'CHILL_TASK_TASK_DELETE';
const SHOW = 'CHILL_TASK_TASK_SHOW';
const UPDATE = 'CHILL_TASK_TASK_UPDATE';
const ROLES = [ const ROLES = [
self::CREATE, self::CREATE_COURSE,
self::UPDATE, self::CREATE_PERSON,
self::DELETE,
self::SHOW, self::SHOW,
self::DELETE self::UPDATE,
]; ];
protected AuthorizationHelper $authorizationHelper; protected AuthorizationHelper $authorizationHelper;
@ -63,7 +67,9 @@ final class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchy
protected VoterHelperInterface $voter; protected VoterHelperInterface $voter;
public function __construct( public function __construct(
VoterHelperFactoryInterface $voterHelperFactory,
AccessDecisionManagerInterface $accessDecisionManager, AccessDecisionManagerInterface $accessDecisionManager,
AuthorizationHelper $authorizationHelper, AuthorizationHelper $authorizationHelper,
EventDispatcherInterface $eventDispatcher, EventDispatcherInterface $eventDispatcher,
@ -80,7 +86,8 @@ final class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchy
$this->voter = $voterFactory $this->voter = $voterFactory
->generate(AbstractTask::class) ->generate(AbstractTask::class)
->addCheckFor(AbstractTask::class, self::ROLES) ->addCheckFor(AbstractTask::class, self::ROLES)
->addCheckFor(Person::class, [self::SHOW]) ->addCheckFor(Person::class, [self::SHOW, self::CREATE_PERSON])
->addCheckFor(AccompanyingPeriod::class, [self::SHOW, self::CREATE_COURSE])
->addCheckFor(null, [self::SHOW]) ->addCheckFor(null, [self::SHOW])
->build() ->build()
; ;
@ -89,14 +96,6 @@ final class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchy
public function supports($attribute, $subject) public function supports($attribute, $subject)
{ {
return $this->voter->supports($attribute, $subject); return $this->voter->supports($attribute, $subject);
/*
return ($subject instanceof AbstractTask && in_array($attribute, self::ROLES))
||
($subject instanceof Person && \in_array($attribute, [ self::CREATE, self::SHOW ]))
||
(NULL === $subject && $attribute === self::SHOW )
;
*/
} }
/** /**
@ -132,50 +131,24 @@ final class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchy
// do pre-flight check, relying on other decision manager // do pre-flight check, relying on other decision manager
// those pre-flight check concern associated entities // those pre-flight check concern associated entities
if ($subject instanceof AbstractTask) { if ($subject instanceof AbstractTask) {
// a user can always see his own tasks
if ($subject->getAssignee() === $token->getUser()) {
return true;
}
if (NULL !== $person = $subject->getPerson()) { if (NULL !== $person = $subject->getPerson()) {
if (!$this->accessDecisionManager->decide($token, [PersonVoter::SEE], $person)) { if (!$this->accessDecisionManager->decide($token, [PersonVoter::SEE], $person)) {
return false; return false;
} }
} elseif (false) { } elseif (NULL !== $period = $subject->getCourse()) {
// here will come the test if the task is associated to an accompanying course if (!$this->accessDecisionManager->decide($token, [AccompanyingPeriodVoter::SEE], $period)) {
return false;
}
} }
} }
// do regular check. // do regular check.
return $this->voter->voteOnAttribute($attribute, $subject, $token); return $this->voter->voteOnAttribute($attribute, $subject, $token);
/*
if ($subject instanceof AbstractTask) {
if ($subject->getPerson() === null) {
throw new \LogicException("You should associate a person with task "
. "in order to check autorizations");
}
$person = $subject->getPerson();
} elseif ($subject instanceof Person) {
$person = $subject;
} else {
// subject is null. We check that at least one center is reachable
$centers = $this->authorizationHelper->getReachableCenters($token->getUser(), new Role($attribute));
return count($centers) > 0;
}
if (!$this->accessDecisionManager->decide($token, [PersonVoter::SEE], $person)) {
return false;
}
$center = $this->centerResolverDispatcher->resolveCenter($subject);
if (NULL === $center) {
return false;
}
return $this->authorizationHelper->userHasAccess(
$token->getUser(),
$subject,
$attribute
);
*/
} }
public function getRoles() public function getRoles()

View File

@ -1,4 +1,6 @@
module.exports = function(encore, entries) module.exports = function(encore, entries)
{ {
entries.push(__dirname + '/Resources/public/chill/index.js'); entries.push(__dirname + '/Resources/public/chill/index.js');
encore.addEntry('page_task_list', __dirname + '/Resources/public/page/tile_list/index.js');
}; };

View File

@ -1,11 +1,6 @@
services: services:
Chill\TaskBundle\Controller\: Chill\TaskBundle\Controller\:
resource: '../../Controller' resource: "../../Controller"
tags: ['controller.service_arguments'] autowire: true
autoconfigure: ture
Chill\TaskBundle\Controller\SingleTaskController: tags: ["controller.service_arguments"]
arguments:
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
$timelineBuilder: '@chill_main.timeline_builder'
$logger: '@chill.main.logger'
tags: ['controller.service_arguments']

View File

@ -1,4 +1,9 @@
services: services:
Chill\TaskBundle\Form\:
resource: '../../Form/'
autowire: true
autoconfigure: true
Chill\TaskBundle\Form\SingleTaskListType: Chill\TaskBundle\Form\SingleTaskListType:
arguments: arguments:
$em: '@Doctrine\ORM\EntityManagerInterface' $em: '@Doctrine\ORM\EntityManagerInterface'

View File

@ -1,23 +1,22 @@
services: services:
Chill\TaskBundle\Menu\UserMenuBuilder: Chill\TaskBundle\Menu\UserMenuBuilder:
arguments: arguments:
$tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface' $tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'
$counter: '@Chill\TaskBundle\Templating\UI\CountNotificationTask' $counter: '@Chill\TaskBundle\Templating\UI\CountNotificationTask'
$translator: '@Symfony\Component\Translation\TranslatorInterface' $translator: '@Symfony\Component\Translation\TranslatorInterface'
$authorizationChecker: '@Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface' $authorizationChecker: '@Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface'
tags: tags:
- { name: 'chill.menu_builder' } - { name: "chill.menu_builder" }
Chill\TaskBundle\Menu\PersonMenuBuilder: Chill\TaskBundle\Menu\MenuBuilder:
arguments: autowire: true
$authorizationChecker: '@Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface' autoconfigure: true
$translator: '@Symfony\Component\Translation\TranslatorInterface' tags:
tags: - { name: "chill.menu_builder" }
- { name: 'chill.menu_builder' }
Chill\TaskBundle\Menu\SectionMenuBuilder:
Chill\TaskBundle\Menu\SectionMenuBuilder: arguments:
arguments: $authorizationChecker: '@Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface'
$authorizationChecker: '@Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface' $translator: '@Symfony\Component\Translation\TranslatorInterface'
$translator: '@Symfony\Component\Translation\TranslatorInterface' tags:
tags: - { name: "chill.menu_builder" }
- { name: 'chill.menu_builder' }

View File

@ -9,3 +9,9 @@ services:
arguments: arguments:
- "@chill.main.security.authorization.helper" - "@chill.main.security.authorization.helper"
Chill\TaskBundle\Repository\SingleTaskRepository: '@chill_task.single_task_repository' Chill\TaskBundle\Repository\SingleTaskRepository: '@chill_task.single_task_repository'
Chill\TaskBundle\Repository\SingleTaskAclAwareRepository:
autowire: true
autoconfigure: true
Chill\TaskBundle\Repository\SingleTaskAclAwareRepositoryInterface: '@Chill\TaskBundle\Repository\SingleTaskAclAwareRepository'

View File

@ -0,0 +1,38 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\Task;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210909153533 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE chill_task.recurring_task ADD course_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE chill_task.recurring_task ADD CONSTRAINT FK_9F663B90591CC992 FOREIGN KEY (course_id) REFERENCES chill_person_accompanying_period (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX IDX_9F663B90591CC992 ON chill_task.recurring_task (course_id)');
$this->addSql('ALTER TABLE chill_task.single_task ADD course_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE chill_task.single_task ADD CONSTRAINT FK_194CB3D8591CC992 FOREIGN KEY (course_id) REFERENCES chill_person_accompanying_period (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX IDX_194CB3D8591CC992 ON chill_task.single_task (course_id)');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE chill_task.recurring_task DROP CONSTRAINT FK_9F663B90591CC992');
$this->addSql('ALTER TABLE chill_task.recurring_task DROP course_id');
$this->addSql('ALTER TABLE chill_task.single_task DROP CONSTRAINT FK_194CB3D8591CC992');
$this->addSql('ALTER TABLE chill_task.single_task DROP course_id');
}
}

View File

@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\Task;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20211029213909 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add index for task state and end date';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE INDEX by_end_date ON chill_task.single_task (end_date DESC NULLS FIRST)');
}
public function down(Schema $schema): void
{
$this->addSql('DROP INDEX chill_task.by_end_date');
}
}

View File

@ -1,53 +1,55 @@
Tasks: 'Tâches' 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
Description: Description 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 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 avant 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": ""
Task: Tâche Task: Tâche
Details: Détails Details: Détails
Person: Personne Person: Personne
Date: Date Date: Date
Dates: Dates Dates: Dates
User: Utilisateur User: Utilisateur
'Task list': 'Liste des tâches' "Task list": "Liste des tâches"
'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 "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"
'Task end date': "Date d'échéance" "Task end date": "Date d'échéance"
'Start': 'Début' "Start": "Début"
'Warning': 'Avertissement' "Warning": "Avertissement"
'End': 'Échéance' "End": "Échéance"
'Task type': 'Type' "Task type": "Type"
'Task status': 'Statut' "Task status": "Statut"
'Edit the task': 'Modifier la tâche' "Edit the task": "Modifier la tâche"
'Edit task': 'Modifier la tâche' "Edit task": "Modifier la tâche"
'Save task': 'Enregistrer la tâche' "Save task": "Enregistrer la tâche"
'View the task': 'Voir la tâche' "View the task": "Voir la tâche"
'Update the task': 'Mettre à jour la tâche' "Update the task": "Mettre à jour la tâche"
'Remove task': 'Supprimer la tâche' "Remove task": "Supprimer la tâche"
'Delete': 'Supprimer' "Delete": "Supprimer"
'Change task status': 'Changer le statut' "Change task status": "Changer le statut"
'Are you sure you want to remove the task about "%name%" ?': 'Êtes-vous sûr·e de vouloir supprimer la tâche de "%name%"?' 'Are you sure you want to remove the task about "%name%" ?': 'Êtes-vous sûr·e de vouloir supprimer la tâche de "%name%"?'
'See more': 'Voir plus' 'Are you sure you want to remove the task "%title%" ?': 'Êtes-vous sûr·e de vouloir supprimer la tâche "%title%" ?'
'Associated tasks': 'Tâches associées' "See more": "Voir plus"
'My tasks': 'Mes tâches' "Associated tasks": "Tâches associées"
'No description': 'Pas de description' "My tasks": "Mes tâches"
'No dates specified': 'Dates non spécifiées' "Tasks for this accompanying period": "Tâches pour ce parcours d'accompagnement"
'No one assignee': 'Aucune personne assignée' "No description": "Pas de description"
'Task types': Types de tâches "No dates specified": "Dates non spécifiées"
"No one assignee": "Aucune personne assignée"
"Task types": Types de tâches
Days: Jour(s) Days: Jour(s)
Weeks: Semaine(s) Weeks: Semaine(s)
Months: Mois Months: Mois
@ -61,38 +63,43 @@ Default task: Tâche par défaut
Not assigned: Aucun utilisateur assigné Not assigned: Aucun utilisateur assigné
For person: Pour For person: Pour
By: Par By: Par
Any tasks: Aucune tâche
# transitions - default task definition # transitions - default task definition
'new': 'nouvelle' "new": "nouvelle"
'in_progress': 'en cours' "in_progress": "en cours"
'closed': 'fermée' "closed": "fermée"
'canceled': 'supprimée' "canceled": "supprimée"
start: démarrer start: démarrer
close: clotûrer close: clotûrer
cancel: annuler cancel: annuler
Start_verb: Démarrer Start_verb: Démarrer
Close_verb: Clotûrer Close_verb: Clotûrer
Set this task to cancel state: Marquer cette tâche comme annulée Set this task to cancel state: Marquer cette tâche comme annulée
'%user% has closed the task': '%user% a fermé la tâche' "%user% has closed the task": "%user% a fermé la tâche"
'%user% has canceled the task': '%user% a annulé la tâche' "%user% has canceled the task": "%user% a annulé la tâche"
'%user% has started the task': '%user% a commencé la tâche' "%user% has started the task": "%user% a commencé la tâche"
'%user% has created the task': '%user% a introduit la tâche' "%user% has created the task": "%user% a introduit la tâche"
Are you sure you want to close this task ?: Êtes-vous sûrs de vouloir clotûrer cette tâche ? Are you sure you want to close this task ?: Êtes-vous sûrs de vouloir clotûrer cette tâche ?
Are you sure you want to cancel this task ?: Êtes-vous sûrs de vouloir annuler cette tâche ? Are you sure you want to cancel this task ?: Êtes-vous sûrs de vouloir annuler cette tâche ?
Are you sure you want to start this task ?: Êtes-vous sûrs de vouloir démarrer cette tâche ? Are you sure you want to start this task ?: Êtes-vous sûrs de vouloir démarrer cette tâche ?
#Flash messages #Flash messages
'The task is created': 'La tâche a été créée' "The task is created": "La tâche a été créée"
'There is no tasks.': Aucune tâche. "There is no tasks.": Aucune tâche.
'The task has been successfully removed.': 'La tâche a bien été supprimée' "The task has been successfully removed.": "La tâche a bien été supprimée"
'This form contains errors': 'Ce formulaire contient des erreurs' "This form contains errors": "Ce formulaire contient des erreurs"
'The task has been updated': 'La tâche a été mise à jour' "The task has been updated": "La tâche a été mise à jour"
'The transition is successfully applied': 'La transition a bien été effectuée' "The transition is successfully applied": "La transition a bien été effectuée"
'The transition could not be applied': "La transition n'a pas pu être appliquée" "The transition could not be applied": "La transition n'a pas pu être appliquée"
#widget #widget
'%number% tasks over deadline': '{0} Aucune tâche dépassée|{1} Une tâche dépassée | ]1,Inf[ %count% tâches dépassées' "%number% tasks over deadline": "{0} Aucune tâche dépassée|{1} Une tâche dépassée | ]1,Inf[ %count% tâches dépassées"
'%number% tasks near deadline': '{0} Aucune tâche en rappel|{1} Une tâche en rappel | ]1,Inf[ %count% tâches en rappel' "%number% tasks near deadline": "{0} Aucune tâche en rappel|{1} Une tâche en rappel | ]1,Inf[ %count% tâches en rappel"
Tasks near deadline: Tâches à échéance proche
Tasks over deadline: Tâches à échéance dépassée
Tasks without alert: Tâches à échéance future ou sans échéance
#title #title
My tasks near deadline: Mes tâches à échéance proche My tasks near deadline: Mes tâches à échéance proche
@ -107,4 +114,4 @@ All centers: Tous les centres
CHILL_TASK_TASK_CREATE: Ajouter une tâche CHILL_TASK_TASK_CREATE: Ajouter une tâche
CHILL_TASK_TASK_DELETE: Supprimer une tâche CHILL_TASK_TASK_DELETE: Supprimer une tâche
CHILL_TASK_TASK_SHOW: Voir une tâche CHILL_TASK_TASK_SHOW: Voir une tâche
CHILL_TASK_TASK_UPDATE: Modifier une tâche CHILL_TASK_TASK_UPDATE: Modifier une tâche