mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-07-01 06:26:15 +00:00
fix somes validation and acompanying period voter
This commit is contained in:
parent
8113fddcb2
commit
065b10b877
@ -36,6 +36,7 @@ use Symfony\Component\Serializer\SerializerInterface;
|
|||||||
use Symfony\Component\Templating\EngineInterface;
|
use Symfony\Component\Templating\EngineInterface;
|
||||||
use Symfony\Component\Validator\Constraints\NotEqualTo;
|
use Symfony\Component\Validator\Constraints\NotEqualTo;
|
||||||
use Symfony\Component\Validator\Constraints\NotIdenticalTo;
|
use Symfony\Component\Validator\Constraints\NotIdenticalTo;
|
||||||
|
use Symfony\Component\Validator\Constraints\NotNull;
|
||||||
use function is_int;
|
use function is_int;
|
||||||
|
|
||||||
class ReassignAccompanyingPeriodController extends AbstractController
|
class ReassignAccompanyingPeriodController extends AbstractController
|
||||||
@ -116,8 +117,7 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
|||||||
|
|
||||||
$assignForm->handleRequest($request);
|
$assignForm->handleRequest($request);
|
||||||
|
|
||||||
if ($assignForm->isSubmitted()) {
|
if ($assignForm->isSubmitted() && $assignForm->isValid()) {
|
||||||
if ($assignForm->isSubmitted()) {
|
|
||||||
$assignPeriodIds = json_decode($assignForm->get('periods')->getData(), true);
|
$assignPeriodIds = json_decode($assignForm->get('periods')->getData(), true);
|
||||||
$userTo = $assignForm->get('userTo')->getData();
|
$userTo = $assignForm->get('userTo')->getData();
|
||||||
$userFrom = $assignForm->get('userFrom')->getData();
|
$userFrom = $assignForm->get('userFrom')->getData();
|
||||||
@ -135,7 +135,6 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
|||||||
// redirect to the first page
|
// redirect to the first page
|
||||||
return $this->redirectToRoute('chill_course_list_reassign', $request->query->all());
|
return $this->redirectToRoute('chill_course_list_reassign', $request->query->all());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return new Response(
|
return new Response(
|
||||||
$this->engine->render('@ChillPerson/AccompanyingPeriod/reassign_list.html.twig', [
|
$this->engine->render('@ChillPerson/AccompanyingPeriod/reassign_list.html.twig', [
|
||||||
@ -178,6 +177,8 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
|||||||
|
|
||||||
if (null !== $userFrom) {
|
if (null !== $userFrom) {
|
||||||
$constraints = [new NotIdenticalTo(['value' => $userFrom])];
|
$constraints = [new NotIdenticalTo(['value' => $userFrom])];
|
||||||
|
} else {
|
||||||
|
$constraints = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$builder
|
$builder
|
||||||
@ -188,7 +189,7 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
|||||||
'label' => 'reassign.Next user',
|
'label' => 'reassign.Next user',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'help' => 'reassign.All periods on this list will be reassigned to this user, excepted the one you manually reassigned before',
|
'help' => 'reassign.All periods on this list will be reassigned to this user, excepted the one you manually reassigned before',
|
||||||
'constraints' => $constraints ?? [],
|
'constraints' => [new NotNull()],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$builder->get('userFrom')->addModelTransformer(new CallbackTransformer(
|
$builder->get('userFrom')->addModelTransformer(new CallbackTransformer(
|
||||||
|
@ -65,15 +65,15 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if ($this->authorizationChecker->isGranted(AccompanyingPeriodVoter::REASSIGN_BULK, null)) {
|
if ($this->authorizationChecker->isGranted(AccompanyingPeriodVoter::REASSIGN_BULK, null)) {
|
||||||
$menu->addChild($this->translator->trans('Accompanying courses of users'), [
|
$menu->addChild($this->translator->trans('reassign.Bulk reassign'), [
|
||||||
'route' => 'chill_course_list_reassign',
|
'route' => 'chill_course_list_reassign',
|
||||||
])
|
])
|
||||||
->setExtras([
|
->setExtras([
|
||||||
'order' => 12,
|
'order' => 40,
|
||||||
'icons' => ['task'],
|
'icons' => [],
|
||||||
]);
|
]);
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getMenuIds(): array
|
public static function getMenuIds(): array
|
||||||
|
@ -25,6 +25,9 @@ use function in_array;
|
|||||||
|
|
||||||
class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface
|
class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* all the roles that are linked to an accompanying period
|
||||||
|
*/
|
||||||
public const ALL = [
|
public const ALL = [
|
||||||
self::SEE,
|
self::SEE,
|
||||||
self::SEE_DETAILS,
|
self::SEE_DETAILS,
|
||||||
@ -34,7 +37,6 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
|
|||||||
self::FULL,
|
self::FULL,
|
||||||
self::TOGGLE_CONFIDENTIAL_ALL,
|
self::TOGGLE_CONFIDENTIAL_ALL,
|
||||||
self::TOGGLE_INTENSITY,
|
self::TOGGLE_INTENSITY,
|
||||||
self::REASSIGN_BULK,
|
|
||||||
self::RE_OPEN_COURSE,
|
self::RE_OPEN_COURSE,
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -67,6 +69,9 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
|
|||||||
*/
|
*/
|
||||||
public const RE_OPEN_COURSE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_REOPEN';
|
public const RE_OPEN_COURSE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_REOPEN';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allow user to bulk reassign the courses
|
||||||
|
*/
|
||||||
public const REASSIGN_BULK = 'CHILL_PERSON_ACCOMPANYING_COURSE_REASSIGN_BULK';
|
public const REASSIGN_BULK = 'CHILL_PERSON_ACCOMPANYING_COURSE_REASSIGN_BULK';
|
||||||
|
|
||||||
public const SEE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_SEE';
|
public const SEE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_SEE';
|
||||||
@ -101,7 +106,7 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
|
|||||||
$this->security = $security;
|
$this->security = $security;
|
||||||
$this->voterHelper = $voterHelperFactory
|
$this->voterHelper = $voterHelperFactory
|
||||||
->generate(self::class)
|
->generate(self::class)
|
||||||
->addCheckFor(null, [self::CREATE])
|
->addCheckFor(null, [self::CREATE, self::REASSIGN_BULK])
|
||||||
->addCheckFor(AccompanyingPeriod::class, [self::TOGGLE_CONFIDENTIAL, ...self::ALL])
|
->addCheckFor(AccompanyingPeriod::class, [self::TOGGLE_CONFIDENTIAL, ...self::ALL])
|
||||||
->addCheckFor(Person::class, [self::SEE])
|
->addCheckFor(Person::class, [self::SEE])
|
||||||
->build();
|
->build();
|
||||||
@ -109,7 +114,16 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
|
|||||||
|
|
||||||
public function getRoles(): array
|
public function getRoles(): array
|
||||||
{
|
{
|
||||||
return self::ALL;
|
return [
|
||||||
|
self::SEE,
|
||||||
|
self::SEE_DETAILS,
|
||||||
|
self::CREATE,
|
||||||
|
self::EDIT,
|
||||||
|
self::DELETE,
|
||||||
|
self::FULL,
|
||||||
|
self::TOGGLE_CONFIDENTIAL_ALL,
|
||||||
|
self::REASSIGN_BULK,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRolesWithHierarchy(): array
|
public function getRolesWithHierarchy(): array
|
||||||
@ -119,7 +133,7 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
|
|||||||
|
|
||||||
public function getRolesWithoutScope(): array
|
public function getRolesWithoutScope(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [self::REASSIGN_BULK];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function supports($attribute, $subject)
|
protected function supports($attribute, $subject)
|
||||||
@ -169,8 +183,11 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->voterHelper->voteOnAttribute(self::TOGGLE_CONFIDENTIAL_ALL, $subject, $token)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
// return $this->voterHelper->voteOnAttribute(self::TOGGLE_CONFIDENTIAL_ALL, $subject, $token);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self::TOGGLE_INTENSITY === $attribute) {
|
if (self::TOGGLE_INTENSITY === $attribute) {
|
||||||
@ -181,10 +198,6 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (self::REASSIGN_BULK === $attribute) {
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if confidential, only the referent can see it
|
// if confidential, only the referent can see it
|
||||||
if ($subject->isConfidential()) {
|
if ($subject->isConfidential()) {
|
||||||
return $token->getUser() === $subject->getUser();
|
return $token->getUser() === $subject->getUser();
|
||||||
|
@ -301,7 +301,15 @@ CHILL_PERSON_CREATE: Ajouter des personnes
|
|||||||
CHILL_PERSON_STATS: Statistiques sur les personnes
|
CHILL_PERSON_STATS: Statistiques sur les personnes
|
||||||
CHILL_PERSON_LISTS: Liste des personnes
|
CHILL_PERSON_LISTS: Liste des personnes
|
||||||
CHILL_PERSON_DUPLICATE: Gérer les doublons de personnes
|
CHILL_PERSON_DUPLICATE: Gérer les doublons de personnes
|
||||||
CHILL_PERSON_ACCOMPANYING_PERIOD_SEE: Voir les périodes d'accompagnement
|
CHILL_PERSON_ACCOMPANYING_PERIOD_SEE: Vision simplifiée d'une période d'accompagnement
|
||||||
|
CHILL_PERSON_ACCOMPANYING_PERIOD_DELETE: Supprimer une période d'accompagnement
|
||||||
|
CHILL_PERSON_ACCOMPANYING_PERIOD_RE_OPEN: Ré-ouvrir un parcours clotûré
|
||||||
|
CHILL_PERSON_ACCOMPANYING_PERIOD_TOGGLE_CONFIDENTIAL_ALL: Modifier la confidentialité de tous les parcours
|
||||||
|
CHILL_PERSON_ACCOMPANYING_PERIOD_CREATE: Créer une période d'accompagnement
|
||||||
|
CHILL_PERSON_ACCOMPANYING_PERIOD_UPDATE: Modifier une période d'accompagnement
|
||||||
|
CHILL_PERSON_ACCOMPANYING_PERIOD_FULL: Voir les détails, créer, supprimer et mettre à jour une période d'accompagnement
|
||||||
|
CHILL_PERSON_ACCOMPANYING_COURSE_REASSIGN_BULK: Réassigner les parcours en lot
|
||||||
|
CHILL_PERSON_ACCOMPANYING_PERIOD_SEE_DETAILS: Voir les détails d'une période d'accompagnement
|
||||||
|
|
||||||
#period
|
#period
|
||||||
Period closed!: Période clôturée!
|
Period closed!: Période clôturée!
|
||||||
@ -598,6 +606,7 @@ period_by_user_list:
|
|||||||
Any course or no authorization to see them: Aucun parcours pour ce référent, ou aucun droit pour visualiser les parcours de ce référent.
|
Any course or no authorization to see them: Aucun parcours pour ce référent, ou aucun droit pour visualiser les parcours de ce référent.
|
||||||
|
|
||||||
reassign:
|
reassign:
|
||||||
|
Bulk reassign: Réassigner les parcours
|
||||||
Current user: Parcours par référent
|
Current user: Parcours par référent
|
||||||
Next user: Nouveau référent
|
Next user: Nouveau référent
|
||||||
Choose a user and click on "Filter" to apply: Choisissez un utilisateur et cliquez sur "Filtrer" pour visualiser ses parcours
|
Choose a user and click on "Filter" to apply: Choisissez un utilisateur et cliquez sur "Filtrer" pour visualiser ses parcours
|
||||||
|
Loading…
x
Reference in New Issue
Block a user