Merge branch 'features/edit-accompanying-period-social-work' into 'master'

Features/edit accompanying period social work

See merge request Chill-Projet/chill-bundles!91
This commit is contained in:
Julien Fastré 2021-06-26 13:15:34 +00:00
commit a35f3363b2
39 changed files with 2431 additions and 72 deletions

View File

@ -35,6 +35,7 @@ use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\CallbackTransformer;
use Chill\PersonBundle\Form\DataTransformer\PersonToIdTransformer;
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
use Chill\PersonBundle\Templating\Entity\SocialActionRender;
class ActivityType extends AbstractType
{
@ -46,6 +47,10 @@ class ActivityType extends AbstractType
protected TranslatableStringHelper $translatableStringHelper;
protected SocialIssueRender $socialIssueRender;
protected SocialActionRender $socialActionRender;
protected array $timeChoices;
public function __construct (
@ -54,7 +59,8 @@ class ActivityType extends AbstractType
ObjectManager $om,
TranslatableStringHelper $translatableStringHelper,
array $timeChoices,
SocialIssueRender $socialIssueRender
SocialIssueRender $socialIssueRender,
SocialActionRender $socialActionRender
) {
if (!$tokenStorage->getToken()->getUser() instanceof User) {
throw new \RuntimeException("you should have a valid user");
@ -66,6 +72,7 @@ class ActivityType extends AbstractType
$this->translatableStringHelper = $translatableStringHelper;
$this->timeChoices = $timeChoices;
$this->socialIssueRender = $socialIssueRender;
$this->socialActionRender = $socialActionRender;
}
public function buildForm(FormBuilderInterface $builder, array $options): void
@ -124,7 +131,7 @@ class ActivityType extends AbstractType
'required' => $activityType->isRequired('socialActions'),
'class' => SocialAction::class,
'choice_label' => function (SocialAction $socialAction) {
return $this->translatableStringHelper->localize($socialAction->getTitle());
return $this->socialActionRender->renderString($socialAction, []);
},
'multiple' => true,
'choices' => $accompanyingPeriod->getRecursiveSocialActions(),

View File

@ -32,6 +32,7 @@ services:
- "@chill.main.helper.translatable_string"
- "%chill_activity.form.time_duration%"
- '@Chill\PersonBundle\Templating\Entity\SocialIssueRender'
- '@Chill\PersonBundle\Templating\Entity\SocialActionRender'
tags:
- { name: form.type, alias: chill_activitybundle_activity }

View File

@ -8,6 +8,11 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Validator\Validator\ValidatorInterface;
use Chill\MainBundle\Pagination\PaginatorFactory;
use Chill\MainBundle\Pagination\PaginatorInterface;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\MainBundle\CRUD\Resolver\Resolver;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Component\Translation\TranslatorInterface;
class AbstractCRUDController extends AbstractController
{
@ -248,4 +253,24 @@ class AbstractCRUDController extends AbstractController
{
return $this->get('validator');
}
/**
* @return array
*/
public static function getSubscribedServices(): array
{
return \array_merge(
parent::getSubscribedServices(),
[
'chill_main.paginator_factory' => PaginatorFactory::class,
'translator' => TranslatorInterface::class,
AuthorizationHelper::class => AuthorizationHelper::class,
EventDispatcherInterface::class => EventDispatcherInterface::class,
Resolver::class => Resolver::class,
SerializerInterface::class => SerializerInterface::class,
'validator' => ValidatorInterface::class,
]
);
}
}

View File

@ -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);

View File

@ -0,0 +1,23 @@
<?php
namespace Chill\PersonBundle\Controller;
use Chill\MainBundle\CRUD\Controller\ApiController;
use Symfony\Component\HttpFoundation\Request;
class AccompanyingCourseWorkApiController extends ApiController
{
protected function getContextForSerialization(string $action, Request $request, string $_format, $entity): array
{
switch($action) {
case '_entity':
switch ($request->getMethod()) {
case Request::METHOD_PUT:
return [ 'groups' => [ 'accompanying_period_work:edit' ] ];
}
}
return parent::getContextForSerialization($action, $request, $_format, $entity);
}
}

View File

@ -2,32 +2,44 @@
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;
use Symfony\Component\HttpFoundation\Response;
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)
public function createWork(AccompanyingPeriod $period): Response
{
// TODO ACL
@ -49,4 +61,49 @@ class AccompanyingCourseWorkController extends AbstractController
'json' => $json
]);
}
/**
* @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
]);
}
}

View File

@ -0,0 +1,21 @@
<?php
namespace Chill\PersonBundle\Controller;
use Chill\MainBundle\CRUD\Controller\ApiController;
use Chill\MainBundle\Pagination\PaginatorInterface;
use Symfony\Component\HttpFoundation\Request;
class SocialIssueApiController extends ApiController
{
protected function customizeQuery(string $action, Request $request, $query): void
{
$query->where(
$query->expr()->orX(
$query->expr()->gt('e.desactivationDate', ':now'),
$query->expr()->isNull('e.desactivationDate')
)
);
$query->setParameter('now', new \DateTimeImmutable());
}
}

View File

@ -0,0 +1,40 @@
<?php
namespace Chill\PersonBundle\Controller;
use Chill\MainBundle\Pagination\PaginatorFactory;
use Chill\MainBundle\Serializer\Model\Collection;
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
use Chill\PersonBundle\Entity\SocialWork\Goal;
use Chill\PersonBundle\Repository\SocialWork\GoalRepository;
use Chill\MainBundle\CRUD\Controller\ApiController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class SocialWorkGoalApiController extends ApiController
{
private GoalRepository $goalRepository;
private PaginatorFactory $paginator;
public function __construct(GoalRepository $goalRepository, PaginatorFactory $paginator)
{
$this->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" ]]);
}
}

View File

@ -0,0 +1,47 @@
<?php
namespace Chill\PersonBundle\Controller;
use Chill\MainBundle\Serializer\Model\Collection;
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
use Chill\PersonBundle\Entity\SocialWork\Goal;
use Chill\PersonBundle\Repository\SocialWork\ResultRepository;
use Chill\MainBundle\CRUD\Controller\ApiController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class SocialWorkResultApiController extends ApiController
{
private ResultRepository $resultRepository;
public function __construct(ResultRepository $resultRepository)
{
$this->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" ]]);
}
}

View File

@ -488,6 +488,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
[
'class' => \Chill\PersonBundle\Entity\SocialWork\SocialIssue::class,
'name' => 'social_work_social_issue',
'controller' => \Chill\PersonBundle\Controller\SocialIssueApiController::class,
'base_path' => '/api/1.0/person/social-work/social-issue',
'base_role' => 'ROLE_USER',
'actions' => [
@ -553,7 +554,6 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
'methods' => [
Request::METHOD_GET => true,
Request::METHOD_HEAD => true,
Request::METHOD_POST=> true,
]
],
'address' => [
@ -567,25 +567,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 +610,127 @@ 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',
]
],
]
],
[
'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',
]
],
]
],
]
]);
}

View File

@ -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;
@ -38,7 +39,7 @@ use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Column(type="text")
* @Serializer\Groups({"read"})
* @Serializer\Groups({"read", "accompanying_period_work:edit"})
*/
private string $note = "";
@ -50,7 +51,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;
@ -83,13 +85,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 +104,7 @@ use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\ManyToOne(targetEntity=ThirdParty::class)
* @Serializer\Groups({"read"})
* @Serializer\Groups({"accompanying_period_work:edit"})
*
* In schema : traitant
*/
@ -115,13 +121,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,14 +145,27 @@ 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;
/**
*
* @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
@ -255,7 +283,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 +338,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 +346,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);
}
}
@ -375,4 +403,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;
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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 = [];

View File

@ -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]);
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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()
;
}
}

View File

@ -0,0 +1 @@
require('./index.scss');

View File

@ -0,0 +1,96 @@
#accompanying_course_work_list {
.item {
margin-bottom: 1.5rem;
padding: 1rem;
border: 1px solid gray;
.title_label {
display: block;
margin: 0;
font-variant-caps: small-caps;
+ * {
margin-top: 0;
}
}
.objective_results {
display: grid;
grid-template-areas:
"obj res"
;
grid-template-columns: 50%;
column-gap: 1rem;
padding: 0.3rem;
.obj {
grid-area: obj;
}
.res {
grid-area: res;
ul.result_list {
list-style-type: none;
padding: 0;
}
}
}
.objective_results:nth-child(2n+2) {
background-color: var(--chill-llight-gray);
}
}
.updatedBy {
margin-top: 1rem;
text-align: right;
font-size: 0.8rem;
font-style: italic;
}
}
ul.timeline {
display: flex;
align-items: center;
justify-content: center;
padding: 0;
list-style-type: none;
> li {
min-width: 210px;
div.date {
margin-bottom: 20px;
display: flex;
flex-direction: column;
align-items: center;
}
div.label {
display: flex;
flex-direction: column;
align-items: center;
padding: 0 40px;
border-top: 2px solid var(--chill-green);
&:before {
content: '';
display: inline-block;
position: relative;
width: 25px;
height: 25px;
background-color: white;
border-radius: 25px;
border: 1px solid #ddd;
top: -15px;
}
}
}
}

View File

@ -24,7 +24,6 @@ if (root === 'app') {
.use(i18n)
.component('app', App)
.mount('#accompanying-course');
});
}
@ -43,8 +42,7 @@ if (root === 'banner') {
.use(store)
.use(i18n)
.component('banner', Banner)
.mount('#accompanying-course');
.mount('#banner-accompanying-course');
});
}

View File

@ -13,8 +13,7 @@
</div>
<div v-if="hasSocialIssuePicked">
<h2>{{ $t('pick_an_action') }}</h2>
<h2>{{ $t('pick_an_action') }}</h2>
<vue-multiselect
v-model="socialActionPicked"
label="text"
@ -29,8 +28,19 @@
<div v-if="isLoadingSocialActions">
<p>spinner</p>
</div>
</div>
<div v-if="hasSocialActionPicked" id="persons">
<h2>{{ $t('persons_involved') }}</h2>
<ul>
<li v-for="p in personsReachables" :key="p.id">
<input type="checkbox" :value="p.id" v-model="personsPicked">
<person :person="p"></person>
</li>
</ul>
</div>
</div>
<div v-if="hasSocialActionPicked" id="start_date">
<p><label>{{ $t('startDate') }}</label> <input type="date" v-model="startDate" /></p>
</div>
@ -86,6 +96,14 @@
#picking {
grid-area: picking;
#persons {
ul {
padding: 0;
list-style-type: none;
}
}
}
#start_date {
@ -106,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: {
@ -116,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",
}
}
@ -125,6 +145,7 @@ export default {
name: 'App',
components: {
VueMultiselect,
Person,
},
methods: {
submit() {
@ -137,6 +158,7 @@ export default {
'socialIssues',
'socialActionsReachables',
'errors',
'personsReachables',
]),
...mapGetters([
'hasSocialIssuePicked',
@ -145,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;

View File

@ -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,
@ -38,15 +42,23 @@ const store = createStore({
buildPayloadCreate(state) {
let payload = {
type: 'accompanying_period_work',
social_action: {
socialAction: {
type: 'social_work_social_action',
id: state.socialActionPicked.id
},
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) => {
@ -144,9 +167,6 @@ const store = createStore({
commit('addErrors', { errors, cancel_posting: true });
}
});
},
},

View File

@ -0,0 +1,486 @@
<template>
<div id="workEditor">
<div id="title">
<label class="action_title_label">{{ $t('action_title') }}</label>
<p class="action_title">{{ work.socialAction.text }}</p>
</div>
<div id="startDate">
<label>{{ $t('startDate') }}</label>
<input type="date" v-model="startDate" />
</div>
<div id="endDate">
<label>{{ $t('endDate') }}</label>
<input type="date" v-model="endDate" />
</div>
<div id="comment">
<label>Commentaire</label>
<ckeditor
:editor="editor"
v-model="note"
tag-name="textarea"
></ckeditor>
</div>
<div id="objectives" class="objectives_list">
<div class="title" aria="hidden">
<div><h3>Motifs - objectifs - dispositifs</h3></div>
<div><h3>Orientations - résultats</h3></div>
</div>
<!-- results which are not attached to an objective -->
<div v-if="hasResultsForAction">
<div class="results_without_objective">
{{ $t('results_without_objective') }}
</div>
<div>
<add-result :availableResults="resultsForAction" destination="action"></add-result>
</div>
</div>
<!-- results which **are** attached to an objective -->
<div v-for="g in goalsPicked">
<div>
<div @click="removeGoal(g)" class="objective-title">
<i class="fa fa-times"></i>
{{ g.goal.title.fr }}
</div>
</div>
<div>
<add-result destination="goal" :goal="g.goal"></add-result>
</div>
</div>
<!-- box to add goal -->
<div class="add_goal">
<div>
<div v-if="showAddObjective">
<p>Motifs, objectifs et dispositifs disponibles pour ajout&nbsp;:</p>
<ul class="list-objectives">
<li v-for="g in availableForCheckGoal" @click="addGoal(g)" class="badge badge-primary">
<i class="fa fa-plus"></i>
{{ g.title.fr }}
</li>
</ul>
</div>
<ul class="record_actions">
<li>
<button @click="toggleAddObjective" class="sc-button bt-create">
Ajouter un objectif
</button>
</li>
</ul>
</div>
<div><!-- empty for results --></div>
</div>
</div>
<div id="persons">
<h2>{{ $t('persons_involved') }}</h2>
<ul>
<li v-for="p in personsReachables" :key="p.id">
<input type="checkbox" :value="p.id" v-model="personsPicked">
<person :person="p"></person>
</li>
</ul>
</div>
<div id="handlingThirdParty">
<h2>Tiers traitant</h2>
<div v-if="!hasHandlingThirdParty">
<p class="chill-no-data-statement">
Aucun tiers traitant
</p>
<ul class="record_actions">
<li>
<add-persons
buttonTitle="Indiquer un tiers traitant"
modalTitle="Choisir un tiers"
v-bind:key="handlingThirdPartyPicker.key"
v-bind:options="handlingThirdPartyPicker.options"
@addNewPersons="setHandlingThirdParty"
ref="handlingThirdPartyPicker"> <!-- to cast child method -->
</add-persons>
</li>
</ul>
</div>
<div v-else>
<p>{{ handlingThirdParty.text }}</p>
<show-address :address="handlingThirdParty.address"></show-address>
<ul class="record_actions">
<li>
<button class="sc-button bt-delete" @click="removeHandlingThirdParty">
Supprimer le tiers traitant
</button>
</li>
</ul>
</div>
</div>
<div id="thirdParties">
<h2>Tiers intervenants</h2>
<div v-if="!hasThirdParties">
<p class="chill-no-data-statement">Aucun tiers intervenant</p>
</div>
<div v-else>
<ul>
<li v-for="t in thirdParties">
<p>{{ t.text }}</p>
<show-address :address="t.address"></show-address>
<ul class="record_actions">
<button class="sc-button bt-delete" @click="removeThirdParty(t)"></button>
</ul>
</li>
</ul>
</div>
<ul class="record_actions">
<li>
<add-persons
buttonTitle="Ajouter des tiers"
modalTitle="Choisir des tiers"
v-bind:key="thirdPartyPicker.key"
v-bind:options="thirdPartyPicker.options"
@addNewPersons="addThirdParties"
ref="thirdPartyPicker"> <!-- to cast child method -->
</add-persons>
</li>
</ul>
</div>
<div id="errors" v-if="errors.length > 0">
<p>Veuillez corriger les erreurs suivantes:</p>
<ul>
<li v-for="e in errors">{{ e }}</li>
</ul>
</div>
</div>
<ul class="record_actions sticky-form-buttons">
<li v-if="!isPosting">
<button
class="sc-button bt-save"
@click="submit"
>
{{ $t('action.save') }}
</button>
</li>
<li v-if="isPosting">
<button
class="sc-button bt-save"
disabled
>
{{ $t('action.save') }}
</button>
</li>
</ul>
</template>
<style lang="scss">
#workEditor {
display: grid;
grid-template-areas:
"title title"
"startDate endDate"
"comment comment"
"objectives objectives"
"persons persons"
"handling handling"
"tparties tparties"
"errors errors"
;
grid-template-columns: 50%;
column-gap: 1rem;
#title {
grid-area: title;
.action_title_label {
margin-bottom: 0;
}
.action_title {
margin-top: 0;
font-weight: bold;
font-size: 1.5rem;
}
}
#startDate {
grid-area: startDate;
}
#endDate {
grid-area: endDate;
}
#comment {
grid-area: comment;
}
#objectives {
grid-area: objectives;
> div.title {
background-color: var(--chill-light-gray);
color: white;
h3 {
text-align: center;
}
}
> div {
display: grid;
grid-template-areas: "obj res";
grid-template-columns: 50%;
column-gap: 1rem;
> div {
&:nth-child(1) {
grid-area: obj;
}
&:nth-child(2) {
grid-area: res;
}
}
> div.results_without_objective {
background: repeating-linear-gradient(
45deg,
var(--chill-light-gray),
var(--chill-light-gray) 10px,
var(--chill-llight-gray) 10px,
var(--chill-llight-gray) 20px
);
text-align: center;
font-weight: 700;
padding-top: 1.5rem;
}
}
ul.list-objectives {
list-style-type: none;
padding: 0;
li {
margin: 0.5rem;
}
}
div.objective-title {
margin-top: 1rem;
font-size: 1.5rem;
font-weight: bold;
text-align: center;
i.fa {
padding: 0.25rem;
}
i.fa-times {
background-color: red;
color: white;
}
}
li.badge, div.badge {
padding-bottom: 0;
padding-top: 0;
padding-left: 0;
i.fa {
padding: 0.25rem;
}
i.fa-plus {
background-color: green;
}
}
}
#persons {
grid-area: persons;
}
#handlingThirdParty {
grid-area: handling;
}
#thirdParties {
grid-area: tparties;
}
#errors {
grid-area: errors;
}
}
</style>
<script>
import { mapState, mapGetters, } from 'vuex';
import { dateToISO, ISOToDate, ISOToDatetime } from 'ChillMainAssets/js/date.js';
import CKEditor from '@ckeditor/ckeditor5-vue';
import ClassicEditor from 'ChillMainAssets/modules/ckeditor5/index.js';
import AddResult from './_components/AddResult.vue';
import Person from 'ChillPersonAssets/vuejs/_components/Person/Person.vue';
import AddPersons from 'ChillPersonAssets/vuejs/_components/AddPersons.vue';
import ShowAddress from 'ChillMainAssets/vuejs/_components/ShowAddress.vue';
const i18n = {
messages: {
fr: {
action_title: "Action d'accompagnement",
startDate: "Date de début",
endDate: "Date de fin",
results_without_objective: "Résultats - orientations sans objectifs",
add_objectif: "Ajouter un motif - objectif - dispositif",
persons_involved: "Usagers concernés",
}
}
};
export default {
name: 'App',
components: {
ckeditor: CKEditor.component,
AddResult,
AddPersons,
Person,
ShowAddress,
},
i18n,
data() {
return {
editor: ClassicEditor,
showAddObjective: false,
handlingThirdPartyPicker: {
key: 'handling-third-party',
options: {
type: [ 'thirdparty' ],
priority: null,
uniq: true
},
},
thirdPartyPicker: {
key: 'third-party',
options: {
type: [ 'thirdparty' ],
priority: null,
uniq: false,
},
}
};
},
computed: {
...mapState([
'work',
'resultsForAction',
'goalsPicked',
'personsReachables',
'handlingThirdParty',
'thirdParties',
'isPosting',
'errors',
]),
...mapGetters([
'hasResultsForAction',
'hasHandlingThirdParty',
'hasThirdParties',
]),
startDate: {
get() {
console.log('get start date', this.$store.state.startDate);
return dateToISO(this.$store.state.startDate);
},
set(v) {
this.$store.commit('setStartDate', ISOToDate(v));
}
},
endDate: {
get() {
console.log('get end date', this.$store.state.endDate);
return dateToISO(this.$store.state.endDate);
},
set(v) {
this.$store.commit('setEndDate', ISOToDate(v));
}
},
note: {
get() {
return this.$store.state.note;
},
set(v) {
this.$store.commit('setNote', v);
}
},
availableForCheckGoal() {
let pickedIds = this.$store.state.goalsPicked.map(g => g.goal.id);
console.log('pickeds goals id', pickedIds);
console.log(this.$store.state.goalsForAction);
return this.$store.state.goalsForAction.filter(g => !pickedIds.includes(g.id));
},
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);
}
},
},
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);
},
setHandlingThirdParty({ selected, modal }) {
console.log('setHandlingThirdParty', selected);
this.$store.commit('setHandlingThirdParty', selected.shift().result);
this.$refs.handlingThirdPartyPicker.resetSearch();
modal.showModal = false;
},
removeHandlingThirdParty() {
console.log('removeHandlingThirdParty');
this.$store.commit('setHandlingThirdParty', null);
},
addThirdParties({ selected, modal}) {
console.log('addThirdParties', selected);
this.$store.commit('addThirdParties', selected.map(r => r.result));
this.$refs.thirdPartyPicker.resetSearch();
modal.showModal = false;
},
removeThirdParty(t) {
console.log('remove third party', t);
this.$store.commit('removeThirdParty', t);
},
submit() {
this.$store.dispatch('submit');
},
}
};
</script>

View File

@ -0,0 +1,166 @@
<template>
<div class="addResult" v-if="hasResult">
<p class="chill-no-data-statement" v-if="pickedResults.length ===0">
Aucun résultat associé
</p>
<ul class="list-results">
<li v-for="r in pickedResults" @click="removeResult(r)" class="badge badge-primary">
<i class="fa fa-times"></i>
{{ r.title.fr }}
</li>
<template v-if="isExpanded">
<li v-for="r in availableForCheckResults" @click="addResult(r)" class="badge badge-primary">
<i class="fa fa-plus"></i>
{{ r.title.fr }}
</li>
</template>
</ul>
<ul class="record_actions">
<li v-if="isExpanded">
<button @click="toggleSelect" class="sc-button bt-hide" >
<i class="fa fa-eye-slash"></i>
Masquer résultats et orientations disponibles
</button>
</li>
<li v-else>
<button @click="toggleSelect" class="sc-button bt-show">
Afficher résultats et orientations disponibles
</button>
</li>
</ul>
</div>
<div class="noResult" v-if="!hasResult">
<div class="chill-no-data-statement">
{{ $t('goal_has_no_result') }}
</div>
</div>
</template>
<style lang="scss">
button.hide {
background-color: rgb(51, 77, 92);
}
ul.list-results {
list-style-type: none;
padding: 0;
li {
margin: 0.5rem;
}
li.badge {
padding-bottom: 0;
padding-top: 0;
padding-left: 0;
i.fa {
/*border-radius: 0.25rem; */
padding: 0.25rem;
}
i.fa-plus {
background-color: green;
}
i.fa-times {
background-color: red;
color: white;
}
}
}
</style>
<script>
const i18n = {
messages: {
fr: {
add_a_result: "Résultat - orientation disponibles",
goal_has_no_result: "Aucun résultat - orientation disponible",
}
}
};
export default {
name: "AddResult",
props: [ 'destination', 'goal' ],
i18n,
data() {
return {
isExpanded: false,
};
},
computed: {
hasResult() {
if (this.destination === 'action') {
return this.$store.state.resultsForAction.length > 0;
} else if (this.destination === 'goal') {
return this.$store.getters.resultsForGoal(this.goal).length > 0;
}
throw Error(`this.destination is not implemented: ${this.destination}`);
},
pickedResults() {
console.log('get checked');
console.log('this.destination', this.destination);
console.log('this.goal', this.goal);
if (this.destination === 'action') {
return this.$store.state.resultsPicked;
} else if (this.destination === 'goal') {
return this.$store.getters.resultsPickedForGoal(this.goal);
}
throw Error(`this.destination is not implemented: ${this.destination}`);
},
availableForCheckResults() {
console.log('availableForCheckResults');
console.log('this.destination', this.destination);
console.log('this.goal', this.goal);
if (this.destination === 'action') {
let pickedIds = this.$store.state.resultsPicked.map(r => r.id);
console.log('picked ids', pickedIds);
return this.$store.state.resultsForAction.filter(r => !pickedIds.includes(r.id));
} else if (this.destination === 'goal') {
console.log('results picked for goal', this.$store.getters.resultsPickedForGoal(this.goal));
let pickedIds = this.$store.getters.resultsPickedForGoal(this.goal).map(r => r.id);
return this.$store.getters.resultsForGoal(this.goal).filter(r => !pickedIds.includes(r.id));
}
throw Error(`this.destination is not implemented: ${this.destination}`);
}
},
methods: {
toggleSelect() {
this.isExpanded = !this.isExpanded;
},
addResult(r) {
console.log('addResult', r);
if (this.destination === 'action') {
this.$store.commit('addResultPicked', r);
return;
} else if (this.destination === 'goal') {
this.$store.commit('addResultForGoalPicked', { goal: this.goal, result: r });
return;
}
throw Error(`this.destination is not implemented: ${this.destination}`);
},
removeResult(r) {
console.log('removeresult', r);
if (this.destination === 'action') {
this.$store.commit('removeResultPicked', r);
return;
} else if (this.destination === 'goal') {
this.$store.commit('removeResultForGoalPicked', { goal: this.goal, result: r });
return;
}
throw Error(`this.destination is not implemented: ${this.destination}`);
}
}
}
</script>

