diff --git a/CHANGELOG.md b/CHANGELOG.md index c8e0d0f5f..28144720b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,11 +11,23 @@ and this project adheres to ## Unreleased +* [main] change address format in case the country is France, in Address render box and address normalizer * [person] add validator for accompanying period with a test on social issues (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/76) * [activity] fix visibility for location * [origin] fix origin: use correctly the translatable strings * /!\ everyone must update the origin table. As there is only one row, execute `update chill_person_accompanying_period_origin set label = jsonb_build_object('fr', 'appel téléphonique');` +* [person] redirect bug fixed. +* [action] add an unrelated issue within action creation. +* [origin] fix origin: use correctly the translatable strings + * /!\ everyone must update the origin table. As there is only one row, execute `update chill_person_accompanying_period_origin set label = jsonb_build_object('fr', 'appel téléphonique');` +* [main] change order of civilities in civility fixtures (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/191) +* [person] set min attr in the minimum of children field (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/191) +* [person] add marital status date in person view (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/191) +* [person] show number of children + allow set number of children to null (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/191) +* [person] show acceptSMS option (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/191) +* [person] add death information in person render box in twig and vue render boxes (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/191) + ## Test releases @@ -33,6 +45,9 @@ and this project adheres to * [activity] create work if a work with same social action is not associated to the activity * [visgraph] improve and fix bugs on vis-network relationship graph * [bugfix] posting of birth- and deathdate through api fixed. +* [suggestions] improve suggestions lists +* [badge-entity] design coherency between badge-person and 3 kinds of badge-thirdparty +* [AddPersons] suggestions row are clickable, not only checkbox ### Test release 2021-11-19 - bis diff --git a/CONVENTIONS.md b/CONVENTIONS.md index 2543e54b7..717249a83 100644 --- a/CONVENTIONS.md +++ b/CONVENTIONS.md @@ -409,3 +409,4 @@ Créer un titre enlevable (avec une croix rouge cliquable, l'ancre a est vide) ``` +Les classes `cols` ou `inline` peuvent être ajoutées à côté de `list-suggest` pour modifier la disposition de la liste. diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/ConcernedGroups.vue b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/ConcernedGroups.vue index 853b43eb0..49b53c8cb 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/ConcernedGroups.vue +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/ConcernedGroups.vue @@ -11,7 +11,7 @@
-
{% endif %} {{ _self.validity(address, options) }} diff --git a/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig b/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig index f9924eb11..515685b9e 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/FilterOrder/base.html.twig @@ -1,5 +1,5 @@ {{ form_start(form) }} -
+
{% if form.vars.has_search_box %}
diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/AddressNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/AddressNormalizer.php index 131638b3d..fd250e967 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/AddressNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/AddressNormalizer.php @@ -52,9 +52,19 @@ class AddressNormalizer implements ContextAwareNormalizerInterface, NormalizerAw public function normalize($address, ?string $format = null, array $context = []) { if ($address instanceof Address) { + $text = $address->isNoAddress() ? '' : $address->getStreet() . ', ' . $address->getStreetNumber(); + + if (null !== $address->getPostCode()->getCountry()->getCountryCode()) { + if ($address->getPostCode()->getCountry()->getCountryCode() === 'FR') { + $text = $address->isNoAddress() ? '' : $address->getStreetNumber() . ', ' . $address->getStreet(); + } else { + $text = $address->isNoAddress() ? '' : $address->getStreetNumber() . ', ' . $address->getStreet(); + } + } + $data = [ 'address_id' => $address->getId(), - 'text' => $address->isNoAddress() ? '' : $address->getStreetNumber() . ', ' . $address->getStreet(), + 'text' => $text, 'street' => $address->getStreet(), 'streetNumber' => $address->getStreetNumber(), 'postcode' => [ diff --git a/src/Bundle/ChillMainBundle/Templating/Entity/AddressRender.php b/src/Bundle/ChillMainBundle/Templating/Entity/AddressRender.php index 2a29fb2f3..264f11688 100644 --- a/src/Bundle/ChillMainBundle/Templating/Entity/AddressRender.php +++ b/src/Bundle/ChillMainBundle/Templating/Entity/AddressRender.php @@ -46,6 +46,7 @@ class AddressRender implements ChillEntityRenderInterface return $this->templating ->render('@ChillMain/Entity/address.html.twig', [ 'address' => $addr, + 'streetLine' => $this->renderStreetLine($addr), 'render' => $options['render'] ?? 'bloc', 'options' => $options, ]); @@ -59,13 +60,7 @@ class AddressRender implements ChillEntityRenderInterface { $lines = []; - if (!empty($addr->getStreet())) { - $lines[0] = $addr->getStreet(); - } - - if (!empty($addr->getStreetNumber())) { - $lines[0] .= ', ' . $addr->getStreetNumber(); - } + $lines[0] = $this->renderStreetLine($addr); if (!empty($addr->getPostcode())) { $lines[1] = strtr('{postcode} {label}', [ @@ -81,4 +76,33 @@ class AddressRender implements ChillEntityRenderInterface { return $entity instanceof Address; } + + private function renderStreetLine($addr): string + { + if (!empty($addr->getStreet())) { + $street = $addr->getStreet(); + } else { + $street = ''; + } + + if (!empty($addr->getStreetNumber())) { + $streetNumber = $addr->getStreetNumber(); + } else { + $streetNumber = ''; + } + + $res = trim($street . ', ' . $streetNumber, ', '); + + if (null !== $addr->getPostCode()->getCountry()->getCountryCode()) { + if ($addr->getPostCode()->getCountry()->getCountryCode() === 'FR') { + $res = trim($streetNumber . ', ' . $street, ', '); + } + } + + if (',' === $res) { + $res = ''; + } + + return $res; + } } diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php index 43276c949..9445dc302 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php @@ -34,6 +34,8 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Serializer\Exception\RuntimeException; use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; +use Symfony\Component\Validator\ConstraintViolationList; +use Symfony\Component\Validator\ConstraintViolationListInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; use Symfony\Component\Workflow\Registry; use function array_values; @@ -294,4 +296,17 @@ final class AccompanyingCourseApiController extends ApiController return null; } + + protected function validate(string $action, Request $request, string $_format, $entity, array $more = []): ConstraintViolationListInterface + { + if ('work' !== $action) { + return parent::validate($action, $request, $_format, $entity, $more); + } + + if (Request::METHOD_POST === $request->getMethod()) { + return $this->getValidator()->validate($more[0], null); + } + + return new ConstraintViolationList([]); + } } diff --git a/src/Bundle/ChillPersonBundle/Controller/HouseholdMemberController.php b/src/Bundle/ChillPersonBundle/Controller/HouseholdMemberController.php index 012d0fd68..802f9fd6c 100644 --- a/src/Bundle/ChillPersonBundle/Controller/HouseholdMemberController.php +++ b/src/Bundle/ChillPersonBundle/Controller/HouseholdMemberController.php @@ -186,7 +186,7 @@ class HouseholdMemberController extends ApiController $_format, ['groups' => ['read']] ); - } catch (Exception\InvalidArgumentException | Exception\UnexpectedValueException $e) { + } catch (Exception\InvalidArgumentException|Exception\UnexpectedValueException $e) { throw new BadRequestException("Deserialization error: {$e->getMessage()}", 45896, $e); } diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonController.php b/src/Bundle/ChillPersonBundle/Controller/PersonController.php index 6247b92bb..1b79ba867 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonController.php @@ -222,9 +222,7 @@ final class PersonController extends AbstractController 'label' => 'Add the person', ])->add('createPeriod', SubmitType::class, [ 'label' => 'Add the person and create an accompanying period', - ])->add('createHousehold', SubmitType::class, [ - 'label' => 'Add the person and create an household', - ]); // TODO createHousehold form action + ]); $form->handleRequest($request); diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php index 1e4d5022f..65a45c2e6 100644 --- a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php +++ b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php @@ -79,6 +79,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac $loader->load('services/serializer.yaml'); $loader->load('services/security.yaml'); $loader->load('services/doctrineEventListener.yaml'); + $loader->load('services/accompanyingPeriodConsistency.yaml'); if ($container->getParameter('chill_person.accompanying_period') !== 'hidden') { $loader->load('services/exports_accompanying_period.yaml'); diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php index d3e1b7f82..8a0cab301 100644 --- a/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php @@ -80,6 +80,7 @@ class Configuration implements ConfigurationInterface ->append($this->addFieldNode('memo')) ->append($this->addFieldNode('number_of_children')) ->append($this->addFieldNode('acceptEmail')) + ->append($this->addFieldNode('deathdate')) ->arrayNode('alt_names') ->defaultValue([]) ->arrayPrototype() diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php index 0e7b27cef..df4a5f5de 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php @@ -14,10 +14,12 @@ namespace Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\MainBundle\Doctrine\Model\TrackCreationInterface; use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface; use Chill\MainBundle\Entity\User; +use Chill\PersonBundle\AccompanyingPeriod\SocialIssueConsistency\AccompanyingPeriodLinkedWithSocialIssuesEntityInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\SocialWork\Result; use Chill\PersonBundle\Entity\SocialWork\SocialAction; +use Chill\PersonBundle\Entity\SocialWork\SocialIssue; use Chill\ThirdPartyBundle\Entity\ThirdParty; use DateTimeImmutable; use DateTimeInterface; @@ -28,458 +30,470 @@ use LogicException; use Symfony\Component\Serializer\Annotation as Serializer; use Symfony\Component\Validator\Constraints as Assert; - /** - * @ORM\Entity - * @ORM\Table(name="chill_person_accompanying_period_work") - * @Serializer\DiscriminatorMap( - * typeProperty="type", - * mapping={ - * "accompanying_period_work": AccompanyingPeriodWork::class - * } - * ) - */ - class AccompanyingPeriodWork implements TrackCreationInterface, TrackUpdateInterface - { - /** - * @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class) - * @Serializer\Groups({"read"}) - */ - private ?AccompanyingPeriod $accompanyingPeriod = null; - - /** - * @ORM\OneToMany( - * targetEntity=AccompanyingPeriodWorkEvaluation::class, - * mappedBy="accompanyingPeriodWork", - * cascade={"remove", "persist"}, - * orphanRemoval=true - * ) - * @Serializer\Groups({"read", "docgen:read"}) - * - * @internal /!\ the serialization for write evaluations is handled in `AccompanyingPeriodWorkDenormalizer` - */ - private Collection $accompanyingPeriodWorkEvaluations; - - /** - * @ORM\Column(type="datetime_immutable") - * @Serializer\Groups({"read", "docgen:read"}) - */ - private ?DateTimeImmutable $createdAt = null; - - /** - * @ORM\Column(type="boolean") - * @Serializer\Groups({"read", "docgen:read"}) - */ - private bool $createdAutomatically = false; - - /** - * @ORM\Column(type="text") - * @Serializer\Groups({"read", "docgen:read"}) - */ - private string $createdAutomaticallyReason = ''; - - /** - * @ORM\ManyToOne(targetEntity=User::class) - * @ORM\JoinColumn(nullable=false) - * @Serializer\Groups({"read", "docgen:read"}) - */ - private ?User $createdBy = null; - - /** - * @ORM\Column(type="date_immutable", nullable=true, options={"default": null}) - * @Serializer\Groups({"accompanying_period_work:create"}) - * @Serializer\Groups({"accompanying_period_work:edit"}) - * @Serializer\Groups({"read", "docgen:read"}) - * @Assert\GreaterThan(propertyPath="startDate", - * message="accompanying_course_work.The endDate should be greater than the start date" - * ) - */ - private ?DateTimeImmutable $endDate = null; - - /** - * @ORM\OneToMany( - * targetEntity=AccompanyingPeriodWorkGoal::class, - * mappedBy="accompanyingPeriodWork", - * cascade={"persist"}, - * orphanRemoval=true - * ) - * @Serializer\Groups({"read", "docgen:read"}) - * @Serializer\Groups({"accompanying_period_work:edit"}) - */ - private Collection $goals; - - /** - * @ORM\ManyToOne(targetEntity=ThirdParty::class) - * @Serializer\Groups({"read", "docgen:read"}) - * @Serializer\Groups({"accompanying_period_work:edit"}) - * - * In schema : traitant - */ - private ?ThirdParty $handlingThierParty = null; - - /** - * @ORM\Id - * @ORM\GeneratedValue - * @ORM\Column(type="integer") - * @Serializer\Groups({"read", "docgen:read"}) - */ - private ?int $id = null; - - /** - * @ORM\Column(type="text") - * @Serializer\Groups({"read", "accompanying_period_work:edit", "docgen:read"}) - */ - private string $note = ''; - - /** - * @ORM\ManyToMany(targetEntity=Person::class) - * @ORM\JoinTable(name="chill_person_accompanying_period_work_person") - * @Serializer\Groups({"read", "docgen:read"}) - * @Serializer\Groups({"accompanying_period_work:edit"}) - * @Serializer\Groups({"accompanying_period_work:create"}) - */ - private Collection $persons; - - /** - * @ORM\ManyToMany(targetEntity=Result::class, inversedBy="accompanyingPeriodWorks") - * @ORM\JoinTable(name="chill_person_accompanying_period_work_result") - * @Serializer\Groups({"read", "docgen:read"}) - * @Serializer\Groups({"accompanying_period_work:edit"}) - */ - private Collection $results; - - /** - * @ORM\ManyToOne(targetEntity=SocialAction::class) - * @Serializer\Groups({"read", "docgen:read"}) - * @Serializer\Groups({"accompanying_period_work:create"}) - */ - private ?SocialAction $socialAction = null; - - /** - * @ORM\Column(type="date_immutable") - * @Serializer\Groups({"accompanying_period_work:create"}) - * @Serializer\Groups({"accompanying_period_work:edit"}) - * @Serializer\Groups({"read", "docgen:read"}) - */ - private ?DateTimeImmutable $startDate = null; - - /** - * @ORM\ManyToMany(targetEntity=ThirdParty::class) - * @ORM\JoinTable(name="chill_person_accompanying_period_work_third_party") - * - * In schema : intervenants - * @Serializer\Groups({"read", "docgen:read"}) - * @Serializer\Groups({"accompanying_period_work:edit"}) - */ - private Collection $thirdParties; - - /** - * @ORM\Column(type="datetime_immutable") - * @Serializer\Groups({"read", "docgen:read"}) - */ - private ?DateTimeImmutable $updatedAt = null; - - /** - * @ORM\ManyToOne(targetEntity=User::class) - * @ORM\JoinColumn(nullable=false) - * @Serializer\Groups({"read", "docgen:read"}) - */ - private ?User $updatedBy = null; - - public function __construct() - { - $this->goals = new ArrayCollection(); - $this->results = new ArrayCollection(); - $this->thirdParties = new ArrayCollection(); - $this->persons = new ArrayCollection(); - $this->accompanyingPeriodWorkEvaluations = new ArrayCollection(); - } - - public function addAccompanyingPeriodWorkEvaluation(AccompanyingPeriodWorkEvaluation $evaluation): self - { - if (!$this->accompanyingPeriodWorkEvaluations->contains($evaluation)) { - $this->accompanyingPeriodWorkEvaluations[] = $evaluation; - $evaluation->setAccompanyingPeriodWork($this); - } - - return $this; - } - - public function addGoal(AccompanyingPeriodWorkGoal $goal): self - { - if (!$this->goals->contains($goal)) { - $this->goals[] = $goal; - $goal->setAccompanyingPeriodWork($this); - } - - return $this; - } - - public function addPerson(Person $person): self - { - if (!$this->persons->contains($person)) { - $this->persons[] = $person; - } - - return $this; - } - - public function addResult(Result $result): self - { - if (!$this->results->contains($result)) { - $this->results[] = $result; - } - - return $this; - } - - public function addThirdParty(ThirdParty $thirdParty): self - { - if (!$this->thirdParties->contains($thirdParty)) { - $this->thirdParties[] = $thirdParty; - } - - return $this; - } - - public function getAccompanyingPeriod(): ?AccompanyingPeriod - { - return $this->accompanyingPeriod; - } - - /** - * @return Collection - */ - public function getAccompanyingPeriodWorkEvaluations() - { - return $this->accompanyingPeriodWorkEvaluations; - } - - public function getCreatedAt(): ?DateTimeImmutable - { - return $this->createdAt; - } - - public function getCreatedAutomatically(): ?bool - { - return $this->createdAutomatically; - } - - public function getCreatedAutomaticallyReason(): ?string - { - return $this->createdAutomaticallyReason; - } - - public function getCreatedBy(): ?User - { - return $this->createdBy; - } - - public function getEndDate(): ?DateTimeInterface - { - return $this->endDate; - } - - /** - * @return AccompanyingPeriodWorkGoal[]|Collection - */ - public function getGoals(): Collection - { - return $this->goals; - } - - public function getHandlingThierParty(): ?ThirdParty - { - return $this->handlingThierParty; - } - - public function getId(): ?int - { - return $this->id; - } - - public function getNote(): ?string - { - return $this->note; - } - - public function getPersons(): Collection - { - return $this->persons; - } - - /** - * @return Collection|Result[] - */ - public function getResults(): Collection - { - return $this->results; - } - - public function getSocialAction(): ?SocialAction - { - return $this->socialAction; - } - - public function getStartDate(): ?DateTimeInterface - { - return $this->startDate; - } - - /** - * @return Collection|ThirdParty[] - */ - public function getThirdParties(): Collection - { - return $this->thirdParties; - } - - public function getThirdPartys(): Collection - { - return $this->getThirdParties(); - } - - public function getUpdatedAt(): ?DateTimeImmutable - { - return $this->updatedAt; - } - - public function getUpdatedBy(): ?User - { - return $this->updatedBy; - } - - public function removeAccompanyingPeriodWorkEvaluation(AccompanyingPeriodWorkEvaluation $evaluation): self - { - $this->accompanyingPeriodWorkEvaluations - ->removeElement($evaluation); - $evaluation->setAccompanyingPeriodWork(null); - - return $this; - } - - public function removeGoal(AccompanyingPeriodWorkGoal $goal): self - { - if ($this->goals->removeElement($goal)) { - // set the owning side to null (unless already changed) - if ($goal->getAccompanyingPeriodWork() === $this) { - $goal->setAccompanyingPeriodWork(null); - } - } - - return $this; - } - - public function removePerson(Person $person): self - { - $this->persons->removeElement($person); - - return $this; - } - - public function removeResult(Result $result): self - { - $this->results->removeElement($result); - - return $this; - } - - public function removeThirdParty(ThirdParty $thirdParty): self - { - $this->thirdParties->removeElement($thirdParty); - - return $this; - } - - /** - * Internal: you should use `$accompanyingPeriod->removeWork($work);` or - * `$accompanyingPeriod->addWork($work);`. - */ - public function setAccompanyingPeriod(?AccompanyingPeriod $accompanyingPeriod): self - { - if ($this->accompanyingPeriod instanceof AccompanyingPeriod - && $accompanyingPeriod !== $this->accompanyingPeriod) { - throw new LogicException('A work cannot change accompanyingPeriod'); - } - - $this->accompanyingPeriod = $accompanyingPeriod; - - return $this; - } - - public function setCreatedAt(DateTimeInterface $createdAt): self - { - $this->createdAt = $createdAt; - - return $this; - } - - public function setCreatedAutomatically(bool $createdAutomatically): self - { - $this->createdAutomatically = $createdAutomatically; - - return $this; - } - - public function setCreatedAutomaticallyReason(string $createdAutomaticallyReason): self - { - $this->createdAutomaticallyReason = $createdAutomaticallyReason; - - return $this; - } - - public function setCreatedBy(?User $createdBy): self - { - $this->createdBy = $createdBy; +/** + * @ORM\Entity + * @ORM\Table(name="chill_person_accompanying_period_work") + * @Serializer\DiscriminatorMap( + * typeProperty="type", + * mapping={ + * "accompanying_period_work": AccompanyingPeriodWork::class + * } + * ) + */ +class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterface, TrackCreationInterface, TrackUpdateInterface +{ + /** + * @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class) + * @Serializer\Groups({"read"}) + */ + private ?AccompanyingPeriod $accompanyingPeriod = null; + + /** + * @ORM\OneToMany( + * targetEntity=AccompanyingPeriodWorkEvaluation::class, + * mappedBy="accompanyingPeriodWork", + * cascade={"remove", "persist"}, + * orphanRemoval=true + * ) + * @Serializer\Groups({"read", "docgen:read"}) + * + * @internal /!\ the serialization for write evaluations is handled in `AccompanyingPeriodWorkDenormalizer` + */ + private Collection $accompanyingPeriodWorkEvaluations; + + /** + * @ORM\Column(type="datetime_immutable") + * @Serializer\Groups({"read", "docgen:read"}) + */ + private ?DateTimeImmutable $createdAt = null; + + /** + * @ORM\Column(type="boolean") + * @Serializer\Groups({"read", "docgen:read"}) + */ + private bool $createdAutomatically = false; + + /** + * @ORM\Column(type="text") + * @Serializer\Groups({"read", "docgen:read"}) + */ + private string $createdAutomaticallyReason = ''; + + /** + * @ORM\ManyToOne(targetEntity=User::class) + * @ORM\JoinColumn(nullable=false) + * @Serializer\Groups({"read", "docgen:read"}) + */ + private ?User $createdBy = null; + + /** + * @ORM\Column(type="date_immutable", nullable=true, options={"default": null}) + * @Serializer\Groups({"accompanying_period_work:create"}) + * @Serializer\Groups({"accompanying_period_work:edit"}) + * @Serializer\Groups({"read", "docgen:read"}) + * @Assert\GreaterThan(propertyPath="startDate", + * message="accompanying_course_work.The endDate should be greater than the start date" + * ) + */ + private ?DateTimeImmutable $endDate = null; + + /** + * @ORM\OneToMany( + * targetEntity=AccompanyingPeriodWorkGoal::class, + * mappedBy="accompanyingPeriodWork", + * cascade={"persist"}, + * orphanRemoval=true + * ) + * @Serializer\Groups({"read", "docgen:read"}) + * @Serializer\Groups({"accompanying_period_work:edit"}) + */ + private Collection $goals; + + /** + * @ORM\ManyToOne(targetEntity=ThirdParty::class) + * @Serializer\Groups({"read", "docgen:read"}) + * @Serializer\Groups({"accompanying_period_work:edit"}) + * + * In schema : traitant + */ + private ?ThirdParty $handlingThierParty = null; + + /** + * @ORM\Id + * @ORM\GeneratedValue + * @ORM\Column(type="integer") + * @Serializer\Groups({"read", "docgen:read"}) + */ + private ?int $id = null; + + /** + * @ORM\Column(type="text") + * @Serializer\Groups({"read", "accompanying_period_work:edit", "docgen:read"}) + */ + private string $note = ''; + + /** + * @ORM\ManyToMany(targetEntity=Person::class) + * @ORM\JoinTable(name="chill_person_accompanying_period_work_person") + * @Serializer\Groups({"read", "docgen:read"}) + * @Serializer\Groups({"accompanying_period_work:edit"}) + * @Serializer\Groups({"accompanying_period_work:create"}) + */ + private Collection $persons; + + /** + * @ORM\ManyToMany(targetEntity=Result::class, inversedBy="accompanyingPeriodWorks") + * @ORM\JoinTable(name="chill_person_accompanying_period_work_result") + * @Serializer\Groups({"read", "docgen:read"}) + * @Serializer\Groups({"accompanying_period_work:edit"}) + */ + private Collection $results; + + /** + * @ORM\ManyToOne(targetEntity=SocialAction::class) + * @Serializer\Groups({"read", "docgen:read"}) + * @Serializer\Groups({"accompanying_period_work:create"}) + */ + private ?SocialAction $socialAction = null; + + /** + * @ORM\Column(type="date_immutable") + * @Serializer\Groups({"accompanying_period_work:create"}) + * @Serializer\Groups({"accompanying_period_work:edit"}) + * @Serializer\Groups({"read", "docgen:read"}) + */ + private ?DateTimeImmutable $startDate = null; + + /** + * @ORM\ManyToMany(targetEntity=ThirdParty::class) + * @ORM\JoinTable(name="chill_person_accompanying_period_work_third_party") + * + * In schema : intervenants + * @Serializer\Groups({"read", "docgen:read"}) + * @Serializer\Groups({"accompanying_period_work:edit"}) + */ + private Collection $thirdParties; + + /** + * @ORM\Column(type="datetime_immutable") + * @Serializer\Groups({"read", "docgen:read"}) + */ + private ?DateTimeImmutable $updatedAt = null; + + /** + * @ORM\ManyToOne(targetEntity=User::class) + * @ORM\JoinColumn(nullable=false) + * @Serializer\Groups({"read", "docgen:read"}) + */ + private ?User $updatedBy = null; + + public function __construct() + { + $this->goals = new ArrayCollection(); + $this->results = new ArrayCollection(); + $this->thirdParties = new ArrayCollection(); + $this->persons = new ArrayCollection(); + $this->accompanyingPeriodWorkEvaluations = new ArrayCollection(); + } + + public function addAccompanyingPeriodWorkEvaluation(AccompanyingPeriodWorkEvaluation $evaluation): self + { + if (!$this->accompanyingPeriodWorkEvaluations->contains($evaluation)) { + $this->accompanyingPeriodWorkEvaluations[] = $evaluation; + $evaluation->setAccompanyingPeriodWork($this); + } + + return $this; + } + + public function addGoal(AccompanyingPeriodWorkGoal $goal): self + { + if (!$this->goals->contains($goal)) { + $this->goals[] = $goal; + $goal->setAccompanyingPeriodWork($this); + } + + return $this; + } + + public function addPerson(Person $person): self + { + if (!$this->persons->contains($person)) { + $this->persons[] = $person; + } + + return $this; + } + + public function addResult(Result $result): self + { + if (!$this->results->contains($result)) { + $this->results[] = $result; + } + + return $this; + } + + public function addThirdParty(ThirdParty $thirdParty): self + { + if (!$this->thirdParties->contains($thirdParty)) { + $this->thirdParties[] = $thirdParty; + } + + return $this; + } + + public function getAccompanyingPeriod(): ?AccompanyingPeriod + { + return $this->accompanyingPeriod; + } + + /** + * @return Collection + */ + public function getAccompanyingPeriodWorkEvaluations() + { + return $this->accompanyingPeriodWorkEvaluations; + } + + public function getCreatedAt(): ?DateTimeImmutable + { + return $this->createdAt; + } + + public function getCreatedAutomatically(): ?bool + { + return $this->createdAutomatically; + } + + public function getCreatedAutomaticallyReason(): ?string + { + return $this->createdAutomaticallyReason; + } + + public function getCreatedBy(): ?User + { + return $this->createdBy; + } + + public function getEndDate(): ?DateTimeInterface + { + return $this->endDate; + } + + /** + * @return AccompanyingPeriodWorkGoal[]|Collection + */ + public function getGoals(): Collection + { + return $this->goals; + } + + public function getHandlingThierParty(): ?ThirdParty + { + return $this->handlingThierParty; + } + + public function getId(): ?int + { + return $this->id; + } + + public function getNote(): ?string + { + return $this->note; + } + + public function getPersons(): Collection + { + return $this->persons; + } + + /** + * @return Collection|Result[] + */ + public function getResults(): Collection + { + return $this->results; + } + + public function getSocialAction(): ?SocialAction + { + return $this->socialAction; + } + + public function getSocialIssues(): Collection + { + return new ArrayCollection([$this->getSocialAction()->getIssue()]); + } + + public function getStartDate(): ?DateTimeInterface + { + return $this->startDate; + } + + /** + * @return Collection|ThirdParty[] + */ + public function getThirdParties(): Collection + { + return $this->thirdParties; + } + + public function getThirdPartys(): Collection + { + return $this->getThirdParties(); + } + + public function getUpdatedAt(): ?DateTimeImmutable + { + return $this->updatedAt; + } + + public function getUpdatedBy(): ?User + { + return $this->updatedBy; + } + + public function removeAccompanyingPeriodWorkEvaluation(AccompanyingPeriodWorkEvaluation $evaluation): self + { + $this->accompanyingPeriodWorkEvaluations + ->removeElement($evaluation); + $evaluation->setAccompanyingPeriodWork(null); + + return $this; + } + + public function removeGoal(AccompanyingPeriodWorkGoal $goal): self + { + if ($this->goals->removeElement($goal)) { + // set the owning side to null (unless already changed) + if ($goal->getAccompanyingPeriodWork() === $this) { + $goal->setAccompanyingPeriodWork(null); + } + } + + return $this; + } + + public function removePerson(Person $person): self + { + $this->persons->removeElement($person); + + return $this; + } + + public function removeResult(Result $result): self + { + $this->results->removeElement($result); + + return $this; + } + + public function removeSocialIssue(SocialIssue $issue): AccompanyingPeriodLinkedWithSocialIssuesEntityInterface + { + $this->getSocialIssues()->removeElement($issue); + + return $this; + } + + public function removeThirdParty(ThirdParty $thirdParty): self + { + $this->thirdParties->removeElement($thirdParty); + + return $this; + } + + /** + * Internal: you should use `$accompanyingPeriod->removeWork($work);` or + * `$accompanyingPeriod->addWork($work);`. + */ + public function setAccompanyingPeriod(?AccompanyingPeriod $accompanyingPeriod): self + { + if ($this->accompanyingPeriod instanceof AccompanyingPeriod + && $accompanyingPeriod !== $this->accompanyingPeriod) { + throw new LogicException('A work cannot change accompanyingPeriod'); + } + + $this->accompanyingPeriod = $accompanyingPeriod; + + return $this; + } + + public function setCreatedAt(DateTimeInterface $createdAt): self + { + $this->createdAt = $createdAt; + + return $this; + } - return $this; - } + public function setCreatedAutomatically(bool $createdAutomatically): self + { + $this->createdAutomatically = $createdAutomatically; - public function setEndDate(?DateTimeInterface $endDate = null): self - { - $this->endDate = $endDate; + return $this; + } + + public function setCreatedAutomaticallyReason(string $createdAutomaticallyReason): self + { + $this->createdAutomaticallyReason = $createdAutomaticallyReason; - return $this; - } + return $this; + } - public function setHandlingThierParty(?ThirdParty $handlingThierParty): self - { - $this->handlingThierParty = $handlingThierParty; + public function setCreatedBy(?User $createdBy): self + { + $this->createdBy = $createdBy; - return $this; - } + return $this; + } - public function setNote(string $note): self - { - $this->note = $note; + public function setEndDate(?DateTimeInterface $endDate = null): self + { + $this->endDate = $endDate; - return $this; - } + return $this; + } - public function setSocialAction(?SocialAction $socialAction): self - { - $this->socialAction = $socialAction; + public function setHandlingThierParty(?ThirdParty $handlingThierParty): self + { + $this->handlingThierParty = $handlingThierParty; - return $this; - } + return $this; + } - public function setStartDate(DateTimeInterface $startDate): self - { - $this->startDate = $startDate; + public function setNote(string $note): self + { + $this->note = $note; - return $this; - } + return $this; + } - public function setUpdatedAt(DateTimeInterface $datetime): TrackUpdateInterface - { - $this->updatedAt = $datetime; + public function setSocialAction(?SocialAction $socialAction): self + { + $this->socialAction = $socialAction; - return $this; - } + return $this; + } - public function setUpdatedBy(User $user): TrackUpdateInterface - { - $this->updatedBy = $user; + public function setStartDate(DateTimeInterface $startDate): self + { + $this->startDate = $startDate; - return $this; - } - } + return $this; + } + + public function setUpdatedAt(DateTimeInterface $datetime): TrackUpdateInterface + { + $this->updatedAt = $datetime; + + return $this; + } + + public function setUpdatedBy(User $user): TrackUpdateInterface + { + $this->updatedBy = $user; + + return $this; + } +} diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index fb34a779a..a3524d306 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -244,6 +244,8 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * @Assert\Date( * groups={"general", "creation"} * ) + * @Assert\GreaterThan(propertyPath="birthDate") + * @Assert\LessThanOrEqual("today") */ private ?DateTimeImmutable $deathdate = null; @@ -1774,7 +1776,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI return $this; } - public function setNumberOfChildren(int $numberOfChildren): self + public function setNumberOfChildren(?int $numberOfChildren): self { $this->numberOfChildren = $numberOfChildren; diff --git a/src/Bundle/ChillPersonBundle/Form/PersonType.php b/src/Bundle/ChillPersonBundle/Form/PersonType.php index de9b3bbb1..47baafe2b 100644 --- a/src/Bundle/ChillPersonBundle/Form/PersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/PersonType.php @@ -93,6 +93,7 @@ class PersonType extends AbstractType ]) ->add('numberOfChildren', IntegerType::class, [ 'required' => false, + 'attr' => ['min' => 0], ]); if ($this->configAltNamesHelper->hasAltNames()) { diff --git a/src/Bundle/ChillPersonBundle/Resources/public/chill/scss/badge.scss b/src/Bundle/ChillPersonBundle/Resources/public/chill/scss/badge.scss index 39dbb4e55..acf19205f 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/chill/scss/badge.scss +++ b/src/Bundle/ChillPersonBundle/Resources/public/chill/scss/badge.scss @@ -162,6 +162,13 @@ div.activity-list { } /* +* Specific badge rounded-pill */ - +.badge { + &.bg-person { + //@extend .$chill-ll-gray; + background-color: $chill-ll-gray; + color: $chill-green; + } +} diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js index 4eb6f2a33..8e4134205 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js @@ -22,9 +22,9 @@ const getUsers = () => { }; const getReferrersSuggested = (course) => { - const url = `/api/1.0/person/accompanying-course/${course.id}/referrers-suggested.json`; + const url = `/api/1.0/person/accompanying-course/${course.id}/referrers-suggested.json`; - return fetchResults(url); + return fetchResults(url); } /* diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated.vue index 26e74e944..3ea64bd67 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated.vue @@ -48,7 +48,7 @@
-
    +
    • {{ p.text }}
    • diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Referrer.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Referrer.vue index dad42a504..aa05fe872 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Referrer.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Referrer.vue @@ -20,7 +20,7 @@ diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js index 7e58ebba8..d4bb6a678 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js @@ -132,6 +132,10 @@ const appMessages = { sure_description: "Une fois le changement confirmé, il ne sera plus possible de le remettre à l'état de brouillon !", ok: "Confirmer le parcours" }, + action: { + choose_other_social_issue: "Veuillez choisir un autre problématique", + cancel: "Annuler", + }, // catch errors 'Error while updating AccompanyingPeriod Course.': "Erreur du serveur lors de la mise à jour du parcours d'accompagnement.", 'Error while retriving AccompanyingPeriod Course.': "Erreur du serveur lors du chargement du parcours d'accompagnement.", diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/App.vue index 7931a2a0d..e30c90d08 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/App.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/App.vue @@ -5,24 +5,47 @@
      -
      -

      {{ $t('pick_social_issue_linked_with_action') }}

      - -
      - {{ si.text }} +
      +

      {{ $t('pick_social_issue_linked_with_action') }}

      +
      + {{ si.text }} +
      +
      +
      + + +
      -

      {{ $t('pick_an_action') }}

      - +
      + +
      @@ -63,9 +86,9 @@
      • - +