From b7c0548212b916819325a71f4b2403acd232bbb8 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 16 Dec 2021 10:41:36 +0100 Subject: [PATCH 01/12] Fix style of dropdown menu --- .../Resources/public/chill/scss/record_actions.scss | 1 + .../Resources/public/page/tile_list/task_list.scss | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/record_actions.scss b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/record_actions.scss index 18ebe4a59..928468715 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/record_actions.scss +++ b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/record_actions.scss @@ -35,6 +35,7 @@ ul.record_actions { } ul.dropdown-menu { + z-index: 2000; li { display: block; margin-right: 0; diff --git a/src/Bundle/ChillTaskBundle/Resources/public/page/tile_list/task_list.scss b/src/Bundle/ChillTaskBundle/Resources/public/page/tile_list/task_list.scss index 4c71462d1..12773e276 100644 --- a/src/Bundle/ChillTaskBundle/Resources/public/page/tile_list/task_list.scss +++ b/src/Bundle/ChillTaskBundle/Resources/public/page/tile_list/task_list.scss @@ -21,4 +21,8 @@ text-align: right; } + .column { + list-style: none; + } + } From 8cf08f66d5e39fdfb099472b5f0ac96375232f36 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 16 Dec 2021 10:41:51 +0100 Subject: [PATCH 02/12] Fix bug in singleTaskController --- .../ChillTaskBundle/Controller/SingleTaskController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php index 22513580c..bc4fe9d04 100644 --- a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php @@ -590,8 +590,8 @@ final class SingleTaskController extends AbstractController { $this->denyAccessUnlessGranted(TaskVoter::SHOW, $task); - if ($person = $task->getContext() instanceof Person) { - $event = new PrivacyEvent($person, [ + if ($task->getContext() instanceof Person) { + $event = new PrivacyEvent($task->getContext(), [ 'element_class' => SingleTask::class, 'element_id' => $task->getId(), 'action' => 'show', From 751a418c1f125220f6e37753935d1028d5314be9 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 16 Dec 2021 10:42:02 +0100 Subject: [PATCH 03/12] Update changelog --- CHANGELOG.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67a26b73c..5f5473057 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,10 +11,11 @@ and this project adheres to ## Unreleased -* AddAddress: optimize loading: wait for the user finish typing; -* UserPicker: fix bug with deprecated role -* docgen: add base context + tests -* docgen: add age for person +* [AddAddress]: optimize loading: wait for the user finish typing; +* [UserPicker]: fix bug with deprecated role +* [docgen]: add base context + tests +* [docgen]: add age for person +* [task]: fix dropdown menu style + fix bug in singleTaskController (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/338) ## Test releases From b613a2f49b24dc4cfc542a2ff8acc77ff3b3f68b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 16 Dec 2021 16:57:49 +0100 Subject: [PATCH 04/12] holder: fix when repositionning/moving member on same day * if holder has not the index '0', validator fails. Use the method Collection::first * change constraint to allow a move on household on same day --- CHANGELOG.md | 1 + .../Household/MaxHolderValidator.php | 2 +- .../migrations/Version20211216154008.php | 35 +++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/Bundle/ChillPersonBundle/migrations/Version20211216154008.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f5473057..d2e1a939b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to * [docgen]: add base context + tests * [docgen]: add age for person * [task]: fix dropdown menu style + fix bug in singleTaskController (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/338) +* Household: fix bug when moving person on the same day (see https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/281) ## Test releases diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/Household/MaxHolderValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/Household/MaxHolderValidator.php index c4fad7e41..49a995341 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/Household/MaxHolderValidator.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/Household/MaxHolderValidator.php @@ -29,7 +29,7 @@ class MaxHolderValidator extends ConstraintValidator $covers = new DateRangeCovering( self::MAX_HOLDERS, - $holders[0]->getStartDate()->getTimezone() + $holders->first()->getStartDate()->getTimezone() ); foreach ($holders as $key => $member) { diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20211216154008.php b/src/Bundle/ChillPersonBundle/migrations/Version20211216154008.php new file mode 100644 index 000000000..1cd430055 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/migrations/Version20211216154008.php @@ -0,0 +1,35 @@ +addSql('ALTER TABLE chill_person_household_members DROP CONSTRAINT chill_person_household_members_check'); + $this->addSql('ALTER TABLE chill_person_household_members ADD CONSTRAINT chill_person_household_members_check CHECK (startdate < enddate)'); + } + + public function getDescription(): string + { + return 'Allow a person to be moved into different household on same day'; + } + + public function up(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_person_household_members DROP CONSTRAINT chill_person_household_members_check'); + $this->addSql('ALTER TABLE chill_person_household_members ADD CONSTRAINT chill_person_household_members_check CHECK (startdate <= enddate)'); + } +} From 6296c7a307e3037640f4104ad4db5048f216cb75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 16 Dec 2021 17:00:17 +0100 Subject: [PATCH 05/12] household/address: show date validFrom and validTo when moving Household --- CHANGELOG.md | 1 + .../Resources/views/Household/address_edit.html.twig | 1 + .../Resources/views/Household/addresses.html.twig | 4 +--- .../Resources/views/Household/summary.html.twig | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d2e1a939b..981388fdc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to * [docgen]: add age for person * [task]: fix dropdown menu style + fix bug in singleTaskController (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/338) * Household: fix bug when moving person on the same day (see https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/281) +* Household: show date validFrom and validTo when moving ## Test releases diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Household/address_edit.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Household/address_edit.html.twig index c8342fb07..828f69ef5 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Household/address_edit.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Household/address_edit.html.twig @@ -13,6 +13,7 @@ openPanesInModal: false, stickyActions: true, useValidFrom: true, + useValidTo: true, } %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Household/addresses.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Household/addresses.html.twig index 646463945..2802c62a7 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Household/addresses.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Household/addresses.html.twig @@ -22,10 +22,8 @@ buttonSize: 'btn-lg', buttonText: 'Move household', modalTitle: 'Move household', - } %} - {# useValidFrom: true, - #} + } %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Household/summary.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Household/summary.html.twig index e88e07013..df1e45fce 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Household/summary.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Household/summary.html.twig @@ -38,6 +38,7 @@ buttonText: 'Move household', modalTitle: 'Move household', buttonDisplayText: false, + useValidFrom: true, } %}
  • From 14aab637ebb09d1a45769a44c9ceda484a7c0193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 16 Dec 2021 21:21:40 +0100 Subject: [PATCH 06/12] start to simplify validation groups for person --- .../Controller/PersonController.php | 13 ++++++------- src/Bundle/ChillPersonBundle/Entity/Person.php | 12 +++--------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonController.php b/src/Bundle/ChillPersonBundle/Controller/PersonController.php index 1b79ba867..3f18fe5f6 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonController.php @@ -216,13 +216,12 @@ final class PersonController extends AbstractController ); } - $form = $this->createForm(CreationPersonType::class, $person, [ - 'validation_groups' => ['create'], - ])->add('editPerson', SubmitType::class, [ - 'label' => 'Add the person', - ])->add('createPeriod', SubmitType::class, [ - 'label' => 'Add the person and create an accompanying period', - ]); + $form = $this->createForm(CreationPersonType::class, $person) + ->add('editPerson', SubmitType::class, [ + 'label' => 'Add the person', + ])->add('createPeriod', SubmitType::class, [ + 'label' => 'Add the person and create an accompanying period', + ]); $form->handleRequest($request); diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index 882be10ed..220a8a307 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -153,12 +153,8 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * @var DateTime * * @ORM\Column(type="date", nullable=true) - * @Assert\Date( - * groups={"general", "creation"} - * ) - * @Birthdate( - * groups={"general", "creation"} - * ) + * @Assert\Date + * @Birthdate */ private $birthdate; @@ -241,9 +237,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * @var DateTimeImmutable * * @ORM\Column(type="date_immutable", nullable=true) - * @Assert\Date( - * groups={"general", "creation"} - * ) + * @Assert\Date * @Assert\GreaterThanOrEqual(propertyPath="birthdate") * @Assert\LessThanOrEqual("today") */ From 400ce3ac82f4a63a59487b40498719a440f0cf8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 16 Dec 2021 21:28:53 +0100 Subject: [PATCH 07/12] remove dead code --- .../ChillPersonBundle/Controller/PersonApiController.php | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php index 23f6ec95d..0bf33d688 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php @@ -69,13 +69,4 @@ class PersonApiController extends ApiController return $this->json(array_values($addresses), Response::HTTP_OK, [], ['groups' => ['read']]); } - - protected function createEntity(string $action, Request $request): object - { - return parent::createEntity($action, $request); - // TODO temporary hack to allow creation of person with fake center - /* $centers = $this->authorizationHelper->getReachableCenters($this->getUser(), - new Role(PersonVoter::CREATE)); - $person->setCenter($centers[0]); */ - } } From 06cbe8325c3891272bd3a5818956a67021ccd859 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 16 Dec 2021 21:39:59 +0100 Subject: [PATCH 08/12] fix person validation --- .../Controller/PersonApiController.php | 1 - .../Controller/PersonController.php | 4 +-- .../ChillPersonBundle/Entity/Person.php | 30 ++++--------------- .../ChillPersonBundle/Form/PersonType.php | 4 +-- .../ChillPersonBundle/config/validation.yaml | 2 -- 5 files changed, 10 insertions(+), 31 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php index 0bf33d688..b94e24b0c 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php @@ -20,7 +20,6 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; -use Symfony\Component\Security\Core\Role\Role; use function array_filter; use function array_values; diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonController.php b/src/Bundle/ChillPersonBundle/Controller/PersonController.php index 3f18fe5f6..f810852c0 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonController.php @@ -131,6 +131,8 @@ final class PersonController extends AbstractController ->getFlashBag()->add('error', $this->translator ->trans('This form contains errors')); } elseif ($form->isSubmitted() && $form->isValid()) { + $this->em->flush(); + $this->get('session')->getFlashBag() ->add( 'success', @@ -138,8 +140,6 @@ final class PersonController extends AbstractController ->trans('The person data has been updated') ); - $this->em->flush(); - return $this->redirectToRoute('chill_person_view', [ 'person_id' => $person->getId(), ]); diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index 220a8a307..73b83f246 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -62,9 +62,7 @@ use function in_array; * @DiscriminatorMap(typeProperty="type", mapping={ * "person": Person::class * }) - * @PersonHasCenter( - * groups={"general", "creation"} - * ) + * @PersonHasCenter * @HouseholdMembershipSequential( * groups={"household_memberships"} * ) @@ -250,8 +248,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * * @ORM\Column(type="text", nullable=true) * @Assert\Email( - * checkMX=true, - * groups={"general", "creation"} + * checkMX=true * ) */ private $email = ''; @@ -262,12 +259,9 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * @var string * * @ORM\Column(type="string", length=255) - * @Assert\NotBlank( - * groups={"general", "creation"} - * ) + * @Assert\NotBlank * @Assert\Length( * max=255, - * groups={"general", "creation"} * ) */ private $firstName; @@ -288,9 +282,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * @var string * * @ORM\Column(type="string", length=9, nullable=true) - * @Assert\NotNull( - * groups={"general", "creation"} - * ) + * @Assert\NotNull */ private $gender; @@ -334,12 +326,9 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * @var string * * @ORM\Column(type="string", length=255) - * @Assert\NotBlank( - * groups={"general", "creation"} - * ) + * @Assert\NotBlank * @Assert\Length( * max=255, - * groups={"general", "creation"} * ) */ private $lastName; @@ -367,9 +356,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * @var DateTime * * @ORM\Column(type="date", nullable=true) - * @Assert\Date( - * groups={"general", "creation"} - * ) + * @Assert\Date */ private ?DateTime $maritalStatusDate = null; @@ -388,11 +375,9 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * @ORM\Column(type="text") * @Assert\Regex( * pattern="/^([\+{1}])([0-9\s*]{4,20})$/", - * groups={"general", "creation"} * ) * @PhonenumberConstraint( * type="mobile", - * groups={"general", "creation"} * ) */ private string $mobilenumber = ''; @@ -430,7 +415,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * ) * @Assert\Valid( * traverse=true, - * groups={"general", "creation"} * ) */ private $otherPhoneNumbers; @@ -449,11 +433,9 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * @ORM\Column(type="text") * @Assert\Regex( * pattern="/^([\+{1}])([0-9\s*]{4,20})$/", - * groups={"general", "creation"} * ) * @PhonenumberConstraint( * type="landline", - * groups={"general", "creation"} * ) */ private string $phonenumber = ''; diff --git a/src/Bundle/ChillPersonBundle/Form/PersonType.php b/src/Bundle/ChillPersonBundle/Form/PersonType.php index 99382dec2..bafe21277 100644 --- a/src/Bundle/ChillPersonBundle/Form/PersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/PersonType.php @@ -21,6 +21,7 @@ use Chill\MainBundle\Form\Type\Select2CountryType; use Chill\MainBundle\Form\Type\Select2LanguageType; use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper; +use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\PersonPhone; use Chill\PersonBundle\Form\Type\GenderType; use Chill\PersonBundle\Form\Type\PersonAltNameType; @@ -234,8 +235,7 @@ class PersonType extends AbstractType public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ - 'data_class' => 'Chill\PersonBundle\Entity\Person', - 'validation_groups' => ['general', 'creation'], + 'data_class' => Person::class, ]); $resolver->setRequired([ diff --git a/src/Bundle/ChillPersonBundle/config/validation.yaml b/src/Bundle/ChillPersonBundle/config/validation.yaml index c41513778..192fc60f6 100644 --- a/src/Bundle/ChillPersonBundle/config/validation.yaml +++ b/src/Bundle/ChillPersonBundle/config/validation.yaml @@ -21,8 +21,6 @@ Chill\PersonBundle\Entity\PersonPhone: phonenumber: - Regex: pattern: '/^([\+{1}])([0-9\s*]{4,20})$/' - groups: [ general, creation ] message: 'Invalid phone number: it should begin with the international prefix starting with "+", hold only digits and be smaller than 20 characters. Ex: +33123456789' - Chill\MainBundle\Validation\Constraint\PhonenumberConstraint: type: any - groups: [ general, creation ] From e0bed186b854c57bef2c2545380c3c40eddc3f1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 16 Dec 2021 22:01:35 +0100 Subject: [PATCH 09/12] normalization of date: allow null --- .../Serializer/Normalizer/DateNormalizer.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/DateNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/DateNormalizer.php index 3050ad268..032fa484d 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/DateNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/DateNormalizer.php @@ -17,6 +17,7 @@ use DateTimeInterface; use IntlDateFormatter; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\HttpFoundation\RequestStack; +use Symfony\Component\Serializer\Exception\UnexpectedValueException; use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; use function array_key_exists; @@ -36,15 +37,20 @@ class DateNormalizer implements ContextAwareNormalizerInterface, DenormalizerInt public function denormalize($data, string $type, ?string $format = null, array $context = []) { + if (null === $data) { + return null; + } + switch ($type) { case DateTime::class: return DateTime::createFromFormat(DateTimeInterface::ISO8601, $data['datetime']); case DateTimeInterface::class: case DateTimeImmutable::class: - default: return DateTimeImmutable::createFromFormat(DateTimeInterface::ISO8601, $data['datetime']); } + + throw new UnexpectedValueException(); } public function normalize($date, ?string $format = null, array $context = []) From cdc335372f59a1199addce88704e5225580a50bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 16 Dec 2021 22:02:00 +0100 Subject: [PATCH 10/12] person denormalization: use object to populate if any --- .../Serializer/Normalizer/PersonJsonNormalizer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php index 7049b7c00..98e157712 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php @@ -63,7 +63,7 @@ class PersonJsonNormalizer implements { $person = $this->extractObjectToPopulate($type, $context); - if (array_key_exists('id', $data)) { + if (array_key_exists('id', $data) && null === $person) { $person = $this->repository->find($data['id']); if (null === $person) { From 773aee55348bcf87b82f4cb1708fb2174cc885b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 16 Dec 2021 22:41:37 +0100 Subject: [PATCH 11/12] address reference: add index for refid --- CHANGELOG.md | 1 + .../Entity/AddressReference.php | 4 ++- .../migrations/Version20211216213649.php | 33 +++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/Bundle/ChillMainBundle/migrations/Version20211216213649.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 981388fdc..07b99a923 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to * [task]: fix dropdown menu style + fix bug in singleTaskController (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/338) * Household: fix bug when moving person on the same day (see https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/281) * Household: show date validFrom and validTo when moving +* address reference: add index for refid ## Test releases diff --git a/src/Bundle/ChillMainBundle/Entity/AddressReference.php b/src/Bundle/ChillMainBundle/Entity/AddressReference.php index 99efd391d..a9d421fcb 100644 --- a/src/Bundle/ChillMainBundle/Entity/AddressReference.php +++ b/src/Bundle/ChillMainBundle/Entity/AddressReference.php @@ -17,7 +17,9 @@ use Symfony\Component\Serializer\Annotation\Groups; /** * @ORM\Entity - * @ORM\Table(name="chill_main_address_reference") + * @ORM\Table(name="chill_main_address_reference", indexes={ + * @ORM\Index(name="address_refid", columns={"refId"}, options={"where": "refid != ''"}) + * }) * @ORM\HasLifecycleCallbacks */ class AddressReference diff --git a/src/Bundle/ChillMainBundle/migrations/Version20211216213649.php b/src/Bundle/ChillMainBundle/migrations/Version20211216213649.php new file mode 100644 index 000000000..4e5e4d9d9 --- /dev/null +++ b/src/Bundle/ChillMainBundle/migrations/Version20211216213649.php @@ -0,0 +1,33 @@ +addSql('DROP INDEX address_refid'); + } + + public function getDescription(): string + { + return 'add an index on address reference refid'; + } + + public function up(Schema $schema): void + { + $this->addSql('CREATE INDEX address_refid ON chill_main_address_reference (refId) WHERE refid != \'\''); + } +} From 36890a2256a9e9e6eb6aa4152eda24680ca20dbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 17 Dec 2021 00:33:02 +0100 Subject: [PATCH 12/12] person document: fix use of deprecated role class --- .../Controller/DocumentPersonController.php | 7 +++---- src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php | 2 +- .../Resources/views/PersonDocument/new.html.twig | 6 +++++- src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php b/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php index 25ac9f1bd..5028757bd 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php @@ -24,7 +24,6 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; -use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Translation\TranslatorInterface; /** @@ -100,7 +99,7 @@ class DocumentPersonController extends AbstractController $document, [ 'center' => $document->getCenter(), - 'role' => new Role('CHILL_PERSON_DOCUMENT_UPDATE'), + 'role' => 'CHILL_PERSON_DOCUMENT_UPDATE', ] ); $form->handleRequest($request); @@ -160,7 +159,7 @@ class DocumentPersonController extends AbstractController $reachableScopes = $this->authorizationHelper ->getReachableScopes( $this->getUser(), - new Role(PersonDocumentVoter::SEE), + PersonDocumentVoter::SEE, $person->getCenter() ); @@ -204,7 +203,7 @@ class DocumentPersonController extends AbstractController $form = $this->createForm(PersonDocumentType::class, $document, [ 'center' => $document->getCenter(), - 'role' => new Role('CHILL_PERSON_DOCUMENT_CREATE'), + 'role' => 'CHILL_PERSON_DOCUMENT_CREATE', ]); $form->handleRequest($request); diff --git a/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php b/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php index 474d9d132..86e8d350a 100644 --- a/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php +++ b/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php @@ -93,7 +93,7 @@ class PersonDocumentType extends AbstractType ]); $resolver->setRequired(['role', 'center']) - ->setAllowedTypes('role', [\Symfony\Component\Security\Core\Role\Role::class]) + ->setAllowedTypes('role', ['string']) ->setAllowedTypes('center', [\Chill\MainBundle\Entity\Center::class]); } } diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/new.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/new.html.twig index 73d8cddf5..ad4fcfc81 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/new.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/new.html.twig @@ -32,7 +32,11 @@ {{ form_row(form.title) }} {{ form_row(form.date) }} {{ form_row(form.category) }} - {{ form_row(form.scope) }} + + {% if form.scope is defined %} + {{ form_row(form.scope) }} + {% endif %} + {{ form_row(form.description) }} {{ form_row(form.object, { 'label': 'Document', 'existing': document.object }) }} diff --git a/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php b/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php index 4aa8948ec..0438669b4 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php @@ -80,7 +80,7 @@ class ScopePickerType extends AbstractType { $items = $this->authorizationHelper->getReachableScopes( $this->security->getUser(), - $options['role']->getRole(), + $options['role'] instanceof Role ? $options['role']->getRole() : $options['role'], $options['center'] );