From d163783ed3e4fa6f1d7261cb02ed792d287be7e9 Mon Sep 17 00:00:00 2001 From: nobohan Date: Mon, 28 Feb 2022 11:42:54 +0100 Subject: [PATCH 001/174] Person Document: add a PersonContext class --- .../Service/DocGenerator/PersonContext.php | 214 ++++++++++++++++++ 1 file changed, 214 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php new file mode 100644 index 000000000..2b22d607c --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php @@ -0,0 +1,214 @@ +documentCategoryRepository = $documentCategoryRepository; + $this->normalizer = $normalizer; + $this->translatableStringHelper = $translatableStringHelper; + $this->em = $em; + $this->baseContextData = $baseContextData; + } + + public function adminFormReverseTransform(array $data): array + { + if (array_key_exists('category', $data)) { + $data['category'] = [ + 'idInsideBundle' => $data['category']->getIdInsideBundle(), + 'bundleId' => $data['category']->getBundleId(), + ]; + } + + return $data; + } + + public function adminFormTransform(array $data): array + { + // $r = [ + // 'mainPerson' => $data['mainPerson'] ?? false, + // 'mainPersonLabel' => $data['mainPersonLabel'] ?? $this->translator->trans('docgen.Main person'), + // 'person1' => $data['person1'] ?? false, + // 'person1Label' => $data['person1Label'] ?? $this->translator->trans('docgen.person 1'), + // 'person2' => $data['person2'] ?? false, + // 'person2Label' => $data['person2Label'] ?? $this->translator->trans('docgen.person 2'), + // ]; + + if (array_key_exists('category', $data)) { + $r['category'] = array_key_exists('category', $data) ? + $this->documentCategoryRepository->find($data['category']) : null; + } + + return $r; + } + + public function buildAdminForm(FormBuilderInterface $builder): void + { + $builder + // ->add('mainPerson', CheckboxType::class, [ + // 'required' => false, + // 'label' => 'docgen.Ask for main person', + // ]) + // ->add('mainPersonLabel', TextType::class, [ + // 'label' => 'main person label', + // 'required' => true, + // ]) + // ->add('person1', CheckboxType::class, [ + // 'required' => false, + // 'label' => 'docgen.Ask for person 1', + // ]) + // ->add('person1Label', TextType::class, [ + // 'label' => 'person 1 label', + // 'required' => true, + // ]) + // ->add('person2', CheckboxType::class, [ + // 'required' => false, + // 'label' => 'docgen.Ask for person 2', + // ]) + // ->add('person2Label', TextType::class, [ + // 'label' => 'person 2 label', + // 'required' => true, + // ]) + ->add('category', EntityType::class, [ + 'placeholder' => 'Choose a document category', + 'class' => 'ChillDocStoreBundle:DocumentCategory', + 'query_builder' => static function (EntityRepository $er) { + return $er->createQueryBuilder('c') + ->where('c.documentClass = :docClass') + ->setParameter('docClass', PersonDocument::class); + }, + 'choice_label' => function ($entity = null) { + return $entity ? $this->translatableStringHelper->localize($entity->getName()) : ''; + }, + ]); + } + + public function getData(DocGeneratorTemplate $template, $entity, array $contextGenerationData = []): array + { + if (!$entity instanceof Person) { + throw new UnexpectedTypeException($entity, Person::class); + } + $options = $template->getOptions(); + + $data = []; + $data = array_merge($data, $this->baseContextData->getData()); + $data['person'] = $this->normalizer->normalize($entity, 'docgen', [ + 'docgen:expects' => Person::class, + 'groups' => 'docgen:read' + ]); + + // foreach (['mainPerson', 'person1', 'person2'] as $k) { + // if ($options[$k]) { + // $data[$k] = $this->normalizer->normalize($contextGenerationData[$k], 'docgen', [ + // 'docgen:expects' => Person::class, + // 'groups' => 'docgen:read', + // 'docgen:person:with-household' => true, + // 'docgen:person:with-relations' => true, + // ]); + // } + // } + + return $data; + } + + public function getDescription(): string + { + return 'docgen.A basic context for person'; + } + + public function getEntityClass(): string + { + return Person::class; + } + + public function getFormData(DocGeneratorTemplate $template, $entity): array + { + return [ + 'person' => $entity, + ]; + } + + public static function getKey(): string + { + return self::class; + } + + public function getName(): string + { + return 'docgen.Person basic'; + } + + public function hasAdminForm(): bool + { + return true; + } + + /** + * @param Person $entity + */ + public function storeGenerated(DocGeneratorTemplate $template, StoredObject $storedObject, object $entity, array $contextGenerationData): void + { + $doc = new PersonDocument(); + $doc->setTemplate($template) + ->setTitle($this->translatableStringHelper->localize($template->getName())) + ->setDate(new DateTime()) + ->setDescription($this->translatableStringHelper->localize($template->getName())) + ->setPerson($entity) + ->setObject($storedObject); + + if (array_key_exists('category', $template->getOptions())) { + $doc + ->setCategory( + $this->documentCategoryRepository->find( + $template->getOptions()['category'] + ) + ); + } + + $this->em->persist($doc); + } +} \ No newline at end of file From 7aefa5014c5af9c0437080ef3f117a7041de012a Mon Sep 17 00:00:00 2001 From: nobohan Date: Mon, 28 Feb 2022 12:33:38 +0100 Subject: [PATCH 002/174] Add docgen:read group on Person + 2 fields in PersonContext admin form --- .../ChillPersonBundle/Entity/Person.php | 15 ++++++++ .../Service/DocGenerator/PersonContext.php | 36 ++++++++++--------- .../translations/messages.fr.yml | 2 ++ 3 files changed, 36 insertions(+), 17 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index 49f7ae297..b51b4490c 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -38,6 +38,7 @@ use Doctrine\Common\Collections\Criteria; use Doctrine\ORM\Mapping as ORM; use Exception; use Symfony\Component\Serializer\Annotation\DiscriminatorMap; +use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Context\ExecutionContextInterface; use function count; @@ -152,6 +153,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * * @ORM\Column(type="date", nullable=true) * @Birthdate + * @Groups({"docgen:read"}) */ private $birthdate; @@ -200,6 +202,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * sf4 check: option inversedBy="birthsIn" return error mapping !! * * @ORM\JoinColumn(nullable=true) + * @Groups({"docgen:read"}) */ private $countryOfBirth; @@ -237,6 +240,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * @Assert\Date * @Assert\GreaterThanOrEqual(propertyPath="birthdate") * @Assert\LessThanOrEqual("today") + * @Groups({"docgen:read"}) */ private ?DateTimeImmutable $deathdate = null; @@ -249,6 +253,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * @Assert\Email( * checkMX=true * ) + * @Groups({"docgen:read"}) */ private $email = ''; @@ -262,6 +267,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * @Assert\Length( * max=255, * ) + * @Groups({"docgen:read"}) */ private $firstName; @@ -282,6 +288,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * * @ORM\Column(type="string", length=9, nullable=true) * @Assert\NotNull(message="The gender must be set") + * @Groups({"docgen:read"}) */ private $gender; @@ -339,6 +346,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * * @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\MaritalStatus") * @ORM\JoinColumn(nullable=true) + * @Groups({"docgen:read"}) */ private $maritalStatus; @@ -346,6 +354,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * Comment on marital status. * * @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="maritalStatusComment_") + * @Groups({"docgen:read"}) */ private CommentEmbeddable $maritalStatusComment; @@ -356,6 +365,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * * @ORM\Column(type="date", nullable=true) * @Assert\Date + * @Groups({"docgen:read"}) */ private ?DateTime $maritalStatusDate = null; @@ -378,6 +388,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * @PhonenumberConstraint( * type="mobile", * ) + * @Groups({"docgen:read"}) */ private string $mobilenumber = ''; @@ -391,6 +402,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * sf4 check: option inversedBy="nationals" return error mapping !! * * @ORM\JoinColumn(nullable=true) + * @Groups({"docgen:read"}) */ private $nationality; @@ -400,6 +412,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * @var int * * @ORM\Column(type="integer", nullable=true) + * @Groups({"docgen:read"}) */ private ?int $numberOfChildren = null; @@ -436,6 +449,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * @PhonenumberConstraint( * type="landline", * ) + * @Groups({"docgen:read"}) */ private string $phonenumber = ''; @@ -445,6 +459,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * @var string * * @ORM\Column(type="string", length=255, name="place_of_birth") + * @Groups({"docgen:read"}) */ private $placeOfBirth = ''; diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php index 2b22d607c..30b020728 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php @@ -24,8 +24,11 @@ use DateTime; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Symfony\Bridge\Doctrine\Form\Type\EntityType; +use Symfony\Component\Form\Extension\Core\Type\CheckboxType; +use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; +use Symfony\Contracts\Translation\TranslatorInterface; use function array_key_exists; @@ -41,11 +44,14 @@ class PersonContext implements DocGeneratorContextWithAdminFormInterface private TranslatableStringHelperInterface $translatableStringHelper; + private TranslatorInterface $translator; + public function __construct( DocumentCategoryRepository $documentCategoryRepository, NormalizerInterface $normalizer, TranslatableStringHelperInterface $translatableStringHelper, EntityManagerInterface $em, + TranslatorInterface $translator, BaseContextData $baseContextData ) { $this->documentCategoryRepository = $documentCategoryRepository; @@ -53,6 +59,7 @@ class PersonContext implements DocGeneratorContextWithAdminFormInterface $this->translatableStringHelper = $translatableStringHelper; $this->em = $em; $this->baseContextData = $baseContextData; + $this->translator = $translator; } public function adminFormReverseTransform(array $data): array @@ -69,14 +76,10 @@ class PersonContext implements DocGeneratorContextWithAdminFormInterface public function adminFormTransform(array $data): array { - // $r = [ - // 'mainPerson' => $data['mainPerson'] ?? false, - // 'mainPersonLabel' => $data['mainPersonLabel'] ?? $this->translator->trans('docgen.Main person'), - // 'person1' => $data['person1'] ?? false, - // 'person1Label' => $data['person1Label'] ?? $this->translator->trans('docgen.person 1'), - // 'person2' => $data['person2'] ?? false, - // 'person2Label' => $data['person2Label'] ?? $this->translator->trans('docgen.person 2'), - // ]; + $r = [ + 'mainPerson' => $data['mainPerson'] ?? false, + 'mainPersonLabel' => $data['mainPersonLabel'] ?? $this->translator->trans('docgen.Main person'), + ]; if (array_key_exists('category', $data)) { $r['category'] = array_key_exists('category', $data) ? @@ -89,14 +92,14 @@ class PersonContext implements DocGeneratorContextWithAdminFormInterface public function buildAdminForm(FormBuilderInterface $builder): void { $builder - // ->add('mainPerson', CheckboxType::class, [ - // 'required' => false, - // 'label' => 'docgen.Ask for main person', - // ]) - // ->add('mainPersonLabel', TextType::class, [ - // 'label' => 'main person label', - // 'required' => true, - // ]) + ->add('mainPerson', CheckboxType::class, [ + 'required' => false, + 'label' => 'docgen.Ask for main person', + ]) + ->add('mainPersonLabel', TextType::class, [ + 'label' => 'main person label', + 'required' => true, + ]) // ->add('person1', CheckboxType::class, [ // 'required' => false, // 'label' => 'docgen.Ask for person 1', @@ -140,7 +143,6 @@ class PersonContext implements DocGeneratorContextWithAdminFormInterface 'docgen:expects' => Person::class, 'groups' => 'docgen:read' ]); - // foreach (['mainPerson', 'person1', 'person2'] as $k) { // if ($options[$k]) { // $data[$k] = $this->normalizer->normalize($contextGenerationData[$k], 'docgen', [ diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 3b1aea377..ba990125c 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -541,6 +541,8 @@ docgen: A basic context for accompanying period: Contexte pour les parcours A context for accompanying period work: Contexte pour les actions d'accompagnement A context for accompanying period work evaluation: Contexte pour les évaluations dans les actions d'accompagnement + Person basic: Personne (basique) + A basic context for person: Contexte pour les personnes period_notification: period_designated_subject: Vous êtes référent d'un parcours d'accompagnement From a187bac7b0d008f3e70ee852d234645c51bfb8ec Mon Sep 17 00:00:00 2001 From: nobohan Date: Tue, 1 Mar 2022 15:48:32 +0100 Subject: [PATCH 003/174] DocGeneratorTemplateController: fix in case there is no public form --- .../Controller/DocGeneratorTemplateController.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php b/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php index 2aff33af0..d332f11c2 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php +++ b/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php @@ -207,20 +207,21 @@ final class DocGeneratorTemplateController extends AbstractController $context instanceof DocGeneratorContextWithPublicFormInterface && $context->hasPublicForm($template, $entity) || $isTest ) { - if ($context instanceof DocGeneratorContextWithPublicFormInterface) { + if ($context instanceof DocGeneratorContextWithPublicFormInterface && $context->hasPublicForm($template, $entity)) { $builder = $this->createFormBuilder( array_merge( $context->getFormData($template, $entity), $isTest ? ['test_file' => null] : [] ) ); + + $context->buildPublicForm($builder, $template, $entity); } else { $builder = $this->createFormBuilder( ['test_file' => null] ); } - $context->buildPublicForm($builder, $template, $entity); if ($isTest) { $builder->add('test_file', FileType::class, [ From 88e9a96e0e21eca94e615425b6745c089a5999a2 Mon Sep 17 00:00:00 2001 From: nobohan Date: Tue, 1 Mar 2022 15:51:34 +0100 Subject: [PATCH 004/174] Person document generation: clean build Admin form + add household and relations groups --- .../Service/DocGenerator/PersonContext.php | 39 +------------------ 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php index 30b020728..f84dd83c7 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php @@ -24,8 +24,6 @@ use DateTime; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Symfony\Bridge\Doctrine\Form\Type\EntityType; -use Symfony\Component\Form\Extension\Core\Type\CheckboxType; -use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; use Symfony\Contracts\Translation\TranslatorInterface; @@ -92,30 +90,6 @@ class PersonContext implements DocGeneratorContextWithAdminFormInterface public function buildAdminForm(FormBuilderInterface $builder): void { $builder - ->add('mainPerson', CheckboxType::class, [ - 'required' => false, - 'label' => 'docgen.Ask for main person', - ]) - ->add('mainPersonLabel', TextType::class, [ - 'label' => 'main person label', - 'required' => true, - ]) - // ->add('person1', CheckboxType::class, [ - // 'required' => false, - // 'label' => 'docgen.Ask for person 1', - // ]) - // ->add('person1Label', TextType::class, [ - // 'label' => 'person 1 label', - // 'required' => true, - // ]) - // ->add('person2', CheckboxType::class, [ - // 'required' => false, - // 'label' => 'docgen.Ask for person 2', - // ]) - // ->add('person2Label', TextType::class, [ - // 'label' => 'person 2 label', - // 'required' => true, - // ]) ->add('category', EntityType::class, [ 'placeholder' => 'Choose a document category', 'class' => 'ChillDocStoreBundle:DocumentCategory', @@ -135,24 +109,13 @@ class PersonContext implements DocGeneratorContextWithAdminFormInterface if (!$entity instanceof Person) { throw new UnexpectedTypeException($entity, Person::class); } - $options = $template->getOptions(); $data = []; $data = array_merge($data, $this->baseContextData->getData()); $data['person'] = $this->normalizer->normalize($entity, 'docgen', [ 'docgen:expects' => Person::class, - 'groups' => 'docgen:read' + 'groups' => ['docgen:read', 'docgen:person:with-household', 'docgen:person:with-relations'] ]); - // foreach (['mainPerson', 'person1', 'person2'] as $k) { - // if ($options[$k]) { - // $data[$k] = $this->normalizer->normalize($contextGenerationData[$k], 'docgen', [ - // 'docgen:expects' => Person::class, - // 'groups' => 'docgen:read', - // 'docgen:person:with-household' => true, - // 'docgen:person:with-relations' => true, - // ]); - // } - // } return $data; } From 84478c651e14dd2037518d87ee7ff8b00d2d62eb Mon Sep 17 00:00:00 2001 From: nobohan Date: Tue, 1 Mar 2022 15:54:36 +0100 Subject: [PATCH 005/174] Person: remove useless serialisation groups --- src/Bundle/ChillPersonBundle/Entity/Person.php | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index b51b4490c..49f7ae297 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -38,7 +38,6 @@ use Doctrine\Common\Collections\Criteria; use Doctrine\ORM\Mapping as ORM; use Exception; use Symfony\Component\Serializer\Annotation\DiscriminatorMap; -use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Context\ExecutionContextInterface; use function count; @@ -153,7 +152,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * * @ORM\Column(type="date", nullable=true) * @Birthdate - * @Groups({"docgen:read"}) */ private $birthdate; @@ -202,7 +200,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * sf4 check: option inversedBy="birthsIn" return error mapping !! * * @ORM\JoinColumn(nullable=true) - * @Groups({"docgen:read"}) */ private $countryOfBirth; @@ -240,7 +237,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * @Assert\Date * @Assert\GreaterThanOrEqual(propertyPath="birthdate") * @Assert\LessThanOrEqual("today") - * @Groups({"docgen:read"}) */ private ?DateTimeImmutable $deathdate = null; @@ -253,7 +249,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * @Assert\Email( * checkMX=true * ) - * @Groups({"docgen:read"}) */ private $email = ''; @@ -267,7 +262,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * @Assert\Length( * max=255, * ) - * @Groups({"docgen:read"}) */ private $firstName; @@ -288,7 +282,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * * @ORM\Column(type="string", length=9, nullable=true) * @Assert\NotNull(message="The gender must be set") - * @Groups({"docgen:read"}) */ private $gender; @@ -346,7 +339,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * * @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\MaritalStatus") * @ORM\JoinColumn(nullable=true) - * @Groups({"docgen:read"}) */ private $maritalStatus; @@ -354,7 +346,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * Comment on marital status. * * @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="maritalStatusComment_") - * @Groups({"docgen:read"}) */ private CommentEmbeddable $maritalStatusComment; @@ -365,7 +356,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * * @ORM\Column(type="date", nullable=true) * @Assert\Date - * @Groups({"docgen:read"}) */ private ?DateTime $maritalStatusDate = null; @@ -388,7 +378,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * @PhonenumberConstraint( * type="mobile", * ) - * @Groups({"docgen:read"}) */ private string $mobilenumber = ''; @@ -402,7 +391,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * sf4 check: option inversedBy="nationals" return error mapping !! * * @ORM\JoinColumn(nullable=true) - * @Groups({"docgen:read"}) */ private $nationality; @@ -412,7 +400,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * @var int * * @ORM\Column(type="integer", nullable=true) - * @Groups({"docgen:read"}) */ private ?int $numberOfChildren = null; @@ -449,7 +436,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * @PhonenumberConstraint( * type="landline", * ) - * @Groups({"docgen:read"}) */ private string $phonenumber = ''; @@ -459,7 +445,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * @var string * * @ORM\Column(type="string", length=255, name="place_of_birth") - * @Groups({"docgen:read"}) */ private $placeOfBirth = ''; From d6d7edf25d9067d6faa9928c1f89976e47f0c89f Mon Sep 17 00:00:00 2001 From: nobohan Date: Tue, 1 Mar 2022 16:14:21 +0100 Subject: [PATCH 006/174] Add doc generation for PersonDocument form --- .../Resources/views/PersonDocument/index.html.twig | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/index.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/index.html.twig index b3d2baab6..e63538c22 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/index.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/index.html.twig @@ -26,7 +26,17 @@ {% endblock %} {% block js %} + {{ parent() }} {{ encore_entry_script_tags('mod_async_upload') }} + {{ encore_entry_script_tags('mod_docgen_picktemplate') }} + {{ encore_entry_script_tags('mod_entity_workflow_pick') }} +{% endblock %} + +{% block css %} + {{ parent() }} + {{ encore_entry_link_tags('mod_async_upload') }} + {{ encore_entry_link_tags('mod_docgen_picktemplate') }} + {{ encore_entry_link_tags('mod_entity_workflow_pick') }} {% endblock %} {% block personcontent %} @@ -46,6 +56,8 @@ {{ chill_pagination(pagination) }} +
+ {% if is_granted('CHILL_PERSON_DOCUMENT_CREATE', person) %}
  • From 4406016f823fb01942d297f62bd4a3285d7a1131 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 3 Mar 2022 10:17:16 +0100 Subject: [PATCH 007/174] code fix for PersonContext --- .../Controller/DocGeneratorTemplateController.php | 1 - .../ChillPersonBundle/Service/DocGenerator/PersonContext.php | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php b/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php index d332f11c2..000fcb03a 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php +++ b/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php @@ -222,7 +222,6 @@ final class DocGeneratorTemplateController extends AbstractController ); } - if ($isTest) { $builder->add('test_file', FileType::class, [ 'label' => 'Template file', diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php index f84dd83c7..85ca1c161 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php @@ -114,7 +114,7 @@ class PersonContext implements DocGeneratorContextWithAdminFormInterface $data = array_merge($data, $this->baseContextData->getData()); $data['person'] = $this->normalizer->normalize($entity, 'docgen', [ 'docgen:expects' => Person::class, - 'groups' => ['docgen:read', 'docgen:person:with-household', 'docgen:person:with-relations'] + 'groups' => ['docgen:read', 'docgen:person:with-household', 'docgen:person:with-relations'], ]); return $data; @@ -176,4 +176,4 @@ class PersonContext implements DocGeneratorContextWithAdminFormInterface $this->em->persist($doc); } -} \ No newline at end of file +} From 23fd4be2e54b4b4aab2e8eb23cc7b3cae91fbe72 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 3 Mar 2022 10:17:29 +0100 Subject: [PATCH 008/174] upd CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b38afb37..7168e027f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to ## Unreleased +* [person] Add document generation in admin and in person/{id}/document (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/464) + * [docstore] Add an API entrypoint for StoredObject (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/466) * [person] Add the possibility of uploading existing documents to AccPeriodWorkEvaluationDocument (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/466) * [person] Add title to AccPeriodWorkEvaluationDocument (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/466) From dca17c409b5fd112f1ebe0abc97fb0917db383b5 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 3 Mar 2022 12:03:22 +0100 Subject: [PATCH 009/174] activity: do not override location if already exist (when validating new activity) --- .../Resources/public/vuejs/Activity/store.locations.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.locations.js b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.locations.js index 311bdc219..6125140a5 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.locations.js +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.locations.js @@ -110,10 +110,8 @@ export default function prepareLocations(store) { console.log('default loation id', window.default_location_id); if (window.default_location_id) { for (let group of store.state.availableLocations) { - console.log(group); let location = group.locations.find((l) => l.id === window.default_location_id); - console.log(location); - if (location !== undefined) { + if (location !== undefined & store.state.activity.location === null) { store.dispatch('updateLocation', location); break; } From 1b66941746a3bdbc51daabe9458f07800858a863 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 3 Mar 2022 12:05:55 +0100 Subject: [PATCH 010/174] upd CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bd743078..daf880138 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to ## Unreleased +* [activity] do not override location if already exist (when validating new activity) (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/470) + * [parcours] Toggle emergency/intensity only by referrer (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/442) * [docstore] Add an API entrypoint for StoredObject (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/466) * [person] Add the possibility of uploading existing documents to AccPeriodWorkEvaluationDocument (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/466) From 86bf0115dd9489552448230447e4d3793076f980 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 3 Mar 2022 13:05:01 +0100 Subject: [PATCH 011/174] fix condition when empty phonenumber --- .../ChillMainBundle/Validation/Validator/ValidPhonenumber.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Validation/Validator/ValidPhonenumber.php b/src/Bundle/ChillMainBundle/Validation/Validator/ValidPhonenumber.php index 9620f7cb9..267b2a70b 100644 --- a/src/Bundle/ChillMainBundle/Validation/Validator/ValidPhonenumber.php +++ b/src/Bundle/ChillMainBundle/Validation/Validator/ValidPhonenumber.php @@ -43,7 +43,7 @@ final class ValidPhonenumber extends ConstraintValidator return; } - if ('' === $value) { + if (null === $value) { return; } From 6171b3411fe82bd94801380cb75258b262e1b8fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 3 Mar 2022 13:07:36 +0100 Subject: [PATCH 012/174] fix creation of document when overriding center resolver --- .../Controller/DocumentPersonController.php | 2 - .../Form/PersonDocumentType.php | 39 +++++-------------- 2 files changed, 9 insertions(+), 32 deletions(-) diff --git a/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php b/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php index fcb3a4958..eb9698aee 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php @@ -98,7 +98,6 @@ class DocumentPersonController extends AbstractController PersonDocumentType::class, $document, [ - 'center' => $document->getCenter(), 'role' => 'CHILL_PERSON_DOCUMENT_UPDATE', ] ); @@ -199,7 +198,6 @@ class DocumentPersonController extends AbstractController $document->setDate(new DateTime('Now')); $form = $this->createForm(PersonDocumentType::class, $document, [ - 'center' => $document->getCenter(), '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 bcbd4d707..41dc73154 100644 --- a/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php +++ b/src/Bundle/ChillDocStoreBundle/Form/PersonDocumentType.php @@ -13,15 +13,13 @@ namespace Chill\DocStoreBundle\Form; use Chill\DocStoreBundle\Entity\Document; use Chill\DocStoreBundle\Entity\PersonDocument; -use Chill\MainBundle\Entity\User; use Chill\MainBundle\Form\Type\ChillDateType; use Chill\MainBundle\Form\Type\ChillTextareaType; use Chill\MainBundle\Form\Type\ScopePickerType; -use Chill\MainBundle\Security\Authorization\AuthorizationHelper; +use Chill\MainBundle\Security\Resolver\CenterResolverDispatcher; use Chill\MainBundle\Security\Resolver\ScopeResolverDispatcher; -use Chill\MainBundle\Templating\TranslatableStringHelper; +use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Doctrine\ORM\EntityRepository; -use Doctrine\Persistence\ObjectManager; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Form\AbstractType; @@ -31,34 +29,16 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class PersonDocumentType extends AbstractType { - /** - * @var AuthorizationHelper - */ - protected $authorizationHelper; - - /** - * @var ObjectManager - */ - protected $om; - - /** - * @var TranslatableStringHelper - */ - protected $translatableStringHelper; - - /** - * the user running this form. - * - * @var User - */ - protected $user; + private CenterResolverDispatcher $centerResolverDispatcher; private ParameterBagInterface $parameterBag; private ScopeResolverDispatcher $scopeResolverDispatcher; + private TranslatableStringHelperInterface $translatableStringHelper; + public function __construct( - TranslatableStringHelper $translatableStringHelper, + TranslatableStringHelperInterface $translatableStringHelper, ScopeResolverDispatcher $scopeResolverDispatcher, ParameterBagInterface $parameterBag ) { @@ -96,7 +76,7 @@ class PersonDocumentType extends AbstractType if ($isScopeConcerned && $this->parameterBag->get('chill_main')['acl']['form_show_scopes']) { $builder->add('scope', ScopePickerType::class, [ - 'center' => $options['center'], + 'center' => $this->centerResolverDispatcher->resolveCenter($document), 'role' => $options['role'], ]); } @@ -108,8 +88,7 @@ class PersonDocumentType extends AbstractType 'data_class' => Document::class, ]); - $resolver->setRequired(['role', 'center']) - ->setAllowedTypes('role', ['string']) - ->setAllowedTypes('center', [\Chill\MainBundle\Entity\Center::class]); + $resolver->setRequired(['role']) + ->setAllowedTypes('role', ['string']); } } From 6edf0bcb3b28f330759e1d3a1a45a5539ba630aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 3 Mar 2022 13:56:26 +0100 Subject: [PATCH 013/174] fix delete links in documents --- .../translations/messages.fr.yml | 2 +- .../DocumentAccompanyingCourseController.php | 34 +++++++++++---- .../Controller/DocumentPersonController.php | 38 +++++++++++----- .../_delete_form.html.twig | 5 --- .../delete.html.twig | 43 +++++++++++++++++++ .../AccompanyingCourseDocument/edit.html.twig | 9 +++- .../AccompanyingCourseDocument/show.html.twig | 17 +++++--- .../Resources/views/List/list_item.html.twig | 32 +++++++++----- .../views/PersonDocument/delete.html.twig | 43 +++++++++++++++++++ .../views/PersonDocument/edit.html.twig | 14 +++--- .../views/PersonDocument/new.html.twig | 4 +- .../views/PersonDocument/show.html.twig | 22 ++++++---- .../translations/messages.fr.yml | 6 +++ .../Entity/Person/ResidentialAddress.php | 4 +- .../ResidentialAddressRepository.php | 26 +++++------ .../Normalizer/PersonJsonNormalizer.php | 6 ++- 16 files changed, 226 insertions(+), 79 deletions(-) delete mode 100644 src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/_delete_form.html.twig create mode 100644 src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/delete.html.twig create mode 100644 src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/delete.html.twig diff --git a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml index 81a34d47d..051497b69 100644 --- a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml @@ -76,7 +76,7 @@ activity: Insert a document: Insérer un document Remove a document: Supprimer le document comment: Commentaire -No documents: Pas de documents +No documents: Aucun document #timeline '%user% has done an %activity_type%': '%user% a effectué une activité de type "%activity_type%"' diff --git a/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php b/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php index 199f88c60..ae8db17f6 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php @@ -21,6 +21,8 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod; use DateTime; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\Form\Extension\Core\Type\FormType; +use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; @@ -59,21 +61,37 @@ class DocumentAccompanyingCourseController extends AbstractController } /** - * @Route("/{id}", name="accompanying_course_document_delete", methods="DELETE") + * @Route("/{id}/delete", name="chill_docstore_accompanying_course_document_delete") */ public function delete(Request $request, AccompanyingPeriod $course, AccompanyingCourseDocument $document): Response { $this->denyAccessUnlessGranted(AccompanyingCourseDocumentVoter::DELETE, $document); - if ($this->isCsrfTokenValid('delete' . $document->getId(), $request->request->get('_token'))) { - $em = $this->getDoctrine()->getManager(); - $em->remove($document); - $em->flush(); + $form = $this->createForm(FormType::class); + $form->add('submit', SubmitType::class, ['label' => 'Delete']); + + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $this->getDoctrine()->getManager()->remove($document); + $this->getDoctrine()->getManager()->flush(); + + $this->addFlash('success', $this->translator->trans('The document is successfully removed')); + + if ($request->query->has('returnPath')) { + return $this->redirect($request->query->get('returnPath')); + } + + return $this->redirectToRoute('accompanying_course_document_index', ['course' => $course->getId()]); } - return $this->redirectToRoute( - 'accompanying_course_document_index', - ['accompanyingCourse' => $course->getId()] + return $this->render( + 'ChillDocStoreBundle:AccompanyingCourseDocument:delete.html.twig', + [ + 'document' => $document, + 'delete_form' => $form->createView(), + 'accompanyingCourse' => $course, + ] ); } diff --git a/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php b/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php index eb9698aee..42e49ad3c 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php @@ -14,6 +14,7 @@ namespace Chill\DocStoreBundle\Controller; use Chill\DocStoreBundle\Entity\PersonDocument; use Chill\DocStoreBundle\Form\PersonDocumentType; use Chill\DocStoreBundle\Repository\PersonDocumentACLAwareRepositoryInterface; +use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter; use Chill\MainBundle\Pagination\PaginatorFactory; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\PersonBundle\Entity\Person; @@ -22,6 +23,8 @@ use Chill\PersonBundle\Security\Authorization\PersonVoter; use DateTime; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\Form\Extension\Core\Type\FormType; +use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; @@ -64,22 +67,37 @@ class DocumentPersonController extends AbstractController } /** - * @Route("/{id}", name="person_document_delete", methods="DELETE") + * @Route("/{id}/delete", name="chill_docstore_person_document_delete") */ public function delete(Request $request, Person $person, PersonDocument $document): Response { - $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); - $this->denyAccessUnlessGranted('CHILL_PERSON_DOCUMENT_DELETE', $document); + $this->denyAccessUnlessGranted(PersonDocumentVoter::DELETE, $document); - if ($this->isCsrfTokenValid('delete' . $document->getId(), $request->request->get('_token'))) { - $em = $this->getDoctrine()->getManager(); - $em->remove($document); - $em->flush(); + $form = $this->createForm(FormType::class); + $form->add('submit', SubmitType::class, ['label' => 'Delete']); + + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $this->getDoctrine()->getManager()->remove($document); + $this->getDoctrine()->getManager()->flush(); + + $this->addFlash('success', $this->translator->trans('The document is successfully removed')); + + if ($request->query->has('returnPath')) { + return $this->redirect($request->query->get('returnPath')); + } + + return $this->redirectToRoute('person_document_index', ['person' => $person->getId()]); } - return $this->redirectToRoute( - 'person_document_index', - ['person' => $person->getId()] + return $this->render( + 'ChillDocStoreBundle:PersonDocument:delete.html.twig', + [ + 'document' => $document, + 'delete_form' => $form->createView(), + 'person' => $person, + ] ); } diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/_delete_form.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/_delete_form.html.twig deleted file mode 100644 index 90ee734e0..000000000 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/_delete_form.html.twig +++ /dev/null @@ -1,5 +0,0 @@ -
    - - - -
    diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/delete.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/delete.html.twig new file mode 100644 index 000000000..a6679829b --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/delete.html.twig @@ -0,0 +1,43 @@ +{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %} + +{% set activeRouteKey = '' %} + +{% block title %}{{ 'Delete document ?' }}{% endblock %} + +{% block docdescription %} +
    +
    {{ 'Title'|trans }}
    +
    {{ document.title }}
    + + {% if document.scope is not null %} +
    {{ 'Scope' | trans }}
    +
    {{ document.scope.name | localize_translatable_string }}
    + {% endif %} + +
    {{ 'Category'|trans }}
    +
    {{ document.category.name|localize_translatable_string }}
    + +
    {{ 'Description' | trans }}
    +
    + {% if document.description is empty %} + {{ 'Any description'|trans }} + {% else %} +
    + {{ document.description|chill_markdown_to_html }} +
    + {% endif %} +
    +
    +{% endblock %} + +{% block content %} +{{ include('@ChillMain/Util/confirmation_template.html.twig', + { + 'title' : 'Delete document ?'|trans, + 'display_content' : block('docdescription'), + 'confirm_question' : 'Are you sure you want to remove this document ?'|trans, + 'cancel_route' : 'accompanying_course_document_index', + 'cancel_parameters' : {'course' : accompanyingCourse.id, 'id': document.id}, + 'form' : delete_form + } ) }} +{% endblock %} diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/edit.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/edit.html.twig index d7a5325cf..0ca5661fc 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/edit.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/edit.html.twig @@ -25,8 +25,13 @@ {{ 'Back to the list' | trans }}
  • -
  • - + {% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_DELETE', document) %} +
  • + +
  • + {% endif %} +
  • +
diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/show.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/show.html.twig index 1e4fdb8e6..45ed3988b 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/show.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/show.html.twig @@ -49,12 +49,9 @@ {{ 'Back to the list' | trans }} -
  • - {{ m.download_button(document.object, document.title) }} -
  • - {% if chill_document_is_editable(document.object) %} -
  • - {{ document.object|chill_document_edit_button }} + {% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_DELETE', document) %} +
  • +
  • {% endif %} {% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_UPDATE', document) %} @@ -63,6 +60,14 @@ class="btn btn-edit" title="{{ 'Edit attributes' | trans }}"> {% endif %} +
  • + {{ m.download_button(document.object, document.title) }} +
  • + {% if chill_document_is_editable(document.object) %} +
  • + {{ document.object|chill_document_edit_button }} +
  • + {% endif %} {% set workflows_frame = chill_entity_workflow_list('Chill\\DocStoreBundle\\Entity\\AccompanyingCourseDocument', document.id) %} {% if workflows_frame is not empty %}
  • diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/List/list_item.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/List/list_item.html.twig index 5ce03091b..8fbc3fa5c 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/List/list_item.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/List/list_item.html.twig @@ -44,6 +44,16 @@
      {% if document.course is defined %} + {% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_DELETE', document) %} +
    • + +
    • + {% endif %} + {% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_UPDATE', document) %} +
    • + +
    • + {% endif %} {% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_SEE_DETAILS', document) %}
    • {{ m.download_button(document.object, document.title) }} @@ -52,15 +62,20 @@
    • {% endif %} - {% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_UPDATE', document) %} -
    • - -
    • - {% endif %}
    • {{ chill_entity_workflow_list('Chill\\DocStoreBundle\\Entity\\AccompanyingCourseDocument', document.id) }}
    • {% else %} + {% if is_granted('CHILL_PERSON_DOCUMENT_DELETE', document) %} +
    • + +
    • + {% endif %} + {% if is_granted('CHILL_PERSON_DOCUMENT_UPDATE', document) %} +
    • + +
    • + {% endif %} {% if is_granted('CHILL_PERSON_DOCUMENT_SEE_DETAILS', document) %}
    • {{ m.download_button(document.object, document.title) }} @@ -69,13 +84,8 @@
    • {% endif %} - {% if is_granted('CHILL_PERSON_DOCUMENT_UPDATE', document) %} -
    • - -
    • - {% endif %} {% endif %}
    - + diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/delete.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/delete.html.twig new file mode 100644 index 000000000..e3f6687fd --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/delete.html.twig @@ -0,0 +1,43 @@ +{% extends "@ChillPerson/Person/layout.html.twig" %} + +{% set activeRouteKey = '' %} + +{% block title %}{{ 'Delete document ?' }}{% endblock %} + +{% block docdescription %} +
    +
    {{ 'Title'|trans }}
    +
    {{ document.title }}
    + + {% if document.scope is not null %} +
    {{ 'Scope' | trans }}
    +
    {{ document.scope.name | localize_translatable_string }}
    + {% endif %} + +
    {{ 'Category'|trans }}
    +
    {{ document.category.name|localize_translatable_string }}
    + +
    {{ 'Description' | trans }}
    +
    + {% if document.description is empty %} + {{ 'Any description'|trans }} + {% else %} +
    + {{ document.description|chill_markdown_to_html }} +
    + {% endif %} +
    +
    +{% endblock %} + +{% block personcontent %} +{{ include('@ChillMain/Util/confirmation_template.html.twig', + { + 'title' : 'Delete document ?'|trans, + 'display_content' : block('docdescription'), + 'confirm_question' : 'Are you sure you want to remove this document ?'|trans, + 'cancel_route' : 'person_document_index', + 'cancel_parameters' : {'person' : person.id, 'id': document.id}, + 'form' : delete_form + } ) }} +{% endblock %} diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/edit.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/edit.html.twig index 7533f1120..4a9eab8e3 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/edit.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/edit.html.twig @@ -36,20 +36,20 @@ {{ form_row(form.description) }} {{ form_row(form.object, { 'label': 'Document', 'existing': document.object }) }} -
      +
      • - + {{ 'Back to the list' | trans }}
      • + {% if is_granted('CHILL_PERSON_DOCUMENT_DELETE', document) %} +
      • + +
      • + {% endif %}
      • - {# {% if is_granted('CHILL_PERSON_DOCUMENT_DELETE', document) %} -
      • - {{ include('ChillDocStoreBundle:PersonDocument:_delete_form.html.twig') }} -
      • - {% endif %} #}
      {{ form_end(form) }} diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/new.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/new.html.twig index ad4fcfc81..357120a4e 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/new.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/new.html.twig @@ -40,9 +40,9 @@ {{ form_row(form.description) }} {{ form_row(form.object, { 'label': 'Document', 'existing': document.object }) }} -
        +
        • - + {{ 'Back to the list' | trans }}
        • diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/show.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/show.html.twig index 723757425..a29dc0c04 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/show.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/show.html.twig @@ -64,13 +64,9 @@ -
        • - {{ m.download_button(document.object, document.title) }} -
        • - - {% if chill_document_is_editable(document.object) %} -
        • - {{ document.object|chill_document_edit_button }} + {% if is_granted('CHILL_PERSON_DOCUMENT_DELETE', document) %} +
        • +
        • {% endif %} @@ -82,5 +78,15 @@ {% endif %} - {# {{ include('ChillDocStoreBundle:PersonDocument:_delete_form.html.twig') }} #} +
        • + {{ m.download_button(document.object, document.title) }} +
        • + + {% if chill_document_is_editable(document.object) %} +
        • + {{ document.object|chill_document_edit_button }} +
        • + {% endif %} + + {# {{ include('ChillDocStoreBundle:PersonDocument:_delete_form.html.twig') }} #} {% endblock %} diff --git a/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml b/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml index f438731d4..009f4d987 100644 --- a/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml @@ -19,6 +19,12 @@ The document is successfully registered: Le document est enregistré The document is successfully updated: Le document est mis à jour Any description: Aucune description +# delete +Delete document ?: Supprimer le document ? +Are you sure you want to remove this document ?: Êtes-vous sûr·e de vouloir supprimer ce document ? +The document is successfully removed: Le document a été supprimé + + # dropzone upload File too big: Fichier trop volumineux Drop your file or click here: Cliquez ici ou faites glissez votre nouveau fichier dans cette zone diff --git a/src/Bundle/ChillPersonBundle/Entity/Person/ResidentialAddress.php b/src/Bundle/ChillPersonBundle/Entity/Person/ResidentialAddress.php index cb82f766a..bfa3760fa 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person/ResidentialAddress.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person/ResidentialAddress.php @@ -18,8 +18,8 @@ use Chill\PersonBundle\Repository\ResidentialAddressRepository; use Chill\ThirdPartyBundle\Entity\ThirdParty; use DateTimeImmutable; use Doctrine\ORM\Mapping as ORM; -use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Serializer\Annotation\Context; +use Symfony\Component\Serializer\Annotation\Groups; /** * @ORM\Entity(repositoryClass=ResidentialAddressRepository::class) @@ -49,7 +49,7 @@ class ResidentialAddress * @ORM\ManyToOne(targetEntity=Person::class) * @ORM\JoinColumn(nullable=true) * @Groups({"read"}) - * @Context(normalizationContext={"groups"={"minimal"}}) + * @Context(normalizationContext={"groups": {"minimal"}}) */ private ?Person $hostPerson = null; diff --git a/src/Bundle/ChillPersonBundle/Repository/ResidentialAddressRepository.php b/src/Bundle/ChillPersonBundle/Repository/ResidentialAddressRepository.php index b5d64a31a..4e6131de0 100644 --- a/src/Bundle/ChillPersonBundle/Repository/ResidentialAddressRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/ResidentialAddressRepository.php @@ -32,26 +32,11 @@ class ResidentialAddressRepository extends ServiceEntityRepository parent::__construct($registry, ResidentialAddress::class); } - /** - * @param Person $person - * @param DateTimeImmutable|null $at - * @return array|ResidentialAddress[]|null - */ - public function findCurrentResidentialAddressByPerson(Person $person, ?DateTimeImmutable $at = null): array - { - return $this->buildQueryFindCurrentResidentialAddresses($person, $at) - ->select('ra') - ->getQuery() - ->getResult(); - } - public function buildQueryFindCurrentResidentialAddresses(Person $person, ?DateTimeImmutable $at = null): QueryBuilder { $date = null === $at ? new DateTimeImmutable('today') : $at; $qb = $this->createQueryBuilder('ra'); - - $dateFilter = $qb->expr()->andX( $qb->expr()->lte('ra.startDate', ':dateIn'), $qb->expr()->orX( @@ -69,6 +54,17 @@ class ResidentialAddressRepository extends ServiceEntityRepository return $qb; } + /** + * @return array|ResidentialAddress[]|null + */ + public function findCurrentResidentialAddressByPerson(Person $person, ?DateTimeImmutable $at = null): array + { + return $this->buildQueryFindCurrentResidentialAddresses($person, $at) + ->select('ra') + ->getQuery() + ->getResult(); + } + // /** // * @return ResidentialAddress[] Returns an array of ResidentialAddress objects // */ diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php index b42e30ff6..1901fd50c 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php @@ -31,6 +31,8 @@ use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface; use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait; use Symfony\Component\Serializer\Normalizer\ObjectToPopulateTrait; use function array_key_exists; +use function count; +use function in_array; /** * Serialize a Person entity. @@ -207,8 +209,8 @@ class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwar 'gender' => $person->getGender(), ]; - if (in_array("minimal", $groups) && 1 === count($groups)) { - return $data; + if (in_array('minimal', $groups, true) && 1 === count($groups)) { + return $data; } return array_merge($data, [ From 34b3c6fa327a40c99c7507ebcd24ca9f753aa18b Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 3 Mar 2022 14:15:20 +0100 Subject: [PATCH 014/174] bugfix when position of member is null --- .../vuejs/_components/Entity/HouseholdRenderBox.vue | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/HouseholdRenderBox.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/HouseholdRenderBox.vue index 16d0fa2ff..163f49bcf 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/HouseholdRenderBox.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/HouseholdRenderBox.vue @@ -87,10 +87,14 @@ export default { currentMembers() { let members = this.household.members.filter(m => this.household.current_members_id.includes(m.id)) .sort((a, b) => { - if (a.position.ordering < b.position.ordering) { + + const orderA = a.position ? a.position.ordering : 0; + const orderB = b.position ? b.position.ordering : 0; + + if (orderA < orderB) { return -1; } - if (a.position.ordering > b.position.ordering) { + if (orderA > orderB) { return 1; } if (a.holder && !b.holder) { From 349db2142defe9cc6845e8ca7e7244997740da37 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 3 Mar 2022 14:39:00 +0100 Subject: [PATCH 015/174] person: add url field to SocialWork Evaluation entity + populate with http title values --- .../Entity/SocialWork/Evaluation.php | 18 +++++++++ .../migrations/Version20220303113855.php | 38 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/migrations/Version20220303113855.php diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/Evaluation.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/Evaluation.php index 1350ae6d8..9349c335e 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/Evaluation.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/Evaluation.php @@ -62,6 +62,12 @@ class Evaluation */ private array $title = []; + /** + * @ORM\Column(type="text", nullable=true) + * @Serializer\Groups({"read", "docgen:read"}) + */ + private ?string $url = null; + public function __construct() { $this->socialActions = new ArrayCollection(); @@ -101,6 +107,11 @@ class Evaluation return $this->title; } + public function getUrl(): ?string + { + return $this->url; + } + public function removeSocialAction(SocialAction $socialAction): self { if ($this->socialActions->contains($socialAction)) { @@ -130,4 +141,11 @@ class Evaluation return $this; } + + public function setUrl(?string $url): self + { + $this->url = $url; + + return $this; + } } diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20220303113855.php b/src/Bundle/ChillPersonBundle/migrations/Version20220303113855.php new file mode 100644 index 000000000..9991d2eca --- /dev/null +++ b/src/Bundle/ChillPersonBundle/migrations/Version20220303113855.php @@ -0,0 +1,38 @@ +addSql('ALTER TABLE chill_person_social_work_evaluation ADD url TEXT DEFAULT NULL'); + $this->addSql("UPDATE chill_person_social_work_evaluation SET url = CASE WHEN title->>'fr' LIKE 'http%' THEN title->>'fr' ELSE null END;"); + } + + public function down(Schema $schema): void + { + + $this->addSql('ALTER TABLE chill_person_social_work_evaluation DROP url'); + } +} From f0e41f839fdcfc44d4660628565c7289ec18c27f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 3 Mar 2022 14:39:20 +0100 Subject: [PATCH 016/174] fix error when context is a string in personJsonNormalizer --- .../Serializer/Normalizer/PersonJsonNormalizer.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php index 1901fd50c..1969fffa7 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php @@ -189,6 +189,9 @@ class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwar public function normalize($person, $format = null, array $context = []) { $groups = $context[AbstractNormalizer::GROUPS] ?? []; + if (is_string($groups)) { + $groups = [$groups]; + } $household = $person->getCurrentHousehold(); $currentResidentialAddresses = $this->residentialAddressRepository->findCurrentResidentialAddressByPerson($person); From bf4a3a2c91f69b23697815398c8ff23ac9f4efa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 3 Mar 2022 15:01:14 +0100 Subject: [PATCH 017/174] add id to docgen normalization fo a person --- .../Serializer/Normalizer/PersonDocGenNormalizer.php | 3 ++- .../Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php index 8eae2065d..c6d132992 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php @@ -74,6 +74,7 @@ class PersonDocGenNormalizer implements $data = [ 'type' => 'person', + 'id' => $person->getId(), 'isNull' => false, 'civility' => $this->normalizer->normalize($person->getCivility(), $format, array_merge($context, ['docgen:expects' => Civility::class])), 'firstName' => $person->getFirstName(), @@ -151,7 +152,7 @@ class PersonDocGenNormalizer implements $normalizer = new NormalizeNullValueHelper($this->normalizer, 'type', 'person'); $attributes = [ - 'firstName', 'lastName', 'age', 'altNames', 'text', + 'id', 'firstName', 'lastName', 'age', 'altNames', 'text', 'civility' => Civility::class, 'birthdate' => DateTimeInterface::class, 'deathdate' => DateTimeInterface::class, diff --git a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php index 817125422..c19533e08 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php @@ -38,6 +38,7 @@ final class PersonDocGenNormalizerTest extends KernelTestCase use ProphecyTrait; private const BLANK = [ + 'id' => '', 'firstName' => '', 'lastName' => '', 'altNames' => '', From 9769aa1386aeeea90f9ccc41d501aaca8b47bd02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 3 Mar 2022 15:07:45 +0100 Subject: [PATCH 018/174] fix loading of residential address form type --- .../Controller/ResidentialAddressController.php | 2 +- src/Bundle/ChillPersonBundle/Form/ResidentialAddressType.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/ResidentialAddressController.php b/src/Bundle/ChillPersonBundle/Controller/ResidentialAddressController.php index f77a4150c..bdc6c1b5e 100644 --- a/src/Bundle/ChillPersonBundle/Controller/ResidentialAddressController.php +++ b/src/Bundle/ChillPersonBundle/Controller/ResidentialAddressController.php @@ -13,7 +13,7 @@ namespace Chill\PersonBundle\Controller; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person\ResidentialAddress; -use Chill\PersonBundle\Form\Type\ResidentialAddressType; +use Chill\PersonBundle\Form\ResidentialAddressType; use Chill\PersonBundle\Repository\ResidentialAddressRepository; use Chill\PersonBundle\Security\Authorization\PersonVoter; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; diff --git a/src/Bundle/ChillPersonBundle/Form/ResidentialAddressType.php b/src/Bundle/ChillPersonBundle/Form/ResidentialAddressType.php index b34395daf..8efcf091a 100644 --- a/src/Bundle/ChillPersonBundle/Form/ResidentialAddressType.php +++ b/src/Bundle/ChillPersonBundle/Form/ResidentialAddressType.php @@ -9,11 +9,12 @@ declare(strict_types=1); -namespace Chill\PersonBundle\Form\Type; +namespace Chill\PersonBundle\Form; use Chill\MainBundle\Form\Type\CommentType; use Chill\MainBundle\Form\Type\PickAddressType; use Chill\PersonBundle\Entity\Person\ResidentialAddress; +use Chill\PersonBundle\Form\Type\PickPersonDynamicType; use Chill\ThirdPartyBundle\Form\Type\PickThirdpartyDynamicType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\DateType; From 568a1d95f46544fff7040710359b5fd7ea91a634 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 3 Mar 2022 15:10:05 +0100 Subject: [PATCH 019/174] AccompanyingCourseWorkEdit: add url to vuejs form --- .../components/AddEvaluation.vue | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/AddEvaluation.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/AddEvaluation.vue index 579d0b306..d2b8c5b46 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/AddEvaluation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/AddEvaluation.vue @@ -5,6 +5,11 @@ {{ evaluation.evaluation.title.fr }} + +
          @@ -128,4 +133,11 @@ export default { } } } + div.item-url { + i { + color: unset!important; + margin-left: 1rem; + margin-right: 0.5rem; + } + } From a88e052eb64f06c4195f9a3b20f319ac291505d3 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 3 Mar 2022 15:12:47 +0100 Subject: [PATCH 020/174] upd CHANGELOG --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bd743078..7de2c188a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ and this project adheres to ## Unreleased +* [person] Add url in accompanying period work evaluations entity and form (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/476) + + * [parcours] Toggle emergency/intensity only by referrer (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/442) * [docstore] Add an API entrypoint for StoredObject (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/466) * [person] Add the possibility of uploading existing documents to AccPeriodWorkEvaluationDocument (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/466) From c5eac09478e1b9bed3369182ce351f64420a0366 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 3 Mar 2022 15:17:05 +0100 Subject: [PATCH 021/174] php cs fix on migration --- .../migrations/Version20220303113855.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20220303113855.php b/src/Bundle/ChillPersonBundle/migrations/Version20220303113855.php index 9991d2eca..7840cdfce 100644 --- a/src/Bundle/ChillPersonBundle/migrations/Version20220303113855.php +++ b/src/Bundle/ChillPersonBundle/migrations/Version20220303113855.php @@ -15,10 +15,15 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; /** - * Add url to SocialWork Evaluation + * Add url to SocialWork Evaluation. */ final class Version20220303113855 extends AbstractMigration { + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_person_social_work_evaluation DROP url'); + } + public function getDescription(): string { return 'Add url to SocialWork Evaluation'; @@ -29,10 +34,4 @@ final class Version20220303113855 extends AbstractMigration $this->addSql('ALTER TABLE chill_person_social_work_evaluation ADD url TEXT DEFAULT NULL'); $this->addSql("UPDATE chill_person_social_work_evaluation SET url = CASE WHEN title->>'fr' LIKE 'http%' THEN title->>'fr' ELSE null END;"); } - - public function down(Schema $schema): void - { - - $this->addSql('ALTER TABLE chill_person_social_work_evaluation DROP url'); - } } From 4ad65b616d3d828caf428f8282baeb29f498b904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 3 Mar 2022 15:20:21 +0100 Subject: [PATCH 022/174] fix tests for person json normalizer and residential address stuff --- .../Normalizer/PersonJsonNormalizer.php | 6 ++- .../Normalizer/PersonJsonNormalizerTest.php | 47 ++++++++++++++++++- 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php index 1969fffa7..ae95c9321 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php @@ -33,6 +33,7 @@ use Symfony\Component\Serializer\Normalizer\ObjectToPopulateTrait; use function array_key_exists; use function count; use function in_array; +use function is_string; /** * Serialize a Person entity. @@ -56,11 +57,11 @@ class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwar private ResidentialAddressRepository $residentialAddressRepository; public function __construct( - ChillEntityRenderExtension $render, + ChillEntityRenderExtension $render, /* TODO: replace by PersonRenderInterface, as sthis is the only one required */ PersonRepository $repository, CenterResolverManagerInterface $centerResolverManager, ResidentialAddressRepository $residentialAddressRepository, - PhoneNumberHelperInterface $phoneNumberHelper + PhoneNumberHelperInterface $phoneNumberHelper /* TODO maybe not necessayr any more */ ) { $this->render = $render; $this->repository = $repository; @@ -189,6 +190,7 @@ class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwar public function normalize($person, $format = null, array $context = []) { $groups = $context[AbstractNormalizer::GROUPS] ?? []; + if (is_string($groups)) { $groups = [$groups]; } diff --git a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonJsonNormalizerTest.php b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonJsonNormalizerTest.php index 59cc0a564..13fa54178 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonJsonNormalizerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonJsonNormalizerTest.php @@ -11,7 +11,15 @@ declare(strict_types=1); namespace Serializer\Normalizer; +use Chill\MainBundle\Phonenumber\PhoneNumberHelperInterface; +use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface; +use Chill\MainBundle\Templating\Entity\ChillEntityRenderExtension; use Chill\PersonBundle\Entity\Person; +use Chill\PersonBundle\Repository\PersonRepository; +use Chill\PersonBundle\Repository\ResidentialAddressRepository; +use Chill\PersonBundle\Serializer\Normalizer\PersonJsonNormalizer; +use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; @@ -22,12 +30,27 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface; */ final class PersonJsonNormalizerTest extends KernelTestCase { - private NormalizerInterface $normalizer; + use ProphecyTrait; + + private PersonJsonNormalizer $normalizer; protected function setUp(): void { self::bootKernel(); - $this->normalizer = self::$container->get(NormalizerInterface::class); + + $residentialAddressRepository = $this->prophesize(ResidentialAddressRepository::class); + $residentialAddressRepository + ->findCurrentResidentialAddressByPerson(Argument::type(Person::class), Argument::any()) + ->willReturn([]); + + $this->normalizer = $this->buildPersonJsonNormalizer( + self::$container->get(ChillEntityRenderExtension::class), + self::$container->get(PersonRepository::class), + self::$container->get(CenterResolverManagerInterface::class), + $residentialAddressRepository->reveal(), + self::$container->get(PhoneNumberHelperInterface::class), + self::$container->get(NormalizerInterface::class) + ); } public function testNormalization() @@ -37,4 +60,24 @@ final class PersonJsonNormalizerTest extends KernelTestCase $this->assertIsArray($result); } + + private function buildPersonJsonNormalizer( + ChillEntityRenderExtension $render, + PersonRepository $repository, + CenterResolverManagerInterface $centerResolverManager, + ResidentialAddressRepository $residentialAddressRepository, + PhoneNumberHelperInterface $phoneNumberHelper, + NormalizerInterface $normalizer + ): PersonJsonNormalizer { + $personJsonNormalizer = new PersonJsonNormalizer( + $render, + $repository, + $centerResolverManager, + $residentialAddressRepository, + $phoneNumberHelper + ); + $personJsonNormalizer->setNormalizer($normalizer); + + return $personJsonNormalizer; + } } From e9236875d223129a67a498b7006f35d9a36e59c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 3 Mar 2022 15:44:30 +0100 Subject: [PATCH 023/174] quick fix for phonenumber alt on person --- src/Bundle/ChillPersonBundle/Entity/PersonPhone.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Entity/PersonPhone.php b/src/Bundle/ChillPersonBundle/Entity/PersonPhone.php index 400e39c88..f33646f09 100644 --- a/src/Bundle/ChillPersonBundle/Entity/PersonPhone.php +++ b/src/Bundle/ChillPersonBundle/Entity/PersonPhone.php @@ -13,6 +13,7 @@ namespace Chill\PersonBundle\Entity; use DateTime; use Doctrine\ORM\Mapping as ORM; +use libphonenumber\PhoneNumber; /** * Person Phones. @@ -51,9 +52,9 @@ class PersonPhone private Person $person; /** - * @ORM\Column(type="text", length=40, nullable=false) + * @ORM\Column(type="phone_number", nullable=false) */ - private string $phonenumber = ''; + private ?PhoneNumber $phonenumber = null; /** * @ORM\Column(type="text", length=40, nullable=true) @@ -85,7 +86,7 @@ class PersonPhone return $this->person; } - public function getPhonenumber(): string + public function getPhonenumber(): ?PhoneNumber { return $this->phonenumber; } @@ -115,7 +116,7 @@ class PersonPhone $this->person = $person; } - public function setPhonenumber(string $phonenumber): void + public function setPhonenumber(?PhoneNumber $phonenumber): void { $this->phonenumber = $phonenumber; } From 892be425807ff901efcd593c764bab132cfd46ab Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 3 Mar 2022 16:28:31 +0100 Subject: [PATCH 024/174] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bd743078..8dd9bbbe2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ and this project adheres to * [confidential] Fix position of toggle button so it does not cover text nor fall outside of box (no issue) * [parcours] Fix edit of both thirdparty and contact name (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/474) * [template] do not list inactive templates (for doc generator) +* [household] bugfix if position of member is null, renderbox no longer throws an error (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/480) ## Test releases From 187c9d82b6cd499bc56547ab8f061042d71b4656 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 3 Mar 2022 16:37:58 +0100 Subject: [PATCH 025/174] assign User to undsipatched acc period: filter users by job type --- .../public/mod/AccompanyingPeriod/setReferrer.js | 13 ++++++------- .../_components/AccompanyingPeriod/SetReferrer.vue | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/mod/AccompanyingPeriod/setReferrer.js b/src/Bundle/ChillPersonBundle/Resources/public/mod/AccompanyingPeriod/setReferrer.js index b73c0afea..939075380 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/mod/AccompanyingPeriod/setReferrer.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/mod/AccompanyingPeriod/setReferrer.js @@ -19,22 +19,21 @@ import {fetchResults} from 'ChillMainAssets/lib/api/apiMethods.js'; */ document.querySelectorAll('[data-set-referrer-app]').forEach(function (el) { - let - periodId = Number.parseInt(el.dataset.setReferrerAccompanyingPeriodId); - + const periodId = Number.parseInt(el.dataset.setReferrerAccompanyingPeriodId); + const jobId = Number.parseInt(el.dataset.setReferrerJobId); const url = `/api/1.0/person/accompanying-course/${periodId}/referrers-suggested.json`; fetchResults(url).then(suggested => { - + const filteredSuggested = suggested.filter((s) => s.user_job ? s.user_job.id === jobId : false); const app = createApp({ components: { SetReferrer, }, template: - '', + '', data() { return { - periodId, suggested, original: suggested, + periodId, filteredSuggested, original: filteredSuggested, } }, methods: { @@ -56,7 +55,7 @@ document.querySelectorAll('[data-set-referrer-app]').forEach(function (el) { label.textContent = ref.text; label.classList.remove('chill-no-data-statement'); - this.suggested = this.original.filter(user => user.id !== ref.id); + this.filteredSuggested = this.original.filter(user => user.id !== ref.id); } } }); diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AccompanyingPeriod/SetReferrer.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AccompanyingPeriod/SetReferrer.vue index 3d3675c73..38418f305 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AccompanyingPeriod/SetReferrer.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AccompanyingPeriod/SetReferrer.vue @@ -1,12 +1,12 @@ diff --git a/src/Bundle/ChillMainBundle/Resources/views/Entity/address.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Entity/address.html.twig index 54a0b86b7..3dfc27d2f 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Entity/address.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Entity/address.html.twig @@ -59,7 +59,7 @@ must be shown in such list #} {%- if render == 'list' -%} -
        • +
        • {% if options['with_picto'] %} {% endif %} @@ -68,7 +68,7 @@ {%- endif -%} {%- if render == 'inline' -%} - + {% if options['with_picto'] %} {% endif %} @@ -77,7 +77,7 @@ {%- endif -%} {%- if render == 'bloc' -%} -
          +
          {% if options['has_no_address'] == true and address.isNoAddress == true %} {% if address.postCode is not empty %}
          diff --git a/src/Bundle/ChillPersonBundle/Resources/public/chill/chillperson.scss b/src/Bundle/ChillPersonBundle/Resources/public/chill/chillperson.scss index 92542f178..fba0516a7 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/chill/chillperson.scss +++ b/src/Bundle/ChillPersonBundle/Resources/public/chill/chillperson.scss @@ -33,6 +33,8 @@ div.banner { padding-top: 1em; padding-bottom: 1em; div.contact { + display: flex; + align-content: center; & > * { margin-right: 1em; } diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Requestor.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Requestor.vue index 713693605..7cf0dcecc 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Requestor.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Requestor.vue @@ -9,7 +9,7 @@ {{ $t('requestor.is_anonymous') }} - + @@ -12,28 +12,24 @@ diff --git a/src/Bundle/ChillMainBundle/Resources/views/Entity/address.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Entity/address.html.twig index 54a0b86b7..3dfc27d2f 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Entity/address.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Entity/address.html.twig @@ -59,7 +59,7 @@ must be shown in such list #} {%- if render == 'list' -%} -
        • +
        • {% if options['with_picto'] %} {% endif %} @@ -68,7 +68,7 @@ {%- endif -%} {%- if render == 'inline' -%} - + {% if options['with_picto'] %} {% endif %} @@ -77,7 +77,7 @@ {%- endif -%} {%- if render == 'bloc' -%} -
          +
          {% if options['has_no_address'] == true and address.isNoAddress == true %} {% if address.postCode is not empty %}
          diff --git a/src/Bundle/ChillPersonBundle/Resources/public/chill/chillperson.scss b/src/Bundle/ChillPersonBundle/Resources/public/chill/chillperson.scss index 92542f178..fba0516a7 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/chill/chillperson.scss +++ b/src/Bundle/ChillPersonBundle/Resources/public/chill/chillperson.scss @@ -33,6 +33,8 @@ div.banner { padding-top: 1em; padding-bottom: 1em; div.contact { + display: flex; + align-content: center; & > * { margin-right: 1em; } diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Requestor.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Requestor.vue index 713693605..7cf0dcecc 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Requestor.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Requestor.vue @@ -9,7 +9,7 @@ {{ $t('requestor.is_anonymous') }} - +