From 34d645228621361c388acc9825a5a3d606ed2be0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 22 Jun 2021 15:31:56 +0200 Subject: [PATCH 01/13] fix: household api --- .../ChillPersonExtension.php | 99 +++++++++++++++---- 1 file changed, 79 insertions(+), 20 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php index 79dae3255..3b58bcadc 100644 --- a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php +++ b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php @@ -553,7 +553,6 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac 'methods' => [ Request::METHOD_GET => true, Request::METHOD_HEAD => true, - Request::METHOD_POST=> true, ] ], 'address' => [ @@ -567,25 +566,6 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac ], ] ], - [ - 'class' => \Chill\PersonBundle\Entity\Household\Household::class, - 'name' => 'household', - 'base_path' => '/api/1.0/person/household', - // TODO: acl - 'base_role' => 'ROLE_USER', - 'actions' => [ - '_entity' => [ - 'methods' => [ - Request::METHOD_GET => true, - Request::METHOD_HEAD => true, - ], - 'roles' => [ - Request::METHOD_GET => 'ROLE_USER', - Request::METHOD_HEAD => 'ROLE_USER', - ] - ], - ] - ], [ 'class' => \Chill\PersonBundle\Entity\SocialWork\SocialAction::class, 'name' => 'social_action', @@ -629,6 +609,85 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac ] ] ], + [ + 'class' => \Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork::class, + 'name' => 'accompanying_period_work', + 'base_path' => '/api/1.0/person/accompanying-course/work', + 'controller' => \Chill\PersonBundle\Controller\AccompanyingCourseWorkApiController::class, + // TODO: acl + 'base_role' => 'ROLE_USER', + 'actions' => [ + '_entity' => [ + 'methods' => [ + Request::METHOD_GET => true, + Request::METHOD_HEAD => true, + Request::METHOD_PATCH => true, + Request::METHOD_PUT => true, + ], + 'roles' => [ + Request::METHOD_GET => 'ROLE_USER', + Request::METHOD_HEAD => 'ROLE_USER', + Request::METHOD_PATCH => 'ROLE_USER', + Request::METHOD_PUT => 'ROLE_USER', + ] + ], + ] + ], + [ + 'class' => \Chill\PersonBundle\Entity\SocialWork\Result::class, + 'controller' => \Chill\PersonBundle\Controller\SocialWorkResultApiController::class, + 'name' => 'social_work_result', + 'base_path' => '/api/1.0/person/social-work/result', + 'base_role' => 'ROLE_USER', + 'actions' => [ + '_entity' => [ + 'methods' => [ + Request::METHOD_GET => true, + Request::METHOD_HEAD => true, + ], + 'roles' => [ + Request::METHOD_GET => 'ROLE_USER', + Request::METHOD_HEAD => 'ROLE_USER', + ] + ], + '_index' => [ + 'methods' => [ + Request::METHOD_GET => true, + Request::METHOD_HEAD => true, + ], + 'roles' => [ + Request::METHOD_GET => 'ROLE_USER', + Request::METHOD_HEAD => 'ROLE_USER', + ] + ], + 'by-social-action' => [ + 'single-collection' => 'collection', + 'path' => '/by-social-action/{id}.{_format}', + 'controller_action' => 'listBySocialAction', + 'methods' => [ + Request::METHOD_GET => true, + Request::METHOD_HEAD => true, + ], + 'roles' => [ + Request::METHOD_GET => 'ROLE_USER', + Request::METHOD_HEAD => 'ROLE_USER', + ] + ], + 'by-goal' => [ + 'single-collection' => 'collection', + 'path' => '/by-goal/{id}.{_format}', + 'controller_action' => 'listByGoal', + 'methods' => [ + Request::METHOD_GET => true, + Request::METHOD_HEAD => true, + ], + 'roles' => [ + Request::METHOD_GET => 'ROLE_USER', + Request::METHOD_HEAD => 'ROLE_USER', + ] + ], + ] + ], ] ]); } From b53f6af8d88394051a4b67d278a81ffcac14e260 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 22 Jun 2021 16:08:53 +0200 Subject: [PATCH 02/13] add api for getting goal and results by social action and goal --- .../AccompanyingCourseWorkApiController.php | 23 ++ .../AccompanyingCourseWorkController.php | 9 +- .../SocialWorkGoalApiController.php | 40 +++ .../SocialWorkResultApiController.php | 47 ++++ .../ChillPersonExtension.php | 42 +++ .../AccompanyingPeriodWork.php | 33 ++- .../AccompanyingPeriodWorkGoal.php | 21 ++ .../Entity/SocialWork/Goal.php | 14 + .../Entity/SocialWork/Result.php | 9 + .../Repository/SocialWork/GoalRepository.php | 79 +++++- .../SocialWork/ResultRepository.php | 122 ++++++++- .../ChillPersonBundle/chill.api.specs.yaml | 257 ++++++++++++++++++ .../ChillPersonBundle/config/services.yaml | 1 + .../config/services/controller.yaml | 15 + 14 files changed, 700 insertions(+), 12 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkApiController.php create mode 100644 src/Bundle/ChillPersonBundle/Controller/SocialWorkGoalApiController.php create mode 100644 src/Bundle/ChillPersonBundle/Controller/SocialWorkResultApiController.php diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkApiController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkApiController.php new file mode 100644 index 000000000..6263736b0 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkApiController.php @@ -0,0 +1,23 @@ +getMethod()) { + case Request::METHOD_PUT: + return [ 'groups' => [ 'accompanying_period_work:edit' ] ]; + } + } + + return parent::getContextForSerialization($action, $request, $_format, $entity); + } + +} diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php index 1a5ab3925..8cff8614c 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php @@ -3,6 +3,7 @@ namespace Chill\PersonBundle\Controller; use Chill\PersonBundle\Entity\AccompanyingPeriod; +use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Request; @@ -27,7 +28,7 @@ class AccompanyingCourseWorkController extends AbstractController * methods={"GET", "POST"} * ) */ - public function createWork(AccompanyingPeriod $period) + public function createWork(AccompanyingPeriod $period): Response { // TODO ACL @@ -49,4 +50,10 @@ class AccompanyingCourseWorkController extends AbstractController 'json' => $json ]); } + + public function editWork(AccompanyingPeriodWork $work): Response + { + // TODO ACL + + } } diff --git a/src/Bundle/ChillPersonBundle/Controller/SocialWorkGoalApiController.php b/src/Bundle/ChillPersonBundle/Controller/SocialWorkGoalApiController.php new file mode 100644 index 000000000..2e678a0d0 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Controller/SocialWorkGoalApiController.php @@ -0,0 +1,40 @@ +goalRepository = $goalRepository; + $this->paginator = $paginator; + } + + public function listBySocialAction(Request $request, SocialAction $action): Response + { + $totalItems = $this->goalRepository->countBySocialActionWithDescendants($action); + $paginator = $this->getPaginatorFactory()->create($totalItems); + + $entities = $this->goalRepository->findBySocialActionWithDescendants($action, ["id" => "ASC"], + $paginator->getItemsPerPage(), $paginator->getCurrentPageFirstItemNumber()); + + $model = new Collection($entities, $paginator); + + return $this->json($model, Response::HTTP_OK, [], [ "groups" => [ "read" ]]); + } + +} diff --git a/src/Bundle/ChillPersonBundle/Controller/SocialWorkResultApiController.php b/src/Bundle/ChillPersonBundle/Controller/SocialWorkResultApiController.php new file mode 100644 index 000000000..24902a163 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Controller/SocialWorkResultApiController.php @@ -0,0 +1,47 @@ +resultRepository = $resultRepository; + } + + public function listBySocialAction(Request $request, SocialAction $action): Response + { + $totalItems = $this->resultRepository->countBySocialActionWithDescendants($action); + $paginator = $this->getPaginatorFactory()->create($totalItems); + + $entities = $this->resultRepository->findBySocialActionWithDescendants($action, ["id" => "ASC"], + $paginator->getItemsPerPage(), $paginator->getCurrentPageFirstItemNumber()); + + $model = new Collection($entities, $paginator); + + return $this->json($model, Response::HTTP_OK, [], [ "groups" => [ "read" ]]); + } + + public function listByGoal(Request $request, Goal $goal): Response + { + $totalItems = $this->resultRepository->countByGoal($goal); + $paginator = $this->getPaginatorFactory()->create($totalItems); + + $entities = $this->resultRepository->findByGoal($goal, ["id" => "ASC"], + $paginator->getItemsPerPage(), $paginator->getCurrentPageFirstItemNumber()); + + $model = new Collection($entities, $paginator); + + return $this->json($model, Response::HTTP_OK, [], [ "groups" => [ "read" ]]); + } +} diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php index 3b58bcadc..b4116f47b 100644 --- a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php +++ b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php @@ -688,6 +688,48 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac ], ] ], + [ + 'class' => \Chill\PersonBundle\Entity\SocialWork\Goal::class, + 'controller' => \Chill\PersonBundle\Controller\SocialWorkGoalApiController::class, + 'name' => 'social_work_goal', + 'base_path' => '/api/1.0/person/social-work/goal', + 'base_role' => 'ROLE_USER', + 'actions' => [ + '_entity' => [ + 'methods' => [ + Request::METHOD_GET => true, + Request::METHOD_HEAD => true, + ], + 'roles' => [ + Request::METHOD_GET => 'ROLE_USER', + Request::METHOD_HEAD => 'ROLE_USER', + ] + ], + '_index' => [ + 'methods' => [ + Request::METHOD_GET => true, + Request::METHOD_HEAD => true, + ], + 'roles' => [ + Request::METHOD_GET => 'ROLE_USER', + Request::METHOD_HEAD => 'ROLE_USER', + ] + ], + 'by-social-action' => [ + 'single-collection' => 'collection', + 'path' => '/by-social-action/{id}.{_format}', + 'controller_action' => 'listBySocialAction', + 'methods' => [ + Request::METHOD_GET => true, + Request::METHOD_HEAD => true, + ], + 'roles' => [ + Request::METHOD_GET => 'ROLE_USER', + Request::METHOD_HEAD => 'ROLE_USER', + ] + ], + ] + ], ] ]); } diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php index 11570945e..d1d5ff002 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php @@ -38,13 +38,12 @@ use Symfony\Component\Validator\Constraints as Assert; /** * @ORM\Column(type="text") - * @Serializer\Groups({"read"}) + * @Serializer\Groups({"read", "accompanying_period_work:edit"}) */ private string $note = ""; /** * @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class) - * @Serializer\Groups({"read"}) */ private ?AccompanyingPeriod $accompanyingPeriod = null; @@ -83,13 +82,16 @@ use Symfony\Component\Validator\Constraints as Assert; /** * @ORM\Column(type="date_immutable") * @Serializer\Groups({"accompanying_period_work:create"}) + * @Serializer\Groups({"accompanying_period_work:edit"}) * @Serializer\Groups({"read"}) */ private \DateTimeImmutable $startDate; /** * @ORM\Column(type="date_immutable", nullable=true, options={"default":null}) - * @Serializer\Groups({"accompanying_period_work:create", "read"}) + * @Serializer\Groups({"accompanying_period_work:create"}) + * @Serializer\Groups({"accompanying_period_work:edit"}) + * @Serializer\Groups({"read"}) * @Assert\GreaterThan(propertyPath="startDate", * message="accompanying_course_work.The endDate should be greater than the start date" * ) @@ -99,6 +101,8 @@ use Symfony\Component\Validator\Constraints as Assert; /** * @ORM\ManyToOne(targetEntity=ThirdParty::class) * @Serializer\Groups({"read"}) + * @Serializer\Groups({"accompanying_period_work:create"}) + * @Serializer\Groups({"accompanying_period_work:edit"}) * * In schema : traitant */ @@ -115,13 +119,22 @@ use Symfony\Component\Validator\Constraints as Assert; private string $createdAutomaticallyReason = ""; /** - * @ORM\OneToMany(targetEntity=AccompanyingPeriodWorkGoal::class, mappedBy="accompanyingPeriodWork") + * @ORM\OneToMany( + * targetEntity=AccompanyingPeriodWorkGoal::class, + * mappedBy="accompanyingPeriodWork", + * cascade={"persist"}, + * orphanRemoval=true + * ) + * @Serializer\Groups({"read"}) + * @Serializer\Groups({"accompanying_period_work:edit"}) */ private Collection $goals; /** * @ORM\ManyToMany(targetEntity=Result::class, inversedBy="accompanyingPeriodWorks") * @ORM\JoinTable(name="chill_person_accompanying_period_work_result") + * @Serializer\Groups({"read"}) + * @Serializer\Groups({"accompanying_period_work:edit"}) */ private Collection $results; @@ -130,6 +143,8 @@ use Symfony\Component\Validator\Constraints as Assert; * @ORM\JoinTable(name="chill_person_accompanying_period_work_third_party") * * In schema : intervenants + * @Serializer\Groups({"read"}) + * @Serializer\Groups({"accompanying_period_work:edit"}) */ private Collection $thirdParties; @@ -255,7 +270,7 @@ use Symfony\Component\Validator\Constraints as Assert; return $this->endDate; } - public function setEndDate(\DateTimeInterface $endDate): self + public function setEndDate(?\DateTimeInterface $endDate = null): self { $this->endDate = $endDate; @@ -310,7 +325,7 @@ use Symfony\Component\Validator\Constraints as Assert; { if (!$this->goals->contains($goal)) { $this->goals[] = $goal; - $goal->setAccompanyingPeriodWork2($this); + $goal->setAccompanyingPeriodWork($this); } return $this; @@ -318,10 +333,10 @@ use Symfony\Component\Validator\Constraints as Assert; public function removeGoal(AccompanyingPeriodWorkGoal $goal): self { - if ($this->goals->removeElement($goal)) { + if ($this->goals->removeElement($goal)) { // set the owning side to null (unless already changed) - if ($goal->getAccompanyingPeriodWork2() === $this) { - $goal->setAccompanyingPeriodWork2(null); + if ($goal->getAccompanyingPeriodWork() === $this) { + $goal->setAccompanyingPeriodWork(null); } } diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkGoal.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkGoal.php index 955f9e3a1..d8cfb4875 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkGoal.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkGoal.php @@ -7,10 +7,17 @@ use Chill\PersonBundle\Entity\SocialWork\Result; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Serializer\Annotation as Serializer; /** * @ORM\Entity * @ORM\Table(name="chill_person_accompanying_period_work_goal") + * @Serializer\DiscriminatorMap( + * typeProperty="type", + * mapping={ + * "accompanying_period_work_goal":AccompanyingPeriodWorkGoal::class + * } + * ) */ class AccompanyingPeriodWorkGoal { @@ -18,11 +25,14 @@ class AccompanyingPeriodWorkGoal * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") + * @Serializer\Groups({"read"}) */ private $id; /** * @ORM\Column(type="text") + * @Serializer\Groups({"accompanying_period_work:edit"}) + * @Serializer\Groups({"read"}) */ private $note; @@ -33,12 +43,16 @@ class AccompanyingPeriodWorkGoal /** * @ORM\ManyToOne(targetEntity=Goal::class) + * @Serializer\Groups({"accompanying_period_work:edit"}) + * @Serializer\Groups({"read"}) */ private $goal; /** * @ORM\ManyToMany(targetEntity=Result::class, inversedBy="accompanyingPeriodWorkGoals") * @ORM\JoinTable(name="chill_person_accompanying_period_work_goal_result") + * @Serializer\Groups({"accompanying_period_work:edit"}) + * @Serializer\Groups({"read"}) */ private $results; @@ -71,6 +85,13 @@ class AccompanyingPeriodWorkGoal public function setAccompanyingPeriodWork(?AccompanyingPeriodWork $accompanyingPeriodWork): self { + if ($this->accompanyingPeriodWork instanceof AccompanyingPeriodWork + && $accompanyingPeriodWork !== $this->accompanyingPeriodWork + && $accompanyingPeriodWork !== null + ) { + throw new \LogicException("Change accompanying period work is not allowed"); + } + $this->accompanyingPeriodWork = $accompanyingPeriodWork; return $this; diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/Goal.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/Goal.php index 996fcf3eb..7ad301875 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/Goal.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/Goal.php @@ -5,10 +5,17 @@ namespace Chill\PersonBundle\Entity\SocialWork; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Serializer\Annotation as Serializer; /** * @ORM\Entity * @ORM\Table(name="chill_person_social_work_goal") + * @Serializer\DiscriminatorMap( + * typeProperty="type", + * mapping={ + * "social_work_goal":Goal::class + * } + * ) */ class Goal { @@ -16,11 +23,13 @@ class Goal * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") + * @Serializer\Groups({"read"}) */ private $id; /** * @ORM\Column(type="json") + * @Serializer\Groups({"read"}) */ private $title = []; @@ -46,6 +55,11 @@ class Goal $this->results = new ArrayCollection(); } + public function getId(): ?int + { + return $this->id; + } + public function getTitle(): array { return $this->title; diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/Result.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/Result.php index 37e5c2b18..42a4c0929 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/Result.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/Result.php @@ -7,10 +7,17 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkGoal; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Serializer\Annotation as Serializer; /** * @ORM\Entity * @ORM\Table(name="chill_person_social_work_result") + * @Serializer\DiscriminatorMap( + * typeProperty="type", + * mapping={ + * "social_work_result":Result::class + * } + * ) */ class Result { @@ -18,11 +25,13 @@ class Result * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") + * @Serializer\Groups({"read"}) */ private $id; /** * @ORM\Column(type="json") + * @Serializer\Groups({"read"}) */ private $title = []; diff --git a/src/Bundle/ChillPersonBundle/Repository/SocialWork/GoalRepository.php b/src/Bundle/ChillPersonBundle/Repository/SocialWork/GoalRepository.php index bd7c6a738..e6aac493f 100644 --- a/src/Bundle/ChillPersonBundle/Repository/SocialWork/GoalRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/SocialWork/GoalRepository.php @@ -3,10 +3,13 @@ namespace Chill\PersonBundle\Repository\SocialWork; use Chill\PersonBundle\Entity\SocialWork\Goal; +use Chill\PersonBundle\Entity\SocialWork\SocialAction; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; +use Doctrine\ORM\QueryBuilder; +use Doctrine\Persistence\ObjectRepository; -final class GoalRepository +final class GoalRepository implements ObjectRepository { private EntityRepository $repository; @@ -14,4 +17,78 @@ final class GoalRepository { $this->repository = $entityManager->getRepository(Goal::class); } + + public function find($id) + { + return $this->repository->find($id); + } + + public function findAll() + { + return $this->repository->findAll(); + } + + public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null) + { + return $this->repository->findBy($criteria, $orderBy, $limit, $offset); + } + + public function findOneBy(array $criteria) + { + return $this->findOneBy($criteria); + } + + public function getClassName() + { + return Goal::class; + } + + /** + * + * @return Goal[] + */ + public function findBySocialActionWithDescendants(SocialAction $action, $orderBy = null, $limit = null, $offset = null): array + { + $qb = $this->buildQueryBySocialActionWithDescendants($action); + $qb->select('g'); + + foreach ($orderBy as $sort => $order) { + $qb->addOrderBy('g.'.$sort, $order); + } + + return $qb + ->setMaxResults($limit) + ->setFirstResult($offset) + ->getQuery() + ->getResult() + ; + } + + public function countBySocialActionWithDescendants(SocialAction $action): int + { + $qb = $this->buildQueryBySocialActionWithDescendants($action); + $qb->select('COUNT(g)'); + + return $qb + ->getQuery() + ->getSingleScalarResult() + ; + } + + protected function buildQueryBySocialActionWithDescendants(SocialAction $action): QueryBuilder + { + $actions = $action->getDescendantsWithThis(); + + $qb = $this->repository->createQueryBuilder('g'); + + $orx = $qb->expr()->orX(); + $i = 0; + foreach ($actions as $action) { + $orx->add(":action_{$i} MEMBER OF g.socialActions"); + $qb->setParameter("action_{$i}", $action); + } + $qb->where($orx); + + return $qb; + } } diff --git a/src/Bundle/ChillPersonBundle/Repository/SocialWork/ResultRepository.php b/src/Bundle/ChillPersonBundle/Repository/SocialWork/ResultRepository.php index 1c4d8d013..6dc6a887c 100644 --- a/src/Bundle/ChillPersonBundle/Repository/SocialWork/ResultRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/SocialWork/ResultRepository.php @@ -3,10 +3,14 @@ namespace Chill\PersonBundle\Repository\SocialWork; use Chill\PersonBundle\Entity\SocialWork\Result; +use Chill\PersonBundle\Entity\SocialWork\SocialAction; +use Chill\PersonBundle\Entity\SocialWork\Goal; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; +use Doctrine\ORM\QueryBuilder; +use Doctrine\Persistence\ObjectRepository; -final class ResultRepository +final class ResultRepository implements ObjectRepository { private EntityRepository $repository; @@ -14,4 +18,120 @@ final class ResultRepository { $this->repository = $entityManager->getRepository(Result::class); } + + public function find($id) + { + return $this->repository->find($id); + } + + public function findAll() + { + return $this->repository->findAll(); + } + + public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null) + { + return $this->repository->findBy($criteria, $orderBy, $limit, $offset); + } + + public function findOneBy(array $criteria) + { + return $this->findOneBy($criteria); + } + + public function getClassName() + { + return Result::class; + } + + /** + * + * @return Result[] + */ + public function findBySocialActionWithDescendants(SocialAction $action, $orderBy = null, $limit = null, $offset = null): array + { + $qb = $this->buildQueryBySocialActionWithDescendants($action); + $qb->select('r'); + + foreach ($orderBy as $sort => $order) { + $qb->addOrderBy('r.'.$sort, $order); + } + + return $qb + ->setMaxResults($limit) + ->setFirstResult($offset) + ->getQuery() + ->getResult() + ; + } + + public function countBySocialActionWithDescendants(SocialAction $action): int + { + $qb = $this->buildQueryBySocialActionWithDescendants($action); + $qb->select('COUNT(r)'); + + return $qb + ->getQuery() + ->getSingleScalarResult() + ; + } + + protected function buildQueryBySocialActionWithDescendants(SocialAction $action): QueryBuilder + { + $actions = $action->getDescendantsWithThis(); + + $qb = $this->repository->createQueryBuilder('r'); + + $orx = $qb->expr()->orX(); + $i = 0; + foreach ($actions as $action) { + $orx->add(":action_{$i} MEMBER OF r.socialActions"); + $qb->setParameter("action_{$i}", $action); + } + $qb->where($orx); + + return $qb; + } + protected function buildQueryByGoal(Goal $goal): QueryBuilder + { + $qb = $this->repository->createQueryBuilder('r'); + + $qb->where(":goal MEMBER OF r.goals") + ->setParameter('goal', $goal) + ; + + return $qb; + } + + /** + * @return Result[] + */ + public function findByGoal(Goal $goal, $orderBy = null, $limit = null, $offset = null): array + { + $qb = $this->buildQueryByGoal($goal); + + foreach ($orderBy as $sort => $order) { + $qb->addOrderBy('r.'.$sort, $order); + } + + return $qb + ->select('r') + ->setMaxResults($limit) + ->setFirstResult($offset) + ->getQuery() + ->getResult() + ; + } + + public function countByGoal(Goal $goal): int + { + $qb = $this->buildQueryByGoal($goal); + $qb->select('COUNT(r)'); + + return $qb + ->getQuery() + ->getSingleScalarResult() + ; + } } + diff --git a/src/Bundle/ChillPersonBundle/chill.api.specs.yaml b/src/Bundle/ChillPersonBundle/chill.api.specs.yaml index 4f2ed3dd1..0b02127d9 100644 --- a/src/Bundle/ChillPersonBundle/chill.api.specs.yaml +++ b/src/Bundle/ChillPersonBundle/chill.api.specs.yaml @@ -210,7 +210,67 @@ components: type: string enum: - 'household_position' + AccompanyingCourseWork: + type: object + properties: + id: + type: integer + type: + type: string + enum: + - 'accompanying_period_work' + note: + type: string + startDate: + $ref: "#/components/schemas/Date" + endDate: + $ref: "#/components/schemas/Date" + handlingThirdParty: + $ref: "#/components/schemas/ThirdPartyById" + goals: + type: array + items: + $ref: "#/components/schemas/AccompanyingCourseWorkGoal" + results: + type: array + items: + $ref: "#/components/schemas/SocialWorkResultById" + AccompanyingCourseWorkGoal: + type: object + properties: + id: + type: integer + type: + type: string + enum: + - 'accompanying_period_work_goal' + note: + type: string + goal: + $ref: '#/components/schemas/SocialWorkGoalById' + results: + type: array + items: + $ref: '#/components/schemas/SocialWorkGoalById' + SocialWorkResultById: + type: object + properties: + id: + type: integer + type: + type: string + enum: + - 'social_work_result' + SocialWorkGoalById: + type: object + properties: + id: + type: integer + type: + type: string + enum: + - 'social_work_goal' paths: /1.0/person/person/{id}.json: @@ -802,6 +862,7 @@ paths: post: tags: - person + - accompanying-course-work summary: "Add a work (AccompanyingPeriodwork) to the accompanying course" parameters: - name: id @@ -1026,3 +1087,199 @@ paths: description: "Unprocessable entity (validation errors)" 400: description: "transition cannot be applyed" + + + + /1.0/person/accompanying-course/work/{id}.json: + get: + tags: + - accompanying-course-work + summary: edit an existing accompanying course work + parameters: + - name: id + in: path + required: true + description: The accompanying course social work's id + schema: + type: integer + format: integer + minimum: 1 + responses: + 401: + description: "Unauthorized" + 404: + description: "Not found" + 200: + description: "OK" + 400: + description: "Bad Request" + + put: + tags: + - accompanying-course-work + summary: edit an existing accompanying course work + parameters: + - name: id + in: path + required: true + description: The accompanying course social work's id + schema: + type: integer + format: integer + minimum: 1 + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/AccompanyingCourseWork' + responses: + 401: + description: "Unauthorized" + 404: + description: "Not found" + 200: + description: "OK" + 422: + description: "Unprocessable entity (validation errors)" + 400: + description: "Bad Request" + + /1.0/person/social-work/result.json: + get: + tags: + - accompanying-course-work + summary: get a list of social work result + responses: + 401: + description: "Unauthorized" + 200: + description: "OK" + + /1.0/person/social-work/result/{id}.json: + get: + tags: + - accompanying-course-work + parameters: + - name: id + in: path + required: true + description: The result's id + schema: + type: integer + format: integer + minimum: 1 + responses: + 401: + description: "Unauthorized" + 404: + description: "Not found" + 200: + description: "OK" + 400: + description: "Bad Request" + + + /1.0/person/social-work/result/by-goal/{id}.json: + get: + tags: + - accompanying-course-work + parameters: + - name: id + in: path + required: true + description: The goal's id + schema: + type: integer + format: integer + minimum: 1 + responses: + 401: + description: "Unauthorized" + 404: + description: "Not found" + 200: + description: "OK" + 400: + description: "Bad Request" + + /1.0/person/social-work/result/by-social-action/{id}.json: + get: + tags: + - accompanying-course-work + parameters: + - name: id + in: path + required: true + description: The social action's id + schema: + type: integer + format: integer + minimum: 1 + responses: + 401: + description: "Unauthorized" + 404: + description: "Not found" + 200: + description: "OK" + 400: + description: "Bad Request" + + /1.0/person/social-work/goal.json: + get: + tags: + - accompanying-course-work + summary: get a list of social work goal + responses: + 401: + description: "Unauthorized" + 200: + description: "OK" + + /1.0/person/social-work/goal/{id}.json: + get: + tags: + - accompanying-course-work + parameters: + - name: id + in: path + required: true + description: The goal's id + schema: + type: integer + format: integer + minimum: 1 + responses: + 401: + description: "Unauthorized" + 404: + description: "Not found" + 200: + description: "OK" + 400: + description: "Bad Request" + + + /1.0/person/social-work/goal/by-social-action/{id}.json: + get: + tags: + - accompanying-course-work + parameters: + - name: id + in: path + required: true + description: The social action's id + schema: + type: integer + format: integer + minimum: 1 + responses: + 401: + description: "Unauthorized" + 404: + description: "Not found" + 200: + description: "OK" + 400: + description: "Bad Request" diff --git a/src/Bundle/ChillPersonBundle/config/services.yaml b/src/Bundle/ChillPersonBundle/config/services.yaml index 7f70a02dd..a23ba39b3 100644 --- a/src/Bundle/ChillPersonBundle/config/services.yaml +++ b/src/Bundle/ChillPersonBundle/config/services.yaml @@ -70,6 +70,7 @@ services: Chill\PersonBundle\Controller\: autowire: true + autoconfigure: true resource: '../Controller/' tags: ['controller.service_arguments'] diff --git a/src/Bundle/ChillPersonBundle/config/services/controller.yaml b/src/Bundle/ChillPersonBundle/config/services/controller.yaml index cbc77cce5..e7c34e78f 100644 --- a/src/Bundle/ChillPersonBundle/config/services/controller.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/controller.yaml @@ -60,3 +60,18 @@ services: $authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper' tags: ['controller.service_arguments'] + Chill\PersonBundle\Controller\AccompanyingCourseWorkApiController: + autowire: true + tags: ['controller.service_arguments'] + + Chill\PersonBundle\Controller\SocialWorkResultApiController: + autowire: true + tags: ['controller.service_arguments'] + + Chill\PersonBundle\Controller\SocialWorkGoalApiController: + autowire: true + tags: ['controller.service_arguments'] + + Chill\PersonBundle\Controller\HouseholdApiController: + autowire: true + tags: ['controller.service_arguments'] From 0754d20622a0f94d3adfbb24e33d1f734567e634 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 22 Jun 2021 22:59:34 +0200 Subject: [PATCH 03/13] fix form create + WIP form edit for Accompanying Period Work --- .../Resources/public/js/date.js | 4 +- .../AccompanyingCourseWorkController.php | 56 ++++++- .../AccompanyingPeriodWork.php | 4 +- .../Menu/AccompanyingCourseMenuBuilder.php | 7 + .../AccompanyingPeriodWorkRepository.php | 94 +++++++++++- .../AccompanyingCourseWorkCreate/App.vue | 3 +- .../AccompanyingCourseWorkCreate/store.js | 5 +- .../vuejs/AccompanyingCourseWorkEdit/App.vue | 89 +++++++++++ .../vuejs/AccompanyingCourseWorkEdit/index.js | 15 ++ .../vuejs/AccompanyingCourseWorkEdit/store.js | 139 ++++++++++++++++++ .../AccompanyingCourseWork/edit.html.twig | 24 +++ .../list_by_accompanying_period.html.twig | 28 ++++ .../ChillPersonBundle/chill.webpack.config.js | 1 + 13 files changed, 449 insertions(+), 20 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue create mode 100644 src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/index.js create mode 100644 src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js create mode 100644 src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/edit.html.twig create mode 100644 src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/list_by_accompanying_period.html.twig diff --git a/src/Bundle/ChillMainBundle/Resources/public/js/date.js b/src/Bundle/ChillMainBundle/Resources/public/js/date.js index e49a05972..ec66da770 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/js/date.js +++ b/src/Bundle/ChillMainBundle/Resources/public/js/date.js @@ -48,8 +48,8 @@ const ISOToDatetime = (str) => { let [cal, times] = str.split('T'), [year, month, date] = cal.split('-'), - [time, timezone] = cal.split(times.charAt(9)), - [hours, minutes, seconds] = cal.split(':') + [time, timezone] = times.split(times.charAt(8)), + [hours, minutes, seconds] = time.split(':') ; return new Date(year, month-1, date, hours, minutes, seconds); diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php index 8cff8614c..077fa15d7 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php @@ -2,6 +2,7 @@ namespace Chill\PersonBundle\Controller; +use Chill\MainBundle\Pagination\PaginatorFactory; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; @@ -10,22 +11,32 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Serializer\SerializerInterface; use Symfony\Component\Translation\TranslatorInterface; +use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository; class AccompanyingCourseWorkController extends AbstractController { private TranslatorInterface $trans; private SerializerInterface $serializer; + private AccompanyingPeriodWorkRepository $workRepository; + private PaginatorFactory $paginator; - public function __construct(TranslatorInterface $trans, SerializerInterface $serializer) - { + public function __construct( + TranslatorInterface $trans, + SerializerInterface $serializer, + AccompanyingPeriodWorkRepository $workRepository, + PaginatorFactory $paginator + ) { $this->trans = $trans; $this->serializer = $serializer; + $this->workRepository = $workRepository; + $this->paginator = $paginator; } /** * @Route( * "{_locale}/person/accompanying-period/{id}/work/new", - * methods={"GET", "POST"} + * name="chill_person_accompanying_period_work_new", + * methods={"GET"} * ) */ public function createWork(AccompanyingPeriod $period): Response @@ -51,9 +62,48 @@ class AccompanyingCourseWorkController extends AbstractController ]); } + /** + * @Route( + * "{_locale}/person/accompanying-period/work/{id}/edit", + * name="chill_person_accompanying_period_work_edit", + * methods={"GET"} + * ) + */ public function editWork(AccompanyingPeriodWork $work): Response { // TODO ACL + $json = $this->serializer->normalize($work, 'json', [ "groups" => [ "read" ] ]); + return $this->render('@ChillPerson/AccompanyingCourseWork/edit.html.twig', [ + 'accompanyingCourse' => $work->getAccompanyingPeriod(), + 'work' => $work, + 'json' => $json + ]); + } + /** + * @Route( + * "{_locale}/person/accompanying-period/{id}/work", + * name="chill_person_accompanying_period_work_list", + * methods={"GET"} + * ) + */ + public function listWorkByAccompanyingPeriod(AccompanyingPeriod $period): Response + { + // TODO ACL + $totalItems = $this->workRepository->countByAccompanyingPeriod($period); + $paginator = $this->paginator->create($totalItems); + + $works = $this->workRepository->findByAccompanyingPeriod( + $period, + ['startDate' => 'DESC', 'endDate' => 'DESC'], + $paginator->getItemsPerPage(), + $paginator->getCurrentPageFirstItemNumber() + ); + + return $this->render('@ChillPerson/AccompanyingCourseWork/list_by_accompanying_period.html.twig', [ + 'accompanyingCourse' => $period, + 'works' => $works, + 'paginator' => $paginator + ]); } } diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php index d1d5ff002..b42242a5b 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php @@ -49,7 +49,8 @@ use Symfony\Component\Validator\Constraints as Assert; /** * @ORM\ManyToOne(targetEntity=SocialAction::class) - * @Serializer\Groups({"accompanying_period_work:create", "read"}) + * @Serializer\Groups({"read"}) + * @Serializer\Groups({"accompanying_period_work:create"}) */ private ?SocialAction $socialAction = null; @@ -101,7 +102,6 @@ use Symfony\Component\Validator\Constraints as Assert; /** * @ORM\ManyToOne(targetEntity=ThirdParty::class) * @Serializer\Groups({"read"}) - * @Serializer\Groups({"accompanying_period_work:create"}) * @Serializer\Groups({"accompanying_period_work:edit"}) * * In schema : traitant diff --git a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php index 49543c42d..b946f3f89 100644 --- a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php @@ -60,6 +60,13 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface 'accompanying_period_id' => $period->getId() ]]) ->setExtras(['order' => 30]); + + $menu->addChild($this->translator->trans('Accompanying Course Actions'), [ + 'route' => 'chill_person_accompanying_period_work_list', + 'routeParameters' => [ + 'id' => $period->getId() + ]]) + ->setExtras(['order' => 40]); } diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php index 5d455b617..872feebbe 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php @@ -3,16 +3,12 @@ namespace Chill\PersonBundle\Repository\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; +use Doctrine\Persistence\ObjectRepository; -/** - * @method AccompanyingPeriodWork|null find($id, $lockMode = null, $lockVersion = null) - * @method AccompanyingPeriodWork|null findOneBy(array $criteria, array $orderBy = null) - * @method AccompanyingPeriodWork[] findAll() - * @method AccompanyingPeriodWork[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ -final class AccompanyingPeriodWorkRepository +final class AccompanyingPeriodWorkRepository implements ObjectRepository { private EntityRepository $repository; @@ -20,4 +16,88 @@ final class AccompanyingPeriodWorkRepository { $this->repository = $entityManager->getRepository(AccompanyingPeriodWork::class); } + + public function find($id): ?AccompanyingPeriodWork + { + return $this->repository->find($id); + } + + public function findAll(): array + { + return $this->repository->findAll(); + } + + public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array + { + return $this->repository->findBy($criteria, $orderBy, $limit, $offset); + } + + public function findOneBy(array $criteria): ?AccompanyingPeriodWork + { + return $this->findOneBy($criteria); + } + + public function getClassName() + { + return AccompanyingPeriodWork::class; + } + + /** + * + * @return AccompanyingPeriodWork[] + */ + public function findByAccompanyingPeriod(AccompanyingPeriod $period, $orderBy = null, $limit = null, $offset = null): array + { + return $this->repository->findByAccompanyingPeriod($period, $orderBy, $limit, $offset); + } + + public function countByAccompanyingPeriod(AccompanyingPeriod $period): int + { + return $this->repository->countByAccompanyingPeriod($period); + } + + public function toDelete() + { + $qb = $this->buildQueryBySocialActionWithDescendants($action); + $qb->select('g'); + + foreach ($orderBy as $sort => $order) { + $qb->addOrderBy('g.'.$sort, $order); + } + + return $qb + ->setMaxResults($limit) + ->setFirstResult($offset) + ->getQuery() + ->getResult() + ; + } + + public function countBySocialActionWithDescendants(SocialAction $action): int + { + $qb = $this->buildQueryBySocialActionWithDescendants($action); + $qb->select('COUNT(g)'); + + return $qb + ->getQuery() + ->getSingleScalarResult() + ; + } + + protected function buildQueryBySocialActionWithDescendants(SocialAction $action): QueryBuilder + { + $actions = $action->getDescendantsWithThis(); + + $qb = $this->repository->createQueryBuilder('g'); + + $orx = $qb->expr()->orX(); + $i = 0; + foreach ($actions as $action) { + $orx->add(":action_{$i} MEMBER OF g.socialActions"); + $qb->setParameter("action_{$i}", $action); + } + $qb->where($orx); + + return $qb; + } } diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/App.vue index 3c1f4b07a..7e8f2d5f0 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/App.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/App.vue @@ -13,8 +13,7 @@
-

{{ $t('pick_an_action') }}

- +

{{ $t('pick_an_action') }}

+

Hello

+ +
+
+ +

{{ work.socialAction.text }}

+
+
+ + +
+
+ + +
+
+ +
+
+
+

Objectifs

+

Résultats

+
+
+
+ + + + + + diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/index.js new file mode 100644 index 000000000..0ef2d0de4 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/index.js @@ -0,0 +1,15 @@ +import { createApp } from 'vue'; +import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n'; +import { store } from './store'; +import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n' +import App from './App.vue'; + +const i18n = _createI18n(personMessages); + +const app = createApp({ + template: ``, +}) +.use(store) +.use(i18n) +.component('app', App) +.mount('#accompanying_course_work_edit'); diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js new file mode 100644 index 000000000..f72badc91 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js @@ -0,0 +1,139 @@ +import { createStore } from 'vuex'; +import { datetimeToISO, ISOToDatetime } from 'ChillMainAssets/js/date.js'; +import { findSocialActionsBySocialIssue } from 'ChillPersonAssets/vuejs/_api/SocialWorkSocialAction.js'; +import { create } from 'ChillPersonAssets/vuejs/_api/AccompanyingCourseWork.js'; + +const debug = process.env.NODE_ENV !== 'production'; + +console.log(window.accompanyingCourseWork); + +const store = createStore({ + strict: debug, + state: { + work: window.accompanyingCourseWork, + startDate: ISOToDatetime(window.accompanyingCourseWork.startDate.datetime), + endDate: (window.accompanyingCourseWork.endDate !== null ? + ISOToDatetime(window.accompanyingCourseWork.endDate.datetime) : null), + note: window.accompanyingCourseWork.note, + goalsPicked: window.accompanyingCourseWork.goals, + resultsPicked: window.accompanyingCourseWork.results, + resultsForAction: [], + goalsForAction: [], + resultsForGoal: [], + errors: [], + }, + getters: { + socialAction(state) { + return state.work.socialAction; + }, + }, + mutations: { + setStartDate(state, date) { + state.startDate = date; + }, + setEndDate(state, date) { + state.endDate = date; + }, + setResultsForAction(state, results) { + console.log('set results for action', results); + state.resultsForAction = results; + }, + setResultsForGoal(state, { goal, results }) { + console.log('set results for goal', results); + state.goalsForAction = goal; + for (let i in results) { + let r = results[i]; + r.goalId = goal.id; + console.log('adding result', r); + state.resultsForGoal.push(r); + } + }, + addErrors(state, errors) { + console.log('handling errors', errors); + for (let i in errors) { + state.push(errors[i]); + } + }, + setNote(state, note) { + state.note = note; + }, + }, + actions: { + getReachablesGoalsForAction({ getters, commit, dispatch }) { + console.log('getReachablesGoalsForAction'); + let + socialActionId = getters.socialAction.id, + url = `/api/1.0/person/social-work/goal/by-social-action/${socialActionId}.json` + ; + + console.log(url); + + window + .fetch( + url + ).then( response => { + if (response.ok) { + return response.json(); + } + throw { m: 'Error while retriving goal for social action', s: response.status, b: response.body }; + }).then( data => { + for (let i in data.results) { + dispatch('getReachablesResultsForGoal', data.results[i]); + } + }).catch( errors => { + commit('addErrors', errors); + }); + }, + getReachablesResultsForGoal({ commit }, goal) { + console.log('getReachablesResultsForGoal'); + let + url = `/api/1.0/person/social-work/result/by-goal/${goal.id}.json` + ; + + console.log(url); + + window.fetch(url) + .then(response => { + if (response.ok) { + return response.json(); + } + + throw { m: 'Error while retriving results for goal', s: response.status, b: response.body }; + }) + .then(data => { + console.log('data'); + commit('setResultsForGoal', { goal, results: data.results }); + }); + }, + getReachablesResultsForAction({ getters, commit }) { + console.log('getReachablesResultsForAction'); + let + socialActionId = getters.socialAction.id, + url = `/api/1.0/person/social-work/result/by-social-action/${socialActionId}.json` + ; + + console.log(url); + + window.fetch(url) + .then(response => { + if (response.ok) { + return response.json(); + } + + throw { m: 'Error while retriving results for social action', s: response.status, b: response.body }; + }) + .then(data => { + console.log('data retrived', data); + commit('setResultsForAction', data.results); + }); + }, + initAsync({ dispatch }) { + dispatch('getReachablesResultsForAction'); + dispatch('getReachablesGoalsForAction'); + }, + } +}); + +store.dispatch('initAsync'); + +export { store }; diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/edit.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/edit.html.twig new file mode 100644 index 000000000..e9fdbd3ce --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/edit.html.twig @@ -0,0 +1,24 @@ +{% extends '@ChillPerson/AccompanyingCourse/layout.html.twig' %} + +{% block title 'accompanying_course_work.Edit accompanying course work'|trans %} + + +{% block content %} +

{{ block('title') }}

+ +
+ +{% endblock %} + +{% block js %} + + + {{ encore_entry_script_tags('accompanying_course_work_edit') }} +{% endblock %} + +{% block css %} + {{ parent() }} + {{ encore_entry_link_tags('accompanying_course_work_edit') }} +{% endblock %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/list_by_accompanying_period.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/list_by_accompanying_period.html.twig new file mode 100644 index 000000000..86a7c5401 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/list_by_accompanying_period.html.twig @@ -0,0 +1,28 @@ +{% extends '@ChillPerson/AccompanyingCourse/layout.html.twig' %} + +{% block title 'accompanying_course_work.List accompanying course work'|trans %} + + +{% block content %} +

{{ block('title') }}

+ + + + + +{% endblock %} diff --git a/src/Bundle/ChillPersonBundle/chill.webpack.config.js b/src/Bundle/ChillPersonBundle/chill.webpack.config.js index b20aa004e..bc1bf0679 100644 --- a/src/Bundle/ChillPersonBundle/chill.webpack.config.js +++ b/src/Bundle/ChillPersonBundle/chill.webpack.config.js @@ -14,4 +14,5 @@ module.exports = function(encore, entries) encore.addEntry('vue_accourse', __dirname + '/Resources/public/vuejs/AccompanyingCourse/index.js'); encore.addEntry('household_edit_metadata', __dirname + '/Resources/public/modules/household_edit_metadata/index.js'); encore.addEntry('accompanying_course_work_create', __dirname + '/Resources/public/vuejs/AccompanyingCourseWorkCreate/index.js'); + encore.addEntry('accompanying_course_work_edit', __dirname + '/Resources/public/vuejs/AccompanyingCourseWorkEdit/index.js'); }; From 154fa4719d7a3bbcb9428da4f09d706e841b272f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 23 Jun 2021 17:46:51 +0200 Subject: [PATCH 04/13] add involved persons to accompanying period work --- .../AccompanyingPeriodWork.php | 33 +++++++++++++++++ .../AccompanyingCourseWorkCreate/App.vue | 37 ++++++++++++++++++- .../AccompanyingCourseWorkCreate/store.js | 33 ++++++++++++++--- .../migrations/Version20210623135043.php | 34 +++++++++++++++++ 4 files changed, 131 insertions(+), 6 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/migrations/Version20210623135043.php diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php index b42242a5b..5fd01acf3 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php @@ -4,6 +4,7 @@ namespace Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\SocialWork\Result; use Chill\PersonBundle\Entity\SocialWork\SocialAction; +use Chill\PersonBundle\Entity\Person; use Chill\MainBundle\Entity\User; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\ThirdPartyBundle\Entity\ThirdParty; @@ -148,11 +149,22 @@ use Symfony\Component\Validator\Constraints as Assert; */ private Collection $thirdParties; + /** + * + * @ORM\ManyToMany(targetEntity=Person::class) + * @ORM\JoinTable(name="chill_person_accompanying_period_work_person") + * @Serializer\Groups({"read"}) + * @Serializer\Groups({"accompanying_period_work:edit"}) + * @Serializer\Groups({"accompanying_period_work:create"}) + */ + private Collection $persons; + public function __construct() { $this->goals = new ArrayCollection(); $this->results = new ArrayCollection(); $this->thirdParties = new ArrayCollection(); + $this->persons = new ArrayCollection(); } public function getId(): ?int @@ -390,4 +402,25 @@ use Symfony\Component\Validator\Constraints as Assert; return $this; } + + public function getPersons(): Collection + { + return $this->persons; + } + + public function addPerson(Person $person): self + { + if (!$this->persons->contains($person)) { + $this->persons[] = $person; + } + + return $this; + } + + public function removePerson(Person $person): self + { + $this->persons->removeElement($person); + + return $this; + } } diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/App.vue index 7e8f2d5f0..96edce825 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/App.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/App.vue @@ -28,8 +28,19 @@