View File

@ -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: `<app></app>`,
})
.use(store)
.use(i18n)
.component('app', App)
.mount('#accompanying_course_work_edit');

View File

@ -0,0 +1,304 @@
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: [],
personsPicked: window.accompanyingCourseWork.persons,
personsReachables: window.accompanyingCourseWork.accompanyingPeriod.participations.filter(p => p.endDate == null)
.map(p => p.person),
handlingThirdParty: window.accompanyingCourseWork.handlingThierParty,
thirdParties: window.accompanyingCourseWork.thirdParties,
isPosting: false,
errors: [],
},
getters: {
socialAction(state) {
return state.work.socialAction;
},
hasResultsForAction(state) {
return state.resultsForAction.length > 0;
},
resultsForGoal: (state) => (goal) => {
let founds = state.resultsForGoal.filter(r => r.goalId === goal.id);
return founds === undefined ? [] : founds;
},
resultsPickedForGoal: (state) => (goal) => {
let found = state.goalsPicked.find(g => g.goal.id === goal.id);
return found === undefined ? [] : found.results;
},
hasHandlingThirdParty(state) {
return state.handlingThirdParty !== null;
},
hasThirdParties(state) {
return state.thirdParties.length > 0;
},
buildPayload(state) {
return {
type: 'accompanying_period_work',
id: state.work.id,
startDate: {
datetime: datetimeToISO(state.startDate)
},
endDate: state.endDate === null ? null : {
datetime: datetimeToISO(state.endDate)
},
note: state.note,
persons: state.personsPicked.map(p => ({id: p.id, type: p.type})),
handlingThierParty: state.handlingThirdParty === null ? null : {
id: state.handlingThirdParty.id,
type: state.handlingThirdParty.type
},
results: state.resultsPicked.map(r => ({id: r.id, type: r.type})),
thirdParties: state.thirdParties.map(t => ({id: t.id, type: t.type})),
goals: state.goalsPicked.map(g => {
let o = {
type: g.type,
note: g.note,
goal: {
type: g.goal.type,
id: g.goal.id,
},
results: g.results.map(r => ({id: r.id, type: r.type})),
};
if (g.id !== undefined) {
o.id = g.id;
}
return o;
})
};
}
},
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.push(goal);
for (let i in results) {
let r = results[i];
r.goalId = goal.id;
console.log('adding result', r);
state.resultsForGoal.push(r);
}
},
addResultPicked(state, result) {
state.resultsPicked.push(result);
},
removeResultPicked(state, result) {
state.resultsPicked = state.resultsPicked.filter(r => r.id !== result.id);
},
addGoal(state, goal) {
let g = {
type: "accompanying_period_work_goal",
goal: goal,
note: '',
results: []
}
state.goalsPicked.push(g);
},
removeGoal(state, goal) {
state.goalsPicked = state.goalsPicked.filter(g => g.id !== goal.id);
},
addResultForGoalPicked(state, { goal, result}) {
let found = state.goalsPicked.find(g => g.goal.id === goal.id);
console.log('adResultForGoalPicked');
console.log('found', found);
console.log('goal', goal);
console.log('result', result);
if (found === undefined) {
return;
}
found.results.push(result);
},
removeResultForGoalPicked(state, { goal, result}) {
let found = state.goalsPicked.find(g => g.goal.id === goal.id);
if (found === undefined) {
return;
}
found.results = found.results.filter(r => r.id !== result.id);
},
setPersonsPickedIds(state, ids) {
console.log('persons ids', ids);
state.personsPicked = state.personsReachables
.filter(p => ids.includes(p.id))
},
setNote(state, note) {
state.note = note;
},
setHandlingThirdParty(state, thirdParty) {
state.handlingThirdParty = thirdParty;
},
addThirdParties(state, thirdParties) {
console.log('addThirdParties', thirdParties);
// filter to remove existing thirdparties
let ids = state.thirdParties.map(t => t.id);
let unexistings = thirdParties.filter(t => !ids.includes(t.id));
console.log('unexisting third parties', unexistings);
for (let i in unexistings) {
state.thirdParties.push(unexistings[i]);
}
},
removeThirdParty(state, thirdParty) {
state.thirdParties = state.thirdParties
.filter(t => t.id !== thirdParty.id);
},
setErrors(state, errors) {
console.log('handling errors', errors);
state.errors = errors;
},
setIsPosting(state, st) {
state.isPosting = st;
},
},
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);
});
},
submit({ getters, state, commit }) {
let
payload = getters.buildPayload,
url = `/api/1.0/person/accompanying-course/work/${state.work.id}.json`,
errors = []
;
console.log('action subitting', payload, url);
commit('setIsPosting', true);
window.fetch(url, {
method: 'PUT',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(payload)
}).then(response => {
if (response.ok || response.status === 422) {
return response.json().then(data => ({data, status: response.status}));
}
throw new Error(response.status);
}).then(({data, status}) => {
if (status === 422) {
for (let i in data.violations) {
errors.push(data.violations[i].title);
}
commit('setErrors', errors);
commit('setIsPosting', false);
} else {
console.info('nothing to do here, bye bye');
window.location.assign(`/fr/person/accompanying-period/${state.work.accompanyingPeriod.id}/work`);
}
}).catch(e => {
commit('setErrors', [
'Erreur serveur ou réseau: veuillez ré-essayer. Code erreur: ' + e
]);
commit('setIsPosting', false);
});
},
initAsync({ dispatch }) {
dispatch('getReachablesResultsForAction');
dispatch('getReachablesGoalsForAction');
},
}
});
store.dispatch('initAsync');
export { store };

