From f2ae183682b7fc9de3972c0fafdba912e8da40aa Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 25 Mar 2022 13:01:33 +0100 Subject: [PATCH 01/60] first commit --- .../ReassignAccompanyingPeriodController.php | 19 +++++++++++++-- .../reassign_list.html.twig | 24 +++++++++++++++++-- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php index 4abf5e93c..eb8dcc70e 100644 --- a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php @@ -19,6 +19,7 @@ use Chill\PersonBundle\Repository\AccompanyingPeriodACLAwareRepositoryInterface; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Form\Extension\Core\Type\FormType; +use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\Request; @@ -64,7 +65,9 @@ class ReassignAccompanyingPeriodController extends AbstractController throw new AccessDeniedException(); } - $form = $this->buildFilterForm(); + $periodIds = []; + + $form = $this->buildFilterForm($periodIds); $form->handleRequest($request); @@ -80,16 +83,25 @@ class ReassignAccompanyingPeriodController extends AbstractController $paginator->getCurrentPageFirstItemNumber() ); + foreach ($periods as $period) { + $periodIds[] = $period->getId(); + } + + $assignForm= $this->buildFilterForm($periodIds); + + dump($assignForm->get('periods')); + return new Response( $this->engine->render('@ChillPerson/AccompanyingPeriod/reassign_list.html.twig', [ 'paginator' => $paginator, 'periods' => $periods, 'form' => $form->createView(), + 'assignForm' => $assignForm->createView() ]) ); } - private function buildFilterForm(): FormInterface + private function buildFilterForm(array $periodIds): FormInterface { $data = [ 'user' => null, @@ -107,6 +119,9 @@ class ReassignAccompanyingPeriodController extends AbstractController 'multiple' => false, 'label' => 'User', 'required' => false, + ]) + ->add('periods', HiddenType::class, [ + 'data' => serialize($periodIds), ]); return $builder->getForm(); diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig index 87166d990..2b36a175f 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig @@ -14,7 +14,7 @@ {% if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_UPDATE', period) %}
{% set job_id = null %} - {% if period.job is defined %} + {% if period.job is defined and period.job is not null %} {% set job_id = period.job.id %} {% endif %}
  • {{ form_end(form) }} +
    +

    {{ 'Attribute all parcours in this list to the following users,'|trans }}

    + {{ form_start(assignForm) }} +
    +
    + {{ form_label(assignForm.user ) }} + {{ form_widget(assignForm.user, {'attr': {'class': 'select2'}}) }} +
    +
    + +
      +
    • + +
    • +
    + {{ form_end(assignForm) }} +
    + {% if form.user.vars.value is empty %}

    {{ 'period_by_user_list.Pick a user'|trans }}

    {% elseif periods|length == 0 and form.user.vars.value is not empty %} From 58f1984c7770bac5d51ee7d4b17635dd5047ffc9 Mon Sep 17 00:00:00 2001 From: nobohan Date: Fri, 25 Mar 2022 15:14:13 +0100 Subject: [PATCH 02/60] Add new fields to AddressReference for update procedure --- .../Entity/AddressReference.php | 55 +++++++++++++++++++ .../migrations/Version20220325134944.php | 43 +++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 src/Bundle/ChillMainBundle/migrations/Version20220325134944.php diff --git a/src/Bundle/ChillMainBundle/Entity/AddressReference.php b/src/Bundle/ChillMainBundle/Entity/AddressReference.php index a9d421fcb..fe132f883 100644 --- a/src/Bundle/ChillMainBundle/Entity/AddressReference.php +++ b/src/Bundle/ChillMainBundle/Entity/AddressReference.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\MainBundle\Entity; use Chill\MainBundle\Doctrine\Model\Point; +use DateTimeImmutable; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Serializer\Annotation\Groups; @@ -33,6 +34,18 @@ class AddressReference */ private string $addressCanonical = ''; + /** + * @ORM\Column(type="datetime_immutable", nullable=true) + * @groups({"read"}) + */ + private ?DateTimeImmutable $createdAt = null; + + /** + * @ORM\Column(type="datetime_immutable", nullable=true) + * @groups({"read"}) + */ + private ?DateTimeImmutable $deletedAt = null; + /** * @ORM\Id * @ORM\GeneratedValue @@ -89,6 +102,22 @@ class AddressReference */ private $streetNumber; + /** + * @ORM\Column(type="datetime_immutable", nullable=true) + * @groups({"read"}) + */ + private ?DateTimeImmutable $updatedAt = null; + + public function getCreatedAt(): ?DateTimeImmutable + { + return $this->createdAt; + } + + public function getDeletedAt(): ?DateTimeImmutable + { + return $this->deletedAt; + } + public function getId(): ?int { return $this->id; @@ -134,6 +163,25 @@ class AddressReference return $this->streetNumber; } + public function getUpdatedAt(): ?DateTimeImmutable + { + return $this->updatedAt; + } + + public function setCreatedAt(?DateTimeImmutable $createdAt): self + { + $this->createdAt = $createdAt; + + return $this; + } + + public function setDeletedAt(?DateTimeImmutable $deletedAt): self + { + $this->deletedAt = $deletedAt; + + return $this; + } + public function setMunicipalityCode(?string $municipalityCode): self { $this->municipalityCode = $municipalityCode; @@ -189,4 +237,11 @@ class AddressReference return $this; } + + public function setUpdatedAt(?DateTimeImmutable $updatedAt): self + { + $this->updatedAt = $updatedAt; + + return $this; + } } diff --git a/src/Bundle/ChillMainBundle/migrations/Version20220325134944.php b/src/Bundle/ChillMainBundle/migrations/Version20220325134944.php new file mode 100644 index 000000000..bc0382482 --- /dev/null +++ b/src/Bundle/ChillMainBundle/migrations/Version20220325134944.php @@ -0,0 +1,43 @@ +addSql('ALTER TABLE chill_main_address_reference DROP createdAt'); + $this->addSql('ALTER TABLE chill_main_address_reference DROP deletedAt'); + $this->addSql('ALTER TABLE chill_main_address_reference DROP updatedAt'); + } + + public function getDescription(): string + { + return 'Add 3 fields on AddressReference'; + } + + public function up(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_main_address_reference ADD createdAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_main_address_reference ADD deletedAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_main_address_reference ADD updatedAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL'); + $this->addSql('COMMENT ON COLUMN chill_main_address_reference.createdAt IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN chill_main_address_reference.deletedAt IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN chill_main_address_reference.updatedAt IS \'(DC2Type:datetime_immutable)\''); + } +} From 79630765055d2aa8cca508ce438f4d84435a6c27 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 25 Mar 2022 16:59:05 +0100 Subject: [PATCH 03/60] attempts to submit reassign form --- .../ReassignAccompanyingPeriodController.php | 127 ++++++++++++++++-- .../reassign_list.html.twig | 48 ++++--- 2 files changed, 143 insertions(+), 32 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php index eb8dcc70e..05dd70cb4 100644 --- a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php @@ -16,10 +16,12 @@ use Chill\MainBundle\Pagination\PaginatorFactory; use Chill\MainBundle\Repository\UserRepository; use Chill\MainBundle\Templating\Entity\UserRender; use Chill\PersonBundle\Repository\AccompanyingPeriodACLAwareRepositoryInterface; +use Chill\PersonBundle\Repository\AccompanyingPeriodRepository; +use Doctrine\ORM\EntityManagerInterface; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\FormType; -use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\Request; @@ -45,7 +47,21 @@ class ReassignAccompanyingPeriodController extends AbstractController private UserRepository $userRepository; - public function __construct(AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository, UserRepository $userRepository, EngineInterface $engine, FormFactoryInterface $formFactory, PaginatorFactory $paginatorFactory, Security $security, UserRender $userRender) + private AccompanyingPeriodRepository $courseRepository; + + private EntityManagerInterface $em; + + public function __construct( + AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository, + UserRepository $userRepository, + AccompanyingPeriodRepository $courseRepository, + EngineInterface $engine, + FormFactoryInterface $formFactory, + PaginatorFactory $paginatorFactory, + Security $security, + UserRender $userRender, + EntityManagerInterface $em + ) { $this->accompanyingPeriodACLAwareRepository = $accompanyingPeriodACLAwareRepository; $this->engine = $engine; @@ -54,6 +70,8 @@ class ReassignAccompanyingPeriodController extends AbstractController $this->security = $security; $this->userRepository = $userRepository; $this->userRender = $userRender; + $this->courseRepository = $courseRepository; + $this->em = $em; } /** @@ -65,9 +83,7 @@ class ReassignAccompanyingPeriodController extends AbstractController throw new AccessDeniedException(); } - $periodIds = []; - - $form = $this->buildFilterForm($periodIds); + $form = $this->buildFilterForm(); $form->handleRequest($request); @@ -83,14 +99,66 @@ class ReassignAccompanyingPeriodController extends AbstractController $paginator->getCurrentPageFirstItemNumber() ); - foreach ($periods as $period) { - $periodIds[] = $period->getId(); + // foreach ($periods as $period) { + // $periodIds[] = $period->getId(); + // } + + // $assignForm= $this->buildReassignForm($periods); + $assignData = []; + $assignForm = $this->createFormBuilder($assignData) + ->add('periods', ChoiceType::class, [ + // 'data' => serialize($periods), + 'choices' => $periods, + 'multiple' => true, + 'expanded' => true + ]) + ->add('user', EntityType::class, [ + 'class' => User::class, + 'choices' => $this->userRepository->findByActive(['username' => 'ASC']), + 'choice_label' => function (User $u) { + return $this->userRender->renderString($u, []); + }, + 'placeholder' => 'Choose a user to reassign to', + 'multiple' => false, + 'label' => 'User', + 'required' => true, + ]) + ->getForm(); + + $assignForm->handleRequest($request); + + if ($assignForm->isSubmitted()) { + + $periods = $assignForm->get('periods')->getData(); + $userAssign = $assignForm->get('user')->getData(); + + foreach($periods as $periodId) { + $reassignPeriod = $this->courseRepository->find($periodId); + $reassignPeriod->setUser($userAssign); + $this->em->persist($reassignPeriod); + } + + $this->em->flush(); + + $remainingPeriods = $this->accompanyingPeriodACLAwareRepository + ->findByUserOpenedAccompanyingPeriod( + $form['user']->getData(), + ['openingDate' => 'ASC'], + $paginator->getItemsPerPage(), + $paginator->getCurrentPageFirstItemNumber() + ); + + return new Response( + $this->engine->render('@ChillPerson/AccompanyingPeriod/reassign_list.html.twig', [ + 'paginator' => $paginator, + 'periods' => $remainingPeriods, + 'form' => $form->createView(), + 'assignForm' => $assignForm->createView() + ]) + ); + } - $assignForm= $this->buildFilterForm($periodIds); - - dump($assignForm->get('periods')); - return new Response( $this->engine->render('@ChillPerson/AccompanyingPeriod/reassign_list.html.twig', [ 'paginator' => $paginator, @@ -101,7 +169,7 @@ class ReassignAccompanyingPeriodController extends AbstractController ); } - private function buildFilterForm(array $periodIds): FormInterface + private function buildFilterForm(): FormInterface { $data = [ 'user' => null, @@ -119,9 +187,40 @@ class ReassignAccompanyingPeriodController extends AbstractController 'multiple' => false, 'label' => 'User', 'required' => false, + ]); + // ->add('periods', HiddenType::class, [ + // 'data' => serialize($periodIds), + // ]); + + return $builder->getForm(); + } + + private function buildReassignForm(array $periods): FormInterface + { + $defaultData = [ + 'user' => [], + 'periods' => $periods + ]; + + $builder = $this->formFactory->createBuilder(FormType::class, $defaultData, ['csrf_protection' => false, ]); + + $builder + ->add('periods', ChoiceType::class, [ + // 'data' => serialize($periods), + 'choices' => $periods, + 'multiple' => true, + 'expanded' => true ]) - ->add('periods', HiddenType::class, [ - 'data' => serialize($periodIds), + ->add('user', EntityType::class, [ + 'class' => User::class, + 'choices' => $this->userRepository->findByActive(['username' => 'ASC']), + 'choice_label' => function (User $u) { + return $this->userRender->renderString($u, []); + }, + 'placeholder' => 'Choose a user to reassign to', + 'multiple' => false, + 'label' => 'User', + 'required' => true, ]); return $builder->getForm(); diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig index 2b36a175f..201925188 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig @@ -59,15 +59,37 @@ {{ form_end(form) }} -
    -

    {{ 'Attribute all parcours in this list to the following users,'|trans }}

    + {% if form.user.vars.value is empty %} +

    {{ 'period_by_user_list.Pick a user'|trans }}

    + {% elseif periods|length == 0 and form.user.vars.value is not empty %} +

    {{ 'period_by_user_list.Any course or no authorization to see them'|trans }}

    + {% else %} +

    {{ 'Attribute parcours in this list to the following user,'|trans }}

    +

    {{ paginator.totalItems }} parcours à réassigner (calculé ce jour à {{ null|format_time('medium') }})

    + +
    +
    + {{ form_label(assignForm.user ) }} + {{ form_widget(assignForm.user, {'attr': {'class': 'select2'}}) }} +
    +
    + {{ form_start(assignForm) }} -
    -
    - {{ form_label(assignForm.user ) }} - {{ form_widget(assignForm.user, {'attr': {'class': 'select2'}}) }} +
    +
    + {% for choice in assignForm.periods.vars.choices %} +
    + + +
    + {% endfor %}
    + {% do assignForm.periods.setRendered() %}
    • @@ -77,22 +99,12 @@
    {{ form_end(assignForm) }} -
    - - {% if form.user.vars.value is empty %} -

    {{ 'period_by_user_list.Pick a user'|trans }}

    - {% elseif periods|length == 0 and form.user.vars.value is not empty %} -

    {{ 'period_by_user_list.Any course or no authorization to see them'|trans }}

    - - {% else %} -

    {{ paginator.totalItems }} parcours à réassigner (calculé ce jour à {{ null|format_time('medium') }})

    - -
    + {#
    {% for period in periods %} {% include '@ChillPerson/AccompanyingPeriod/_list_item.html.twig' with {'period': period, 'recordAction': m.period_actions(period), 'itemMeta': m.period_meta(period) } %} {% endfor %} -
    +
    #} {% endif %} {{ chill_pagination(paginator) }} From 818370f03723551a2956c64afd7e072783207d0a Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 28 Mar 2022 16:46:39 +0200 Subject: [PATCH 04/60] selected periods are not coming through in POST. Value not valid --- .../ReassignAccompanyingPeriodController.php | 48 ++++++------------- .../reassign_list.html.twig | 23 ++++----- 2 files changed, 26 insertions(+), 45 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php index 05dd70cb4..92097d807 100644 --- a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php @@ -99,38 +99,23 @@ class ReassignAccompanyingPeriodController extends AbstractController $paginator->getCurrentPageFirstItemNumber() ); - // foreach ($periods as $period) { - // $periodIds[] = $period->getId(); - // } + $assignPeriods = []; - // $assignForm= $this->buildReassignForm($periods); - $assignData = []; - $assignForm = $this->createFormBuilder($assignData) - ->add('periods', ChoiceType::class, [ - // 'data' => serialize($periods), - 'choices' => $periods, - 'multiple' => true, - 'expanded' => true - ]) - ->add('user', EntityType::class, [ - 'class' => User::class, - 'choices' => $this->userRepository->findByActive(['username' => 'ASC']), - 'choice_label' => function (User $u) { - return $this->userRender->renderString($u, []); - }, - 'placeholder' => 'Choose a user to reassign to', - 'multiple' => false, - 'label' => 'User', - 'required' => true, - ]) - ->getForm(); + foreach($periods as $period) { + $assignPeriods[$period->getId()] = $period; + } + + $assignForm = $this->buildReassignForm($assignPeriods); $assignForm->handleRequest($request); if ($assignForm->isSubmitted()) { $periods = $assignForm->get('periods')->getData(); - $userAssign = $assignForm->get('user')->getData(); + $userAssign = $assignForm->get('assignUser')->getData(); + + dump($periods); + dump($userAssign); foreach($periods as $periodId) { $reassignPeriod = $this->courseRepository->find($periodId); @@ -188,30 +173,23 @@ class ReassignAccompanyingPeriodController extends AbstractController 'label' => 'User', 'required' => false, ]); - // ->add('periods', HiddenType::class, [ - // 'data' => serialize($periodIds), - // ]); return $builder->getForm(); } private function buildReassignForm(array $periods): FormInterface { - $defaultData = [ - 'user' => [], - 'periods' => $periods - ]; + $defaultData = []; $builder = $this->formFactory->createBuilder(FormType::class, $defaultData, ['csrf_protection' => false, ]); $builder ->add('periods', ChoiceType::class, [ - // 'data' => serialize($periods), 'choices' => $periods, 'multiple' => true, 'expanded' => true ]) - ->add('user', EntityType::class, [ + ->add('assignUser', EntityType::class, [ 'class' => User::class, 'choices' => $this->userRepository->findByActive(['username' => 'ASC']), 'choice_label' => function (User $u) { @@ -223,6 +201,8 @@ class ReassignAccompanyingPeriodController extends AbstractController 'required' => true, ]); + $builder->get('periods')->resetViewTransformers(); + return $builder->getForm(); } } diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig index 201925188..ac03cafee 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig @@ -67,21 +67,22 @@

    {{ 'Attribute parcours in this list to the following user,'|trans }}

    {{ paginator.totalItems }} parcours à réassigner (calculé ce jour à {{ null|format_time('medium') }})

    -
    -
    - {{ form_label(assignForm.user ) }} - {{ form_widget(assignForm.user, {'attr': {'class': 'select2'}}) }} -
    -
    - {{ form_start(assignForm) }} +
    +
    + {{ form_label(assignForm.assignUser ) }} + {{ form_widget(assignForm.assignUser, {'attr': {'class': 'select2'}}) }} +
    +
    +
    + {# {{ dump(assignForm.periods.vars.choices) }} #} {% for choice in assignForm.periods.vars.choices %} -
    - -
    {% endblock %} From c1ec2933e589f74c32487bc1dbade2acd3e59169 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 14 Apr 2022 17:08:44 +0200 Subject: [PATCH 11/60] person: create a new person: add a civility field --- src/Bundle/ChillPersonBundle/Form/CreationPersonType.php | 6 ++++++ .../Resources/views/Person/create.html.twig | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php b/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php index 2aed9df97..22fd0a12d 100644 --- a/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php @@ -15,6 +15,7 @@ use Chill\MainBundle\Form\Event\CustomizeFormEvent; use Chill\MainBundle\Form\Type\ChillDateType; use Chill\MainBundle\Form\Type\ChillPhoneNumberType; use Chill\MainBundle\Form\Type\PickCenterType; +use Chill\MainBundle\Form\Type\PickCivilityType; use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Form\Type\GenderType; @@ -55,6 +56,11 @@ final class CreationPersonType extends AbstractType $builder ->add('firstName') ->add('lastName') + ->add('civility', PickCivilityType::class, [ + 'required' => false, + 'label' => 'Civility', + 'placeholder' => 'choose civility', + ]) ->add('gender', GenderType::class, [ 'required' => true, 'placeholder' => null, ]) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig index 3a9083310..a5c99379f 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig @@ -93,6 +93,8 @@ {{ form_row(form.gender, { 'label' : 'Gender'|trans }) }} + {{ form_row(form.civility, { 'label' : 'Civility'|trans }) }} + {{ form_row(form.birthdate, { 'label' : 'Date of birth'|trans }) }} {{ form_row(form.phonenumber, { 'label' : 'Phonenumber'|trans }) }} From 7a2151f23a7e550d763fbb32cc5f7fd03a6ddb73 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 14 Apr 2022 18:04:36 +0200 Subject: [PATCH 12/60] AddPerson: add civility when creating a person --- .../vuejs/OnTheFly/components/OnTheFly.vue | 3 +- .../Resources/public/vuejs/_api/OnTheFly.js | 8 ++++- .../public/vuejs/_components/AddPersons.vue | 2 +- .../vuejs/_components/OnTheFly/Person.vue | 30 +++++++++++++++++-- .../Resources/public/vuejs/_js/i18n.js | 4 +++ 5 files changed, 41 insertions(+), 6 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue index 669c225dd..5949a1e56 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue @@ -210,7 +210,6 @@ export default { let type = this.type, data = {} ; - switch (type) { case 'person': data = this.$refs.castPerson.$data.person; @@ -238,7 +237,7 @@ export default { if (typeof data.civility !== 'undefined' && null !== data.civility) { data.civility = data.civility !== null ? {type: 'chill_main_civility', id: data.civility.id} : null; } - if (typeof data.civility !== 'undefined' && null !== data.profession) { + if (typeof data.profession !== 'undefined' && null !== data.profession) { data.profession = data.profession !== null ? {type: 'third_party_profession', id: data.profession.id} : null; } // console.log('onthefly data', data); diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/OnTheFly.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/OnTheFly.js index 20ed1c8da..338094122 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/OnTheFly.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/OnTheFly.js @@ -14,8 +14,13 @@ const getPersonAltNames = () => fetch('/api/1.0/person/config/alt_names.json').then(response => { if (response.ok) { return response.json(); } throw Error('Error with request resource response'); - });; + }); +const getCivilities = () => + fetch('/api/1.0/main/civility.json').then(response => { + if (response.ok) { return response.json(); } + throw Error('Error with request resource response'); + }); /* * POST a new person @@ -56,6 +61,7 @@ const patchPerson = (id, body) => { export { getPerson, getPersonAltNames, + getCivilities, postPerson, patchPerson }; diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue index 90505a1e2..47cae34b1 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue @@ -277,7 +277,7 @@ export default { } }, saveFormOnTheFly({ type, data }) { - // console.log('saveFormOnTheFly from addPersons, type', type, ', data', data); + console.log('saveFormOnTheFly from addPersons, type', type, ', data', data); if (type === 'person') { makeFetch('POST', '/api/1.0/person/person.json', data) .then(response => { diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue index e6fa85902..940b4de41 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue @@ -87,6 +87,20 @@
    +
    + + +
    +
    diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/i18n.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/i18n.js index f3ae3a928..cc3f324e8 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/i18n.js +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/i18n.js @@ -11,6 +11,10 @@ const appMessages = { user: 'Utilisateurs', person: 'Usagers', thirdparty: 'Tiers', + modal_title_one: 'Indiquer un ', + user_one: 'Utilisateur', + thirdparty_one: 'Tiers', + person_one: 'Usager', } } } diff --git a/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig index 8bb09623f..1da384920 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig @@ -217,6 +217,7 @@ {% endblock %} {% block pick_entity_dynamic_widget %} + {{ form_help(form)}}
    {% endblock %} diff --git a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php index 5e07bc96d..0729fd90d 100644 --- a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Controller; use Chill\MainBundle\Entity\User; +use Chill\MainBundle\Form\Type\PickUserDynamicType; use Chill\MainBundle\Pagination\PaginatorFactory; use Chill\MainBundle\Repository\UserRepository; use Chill\MainBundle\Templating\Entity\UserRender; @@ -31,7 +32,10 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Security\Core\Exception\AccessDeniedException; use Symfony\Component\Security\Core\Security; +use Symfony\Component\Serializer\SerializerInterface; use Symfony\Component\Templating\EngineInterface; +use Symfony\Component\Validator\Constraints\NotEqualTo; +use Symfony\Component\Validator\Constraints\NotIdenticalTo; use function is_int; class ReassignAccompanyingPeriodController extends AbstractController @@ -129,18 +133,17 @@ class ReassignAccompanyingPeriodController extends AbstractController $this->em->flush(); // redirect to the first page - return $this->redirectToRoute('chill_course_list_reassign', [ - 'form' => ['user' => $userFrom->getId()], - ]); + return $this->redirectToRoute('chill_course_list_reassign', $request->query->all()); } } return new Response( $this->engine->render('@ChillPerson/AccompanyingPeriod/reassign_list.html.twig', [ + 'assignForm' => $assignForm->createView(), + 'form' => $form->createView(), 'paginator' => $paginator, 'periods' => $periods, - 'form' => $form->createView(), - 'assignForm' => $assignForm->createView(), + 'userFrom' => $userFrom, ]) ); } @@ -154,15 +157,11 @@ class ReassignAccompanyingPeriodController extends AbstractController 'method' => 'get', 'csrf_protection' => false, ]); $builder - ->add('user', EntityType::class, [ - 'class' => User::class, // pickUserType or PickDyamicUserType - 'choices' => $this->userRepository->findByActive(['username' => 'ASC']), - 'choice_label' => function (User $u) { - return $this->userRender->renderString($u, []); - }, + ->add('user', PickUserDynamicType::class, [ 'multiple' => false, - 'label' => 'User', + 'label' => 'reassign.Current user', 'required' => false, + 'help' => 'reassign.Choose a user and click on "Filter" to apply', ]); return $builder->getForm(); @@ -173,26 +172,23 @@ class ReassignAccompanyingPeriodController extends AbstractController $defaultData = [ 'userFrom' => $userFrom, 'periods' => json_encode($periodIds), - 'assignTo' => null, ]; - $builder = $this->formFactory->createBuilder(FormType::class, $defaultData); + $builder = $this->formFactory->createNamedBuilder('reassign', FormType::class, $defaultData); + + if (null !== $userFrom) { + $constraints = [new NotIdenticalTo(['value' => $userFrom])]; + } $builder ->add('periods', HiddenType::class) ->add('userFrom', HiddenType::class) - ->add('userTo', EntityType::class, [ - 'class' => User::class, // PickUserType - 'choices' => $this->userRepository->findByActive(['username' => 'ASC']), - 'choice_label' => function (User $u) { - return $this->userRender->renderString($u, []); - }, - 'placeholder' => 'Choose a user to reassign to', + ->add('userTo', PickUserDynamicType::class, [ 'multiple' => false, - 'label' => 'User', + 'label' => 'reassign.Next user', 'required' => true, - // add a constraint: userFrom is not equal to userTo - //'constraints' => NotEqualToh + 'help' => 'reassign.All periods on this list will be reassigned to this user, excepted the one you manually reassigned before', + 'constraints' => $constraints ?? [], ]); $builder->get('userFrom')->addModelTransformer(new CallbackTransformer( diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig index a77693775..63e25efeb 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig @@ -4,10 +4,12 @@ {% block js %} {{ encore_entry_script_tags('mod_set_referrer') }} + {{ encore_entry_script_tags('mod_pickentity_type') }} {% endblock %} {% block css %} {{ encore_entry_link_tags('mod_set_referrer') }} + {{ encore_entry_link_tags('mod_pickentity_type') }} {% endblock %} {% macro period_meta(period) %} @@ -38,61 +40,66 @@ {% import _self as m %} {% block content %} -
    +

    {{ block('title') }}

    - {{ form_start(form) }}
    + {{ form_start(form) }} {{ form_label(form.user ) }} {{ form_widget(form.user, {'attr': {'class': 'select2'}}) }} -
    -
    - -
      -
    • - -
    • -
    - - {{ form_end(form) }} - - {% if form.user.vars.value is empty %} -

    {{ 'period_by_user_list.Pick a user'|trans }}

    - {% elseif periods|length == 0 and form.user.vars.value is not empty %} -

    {{ 'period_by_user_list.Any course or no authorization to see them'|trans }}

    - {% else %} -

    {{ 'Attribute parcours in this list to the following user,'|trans }}

    -

    {{ paginator.totalItems }} parcours à réassigner (calculé ce jour à {{ null|format_time('medium') }})

    - - {{ form_start(assignForm) }} -
    -
    - {{ form_label(assignForm.userTo ) }} - {{ form_widget(assignForm.userTo, {'attr': {'class': 'select2'}}) }} -
    -
    • -
    - {{ form_end(assignForm) }} -
    - {% for period in periods %} - {% include '@ChillPerson/AccompanyingPeriod/_list_item.html.twig' with {'period': period, - 'recordAction': m.period_actions(period), 'itemMeta': m.period_meta(period) } %} - {% endfor %} + {{ form_end(form) }}
    + +
    + {% if userFrom is not null %} +
    + {{ form_start(assignForm) }} + {{ form_label(assignForm.userTo ) }} + {{ form_widget(assignForm.userTo, {'attr': {'class': 'select2'}}) }} +
    +
      +
    • + +
    • +
    + {{ form_end(assignForm) }} + {% else %} +
    {{ 'reassign.List periods to be able to reassign them'|trans }}
    + {% endif %} + +
    +
    + + {% if userFrom is not null %} +

    {{ paginator.totalItems }} parcours à réassigner (calculé ce jour à {{ null|format_time('medium') }})

    {% endif %} - {% if paginator is defined %} - {{ chill_pagination(paginator) }} - {% endif %} +
    + {% for period in periods %} + {% include '@ChillPerson/AccompanyingPeriod/_list_item.html.twig' with {'period': period, + 'recordAction': m.period_actions(period), 'itemMeta': m.period_meta(period) } %} + {% else %} + {% if userFrom is same as(null) %} +

    {{ 'period_by_user_list.Pick a user'|trans }}

    + {% else %} +

    {{ 'period_by_user_list.Any course or no authorization to see them'|trans }}

    + {% endif %} + {% endfor %} +
    + {% if paginator is defined %} + {{ chill_pagination(paginator) }} + {% endif %}
    + {% endblock %} diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 70441965c..5ad18796c 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -596,3 +596,11 @@ period_by_user_list: Period by user: Parcours d'accompagnement par utilisateur Pick a user: Choisissez un utilisateur pour obtenir la liste de ses parcours 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: + Current user: Parcours par 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 + All periods on this list will be reassigned to this user, excepted the one you manually reassigned before: Tous les parcours visibles sur cette page seront assignés à cet utilisateur, sauf ceux que vous aurez assigné à un utilisateur manuellement. + Reassign: Assigner le référent + List periods to be able to reassign them: Choisissez un utilisateur et cliquez sur "Filtrer" pour visualiser ses parcours. Vous pourrez ensuite les réassigner. From 065b10b877bf056e4695bff6dae13ecd14261d98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 2 May 2022 16:22:25 +0200 Subject: [PATCH 47/60] fix somes validation and acompanying period voter --- .../ReassignAccompanyingPeriodController.php | 33 ++++++++++--------- .../Menu/SectionMenuBuilder.php | 10 +++--- .../Authorization/AccompanyingPeriodVoter.php | 31 ++++++++++++----- .../translations/messages.fr.yml | 11 ++++++- 4 files changed, 54 insertions(+), 31 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php index 0729fd90d..c8dc5bb8f 100644 --- a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php @@ -36,6 +36,7 @@ use Symfony\Component\Serializer\SerializerInterface; use Symfony\Component\Templating\EngineInterface; use Symfony\Component\Validator\Constraints\NotEqualTo; use Symfony\Component\Validator\Constraints\NotIdenticalTo; +use Symfony\Component\Validator\Constraints\NotNull; use function is_int; class ReassignAccompanyingPeriodController extends AbstractController @@ -116,25 +117,23 @@ class ReassignAccompanyingPeriodController extends AbstractController $assignForm->handleRequest($request); - if ($assignForm->isSubmitted()) { - if ($assignForm->isSubmitted()) { - $assignPeriodIds = json_decode($assignForm->get('periods')->getData(), true); - $userTo = $assignForm->get('userTo')->getData(); - $userFrom = $assignForm->get('userFrom')->getData(); + if ($assignForm->isSubmitted() && $assignForm->isValid()) { + $assignPeriodIds = json_decode($assignForm->get('periods')->getData(), true); + $userTo = $assignForm->get('userTo')->getData(); + $userFrom = $assignForm->get('userFrom')->getData(); - foreach ($assignPeriodIds as $periodId) { - $period = $this->courseRepository->find($periodId); + foreach ($assignPeriodIds as $periodId) { + $period = $this->courseRepository->find($periodId); - if ($period->getUser() === $userFrom) { - $period->setUser($userTo); - } + if ($period->getUser() === $userFrom) { + $period->setUser($userTo); } - - $this->em->flush(); - - // redirect to the first page - return $this->redirectToRoute('chill_course_list_reassign', $request->query->all()); } + + $this->em->flush(); + + // redirect to the first page + return $this->redirectToRoute('chill_course_list_reassign', $request->query->all()); } return new Response( @@ -178,6 +177,8 @@ class ReassignAccompanyingPeriodController extends AbstractController if (null !== $userFrom) { $constraints = [new NotIdenticalTo(['value' => $userFrom])]; + } else { + $constraints = []; } $builder @@ -188,7 +189,7 @@ class ReassignAccompanyingPeriodController extends AbstractController 'label' => 'reassign.Next user', 'required' => true, '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( diff --git a/src/Bundle/ChillPersonBundle/Menu/SectionMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/SectionMenuBuilder.php index b1d735541..aede2bc6b 100644 --- a/src/Bundle/ChillPersonBundle/Menu/SectionMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/SectionMenuBuilder.php @@ -65,15 +65,15 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface ]); } - // if ($this->authorizationChecker->isGranted(AccompanyingPeriodVoter::REASSIGN_BULK, null)) { - $menu->addChild($this->translator->trans('Accompanying courses of users'), [ + if ($this->authorizationChecker->isGranted(AccompanyingPeriodVoter::REASSIGN_BULK, null)) { + $menu->addChild($this->translator->trans('reassign.Bulk reassign'), [ 'route' => 'chill_course_list_reassign', ]) ->setExtras([ - 'order' => 12, - 'icons' => ['task'], + 'order' => 40, + 'icons' => [], ]); - // } + } } public static function getMenuIds(): array diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php index 0b6fba35f..70acb2ffc 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php @@ -25,6 +25,9 @@ use function in_array; class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface { + /** + * all the roles that are linked to an accompanying period + */ public const ALL = [ self::SEE, self::SEE_DETAILS, @@ -34,7 +37,6 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH self::FULL, self::TOGGLE_CONFIDENTIAL_ALL, self::TOGGLE_INTENSITY, - self::REASSIGN_BULK, self::RE_OPEN_COURSE, ]; @@ -67,6 +69,9 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH */ 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 SEE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_SEE'; @@ -101,7 +106,7 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH $this->security = $security; $this->voterHelper = $voterHelperFactory ->generate(self::class) - ->addCheckFor(null, [self::CREATE]) + ->addCheckFor(null, [self::CREATE, self::REASSIGN_BULK]) ->addCheckFor(AccompanyingPeriod::class, [self::TOGGLE_CONFIDENTIAL, ...self::ALL]) ->addCheckFor(Person::class, [self::SEE]) ->build(); @@ -109,7 +114,16 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH 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 @@ -119,7 +133,7 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH public function getRolesWithoutScope(): array { - return []; + return [self::REASSIGN_BULK]; } protected function supports($attribute, $subject) @@ -169,8 +183,11 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH return true; } + if ($this->voterHelper->voteOnAttribute(self::TOGGLE_CONFIDENTIAL_ALL, $subject, $token)) { + return true; + } + return false; - // return $this->voterHelper->voteOnAttribute(self::TOGGLE_CONFIDENTIAL_ALL, $subject, $token); } if (self::TOGGLE_INTENSITY === $attribute) { @@ -181,10 +198,6 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH return false; } - // if (self::REASSIGN_BULK === $attribute) { - - // } - // if confidential, only the referent can see it if ($subject->isConfidential()) { return $token->getUser() === $subject->getUser(); diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 5ad18796c..c7d492420 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -301,7 +301,15 @@ CHILL_PERSON_CREATE: Ajouter des personnes CHILL_PERSON_STATS: Statistiques sur les personnes CHILL_PERSON_LISTS: Liste des 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 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. reassign: + Bulk reassign: Réassigner les parcours Current user: Parcours par 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 From ee14cd268b9ce8f5691b835e3d1060d0a29cc4ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 2 May 2022 16:44:02 +0200 Subject: [PATCH 48/60] add role to get acl on confidential periods --- .../DependencyInjection/ChillPersonExtension.php | 6 ++++++ .../Security/Authorization/AccompanyingPeriodVoter.php | 10 ++++++++++ .../ChillPersonBundle/translations/messages.fr.yml | 1 + 3 files changed, 17 insertions(+) diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php index 6d2bf6d18..25fc251e5 100644 --- a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php +++ b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php @@ -873,6 +873,12 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac AccompanyingPeriodVoter::EDIT, AccompanyingPeriodVoter::DELETE, ], + AccompanyingPeriodVoter::REASSIGN_BULK => [ + AccompanyingPeriodVoter::CONFIDENTIAL_CRUD, + ], + AccompanyingPeriodVoter::TOGGLE_CONFIDENTIAL => [ + AccompanyingPeriodVoter::CONFIDENTIAL_CRUD, + ], ], ]); } diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php index 70acb2ffc..959ecf2e3 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php @@ -83,6 +83,11 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH */ public const SEE_DETAILS = 'CHILL_PERSON_ACCOMPANYING_PERIOD_SEE_DETAILS'; + /** + * Give the ability to see all confidential courses + */ + public const CONFIDENTIAL_CRUD = 'CHILL_PERSON_ACCOMPANYING_PERIOD_CRUD_CONFIDENTIAL'; + public const TOGGLE_CONFIDENTIAL = 'CHILL_PERSON_ACCOMPANYING_PERIOD_TOGGLE_CONFIDENTIAL'; /** @@ -117,6 +122,7 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH return [ self::SEE, self::SEE_DETAILS, + self::CONFIDENTIAL_CRUD, self::CREATE, self::EDIT, self::DELETE, @@ -200,6 +206,10 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH // if confidential, only the referent can see it if ($subject->isConfidential()) { + if ($this->voterHelper->voteOnAttribute(self::CONFIDENTIAL_CRUD, $subject, $token)) { + return true; + } + return $token->getUser() === $subject->getUser(); } } diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index c7d492420..7a9d05a5e 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -302,6 +302,7 @@ CHILL_PERSON_STATS: Statistiques sur les personnes CHILL_PERSON_LISTS: Liste des personnes CHILL_PERSON_DUPLICATE: Gérer les doublons de personnes CHILL_PERSON_ACCOMPANYING_PERIOD_SEE: Vision simplifiée d'une période d'accompagnement +CHILL_PERSON_ACCOMPANYING_PERIOD_CONFIDENTIAL: Voir et modifier les périodes d'accompagnement confidentielles 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 From 14341b9768240c51a54aa83f9ddad5a32e378ad6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 2 May 2022 16:44:26 +0200 Subject: [PATCH 49/60] fix cs --- .../ReassignAccompanyingPeriodController.php | 3 --- .../Menu/SectionMenuBuilder.php | 14 +++++++------- .../Authorization/AccompanyingPeriodVoter.php | 16 ++++++++-------- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php index c8dc5bb8f..1fd54f14c 100644 --- a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php @@ -19,7 +19,6 @@ use Chill\MainBundle\Templating\Entity\UserRender; use Chill\PersonBundle\Repository\AccompanyingPeriodACLAwareRepositoryInterface; use Chill\PersonBundle\Repository\AccompanyingPeriodRepository; use Doctrine\ORM\EntityManagerInterface; -use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Form\CallbackTransformer; use Symfony\Component\Form\Exception\TransformationFailedException; @@ -32,9 +31,7 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Security\Core\Exception\AccessDeniedException; use Symfony\Component\Security\Core\Security; -use Symfony\Component\Serializer\SerializerInterface; use Symfony\Component\Templating\EngineInterface; -use Symfony\Component\Validator\Constraints\NotEqualTo; use Symfony\Component\Validator\Constraints\NotIdenticalTo; use Symfony\Component\Validator\Constraints\NotNull; use function is_int; diff --git a/src/Bundle/ChillPersonBundle/Menu/SectionMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/SectionMenuBuilder.php index aede2bc6b..722598ef7 100644 --- a/src/Bundle/ChillPersonBundle/Menu/SectionMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/SectionMenuBuilder.php @@ -66,13 +66,13 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface } if ($this->authorizationChecker->isGranted(AccompanyingPeriodVoter::REASSIGN_BULK, null)) { - $menu->addChild($this->translator->trans('reassign.Bulk reassign'), [ - 'route' => 'chill_course_list_reassign', - ]) - ->setExtras([ - 'order' => 40, - 'icons' => [], - ]); + $menu->addChild($this->translator->trans('reassign.Bulk reassign'), [ + 'route' => 'chill_course_list_reassign', + ]) + ->setExtras([ + 'order' => 40, + 'icons' => [], + ]); } } diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php index 959ecf2e3..0859ba7bd 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php @@ -26,7 +26,7 @@ use function in_array; class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface { /** - * all the roles that are linked to an accompanying period + * all the roles that are linked to an accompanying period. */ public const ALL = [ self::SEE, @@ -40,6 +40,11 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH self::RE_OPEN_COURSE, ]; + /** + * Give the ability to see all confidential courses. + */ + public const CONFIDENTIAL_CRUD = 'CHILL_PERSON_ACCOMPANYING_PERIOD_CRUD_CONFIDENTIAL'; + public const CREATE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_CREATE'; /** @@ -70,7 +75,7 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH public const RE_OPEN_COURSE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_REOPEN'; /** - * Allow user to bulk reassign the courses + * Allow user to bulk reassign the courses. */ public const REASSIGN_BULK = 'CHILL_PERSON_ACCOMPANYING_COURSE_REASSIGN_BULK'; @@ -83,11 +88,6 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH */ public const SEE_DETAILS = 'CHILL_PERSON_ACCOMPANYING_PERIOD_SEE_DETAILS'; - /** - * Give the ability to see all confidential courses - */ - public const CONFIDENTIAL_CRUD = 'CHILL_PERSON_ACCOMPANYING_PERIOD_CRUD_CONFIDENTIAL'; - public const TOGGLE_CONFIDENTIAL = 'CHILL_PERSON_ACCOMPANYING_PERIOD_TOGGLE_CONFIDENTIAL'; /** @@ -129,7 +129,7 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH self::FULL, self::TOGGLE_CONFIDENTIAL_ALL, self::REASSIGN_BULK, - ]; + ]; } public function getRolesWithHierarchy(): array From 6abbf9bf216f479483ca5d7230c77d621c05e168 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 6 May 2022 11:43:05 +0200 Subject: [PATCH 50/60] improves create a person with address * validation: must have an address when 'create a form' is checked; * minor improvements --- .../Resources/views/layout.html.twig | 48 ++++++++++--------- .../Controller/PersonController.php | 4 +- .../Entity/Household/HouseholdMember.php | 4 +- .../Form/CreationPersonType.php | 22 +++++++++ .../Resources/views/Person/create.html.twig | 3 +- .../translations/validators.fr.yml | 5 +- 6 files changed, 56 insertions(+), 30 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig b/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig index c11422a1b..f59e0aaff 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig @@ -36,33 +36,35 @@ {# Flash messages ! #} {% if app.session.flashbag.keys()|length > 0 %} -
    +
    +
    + + {% for flashMessage in app.session.flashbag.get('success') %} +
    + {{ flashMessage|raw }} +
    + {% endfor %} + + {% for flashMessage in app.session.flashbag.get('error') %} +
    + {{ flashMessage|raw }} +
    + {% endfor %} + + {% for flashMessage in app.session.flashbag.get('notice') %} +
    + {{ flashMessage|raw }} +
    + {% endfor %} - {% for flashMessage in app.session.flashbag.get('success') %} -
    - {{ flashMessage|raw }}
    - {% endfor %} - - {% for flashMessage in app.session.flashbag.get('error') %} -
    - {{ flashMessage|raw }} -
    - {% endfor %} - - {% for flashMessage in app.session.flashbag.get('notice') %} -
    - {{ flashMessage|raw }} -
    - {% endfor %} - -
    +
    {% endif %} {% block content %} - + {# DISABLED {{ chill_widget('homepage', {} ) }} #} - + {% include '@ChillMain/Homepage/index.html.twig' %} - + {% endblock %}
    diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonController.php b/src/Bundle/ChillPersonBundle/Controller/PersonController.php index ca5de4ef0..a4a29216c 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonController.php @@ -252,7 +252,7 @@ final class PersonController extends AbstractController $this->lastPostDataReset(); $address = $form->get('address')->getData(); - $addressForm = $form->get('addressForm')->getData(); + $addressForm = (bool) $form->get('addressForm')->getData(); if (null !== $address && $addressForm) { $household = new Household(); @@ -271,7 +271,7 @@ final class PersonController extends AbstractController if ($form->get('createHousehold')->isClicked()) { return $this->redirectToRoute('chill_person_household_members_editor', [ 'persons' => [$person->getId()], - 'household' => $household->getId() + 'household' => $household->getId(), ]); } } diff --git a/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdMember.php b/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdMember.php index e738528c9..2de526ee6 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdMember.php +++ b/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdMember.php @@ -35,7 +35,7 @@ class HouseholdMember /** * @ORM\Column(type="date_immutable", nullable=true, options={"default": null}) * @Serializer\Groups({"read", "docgen:read"}) - * @Assert\GreaterThan( + * @Assert\GreaterThanOrEqual( * propertyPath="startDate", * message="household_membership.The end date must be after start date", * groups={"household_memberships"} @@ -202,7 +202,7 @@ class HouseholdMember public function setPosition(?Position $position): self { - if ($this->position instanceof Position) { + if ($this->position instanceof Position && $this->position !== $position) { throw new LogicException('The position is already set. You cannot change ' . 'a position of a membership'); } diff --git a/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php b/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php index 0d854b681..124db26eb 100644 --- a/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Form; +use Chill\MainBundle\Entity\Address; use Chill\MainBundle\Form\Event\CustomizeFormEvent; use Chill\MainBundle\Form\Type\ChillDateType; use Chill\MainBundle\Form\Type\ChillPhoneNumberType; @@ -30,6 +31,8 @@ use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Extension\Core\Type\EmailType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; +use Symfony\Component\Validator\Constraints\Callback; +use Symfony\Component\Validator\Context\ExecutionContextInterface; final class CreationPersonType extends AbstractType { @@ -84,10 +87,12 @@ final class CreationPersonType extends AbstractType 'label' => 'Create a household and add an address', 'required' => false, 'mapped' => false, + 'help' => 'A new household will be created. The person will be member of this household.', ]) ->add('address', PickAddressType::class, [ 'required' => false, 'mapped' => false, + 'label' => false, ]); if ($this->askCenters) { @@ -114,6 +119,9 @@ final class CreationPersonType extends AbstractType { $resolver->setDefaults([ 'data_class' => Person::class, + 'constraints' => [ + new Callback([$this, 'validateCheckedAddress']), + ], ]); } @@ -124,4 +132,18 @@ final class CreationPersonType extends AbstractType { return self::NAME; } + + public function validateCheckedAddress($data, ExecutionContextInterface $context, $payload): void + { + /** @var bool $addressFrom */ + $addressFrom = $context->getObject()->get('addressForm')->getData(); + /** @var ?Address $address */ + $address = $context->getObject()->get('address')->getData(); + + if ($addressFrom && null === $address) { + $context->buildViolation('person_creation.If you want to create an household, an address is required') + ->atPath('addressForm') + ->addViolation(); + } + } } diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig index e3631f119..03bece4d5 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig @@ -111,7 +111,6 @@ {{ form_row(form.addressForm) }}
    -

    {{ 'A new household will be created. The person will be member of this household.'|trans }}

    {{ form_row(form.address) }}
    @@ -148,4 +147,4 @@ {% block css %} {{ encore_entry_link_tags('mod_input_address') }} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/src/Bundle/ChillPersonBundle/translations/validators.fr.yml b/src/Bundle/ChillPersonBundle/translations/validators.fr.yml index b2bc549d7..c9c8d8648 100644 --- a/src/Bundle/ChillPersonBundle/translations/validators.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/validators.fr.yml @@ -65,4 +65,7 @@ The person where the course is located must be associated to the course. Change #relationship relationship: - duplicate: Une relation de filiation existe déjà entre ces 2 personnes \ No newline at end of file + duplicate: Une relation de filiation existe déjà entre ces 2 personnes + +person_creation: + If you want to create an household, an address is required: Pour la création d'un ménage, une adresse est requise From 6c246a0d38aba73dc363f39134fb4e3dfb35028f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 6 May 2022 12:54:01 +0200 Subject: [PATCH 51/60] allow to edit civility in onTheFly --- .../public/vuejs/OnTheFly/components/OnTheFly.vue | 1 + .../components/PersonsAssociated/ParticipationItem.vue | 1 + .../components/Resources/ResourceItem.vue | 1 + .../Resources/public/vuejs/_components/AddPersons.vue | 3 ++- .../public/vuejs/_components/OnTheFly/Person.vue | 6 +++--- .../Serializer/Normalizer/PersonJsonNormalizer.php | 9 ++------- 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue index 5949a1e56..e3991fe2f 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue @@ -213,6 +213,7 @@ export default { switch (type) { case 'person': data = this.$refs.castPerson.$data.person; + console.log('person data are', data); break; case 'thirdparty': diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated/ParticipationItem.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated/ParticipationItem.vue index 1a1a7e26e..ff8aef961 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated/ParticipationItem.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated/ParticipationItem.vue @@ -123,6 +123,7 @@ export default { body.email = payload.data.email; body.altNames = payload.data.altNames; body.gender = payload.data.gender; + body.civility = payload.data.civility; makeFetch('PATCH', `/api/1.0/person/person/${payload.data.id}.json`, body) .then(response => { diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources/ResourceItem.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources/ResourceItem.vue index df2bd0c35..605ab6443 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources/ResourceItem.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources/ResourceItem.vue @@ -150,6 +150,7 @@ export default { body.email = payload.data.email; body.altNames = payload.data.altNames; body.gender = payload.data.gender; + body.civility = payload.data.civility; makeFetch('PATCH', `/api/1.0/person/person/${payload.data.id}.json`, body) .then(response => { diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue index 0d50b368c..f84fc2e1d 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue @@ -303,6 +303,7 @@ export default { 'id': responsePerson.id }, 'start_date': { + // TODO: use date.js methods (low priority) 'datetime': `${new Date().toISOString().split('T')[0]}T00:00:00+02:00` }, 'holder': false, @@ -315,7 +316,7 @@ export default { }, 'composition': null }; - makeFetch('POST', '/api/1.0/person/household/members/move.json', member) + return makeFetch('POST', '/api/1.0/person/household/members/move.json', member) .then(_response => { makeFetch('POST', `/api/1.0/person/household/${responseHousehold.id}/address.json`, address) .then(_response => {}) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue index 27657ff46..5a8708cc3 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue @@ -87,7 +87,7 @@
    -
    +
    Date: Wed, 11 May 2022 19:39:36 +0200 Subject: [PATCH 58/60] fix construction of BadRequestHttpException --- .../Controller/AccompanyingCourseApiController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php index 21db6b00c..d1730d977 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php @@ -247,7 +247,7 @@ final class AccompanyingCourseApiController extends ApiController } if (null === $requestor) { - throw new BadRequestHttpException('Could not find any person or thirdparty', 0, null); + throw new BadRequestHttpException('Could not find any person or thirdparty'); } $accompanyingPeriod->setRequestor($requestor); From 3fb3df9db15dcd621f84cfd57d6ef215160f1a7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 11 May 2022 19:40:28 +0200 Subject: [PATCH 59/60] remove not necessary debug log --- .../Security/Authorization/AccompanyingCourseDocumentVoter.php | 2 -- src/Bundle/ChillTaskBundle/Security/Authorization/TaskVoter.php | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/Bundle/ChillDocStoreBundle/Security/Authorization/AccompanyingCourseDocumentVoter.php b/src/Bundle/ChillDocStoreBundle/Security/Authorization/AccompanyingCourseDocumentVoter.php index 88e701fcf..35fde9b28 100644 --- a/src/Bundle/ChillDocStoreBundle/Security/Authorization/AccompanyingCourseDocumentVoter.php +++ b/src/Bundle/ChillDocStoreBundle/Security/Authorization/AccompanyingCourseDocumentVoter.php @@ -85,8 +85,6 @@ class AccompanyingCourseDocumentVoter extends AbstractChillVoter implements Prov protected function voteOnAttribute($attribute, $subject, TokenInterface $token) { - $this->logger->debug(sprintf('Voting from %s class', self::class)); - if (!$token->getUser() instanceof User) { return false; } diff --git a/src/Bundle/ChillTaskBundle/Security/Authorization/TaskVoter.php b/src/Bundle/ChillTaskBundle/Security/Authorization/TaskVoter.php index 06953a107..1038ac42f 100644 --- a/src/Bundle/ChillTaskBundle/Security/Authorization/TaskVoter.php +++ b/src/Bundle/ChillTaskBundle/Security/Authorization/TaskVoter.php @@ -99,8 +99,6 @@ final class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchy protected function voteOnAttribute($attribute, $subject, TokenInterface $token) { - $this->logger->debug(sprintf('Voting from %s class', self::class)); - if (!$token->getUser() instanceof User) { return false; } From 52dd08e08807322428e772fa75f4682ae2f258dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 13 May 2022 14:51:02 +0200 Subject: [PATCH 60/60] add default attributes for user --- src/Bundle/ChillMainBundle/Entity/User.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Entity/User.php b/src/Bundle/ChillMainBundle/Entity/User.php index 76fd7196d..ad4888d58 100644 --- a/src/Bundle/ChillMainBundle/Entity/User.php +++ b/src/Bundle/ChillMainBundle/Entity/User.php @@ -45,7 +45,7 @@ class User implements AdvancedUserInterface * * @ORM\Column(type="json", nullable=true) */ - private array $attributes; + private array $attributes = []; /** * @ORM\ManyToOne(targetEntity=Location::class)