spinner

-
+
+

{{ $t('persons_involved') }}

+ +
    +
  • + + +
  • +
+
+ +

@@ -85,6 +96,14 @@ #picking { grid-area: picking; + + #persons { + ul { + padding: 0; + + list-style-type: none; + } + } } #start_date { @@ -105,6 +124,7 @@ import { mapState, mapActions, mapGetters } from 'vuex'; import VueMultiselect from 'vue-multiselect'; import { dateToISO, ISOToDate } from 'ChillMainAssets/js/date.js'; +import Person from 'ChillPersonAssets/vuejs/_components/Person/Person.vue'; const i18n = { messages: { @@ -115,6 +135,7 @@ const i18n = { pick_social_issue: "Choisir une problématique sociale", pick_an_action: "Choisir une action d'accompagnement", pick_social_issue_linked_with_action: "Indiquez la problématique sociale liée à l'action d'accompagnement", + persons_involved: "Usagers concernés", } } @@ -124,6 +145,7 @@ export default { name: 'App', components: { VueMultiselect, + Person, }, methods: { submit() { @@ -136,6 +158,7 @@ export default { 'socialIssues', 'socialActionsReachables', 'errors', + 'personsReachables', ]), ...mapGetters([ 'hasSocialIssuePicked', @@ -144,6 +167,18 @@ export default { 'isPostingWork', 'hasErrors', ]), + personsPicked: { + get() { + let s = this.$store.state.personsPicked.map(p => p.id); + console.log('persons picked', s); + + return s; + }, + set(v) { + console.log('persons picked', v); + this.$store.commit('setPersonsPickedIds', v); + } + }, socialIssuePicked: { get() { let s = this.$store.state.socialIssuePicked; diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/store.js index 8f0aed245..5efe3a6e9 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/store.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/store.js @@ -14,6 +14,10 @@ const store = createStore({ socialIssuePicked: null, socialActionsReachables: [], socialActionPicked: null, + personsPicked: window.accompanyingCourse.participations.filter(p => p.endDate == null) + .map(p => p.person), + personsReachables: window.accompanyingCourse.participations.filter(p => p.endDate == null) + .map(p => p.person), startDate: new Date(), endDate: null, isLoadingSocialActions: false, @@ -44,9 +48,17 @@ const store = createStore({ }, startDate: { datetime: datetimeToISO(state.startDate) - } + }, + persons: [] }; + for (let i in state.personsPicked) { + payload.persons.push({ + id: state.personsPicked[i].id, + type: 'person' + }); + } + if (null !== state.endDate) { payload.endDate = { datetime: datetimeToISO(state.endDate) @@ -71,12 +83,16 @@ const store = createStore({ state.socialActionPicked = socialAction; }, setSocialIssue(state, socialIssueId) { + console.log('set social issue', socialIssueId); if (socialIssueId === null) { state.socialIssuePicked = null; - return; + } else { + let mapped = state.socialIssues + .find(e => e.id === socialIssueId); + console.log('mapped', mapped); + state.socialIssuePicked = mapped; + console.log('social issue setted', state.socialIssuePicked); } - state.socialIssuePicked = state.socialIssues - .find(e => e.id === socialIssueId); }, setIsLoadingSocialActions(state, s) { state.isLoadingSocialActions = s; @@ -90,6 +106,11 @@ const store = createStore({ setEndDate(state, date) { state.endDate = date; }, + setPersonsPickedIds(state, ids) { + console.log('persons ids', ids); + state.personsPicked = state.personsReachables + .filter(p => ids.includes(p.id)) + }, addErrors(state, { errors, cancel_posting }) { console.log('add errors', errors); state.errors = errors; @@ -103,8 +124,10 @@ const store = createStore({ console.log('pick social issue'); commit('setIsLoadingSocialActions', true); - commit('setSocialIssue', null); + commit('setSocialAction', null); commit('setSocialActionsReachables', []); + commit('setSocialIssue', null); + findSocialActionsBySocialIssue(socialIssueId).then( (response) => { diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20210623135043.php b/src/Bundle/ChillPersonBundle/migrations/Version20210623135043.php new file mode 100644 index 000000000..d7f2f4ccc --- /dev/null +++ b/src/Bundle/ChillPersonBundle/migrations/Version20210623135043.php @@ -0,0 +1,34 @@ +addSql("CREATE TABLE chill_person_accompanying_period_work_person (accompanyingperiodwork_id INT NOT NULL, person_id INT NOT NULL, PRIMARY KEY(accompanyingperiodwork_id, person_id))"); + $this->addSql("CREATE INDEX IDX_615F494CB99F6060 ON chill_person_accompanying_period_work_person (accompanyingperiodwork_id)"); + $this->addSql("CREATE INDEX IDX_615F494C217BBB47 ON chill_person_accompanying_period_work_person (person_id)"); + $this->addSql("ALTER TABLE chill_person_accompanying_period_work_person ADD CONSTRAINT FK_615F494CB99F6060 FOREIGN KEY (accompanyingperiodwork_id) REFERENCES chill_person_accompanying_period_work (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE"); + $this->addSql("ALTER TABLE chill_person_accompanying_period_work_person ADD CONSTRAINT FK_615F494C217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE"); + + } + + public function down(Schema $schema): void + { + $this->addSql("DROP TABLE chill_person_accompanying_period_work_person"); + } +} From 5a4a0a3617794d0635e51298a5f15c3e1eaff7af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 23 Jun 2021 21:26:36 +0200 Subject: [PATCH 05/13] add results for actions in course edit form --- .../vuejs/AccompanyingCourseWorkEdit/App.vue | 73 ++++++++++++++++-- .../_components/AddResult.vue | 76 +++++++++++++++++++ .../vuejs/AccompanyingCourseWorkEdit/store.js | 9 +++ 3 files changed, 151 insertions(+), 7 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/_components/AddResult.vue diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue index f46c36d03..3ef3b3390 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue @@ -2,30 +2,41 @@