View File

@ -24,3 +24,4 @@
</div>
</div>
</div>
<span id="banner-accompanying-course"></span>

View File

@ -0,0 +1,25 @@
{% extends '@ChillPerson/AccompanyingCourse/layout.html.twig' %}
{% block title 'accompanying_course_work.Edit accompanying course work'|trans %}
{% block content %}
<h1>{{ block('title') }}</h1>
<div id="accompanying_course_work_edit"></div>
{% endblock %}
{% block js %}
{{ parent() }}
<script type="text/javascript">
window.accompanyingCourseWork = {{ json|json_encode|raw }};
</script>
{{ encore_entry_script_tags('accompanying_course_work_edit') }}
{% endblock %}
{% block css %}
{{ parent() }}
{{ encore_entry_link_tags('accompanying_course_work_edit') }}
{% endblock %}

View File

@ -0,0 +1,124 @@
{% extends '@ChillPerson/AccompanyingCourse/layout.html.twig' %}
{% block title 'accompanying_course_work.List accompanying course work'|trans %}
{% block content %}
<h1>{{ block('title') }}</h1>
<div id="accompanying_course_work_list">
{% for w in works %}
<div class="item">
<div class="title">
<p class="title_label">{{ 'accompanying_course_work.action'|trans }}</p >
<h2 class="action_title">
{{ w.socialAction|chill_entity_render_box({ 'no-badge': true }) }}
</h2>
</div>
<div class="timeline">
<ul class="timeline">
<li class="completed">
<div class="date">
<span>{{ w.createdAt|format_date('long') }}</span>
</div>
<div class="label">
<span>{{ 'accompanying_course_work.create_date'|trans }}</span>
</div>
</li>
<li class="completed">
<div class="date">
<span>{{ w.startDate|format_date('long') }}</span>
</div>
<div class="label">
<span>{{ 'accompanying_course_work.start_date'|trans }}</span>
</div>
</li>
<li class="{%if date(w.endDate) < date('now') %}completed{% endif %}">
<div class="date">
<span>{{ w.endDate|format_date('long') }}</span>
</div>
<div class="label">
<span>{{ 'accompanying_course_work.end_date'|trans }}</span>
</div>
</li>
</ul>
</div>
{% if w.results|length > 0 %}
<div class="objective_results objective_results__without-objectives">
<div class="obj without_objective">
<p class="title_label">{{ 'accompanying_course_work.goal'|trans }}</p>
<p class="chill-no-data-statement">{{ 'accompanying_course_work.results without objective'|trans }}</p>
</div>
<div class="res results">
<p class="title_label">{{ 'accompanying_course_work.results'|trans }}</p>
<ul class="result_list">
{% for r in w.results %}
<li class="badge badge-primary">{{ r.title|localize_translatable_string }}</li>
{% endfor %}
</ul>
</div>
</div>
{% endif %}
{% if w.goals|length > 0 %}
{% for g in w.goals %}
<div class="objective_results objective_results--with-objectives">
<div class="objective obj">
<p class="title_label">{{ 'accompanying_course_work.goal'|trans }}</p>
<h3 class="goal_title">{{ g.goal.title|localize_translatable_string }}</h3>
</div>
<div class="results res">
{% if g.results|length == 0 %}
<p class="title_label">{{ 'accompanying_course_work.results'|trans }}</p>
<p class="chill-no-data-statement">{{ 'accompanying_course_work.no_results'|trans }}</p>
{% else %}
<p class="title_label">{{ 'accompanying_course_work.results'|trans }}</p>
<ul class="result_list">
{% for r in g.results %}
<li class="badge badge-primary">{{ r.title|localize_translatable_string }}</li>
{% endfor %}
</ul>
{% endif %}
</div>
</div>
{% endfor %}
{% endif %}
<div class="updatedBy">
{{ 'Last updated by'|trans}}: {{ w.updatedBy|chill_entity_render_box }}, {{ w.updatedAt|format_datetime('long', 'short') }}
</div>
<div class="actions">
<ul class="record_actions">
<li>
<a
class="sc-button bt-edit"
href="{{ chill_path_add_return_path('chill_person_accompanying_period_work_edit', { 'id': w.id }) }}">{{ 'Update'|trans }}</a>
</li>
</ul>
</div>
</div>
{% else %}
<p class="chill-no-data-statement">{{ 'accompanying_course_work.No work'|trans }}</p>
{% endfor %}
</div>
<ul class="record_actions sticky-form-buttons">
<li>
<a href="{{ chill_path_add_return_path('chill_person_accompanying_period_work_new', { 'id': accompanyingCourse.id }) }}"
class="sc-button bt-new">
{{ 'accompanying_course_work.create'|trans }}
</a>
</li>
</ul>
{% endblock %}
{% block css %}
{{ parent() }}
{{ encore_entry_link_tags('accompanying_course_work_list') }}
{% endblock %}

View File

@ -1,6 +1,6 @@
{% set reversed_parents = parents|reverse %}
<span class="chill-entity chill-entity__social-action">
<span class="badge badge-primary">
<span class="{% if not options['no-badge'] %}badge badge-primary{% endif %}">
{%- for p in reversed_parents %}
<span class="chill-entity__social-action__parent--{{ loop.revindex0 }}">
{{ p.title|localize_translatable_string }}{{ options['default.separator'] }}

View File

@ -13,9 +13,14 @@ class SocialActionRender implements ChillEntityRenderInterface
private EngineInterface $engine;
public const SEPARATOR_KEY = 'default.separator';
/**
* if true, the action will not be encapsulated into a "badge"
*/
public const NO_BADGE = 'no-badge';
public const DEFAULT_ARGS = [
self::SEPARATOR_KEY => ' > ',
self::SEPARATOR_KEY => ' > ',
self::NO_BADGE => false,
];
public function __construct(TranslatableStringHelper $translatableStringHelper, EngineInterface $engine)
@ -33,17 +38,18 @@ class SocialActionRender implements ChillEntityRenderInterface
{
/** @var $socialAction SocialAction */
$options = \array_merge(self::DEFAULT_ARGS, $options);
$str = $this->translatableStringHelper->localize($socialAction->getTitle());
$titles[] = $this->translatableStringHelper->localize($socialAction->getTitle());
while ($socialAction->hasParent()) {
$socialAction = $socialAction->getParent();
$str .= $options[self::SEPARATOR_KEY].$this->translatableStringHelper->localize(
$titles[] = $this->translatableStringHelper->localize(
$socialAction->getTitle()
);
}
return $str;
$titles = \array_reverse($titles);
return \implode($options[self::SEPARATOR_KEY], $titles);
}
protected function buildParents($socialAction): array

View File

@ -38,16 +38,20 @@ final class SocialIssueRender implements ChillEntityRenderInterface
/** @var $socialIssue SocialIssue */
$options = array_merge(self::DEFAULT_ARGS, $options);
$str = $this->translatableStringHelper->localize($socialIssue->getTitle());
$titles[] = $this->translatableStringHelper
->localize($socialIssue->getTitle());
// loop to parent, until root
while ($socialIssue->hasParent()) {
$socialIssue = $socialIssue->getParent();
$str .= $options[self::SEPARATOR_KEY].$this->translatableStringHelper->localize(
$titles[] = $this->translatableStringHelper->localize(
$socialIssue->getTitle()
);
}
return $str;
$titles = \array_reverse($titles);
return \implode($options[self::SEPARATOR_KEY], $titles);
}
protected function buildParents(SocialIssue $socialIssue): array

View File

@ -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,258 @@ 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/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:
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"

View File

@ -14,6 +14,7 @@ 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');
encore.addEntry('accompanying_course_work_list', __dirname + '/Resources/public/modules/accompanying_course_work_list/index.js');
encore.addEntry('person', __dirname + '/Resources/public/js/person.js');
};

View File

@ -70,6 +70,7 @@ services:
Chill\PersonBundle\Controller\:
autowire: true
autoconfigure: true
resource: '../Controller/'
tags: ['controller.service_arguments']

View File

@ -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']

View File

@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\Person;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Add link to accompanying period work and persons
*/
final class Version20210623135043 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add link to accompanying period work and persons';
}
public function up(Schema $schema): void
{
$this->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");
}
}

View File

@ -339,6 +339,18 @@ Move household: Nouveau déménagement
Addresses history for household: Historique des adresses
# accompanying course work
Accompanying Course Actions: Actions d'accompagnements
accompanying_course_work:
create: Créer une action
Create accompanying course work: Créer une action d'accompagnement
Edit accompanying course work: Modifier une action d'accompagnement
List accompanying course work: Liste des actions d'accompagnement
action: Action
create_date: Date de création
start_date: Date de début
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