Hello

-
+

{{ work.socialAction.text }}

-
+
-
+
-
+
-
+

Objectifs

Résultats

+ + + +
+
+ {{ $t('results_without_objective') }} +
+
+ +
+
@@ -33,20 +44,64 @@ diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js index f72badc91..0e9e30897 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/store.js @@ -26,6 +26,9 @@ const store = createStore({ socialAction(state) { return state.work.socialAction; }, + hasResultsForAction(state) { + return state.resultsForAction.length > 0; + } }, mutations: { setStartDate(state, date) { @@ -48,6 +51,12 @@ const store = createStore({ state.resultsForGoal.push(r); } }, + addResultPicked(state, result) { + state.resultsPicked.push(result); + }, + removeResultPicked(state, result) { + state.resultsPicked = state.resultsPicked.filter(r => r.id !== result.id); + }, addErrors(state, errors) { console.log('handling errors', errors); for (let i in errors) { From ac4cf43753c0e36d851d736bd16194cfc2e50916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 23 Jun 2021 22:40:11 +0200 Subject: [PATCH 06/13] add goals to work, and add results for each goal --- .../vuejs/AccompanyingCourseWorkEdit/App.vue | 57 ++++++++++++++++++- .../_components/AddResult.vue | 40 ++++++++++++- .../vuejs/AccompanyingCourseWorkEdit/store.js | 39 ++++++++++++- 3 files changed, 130 insertions(+), 6 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue index 3ef3b3390..feee033e4 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue @@ -27,8 +27,7 @@

Résultats

- - +
{{ $t('results_without_objective') }} @@ -37,6 +36,38 @@
+ + +
+
+ + + {{ g.title.fr }} + +
+
+ +
+
+ + +
+
+
+
    +
  • + + {{ g.title.fr }} +
  • +
+
+
+ + {{ $t('add_objective') }} +
+
+
+
@@ -106,12 +137,14 @@ export default { data() { return { editor: ClassicEditor, + showAddObjective: false, }; }, computed: { ...mapState([ 'work', 'resultsForAction', + 'goalsPicked', ]), ...mapGetters([ 'hasResultsForAction', @@ -142,6 +175,26 @@ export default { this.$store.mutate('setNote', note); } }, + availableForCheckGoal() { + let pickedIds = this.$store.state.goalsPicked.map(g => g.id); + console.log('pickeds goals id', pickedIds); + console.log(this.$store.state.goalsForAction); + + return this.$store.state.goalsForAction.filter(g => !pickedIds.includes(g.id)); + }, + }, + methods: { + toggleAddObjective() { + this.showAddObjective = !this.showAddObjective; + }, + addGoal(g) { + console.log('add Goal', g); + this.$store.commit('addGoal', g); + }, + removeGoal(g) { + console.log('remove goal', g); + this.$store.commit('removeGoal', g); + }, } }; diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/_components/AddResult.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/_components/AddResult.vue index ed86724d2..d56a287a8 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/_components/AddResult.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/_components/AddResult.vue @@ -1,5 +1,5 @@ diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/list_by_accompanying_period.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/list_by_accompanying_period.html.twig index 86a7c5401..ec5279759 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/list_by_accompanying_period.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/list_by_accompanying_period.html.twig @@ -6,15 +6,78 @@ {% block content %}

{{ block('title') }}

- +
+ {% for w in works %} +
+
+

{{ 'accompanying_course_work.action'|trans }}

+

+ {{ w.socialAction|chill_entity_render_box({ 'no-badge': true }) }} +

+
+ +
+
    +
  • + {{ 'accompanying_course_work.create_date'|trans }} +
  • +
+
+ + {% if w.results|length > 0 %} +
+
+ {{ 'accompanying_course_work.results without objective'|trans }} +
+
+

{{ 'accompanying_course_work.goal'|trans }}

+
    + {% for r in w.results %} +
  • {{ r.title|localize_translatable_string }}
  • + {% endfor %} +
+
+
+ {% endif %} + + {% if w.goals|length > 0 %} +
+ {% for g in w.goals %} +
+

{{ 'accompanying_course_work.goal'|trans }}

+

{{ g.goal.title|localize_translatable_string }}

+
+
+ {% if g.results|length == 0 %} +

{{ 'accompanying_course_work.no_results'|trans }}

+ {% else %} +

{{ 'accompanying_course_work.result'|trans }}

+
    + {% for r in g.results %} +
  • {{ r.title|localize_translatable_string }}
  • + {% endfor %} +
+ {% endif %} +
+ {% endfor %} +
+ {% endif %} + + + +
+ {% else %} +

{{ 'accompanying_course_work.No work'|trans }}

+ {% endfor %} +
  • @@ -26,3 +89,9 @@
{% endblock %} + + +{% block css %} + {{ parent() }} + {{ encore_entry_link_tags('accompanying_course_work_list') }} +{% endblock %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Entity/social_action.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Entity/social_action.html.twig index 246ddd1ea..858643e95 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Entity/social_action.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Entity/social_action.html.twig @@ -1,6 +1,6 @@ {% set reversed_parents = parents|reverse %}
-
    -
  • - {{ 'accompanying_course_work.create_date'|trans }} +
      +
    • +
      + {{ w.createdAt|format_date('long') }} +
      +
      + {{ 'accompanying_course_work.create_date'|trans }} +
      +
    • +
    • +
      + {{ w.startDate|format_date('long') }} +
      +
      + {{ 'accompanying_course_work.start_date'|trans }} +
      +
    • +
    • +
      + {{ w.endDate|format_date('long') }} +
      +
      + {{ 'accompanying_course_work.end_date'|trans }} +
{% if w.results|length > 0 %} -
+
- {{ 'accompanying_course_work.results without objective'|trans }} +

{{ 'accompanying_course_work.goal'|trans }}

+

{{ 'accompanying_course_work.results without objective'|trans }}

-

{{ 'accompanying_course_work.goal'|trans }}

-
    +

    {{ 'accompanying_course_work.results'|trans }}

    +
      {% for r in w.results %} -
    • {{ r.title|localize_translatable_string }}
    • +
    • {{ r.title|localize_translatable_string }}
    • {% endfor %}
@@ -41,35 +63,40 @@ {% endif %} {% if w.goals|length > 0 %} -
- {% for g in w.goals %} -
+ {% for g in w.goals %} +
+

{{ 'accompanying_course_work.goal'|trans }}

-

{{ g.goal.title|localize_translatable_string }}

+

{{ g.goal.title|localize_translatable_string }}

-
+
{% if g.results|length == 0 %} +

{{ 'accompanying_course_work.results'|trans }}

{{ 'accompanying_course_work.no_results'|trans }}

{% else %} -

{{ 'accompanying_course_work.result'|trans }}

-
    +

    {{ 'accompanying_course_work.results'|trans }}

    +
      {% for r in g.results %} -
    • {{ r.title|localize_translatable_string }}
    • +
    • {{ r.title|localize_translatable_string }}
    • {% endfor %}
    {% endif %}
- {% endfor %} -
+
+ {% endfor %} {% endif %} +
+ {{ 'Last updated by'|trans}}: {{ w.updatedBy|chill_entity_render_box }}, {{ w.updatedAt|format_datetime('long', 'short') }} +
+ diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index d34bd76b7..8397c3fa7 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -339,7 +339,9 @@ accompanying_course_work: action: Action create_date: Date de création start_date: Date de début - results without objective: Résultats - orientation sans objectifs - motifs - dispositifs - no_result: Aucun résultat - orientation - result: Résultat - orientation - goal: Objectifs - motifs - dispositifs + end_date: Date de fin + results without objective: Aucun objectif - motif - dispositif + no_results: Aucun résultat - orientation + results: Résultats - orientations + goal: Objectif - motif - dispositif + From 25f2d170974cbf6839cba20e5d52d871bd48f679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 25 Jun 2021 21:34:36 +0200 Subject: [PATCH 13/13] documentation for api social actions --- .../ChillPersonBundle/chill.api.specs.yaml | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/src/Bundle/ChillPersonBundle/chill.api.specs.yaml b/src/Bundle/ChillPersonBundle/chill.api.specs.yaml index 0b02127d9..6c7f1ef62 100644 --- a/src/Bundle/ChillPersonBundle/chill.api.specs.yaml +++ b/src/Bundle/ChillPersonBundle/chill.api.specs.yaml @@ -1144,6 +1144,65 @@ paths: description: "Unprocessable entity (validation errors)" 400: description: "Bad Request" + + /1.0/person/social/social-action.json: + get: + tags: + - accompanying-course-work + summary: get a list of social action + responses: + 401: + description: "Unauthorized" + 200: + description: "OK" + + /1.0/person/social/social-action/{id}.json: + get: + tags: + - accompanying-course-work + parameters: + - name: id + in: path + required: true + description: The social action's id + schema: + type: integer + format: integer + minimum: 1 + responses: + 401: + description: "Unauthorized" + 404: + description: "Not found" + 200: + description: "OK" + 400: + description: "Bad Request" + + + /1.0/person/social/social-action/by-social-issue/{id}.json: + get: + tags: + - accompanying-course-work + parameters: + - name: id + in: path + required: true + description: The social action's id + schema: + type: integer + format: integer + minimum: 1 + responses: + 401: + description: "Unauthorized" + 404: + description: "Not found" + 200: + description: "OK" + 400: + description: "Bad Request" + /1.0/person/social-work/result.json: get: