mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-30 10:29:42 +00:00
Compare commits
1 Commits
deploy/qui
...
fix-test-a
Author | SHA1 | Date | |
---|---|---|---|
6a54316f46 |
@@ -72,7 +72,6 @@ class ActivityController extends AbstractController
|
|||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
$view = null;
|
$view = null;
|
||||||
// TODO: add pagination
|
|
||||||
|
|
||||||
[$person, $accompanyingPeriod] = $this->getEntity($request);
|
[$person, $accompanyingPeriod] = $this->getEntity($request);
|
||||||
|
|
||||||
@@ -81,9 +80,10 @@ class ActivityController extends AbstractController
|
|||||||
->getReachableCircles($this->getUser(), new Role('CHILL_ACTIVITY_SEE'),
|
->getReachableCircles($this->getUser(), new Role('CHILL_ACTIVITY_SEE'),
|
||||||
$person->getCenter());
|
$person->getCenter());
|
||||||
|
|
||||||
$activities = $em->getRepository(Activity::class)
|
$activities = $em->getRepository('ChillActivityBundle:Activity')->findBy(
|
||||||
->findByPersonImplied($person, $reachableScopes)
|
['person' => $person, 'scope' => $reachableScopes],
|
||||||
;
|
['date' => 'DESC'],
|
||||||
|
);
|
||||||
|
|
||||||
$event = new PrivacyEvent($person, array(
|
$event = new PrivacyEvent($person, array(
|
||||||
'element_class' => Activity::class,
|
'element_class' => Activity::class,
|
||||||
|
@@ -106,16 +106,15 @@ class Activity implements HasCenterInterface, HasScopeInterface
|
|||||||
/**
|
/**
|
||||||
* @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\SocialWork\SocialIssue")
|
* @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\SocialWork\SocialIssue")
|
||||||
* @ORM\JoinTable(name="chill_activity_activity_chill_person_socialissue")
|
* @ORM\JoinTable(name="chill_activity_activity_chill_person_socialissue")
|
||||||
* @Groups({"read"})
|
|
||||||
*/
|
*/
|
||||||
private Collection $socialIssues;
|
private $socialIssues;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\SocialWork\SocialAction")
|
* @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\SocialWork\SocialAction")
|
||||||
* @ORM\JoinTable(name="chill_activity_activity_chill_person_socialaction")
|
* @ORM\JoinTable(name="chill_activity_activity_chill_person_socialaction")
|
||||||
* @Groups({"read"})
|
|
||||||
*/
|
*/
|
||||||
private Collection $socialActions;
|
private $socialActions;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityType")
|
* @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityType")
|
||||||
@@ -282,7 +281,7 @@ class Activity implements HasCenterInterface, HasScopeInterface
|
|||||||
return $this->socialIssues;
|
return $this->socialIssues;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addSocialIssue(?SocialIssue $socialIssue): self
|
public function addSocialIssue(SocialIssue $socialIssue): self
|
||||||
{
|
{
|
||||||
if (!$this->socialIssues->contains($socialIssue)) {
|
if (!$this->socialIssues->contains($socialIssue)) {
|
||||||
$this->socialIssues[] = $socialIssue;
|
$this->socialIssues[] = $socialIssue;
|
||||||
@@ -298,12 +297,15 @@ class Activity implements HasCenterInterface, HasScopeInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Collection|SocialAction[]
|
||||||
|
*/
|
||||||
public function getSocialActions(): Collection
|
public function getSocialActions(): Collection
|
||||||
{
|
{
|
||||||
return $this->socialActions;
|
return $this->socialActions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addSocialAction(?SocialAction $socialAction): self
|
public function addSocialAction(SocialAction $socialAction): self
|
||||||
{
|
{
|
||||||
if (!$this->socialActions->contains($socialAction)) {
|
if (!$this->socialActions->contains($socialAction)) {
|
||||||
$this->socialActions[] = $socialAction;
|
$this->socialActions[] = $socialAction;
|
||||||
|
@@ -35,7 +35,6 @@ use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
|||||||
use Symfony\Component\Form\CallbackTransformer;
|
use Symfony\Component\Form\CallbackTransformer;
|
||||||
use Chill\PersonBundle\Form\DataTransformer\PersonToIdTransformer;
|
use Chill\PersonBundle\Form\DataTransformer\PersonToIdTransformer;
|
||||||
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
|
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
|
||||||
use Chill\PersonBundle\Templating\Entity\SocialActionRender;
|
|
||||||
|
|
||||||
class ActivityType extends AbstractType
|
class ActivityType extends AbstractType
|
||||||
{
|
{
|
||||||
@@ -47,10 +46,6 @@ class ActivityType extends AbstractType
|
|||||||
|
|
||||||
protected TranslatableStringHelper $translatableStringHelper;
|
protected TranslatableStringHelper $translatableStringHelper;
|
||||||
|
|
||||||
protected SocialIssueRender $socialIssueRender;
|
|
||||||
|
|
||||||
protected SocialActionRender $socialActionRender;
|
|
||||||
|
|
||||||
protected array $timeChoices;
|
protected array $timeChoices;
|
||||||
|
|
||||||
public function __construct (
|
public function __construct (
|
||||||
@@ -59,8 +54,7 @@ class ActivityType extends AbstractType
|
|||||||
ObjectManager $om,
|
ObjectManager $om,
|
||||||
TranslatableStringHelper $translatableStringHelper,
|
TranslatableStringHelper $translatableStringHelper,
|
||||||
array $timeChoices,
|
array $timeChoices,
|
||||||
SocialIssueRender $socialIssueRender,
|
SocialIssueRender $socialIssueRender
|
||||||
SocialActionRender $socialActionRender
|
|
||||||
) {
|
) {
|
||||||
if (!$tokenStorage->getToken()->getUser() instanceof User) {
|
if (!$tokenStorage->getToken()->getUser() instanceof User) {
|
||||||
throw new \RuntimeException("you should have a valid user");
|
throw new \RuntimeException("you should have a valid user");
|
||||||
@@ -72,7 +66,6 @@ class ActivityType extends AbstractType
|
|||||||
$this->translatableStringHelper = $translatableStringHelper;
|
$this->translatableStringHelper = $translatableStringHelper;
|
||||||
$this->timeChoices = $timeChoices;
|
$this->timeChoices = $timeChoices;
|
||||||
$this->socialIssueRender = $socialIssueRender;
|
$this->socialIssueRender = $socialIssueRender;
|
||||||
$this->socialActionRender = $socialActionRender;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
@@ -112,51 +105,31 @@ class ActivityType extends AbstractType
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($activityType->isVisible('socialIssues') && $accompanyingPeriod) {
|
if ($activityType->isVisible('socialIssues') && $accompanyingPeriod) {
|
||||||
$builder->add('socialIssues', HiddenType::class);
|
$builder->add('socialIssues', EntityType::class, [
|
||||||
$builder->get('socialIssues')
|
'label' => $activityType->getLabel('socialIssues'),
|
||||||
->addModelTransformer(new CallbackTransformer(
|
'required' => $activityType->isRequired('socialIssues'),
|
||||||
function (iterable $socialIssuesAsIterable): string {
|
'class' => SocialIssue::class,
|
||||||
$socialIssueIds = [];
|
'choice_label' => function (SocialIssue $socialIssue) {
|
||||||
foreach ($socialIssuesAsIterable as $value) {
|
return $this->socialIssueRender->renderString($socialIssue, []);
|
||||||
$socialIssueIds[] = $value->getId();
|
},
|
||||||
}
|
'multiple' => true,
|
||||||
return implode(',', $socialIssueIds);
|
'choices' => $accompanyingPeriod->getRecursiveSocialIssues(),
|
||||||
},
|
'expanded' => true,
|
||||||
function (?string $socialIssuesAsString): array {
|
]);
|
||||||
if (null === $socialIssuesAsString) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
return array_map(
|
|
||||||
fn(string $id): ?SocialIssue => $this->om->getRepository(SocialIssue::class)->findOneBy(['id' => (int) $id]),
|
|
||||||
explode(',', $socialIssuesAsString)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
))
|
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($activityType->isVisible('socialActions') && $accompanyingPeriod) {
|
if ($activityType->isVisible('socialActions') && $accompanyingPeriod) {
|
||||||
$builder->add('socialActions', HiddenType::class);
|
$builder->add('socialActions', EntityType::class, [
|
||||||
$builder->get('socialActions')
|
'label' => $activityType->getLabel('socialActions'),
|
||||||
->addModelTransformer(new CallbackTransformer(
|
'required' => $activityType->isRequired('socialActions'),
|
||||||
function (iterable $socialActionsAsIterable): string {
|
'class' => SocialAction::class,
|
||||||
$socialActionIds = [];
|
'choice_label' => function (SocialAction $socialAction) {
|
||||||
foreach ($socialActionsAsIterable as $value) {
|
return $this->translatableStringHelper->localize($socialAction->getTitle());
|
||||||
$socialActionIds[] = $value->getId();
|
},
|
||||||
}
|
'multiple' => true,
|
||||||
return implode(',', $socialActionIds);
|
'choices' => $accompanyingPeriod->getRecursiveSocialActions(),
|
||||||
},
|
'expanded' => true,
|
||||||
function (?string $socialActionsAsString): array {
|
]);
|
||||||
if (null === $socialActionsAsString) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
return array_map(
|
|
||||||
fn(string $id): ?SocialAction => $this->om->getRepository(SocialAction::class)->findOneBy(['id' => (int) $id]),
|
|
||||||
explode(',', $socialActionsAsString)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
))
|
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($activityType->isVisible('date')) {
|
if ($activityType->isVisible('date')) {
|
||||||
@@ -224,14 +197,15 @@ class ActivityType extends AbstractType
|
|||||||
|
|
||||||
if ($activityType->isVisible('comment')) {
|
if ($activityType->isVisible('comment')) {
|
||||||
$builder->add('comment', CommentType::class, [
|
$builder->add('comment', CommentType::class, [
|
||||||
'label' => empty($activityType->getLabel('comment'))
|
'label' => $activityType->getLabel('comment'),
|
||||||
? 'activity.comment' : $activityType->getLabel('comment'),
|
|
||||||
'required' => $activityType->isRequired('comment'),
|
'required' => $activityType->isRequired('comment'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($activityType->isVisible('persons')) {
|
if ($activityType->isVisible('persons')) {
|
||||||
$builder->add('persons', HiddenType::class);
|
$builder->add('persons', HiddenType::class, [
|
||||||
|
//'data_class' => Person::class,
|
||||||
|
]);
|
||||||
$builder->get('persons')
|
$builder->get('persons')
|
||||||
->addModelTransformer(new CallbackTransformer(
|
->addModelTransformer(new CallbackTransformer(
|
||||||
function (iterable $personsAsIterable): string {
|
function (iterable $personsAsIterable): string {
|
||||||
@@ -252,7 +226,9 @@ class ActivityType extends AbstractType
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($activityType->isVisible('thirdParties')) {
|
if ($activityType->isVisible('thirdParties')) {
|
||||||
$builder->add('thirdParties', HiddenType::class);
|
$builder->add('thirdParties', HiddenType::class, [
|
||||||
|
//'data_class' => ThirdParty::class,
|
||||||
|
]);
|
||||||
$builder->get('thirdParties')
|
$builder->get('thirdParties')
|
||||||
->addModelTransformer(new CallbackTransformer(
|
->addModelTransformer(new CallbackTransformer(
|
||||||
function (iterable $thirdpartyAsIterable): string {
|
function (iterable $thirdpartyAsIterable): string {
|
||||||
@@ -284,7 +260,9 @@ class ActivityType extends AbstractType
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($activityType->isVisible('users')) {
|
if ($activityType->isVisible('users')) {
|
||||||
$builder->add('users', HiddenType::class);
|
$builder->add('users', HiddenType::class, [
|
||||||
|
//'data_class' => User::class,
|
||||||
|
]);
|
||||||
$builder->get('users')
|
$builder->get('users')
|
||||||
->addModelTransformer(new CallbackTransformer(
|
->addModelTransformer(new CallbackTransformer(
|
||||||
function (iterable $usersAsIterable): string {
|
function (iterable $usersAsIterable): string {
|
||||||
|
@@ -4,7 +4,6 @@ namespace Chill\ActivityBundle\Menu;
|
|||||||
|
|
||||||
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
|
||||||
use Knp\Menu\MenuItem;
|
use Knp\Menu\MenuItem;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
@@ -35,13 +34,21 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
{
|
{
|
||||||
$period = $parameters['accompanyingCourse'];
|
$period = $parameters['accompanyingCourse'];
|
||||||
|
|
||||||
if (AccompanyingPeriod::STEP_DRAFT !== $period->getStep()) {
|
$menu->addChild($this->translator->trans('Activity list'), [
|
||||||
$menu->addChild($this->translator->trans('Activity list'), [
|
'route' => 'chill_activity_activity_list',
|
||||||
'route' => 'chill_activity_activity_list',
|
'routeParameters' => [
|
||||||
'routeParameters' => [
|
'accompanying_period_id' => $period->getId(),
|
||||||
'accompanying_period_id' => $period->getId(),
|
]])
|
||||||
]])
|
->setExtras(['order' => 40]);
|
||||||
->setExtras(['order' => 40]);
|
|
||||||
}
|
$menu->addChild($this->translator->trans('Add a new activity'), [
|
||||||
|
'route' => 'chill_activity_activity_select_type',
|
||||||
|
'routeParameters' => [
|
||||||
|
'accompanying_period_id' => $period->getId(),
|
||||||
|
]])
|
||||||
|
->setExtras(['order' => 41]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
88
src/Bundle/ChillActivityBundle/Menu/MenuBuilder.php
Normal file
88
src/Bundle/ChillActivityBundle/Menu/MenuBuilder.php
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
namespace Chill\ActivityBundle\Menu;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
||||||
|
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||||
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||||
|
use Symfony\Component\Translation\TranslatorInterface;
|
||||||
|
use Knp\Menu\MenuItem;
|
||||||
|
use Symfony\Component\Security\Core\Role\Role;
|
||||||
|
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
|
*/
|
||||||
|
class MenuBuilder implements LocalMenuBuilderInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var TokenStorageInterface
|
||||||
|
*/
|
||||||
|
protected $tokenStorage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var TranslatorInterface
|
||||||
|
*/
|
||||||
|
protected $translator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var AuthorizationHelper
|
||||||
|
*/
|
||||||
|
protected $authorizationHelper;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
TokenStorageInterface $tokenStorage,
|
||||||
|
TranslatorInterface $translator,
|
||||||
|
AuthorizationHelper $authorizationHelper
|
||||||
|
) {
|
||||||
|
$this->tokenStorage = $tokenStorage;
|
||||||
|
$this->translator = $translator;
|
||||||
|
$this->authorizationHelper = $authorizationHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
||||||
|
{
|
||||||
|
/* @var $person \Chill\PersonBundle\Entity\Person */
|
||||||
|
$person = $parameters['person'];
|
||||||
|
$user = $this->tokenStorage->getToken()->getUser();
|
||||||
|
$roleSee = new Role(ActivityVoter::SEE);
|
||||||
|
$roleAdd = new Role(ActivityVoter::CREATE);
|
||||||
|
|
||||||
|
if ($this->authorizationHelper->userHasAccess($user, $person, $roleSee)) {
|
||||||
|
$menu->addChild($this->translator->trans('Activity list'), [
|
||||||
|
'route' => 'chill_activity_activity_list',
|
||||||
|
'routeParameters' => [
|
||||||
|
'person_id' => $person->getId()
|
||||||
|
]
|
||||||
|
])
|
||||||
|
->setExtras([
|
||||||
|
'order' => 201
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->authorizationHelper->userHasAccess($user, $person, $roleAdd)) {
|
||||||
|
$menu->addChild($this->translator->trans('Add a new activity'), [
|
||||||
|
'route' => 'chill_activity_activity_new',
|
||||||
|
'routeParameters' => [
|
||||||
|
'person_id' => $person->getId()
|
||||||
|
]
|
||||||
|
])
|
||||||
|
->setExtras([
|
||||||
|
'order' => 200
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getMenuIds(): array
|
||||||
|
{
|
||||||
|
return [ 'person' ];
|
||||||
|
}
|
||||||
|
}
|
@@ -15,7 +15,8 @@
|
|||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
namespace Chill\ActivityBundle\Menu;
|
namespace Chill\ActivityBundle\Menu;
|
||||||
|
|
||||||
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
||||||
use Knp\Menu\MenuItem;
|
use Knp\Menu\MenuItem;
|
||||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||||
@@ -64,6 +65,15 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
->setExtra('order', 201)
|
->setExtra('order', 201)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
if ($this->authorizationChecker->isGranted(ActivityVoter::CREATE, $person)) {
|
||||||
|
$menu->addChild(
|
||||||
|
$this->translator->trans('Add a new activity'), [
|
||||||
|
'route' => 'chill_activity_activity_new',
|
||||||
|
'routeParameters' => [ 'person_id' => $person->getId() ],
|
||||||
|
])
|
||||||
|
->setExtra('order', 200)
|
||||||
|
;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getMenuIds(): array
|
public static function getMenuIds(): array
|
||||||
|
@@ -38,30 +38,5 @@ class ActivityRepository extends ServiceEntityRepository
|
|||||||
{
|
{
|
||||||
parent::__construct($registry, Activity::class);
|
parent::__construct($registry, Activity::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findByPersonImplied($person, array $scopes, $orderBy = [ 'date' => 'DESC'], $limit = 100, $offset = 0)
|
|
||||||
{
|
|
||||||
$qb = $this->createQueryBuilder('a');
|
|
||||||
$qb->select('a');
|
|
||||||
|
|
||||||
$qb
|
|
||||||
// TODO add acl
|
|
||||||
//->where($qb->expr()->in('a.scope', ':scopes'))
|
|
||||||
//->setParameter('scopes', $scopes)
|
|
||||||
->andWhere(
|
|
||||||
$qb->expr()->orX(
|
|
||||||
$qb->expr()->eq('a.person', ':person'),
|
|
||||||
':person MEMBER OF a.persons'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
->setParameter('person', $person)
|
|
||||||
;
|
|
||||||
|
|
||||||
foreach ($orderBy as $k => $dir) {
|
|
||||||
$qb->addOrderBy('a.'.$k, $dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $qb->getQuery()
|
|
||||||
->getResult();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -112,19 +112,3 @@ div.flex-table.list-records {
|
|||||||
margin-top: 1em;
|
margin-top: 1em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
div.activity-row {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
justify-content: center;
|
|
||||||
gap: 12px;
|
|
||||||
div.bloc {
|
|
||||||
width: 200px;
|
|
||||||
align-self: flex-end;
|
|
||||||
height: 140px;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@@ -1,17 +1,170 @@
|
|||||||
<template>
|
<template>
|
||||||
<concerned-groups></concerned-groups>
|
<teleport to="#add-persons">
|
||||||
<social-issues-acc></social-issues-acc>
|
|
||||||
|
<div class="flex-bloc concerned-groups" :class="getContext">
|
||||||
|
<persons-bloc
|
||||||
|
v-for="bloc in contextPersonsBlocs"
|
||||||
|
v-bind:key="bloc.key"
|
||||||
|
v-bind:bloc="bloc"
|
||||||
|
v-bind:setPersonsInBloc="setPersonsInBloc">
|
||||||
|
</persons-bloc>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<add-persons
|
||||||
|
buttonTitle="activity.add_persons"
|
||||||
|
modalTitle="activity.add_persons"
|
||||||
|
v-bind:key="addPersons.key"
|
||||||
|
v-bind:options="addPersons.options"
|
||||||
|
@addNewPersons="addNewPersons"
|
||||||
|
ref="addPersons">
|
||||||
|
</add-persons>
|
||||||
|
|
||||||
|
</teleport>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import ConcernedGroups from './components/ConcernedGroups.vue';
|
import { mapState } from 'vuex';
|
||||||
import SocialIssuesAcc from './components/SocialIssuesAcc.vue';
|
import AddPersons from 'ChillPersonAssets/vuejs/_components/AddPersons.vue';
|
||||||
|
import PersonsBloc from './components/PersonsBloc.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "App",
|
name: "App",
|
||||||
components: {
|
components: {
|
||||||
ConcernedGroups,
|
AddPersons,
|
||||||
SocialIssuesAcc
|
PersonsBloc
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
personsBlocs: [
|
||||||
|
{ key: 'persons',
|
||||||
|
title: 'activity.bloc_persons',
|
||||||
|
persons: [],
|
||||||
|
included: false
|
||||||
|
},
|
||||||
|
{ key: 'personsAssociated',
|
||||||
|
title: 'activity.bloc_persons_associated',
|
||||||
|
persons: [],
|
||||||
|
included: false
|
||||||
|
},
|
||||||
|
{ key: 'personsNotAssociated',
|
||||||
|
title: 'activity.bloc_persons_not_associated',
|
||||||
|
persons: [],
|
||||||
|
included: false
|
||||||
|
},
|
||||||
|
{ key: 'thirdparty',
|
||||||
|
title: 'activity.bloc_thirdparty',
|
||||||
|
persons: [],
|
||||||
|
included: true
|
||||||
|
},
|
||||||
|
{ key: 'users',
|
||||||
|
title: 'activity.bloc_users',
|
||||||
|
persons: [],
|
||||||
|
included: true
|
||||||
|
},
|
||||||
|
],
|
||||||
|
addPersons: {
|
||||||
|
key: 'activity',
|
||||||
|
options: {
|
||||||
|
type: ['person', 'thirdparty'], // TODO add 'user'
|
||||||
|
priority: null,
|
||||||
|
uniq: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapState({
|
||||||
|
persons: state => state.activity.persons,
|
||||||
|
thirdParties: state => state.activity.thirdParties,
|
||||||
|
users: state => state.activity.users,
|
||||||
|
accompanyingCourse: state => state.activity.accompanyingPeriod
|
||||||
|
}),
|
||||||
|
getContext() {
|
||||||
|
return (this.accompanyingCourse) ? "accompanyingCourse" : "person";
|
||||||
|
},
|
||||||
|
contextPersonsBlocs() {
|
||||||
|
return this.personsBlocs.filter(bloc => bloc.included !== false);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.setPersonsInBloc();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
setPersonsInBloc() {
|
||||||
|
let groups;
|
||||||
|
if (this.accompanyingCourse) {
|
||||||
|
groups = this.splitPersonsInGroups();
|
||||||
|
}
|
||||||
|
this.personsBlocs.forEach(bloc => {
|
||||||
|
if (this.accompanyingCourse) {
|
||||||
|
switch (bloc.key) {
|
||||||
|
case 'personsAssociated':
|
||||||
|
bloc.persons = groups.personsAssociated;
|
||||||
|
bloc.included = true;
|
||||||
|
break;
|
||||||
|
case 'personsNotAssociated':
|
||||||
|
bloc.persons = groups.personsNotAssociated;
|
||||||
|
bloc.included = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
switch (bloc.key) {
|
||||||
|
case 'persons':
|
||||||
|
bloc.persons = this.persons;
|
||||||
|
bloc.included = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
switch (bloc.key) {
|
||||||
|
case 'thirdparty':
|
||||||
|
bloc.persons = this.thirdParties;
|
||||||
|
break;
|
||||||
|
case 'users':
|
||||||
|
bloc.persons = this.users;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}, groups);
|
||||||
|
},
|
||||||
|
splitPersonsInGroups() {
|
||||||
|
let personsAssociated = [];
|
||||||
|
let personsNotAssociated = this.persons;
|
||||||
|
let participations = this.getCourseParticipations();
|
||||||
|
this.persons.forEach(person => {
|
||||||
|
participations.forEach(participation => {
|
||||||
|
if (person.id === participation.id) {
|
||||||
|
console.log(person.id);
|
||||||
|
personsAssociated.push(person);
|
||||||
|
personsNotAssociated = personsNotAssociated.filter(p => p !== person);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
'personsAssociated': personsAssociated,
|
||||||
|
'personsNotAssociated': personsNotAssociated
|
||||||
|
};
|
||||||
|
},
|
||||||
|
getCourseParticipations() {
|
||||||
|
let participations = [];
|
||||||
|
this.accompanyingCourse.participations.forEach(participation => {
|
||||||
|
if (!participation.endDate) {
|
||||||
|
participations.push(participation.person);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return participations;
|
||||||
|
},
|
||||||
|
addNewPersons({ selected, modal }) {
|
||||||
|
console.log('@@@ CLICK button addNewPersons', selected);
|
||||||
|
selected.forEach(function(item) {
|
||||||
|
this.$store.dispatch('addPersonsInvolved', item);
|
||||||
|
}, this
|
||||||
|
);
|
||||||
|
this.$refs.addPersons.resetSearch(); // to cast child method
|
||||||
|
modal.showModal = false;
|
||||||
|
this.setPersonsInBloc();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
</style>
|
||||||
|
@@ -1,18 +0,0 @@
|
|||||||
import { getSocialIssues } from 'ChillPersonAssets/vuejs/AccompanyingCourse/api.js';
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Load socialActions by socialIssue (id)
|
|
||||||
*/
|
|
||||||
const getSocialActionByIssue = (id) => {
|
|
||||||
const url = `/api/1.0/person/social/social-action/by-social-issue/${id}.json`;
|
|
||||||
return fetch(url)
|
|
||||||
.then(response => {
|
|
||||||
if (response.ok) { return response.json(); }
|
|
||||||
throw Error('Error with request resource response');
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export {
|
|
||||||
getSocialIssues,
|
|
||||||
getSocialActionByIssue
|
|
||||||
};
|
|
@@ -1,170 +0,0 @@
|
|||||||
<template>
|
|
||||||
<teleport to="#add-persons">
|
|
||||||
|
|
||||||
<div class="flex-bloc concerned-groups" :class="getContext">
|
|
||||||
<persons-bloc
|
|
||||||
v-for="bloc in contextPersonsBlocs"
|
|
||||||
v-bind:key="bloc.key"
|
|
||||||
v-bind:bloc="bloc"
|
|
||||||
v-bind:setPersonsInBloc="setPersonsInBloc">
|
|
||||||
</persons-bloc>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<add-persons
|
|
||||||
buttonTitle="activity.add_persons"
|
|
||||||
modalTitle="activity.add_persons"
|
|
||||||
v-bind:key="addPersons.key"
|
|
||||||
v-bind:options="addPersons.options"
|
|
||||||
@addNewPersons="addNewPersons"
|
|
||||||
ref="addPersons">
|
|
||||||
</add-persons>
|
|
||||||
|
|
||||||
</teleport>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { mapState } from 'vuex';
|
|
||||||
import AddPersons from 'ChillPersonAssets/vuejs/_components/AddPersons.vue';
|
|
||||||
import PersonsBloc from './ConcernedGroups/PersonsBloc.vue';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: "ConcernedGroups",
|
|
||||||
components: {
|
|
||||||
AddPersons,
|
|
||||||
PersonsBloc
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
personsBlocs: [
|
|
||||||
{ key: 'persons',
|
|
||||||
title: 'activity.bloc_persons',
|
|
||||||
persons: [],
|
|
||||||
included: false
|
|
||||||
},
|
|
||||||
{ key: 'personsAssociated',
|
|
||||||
title: 'activity.bloc_persons_associated',
|
|
||||||
persons: [],
|
|
||||||
included: false
|
|
||||||
},
|
|
||||||
{ key: 'personsNotAssociated',
|
|
||||||
title: 'activity.bloc_persons_not_associated',
|
|
||||||
persons: [],
|
|
||||||
included: false
|
|
||||||
},
|
|
||||||
{ key: 'thirdparty',
|
|
||||||
title: 'activity.bloc_thirdparty',
|
|
||||||
persons: [],
|
|
||||||
included: true
|
|
||||||
},
|
|
||||||
{ key: 'users',
|
|
||||||
title: 'activity.bloc_users',
|
|
||||||
persons: [],
|
|
||||||
included: true
|
|
||||||
},
|
|
||||||
],
|
|
||||||
addPersons: {
|
|
||||||
key: 'activity',
|
|
||||||
options: {
|
|
||||||
type: ['person', 'thirdparty'], // TODO add 'user'
|
|
||||||
priority: null,
|
|
||||||
uniq: false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
...mapState({
|
|
||||||
persons: state => state.activity.persons,
|
|
||||||
thirdParties: state => state.activity.thirdParties,
|
|
||||||
users: state => state.activity.users,
|
|
||||||
accompanyingCourse: state => state.activity.accompanyingPeriod
|
|
||||||
}),
|
|
||||||
getContext() {
|
|
||||||
return (this.accompanyingCourse) ? "accompanyingCourse" : "person";
|
|
||||||
},
|
|
||||||
contextPersonsBlocs() {
|
|
||||||
return this.personsBlocs.filter(bloc => bloc.included !== false);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.setPersonsInBloc();
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
setPersonsInBloc() {
|
|
||||||
let groups;
|
|
||||||
if (this.accompanyingCourse) {
|
|
||||||
groups = this.splitPersonsInGroups();
|
|
||||||
}
|
|
||||||
this.personsBlocs.forEach(bloc => {
|
|
||||||
if (this.accompanyingCourse) {
|
|
||||||
switch (bloc.key) {
|
|
||||||
case 'personsAssociated':
|
|
||||||
bloc.persons = groups.personsAssociated;
|
|
||||||
bloc.included = true;
|
|
||||||
break;
|
|
||||||
case 'personsNotAssociated':
|
|
||||||
bloc.persons = groups.personsNotAssociated;
|
|
||||||
bloc.included = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
switch (bloc.key) {
|
|
||||||
case 'persons':
|
|
||||||
bloc.persons = this.persons;
|
|
||||||
bloc.included = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
switch (bloc.key) {
|
|
||||||
case 'thirdparty':
|
|
||||||
bloc.persons = this.thirdParties;
|
|
||||||
break;
|
|
||||||
case 'users':
|
|
||||||
bloc.persons = this.users;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}, groups);
|
|
||||||
},
|
|
||||||
splitPersonsInGroups() {
|
|
||||||
let personsAssociated = [];
|
|
||||||
let personsNotAssociated = this.persons;
|
|
||||||
let participations = this.getCourseParticipations();
|
|
||||||
this.persons.forEach(person => {
|
|
||||||
participations.forEach(participation => {
|
|
||||||
if (person.id === participation.id) {
|
|
||||||
//console.log(person.id);
|
|
||||||
personsAssociated.push(person);
|
|
||||||
personsNotAssociated = personsNotAssociated.filter(p => p !== person);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return {
|
|
||||||
'personsAssociated': personsAssociated,
|
|
||||||
'personsNotAssociated': personsNotAssociated
|
|
||||||
};
|
|
||||||
},
|
|
||||||
getCourseParticipations() {
|
|
||||||
let participations = [];
|
|
||||||
this.accompanyingCourse.participations.forEach(participation => {
|
|
||||||
if (!participation.endDate) {
|
|
||||||
participations.push(participation.person);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return participations;
|
|
||||||
},
|
|
||||||
addNewPersons({ selected, modal }) {
|
|
||||||
console.log('@@@ CLICK button addNewPersons', selected);
|
|
||||||
selected.forEach(function(item) {
|
|
||||||
this.$store.dispatch('addPersonsInvolved', item);
|
|
||||||
}, this
|
|
||||||
);
|
|
||||||
this.$refs.addPersons.resetSearch(); // to cast child method
|
|
||||||
modal.showModal = false;
|
|
||||||
this.setPersonsInBloc();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
</style>
|
|
@@ -1,214 +0,0 @@
|
|||||||
<template>
|
|
||||||
<teleport to="#social-issues-acc">
|
|
||||||
|
|
||||||
<div class="container">
|
|
||||||
<div class="grid-4 clear">
|
|
||||||
<label>{{ $t('activity.social_issues') }}</label>
|
|
||||||
</div>
|
|
||||||
<div class="grid-8">
|
|
||||||
|
|
||||||
<check-social-issue
|
|
||||||
v-for="issue in socialIssuesList"
|
|
||||||
v-bind:key="issue.id"
|
|
||||||
v-bind:issue="issue"
|
|
||||||
v-bind:selection="socialIssuesSelected"
|
|
||||||
@updateSelected="updateIssuesSelected">
|
|
||||||
</check-social-issue>
|
|
||||||
|
|
||||||
<div class="my-3">
|
|
||||||
<VueMultiselect
|
|
||||||
name="otherIssues"
|
|
||||||
label="text"
|
|
||||||
track-by="id"
|
|
||||||
open-direction="bottom"
|
|
||||||
v-bind:close-on-select="true"
|
|
||||||
v-bind:preserve-search="false"
|
|
||||||
v-bind:reset-after="true"
|
|
||||||
v-bind:hide-selected="true"
|
|
||||||
v-bind:taggable="false"
|
|
||||||
v-bind:multiple="false"
|
|
||||||
v-bind:searchable="true"
|
|
||||||
v-bind:allow-empty="true"
|
|
||||||
v-bind:show-labels="false"
|
|
||||||
v-bind:loading="issueIsLoading"
|
|
||||||
v-bind:placeholder="$t('activity.choose_other_social_issue')"
|
|
||||||
v-bind:options="socialIssuesOther"
|
|
||||||
v-model="value"
|
|
||||||
@select="addIssueInList">
|
|
||||||
</VueMultiselect>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="container">
|
|
||||||
<div class="grid-4 clear">
|
|
||||||
<label>{{ $t('activity.social_actions') }}</label>
|
|
||||||
</div>
|
|
||||||
<div class="grid-8">
|
|
||||||
|
|
||||||
<div v-if="actionIsLoading === true">
|
|
||||||
<i class="chill-green fa fa-circle-o-notch fa-spin fa-lg"></i>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<check-social-action
|
|
||||||
v-if="socialIssuesSelected.length || socialActionsSelected.length"
|
|
||||||
v-for="action in socialActionsList"
|
|
||||||
v-bind:key="action.id"
|
|
||||||
v-bind:action="action"
|
|
||||||
v-bind:selection="socialActionsSelected"
|
|
||||||
@updateSelected="updateActionsSelected">
|
|
||||||
</check-social-action>
|
|
||||||
|
|
||||||
<span v-else class="inline-choice chill-no-data-statement mt-3">
|
|
||||||
{{ $t('activity.select_first_a_social_issue') }}
|
|
||||||
</span>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</teleport>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { readonly } from 'vue';
|
|
||||||
import VueMultiselect from 'vue-multiselect';
|
|
||||||
import CheckSocialIssue from './SocialIssuesAcc/CheckSocialIssue.vue';
|
|
||||||
import CheckSocialAction from './SocialIssuesAcc/CheckSocialAction.vue';
|
|
||||||
import { getSocialIssues, getSocialActionByIssue } from '../api.js';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: "SocialIssuesAcc",
|
|
||||||
components: {
|
|
||||||
CheckSocialIssue,
|
|
||||||
CheckSocialAction,
|
|
||||||
VueMultiselect
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
issueIsLoading: false,
|
|
||||||
actionIsLoading: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
socialIssuesList() {
|
|
||||||
return this.$store.state.activity.accompanyingPeriod.socialIssues;
|
|
||||||
},
|
|
||||||
socialIssuesSelected() {
|
|
||||||
return this.$store.state.activity.socialIssues;
|
|
||||||
},
|
|
||||||
socialIssuesOther() {
|
|
||||||
return this.$store.state.socialIssuesOther;
|
|
||||||
},
|
|
||||||
socialActionsList() {
|
|
||||||
return this.$store.state.socialActionsList;
|
|
||||||
},
|
|
||||||
socialActionsSelected() {
|
|
||||||
return this.$store.state.activity.socialActions;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
/* Load others issues in multiselect
|
|
||||||
*/
|
|
||||||
this.issueIsLoading = true;
|
|
||||||
getSocialIssues().then(response => new Promise((resolve, reject) => {
|
|
||||||
this.$store.commit('updateIssuesOther', response.results);
|
|
||||||
|
|
||||||
/* Add in list the issues already associated (if not yet listed)
|
|
||||||
*/
|
|
||||||
this.socialIssuesSelected.forEach(issue => {
|
|
||||||
if (this.socialIssuesList.filter(i => i.id === issue.id).length !== 1) {
|
|
||||||
this.$store.commit('addIssueInList', issue);
|
|
||||||
}
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
/* Remove from multiselect the issues that are not yet in checkbox list
|
|
||||||
*/
|
|
||||||
this.socialIssuesList.forEach(issue => {
|
|
||||||
this.$store.commit('removeIssueInOther', issue);
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
/* Filter issues
|
|
||||||
*/
|
|
||||||
this.$store.commit('filterList', 'issues');
|
|
||||||
|
|
||||||
/* Add in list the actions already associated (if not yet listed)
|
|
||||||
*/
|
|
||||||
this.socialActionsSelected.forEach(action => {
|
|
||||||
this.$store.commit('addActionInList', action);
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
/* Filter issues
|
|
||||||
*/
|
|
||||||
this.$store.commit('filterList', 'actions');
|
|
||||||
|
|
||||||
this.issueIsLoading = false;
|
|
||||||
resolve();
|
|
||||||
}));
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
|
|
||||||
/* When choosing an issue in multiselect, add it in checkboxes (as selected),
|
|
||||||
remove it from multiselect, and add socialActions concerned
|
|
||||||
*/
|
|
||||||
addIssueInList(value) {
|
|
||||||
//console.log('addIssueInList', value);
|
|
||||||
this.$store.commit('addIssueInList', value);
|
|
||||||
this.$store.commit('removeIssueInOther', value);
|
|
||||||
this.$store.dispatch('addIssueSelected', value);
|
|
||||||
this.updateActionsList();
|
|
||||||
},
|
|
||||||
/* Update value for selected issues checkboxes
|
|
||||||
*/
|
|
||||||
updateIssuesSelected(issues) {
|
|
||||||
//console.log('updateIssuesSelected', issues);
|
|
||||||
this.$store.dispatch('updateIssuesSelected', issues);
|
|
||||||
this.updateActionsList();
|
|
||||||
},
|
|
||||||
/* Update value for selected actions checkboxes
|
|
||||||
*/
|
|
||||||
updateActionsSelected(actions) {
|
|
||||||
//console.log('updateActionsSelected', actions);
|
|
||||||
this.$store.dispatch('updateActionsSelected', actions);
|
|
||||||
},
|
|
||||||
/* Add socialActions concerned: after reset, loop on each issue selected
|
|
||||||
to get social actions concerned
|
|
||||||
*/
|
|
||||||
updateActionsList() {
|
|
||||||
//console.log('updateActionsList');
|
|
||||||
this.resetActionsList();
|
|
||||||
this.socialIssuesSelected.forEach(item => {
|
|
||||||
|
|
||||||
this.actionIsLoading = true;
|
|
||||||
getSocialActionByIssue(item.id)
|
|
||||||
.then(actions => new Promise((resolve, reject) => {
|
|
||||||
|
|
||||||
actions.results.forEach(action => {
|
|
||||||
this.$store.commit('addActionInList', action);
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.$store.commit('filterList', 'actions');
|
|
||||||
|
|
||||||
this.actionIsLoading = false;
|
|
||||||
resolve();
|
|
||||||
}));
|
|
||||||
}, this);
|
|
||||||
},
|
|
||||||
/* Reset socialActions List: flush list and restore selected actions
|
|
||||||
*/
|
|
||||||
resetActionsList() {
|
|
||||||
this.$store.commit('resetActionsList');
|
|
||||||
this.socialActionsSelected.forEach(item => {
|
|
||||||
this.$store.commit('addActionInList', item);
|
|
||||||
}, this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style src="vue-multiselect/dist/vue-multiselect.css"></style>
|
|
||||||
<style lang="scss">
|
|
||||||
span.multiselect__single {
|
|
||||||
display: none !important;
|
|
||||||
}
|
|
||||||
</style>
|
|
@@ -1,34 +0,0 @@
|
|||||||
<template>
|
|
||||||
<span class="inline-choice">
|
|
||||||
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
v-model="selected"
|
|
||||||
name="action"
|
|
||||||
v-bind:id="action.id"
|
|
||||||
v-bind:value="action"
|
|
||||||
/>
|
|
||||||
<label class="inline" v-bind:for="action.id">
|
|
||||||
{{ action.text }}
|
|
||||||
</label>
|
|
||||||
|
|
||||||
</span><br>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
name: "CheckSocialAction",
|
|
||||||
props: [ 'action', 'selection' ],
|
|
||||||
emits: [ 'updateSelected' ],
|
|
||||||
computed: {
|
|
||||||
selected: {
|
|
||||||
set(value) {
|
|
||||||
this.$emit('updateSelected', value);
|
|
||||||
},
|
|
||||||
get() {
|
|
||||||
return this.selection;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
@@ -1,34 +0,0 @@
|
|||||||
<template>
|
|
||||||
<span class="inline-choice">
|
|
||||||
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
v-model="selected"
|
|
||||||
name="issue"
|
|
||||||
v-bind:id="issue.id"
|
|
||||||
v-bind:value="issue"
|
|
||||||
/>
|
|
||||||
<label class="inline" v-bind:for="issue.id">
|
|
||||||
{{ issue.text }}
|
|
||||||
</label>
|
|
||||||
|
|
||||||
</span><br>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
name: "CheckSocialIssue",
|
|
||||||
props: [ 'issue', 'selection' ],
|
|
||||||
emits: [ 'updateSelected' ],
|
|
||||||
computed: {
|
|
||||||
selected: {
|
|
||||||
set(value) {
|
|
||||||
this.$emit('updateSelected', value);
|
|
||||||
},
|
|
||||||
get() {
|
|
||||||
return this.selection;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
@@ -3,13 +3,6 @@ import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n'
|
|||||||
const appMessages = {
|
const appMessages = {
|
||||||
fr: {
|
fr: {
|
||||||
activity: {
|
activity: {
|
||||||
//
|
|
||||||
social_issues: "Problématiques sociales",
|
|
||||||
choose_other_social_issue: "Ajouter une autre problématique sociale...",
|
|
||||||
social_actions: "Actions d'accompagnement",
|
|
||||||
select_first_a_social_issue: "Sélectionnez d'abord une problématique sociale",
|
|
||||||
|
|
||||||
//
|
|
||||||
add_persons: "Ajouter des personnes concernées",
|
add_persons: "Ajouter des personnes concernées",
|
||||||
bloc_persons: "Usagers",
|
bloc_persons: "Usagers",
|
||||||
bloc_persons_associated: "Usagers du parcours",
|
bloc_persons_associated: "Usagers du parcours",
|
||||||
|
@@ -21,62 +21,11 @@ const removeIdFromValue = (string, id) => {
|
|||||||
const store = createStore({
|
const store = createStore({
|
||||||
strict: debug,
|
strict: debug,
|
||||||
state: {
|
state: {
|
||||||
activity: window.activity,
|
activity: window.activity
|
||||||
socialIssuesOther: [],
|
},
|
||||||
socialActionsList: [],
|
getters: {
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
|
|
||||||
// SocialIssueAcc
|
|
||||||
addIssueInList(state, issue) {
|
|
||||||
//console.log('add issue list', issue.id);
|
|
||||||
state.activity.accompanyingPeriod.socialIssues.push(issue);
|
|
||||||
},
|
|
||||||
addIssueSelected(state, issue) {
|
|
||||||
//console.log('add issue selected', issue.id);
|
|
||||||
state.activity.socialIssues.push(issue);
|
|
||||||
},
|
|
||||||
updateIssuesSelected(state, issues) {
|
|
||||||
//console.log('update issues selected', issues);
|
|
||||||
state.activity.socialIssues = issues;
|
|
||||||
},
|
|
||||||
updateIssuesOther(state, payload) {
|
|
||||||
//console.log('update issues other');
|
|
||||||
state.socialIssuesOther = payload;
|
|
||||||
},
|
|
||||||
removeIssueInOther(state, issue) {
|
|
||||||
//console.log('remove issue other', issue.id);
|
|
||||||
state.socialIssuesOther = state.socialIssuesOther.filter(i => i.id !== issue.id);
|
|
||||||
},
|
|
||||||
resetActionsList(state) {
|
|
||||||
//console.log('reset list actions');
|
|
||||||
state.socialActionsList = [];
|
|
||||||
},
|
|
||||||
addActionInList(state, action) {
|
|
||||||
//console.log('add action list', action.id);
|
|
||||||
state.socialActionsList.push(action);
|
|
||||||
},
|
|
||||||
updateActionsSelected(state, actions) {
|
|
||||||
//console.log('update actions selected', actions);
|
|
||||||
state.activity.socialActions = actions;
|
|
||||||
},
|
|
||||||
filterList(state, list) {
|
|
||||||
const filterList = (list) => {
|
|
||||||
// remove duplicates entries
|
|
||||||
list = list.filter((value, index) => list.findIndex(array => array.id === value.id) === index);
|
|
||||||
// alpha sort
|
|
||||||
list.sort((a,b) => (a.text > b.text) ? 1 : ((b.text > a.text) ? -1 : 0));
|
|
||||||
return list;
|
|
||||||
};
|
|
||||||
if (list === 'issues') {
|
|
||||||
state.activity.accompanyingPeriod.socialIssues = filterList(state.activity.accompanyingPeriod.socialIssues);
|
|
||||||
}
|
|
||||||
if (list === 'actions') {
|
|
||||||
state.socialActionsList = filterList(state.socialActionsList);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// ConcernedGroups
|
|
||||||
addPersonsInvolved(state, payload) {
|
addPersonsInvolved(state, payload) {
|
||||||
//console.log('### mutation addPersonsInvolved', payload.result.type);
|
//console.log('### mutation addPersonsInvolved', payload.result.type);
|
||||||
switch (payload.result.type) {
|
switch (payload.result.type) {
|
||||||
@@ -107,29 +56,8 @@ const store = createStore({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
addIssueSelected({ commit }, issue) {
|
|
||||||
let aSocialIssues = document.getElementById("chill_activitybundle_activity_socialIssues");
|
|
||||||
aSocialIssues.value = addIdToValue(aSocialIssues.value, issue.id);
|
|
||||||
commit('addIssueSelected', issue);
|
|
||||||
},
|
|
||||||
updateIssuesSelected({ commit }, payload) {
|
|
||||||
let aSocialIssues = document.getElementById("chill_activitybundle_activity_socialIssues");
|
|
||||||
aSocialIssues.value = '';
|
|
||||||
payload.forEach(item => {
|
|
||||||
aSocialIssues.value = addIdToValue(aSocialIssues.value, item.id);
|
|
||||||
});
|
|
||||||
commit('updateIssuesSelected', payload);
|
|
||||||
},
|
|
||||||
updateActionsSelected({ commit }, payload) {
|
|
||||||
let aSocialActions = document.getElementById("chill_activitybundle_activity_socialActions");
|
|
||||||
aSocialActions.value = '';
|
|
||||||
payload.forEach(item => {
|
|
||||||
aSocialActions.value = addIdToValue(aSocialActions.value, item.id);
|
|
||||||
});
|
|
||||||
commit('updateActionsSelected', payload);
|
|
||||||
},
|
|
||||||
addPersonsInvolved({ commit }, payload) {
|
addPersonsInvolved({ commit }, payload) {
|
||||||
//console.log('### action addPersonsInvolved', payload.result.type);
|
console.log('### action addPersonsInvolved', payload.result.type);
|
||||||
switch (payload.result.type) {
|
switch (payload.result.type) {
|
||||||
case 'person':
|
case 'person':
|
||||||
let aPersons = document.getElementById("chill_activitybundle_activity_persons");
|
let aPersons = document.getElementById("chill_activitybundle_activity_persons");
|
||||||
@@ -147,7 +75,7 @@ const store = createStore({
|
|||||||
commit('addPersonsInvolved', payload);
|
commit('addPersonsInvolved', payload);
|
||||||
},
|
},
|
||||||
removePersonInvolved({ commit }, payload) {
|
removePersonInvolved({ commit }, payload) {
|
||||||
//console.log('### action removePersonInvolved', payload);
|
console.log('### action removePersonInvolved', payload);
|
||||||
switch (payload.type) {
|
switch (payload.type) {
|
||||||
case 'person':
|
case 'person':
|
||||||
let aPersons = document.getElementById("chill_activitybundle_activity_persons");
|
let aPersons = document.getElementById("chill_activitybundle_activity_persons");
|
||||||
|
@@ -1,8 +1,4 @@
|
|||||||
<h1>{{ "Update activity"|trans ~ ' :' }}
|
<h1>{{ "Update activity"|trans }}</h1>
|
||||||
<span style="font-size: 70%; text-transform: lowercase; margin-left: 1em;">
|
|
||||||
{{ entity.type.name|localize_translatable_string }}
|
|
||||||
</span>
|
|
||||||
</h1>
|
|
||||||
|
|
||||||
{{ form_start(edit_form) }}
|
{{ form_start(edit_form) }}
|
||||||
{{ form_errors(edit_form) }}
|
{{ form_errors(edit_form) }}
|
||||||
@@ -23,15 +19,13 @@
|
|||||||
{{ form_row(edit_form.scope) }}
|
{{ form_row(edit_form.scope) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{%- if edit_form.socialIssues is defined -%}
|
|
||||||
{{ form_row(edit_form.socialIssues) }}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{%- if edit_form.socialActions is defined -%}
|
{%- if edit_form.socialActions is defined -%}
|
||||||
{{ form_row(edit_form.socialActions) }}
|
{{ form_row(edit_form.socialActions) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<div id="social-issues-acc"></div>
|
{%- if edit_form.socialIssues is defined -%}
|
||||||
|
{{ form_row(edit_form.socialIssues) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{%- if edit_form.reasons is defined -%}
|
{%- if edit_form.reasons is defined -%}
|
||||||
{{ form_row(edit_form.reasons) }}
|
{{ form_row(edit_form.reasons) }}
|
||||||
@@ -99,7 +93,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<button class="sc-button bt-update" type="submit">{{ 'Save'|trans }}</button>
|
<button class="sc-button bt-update" type="submit">{{ 'Save activity'|trans }}</button>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
{{ form_end(edit_form) }}
|
{{ form_end(edit_form) }}
|
||||||
|
@@ -10,20 +10,16 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block js %}
|
{% block js %}
|
||||||
{{ parent() }}
|
|
||||||
{{ encore_entry_link_tags('async_upload') }}
|
{{ encore_entry_link_tags('async_upload') }}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
window.addEventListener('DOMContentLoaded', function (e) {
|
chill.displayAlertWhenLeavingModifiedForm('form[name="{{ edit_form.vars.form.vars.name }}"]',
|
||||||
chill.displayAlertWhenLeavingModifiedForm('form[name="{{ edit_form.vars.form.vars.name }}"]',
|
|
||||||
'{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}');
|
'{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}');
|
||||||
});
|
|
||||||
window.activity = {{ activity_json|json_encode|raw }};
|
window.activity = {{ activity_json|json_encode|raw }};
|
||||||
</script>
|
</script>
|
||||||
{{ encore_entry_script_tags('vue_activity') }}
|
{{ encore_entry_script_tags('vue_activity') }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block css %}
|
{% block css %}
|
||||||
{{ parent() }}
|
|
||||||
{{ encore_entry_link_tags('async_upload') }}
|
{{ encore_entry_link_tags('async_upload') }}
|
||||||
{{ encore_entry_link_tags('vue_activity') }}
|
{{ encore_entry_link_tags('vue_activity') }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@@ -21,17 +21,15 @@
|
|||||||
{% block title 'Update activity'|trans %}
|
{% block title 'Update activity'|trans %}
|
||||||
|
|
||||||
{% block personcontent %}
|
{% block personcontent %}
|
||||||
<div id="activity"></div> {# <=== vue component #}
|
|
||||||
{% include 'ChillActivityBundle:Activity:edit.html.twig' %}
|
{% include 'ChillActivityBundle:Activity:edit.html.twig' %}
|
||||||
|
<div id="activity"></div> {# <=== vue component #}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block js %}
|
{% block js %}
|
||||||
{{ encore_entry_link_tags('async_upload') }}
|
{{ encore_entry_link_tags('async_upload') }}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
window.addEventListener('DOMContentLoaded', function (e) {
|
chill.displayAlertWhenLeavingModifiedForm('form[name="{{ edit_form.vars.form.vars.name }}"]',
|
||||||
chill.displayAlertWhenLeavingModifiedForm('form[name="{{ edit_form.vars.form.vars.name }}"]',
|
|
||||||
'{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}');
|
'{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}');
|
||||||
});
|
|
||||||
window.activity = {{ activity_json|json_encode|raw }};
|
window.activity = {{ activity_json|json_encode|raw }};
|
||||||
</script>
|
</script>
|
||||||
{{ encore_entry_script_tags('vue_activity') }}
|
{{ encore_entry_script_tags('vue_activity') }}
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
</p>
|
</p>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
||||||
<div class="flex-table list-records context-{{ context }}">
|
<div class="flex-table list-records {{ context }}">
|
||||||
<!--
|
<!--
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -54,20 +54,6 @@
|
|||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if context == 'person' and activity.accompanyingPeriod is not empty %}
|
|
||||||
<div class="accompanyingPeriodLink" style="margin-top: 1rem">
|
|
||||||
<a
|
|
||||||
href="{{ chill_path_add_return_path(
|
|
||||||
"chill_person_accompanying_course_index",
|
|
||||||
{ 'accompanying_period_id': activity.accompanyingPeriod.id }
|
|
||||||
) }}"
|
|
||||||
>
|
|
||||||
<i class="fa fa-random"></i>
|
|
||||||
{{ activity.accompanyingPeriod.id }}
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="item-col">
|
<div class="item-col">
|
||||||
@@ -161,14 +147,13 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{%
|
{%
|
||||||
if activity.comment.comment is not empty
|
if activity.comment.comment is not empty
|
||||||
or activity.persons|length > 0
|
or activity.persons|length > 0
|
||||||
or activity.thirdParties|length > 0
|
or activity.thirdParties|length > 0
|
||||||
or activity.users|length > 0
|
or activity.users|length > 0
|
||||||
%}
|
%}
|
||||||
<div class="item-row details">
|
<div class="item-row details">
|
||||||
<div class="item-col">
|
<div class="item-col">
|
||||||
|
|
||||||
{% include 'ChillActivityBundle:Activity:concernedGroups.html.twig' with {'context': context, 'with_display': 'row', 'entity': activity } %}
|
{% include 'ChillActivityBundle:Activity:concernedGroups.html.twig' with {'context': context, 'with_display': 'row', 'entity': activity } %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -185,13 +170,10 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if context != 'person' %}
|
<ul class="record_actions">
|
||||||
{# TODO set this condition in configuration #}
|
<li>
|
||||||
<ul class="record_actions">
|
<a href="{{ path('chill_activity_activity_new', {'person_id': person_id, 'accompanying_period_id': accompanying_course_id}) }}" class="sc-button bt-create">
|
||||||
<li>
|
{{ 'Add a new activity' | trans }}
|
||||||
<a href="{{ path('chill_activity_activity_new', {'person_id': person_id, 'accompanying_period_id': accompanying_course_id}) }}" class="sc-button bt-create">
|
</a>
|
||||||
{{ 'Add a new activity' | trans }}
|
</li>
|
||||||
</a>
|
</ul>
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
{% endif %}
|
|
||||||
|
@@ -1,8 +1,4 @@
|
|||||||
<h1>{{ "Activity creation"|trans ~ ' :' }}
|
<h1>{{ "Activity creation"|trans }}</h1>
|
||||||
<span style="font-size: 70%; text-transform: lowercase; margin-left: 1em;">
|
|
||||||
{{ entity.type.name|localize_translatable_string }}
|
|
||||||
</span>
|
|
||||||
</h1>
|
|
||||||
|
|
||||||
{{ form_start(form) }}
|
{{ form_start(form) }}
|
||||||
{{ form_errors(form) }}
|
{{ form_errors(form) }}
|
||||||
@@ -24,15 +20,14 @@
|
|||||||
{{ form_row(form.scope) }}
|
{{ form_row(form.scope) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{%- if form.socialIssues is defined -%}
|
|
||||||
{{ form_row(form.socialIssues) }}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{%- if form.socialActions is defined -%}
|
{%- if form.socialActions is defined -%}
|
||||||
{{ form_row(form.socialActions) }}
|
{{ form_row(form.socialActions) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<div id="social-issues-acc"></div>
|
{%- if form.socialIssues is defined -%}
|
||||||
|
{{ form_row(form.socialIssues) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
{%- if form.reasons is defined -%}
|
{%- if form.reasons is defined -%}
|
||||||
{{ form_row(form.reasons) }}
|
{{ form_row(form.reasons) }}
|
||||||
@@ -98,7 +93,7 @@
|
|||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<button class="sc-button bt-create" type="submit">
|
<button class="sc-button bt-create" type="submit">
|
||||||
{{ 'Create'|trans }}
|
{{ 'Add a new activity'|trans }}
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@@ -10,20 +10,16 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block js %}
|
{% block js %}
|
||||||
{{ parent() }}
|
|
||||||
{{ encore_entry_script_tags('async_upload') }}
|
{{ encore_entry_script_tags('async_upload') }}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
window.addEventListener('DOMContentLoaded', function (e) {
|
chill.displayAlertWhenLeavingUnsubmittedForm('form[name="{{ form.vars.form.vars.name }}"]',
|
||||||
chill.displayAlertWhenLeavingUnsubmittedForm('form[name="{{ form.vars.form.vars.name }}"]',
|
|
||||||
'{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}');
|
'{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}');
|
||||||
});
|
|
||||||
window.activity = {{ activity_json|json_encode|raw }};
|
window.activity = {{ activity_json|json_encode|raw }};
|
||||||
</script>
|
</script>
|
||||||
{{ encore_entry_script_tags('vue_activity') }}
|
{{ encore_entry_script_tags('vue_activity') }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block css %}
|
{% block css %}
|
||||||
{{ parent() }}
|
|
||||||
<link rel="stylesheet" href="{{ asset('build/async_upload.css') }}"/>
|
<link rel="stylesheet" href="{{ asset('build/async_upload.css') }}"/>
|
||||||
{{ encore_entry_link_tags('vue_activity') }}
|
{{ encore_entry_link_tags('vue_activity') }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@@ -5,17 +5,15 @@
|
|||||||
{% block title 'Activity creation' |trans %}
|
{% block title 'Activity creation' |trans %}
|
||||||
|
|
||||||
{% block personcontent %}
|
{% block personcontent %}
|
||||||
<div id="activity"></div> {# <=== vue component #}
|
|
||||||
{% include 'ChillActivityBundle:Activity:new.html.twig' with {'context': 'person'} %}
|
{% include 'ChillActivityBundle:Activity:new.html.twig' with {'context': 'person'} %}
|
||||||
|
<div id="activity"></div> {# <=== vue component #}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block js %}
|
{% block js %}
|
||||||
{{ encore_entry_link_tags('async_upload') }}
|
{{ encore_entry_link_tags('async_upload') }}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
window.addEventListener('DOMContentLoaded', function (e) {
|
chill.displayAlertWhenLeavingUnsubmittedForm('form[name="{{ form.vars.form.vars.name }}"]',
|
||||||
chill.displayAlertWhenLeavingUnsubmittedForm('form[name="{{ form.vars.form.vars.name }}"]',
|
|
||||||
'{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}');
|
'{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}');
|
||||||
});
|
|
||||||
window.activity = {{ activity_json|json_encode|raw }};
|
window.activity = {{ activity_json|json_encode|raw }};
|
||||||
</script>
|
</script>
|
||||||
{{ encore_entry_script_tags('vue_activity') }}
|
{{ encore_entry_script_tags('vue_activity') }}
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
{% for row in data %}
|
{% for row in data %}
|
||||||
<h3>{{ row.activityTypeCategory.name|localize_translatable_string }}</h3>
|
<h3>{{ row.activityTypeCategory.name|localize_translatable_string }}</h3>
|
||||||
<div class="activity-row">
|
<div style="display:flex;justify-content:center;gap:12px;flex-wrap:wrap;">
|
||||||
{% for activityType in row.activityTypes %}
|
{% for activityType in row.activityTypes %}
|
||||||
|
|
||||||
{% set person_id = null %}
|
{% set person_id = null %}
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
<a href="{{ path('chill_activity_activity_new', {'person_id': person_id, 'activityType_id': activityType.id, 'accompanying_period_id': accompanying_course_id }) }}">
|
<a href="{{ path('chill_activity_activity_new', {'person_id': person_id, 'activityType_id': activityType.id, 'accompanying_period_id': accompanying_course_id }) }}">
|
||||||
|
|
||||||
<div class="bloc btn btn-primary btn-lg btn-block">
|
<div style="width:200px;height:200px;border:1px dotted red;display:flex;justify-content:center;align-items:center;align-content:center;">
|
||||||
{{ activityType.name|localize_translatable_string }}
|
{{ activityType.name|localize_translatable_string }}
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
@@ -117,7 +117,7 @@
|
|||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a class="sc-button bt-update" href="{{ path('chill_activity_activity_edit', { 'id': entity.id, 'person_id': person_id, 'accompanying_period_id': accompanying_course_id }) }}">
|
<a class="sc-button bt-update" href="{{ path('chill_activity_activity_edit', { 'id': entity.id, 'person_id': person_id, 'accompanying_period_id': accompanying_course_id }) }}">
|
||||||
{{ 'Edit'|trans }}
|
{{ 'Edit the activity'|trans }}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{# TODO
|
{# TODO
|
||||||
|
@@ -32,7 +32,6 @@ services:
|
|||||||
- "@chill.main.helper.translatable_string"
|
- "@chill.main.helper.translatable_string"
|
||||||
- "%chill_activity.form.time_duration%"
|
- "%chill_activity.form.time_duration%"
|
||||||
- '@Chill\PersonBundle\Templating\Entity\SocialIssueRender'
|
- '@Chill\PersonBundle\Templating\Entity\SocialIssueRender'
|
||||||
- '@Chill\PersonBundle\Templating\Entity\SocialActionRender'
|
|
||||||
tags:
|
tags:
|
||||||
- { name: form.type, alias: chill_activitybundle_activity }
|
- { name: form.type, alias: chill_activitybundle_activity }
|
||||||
|
|
||||||
|
@@ -38,7 +38,7 @@ Required: Obligatoire
|
|||||||
Persons: Personnes
|
Persons: Personnes
|
||||||
Users: Utilisateurs
|
Users: Utilisateurs
|
||||||
Emergency: Urgent
|
Emergency: Urgent
|
||||||
Sent received: Entrant / Sortant
|
Sent received: Envoyer / Recevoir
|
||||||
Sent: Envoyer
|
Sent: Envoyer
|
||||||
Received: Recevoir
|
Received: Recevoir
|
||||||
by: 'Par '
|
by: 'Par '
|
||||||
@@ -74,7 +74,6 @@ Users concerned: T(M)S
|
|||||||
activity:
|
activity:
|
||||||
Insert a document: Insérer un document
|
Insert a document: Insérer un document
|
||||||
Remove a document: Supprimer le document
|
Remove a document: Supprimer le document
|
||||||
comment: Commentaire
|
|
||||||
|
|
||||||
|
|
||||||
#timeline
|
#timeline
|
||||||
|
@@ -22,7 +22,6 @@ use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
|||||||
use Symfony\Component\DependencyInjection\Reference;
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
use Chill\MainBundle\Routing\MenuComposer;
|
use Chill\MainBundle\Routing\MenuComposer;
|
||||||
use Symfony\Component\DependencyInjection\Definition;
|
use Symfony\Component\DependencyInjection\Definition;
|
||||||
use Symfony\Component\DependencyInjection\Alias;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -50,32 +49,29 @@ class CRUDControllerCompilerPass implements CompilerPassInterface
|
|||||||
private function configureCrudController(ContainerBuilder $container, array $crudEntry, string $apiOrCrud): void
|
private function configureCrudController(ContainerBuilder $container, array $crudEntry, string $apiOrCrud): void
|
||||||
{
|
{
|
||||||
$controllerClass = $crudEntry['controller'];
|
$controllerClass = $crudEntry['controller'];
|
||||||
|
|
||||||
$controllerServiceName = 'cs'.$apiOrCrud.'_'.$crudEntry['name'].'_controller';
|
$controllerServiceName = 'cs'.$apiOrCrud.'_'.$crudEntry['name'].'_controller';
|
||||||
|
|
||||||
// create config parameter in container
|
|
||||||
$param = 'chill_main_'.$apiOrCrud.'_config_'.$crudEntry['name'];
|
|
||||||
$container->setParameter($param, $crudEntry);
|
|
||||||
|
|
||||||
if ($container->hasDefinition($controllerClass)) {
|
if ($container->hasDefinition($controllerClass)) {
|
||||||
// create an alias to not to re-create the service
|
$controller = $container->getDefinition($controllerClass);
|
||||||
$alias = new Alias($controllerClass, true);
|
$container->removeDefinition($controllerClass);
|
||||||
$container->setAlias($controllerServiceName, $alias);
|
$alreadyDefined = true;
|
||||||
|
|
||||||
// add the "addMethodCall"
|
|
||||||
$container->getDefinition($controllerClass)
|
|
||||||
->addMethodCall('setCrudConfig', ['%'.$param.'%']);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$controller = new Definition($controllerClass);
|
$controller = new Definition($controllerClass);
|
||||||
|
$alreadyDefined = false;
|
||||||
|
}
|
||||||
|
|
||||||
$controller->addTag('controller.service_arguments');
|
$controller->addTag('controller.service_arguments');
|
||||||
|
if (FALSE === $alreadyDefined) {
|
||||||
$controller->setAutoconfigured(true);
|
$controller->setAutoconfigured(true);
|
||||||
$controller->setPublic(true);
|
$controller->setPublic(true);
|
||||||
|
|
||||||
$controller->addMethodCall('setCrudConfig', ['%'.$param.'%']);
|
|
||||||
|
|
||||||
$container->setDefinition($controllerServiceName, $controller);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$param = 'chill_main_'.$apiOrCrud.'_config_'.$crudEntry['name'];
|
||||||
|
$container->setParameter($param, $crudEntry);
|
||||||
|
$controller->addMethodCall('setCrudConfig', ['%'.$param.'%']);
|
||||||
|
|
||||||
|
$container->setDefinition($controllerServiceName, $controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -8,11 +8,6 @@ use Symfony\Component\HttpFoundation\Response;
|
|||||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||||
use Chill\MainBundle\Pagination\PaginatorInterface;
|
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
|
class AbstractCRUDController extends AbstractController
|
||||||
{
|
{
|
||||||
@@ -253,24 +248,4 @@ class AbstractCRUDController extends AbstractController
|
|||||||
{
|
{
|
||||||
return $this->get('validator');
|
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,
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -359,10 +359,9 @@ class ApiController extends AbstractCRUDController
|
|||||||
* 6. validate the base entity (not the deserialized one). Groups are fetched from getValidationGroups, validation is perform by `validate`
|
* 6. validate the base entity (not the deserialized one). Groups are fetched from getValidationGroups, validation is perform by `validate`
|
||||||
* 7. run onAfterValidation
|
* 7. run onAfterValidation
|
||||||
* 8. if errors, return a 422 response with errors
|
* 8. if errors, return a 422 response with errors
|
||||||
* 9. if $forcePersist === true, persist the entity
|
* 9. flush the data
|
||||||
* 10. flush the data
|
* 10. run onAfterFlush
|
||||||
* 11. run onAfterFlush
|
* 11. return a 202 response for DELETE with empty body, or HTTP 200 for post with serialized posted entity
|
||||||
* 12. return a 202 response for DELETE with empty body, or HTTP 200 for post with serialized posted entity
|
|
||||||
*
|
*
|
||||||
* @param string action
|
* @param string action
|
||||||
* @param mixed id
|
* @param mixed id
|
||||||
@@ -371,12 +370,11 @@ class ApiController extends AbstractCRUDController
|
|||||||
* @param string $property the name of the property. This will be used to make a `add+$property` and `remove+$property` method
|
* @param string $property the name of the property. This will be used to make a `add+$property` and `remove+$property` method
|
||||||
* @param string $postedDataType the type of the posted data (the content)
|
* @param string $postedDataType the type of the posted data (the content)
|
||||||
* @param string $postedDataContext a context to deserialize posted data (the content)
|
* @param string $postedDataContext a context to deserialize posted data (the content)
|
||||||
* @param bool $forcePersist force to persist the created element (only for POST request)
|
|
||||||
* @throw BadRequestException if unable to deserialize the posted data
|
* @throw BadRequestException if unable to deserialize the posted data
|
||||||
* @throw BadRequestException if the method is not POST or DELETE
|
* @throw BadRequestException if the method is not POST or DELETE
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected function addRemoveSomething(string $action, $id, Request $request, string $_format, string $property, string $postedDataType, array $postedDataContext = [], bool $forcePersist = false): Response
|
protected function addRemoveSomething(string $action, $id, Request $request, string $_format, string $property, string $postedDataType, $postedDataContext = []): Response
|
||||||
{
|
{
|
||||||
$entity = $this->getEntity($action, $id, $request);
|
$entity = $this->getEntity($action, $id, $request);
|
||||||
|
|
||||||
@@ -431,10 +429,6 @@ class ApiController extends AbstractCRUDController
|
|||||||
return $this->json($errors, 422);
|
return $this->json($errors, 422);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($forcePersist && $request->getMethod() === Request::METHOD_POST) {
|
|
||||||
$this->getDoctrine()->getManager()->persist($postedData);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->getDoctrine()->getManager()->flush();
|
$this->getDoctrine()->getManager()->flush();
|
||||||
|
|
||||||
|
|
||||||
|
@@ -142,11 +142,11 @@ class CRUDRoutesLoader extends Loader
|
|||||||
protected function loadApi(array $crudConfig): RouteCollection
|
protected function loadApi(array $crudConfig): RouteCollection
|
||||||
{
|
{
|
||||||
$collection = new RouteCollection();
|
$collection = new RouteCollection();
|
||||||
$controller = 'csapi_'.$crudConfig['name'].'_controller';
|
$controller ='csapi_'.$crudConfig['name'].'_controller';
|
||||||
|
|
||||||
foreach ($crudConfig['actions'] as $name => $action) {
|
foreach ($crudConfig['actions'] as $name => $action) {
|
||||||
// filter only on single actions
|
// filter only on single actions
|
||||||
$singleCollection = $action['single_collection'] ?? $name === '_entity' ? 'single' : NULL;
|
$singleCollection = $action['single-collection'] ?? $name === '_entity' ? 'single' : NULL;
|
||||||
if ('collection' === $singleCollection) {
|
if ('collection' === $singleCollection) {
|
||||||
// continue;
|
// continue;
|
||||||
}
|
}
|
||||||
@@ -171,7 +171,7 @@ class CRUDRoutesLoader extends Loader
|
|||||||
// path are rewritten
|
// path are rewritten
|
||||||
// if name === 'default', we rewrite it to nothing :-)
|
// if name === 'default', we rewrite it to nothing :-)
|
||||||
$localName = \in_array($name, [ '_entity', '_index' ]) ? '' : '/'.$name;
|
$localName = \in_array($name, [ '_entity', '_index' ]) ? '' : '/'.$name;
|
||||||
if ('collection' === $action['single_collection'] || '_index' === $name) {
|
if ('collection' === $action['single-collection'] || '_index' === $name) {
|
||||||
$localPath = $action['path'] ?? $localName.'.{_format}';
|
$localPath = $action['path'] ?? $localName.'.{_format}';
|
||||||
} else {
|
} else {
|
||||||
$localPath = $action['path'] ?? '/{id}'.$localName.'.{_format}';
|
$localPath = $action['path'] ?? '/{id}'.$localName.'.{_format}';
|
||||||
|
@@ -36,7 +36,6 @@ use Chill\MainBundle\Search\SearchProvider;
|
|||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||||
use Chill\MainBundle\Search\SearchApi;
|
use Chill\MainBundle\Search\SearchApi;
|
||||||
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class SearchController
|
* Class SearchController
|
||||||
@@ -152,14 +151,11 @@ class SearchController extends AbstractController
|
|||||||
{
|
{
|
||||||
//TODO this is an incomplete implementation
|
//TODO this is an incomplete implementation
|
||||||
$query = $request->query->get('q', '');
|
$query = $request->query->get('q', '');
|
||||||
$types = $request->query->get('type', []);
|
|
||||||
|
|
||||||
if (count($types) === 0) {
|
$results = $this->searchApi->getResults($query, 0, 150);
|
||||||
throw new BadRequestException("The request must contains at "
|
$paginator = $this->paginatorFactory->create(count($results));
|
||||||
." one type");
|
|
||||||
}
|
|
||||||
|
|
||||||
$collection = $this->searchApi->getResults($query, $types, []);
|
$collection = new Collection($results, $paginator);
|
||||||
|
|
||||||
return $this->json($collection);
|
return $this->json($collection);
|
||||||
}
|
}
|
||||||
|
@@ -1,27 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\MainBundle\Controller;
|
|
||||||
|
|
||||||
use Chill\MainBundle\CRUD\Controller\ApiController;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
|
||||||
|
|
||||||
class UserApiController extends ApiController
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @Route(
|
|
||||||
* "/api/1.0/main/whoami.{_format}",
|
|
||||||
* name="chill_main_user_whoami",
|
|
||||||
* requirements={
|
|
||||||
* "_format": "json"
|
|
||||||
* }
|
|
||||||
* )
|
|
||||||
*/
|
|
||||||
public function whoami($_format): JsonResponse
|
|
||||||
{
|
|
||||||
return $this->json($this->getUser(), JsonResponse::HTTP_OK, [],
|
|
||||||
[ "groups" => [ "read" ] ]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -195,9 +195,7 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
|
|||||||
->prependExtensionConfig(
|
->prependExtensionConfig(
|
||||||
'doctrine',
|
'doctrine',
|
||||||
[
|
[
|
||||||
'dbal' => [
|
'dbal' => [
|
||||||
// ignore views:
|
|
||||||
'schema_filter' => '~^(?!view_)~',
|
|
||||||
// This is mandatory since we are using postgis as database.
|
// This is mandatory since we are using postgis as database.
|
||||||
'mapping_types' => [
|
'mapping_types' => [
|
||||||
'geometry' => 'string',
|
'geometry' => 'string',
|
||||||
@@ -279,8 +277,7 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
|
|||||||
'methods' => [
|
'methods' => [
|
||||||
Request::METHOD_GET => true,
|
Request::METHOD_GET => true,
|
||||||
Request::METHOD_POST => true,
|
Request::METHOD_POST => true,
|
||||||
Request::METHOD_HEAD => true,
|
Request::METHOD_HEAD => true
|
||||||
Request::METHOD_PATCH => true
|
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
@@ -322,8 +319,7 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
|
|||||||
'_entity' => [
|
'_entity' => [
|
||||||
'methods' => [
|
'methods' => [
|
||||||
Request::METHOD_GET => true,
|
Request::METHOD_GET => true,
|
||||||
Request::METHOD_HEAD => true,
|
Request::METHOD_HEAD => true
|
||||||
Request::METHOD_POST => true,
|
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
@@ -347,28 +343,7 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
|
|||||||
]
|
]
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
],
|
]
|
||||||
[
|
|
||||||
'class' => \Chill\MainBundle\Entity\User::class,
|
|
||||||
'controller' => \Chill\MainBundle\Controller\UserApiController::class,
|
|
||||||
'name' => 'user',
|
|
||||||
'base_path' => '/api/1.0/main/user',
|
|
||||||
'base_role' => 'ROLE_USER',
|
|
||||||
'actions' => [
|
|
||||||
'_index' => [
|
|
||||||
'methods' => [
|
|
||||||
Request::METHOD_GET => true,
|
|
||||||
Request::METHOD_HEAD => true
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'_entity' => [
|
|
||||||
'methods' => [
|
|
||||||
Request::METHOD_GET => true,
|
|
||||||
Request::METHOD_HEAD => true,
|
|
||||||
]
|
|
||||||
],
|
|
||||||
]
|
|
||||||
],
|
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@@ -205,7 +205,7 @@ class Configuration implements ConfigurationInterface
|
|||||||
->ignoreExtraKeys(false)
|
->ignoreExtraKeys(false)
|
||||||
->info('the requirements for the route. Will be set to `[ \'id\' => \'\d+\' ]` if left empty.')
|
->info('the requirements for the route. Will be set to `[ \'id\' => \'\d+\' ]` if left empty.')
|
||||||
->end()
|
->end()
|
||||||
->enumNode('single_collection')
|
->enumNode('single-collection')
|
||||||
->values(['single', 'collection'])
|
->values(['single', 'collection'])
|
||||||
->defaultValue('single')
|
->defaultValue('single')
|
||||||
->info('indicates if the returned object is a single element or a collection. '.
|
->info('indicates if the returned object is a single element or a collection. '.
|
||||||
|
@@ -116,7 +116,7 @@ class Address
|
|||||||
* @ORM\Column(type="date")
|
* @ORM\Column(type="date")
|
||||||
* @groups({"write"})
|
* @groups({"write"})
|
||||||
*/
|
*/
|
||||||
private \DateTime $validFrom;
|
private $validFrom;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates when the address ends. Used to build an history
|
* Indicates when the address ends. Used to build an history
|
||||||
@@ -127,12 +127,11 @@ class Address
|
|||||||
* @ORM\Column(type="date", nullable=true)
|
* @ORM\Column(type="date", nullable=true)
|
||||||
* @groups({"write"})
|
* @groups({"write"})
|
||||||
*/
|
*/
|
||||||
private ?\DateTime $validTo = null;
|
private $validTo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True if the address is a "no address", aka homeless person, ...
|
* True if the address is a "no address", aka homeless person, ...
|
||||||
* @groups({"write"})
|
* @groups({"write"})
|
||||||
* @ORM\Column(type="boolean")
|
|
||||||
*
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
@@ -299,7 +298,7 @@ class Address
|
|||||||
* @param bool $isNoAddress
|
* @param bool $isNoAddress
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setIsNoAddress(bool $isNoAddress): self
|
public function setIsNoAddress(bool $isNoAddress)
|
||||||
{
|
{
|
||||||
$this->isNoAddress = $isNoAddress;
|
$this->isNoAddress = $isNoAddress;
|
||||||
return $this;
|
return $this;
|
||||||
|
@@ -26,7 +26,7 @@ class PostalCode
|
|||||||
* @ORM\Id
|
* @ORM\Id
|
||||||
* @ORM\Column(name="id", type="integer")
|
* @ORM\Column(name="id", type="integer")
|
||||||
* @ORM\GeneratedValue(strategy="AUTO")
|
* @ORM\GeneratedValue(strategy="AUTO")
|
||||||
* @groups({"write", "read"})
|
* @groups({"read"})
|
||||||
*/
|
*/
|
||||||
private $id;
|
private $id;
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ class PostalCode
|
|||||||
* @var string
|
* @var string
|
||||||
*
|
*
|
||||||
* @ORM\Column(type="string", length=255, name="label")
|
* @ORM\Column(type="string", length=255, name="label")
|
||||||
* @groups({"write", "read"})
|
* @groups({"read"})
|
||||||
*/
|
*/
|
||||||
private $name;
|
private $name;
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ class PostalCode
|
|||||||
* @var string
|
* @var string
|
||||||
*
|
*
|
||||||
* @ORM\Column(type="string", length=100)
|
* @ORM\Column(type="string", length=100)
|
||||||
* @groups({"write", "read"})
|
* @groups({"read"})
|
||||||
*/
|
*/
|
||||||
private $code;
|
private $code;
|
||||||
|
|
||||||
@@ -50,17 +50,10 @@ class PostalCode
|
|||||||
* @var Country
|
* @var Country
|
||||||
*
|
*
|
||||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Country")
|
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Country")
|
||||||
* @groups({"write", "read"})
|
* @groups({"read"})
|
||||||
*/
|
*/
|
||||||
private $country;
|
private $country;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var integer
|
|
||||||
*
|
|
||||||
* @ORM\Column(name="origin", type="integer", nullable=true)
|
|
||||||
* @groups({"write", "read"})
|
|
||||||
*/
|
|
||||||
private $origin = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get id
|
* Get id
|
||||||
@@ -72,32 +65,6 @@ class PostalCode
|
|||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set origin
|
|
||||||
*
|
|
||||||
* @param int $origin
|
|
||||||
*
|
|
||||||
* @return PostalCode
|
|
||||||
*/
|
|
||||||
public function setOrigin($origin)
|
|
||||||
{
|
|
||||||
$this->origin = $origin;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get origin
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getOrigin()
|
|
||||||
{
|
|
||||||
return $this->origin;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set name
|
* Set name
|
||||||
*
|
*
|
||||||
|
@@ -45,14 +45,13 @@ class CommentType extends AbstractType
|
|||||||
{
|
{
|
||||||
$builder
|
$builder
|
||||||
->add('comment', ChillTextareaType::class, [
|
->add('comment', ChillTextareaType::class, [
|
||||||
'disable_editor' => $options['disable_editor'],
|
'disable_editor' => $options['disable_editor']
|
||||||
'label' => $options['label'],
|
|
||||||
])
|
])
|
||||||
;
|
;
|
||||||
|
|
||||||
$builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) {
|
$builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) {
|
||||||
$data = $event->getForm()->getData();
|
$data = $event->getForm()->getData();
|
||||||
$comment = $event->getData() ?? ['comment' => ''];
|
$comment = $event->getData();
|
||||||
|
|
||||||
if ($data->getComment() !== $comment['comment']) {
|
if ($data->getComment() !== $comment['comment']) {
|
||||||
$data->setDate(new \DateTime());
|
$data->setDate(new \DateTime());
|
||||||
|
@@ -43,11 +43,6 @@ final class ScopeRepository implements ObjectRepository
|
|||||||
{
|
{
|
||||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createQueryBuilder($alias, $indexBy = null)
|
|
||||||
{
|
|
||||||
return $this->repository->createQueryBuilder($alias, $indexBy);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getClassName() {
|
public function getClassName() {
|
||||||
return Scope::class;
|
return Scope::class;
|
||||||
|
@@ -11,16 +11,13 @@
|
|||||||
*
|
*
|
||||||
* Do not take time into account
|
* Do not take time into account
|
||||||
*
|
*
|
||||||
|
* **Experimental**
|
||||||
*/
|
*/
|
||||||
const dateToISO = (date) => {
|
const dateToISO = (date) => {
|
||||||
if (null === date) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
date.getFullYear(),
|
this.$store.state.startDate.getFullYear(),
|
||||||
(date.getMonth() + 1).toString().padStart(2, '0'),
|
(this.$store.state.startDate.getMonth() + 1).toString().padStart(2, '0'),
|
||||||
date.getDate().toString().padStart(2, '0')
|
this.$store.state.startDate.getDate().toString().padStart(2, '0')
|
||||||
].join('-');
|
].join('-');
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -39,17 +36,15 @@ const ISOToDate = (str) => {
|
|||||||
/**
|
/**
|
||||||
* Return a date object from iso string formatted as YYYY-mm-dd:HH:MM:ss+01:00
|
* Return a date object from iso string formatted as YYYY-mm-dd:HH:MM:ss+01:00
|
||||||
*
|
*
|
||||||
|
* **Experimental**
|
||||||
*/
|
*/
|
||||||
const ISOToDatetime = (str) => {
|
const ISOToDatetime = (str) => {
|
||||||
if (null === str) {
|
console.log(str);
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
let
|
let
|
||||||
[cal, times] = str.split('T'),
|
[cal, times] = str.split('T'),
|
||||||
[year, month, date] = cal.split('-'),
|
[year, month, date] = cal.split('-'),
|
||||||
[time, timezone] = times.split(times.charAt(8)),
|
[time, timezone] = cal.split(times.charAt(9)),
|
||||||
[hours, minutes, seconds] = time.split(':')
|
[hours, minutes, seconds] = cal.split(':')
|
||||||
;
|
;
|
||||||
|
|
||||||
return new Date(year, month-1, date, hours, minutes, seconds);
|
return new Date(year, month-1, date, hours, minutes, seconds);
|
||||||
|
@@ -35,7 +35,6 @@ $table-body-td-text-align: left;
|
|||||||
// Tabs
|
// Tabs
|
||||||
$tabs-nav-margin-bottom: 0.2em;
|
$tabs-nav-margin-bottom: 0.2em;
|
||||||
$tabs-nav-bg-color: $yellow;
|
$tabs-nav-bg-color: $yellow;
|
||||||
$tabs-nav-bg-color-light: lighten($yellow, 10%);
|
|
||||||
$tabs-nav-text-color: $blue;
|
$tabs-nav-text-color: $blue;
|
||||||
$tabs-new-border: none;
|
$tabs-new-border: none;
|
||||||
$tabs-nav-hover-border: none;
|
$tabs-nav-hover-border: none;
|
||||||
|
@@ -30,7 +30,7 @@
|
|||||||
&.bt-cancel::before,
|
&.bt-cancel::before,
|
||||||
&.bt-view::before,
|
&.bt-view::before,
|
||||||
&.bt-show::before {
|
&.bt-show::before {
|
||||||
font: normal normal normal 14px/1 ForkAwesome;
|
font: normal normal normal 14px/1 FontAwesome;
|
||||||
margin-right: 0.5em;
|
margin-right: 0.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -26,13 +26,7 @@ $global-bg-color: $yellow;
|
|||||||
color: $tabs-nav-title-text-color;
|
color: $tabs-nav-title-text-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.sub-menu {
|
> a {
|
||||||
padding-left: 20px;
|
|
||||||
> a {
|
|
||||||
background-color: $tabs-nav-bg-color-light;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
> a {
|
|
||||||
display: block;
|
display: block;
|
||||||
width: auto;
|
width: auto;
|
||||||
padding: $tabs-nav-padding;
|
padding: $tabs-nav-padding;
|
||||||
@@ -44,11 +38,11 @@ $global-bg-color: $yellow;
|
|||||||
@include border-top-radius($base-border-radius);
|
@include border-top-radius($base-border-radius);
|
||||||
@include border-bottom-radius($base-border-radius);
|
@include border-bottom-radius($base-border-radius);
|
||||||
|
|
||||||
&:hover, &:active {
|
&:hover, &:active {
|
||||||
border: $tabs-nav-hover-border;
|
border: $tabs-nav-hover-border;
|
||||||
color: $tabs-nav-hover-text-color;
|
color: $tabs-nav-hover-text-color;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,10 +0,0 @@
|
|||||||
/*
|
|
||||||
* when an alert is the first child of the page, with a banner, we do not want the alert to be merged with the banner
|
|
||||||
*/
|
|
||||||
div.container.content {
|
|
||||||
& > div {
|
|
||||||
div.alert:nth-child(2) {
|
|
||||||
margin-top: 1rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,29 +0,0 @@
|
|||||||
|
|
||||||
div.alert.alert-with-actions {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
|
|
||||||
ul.record_actions {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
padding: 0;
|
|
||||||
margin: 0;
|
|
||||||
|
|
||||||
li:nth-child(1n+2) {
|
|
||||||
margin-top: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
li {
|
|
||||||
margin-right: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media screen and (max-width: 1050px) {
|
|
||||||
flex-direction: column;
|
|
||||||
|
|
||||||
ul.record_actions {
|
|
||||||
margin-top: 1rem;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -7,10 +7,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@import 'alert-first-child';
|
|
||||||
@import 'alert-with-actions';
|
|
||||||
|
|
||||||
|
|
||||||
/* [hack] /!\ Contourne le positionnement problématique du div#content_conainter suivant,
|
/* [hack] /!\ Contourne le positionnement problématique du div#content_conainter suivant,
|
||||||
* car sa position: relative le place au-dessus du bandeau et les liens sont incliquables */
|
* car sa position: relative le place au-dessus du bandeau et les liens sont incliquables */
|
||||||
div.subheader {
|
div.subheader {
|
||||||
@@ -45,6 +41,33 @@ table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ACCOMPANYING_COURSE
|
||||||
|
* Header custom for Accompanying Course
|
||||||
|
*/
|
||||||
|
|
||||||
|
div#header-accompanying_course-name {
|
||||||
|
background: none repeat scroll 0 0 #718596;
|
||||||
|
color: #FFF;
|
||||||
|
h1 {
|
||||||
|
margin: 0.4em 0;
|
||||||
|
}
|
||||||
|
span {
|
||||||
|
a {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
div#header-accompanying_course-details {
|
||||||
|
background: none repeat scroll 0 0 #718596ab;
|
||||||
|
color: #FFF;
|
||||||
|
padding-top: 1em;
|
||||||
|
padding-bottom: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FLEX RESPONSIVE TABLE/BLOCK PRESENTATION
|
* FLEX RESPONSIVE TABLE/BLOCK PRESENTATION
|
||||||
*/
|
*/
|
||||||
@@ -82,13 +105,23 @@ div.flex-bloc {
|
|||||||
align-content: stretch;
|
align-content: stretch;
|
||||||
|
|
||||||
div.item-bloc {
|
div.item-bloc {
|
||||||
flex-grow: 0; flex-shrink: 1; flex-basis: 33%;
|
flex-grow: 0; flex-shrink: 1; flex-basis: 50%;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 1em;
|
padding: 1em;
|
||||||
|
border-top: 0;
|
||||||
|
&:nth-child(1), &:nth-child(2) {
|
||||||
|
border-top: 1px solid #000;
|
||||||
|
}
|
||||||
|
border-left: 0;
|
||||||
|
&:nth-child(odd) {
|
||||||
|
border-left: 1px solid #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
//background-color: #e6e6e6;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
div.item-row {
|
& > div.item-row {
|
||||||
flex-grow: 1; flex-shrink: 1; flex-basis: auto;
|
flex-grow: 1; flex-shrink: 1; flex-basis: auto;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -121,6 +154,12 @@ div.flex-bloc {
|
|||||||
@media only screen and (max-width: 900px) {
|
@media only screen and (max-width: 900px) {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
margin: auto 0;
|
margin: auto 0;
|
||||||
|
div.item-bloc {
|
||||||
|
border-left: 1px solid #000;
|
||||||
|
&:nth-child(2) {
|
||||||
|
border-top: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,6 +228,8 @@ div.flex-table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Address form
|
* Address form
|
||||||
*/
|
*/
|
||||||
@@ -207,9 +248,6 @@ div.address_form {
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
div.custom-address, div.custom-postcode {
|
|
||||||
padding: 12px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
div.address_form__select__map {
|
div.address_form__select__map {
|
||||||
@@ -217,18 +255,13 @@ div.address_form {
|
|||||||
div#address_map {
|
div#address_map {
|
||||||
height:400px;
|
height:400px;
|
||||||
width:400px;
|
width:400px;
|
||||||
input {
|
|
||||||
border: 1px solid #999;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
div.address_form__more {
|
div.address_form__more {
|
||||||
& > div {
|
|
||||||
display: flex;
|
|
||||||
& > label {
|
|
||||||
width: 30%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,85 +1,33 @@
|
|||||||
<template>
|
<template>
|
||||||
|
|
||||||
<div class='person__address__create'>
|
<div v-if="address.address">
|
||||||
<div>
|
{{ address.address.street }}, {{ address.address.streetNumber }}
|
||||||
<h2 v-if="!edit">{{ $t('create_a_new_address') }}</h2>
|
|
||||||
<h2 v-else>{{ $t('edit_a_new_address') }}</h2>
|
|
||||||
<add-address
|
|
||||||
@addNewAddress="addNewAddress">
|
|
||||||
</add-address>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<show-address
|
|
||||||
v-if="address"
|
|
||||||
v-bind:address="address">
|
|
||||||
</show-address>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div v-if="!edit" class='person__address__valid'>
|
<div v-if="address.city">
|
||||||
<h2>{{ $t('date') }}</h2>
|
{{ address.city.code }} {{ address.city.name }}
|
||||||
<input
|
</div>
|
||||||
type="date"
|
<div v-if="address.country">
|
||||||
name="validFrom"
|
{{ address.country.name }}
|
||||||
:placeholder="$t('validFrom')"
|
|
||||||
v-model="validFrom"/>
|
|
||||||
<div v-if="errors.length > 0">
|
|
||||||
{{ errors }}
|
|
||||||
</div>
|
|
||||||
<div v-if="loading">
|
|
||||||
{{ $t('loading') }}
|
|
||||||
</div>
|
|
||||||
<div v-if="success">
|
|
||||||
{{ $t('person_address_creation_success') }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<ul class="record_actions sticky-form-buttons">
|
|
||||||
<li class="cancel">
|
|
||||||
<a :href=backUrl class="sc-button bt-cancel">{{ $t('back_to_the_list') }}</a>
|
|
||||||
</li>
|
|
||||||
<li v-if="!edit">
|
|
||||||
<button type="submit" class="sc-button bt-update centered" @click="addToPerson">
|
|
||||||
{{ $t('add_an_address_to_person') }}
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<add-address
|
||||||
|
@addNewAddress="addNewAddress">
|
||||||
|
</add-address>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { mapState } from 'vuex';
|
||||||
|
|
||||||
import AddAddress from '../_components/AddAddress.vue';
|
import AddAddress from '../_components/AddAddress.vue';
|
||||||
import ShowAddress from '../_components/ShowAddress.vue';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'App',
|
name: 'App',
|
||||||
components: {
|
components: {
|
||||||
AddAddress,
|
AddAddress
|
||||||
ShowAddress
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
edit: window.mode === 'edit',
|
|
||||||
personId: window.personId,
|
|
||||||
addressId: window.addressId,
|
|
||||||
backUrl: `/fr/person/${window.personId}/address/list`, //TODO better way to pass this
|
|
||||||
validFrom: new Date().toISOString().split('T')[0]
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
address() {
|
address() {
|
||||||
return this.$store.state.address;
|
return this.$store.state.address;
|
||||||
},
|
|
||||||
errors() {
|
|
||||||
return this.$store.state.errorMsg;
|
|
||||||
},
|
|
||||||
loading() {
|
|
||||||
return this.$store.state.loading;
|
|
||||||
},
|
|
||||||
success() {
|
|
||||||
return this.$store.state.success;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -88,9 +36,9 @@ export default {
|
|||||||
|
|
||||||
let newAddress = {
|
let newAddress = {
|
||||||
'isNoAddress': address.isNoAddress,
|
'isNoAddress': address.isNoAddress,
|
||||||
'street': address.isNoAddress ? '' : address.street,
|
'street': address.selected.address.street,
|
||||||
'streetNumber': address.isNoAddress ? '' : address.streetNumber,
|
'streetNumber': address.selected.address.streetNumber,
|
||||||
'postcode': {'id': address.selected.city.id},
|
'postcode': {'id': address.selected.city.id },
|
||||||
'floor': address.floor,
|
'floor': address.floor,
|
||||||
'corridor': address.corridor,
|
'corridor': address.corridor,
|
||||||
'steps': address.steps,
|
'steps': address.steps,
|
||||||
@@ -101,47 +49,12 @@ export default {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (address.selected.address.point !== undefined){
|
if (address.selected.address.point !== undefined){
|
||||||
newAddress = Object.assign(newAddress, {
|
newAddress = Object.assign(newAddress, {'point': address.selected.address.point.coordinates});
|
||||||
'point': address.selected.address.point.coordinates
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (address.writeNewPostalCode){
|
|
||||||
let newPostalCode = address.newPostalCode;
|
|
||||||
newPostalCode = Object.assign(newPostalCode, {
|
|
||||||
'country': {'id': address.selected.country.id },
|
|
||||||
});
|
|
||||||
newAddress = Object.assign(newAddress, {
|
|
||||||
'newPostalCode': newPostalCode
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.edit){
|
|
||||||
this.$store.dispatch('updateAddress', {
|
|
||||||
addressId: this.addressId,
|
|
||||||
newAddress: newAddress
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.$store.dispatch('addAddress', newAddress);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.$store.dispatch('addAddress', newAddress);
|
||||||
modal.showModal = false;
|
modal.showModal = false;
|
||||||
},
|
|
||||||
addToPerson() {
|
|
||||||
this.$store.dispatch('addDateToAddressAndAddressToPerson', {
|
|
||||||
personId: this.personId,
|
|
||||||
addressId: this.$store.state.address.address_id,
|
|
||||||
body: { validFrom: {datetime: `${this.validFrom}T00:00:00+0100`}}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
getEditAddress() {
|
|
||||||
this.$store.dispatch('getEditAddress', this.addressId);
|
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
mounted() {
|
|
||||||
if (this.edit) {
|
|
||||||
this.getEditAddress();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@@ -1,34 +1,20 @@
|
|||||||
const addressMessages = {
|
const addressMessages = {
|
||||||
fr: {
|
fr: {
|
||||||
add_an_address_title: 'Créer une adresse',
|
add_an_address_title: 'Ajouter une adresse',
|
||||||
edit_an_address_title: 'Modifier une adresse',
|
|
||||||
create_a_new_address: 'Créer une nouvelle adresse',
|
|
||||||
edit_a_new_address: 'Modifier l\'adresse',
|
|
||||||
select_an_address_title: 'Sélectionner une adresse',
|
select_an_address_title: 'Sélectionner une adresse',
|
||||||
fill_an_address: 'Compléter l\'adresse',
|
fill_an_address: 'Compléter l\'adresse',
|
||||||
select_country: 'Choisir le pays',
|
select_country: 'Choisir le pays',
|
||||||
select_city: 'Choisir une localité',
|
select_city: 'Choisir une localité',
|
||||||
select_address: 'Choisir une adresse',
|
select_address: 'Choisir une adresse',
|
||||||
create_address: 'Adresse inconnue. Cliquez ici pour créer une nouvelle adresse',
|
create_address: 'Appuyer sur "Entrée" pour créer une nouvelle adresse',
|
||||||
isNoAddress: 'Pas d\'adresse complète',
|
isNoAddress: 'Pas d\'adresse complète',
|
||||||
street: 'Nom de rue',
|
|
||||||
streetNumber: 'Numéro',
|
|
||||||
floor: 'Étage',
|
floor: 'Étage',
|
||||||
corridor: 'Couloir',
|
corridor: 'Couloir',
|
||||||
steps: 'Escalier',
|
steps: 'Escalier',
|
||||||
flat: 'Appartement',
|
flat: 'Appartement',
|
||||||
buildingName: 'Nom du batiment',
|
buildingName: 'Nom du batiment',
|
||||||
extra: 'Complément d\'adresse',
|
extra: 'Complément d\'adresse',
|
||||||
distribution: 'Service particulier de distribution',
|
distribution: 'Service particulier de distribution'
|
||||||
create_postal_code: 'Localité inconnue. Cliquez ici pour créer une nouvelle localité',
|
|
||||||
postalCode_name: 'Nom de la localité',
|
|
||||||
postalCode_code: 'Code postal de la localité',
|
|
||||||
date: 'Date de la nouvelle adresse',
|
|
||||||
add_an_address_to_person: 'Ajouter l\'adresse à la personne',
|
|
||||||
validFrom: 'Date de la nouvelle adresse',
|
|
||||||
back_to_the_list: 'Retour à la liste',
|
|
||||||
person_address_creation_success: 'La nouvelle adresse de la personne est enregistrée',
|
|
||||||
loading: 'chargement en cours...'
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import 'es6-promise/auto';
|
import 'es6-promise/auto';
|
||||||
import { createStore } from 'vuex';
|
import { createStore } from 'vuex';
|
||||||
|
|
||||||
import { patchAddress, postAddress, postPostalCode, postAddressToPerson, getAddress } from '../../_api/AddAddress'
|
import { postAddress } from '../../_api/AddAddress'
|
||||||
|
|
||||||
const debug = process.env.NODE_ENV !== 'production';
|
const debug = process.env.NODE_ENV !== 'production';
|
||||||
|
|
||||||
@@ -9,11 +9,7 @@ const store = createStore({
|
|||||||
strict: debug,
|
strict: debug,
|
||||||
state: {
|
state: {
|
||||||
address: {},
|
address: {},
|
||||||
editAddress: {}, //TODO or should be address?
|
errorMsg: []
|
||||||
person: {},
|
|
||||||
errorMsg: [],
|
|
||||||
loading: false,
|
|
||||||
success: false
|
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
},
|
},
|
||||||
@@ -24,133 +20,25 @@ const store = createStore({
|
|||||||
addAddress(state, address) {
|
addAddress(state, address) {
|
||||||
console.log('@M addAddress address', address);
|
console.log('@M addAddress address', address);
|
||||||
state.address = address;
|
state.address = address;
|
||||||
},
|
|
||||||
updateAddress(state, address) {
|
|
||||||
console.log('@M updateAddress address', address);
|
|
||||||
state.address = address;
|
|
||||||
},
|
|
||||||
addAddressToPerson(state, person) {
|
|
||||||
console.log('@M addAddressToPerson person', person);
|
|
||||||
state.person = person;
|
|
||||||
},
|
|
||||||
addDateToAddress(state, validFrom) {
|
|
||||||
console.log('@M addDateToAddress address.validFrom', validFrom);
|
|
||||||
state.validFrom = validFrom;
|
|
||||||
},
|
|
||||||
getEditAddress(state, address) {
|
|
||||||
console.log('@M getEditAddress address', address);
|
|
||||||
state.editAddress = address;
|
|
||||||
},
|
|
||||||
setLoading(state, b) {
|
|
||||||
state.loading = b;
|
|
||||||
},
|
|
||||||
setSuccess(state, b) {
|
|
||||||
state.success = b;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
addAddress({ commit }, payload) {
|
addAddress({ commit }, payload) {
|
||||||
console.log('@A addAddress payload', payload);
|
console.log('@A addAddress payload', payload);
|
||||||
commit('setLoading', true);
|
//commit('addAddress', payload); // à remplacer par la suite
|
||||||
if('newPostalCode' in payload){
|
|
||||||
let postalCodeBody = payload.newPostalCode;
|
|
||||||
postalCodeBody = Object.assign(postalCodeBody, {'origin': 3});
|
|
||||||
postPostalCode(postalCodeBody)
|
|
||||||
.then(postalCode => {
|
|
||||||
let body = payload;
|
|
||||||
body.postcode = {'id': postalCode.id},
|
|
||||||
postAddress(body)
|
|
||||||
.then(address => new Promise((resolve, reject) => {
|
|
||||||
commit('addAddress', address);
|
|
||||||
resolve();
|
|
||||||
commit('setLoading', false);
|
|
||||||
}))
|
|
||||||
.catch((error) => {
|
|
||||||
commit('catchError', error);
|
|
||||||
commit('setLoading', false);
|
|
||||||
});
|
|
||||||
})
|
|
||||||
|
|
||||||
} else {
|
//fetch POST qui envoie l'adresse, et récupère la confirmation que c'est ok.
|
||||||
postAddress(payload)
|
//La confirmation est l'adresse elle-même.
|
||||||
.then(address => new Promise((resolve, reject) => {
|
|
||||||
commit('addAddress', address);
|
postAddress(payload)
|
||||||
resolve();
|
|
||||||
commit('setLoading', false);
|
|
||||||
}))
|
|
||||||
.catch((error) => {
|
|
||||||
commit('catchError', error);
|
|
||||||
commit('setLoading', false);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
addDateToAddressAndAddressToPerson({ commit }, payload) {
|
|
||||||
console.log('@A addDateToAddressAndAddressToPerson payload', payload);
|
|
||||||
commit('setLoading', true);
|
|
||||||
patchAddress(payload.addressId, payload.body)
|
|
||||||
.then(address => new Promise((resolve, reject) => {
|
.then(address => new Promise((resolve, reject) => {
|
||||||
commit('addDateToAddress', address.validFrom);
|
commit('addAddress', address);
|
||||||
resolve();
|
resolve();
|
||||||
}).then(
|
}))
|
||||||
postAddressToPerson(payload.personId, payload.addressId)
|
|
||||||
.then(person => new Promise((resolve, reject) => {
|
|
||||||
commit('addAddressToPerson', person);
|
|
||||||
resolve();
|
|
||||||
commit('setLoading', false);
|
|
||||||
commit('setSuccess', true);
|
|
||||||
}))
|
|
||||||
.catch((error) => {
|
|
||||||
commit('catchError', error);
|
|
||||||
commit('setLoading', false);
|
|
||||||
})
|
|
||||||
))
|
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
commit('catchError', error);
|
commit('catchError', error);
|
||||||
commit('setLoading', false);
|
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
updateAddress({ commit }, payload) {
|
|
||||||
console.log('@A updateAddress payload', payload);
|
|
||||||
|
|
||||||
if('newPostalCode' in payload.newAddress){ // TODO change the condition because it writes new postal code in edit mode now: !writeNewPostalCode
|
|
||||||
let postalCodeBody = payload.newAddress.newPostalCode;
|
|
||||||
postalCodeBody = Object.assign(postalCodeBody, {'origin': 3});
|
|
||||||
postPostalCode(postalCodeBody)
|
|
||||||
.then(postalCode => {
|
|
||||||
let body = payload.newAddress;
|
|
||||||
body.postcode = {'id': postalCode.id },
|
|
||||||
patchAddress(payload.addressId, body)
|
|
||||||
.then(address => new Promise((resolve, reject) => {
|
|
||||||
commit('updateAddress', address);
|
|
||||||
resolve();
|
|
||||||
}))
|
|
||||||
.catch((error) => {
|
|
||||||
commit('catchError', error);
|
|
||||||
});
|
|
||||||
})
|
|
||||||
|
|
||||||
} else {
|
|
||||||
patchAddress(payload.addressId, payload.newAddress)
|
|
||||||
.then(address => new Promise((resolve, reject) => {
|
|
||||||
commit('updateAddress', address);
|
|
||||||
resolve();
|
|
||||||
}))
|
|
||||||
.catch((error) => {
|
|
||||||
commit('catchError', error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
getEditAddress({ commit }, payload) {
|
|
||||||
console.log('@A getEditAddress payload', payload);
|
|
||||||
|
|
||||||
getAddress(payload).then(address => new Promise((resolve, reject) => {
|
|
||||||
commit('getEditAddress', address);
|
|
||||||
resolve();
|
|
||||||
}))
|
|
||||||
.catch((error) => {
|
|
||||||
commit('catchError', error);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -36,6 +36,7 @@ const fetchCities = (country) => {
|
|||||||
*/
|
*/
|
||||||
const fetchReferenceAddresses = (postalCode) => {
|
const fetchReferenceAddresses = (postalCode) => {
|
||||||
console.log('<<< fetching references addresses for', postalCode);
|
console.log('<<< fetching references addresses for', postalCode);
|
||||||
|
//TODO deal with huge number of addresses... we should do suggestion...
|
||||||
const url = `/api/1.0/main/address-reference.json?item_per_page=1000&postal_code=${postalCode.id}`;
|
const url = `/api/1.0/main/address-reference.json?item_per_page=1000&postal_code=${postalCode.id}`;
|
||||||
return fetch(url)
|
return fetch(url)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
@@ -44,75 +45,16 @@ const fetchReferenceAddresses = (postalCode) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* Endpoint chill_api_single_address_reference__index
|
|
||||||
* method GET, get AddressReference Object
|
|
||||||
* @returns {Promise} a promise containing all AddressReference objects filtered with postal code
|
|
||||||
*/
|
|
||||||
const fetchAddresses = () => {
|
|
||||||
console.log('<<< fetching addresses');
|
|
||||||
//TODO deal with huge number of addresses... we should do suggestion...
|
|
||||||
const url = `/api/1.0/main/address.json?item_per_page=1000`;
|
|
||||||
return fetch(url)
|
|
||||||
.then(response => {
|
|
||||||
if (response.ok) { return response.json(); }
|
|
||||||
throw Error('Error with request resource response');
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Endpoint chill_api_single_address__entity__create
|
* Endpoint chill_api_single_address__entity__create
|
||||||
* method POST, post Address Object
|
* method POST, post Address Object
|
||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
const postAddress = (address) => {
|
const postAddress = (address) => {
|
||||||
|
console.log(address);
|
||||||
const url = `/api/1.0/main/address.json?`;
|
const url = `/api/1.0/main/address.json?`;
|
||||||
const body = address;
|
const body = address;
|
||||||
|
|
||||||
return fetch(url, {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json;charset=utf-8'
|
|
||||||
},
|
|
||||||
body: JSON.stringify(body)
|
|
||||||
}).then(response => {
|
|
||||||
if (response.ok) { return response.json(); }
|
|
||||||
throw Error('Error with request resource response');
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Endpoint chill_api_single_address__entity__create
|
|
||||||
* method PATCH, patch Address Instance
|
|
||||||
*
|
|
||||||
* @id integer - id of address
|
|
||||||
* @body Object - dictionary with changes to post
|
|
||||||
*/
|
|
||||||
const patchAddress = (id, body) => {
|
|
||||||
const url = `/api/1.0/main/address/${id}.json`;
|
|
||||||
return fetch(url, {
|
|
||||||
method: 'PATCH',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json;charset=utf-8'
|
|
||||||
},
|
|
||||||
body: JSON.stringify(body)
|
|
||||||
})
|
|
||||||
.then(response => {
|
|
||||||
if (response.ok) { return response.json(); }
|
|
||||||
throw Error('Error with request resource response');
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Endpoint chill_api_single_postal_code__entity_create
|
|
||||||
* method POST, post Postal Code Object
|
|
||||||
* @returns {Promise}
|
|
||||||
*/
|
|
||||||
const postPostalCode = (postalCode) => {
|
|
||||||
const url = `/api/1.0/main/postal-code.json?`;
|
|
||||||
const body = postalCode;
|
|
||||||
|
|
||||||
return fetch(url, {
|
return fetch(url, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
@@ -125,55 +67,9 @@ const postPostalCode = (postalCode) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* Endpoint chill_api_single_person_address
|
|
||||||
* method POST, post Person instance
|
|
||||||
*
|
|
||||||
* @id integer - id of Person
|
|
||||||
* @body Object - dictionary with changes to post
|
|
||||||
*/
|
|
||||||
const postAddressToPerson = (personId, addressId) => {
|
|
||||||
console.log(personId);
|
|
||||||
console.log(addressId);
|
|
||||||
const body = {
|
|
||||||
'id': addressId
|
|
||||||
};
|
|
||||||
const url = `/api/1.0/person/person/${personId}/address.json`
|
|
||||||
return fetch(url, {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {'Content-Type': 'application/json;charset=utf-8'},
|
|
||||||
body: JSON.stringify(body)
|
|
||||||
})
|
|
||||||
.then(response => {
|
|
||||||
if (response.ok) { return response.json(); }
|
|
||||||
throw Error('Error with request resource response');
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Endpoint chill_api_single_address__index
|
|
||||||
* method GET, get Address Object
|
|
||||||
* @params {id} the address id
|
|
||||||
* @returns {Promise} a promise containing a Address object
|
|
||||||
*/
|
|
||||||
const getAddress = (id) => {
|
|
||||||
console.log('<<< get address');
|
|
||||||
const url = `/api/1.0/main/address/${id}.json`;
|
|
||||||
return fetch(url)
|
|
||||||
.then(response => {
|
|
||||||
if (response.ok) { return response.json(); }
|
|
||||||
throw Error('Error with request resource response');
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
fetchCountries,
|
fetchCountries,
|
||||||
fetchCities,
|
fetchCities,
|
||||||
fetchReferenceAddresses,
|
fetchReferenceAddresses,
|
||||||
fetchAddresses,
|
postAddress
|
||||||
postAddress,
|
|
||||||
patchAddress,
|
|
||||||
postPostalCode,
|
|
||||||
postAddressToPerson,
|
|
||||||
getAddress
|
|
||||||
};
|
};
|
||||||
|
@@ -1,10 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<button v-if="!edit" class="sc-button bt-create mt-4" @click="openModal">
|
<button class="sc-button bt-create centered mt-4" @click="openModal">
|
||||||
{{ $t('add_an_address_title') }}
|
{{ $t('add_an_address_title') }}
|
||||||
</button>
|
</button>
|
||||||
<button v-else class="sc-button bt-create mt-4" @click="openModal">
|
|
||||||
{{ $t('edit_an_address_title') }}
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<teleport to="body">
|
<teleport to="body">
|
||||||
<modal v-if="modal.showModal"
|
<modal v-if="modal.showModal"
|
||||||
@@ -12,17 +9,12 @@
|
|||||||
@close="modal.showModal = false">
|
@close="modal.showModal = false">
|
||||||
|
|
||||||
<template v-slot:header>
|
<template v-slot:header>
|
||||||
<h3 v-if="!edit" class="modal-title">{{ $t('add_an_address_title') }}</h3>
|
<h3 class="modal-title">{{ $t('add_an_address_title') }}</h3>
|
||||||
<h3 v-if="edit" class="modal-title">{{ $t('edit_an_address_title') }}</h3>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-slot:body>
|
<template v-slot:body>
|
||||||
<div class="address_form">
|
<div class="address_form">
|
||||||
|
|
||||||
<div v-if="loading">
|
|
||||||
{{ $t('loading') }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="address_form__header">
|
<div class="address_form__header">
|
||||||
<h4>{{ $t('select_an_address_title') }}</h4>
|
<h4>{{ $t('select_an_address_title') }}</h4>
|
||||||
</div>
|
</div>
|
||||||
@@ -46,12 +38,10 @@
|
|||||||
|
|
||||||
<city-selection
|
<city-selection
|
||||||
v-bind:address="address"
|
v-bind:address="address"
|
||||||
v-bind:focusOnAddress="focusOnAddress"
|
|
||||||
v-bind:getReferenceAddresses="getReferenceAddresses">
|
v-bind:getReferenceAddresses="getReferenceAddresses">
|
||||||
</city-selection>
|
</city-selection>
|
||||||
|
|
||||||
<address-selection
|
<address-selection
|
||||||
v-if="!isNoAddress"
|
|
||||||
v-bind:address="address"
|
v-bind:address="address"
|
||||||
v-bind:updateMapCenter="updateMapCenter">
|
v-bind:updateMapCenter="updateMapCenter">
|
||||||
</address-selection>
|
</address-selection>
|
||||||
@@ -110,15 +100,11 @@ export default {
|
|||||||
emits: ['addNewAddress'],
|
emits: ['addNewAddress'],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
edit: window.mode === 'edit',
|
|
||||||
modal: {
|
modal: {
|
||||||
showModal: false,
|
showModal: false,
|
||||||
modalDialogClass: "modal-dialog-scrollable modal-xl"
|
modalDialogClass: "modal-dialog-scrollable modal-xl"
|
||||||
},
|
},
|
||||||
loading: false,
|
|
||||||
address: {
|
address: {
|
||||||
writeNewAddress: false,
|
|
||||||
writeNewPostalCode: false,
|
|
||||||
loaded: {
|
loaded: {
|
||||||
countries: [],
|
countries: [],
|
||||||
cities: [],
|
cities: [],
|
||||||
@@ -129,17 +115,11 @@ export default {
|
|||||||
city: {},
|
city: {},
|
||||||
address: {},
|
address: {},
|
||||||
},
|
},
|
||||||
newPostalCode: {
|
|
||||||
code: null,
|
|
||||||
name: null
|
|
||||||
},
|
|
||||||
addressMap: {
|
addressMap: {
|
||||||
center : [48.8589, 2.3469], // Note: LeafletJs demands [lat, lon] cfr https://macwright.com/lonlat/
|
center : [48.8589, 2.3469], // Note: LeafletJs demands [lat, lon] cfr https://macwright.com/lonlat/
|
||||||
zoom: 12
|
zoom: 12
|
||||||
},
|
},
|
||||||
isNoAddress: false,
|
isNoAddress: false,
|
||||||
street: null,
|
|
||||||
streetNumber: null,
|
|
||||||
floor: null,
|
floor: null,
|
||||||
corridor: null,
|
corridor: null,
|
||||||
steps: null,
|
steps: null,
|
||||||
@@ -149,7 +129,7 @@ export default {
|
|||||||
extra: null,
|
extra: null,
|
||||||
distribution: null,
|
distribution: null,
|
||||||
},
|
},
|
||||||
errorMsg: {},
|
errorMsg: {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -174,52 +154,35 @@ export default {
|
|||||||
// this.$refs.search.focus(); // positionner le curseur à l'ouverture de la modale
|
// this.$refs.search.focus(); // positionner le curseur à l'ouverture de la modale
|
||||||
//})
|
//})
|
||||||
},
|
},
|
||||||
focusOnCity() {
|
|
||||||
const citySelector = document.getElementById('citySelector');
|
|
||||||
citySelector.focus();
|
|
||||||
},
|
|
||||||
focusOnAddress() {
|
|
||||||
const addressSelector = document.getElementById('addressSelector');
|
|
||||||
addressSelector.focus();
|
|
||||||
},
|
|
||||||
getCountries() {
|
getCountries() {
|
||||||
console.log('getCountries');
|
console.log('getCountries');
|
||||||
this.loading = true;
|
|
||||||
fetchCountries().then(countries => new Promise((resolve, reject) => {
|
fetchCountries().then(countries => new Promise((resolve, reject) => {
|
||||||
this.address.loaded.countries = countries.results;
|
this.address.loaded.countries = countries.results;
|
||||||
resolve()
|
resolve()
|
||||||
this.loading = false;
|
|
||||||
}))
|
}))
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.errorMsg.push(error.message);
|
this.errorMsg.push(error.message);
|
||||||
this.loading = false;
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getCities(country) {
|
getCities(country) {
|
||||||
console.log('getCities for', country.name);
|
console.log('getCities for', country.name);
|
||||||
this.loading = true;
|
|
||||||
fetchCities(country).then(cities => new Promise((resolve, reject) => {
|
fetchCities(country).then(cities => new Promise((resolve, reject) => {
|
||||||
this.address.loaded.cities = cities.results.filter(c => c.origin !== 3); // filter out user-defined cities
|
this.address.loaded.cities = cities.results;
|
||||||
resolve();
|
resolve()
|
||||||
this.loading = false;
|
|
||||||
}))
|
}))
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.errorMsg.push(error.message);
|
this.errorMsg.push(error.message);
|
||||||
this.loading = false;
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getReferenceAddresses(city) {
|
getReferenceAddresses(city) {
|
||||||
this.loading = true;
|
|
||||||
console.log('getReferenceAddresses for', city.name);
|
console.log('getReferenceAddresses for', city.name);
|
||||||
fetchReferenceAddresses(city).then(addresses => new Promise((resolve, reject) => {
|
fetchReferenceAddresses(city).then(addresses => new Promise((resolve, reject) => {
|
||||||
console.log('addresses', addresses);
|
console.log('addresses', addresses);
|
||||||
this.address.loaded.addresses = addresses.results;
|
this.address.loaded.addresses = addresses.results;
|
||||||
resolve();
|
resolve();
|
||||||
this.loading = false;
|
|
||||||
}))
|
}))
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.errorMsg.push(error.message);
|
this.errorMsg.push(error.message);
|
||||||
this.loading = false;
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
updateMapCenter(point) {
|
updateMapCenter(point) {
|
||||||
@@ -235,23 +198,6 @@ export default {
|
|||||||
this.address.loaded.cities = [];
|
this.address.loaded.cities = [];
|
||||||
this.address.selected.city = {};
|
this.address.selected.city = {};
|
||||||
this.address.selected.country = {};
|
this.address.selected.country = {};
|
||||||
this.address.isNoAddress = this.edit ? this.$store.state.editAddress.isNoAddress: false;;
|
|
||||||
this.address.street = this.edit ? this.$store.state.editAddress.street: null;
|
|
||||||
this.address.streetNumber = this.edit ? this.$store.state.editAddress.streetNumber: null;
|
|
||||||
this.address.floor = this.edit ? this.$store.state.editAddress.floor: null;
|
|
||||||
this.address.corridor = this.edit ? this.$store.state.editAddress.corridor: null;
|
|
||||||
this.address.steps = this.edit ? this.$store.state.editAddress.steps: null;
|
|
||||||
this.address.flat = this.edit ? this.$store.state.editAddress.flat: null;
|
|
||||||
this.address.buildingName = this.edit ? this.$store.state.editAddress.buildingName: null;
|
|
||||||
this.address.distribution = this.edit ? this.$store.state.editAddress.distribution: null;
|
|
||||||
this.address.extra = this.edit ? this.$store.state.editAddress.extra: null;
|
|
||||||
this.address.writeNewAddress = this.edit;
|
|
||||||
this.address.writeNewPostalCode = this.edit;
|
|
||||||
this.address.newPostalCode = this.edit ?
|
|
||||||
{
|
|
||||||
code: this.$store.state.editAddress.postcode !== undefined ? this.$store.state.editAddress.postcode.code : null,
|
|
||||||
name: this.$store.state.editAddress.postcode !== undefined ? this.$store.state.editAddress.postcode.name : null
|
|
||||||
} : {};
|
|
||||||
console.log('cities and addresses', this.address.loaded.cities, this.address.loaded.addresses);
|
console.log('cities and addresses', this.address.loaded.cities, this.address.loaded.addresses);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -23,7 +23,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods:{
|
methods:{
|
||||||
init() {
|
init() {
|
||||||
map = L.map('address_map').setView([46.67059, -1.42683], 12);
|
map = L.map('address_map').setView([48.8589, 2.3469], 12);
|
||||||
|
|
||||||
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||||
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
||||||
@@ -40,7 +40,7 @@ export default {
|
|||||||
update() {
|
update() {
|
||||||
console.log('update map with : ', this.address.addressMap.center)
|
console.log('update map with : ', this.address.addressMap.center)
|
||||||
marker.setLatLng(this.address.addressMap.center);
|
marker.setLatLng(this.address.addressMap.center);
|
||||||
map.setView(this.address.addressMap.center, 15);
|
map.setView(this.address.addressMap.center, 12);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted(){
|
mounted(){
|
||||||
|
@@ -1,65 +1,39 @@
|
|||||||
<template>
|
<template>
|
||||||
<h4>{{ $t('fill_an_address') }}</h4>
|
|
||||||
<div>
|
<div>
|
||||||
<label for="floor">{{ $t('floor') }}</label>
|
<h4>{{ $t('fill_an_address') }}</h4>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
name="floor"
|
name="floor"
|
||||||
maxlength=16
|
|
||||||
:placeholder="$t('floor')"
|
:placeholder="$t('floor')"
|
||||||
v-model="floor"/>
|
v-model="floor"/>
|
||||||
</div>
|
<input
|
||||||
<div>
|
|
||||||
<label for="corridor">{{ $t('corridor') }}</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
type="text"
|
||||||
name="corridor"
|
name="corridor"
|
||||||
maxlength=16
|
|
||||||
:placeholder="$t('corridor')"
|
:placeholder="$t('corridor')"
|
||||||
v-model="corridor"/>
|
v-model="corridor"/>
|
||||||
</div>
|
<input
|
||||||
<div>
|
|
||||||
<label for="steps">{{ $t('steps') }}</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
type="text"
|
||||||
name="steps"
|
name="steps"
|
||||||
maxlength=16
|
|
||||||
:placeholder="$t('steps')"
|
:placeholder="$t('steps')"
|
||||||
v-model="steps"/>
|
v-model="steps"/>
|
||||||
</div>
|
<input
|
||||||
<div>
|
|
||||||
<label for="flat">{{ $t('flat') }}</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
type="text"
|
||||||
name="flat"
|
name="flat"
|
||||||
maxlength=16
|
|
||||||
:placeholder="$t('flat')"
|
:placeholder="$t('flat')"
|
||||||
v-model="flat"/>
|
v-model="flat"/>
|
||||||
</div>
|
<input
|
||||||
<div>
|
|
||||||
<label for="buildingName">{{ $t('buildingName') }}</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
type="text"
|
||||||
name="buildingName"
|
name="buildingName"
|
||||||
maxlength=255
|
|
||||||
:placeholder="$t('buildingName')"
|
:placeholder="$t('buildingName')"
|
||||||
v-model="buildingName"/>
|
v-model="buildingName"/>
|
||||||
</div>
|
<input
|
||||||
<div>
|
|
||||||
<label for="extra">{{ $t('extra') }}</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
type="text"
|
||||||
name="extra"
|
name="extra"
|
||||||
maxlength=255
|
|
||||||
:placeholder="$t('extra')"
|
:placeholder="$t('extra')"
|
||||||
v-model="extra"/>
|
v-model="extra"/>
|
||||||
</div>
|
<input
|
||||||
<div>
|
|
||||||
<label for="distribution">{{ $t('distribution') }}</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
type="text"
|
||||||
name="distribution"
|
name="distribution"
|
||||||
maxlength=255
|
|
||||||
:placeholder="$t('distribution')"
|
:placeholder="$t('distribution')"
|
||||||
v-model="distribution"/>
|
v-model="distribution"/>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<VueMultiselect
|
<VueMultiselect
|
||||||
id="addressSelector"
|
|
||||||
v-model="value"
|
v-model="value"
|
||||||
@select="selectAddress"
|
@select="selectAddress"
|
||||||
name="field"
|
name="field"
|
||||||
@@ -16,18 +15,6 @@
|
|||||||
:options="addresses">
|
:options="addresses">
|
||||||
</VueMultiselect>
|
</VueMultiselect>
|
||||||
</div>
|
</div>
|
||||||
<div class="custom-address" v-if="writeNewAddress || writeNewPostalCode">
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
name="street"
|
|
||||||
:placeholder="$t('street')"
|
|
||||||
v-model="street"/>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
name="streetNumber"
|
|
||||||
:placeholder="$t('streetNumber')"
|
|
||||||
v-model="streetNumber"/>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -43,44 +30,24 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
writeNewAddress() {
|
|
||||||
return this.address.writeNewAddress;
|
|
||||||
},
|
|
||||||
writeNewPostalCode() {
|
|
||||||
return this.address.writeNewPostalCode;
|
|
||||||
},
|
|
||||||
addresses() {
|
addresses() {
|
||||||
return this.address.loaded.addresses;
|
return this.address.loaded.addresses;
|
||||||
},
|
}
|
||||||
street: {
|
|
||||||
set(value) {
|
|
||||||
this.address.street = value;
|
|
||||||
},
|
|
||||||
get() {
|
|
||||||
return this.address.street;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
streetNumber: {
|
|
||||||
set(value) {
|
|
||||||
this.address.streetNumber = value;
|
|
||||||
},
|
|
||||||
get() {
|
|
||||||
return this.address.streetNumber;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
transName(value) {
|
transName(value) {
|
||||||
return value.streetNumber === undefined ? value.street : `${value.streetNumber}, ${value.street}`
|
return value.streetNumber === undefined ? value.street : `${value.street}, ${value.streetNumber}`
|
||||||
},
|
},
|
||||||
selectAddress(value) {
|
selectAddress(value) {
|
||||||
this.address.selected.address = value;
|
this.address.selected.address = value;
|
||||||
this.address.street = value.street;
|
|
||||||
this.address.streetNumber = value.streetNumber;
|
|
||||||
this.updateMapCenter(value.point);
|
this.updateMapCenter(value.point);
|
||||||
},
|
},
|
||||||
addAddress() {
|
addAddress (newAddress) {
|
||||||
this.address.writeNewAddress = true;
|
const address = {
|
||||||
|
street: newAddress
|
||||||
|
};
|
||||||
|
this.value = address;
|
||||||
|
this.address.selected.address = address;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<VueMultiselect
|
<VueMultiselect
|
||||||
id="citySelector"
|
|
||||||
v-model="value"
|
v-model="value"
|
||||||
@select="selectCity"
|
@select="selectCity"
|
||||||
name="field"
|
name="field"
|
||||||
@@ -9,25 +8,9 @@
|
|||||||
label="value"
|
label="value"
|
||||||
:custom-label="transName"
|
:custom-label="transName"
|
||||||
:placeholder="$t('select_city')"
|
:placeholder="$t('select_city')"
|
||||||
:taggable="true"
|
|
||||||
:multiple="false"
|
|
||||||
@tag="addPostalCode"
|
|
||||||
:tagPlaceholder="$t('create_postal_code')"
|
|
||||||
:options="cities">
|
:options="cities">
|
||||||
</VueMultiselect>
|
</VueMultiselect>
|
||||||
</div>
|
</div>
|
||||||
<div class="custom-postcode" v-if="writeNewPostalCode">
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
name="name"
|
|
||||||
:placeholder="$t('postalCode_name')"
|
|
||||||
v-model="name"/>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
name="code"
|
|
||||||
:placeholder="$t('postalCode_code')"
|
|
||||||
v-model="code"/>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -36,49 +19,24 @@ import VueMultiselect from 'vue-multiselect';
|
|||||||
export default {
|
export default {
|
||||||
name: 'CitySelection',
|
name: 'CitySelection',
|
||||||
components: { VueMultiselect },
|
components: { VueMultiselect },
|
||||||
props: ['address', 'getReferenceAddresses', 'focusOnAddress'],
|
props: ['address', 'getReferenceAddresses'],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
value: null
|
value: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
|
||||||
writeNewPostalCode() {
|
|
||||||
return this.address.writeNewPostalCode;
|
|
||||||
},
|
|
||||||
cities() {
|
|
||||||
return this.address.loaded.cities;
|
|
||||||
},
|
|
||||||
name: {
|
|
||||||
set(value) {
|
|
||||||
this.address.newPostalCode.name = value;
|
|
||||||
},
|
|
||||||
get() {
|
|
||||||
return this.address.newPostalCode.name;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
code: {
|
|
||||||
set(value) {
|
|
||||||
this.address.newPostalCode.code= value;
|
|
||||||
},
|
|
||||||
get() {
|
|
||||||
return this.address.newPostalCode.code;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
transName(value) {
|
transName(value) {
|
||||||
return `${value.code}-${value.name}`
|
return `${value.code}-${value.name}`
|
||||||
},
|
},
|
||||||
selectCity(value) {
|
selectCity(value) {
|
||||||
this.address.selected.city = value;
|
this.address.selected.city = value;
|
||||||
this.address.newPostalCode.name = value.name;
|
|
||||||
this.address.newPostalCode.code = value.code;
|
|
||||||
this.getReferenceAddresses(value);
|
this.getReferenceAddresses(value);
|
||||||
this.focusOnAddress();
|
|
||||||
},
|
},
|
||||||
addPostalCode() {
|
},
|
||||||
this.address.writeNewPostalCode = true;
|
computed: {
|
||||||
|
cities() {
|
||||||
|
return this.address.loaded.cities;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -22,24 +22,20 @@ export default {
|
|||||||
props: ['address', 'getCities'],
|
props: ['address', 'getCities'],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
edit: window.mode === 'edit',
|
value: this.address.loaded.countries.filter(c => c.countryCode === 'FR')[0]
|
||||||
defaultCountry: this.edit ? this.$store.state.editAddress.country.code : 'FR',
|
|
||||||
value: this.address.loaded.countries.filter(c => c.countryCode === this.defaultCountry)[0]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
init() {
|
init() {
|
||||||
this.value = this.edit ?
|
|
||||||
this.address.loaded.countries.filter(c => c.countryCode === this.$store.state.editAddress.country.code)[0]:
|
|
||||||
this.address.loaded.countries.filter(c => c.countryCode === 'FR')[0]
|
|
||||||
if (this.value !== undefined) {
|
if (this.value !== undefined) {
|
||||||
this.selectCountry(this.value);
|
this.getCities(this.value);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
transName ({ name }) {
|
transName ({ name }) {
|
||||||
return name.fr //TODO multilang
|
return name.fr //TODO multilang
|
||||||
},
|
},
|
||||||
selectCountry(value) {
|
selectCountry(value) {
|
||||||
|
console.log(value);
|
||||||
this.address.selected.country = value;
|
this.address.selected.country = value;
|
||||||
this.getCities(value);
|
this.getCities(value);
|
||||||
},
|
},
|
||||||
|
@@ -1,46 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="chill_address_address chill_address_address--multiline">
|
|
||||||
<div v-if="address.text">
|
|
||||||
{{ address.text }}
|
|
||||||
</div>
|
|
||||||
<div v-if="address.postcode">
|
|
||||||
{{ address.postcode.name }}
|
|
||||||
</div>
|
|
||||||
<div v-if="address.country">
|
|
||||||
{{ address.country.name.fr }}
|
|
||||||
</div>
|
|
||||||
<div v-if="address.floor">
|
|
||||||
<span>{{ $t('floor') }}</span>: {{ address.floor }}
|
|
||||||
</div>
|
|
||||||
<div v-if="address.corridor">
|
|
||||||
<span>{{ $t('corridor') }}</span>: {{ address.corridor }}
|
|
||||||
</div>
|
|
||||||
<div v-if="address.steps">
|
|
||||||
<span>{{ $t('steps') }}</span>: {{ address.steps }}
|
|
||||||
</div>
|
|
||||||
<div v-if="address.flat">
|
|
||||||
<span>{{ $t('flat') }}</span>: {{ address.flat }}
|
|
||||||
</div>
|
|
||||||
<div v-if="address.buildingName">
|
|
||||||
<span>{{ $t('buildingName') }}</span>: {{ address.buildingName }}
|
|
||||||
</div>
|
|
||||||
<div v-if="address.extra">
|
|
||||||
<span>{{ $t('extra') }}</span>: {{ address.extra }}
|
|
||||||
</div>
|
|
||||||
<div v-if="address.distribution">
|
|
||||||
<span>{{ $t('distribution') }}</span>: {{ address.distribution }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'ShowAddress',
|
|
||||||
props: ['address'],
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
@@ -58,9 +58,9 @@ const messages = {
|
|||||||
},
|
},
|
||||||
create: {
|
create: {
|
||||||
button: "Créer \"{q}\"",
|
button: "Créer \"{q}\"",
|
||||||
title: "Création d'un nouvel usager ou d'un tiers professionnel",
|
title: "Créer à la volée…",
|
||||||
person: "un nouvel usager",
|
person: "un nouvel usager",
|
||||||
thirdparty: "un nouveau tiers professionnel"
|
thirdparty: "un nouveau tiers"
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@@ -164,12 +164,10 @@
|
|||||||
{{ encore_entry_script_tags('ckeditor5') }}
|
{{ encore_entry_script_tags('ckeditor5') }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
window.addEventListener('DOMContentLoaded', function(e) {
|
|
||||||
chill.checkOtherValueOnChange();
|
chill.checkOtherValueOnChange();
|
||||||
$('.select2').select2({allowClear: true});
|
$('.select2').select2({allowClear: true});
|
||||||
chill.categoryLinkParentChildSelect();
|
chill.categoryLinkParentChildSelect();
|
||||||
});
|
</script>
|
||||||
</script>
|
{% block js%}<!-- nothing added to js -->{% endblock %}
|
||||||
{% block js%}<!-- nothing added to js -->{% endblock %}
|
</body>
|
||||||
</body>
|
</html>
|
||||||
</html>
|
|
||||||
|
@@ -2,169 +2,88 @@
|
|||||||
|
|
||||||
namespace Chill\MainBundle\Search;
|
namespace Chill\MainBundle\Search;
|
||||||
|
|
||||||
use Chill\MainBundle\Serializer\Model\Collection;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||||
use Chill\PersonBundle\Search\SearchPersonApiProvider;
|
|
||||||
use Chill\ThirdPartyBundle\Search\ThirdPartyApiSearch;
|
|
||||||
use Doctrine\DBAL\Types\Types;
|
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\ORM\Query\ResultSetMappingBuilder;
|
|
||||||
use Chill\MainBundle\Search\SearchProvider;
|
use Chill\MainBundle\Search\SearchProvider;
|
||||||
use Symfony\Component\VarDumper\Resources\functions\dump;
|
use Symfony\Component\VarDumper\Resources\functions\dump;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* ***Warning*** This is an incomplete implementation ***Warning***
|
||||||
*/
|
*/
|
||||||
class SearchApi
|
class SearchApi
|
||||||
{
|
{
|
||||||
private EntityManagerInterface $em;
|
private EntityManagerInterface $em;
|
||||||
private PaginatorFactory $paginator;
|
private SearchProvider $search;
|
||||||
|
|
||||||
private array $providers = [];
|
public function __construct(EntityManagerInterface $em, SearchProvider $search)
|
||||||
|
|
||||||
public function __construct(
|
|
||||||
EntityManagerInterface $em,
|
|
||||||
SearchPersonApiProvider $searchPerson,
|
|
||||||
ThirdPartyApiSearch $thirdPartyApiSearch,
|
|
||||||
PaginatorFactory $paginator
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
$this->providers[] = $searchPerson;
|
$this->search = $search;
|
||||||
$this->providers[] = $thirdPartyApiSearch;
|
|
||||||
$this->paginator = $paginator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Model/Result[]
|
* @return Model/Result[]
|
||||||
*/
|
*/
|
||||||
public function getResults(string $pattern, array $types, array $parameters): Collection
|
public function getResults(string $query, int $offset, int $maxResult): array
|
||||||
{
|
{
|
||||||
$queries = $this->findQueries($pattern, $types, $parameters);
|
// **warning again**: this is an incomplete implementation
|
||||||
|
$results = [];
|
||||||
|
|
||||||
$total = $this->countItems($queries, $types, $parameters);
|
foreach ($this->getPersons($query) as $p) {
|
||||||
$paginator = $this->paginator->create($total);
|
$results[] = new Model\Result((float)\rand(0, 100) / 100, $p);
|
||||||
|
}
|
||||||
$rawResults = $this->fetchRawResult($queries, $types, $parameters, $paginator);
|
foreach ($this->getThirdParties($query) as $t) {
|
||||||
|
$results[] = new Model\Result((float)\rand(0, 100) / 100, $t);
|
||||||
$this->prepareProviders($rawResults);
|
|
||||||
$results = $this->buildResults($rawResults);
|
|
||||||
|
|
||||||
$collection = new Collection($results, $paginator);
|
|
||||||
|
|
||||||
return $collection;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function findQueries($pattern, array $types, array $parameters): array
|
|
||||||
{
|
|
||||||
return \array_map(
|
|
||||||
fn($p) => $p->provideQuery($pattern, $parameters),
|
|
||||||
$this->findProviders($pattern, $types, $parameters),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function findProviders(string $pattern, array $types, array $parameters): array
|
|
||||||
{
|
|
||||||
return \array_filter(
|
|
||||||
$this->providers,
|
|
||||||
fn($p) => $p->supportsTypes($pattern, $types, $parameters)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function countItems($providers, $types, $parameters): int
|
|
||||||
{
|
|
||||||
list($countQuery, $parameters) = $this->buildCountQuery($providers, $types, $parameters);
|
|
||||||
$rsmCount = new ResultSetMappingBuilder($this->em);
|
|
||||||
$rsmCount->addScalarResult('count', 'count');
|
|
||||||
$countNq = $this->em->createNativeQuery($countQuery, $rsmCount);
|
|
||||||
$countNq->setParameters($parameters);
|
|
||||||
|
|
||||||
return $countNq->getSingleScalarResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
private function buildCountQuery(array $queries, $types, $parameters)
|
|
||||||
{
|
|
||||||
$query = "SELECT COUNT(sq.key) AS count FROM ({union_unordered}) AS sq";
|
|
||||||
$unions = [];
|
|
||||||
$parameters = [];
|
|
||||||
|
|
||||||
foreach ($queries as $q) {
|
|
||||||
$unions[] = $q->buildQuery();
|
|
||||||
$parameters = \array_merge($parameters, $q->buildParameters());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$unionUnordered = \implode(" UNION ", $unions);
|
\usort($results, function(Model\Result $a, Model\Result $b) {
|
||||||
|
return ($a->getRelevance() <=> $b->getRelevance()) * -1;
|
||||||
|
});
|
||||||
|
|
||||||
return [
|
return $results;
|
||||||
\strtr($query, [ '{union_unordered}' => $unionUnordered ]),
|
|
||||||
$parameters
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildUnionQuery(array $queries, $types, $parameters)
|
public function countResults(string $query): int
|
||||||
{
|
{
|
||||||
$query = "{unions} ORDER BY pertinence DESC";
|
return 0;
|
||||||
$unions = [];
|
}
|
||||||
$parameters = [];
|
|
||||||
|
|
||||||
foreach ($queries as $q) {
|
private function getThirdParties(string $query)
|
||||||
$unions[] = $q->buildQuery();
|
{
|
||||||
$parameters = \array_merge($parameters, $q->buildParameters());
|
$thirdPartiesIds = $this->em->createQuery('SELECT t.id FROM '.ThirdParty::class.' t')
|
||||||
|
->getScalarResult();
|
||||||
|
$nbResults = rand(0, 15);
|
||||||
|
|
||||||
|
if ($nbResults === 1) {
|
||||||
|
$nbResults++;
|
||||||
|
} elseif ($nbResults === 0) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
$ids = \array_map(function ($e) use ($thirdPartiesIds) { return $thirdPartiesIds[$e]['id'];},
|
||||||
|
\array_rand($thirdPartiesIds, $nbResults));
|
||||||
|
|
||||||
|
$a = $this->em->getRepository(ThirdParty::class)
|
||||||
|
->findById($ids);
|
||||||
|
return $a;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getPersons(string $query)
|
||||||
|
{
|
||||||
|
$params = [
|
||||||
|
SearchInterface::SEARCH_PREVIEW_OPTION => false
|
||||||
|
];
|
||||||
|
$search = $this->search->getResultByName($query, 'person_regular', 0, 50, $params, 'json');
|
||||||
|
$ids = \array_map(function($r) { return $r['id']; }, $search['results']);
|
||||||
|
|
||||||
|
|
||||||
|
if (count($ids) === 0) {
|
||||||
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$union = \implode(" UNION ", $unions);
|
return $this->em->getRepository(Person::class)
|
||||||
|
->findById($ids)
|
||||||
return [
|
|
||||||
\strtr($query, [ '{unions}' => $union]),
|
|
||||||
$parameters
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
private function fetchRawResult($queries, $types, $parameters, $paginator): array
|
|
||||||
{
|
|
||||||
list($union, $parameters) = $this->buildUnionQuery($queries, $types, $parameters, $paginator);
|
|
||||||
$rsm = new ResultSetMappingBuilder($this->em);
|
|
||||||
$rsm->addScalarResult('key', 'key', Types::STRING)
|
|
||||||
->addScalarResult('metadata', 'metadata', Types::JSON)
|
|
||||||
->addScalarResult('pertinence', 'pertinence', Types::FLOAT)
|
|
||||||
;
|
;
|
||||||
|
|
||||||
$nq = $this->em->createNativeQuery($union, $rsm);
|
|
||||||
$nq->setParameters($parameters);
|
|
||||||
|
|
||||||
return $nq->getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
private function prepareProviders($rawResults)
|
|
||||||
{
|
|
||||||
$metadatas = [];
|
|
||||||
foreach ($rawResults as $r) {
|
|
||||||
foreach ($this->providers as $k => $p) {
|
|
||||||
if ($p->supportsResult($r['key'], $r['metadata'])) {
|
|
||||||
$metadatas[$k][] = $r['metadata'];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($metadatas as $k => $m) {
|
|
||||||
$this->providers[$k]->prepare($m);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function buildResults($rawResults)
|
|
||||||
{
|
|
||||||
foreach ($rawResults as $r) {
|
|
||||||
foreach ($this->providers as $k => $p) {
|
|
||||||
if ($p->supportsResult($r['key'], $r['metadata'])) {
|
|
||||||
$items[] = (new SearchApiResult($r['pertinence']))
|
|
||||||
->setResult(
|
|
||||||
$p->getResult($r['key'], $r['metadata'], $r['pertinence'])
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $items ?? [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\MainBundle\Search;
|
|
||||||
|
|
||||||
use Chill\MainBundle\Search\SearchApiQuery;
|
|
||||||
|
|
||||||
interface SearchApiInterface
|
|
||||||
{
|
|
||||||
public function provideQuery(string $pattern, array $parameters): SearchApiQuery;
|
|
||||||
|
|
||||||
public function supportsTypes(string $pattern, array $types, array $parameters): bool;
|
|
||||||
|
|
||||||
public function prepare(array $metadatas): void;
|
|
||||||
|
|
||||||
public function supportsResult(string $key, array $metadatas): bool;
|
|
||||||
|
|
||||||
public function getResult(string $key, array $metadata, float $pertinence);
|
|
||||||
}
|
|
@@ -1,85 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\MainBundle\Search;
|
|
||||||
|
|
||||||
class SearchApiQuery
|
|
||||||
{
|
|
||||||
private ?string $selectKey;
|
|
||||||
private array $selectKeyParams = [];
|
|
||||||
private ?string $jsonbMetadata;
|
|
||||||
private array $jsonbMetadataParams = [];
|
|
||||||
private ?string $pertinence;
|
|
||||||
private array $pertinenceParams = [];
|
|
||||||
private ?string $fromClause;
|
|
||||||
private array $fromClauseParams = [];
|
|
||||||
private ?string $whereClause;
|
|
||||||
private array $whereClauseParams = [];
|
|
||||||
|
|
||||||
public function setSelectKey(string $selectKey, array $params = []): self
|
|
||||||
{
|
|
||||||
$this->selectKey = $selectKey;
|
|
||||||
$this->selectKeyParams = $params;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setSelectJsonbMetadata(string $jsonbMetadata, array $params = []): self
|
|
||||||
{
|
|
||||||
$this->jsonbMetadata = $jsonbMetadata;
|
|
||||||
$this->jsonbMetadataParams = $params;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setSelectPertinence(string $pertinence, array $params = []): self
|
|
||||||
{
|
|
||||||
$this->pertinence = $pertinence;
|
|
||||||
$this->pertinenceParams = $params;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setFromClause(string $fromClause, array $params = []): self
|
|
||||||
{
|
|
||||||
$this->fromClause = $fromClause;
|
|
||||||
$this->fromClauseParams = $params;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setWhereClause(string $whereClause, array $params = []): self
|
|
||||||
{
|
|
||||||
$this->whereClause = $whereClause;
|
|
||||||
$this->whereClauseParams = $params;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function buildQuery(): string
|
|
||||||
{
|
|
||||||
return \strtr("SELECT
|
|
||||||
'{key}' AS key,
|
|
||||||
{metadata} AS metadata,
|
|
||||||
{pertinence} AS pertinence
|
|
||||||
FROM {from}
|
|
||||||
WHERE {where}
|
|
||||||
", [
|
|
||||||
'{key}' => $this->selectKey,
|
|
||||||
'{metadata}' => $this->jsonbMetadata,
|
|
||||||
'{pertinence}' => $this->pertinence,
|
|
||||||
'{from}' => $this->fromClause,
|
|
||||||
'{where}' => $this->whereClause
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function buildParameters(): array
|
|
||||||
{
|
|
||||||
return \array_merge(
|
|
||||||
$this->selectKeyParams,
|
|
||||||
$this->jsonbMetadataParams,
|
|
||||||
$this->pertinenceParams,
|
|
||||||
$this->fromClauseParams,
|
|
||||||
$this->whereClauseParams
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,40 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\MainBundle\Search;
|
|
||||||
|
|
||||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
|
||||||
|
|
||||||
class SearchApiResult
|
|
||||||
{
|
|
||||||
private float $pertinence;
|
|
||||||
|
|
||||||
private $result;
|
|
||||||
|
|
||||||
public function __construct(float $relevance)
|
|
||||||
{
|
|
||||||
$this->relevance = $relevance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setResult($result): self
|
|
||||||
{
|
|
||||||
$this->result = $result;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Serializer\Groups({"read"})
|
|
||||||
*/
|
|
||||||
public function getResult()
|
|
||||||
{
|
|
||||||
return $this->result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Serializer\Groups({"read"})
|
|
||||||
*/
|
|
||||||
public function getRelevance(): float
|
|
||||||
{
|
|
||||||
return $this->relevance;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -14,20 +14,8 @@ class AddressNormalizer implements NormalizerAwareInterface, NormalizerInterface
|
|||||||
public function normalize($address, string $format = null, array $context = [])
|
public function normalize($address, string $format = null, array $context = [])
|
||||||
{
|
{
|
||||||
$data['address_id'] = $address->getId();
|
$data['address_id'] = $address->getId();
|
||||||
$data['text'] = $address->isNoAddress() ? '' : $address->getStreetNumber().', '.$address->getStreet();
|
$data['text'] = $address->getStreet().', '.$address->getBuildingName();
|
||||||
$data['street'] = $address->getStreet();
|
|
||||||
$data['streetNumber'] = $address->getStreetNumber();
|
|
||||||
$data['postcode']['name'] = $address->getPostCode()->getName();
|
$data['postcode']['name'] = $address->getPostCode()->getName();
|
||||||
$data['postcode']['code'] = $address->getPostCode()->getCode();
|
|
||||||
$data['country']['name'] = $address->getPostCode()->getCountry()->getName();
|
|
||||||
$data['country']['code'] = $address->getPostCode()->getCountry()->getCountryCode();
|
|
||||||
$data['floor'] = $address->getFloor();
|
|
||||||
$data['corridor'] = $address->getCorridor();
|
|
||||||
$data['steps'] = $address->getSteps();
|
|
||||||
$data['flat'] = $address->getBuildingName();
|
|
||||||
$data['buildingName'] = $address->getFlat();
|
|
||||||
$data['distribution'] = $address->getDistribution();
|
|
||||||
$data['extra'] = $address->getExtra();
|
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
@@ -37,5 +25,5 @@ class AddressNormalizer implements NormalizerAwareInterface, NormalizerInterface
|
|||||||
return $data instanceof Address;
|
return $data instanceof Address;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -19,6 +19,7 @@ class CollectionNormalizer implements NormalizerInterface, NormalizerAwareInterf
|
|||||||
public function normalize($collection, string $format = null, array $context = [])
|
public function normalize($collection, string $format = null, array $context = [])
|
||||||
{
|
{
|
||||||
/** @var $collection Collection */
|
/** @var $collection Collection */
|
||||||
|
/** @var $collection Chill\MainBundle\Pagination\PaginatorInterface */
|
||||||
$paginator = $collection->getPaginator();
|
$paginator = $collection->getPaginator();
|
||||||
|
|
||||||
$data['count'] = $paginator->getTotalItems();
|
$data['count'] = $paginator->getTotalItems();
|
||||||
|
@@ -1,36 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Bundle\ChillMainBundle\Tests\Controller;
|
|
||||||
|
|
||||||
use Chill\MainBundle\Test\PrepareClientTrait;
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
|
|
||||||
class SearchApiControllerTest extends WebTestCase
|
|
||||||
{
|
|
||||||
use PrepareClientTrait;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider generateSearchData
|
|
||||||
*/
|
|
||||||
public function testSearch(string $pattern, array $types)
|
|
||||||
{
|
|
||||||
$client = $this->getClientAuthenticated();
|
|
||||||
|
|
||||||
$client->request(
|
|
||||||
Request::METHOD_GET,
|
|
||||||
'/api/1.0/search.json',
|
|
||||||
[ 'q' => $pattern, 'type' => $types ]
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertResponseIsSuccessful();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function generateSearchData()
|
|
||||||
{
|
|
||||||
yield ['per', ['person', 'thirdparty'] ];
|
|
||||||
yield ['per', ['thirdparty'] ];
|
|
||||||
yield ['per', ['person'] ];
|
|
||||||
yield ['fjklmeqjfkdqjklrmefdqjklm', ['person', 'thirdparty'] ];
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,49 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\MainBundle\Tests\Controller;
|
|
||||||
|
|
||||||
use Chill\MainBundle\Test\PrepareClientTrait;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
|
||||||
|
|
||||||
class UserApiControllerTest extends WebTestCase
|
|
||||||
{
|
|
||||||
use PrepareClientTrait;
|
|
||||||
|
|
||||||
public function testIndex()
|
|
||||||
{
|
|
||||||
$client = $this->getClientAuthenticated();
|
|
||||||
|
|
||||||
$client->request(Request::METHOD_GET, '/api/1.0/main/user.json');
|
|
||||||
|
|
||||||
$this->assertResponseIsSuccessful();
|
|
||||||
|
|
||||||
$data = \json_decode($client->getResponse()->getContent(), true);
|
|
||||||
$this->assertTrue(\array_key_exists('count', $data));
|
|
||||||
$this->assertGreaterThan(0, $data['count']);
|
|
||||||
$this->assertTrue(\array_key_exists('results', $data));
|
|
||||||
|
|
||||||
return $data['results'][0];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @depends testIndex
|
|
||||||
*/
|
|
||||||
public function testEntity($existingUser)
|
|
||||||
{
|
|
||||||
$client = $this->getClientAuthenticated();
|
|
||||||
|
|
||||||
$client->request(Request::METHOD_GET, '/api/1.0/main/user/'.$existingUser['id'].'.json');
|
|
||||||
|
|
||||||
$this->assertResponseIsSuccessful();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testWhoami()
|
|
||||||
{
|
|
||||||
$client = $this->getClientAuthenticated();
|
|
||||||
|
|
||||||
$client->request(Request::METHOD_GET, '/api/1.0/main/whoami.json');
|
|
||||||
|
|
||||||
$this->assertResponseIsSuccessful();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,216 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\MainBundle\Tests\Util;
|
|
||||||
|
|
||||||
use Chill\MainBundle\Util\DateRangeCovering;
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
|
|
||||||
class DateRangeCoveringTest extends TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
public function testCoveringWithMinCover1()
|
|
||||||
{
|
|
||||||
$cover = new DateRangeCovering(1, new \DateTimeZone('Europe/Brussels'));
|
|
||||||
$cover
|
|
||||||
->add(new \DateTime('2010-01-01'), new \DateTime('2010-12-01'), 1)
|
|
||||||
->add(new \DateTime('2010-06-01'), new \DateTime('2011-06-01'), 2)
|
|
||||||
->add(new \DateTime('2019-06-01'), new \DateTime('2019-06-01'), 3)
|
|
||||||
->compute()
|
|
||||||
;
|
|
||||||
|
|
||||||
$this->assertTrue($cover->hasIntersections());
|
|
||||||
$this->assertIsArray($cover->getIntersections());
|
|
||||||
$this->assertCount(1, $cover->getIntersections());
|
|
||||||
$this->assertEquals(
|
|
||||||
new \DateTime('2010-06-01'),
|
|
||||||
$cover->getIntersections()[0][0],
|
|
||||||
"assert date start are the intersection"
|
|
||||||
);
|
|
||||||
$this->assertEquals(
|
|
||||||
new \DateTime('2010-12-01'),
|
|
||||||
$cover->getIntersections()[0][1],
|
|
||||||
"assert date end are the intersection"
|
|
||||||
);
|
|
||||||
$this->assertIsArray($cover->getIntersections()[0][2]);
|
|
||||||
$this->assertContains(1, $cover->getIntersections()[0][2]);
|
|
||||||
$this->assertContains(2, $cover->getIntersections()[0][2]);
|
|
||||||
$this->assertNotContains(3, $cover->getIntersections()[0][2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCoveringWithMinCover1WithTwoIntersections()
|
|
||||||
{
|
|
||||||
$cover = new DateRangeCovering(1, new \DateTimeZone('Europe/Brussels'));
|
|
||||||
$cover
|
|
||||||
->add(new \DateTime('2010-01-01'), new \DateTime('2010-12-01'), 1)
|
|
||||||
->add(new \DateTime('2010-06-01'), new \DateTime('2011-06-01'), 2)
|
|
||||||
->add(new \DateTime('2019-01-01'), new \DateTime('2019-12-01'), 3)
|
|
||||||
->add(new \DateTime('2019-06-01'), new \DateTime('2020-06-01'), 4)
|
|
||||||
->compute()
|
|
||||||
;
|
|
||||||
|
|
||||||
$this->assertTrue($cover->hasIntersections());
|
|
||||||
$this->assertIsArray($cover->getIntersections());
|
|
||||||
$this->assertCount(2, $cover->getIntersections());
|
|
||||||
|
|
||||||
$intersections = $cover->getIntersections();
|
|
||||||
|
|
||||||
// sort the intersections to compare them in expected order
|
|
||||||
\usort($intersections, function($a, $b) {
|
|
||||||
if ($a[0] === $b[0]) {
|
|
||||||
return $a[1] <=> $b[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $a[0] <=> $b[0];
|
|
||||||
});
|
|
||||||
|
|
||||||
// first intersection
|
|
||||||
$this->assertEquals(
|
|
||||||
new \DateTime('2010-06-01'),
|
|
||||||
$intersections[0][0],
|
|
||||||
"assert date start are the intersection"
|
|
||||||
);
|
|
||||||
$this->assertEquals(
|
|
||||||
new \DateTime('2010-12-01'),
|
|
||||||
$intersections[0][1],
|
|
||||||
"assert date end are the intersection"
|
|
||||||
);
|
|
||||||
$this->assertIsArray($intersections[0][2]);
|
|
||||||
$this->assertContains(1, $intersections[0][2]);
|
|
||||||
$this->assertContains(2, $intersections[0][2]);
|
|
||||||
$this->assertNotContains(3, $intersections[0][2]);
|
|
||||||
$this->assertNotContains(4, $intersections[0][2]);
|
|
||||||
|
|
||||||
// second intersection
|
|
||||||
$this->assertEquals(
|
|
||||||
new \DateTime('2019-06-01'),
|
|
||||||
$intersections[1][0],
|
|
||||||
"assert date start are the intersection"
|
|
||||||
);
|
|
||||||
$this->assertEquals(
|
|
||||||
new \DateTime('2019-12-01'),
|
|
||||||
$intersections[1][1],
|
|
||||||
"assert date end are the intersection"
|
|
||||||
);
|
|
||||||
$this->assertIsArray($intersections[1][2]);
|
|
||||||
$this->assertContains(3, $intersections[1][2]);
|
|
||||||
$this->assertContains(4, $intersections[1][2]);
|
|
||||||
$this->assertNotContains(1, $intersections[1][2]);
|
|
||||||
$this->assertNotContains(2, $intersections[1][2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCoveringWithMinCover2()
|
|
||||||
{
|
|
||||||
$cover = new DateRangeCovering(2, new \DateTimeZone('Europe/Brussels'));
|
|
||||||
$cover
|
|
||||||
->add(new \DateTime('2010-01-01'), new \DateTime('2010-10-01'), 1)
|
|
||||||
->add(new \DateTime('2010-06-01'), new \DateTime('2010-09-01'), 2)
|
|
||||||
->add(new \DateTime('2010-04-01'), new \DateTime('2010-12-01'), 3)
|
|
||||||
->add(new \DateTime('2019-01-01'), new \DateTime('2019-10-01'), 4)
|
|
||||||
->add(new \DateTime('2019-06-01'), new \DateTime('2019-09-01'), 5)
|
|
||||||
->compute()
|
|
||||||
;
|
|
||||||
$this->assertTrue($cover->hasIntersections());
|
|
||||||
$this->assertIsArray($cover->getIntersections());
|
|
||||||
$this->assertCount(1, $cover->getIntersections());
|
|
||||||
|
|
||||||
$this->assertEquals(
|
|
||||||
new \DateTime('2010-06-01'),
|
|
||||||
$cover->getIntersections()[0][0],
|
|
||||||
"assert date start are the intersection"
|
|
||||||
);
|
|
||||||
$this->assertEquals(
|
|
||||||
new \DateTime('2010-09-01'),
|
|
||||||
$cover->getIntersections()[0][1],
|
|
||||||
"assert date end are the intersection"
|
|
||||||
);
|
|
||||||
$this->assertIsArray($cover->getIntersections()[0][2]);
|
|
||||||
$this->assertContains(1, $cover->getIntersections()[0][2]);
|
|
||||||
$this->assertContains(2, $cover->getIntersections()[0][2]);
|
|
||||||
$this->assertContains(3, $cover->getIntersections()[0][2]);
|
|
||||||
$this->assertNotContains(4, $cover->getIntersections()[0][2]);
|
|
||||||
$this->assertNotContains(5, $cover->getIntersections()[0][2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCoveringWithMinCover2AndThreePeriodsCovering()
|
|
||||||
{
|
|
||||||
$cover = new DateRangeCovering(2, new \DateTimeZone('Europe/Brussels'));
|
|
||||||
$cover
|
|
||||||
->add(new \DateTime('2010-01-01'), new \DateTime('2010-10-01'), 1)
|
|
||||||
->add(new \DateTime('2010-06-01'), new \DateTime('2010-09-01'), 2)
|
|
||||||
->add(new \DateTime('2010-04-01'), new \DateTime('2010-12-01'), 3)
|
|
||||||
->add(new \DateTime('2009-01-01'), new \DateTime('2010-09-15'), 4)
|
|
||||||
->add(new \DateTime('2019-01-01'), new \DateTime('2019-10-01'), 5)
|
|
||||||
->add(new \DateTime('2019-06-01'), new \DateTime('2019-09-01'), 6)
|
|
||||||
->compute()
|
|
||||||
;
|
|
||||||
|
|
||||||
$this->assertTrue($cover->hasIntersections());
|
|
||||||
$this->assertIsArray($cover->getIntersections());
|
|
||||||
$this->assertCount(1, $cover->getIntersections());
|
|
||||||
|
|
||||||
$this->assertEquals(
|
|
||||||
new \DateTime('2010-04-01'),
|
|
||||||
$cover->getIntersections()[0][0],
|
|
||||||
"assert date start are the intersection"
|
|
||||||
);
|
|
||||||
$this->assertEquals(
|
|
||||||
new \DateTime('2010-09-15'),
|
|
||||||
$cover->getIntersections()[0][1],
|
|
||||||
"assert date end are the intersection"
|
|
||||||
);
|
|
||||||
$this->assertIsArray($cover->getIntersections()[0][2]);
|
|
||||||
$this->assertContains(1, $cover->getIntersections()[0][2]);
|
|
||||||
$this->assertContains(2, $cover->getIntersections()[0][2]);
|
|
||||||
$this->assertContains(3, $cover->getIntersections()[0][2]);
|
|
||||||
$this->assertContains(4, $cover->getIntersections()[0][2]);
|
|
||||||
$this->assertNotContains(5, $cover->getIntersections()[0][2]);
|
|
||||||
$this->assertNotContains(6, $cover->getIntersections()[0][2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCoveringWithMinCover2AndThreePeriodsCoveringWithNullMetadata()
|
|
||||||
{
|
|
||||||
$cover = new DateRangeCovering(2, new \DateTimeZone('Europe/Brussels'));
|
|
||||||
$cover
|
|
||||||
->add(new \DateTime('2010-01-01'), new \DateTime('2010-10-01'), null)
|
|
||||||
->add(new \DateTime('2010-06-01'), new \DateTime('2010-09-01'), null)
|
|
||||||
->add(new \DateTime('2010-04-01'), new \DateTime('2010-12-01'), null)
|
|
||||||
->add(new \DateTime('2009-01-01'), new \DateTime('2010-09-15'), null)
|
|
||||||
->add(new \DateTime('2019-01-01'), new \DateTime('2019-10-01'), null)
|
|
||||||
->add(new \DateTime('2019-06-01'), new \DateTime('2019-09-01'), null)
|
|
||||||
->compute()
|
|
||||||
;
|
|
||||||
|
|
||||||
$this->assertTrue($cover->hasIntersections());
|
|
||||||
$this->assertIsArray($cover->getIntersections());
|
|
||||||
$this->assertCount(1, $cover->getIntersections());
|
|
||||||
|
|
||||||
$this->assertEquals(
|
|
||||||
new \DateTime('2010-04-01'),
|
|
||||||
$cover->getIntersections()[0][0],
|
|
||||||
"assert date start are the intersection"
|
|
||||||
);
|
|
||||||
$this->assertEquals(
|
|
||||||
new \DateTime('2010-09-15'),
|
|
||||||
$cover->getIntersections()[0][1],
|
|
||||||
"assert date end are the intersection"
|
|
||||||
);
|
|
||||||
$this->assertIsArray($cover->getIntersections()[0][2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function testCoveringWithMinCover3Absent()
|
|
||||||
{
|
|
||||||
$cover = new DateRangeCovering(3, new \DateTimeZone('Europe/Brussels'));
|
|
||||||
$cover
|
|
||||||
->add(new \DateTime('2010-01-01'), new \DateTime('2010-10-01'), 1)
|
|
||||||
->add(new \DateTime('2010-06-01'), new \DateTime('2010-09-01'), 2)
|
|
||||||
->add(new \DateTime('2010-04-01'), new \DateTime('2010-12-01'), 3)
|
|
||||||
->add(new \DateTime('2019-01-01'), new \DateTime('2019-10-01'), 4)
|
|
||||||
->add(new \DateTime('2019-06-01'), new \DateTime('2019-09-01'), 5)
|
|
||||||
->compute()
|
|
||||||
;
|
|
||||||
$this->assertFalse($cover->hasIntersections());
|
|
||||||
$this->assertIsArray($cover->getIntersections());
|
|
||||||
$this->assertCount(0, $cover->getIntersections());
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,224 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\MainBundle\Util;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Utilities to compare date periods
|
|
||||||
*
|
|
||||||
* This class allow to compare periods when there are period covering. The
|
|
||||||
* argument `minCovers` allow to find also when there are more than 2 period
|
|
||||||
* which intersects.
|
|
||||||
*
|
|
||||||
* Example: a team may have maximum 2 leaders on a same period: you will
|
|
||||||
* find here all periods where there are more than 2 leaders.
|
|
||||||
*
|
|
||||||
* Usage:
|
|
||||||
*
|
|
||||||
* ```php
|
|
||||||
* $cover = new DateRangeCovering(2); // 2 means we will have periods
|
|
||||||
* // when there are 2+ periods intersecting
|
|
||||||
* $cover
|
|
||||||
* ->add(new \DateTime('2010-01-01'), new \DateTime('2010-10-01'), null)
|
|
||||||
* ->add(new \DateTime('2010-06-01'), new \DateTime('2010-09-01'), null)
|
|
||||||
* ->add(new \DateTime('2010-04-01'), new \DateTime('2010-12-01'), null)
|
|
||||||
* ->add(new \DateTime('2009-01-01'), new \DateTime('2010-09-15'), null)
|
|
||||||
* ->add(new \DateTime('2019-01-01'), new \DateTime('2019-10-01'), null)
|
|
||||||
* ->add(new \DateTime('2019-06-01'), new \DateTime('2019-09-01'), null)
|
|
||||||
* ->compute()
|
|
||||||
* ;
|
|
||||||
* $cover->getIntersections();
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
class DateRangeCovering
|
|
||||||
{
|
|
||||||
private bool $computed = false;
|
|
||||||
|
|
||||||
private array $intersections = [];
|
|
||||||
|
|
||||||
private array $intervals = [];
|
|
||||||
|
|
||||||
private int $minCover;
|
|
||||||
|
|
||||||
private int $uniqueKeyCounter = 0;
|
|
||||||
|
|
||||||
private array $metadatas = [];
|
|
||||||
|
|
||||||
private array $sequence = [];
|
|
||||||
|
|
||||||
private \DateTimeZone $tz;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param int $minCover the minimum of covering required
|
|
||||||
*/
|
|
||||||
public function __construct(int $minCover, \DateTimeZone $tz)
|
|
||||||
{
|
|
||||||
if ($minCover < 0) {
|
|
||||||
throw new \LogicException("argument minCover cannot be lower than 0");
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->minCover = $minCover;
|
|
||||||
$this->tz = $tz;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function add(\DateTimeInterface $start, \DateTimeInterface $end = null, $metadata = null): self
|
|
||||||
{
|
|
||||||
if ($this->computed) {
|
|
||||||
throw new \LogicException("You cannot add intervals to a computed instance");
|
|
||||||
}
|
|
||||||
|
|
||||||
$k = $this->uniqueKeyCounter++;
|
|
||||||
$this->intervals[$k] = [$start, $end];
|
|
||||||
$this->metadatas[$k] = $metadata;
|
|
||||||
|
|
||||||
$this->addToSequence($start->getTimestamp(), $k, null);
|
|
||||||
$this->addToSequence(
|
|
||||||
NULL === $end ? PHP_INT_MAX : $end->getTimestamp(), null, $k
|
|
||||||
);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function addToSequence($timestamp, int $start = null, int $end = null)
|
|
||||||
{
|
|
||||||
if (!\array_key_exists($timestamp, $this->sequence)) {
|
|
||||||
$this->sequence[$timestamp] = [ 's' => [], 'e' => [] ];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NULL !== $start) {
|
|
||||||
$this->sequence[$timestamp]['s'][] = $start;
|
|
||||||
}
|
|
||||||
if (NULL !== $end) {
|
|
||||||
$this->sequence[$timestamp]['e'][] = $end;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function compute(): self
|
|
||||||
{
|
|
||||||
\ksort($this->sequence);
|
|
||||||
|
|
||||||
$currentPeriod = [];
|
|
||||||
$currents = [];
|
|
||||||
$isOpen = false;
|
|
||||||
$overs = [];
|
|
||||||
|
|
||||||
foreach ($this->sequence as $ts => $moves) {
|
|
||||||
$currents = \array_merge($currents, $moves['s']);
|
|
||||||
$currents = \array_diff($currents, $moves['e']);
|
|
||||||
|
|
||||||
if (count($currents) > $this->minCover && !$isOpen) {
|
|
||||||
$currentPeriod[0] = $ts;
|
|
||||||
$currentPeriod[2] = $currents;
|
|
||||||
$isOpen = true;
|
|
||||||
} elseif ($isOpen && count($currents) <= $this->minCover) {
|
|
||||||
$currentPeriod[1] = $ts;
|
|
||||||
$overs[] = $currentPeriod;
|
|
||||||
$currentPeriod = [];
|
|
||||||
$isOpen = false;
|
|
||||||
} elseif ($isOpen) {
|
|
||||||
$currentPeriod[2] = \array_merge($currentPeriod[2], $currents);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// process metadata
|
|
||||||
foreach ($overs as list($start, $end, $metadata)) {
|
|
||||||
$this->intersections[] = [
|
|
||||||
(new \DateTimeImmutable('@'.$start))
|
|
||||||
->setTimezone($this->tz),
|
|
||||||
$end === PHP_INT_MAX ? null : (new \DateTimeImmutable('@'.$end))
|
|
||||||
->setTimezone($this->tz),
|
|
||||||
\array_values(
|
|
||||||
\array_intersect_key(
|
|
||||||
$this->metadatas,
|
|
||||||
\array_flip(\array_unique($metadata))
|
|
||||||
)
|
|
||||||
)
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->computed = true;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function process(array $intersections): array
|
|
||||||
{
|
|
||||||
$result = [];
|
|
||||||
$starts = [];
|
|
||||||
$ends = [];
|
|
||||||
$metadatas = [];
|
|
||||||
|
|
||||||
while (null !== ($current = \array_pop($intersections))) {
|
|
||||||
list($cStart, $cEnd, $cMetadata) = $current;
|
|
||||||
$n = count($cMetadata);
|
|
||||||
|
|
||||||
foreach ($intersections as list($iStart, $iEnd, $iMetadata)) {
|
|
||||||
$start = max($cStart, $iStart);
|
|
||||||
$end = min($cEnd, $iEnd);
|
|
||||||
|
|
||||||
if ($start <= $end) {
|
|
||||||
if (FALSE !== ($key = \array_search($start, $starts))) {
|
|
||||||
if ($ends[$key] === $end) {
|
|
||||||
$metadatas[$key] = \array_unique(\array_merge($metadatas[$key], $iMetadata));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$starts[] = $start;
|
|
||||||
$ends[] = $end;
|
|
||||||
$metadatas[] = \array_unique(\array_merge($iMetadata, $cMetadata));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// recompose results
|
|
||||||
foreach ($starts as $k => $start) {
|
|
||||||
$result[] = [$start, $ends[$k], \array_unique($metadatas[$k])];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function addToIntersections(array $intersections, array $intersection)
|
|
||||||
{
|
|
||||||
$foundExisting = false;
|
|
||||||
list($nStart, $nEnd, $nMetadata) = $intersection;
|
|
||||||
|
|
||||||
\array_walk($intersections,
|
|
||||||
function(&$i, $key) use ($nStart, $nEnd, $nMetadata, $foundExisting) {
|
|
||||||
if ($foundExisting) {
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
if ($i[0] === $nStart && $i[1] === $nEnd) {
|
|
||||||
$foundExisting = true;
|
|
||||||
$i[2] = \array_merge($i[2], $nMetadata);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!$foundExisting) {
|
|
||||||
$intersections[] = $intersection;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $intersections;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function hasIntersections(): bool
|
|
||||||
{
|
|
||||||
if (!$this->computed) {
|
|
||||||
throw new \LogicException(sprintf("You cannot call the method %s before ".
|
|
||||||
"'process'", __METHOD));
|
|
||||||
}
|
|
||||||
|
|
||||||
return count($this->intersections) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getIntersections(): array
|
|
||||||
{
|
|
||||||
if (!$this->computed) {
|
|
||||||
throw new \LogicException(sprintf("You cannot call the method %s before ".
|
|
||||||
"'process'", __METHOD));
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->intersections;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -10,19 +10,6 @@ servers:
|
|||||||
|
|
||||||
components:
|
components:
|
||||||
schemas:
|
schemas:
|
||||||
User:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
type: integer
|
|
||||||
type:
|
|
||||||
type: string
|
|
||||||
enum:
|
|
||||||
- user
|
|
||||||
username:
|
|
||||||
type: string
|
|
||||||
text:
|
|
||||||
type: string
|
|
||||||
Center:
|
Center:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
@@ -30,93 +17,6 @@ components:
|
|||||||
type: integer
|
type: integer
|
||||||
name:
|
name:
|
||||||
type: string
|
type: string
|
||||||
Address:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
address_id:
|
|
||||||
type: integer
|
|
||||||
text:
|
|
||||||
type: string
|
|
||||||
postcode:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
|
|
||||||
Country:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
type: integer
|
|
||||||
name:
|
|
||||||
type: object
|
|
||||||
countryCode:
|
|
||||||
type: string
|
|
||||||
|
|
||||||
PostalCode:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
type: integer
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
code:
|
|
||||||
type: string
|
|
||||||
country:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
type: integer
|
|
||||||
name:
|
|
||||||
type: object
|
|
||||||
countryCode:
|
|
||||||
type: string
|
|
||||||
|
|
||||||
AddressReference:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
type: integer
|
|
||||||
refId:
|
|
||||||
type: string
|
|
||||||
street:
|
|
||||||
type: string
|
|
||||||
streetNumber:
|
|
||||||
type: string
|
|
||||||
postcode:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
type: integer
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
code:
|
|
||||||
type: string
|
|
||||||
country:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
type: integer
|
|
||||||
name:
|
|
||||||
type: object
|
|
||||||
countryCode:
|
|
||||||
type: string
|
|
||||||
municipalityCode:
|
|
||||||
type: string
|
|
||||||
source:
|
|
||||||
type: string
|
|
||||||
point:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
type:
|
|
||||||
type: string
|
|
||||||
coordinates:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
type: number
|
|
||||||
minItems: 2
|
|
||||||
maxItems: 2
|
|
||||||
|
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
/1.0/search.json:
|
/1.0/search.json:
|
||||||
@@ -129,7 +29,7 @@ paths:
|
|||||||
description: >
|
description: >
|
||||||
**Warning**: This is currently a stub (not really implemented
|
**Warning**: This is currently a stub (not really implemented
|
||||||
|
|
||||||
The search is performed across multiple entities. The entities must be listed into
|
The search is performed across multiple entities. The entities must be listed into
|
||||||
`type` parameters.
|
`type` parameters.
|
||||||
|
|
||||||
The results are ordered by relevance, from the most to the lowest relevant.
|
The results are ordered by relevance, from the most to the lowest relevant.
|
||||||
@@ -155,329 +55,4 @@ paths:
|
|||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
description: "OK"
|
description: "OK"
|
||||||
/1.0/main/address.json:
|
|
||||||
get:
|
|
||||||
tags:
|
|
||||||
- address
|
|
||||||
summary: Return a list of all Chill addresses
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: "ok"
|
|
||||||
post:
|
|
||||||
tags:
|
|
||||||
- address
|
|
||||||
summary: create a new address
|
|
||||||
requestBody:
|
|
||||||
required: true
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
buildingName:
|
|
||||||
type: string
|
|
||||||
corridor:
|
|
||||||
type: string
|
|
||||||
distribution:
|
|
||||||
type: string
|
|
||||||
extra:
|
|
||||||
type: string
|
|
||||||
flat:
|
|
||||||
type: string
|
|
||||||
floor:
|
|
||||||
type: string
|
|
||||||
isNoAddress:
|
|
||||||
type: boolean
|
|
||||||
point:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
type: number
|
|
||||||
minItems: 2
|
|
||||||
maxItems: 2
|
|
||||||
postcode:
|
|
||||||
$ref: '#/components/schemas/PostalCode'
|
|
||||||
steps:
|
|
||||||
type: string
|
|
||||||
street:
|
|
||||||
type: string
|
|
||||||
streetNumber:
|
|
||||||
type: string
|
|
||||||
responses:
|
|
||||||
401:
|
|
||||||
description: "Unauthorized"
|
|
||||||
404:
|
|
||||||
description: "Not found"
|
|
||||||
200:
|
|
||||||
description: "OK"
|
|
||||||
422:
|
|
||||||
description: "Unprocessable entity (validation errors)"
|
|
||||||
400:
|
|
||||||
description: "transition cannot be applyed"
|
|
||||||
patch:
|
|
||||||
tags:
|
|
||||||
- address
|
|
||||||
summary: patch an address
|
|
||||||
requestBody:
|
|
||||||
required: true
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
buildingName:
|
|
||||||
type: string
|
|
||||||
corridor:
|
|
||||||
type: string
|
|
||||||
distribution:
|
|
||||||
type: string
|
|
||||||
extra:
|
|
||||||
type: string
|
|
||||||
flat:
|
|
||||||
type: string
|
|
||||||
floor:
|
|
||||||
type: string
|
|
||||||
isNoAddress:
|
|
||||||
type: boolean
|
|
||||||
point:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
type: number
|
|
||||||
minItems: 2
|
|
||||||
maxItems: 2
|
|
||||||
postcode:
|
|
||||||
$ref: '#/components/schemas/PostalCode'
|
|
||||||
steps:
|
|
||||||
type: string
|
|
||||||
street:
|
|
||||||
type: string
|
|
||||||
streetNumber:
|
|
||||||
type: string
|
|
||||||
validFrom:
|
|
||||||
type: string
|
|
||||||
validTo:
|
|
||||||
type: string
|
|
||||||
responses:
|
|
||||||
401:
|
|
||||||
description: "Unauthorized"
|
|
||||||
404:
|
|
||||||
description: "Not found"
|
|
||||||
200:
|
|
||||||
description: "OK"
|
|
||||||
422:
|
|
||||||
description: "Unprocessable entity (validation errors)"
|
|
||||||
400:
|
|
||||||
description: "transition cannot be applyed"
|
|
||||||
|
|
||||||
/1.0/main/address/{id}.json:
|
|
||||||
get:
|
|
||||||
tags:
|
|
||||||
- address
|
|
||||||
summary: Return an address by id
|
|
||||||
parameters:
|
|
||||||
- name: id
|
|
||||||
in: path
|
|
||||||
required: true
|
|
||||||
description: The address id
|
|
||||||
schema:
|
|
||||||
type: integer
|
|
||||||
format: integer
|
|
||||||
minimum: 1
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: "ok"
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/Address'
|
|
||||||
404:
|
|
||||||
description: "not found"
|
|
||||||
401:
|
|
||||||
description: "Unauthorized"
|
|
||||||
|
|
||||||
/1.0/main/address-reference.json:
|
|
||||||
get:
|
|
||||||
tags:
|
|
||||||
- address
|
|
||||||
summary: Return a list of all reference addresses
|
|
||||||
parameters:
|
|
||||||
- in: query
|
|
||||||
name: postal_code
|
|
||||||
required: false
|
|
||||||
schema:
|
|
||||||
type: integer
|
|
||||||
description: The id of a postal code to filter the reference addresses
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: "ok"
|
|
||||||
/1.0/main/address-reference/{id}.json:
|
|
||||||
get:
|
|
||||||
tags:
|
|
||||||
- address
|
|
||||||
summary: Return a reference address by id
|
|
||||||
parameters:
|
|
||||||
- name: id
|
|
||||||
in: path
|
|
||||||
required: true
|
|
||||||
description: The reference address id
|
|
||||||
schema:
|
|
||||||
type: integer
|
|
||||||
format: integer
|
|
||||||
minimum: 1
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: "ok"
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/AddressReference'
|
|
||||||
404:
|
|
||||||
description: "not found"
|
|
||||||
401:
|
|
||||||
description: "Unauthorized"
|
|
||||||
|
|
||||||
/1.0/main/postal-code.json:
|
|
||||||
get:
|
|
||||||
tags:
|
|
||||||
- address
|
|
||||||
summary: Return a list of all postal-code
|
|
||||||
parameters:
|
|
||||||
- in: query
|
|
||||||
name: country
|
|
||||||
required: false
|
|
||||||
schema:
|
|
||||||
type: integer
|
|
||||||
description: The id of a country to filter the postal code
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: "ok"
|
|
||||||
post:
|
|
||||||
tags:
|
|
||||||
- address
|
|
||||||
summary: create a new PostalCode
|
|
||||||
requestBody:
|
|
||||||
required: true
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
code:
|
|
||||||
type: string
|
|
||||||
country:
|
|
||||||
$ref: '#/components/schemas/Country'
|
|
||||||
responses:
|
|
||||||
401:
|
|
||||||
description: "Unauthorized"
|
|
||||||
404:
|
|
||||||
description: "Not found"
|
|
||||||
200:
|
|
||||||
description: "OK"
|
|
||||||
422:
|
|
||||||
description: "Unprocessable entity (validation errors)"
|
|
||||||
400:
|
|
||||||
description: "transition cannot be applyed"
|
|
||||||
|
|
||||||
/1.0/main/postal-code/{id}.json:
|
|
||||||
get:
|
|
||||||
tags:
|
|
||||||
- address
|
|
||||||
summary: Return a postal code by id
|
|
||||||
parameters:
|
|
||||||
- name: id
|
|
||||||
in: path
|
|
||||||
required: true
|
|
||||||
description: The postal code id
|
|
||||||
schema:
|
|
||||||
type: integer
|
|
||||||
format: integer
|
|
||||||
minimum: 1
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: "ok"
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/PostalCode'
|
|
||||||
404:
|
|
||||||
description: "not found"
|
|
||||||
401:
|
|
||||||
description: "Unauthorized"
|
|
||||||
|
|
||||||
/1.0/main/country.json:
|
|
||||||
get:
|
|
||||||
tags:
|
|
||||||
- address
|
|
||||||
summary: Return a list of all countries
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: "ok"
|
|
||||||
/1.0/main/country/{id}.json:
|
|
||||||
get:
|
|
||||||
tags:
|
|
||||||
- address
|
|
||||||
summary: Return a country by id
|
|
||||||
parameters:
|
|
||||||
- name: id
|
|
||||||
in: path
|
|
||||||
required: true
|
|
||||||
description: The country id
|
|
||||||
schema:
|
|
||||||
type: integer
|
|
||||||
format: integer
|
|
||||||
minimum: 1
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: "ok"
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/Country'
|
|
||||||
404:
|
|
||||||
description: "not found"
|
|
||||||
401:
|
|
||||||
description: "Unauthorized"
|
|
||||||
|
|
||||||
|
|
||||||
/1.0/main/user.json:
|
|
||||||
get:
|
|
||||||
tags:
|
|
||||||
- user
|
|
||||||
summary: Return a list of all user
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: "ok"
|
|
||||||
/1.0/main/whoami.json:
|
|
||||||
get:
|
|
||||||
tags:
|
|
||||||
- user
|
|
||||||
summary: Return the currently authenticated user
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: "ok"
|
|
||||||
/1.0/main/user/{id}.json:
|
|
||||||
get:
|
|
||||||
tags:
|
|
||||||
- user
|
|
||||||
summary: Return a user by id
|
|
||||||
parameters:
|
|
||||||
- name: id
|
|
||||||
in: path
|
|
||||||
required: true
|
|
||||||
description: The user id
|
|
||||||
schema:
|
|
||||||
type: integer
|
|
||||||
format: integer
|
|
||||||
minimum: 1
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: "ok"
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/User'
|
|
||||||
404:
|
|
||||||
description: "not found"
|
|
||||||
401:
|
|
||||||
description: "Unauthorized"
|
|
||||||
|
@@ -56,6 +56,7 @@ module.exports = function(encore, entries)
|
|||||||
// Chill2 new assets
|
// Chill2 new assets
|
||||||
encore.addEntry('forkawesome', __dirname + '/Resources/public/modules/forkawesome/index.js');
|
encore.addEntry('forkawesome', __dirname + '/Resources/public/modules/forkawesome/index.js');
|
||||||
encore.addEntry('bootstrap', __dirname + '/Resources/public/modules/bootstrap/index.js');
|
encore.addEntry('bootstrap', __dirname + '/Resources/public/modules/bootstrap/index.js');
|
||||||
|
//encore.addEntry('vuejs', __dirname + '/Resources/public/modules/vue/index.js');
|
||||||
|
|
||||||
// CKEditor5
|
// CKEditor5
|
||||||
buildCKEditor(encore);
|
buildCKEditor(encore);
|
||||||
|
@@ -58,14 +58,13 @@ services:
|
|||||||
arguments:
|
arguments:
|
||||||
- "@chill.main.helper.translatable_string"
|
- "@chill.main.helper.translatable_string"
|
||||||
- '@Symfony\Component\Routing\Generator\UrlGeneratorInterface'
|
- '@Symfony\Component\Routing\Generator\UrlGeneratorInterface'
|
||||||
- '@Chill\MainBundle\Form\ChoiceLoader\PostalCodeChoiceLoader'
|
- '@chill.main.form.choice_loader.postal_code'
|
||||||
- '@Symfony\Component\Translation\TranslatorInterface'
|
- '@Symfony\Component\Translation\TranslatorInterface'
|
||||||
tags:
|
tags:
|
||||||
- { name: form.type }
|
- { name: form.type }
|
||||||
|
|
||||||
Chill\MainBundle\Form\ChoiceLoader\PostalCodeChoiceLoader:
|
chill.main.form.choice_loader.postal_code:
|
||||||
autowire: true
|
class: Chill\MainBundle\Form\ChoiceLoader\PostalCodeChoiceLoader
|
||||||
autoconfigure: true
|
|
||||||
|
|
||||||
chill.main.form.type.export:
|
chill.main.form.type.export:
|
||||||
class: Chill\MainBundle\Form\Type\Export\ExportType
|
class: Chill\MainBundle\Form\Type\Export\ExportType
|
||||||
|
@@ -5,5 +5,6 @@ services:
|
|||||||
Chill\MainBundle\Search\SearchProvider: '@chill_main.search_provider'
|
Chill\MainBundle\Search\SearchProvider: '@chill_main.search_provider'
|
||||||
|
|
||||||
Chill\MainBundle\Search\SearchApi:
|
Chill\MainBundle\Search\SearchApi:
|
||||||
autowire: true
|
arguments:
|
||||||
autoconfigure: true
|
$em: '@Doctrine\ORM\EntityManagerInterface'
|
||||||
|
$search: '@Chill\MainBundle\Search\SearchProvider'
|
||||||
|
@@ -1,29 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\Migrations\Main;
|
|
||||||
|
|
||||||
use Doctrine\DBAL\Schema\Schema;
|
|
||||||
use Doctrine\Migrations\AbstractMigration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Auto-generated Migration: Please modify to your needs!
|
|
||||||
*/
|
|
||||||
final class Version20210616134328 extends AbstractMigration
|
|
||||||
{
|
|
||||||
public function getDescription(): string
|
|
||||||
{
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function up(Schema $schema): void
|
|
||||||
{
|
|
||||||
$this->addSql('ALTER TABLE chill_main_postal_code ADD origin INT DEFAULT NULL');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function down(Schema $schema): void
|
|
||||||
{
|
|
||||||
$this->addSql('ALTER TABLE chill_main_postal_code DROP origin');
|
|
||||||
}
|
|
||||||
}
|
|
@@ -6,7 +6,6 @@ use Chill\MainBundle\CRUD\Controller\ApiController;
|
|||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
|
||||||
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
|
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||||
@@ -117,20 +116,6 @@ $workflow = $this->registry->get($accompanyingPeriod);
|
|||||||
return $this->addRemoveSomething('socialissue', $id, $request, $_format, 'socialIssue', SocialIssue::class, [ 'groups' => [ 'read' ] ]);
|
return $this->addRemoveSomething('socialissue', $id, $request, $_format, 'socialIssue', SocialIssue::class, [ 'groups' => [ 'read' ] ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function workApi($id, Request $request, string $_format): Response
|
|
||||||
{
|
|
||||||
return $this->addRemoveSomething(
|
|
||||||
'work',
|
|
||||||
$id,
|
|
||||||
$request,
|
|
||||||
$_format,
|
|
||||||
'work',
|
|
||||||
AccompanyingPeriodWork::class,
|
|
||||||
[ 'groups' => [ 'accompanying_period_work:create' ] ],
|
|
||||||
true // force persist
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function requestorApi($id, Request $request, string $_format): Response
|
public function requestorApi($id, Request $request, string $_format): Response
|
||||||
{
|
{
|
||||||
/** @var AccompanyingPeriod $accompanyingPeriod */
|
/** @var AccompanyingPeriod $accompanyingPeriod */
|
||||||
|
@@ -2,12 +2,10 @@
|
|||||||
|
|
||||||
namespace Chill\PersonBundle\Controller;
|
namespace Chill\PersonBundle\Controller;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\Activity;
|
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
|
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
|
||||||
use Chill\PersonBundle\Privacy\AccompanyingPeriodPrivacyEvent;
|
use Chill\PersonBundle\Privacy\AccompanyingPeriodPrivacyEvent;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
|
|
||||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
@@ -36,18 +34,14 @@ class AccompanyingCourseController extends Controller
|
|||||||
|
|
||||||
protected ValidatorInterface $validator;
|
protected ValidatorInterface $validator;
|
||||||
|
|
||||||
private AccompanyingPeriodWorkRepository $workRepository;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
SerializerInterface $serializer,
|
SerializerInterface $serializer,
|
||||||
EventDispatcherInterface $dispatcher,
|
EventDispatcherInterface $dispatcher,
|
||||||
ValidatorInterface $validator,
|
ValidatorInterface $validator
|
||||||
AccompanyingPeriodWorkRepository $workRepository
|
|
||||||
) {
|
) {
|
||||||
$this->serializer = $serializer;
|
$this->serializer = $serializer;
|
||||||
$this->dispatcher = $dispatcher;
|
$this->dispatcher = $dispatcher;
|
||||||
$this->validator = $validator;
|
$this->validator = $validator;
|
||||||
$this->workRepository = $workRepository;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -81,7 +75,7 @@ class AccompanyingCourseController extends Controller
|
|||||||
return $this->redirectToRoute('chill_person_accompanying_course_edit', [
|
return $this->redirectToRoute('chill_person_accompanying_course_edit', [
|
||||||
'accompanying_period_id' => $period->getId()
|
'accompanying_period_id' => $period->getId()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -92,32 +86,8 @@ class AccompanyingCourseController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function indexAction(AccompanyingPeriod $accompanyingCourse): Response
|
public function indexAction(AccompanyingPeriod $accompanyingCourse): Response
|
||||||
{
|
{
|
||||||
// compute some warnings
|
|
||||||
// get persons without household
|
|
||||||
$withoutHousehold = [];
|
|
||||||
foreach ($accompanyingCourse->getParticipations() as
|
|
||||||
$p) {
|
|
||||||
if (FALSE === $p->getPerson()->isSharingHousehold()) {
|
|
||||||
$withoutHousehold[] = $p->getPerson();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$activities = $this->getDoctrine()->getManager()->getRepository(Activity::class)->findBy(
|
|
||||||
['accompanyingPeriod' => $accompanyingCourse],
|
|
||||||
['date' => 'DESC'],
|
|
||||||
);
|
|
||||||
|
|
||||||
$works = $this->workRepository->findByAccompanyingPeriod(
|
|
||||||
$accompanyingCourse,
|
|
||||||
['startDate' => 'DESC', 'endDate' => 'DESC'],
|
|
||||||
3
|
|
||||||
);
|
|
||||||
|
|
||||||
return $this->render('@ChillPerson/AccompanyingCourse/index.html.twig', [
|
return $this->render('@ChillPerson/AccompanyingCourse/index.html.twig', [
|
||||||
'accompanyingCourse' => $accompanyingCourse,
|
'accompanyingCourse' => $accompanyingCourse
|
||||||
'withoutHousehold' => $withoutHousehold,
|
|
||||||
'works' => $works,
|
|
||||||
'activities' => $activities
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,23 +0,0 @@
|
|||||||
<?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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,109 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
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,
|
|
||||||
AccompanyingPeriodWorkRepository $workRepository,
|
|
||||||
PaginatorFactory $paginator
|
|
||||||
) {
|
|
||||||
$this->trans = $trans;
|
|
||||||
$this->serializer = $serializer;
|
|
||||||
$this->workRepository = $workRepository;
|
|
||||||
$this->paginator = $paginator;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Route(
|
|
||||||
* "{_locale}/person/accompanying-period/{id}/work/new",
|
|
||||||
* name="chill_person_accompanying_period_work_new",
|
|
||||||
* methods={"GET"}
|
|
||||||
* )
|
|
||||||
*/
|
|
||||||
public function createWork(AccompanyingPeriod $period): Response
|
|
||||||
{
|
|
||||||
// TODO ACL
|
|
||||||
|
|
||||||
if ($period->getSocialIssues()->count() === 0) {
|
|
||||||
$this->addFlash('error', $this->trans->trans(
|
|
||||||
"accompanying_work.You must add at least ".
|
|
||||||
"one social issue on accompanying period")
|
|
||||||
);
|
|
||||||
|
|
||||||
return $this->redirectToRoute('chill_person_accompanying_course_index', [
|
|
||||||
'accompanying_period_id' => $period->getId()
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$json = $this->serializer->normalize($period, 'json', [ "groups" => [ "read" ]]);
|
|
||||||
|
|
||||||
return $this->render('@ChillPerson/AccompanyingCourseWork/create.html.twig', [
|
|
||||||
'accompanyingCourse' => $period,
|
|
||||||
'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
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -47,12 +47,12 @@ class AccompanyingPeriodController extends AbstractController
|
|||||||
* @var EventDispatcherInterface
|
* @var EventDispatcherInterface
|
||||||
*/
|
*/
|
||||||
protected $eventDispatcher;
|
protected $eventDispatcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var ValidatorInterface
|
* @var ValidatorInterface
|
||||||
*/
|
*/
|
||||||
protected $validator;
|
protected $validator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AccompanyingPeriodController constructor.
|
* AccompanyingPeriodController constructor.
|
||||||
*
|
*
|
||||||
@@ -64,25 +64,23 @@ class AccompanyingPeriodController extends AbstractController
|
|||||||
$this->eventDispatcher = $eventDispatcher;
|
$this->eventDispatcher = $eventDispatcher;
|
||||||
$this->validator = $validator;
|
$this->validator = $validator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function listAction(int $person_id): Response
|
public function listAction(int $person_id): Response
|
||||||
{
|
{
|
||||||
$person = $this->_getPerson($person_id);
|
$person = $this->_getPerson($person_id);
|
||||||
|
|
||||||
$event = new PrivacyEvent($person, [
|
$event = new PrivacyEvent($person, [
|
||||||
'element_class' => AccompanyingPeriod::class,
|
'element_class' => AccompanyingPeriod::class,
|
||||||
'action' => 'list'
|
'action' => 'list'
|
||||||
]);
|
]);
|
||||||
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
|
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
|
||||||
|
|
||||||
$accompanyingPeriods = $person->getAccompanyingPeriodsOrdered();
|
|
||||||
|
|
||||||
return $this->render('ChillPersonBundle:AccompanyingPeriod:list.html.twig', [
|
return $this->render('ChillPersonBundle:AccompanyingPeriod:list.html.twig', [
|
||||||
'accompanying_periods' => $accompanyingPeriods,
|
'accompanying_periods' => $person->getAccompanyingPeriodsOrdered(),
|
||||||
'person' => $person
|
'person' => $person
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createAction(int $person_id, Request $request): Response
|
public function createAction(int $person_id, Request $request): Response
|
||||||
{
|
{
|
||||||
$person = $this->_getPerson($person_id);
|
$person = $this->_getPerson($person_id);
|
||||||
@@ -92,17 +90,17 @@ class AccompanyingPeriodController extends AbstractController
|
|||||||
|
|
||||||
$accompanyingPeriod = new AccompanyingPeriod(new \DateTime('now'));
|
$accompanyingPeriod = new AccompanyingPeriod(new \DateTime('now'));
|
||||||
$accompanyingPeriod->setClosingDate(new \DateTime('now'));
|
$accompanyingPeriod->setClosingDate(new \DateTime('now'));
|
||||||
|
|
||||||
$accompanyingPeriod->addPerson($person);
|
$accompanyingPeriod->addPerson($person);
|
||||||
//or $person->addAccompanyingPeriod($accompanyingPeriod);
|
//or $person->addAccompanyingPeriod($accompanyingPeriod);
|
||||||
|
|
||||||
$form = $this->createForm(
|
$form = $this->createForm(
|
||||||
AccompanyingPeriodType::class,
|
AccompanyingPeriodType::class,
|
||||||
$accompanyingPeriod, [
|
$accompanyingPeriod, [
|
||||||
'period_action' => 'create',
|
'period_action' => 'create',
|
||||||
'center' => $person->getCenter()
|
'center' => $person->getCenter()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($request->getMethod() === 'POST') {
|
if ($request->getMethod() === 'POST') {
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
$errors = $this->_validatePerson($person);
|
$errors = $this->_validatePerson($person);
|
||||||
@@ -122,7 +120,7 @@ class AccompanyingPeriodController extends AbstractController
|
|||||||
$this->generateUrl('chill_person_accompanying_period_list', [
|
$this->generateUrl('chill_person_accompanying_period_list', [
|
||||||
'person_id' => $person->getId()
|
'person_id' => $person->getId()
|
||||||
]));
|
]));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$flashBag->add('error', $this->get('translator')
|
$flashBag->add('error', $this->get('translator')
|
||||||
->trans('Error! Period not created!'));
|
->trans('Error! Period not created!'));
|
||||||
@@ -139,7 +137,7 @@ class AccompanyingPeriodController extends AbstractController
|
|||||||
'accompanying_period' => $accompanyingPeriod
|
'accompanying_period' => $accompanyingPeriod
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@@ -156,7 +154,7 @@ class AccompanyingPeriodController extends AbstractController
|
|||||||
|
|
||||||
/** @var Person $person */
|
/** @var Person $person */
|
||||||
$person = $this->_getPerson($person_id);
|
$person = $this->_getPerson($person_id);
|
||||||
|
|
||||||
// CHECK
|
// CHECK
|
||||||
if (! $accompanyingPeriod->containsPerson($person)) {
|
if (! $accompanyingPeriod->containsPerson($person)) {
|
||||||
throw new Exception("Accompanying period " . $period_id . " does not contain person " . $person_id);
|
throw new Exception("Accompanying period " . $period_id . " does not contain person " . $person_id);
|
||||||
@@ -178,7 +176,7 @@ class AccompanyingPeriodController extends AbstractController
|
|||||||
|
|
||||||
if ($form->isValid(['Default', 'closed'])
|
if ($form->isValid(['Default', 'closed'])
|
||||||
&& count($errors) === 0) {
|
&& count($errors) === 0) {
|
||||||
|
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
$flashBag->add('success',
|
$flashBag->add('success',
|
||||||
@@ -188,9 +186,9 @@ class AccompanyingPeriodController extends AbstractController
|
|||||||
$this->generateUrl('chill_person_accompanying_period_list', [
|
$this->generateUrl('chill_person_accompanying_period_list', [
|
||||||
'person_id' => $person->getId()
|
'person_id' => $person->getId()
|
||||||
]));
|
]));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$flashBag->add('error', $this->get('translator')
|
$flashBag->add('error', $this->get('translator')
|
||||||
->trans('Error when updating the period'));
|
->trans('Error when updating the period'));
|
||||||
|
|
||||||
@@ -206,19 +204,19 @@ class AccompanyingPeriodController extends AbstractController
|
|||||||
'accompanying_period' => $accompanyingPeriod
|
'accompanying_period' => $accompanyingPeriod
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function closeAction(int $person_id, Request $request): Response
|
public function closeAction(int $person_id, Request $request): Response
|
||||||
{
|
{
|
||||||
|
|
||||||
$person = $this->_getPerson($person_id);
|
$person = $this->_getPerson($person_id);
|
||||||
|
|
||||||
$this->denyAccessUnlessGranted(PersonVoter::UPDATE, $person, 'You are not allowed to update this person');
|
$this->denyAccessUnlessGranted(PersonVoter::UPDATE, $person, 'You are not allowed to update this person');
|
||||||
|
|
||||||
if ($person->isOpen() === false) {
|
if ($person->isOpen() === false) {
|
||||||
|
|
||||||
$this->get('session')->getFlashBag()
|
$this->get('session')->getFlashBag()
|
||||||
->add('error', $this->get('translator')
|
->add('error', $this->get('translator')
|
||||||
->trans('Beware period is closed', ['%name%' => $person->__toString()]
|
->trans('Beware period is closed', ['%name%' => $person->__toString()]
|
||||||
@@ -231,7 +229,7 @@ class AccompanyingPeriodController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
$current = $person->getCurrentAccompanyingPeriod();
|
$current = $person->getCurrentAccompanyingPeriod();
|
||||||
|
|
||||||
$form = $this->createForm(AccompanyingPeriodType::class, $current, [
|
$form = $this->createForm(AccompanyingPeriodType::class, $current, [
|
||||||
'period_action' => 'close',
|
'period_action' => 'close',
|
||||||
'center' => $person->getCenter()
|
'center' => $person->getCenter()
|
||||||
@@ -258,7 +256,7 @@ class AccompanyingPeriodController extends AbstractController
|
|||||||
'person_id' => $person->getId()
|
'person_id' => $person->getId()
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$this->get('session')->getFlashBag()
|
$this->get('session')->getFlashBag()
|
||||||
->add('error', $this->get('translator')
|
->add('error', $this->get('translator')
|
||||||
@@ -269,7 +267,7 @@ class AccompanyingPeriodController extends AbstractController
|
|||||||
->add('info', $error->getMessage());
|
->add('info', $error->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else { //if form is not valid
|
} else { //if form is not valid
|
||||||
$this->get('session')->getFlashBag()
|
$this->get('session')->getFlashBag()
|
||||||
->add('error',
|
->add('error',
|
||||||
@@ -290,7 +288,7 @@ class AccompanyingPeriodController extends AbstractController
|
|||||||
'accompanying_period' => $current
|
'accompanying_period' => $current
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _validatePerson(Person $person): ConstraintViolationListInterface
|
private function _validatePerson(Person $person): ConstraintViolationListInterface
|
||||||
{
|
{
|
||||||
$errors = $this->validator->validate($person, null,
|
$errors = $this->validator->validate($person, null,
|
||||||
@@ -298,10 +296,10 @@ class AccompanyingPeriodController extends AbstractController
|
|||||||
|
|
||||||
// Can be disabled with config
|
// Can be disabled with config
|
||||||
if (false === $this->container->getParameter('chill_person.allow_multiple_simultaneous_accompanying_periods')) {
|
if (false === $this->container->getParameter('chill_person.allow_multiple_simultaneous_accompanying_periods')) {
|
||||||
|
|
||||||
$errors_accompanying_period = $this->validator->validate($person, null,
|
$errors_accompanying_period = $this->validator->validate($person, null,
|
||||||
['accompanying_period_consistent']);
|
['accompanying_period_consistent']);
|
||||||
|
|
||||||
foreach($errors_accompanying_period as $error ) {
|
foreach($errors_accompanying_period as $error ) {
|
||||||
$errors->add($error);
|
$errors->add($error);
|
||||||
}
|
}
|
||||||
@@ -309,7 +307,7 @@ class AccompanyingPeriodController extends AbstractController
|
|||||||
|
|
||||||
return $errors;
|
return $errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function openAction(int $person_id, Request $request): Response
|
public function openAction(int $person_id, Request $request): Response
|
||||||
{
|
{
|
||||||
$person = $this->_getPerson($person_id);
|
$person = $this->_getPerson($person_id);
|
||||||
@@ -386,7 +384,7 @@ class AccompanyingPeriodController extends AbstractController
|
|||||||
'accompanying_period' => $accompanyingPeriod
|
'accompanying_period' => $accompanyingPeriod
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function reOpenAction(int $person_id, int $period_id, Request $request): Response
|
public function reOpenAction(int $person_id, int $period_id, Request $request): Response
|
||||||
{
|
{
|
||||||
/** @var Person $person */
|
/** @var Person $person */
|
||||||
@@ -394,7 +392,7 @@ class AccompanyingPeriodController extends AbstractController
|
|||||||
|
|
||||||
/* @var $period AccompanyingPeriod */
|
/* @var $period AccompanyingPeriod */
|
||||||
$period = \array_filter(
|
$period = \array_filter(
|
||||||
$person->getAccompanyingPeriods(),
|
$person->getAccompanyingPeriods(),
|
||||||
function (AccompanyingPeriod $p) use ($period_id) {
|
function (AccompanyingPeriod $p) use ($period_id) {
|
||||||
return $p->getId() === ($period_id);
|
return $p->getId() === ($period_id);
|
||||||
}
|
}
|
||||||
@@ -419,13 +417,13 @@ class AccompanyingPeriodController extends AbstractController
|
|||||||
return $this->redirectToRoute('chill_person_accompanying_period_list', [
|
return $this->redirectToRoute('chill_person_accompanying_period_list', [
|
||||||
'person_id' => $person->getId()
|
'person_id' => $person->getId()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
} elseif ($confirm === false && $period->canBeReOpened($person)) {
|
} elseif ($confirm === false && $period->canBeReOpened($person)) {
|
||||||
return $this->render('ChillPersonBundle:AccompanyingPeriod:re_open.html.twig', [
|
return $this->render('ChillPersonBundle:AccompanyingPeriod:re_open.html.twig', [
|
||||||
'period' => $period,
|
'period' => $period,
|
||||||
'person' => $person
|
'person' => $person
|
||||||
]);
|
]);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return (new Response())
|
return (new Response())
|
||||||
->setStatusCode(Response::HTTP_BAD_REQUEST)
|
->setStatusCode(Response::HTTP_BAD_REQUEST)
|
||||||
|
@@ -1,53 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Controller;
|
|
||||||
|
|
||||||
use Chill\MainBundle\CRUD\Controller\ApiController;
|
|
||||||
use Chill\MainBundle\Entity\Address;
|
|
||||||
use Chill\MainBundle\Serializer\Model\Collection;
|
|
||||||
use Chill\PersonBundle\Entity\Person;
|
|
||||||
use Chill\PersonBundle\Repository\Household\HouseholdRepository;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
|
||||||
|
|
||||||
class HouseholdApiController extends ApiController
|
|
||||||
{
|
|
||||||
private HouseholdRepository $householdRepository;
|
|
||||||
|
|
||||||
public function __construct(HouseholdRepository $householdRepository)
|
|
||||||
{
|
|
||||||
$this->householdRepository = $householdRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function householdAddressApi($id, Request $request, string $_format): Response
|
|
||||||
{
|
|
||||||
return $this->addRemoveSomething('address', $id, $request, $_format, 'address', Address::class, [ 'groups' => [ 'read' ] ]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find Household of people participating to the same AccompanyingPeriod
|
|
||||||
*
|
|
||||||
* @ParamConverter("person", options={"id" = "person_id"})
|
|
||||||
*/
|
|
||||||
public function suggestHouseholdByAccompanyingPeriodParticipationApi(Person $person, string $_format)
|
|
||||||
{
|
|
||||||
// TODO add acl
|
|
||||||
|
|
||||||
$count = $this->householdRepository->countByAccompanyingPeriodParticipation($person);
|
|
||||||
$paginator = $this->getPaginatorFactory()->create($count);
|
|
||||||
|
|
||||||
if ($count === 0) {
|
|
||||||
$households = [];
|
|
||||||
} else {
|
|
||||||
$households = $this->householdRepository->findByAccompanyingPeriodParticipation($person,
|
|
||||||
$paginator->getItemsPerPage(), $paginator->getCurrentPageFirstItemNumber());
|
|
||||||
}
|
|
||||||
|
|
||||||
$collection = new Collection($households, $paginator);
|
|
||||||
|
|
||||||
return $this->json($collection, Response::HTTP_OK, [],
|
|
||||||
[ "groups" => ["read"]]);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -2,35 +2,19 @@
|
|||||||
|
|
||||||
namespace Chill\PersonBundle\Controller;
|
namespace Chill\PersonBundle\Controller;
|
||||||
|
|
||||||
use Chill\MainBundle\Entity\Address;
|
|
||||||
use Chill\PersonBundle\Form\HouseholdType;
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\Form\FormInterface;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Component\Translation\TranslatorInterface;
|
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||||
use Chill\PersonBundle\Entity\Household\Household;
|
use Chill\PersonBundle\Entity\Household\Household;
|
||||||
use Chill\PersonBundle\Entity\Household\Position;
|
use Chill\PersonBundle\Entity\Household\Position;
|
||||||
use Chill\PersonBundle\Repository\Household\PositionRepository;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/{_locale}/person/household")
|
* @Route("/{_locale}/person/household")
|
||||||
*/
|
*/
|
||||||
class HouseholdController extends AbstractController
|
class HouseholdController extends AbstractController
|
||||||
{
|
{
|
||||||
private TranslatorInterface $translator;
|
|
||||||
|
|
||||||
private PositionRepository $positionRepository;
|
|
||||||
|
|
||||||
public function __construct(TranslatorInterface $translator, PositionRepository $positionRepository)
|
|
||||||
|
|
||||||
{
|
|
||||||
$this->translator = $translator;
|
|
||||||
$this->positionRepository = $positionRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route(
|
* @Route(
|
||||||
* "/{household_id}/summary",
|
* "/{household_id}/summary",
|
||||||
@@ -43,51 +27,48 @@ class HouseholdController extends AbstractController
|
|||||||
{
|
{
|
||||||
// TODO ACL
|
// TODO ACL
|
||||||
|
|
||||||
$positions = $this->positionRepository
|
$positions = $this->getDoctrine()->getManager()
|
||||||
->findByActiveOrdered()
|
->getRepository(Position::class)
|
||||||
|
->findAll()
|
||||||
;
|
;
|
||||||
|
|
||||||
// little performance improvement:
|
// little performance improvement:
|
||||||
// initialize members collection, which will avoid
|
// initialize members collection, which will avoid
|
||||||
// some queries
|
// some queries
|
||||||
$household->getMembers()->initialize();
|
$household->getMembers()->initialize();
|
||||||
|
|
||||||
if ($request->query->has('edit')) {
|
|
||||||
$form = $this->createMetadataForm($household);
|
|
||||||
} else {
|
|
||||||
$form = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->render('@ChillPerson/Household/summary.html.twig',
|
return $this->render('@ChillPerson/Household/summary.html.twig',
|
||||||
[
|
[
|
||||||
'household' => $household,
|
'household' => $household,
|
||||||
'positions' => $positions,
|
'positions' => $positions
|
||||||
'form' => NULL !== $form ? $form->createView() : null,
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route(
|
* @Route(
|
||||||
* "/{household_id}/accompanying-period",
|
* "/{household_id}/members",
|
||||||
* name="chill_person_household_accompanying_period",
|
* name="chill_person_household_members",
|
||||||
* methods={"GET", "HEAD"}
|
* methods={"GET", "HEAD"}
|
||||||
* )
|
* )
|
||||||
* @ParamConverter("household", options={"id" = "household_id"})
|
* @ParamConverter("household", options={"id" = "household_id"})
|
||||||
*/
|
*/
|
||||||
public function accompanyingPeriod(Request $request, Household $household)
|
public function members(Request $request, Household $household)
|
||||||
{
|
{
|
||||||
// TODO ACL
|
// TODO ACL
|
||||||
|
$positions = $this->getDoctrine()->getManager()
|
||||||
|
->getRepository(Position::class)
|
||||||
|
->findAll()
|
||||||
|
;
|
||||||
|
|
||||||
$members = $household->getMembers();
|
// little performance improvement:
|
||||||
foreach($members as $m) {
|
// initialize members collection, which will avoid
|
||||||
$accompanyingPeriods = $m->getPerson()->getAccompanyingPeriods();
|
// some queries
|
||||||
}
|
$household->getMembers()->initialize();
|
||||||
|
|
||||||
return $this->render('@ChillPerson/Household/accompanying_period.html.twig',
|
return $this->render('@ChillPerson/Household/members.html.twig',
|
||||||
[
|
[
|
||||||
'household' => $household,
|
'household' => $household,
|
||||||
'accompanying_periods' => $accompanyingPeriods
|
'positions' => $positions
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -103,16 +84,6 @@ class HouseholdController extends AbstractController
|
|||||||
public function addresses(Request $request, Household $household)
|
public function addresses(Request $request, Household $household)
|
||||||
{
|
{
|
||||||
// TODO ACL
|
// TODO ACL
|
||||||
|
|
||||||
//TODO put these lines into a validator constraint on household->getAddress
|
|
||||||
$addresses = $household->getAddresses();
|
|
||||||
$cond = True;
|
|
||||||
for ($i=0; $i < count($addresses) - 1; $i++) {
|
|
||||||
if ($addresses[$i]->getValidFrom() != $addresses[$i + 1]->getValidTo()) {
|
|
||||||
$cond = False;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->render('@ChillPerson/Household/addresses.html.twig',
|
return $this->render('@ChillPerson/Household/addresses.html.twig',
|
||||||
[
|
[
|
||||||
'household' => $household
|
'household' => $household
|
||||||
@@ -120,7 +91,6 @@ class HouseholdController extends AbstractController
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route(
|
* @Route(
|
||||||
* "/{household_id}/address/move",
|
* "/{household_id}/address/move",
|
||||||
@@ -132,83 +102,10 @@ class HouseholdController extends AbstractController
|
|||||||
public function addressMove(Request $request, Household $household)
|
public function addressMove(Request $request, Household $household)
|
||||||
{
|
{
|
||||||
// TODO ACL
|
// TODO ACL
|
||||||
|
|
||||||
return $this->render('@ChillPerson/Household/address_move.html.twig',
|
return $this->render('@ChillPerson/Household/address_move.html.twig',
|
||||||
[
|
[
|
||||||
'household' => $household
|
'household' => $household
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @Route(
|
|
||||||
* "/{household_id}/address/edit",
|
|
||||||
* name="chill_person_household_address_edit",
|
|
||||||
* methods={"GET", "HEAD", "POST"}
|
|
||||||
* )
|
|
||||||
* @ParamConverter("household", options={"id" = "household_id"})
|
|
||||||
*/
|
|
||||||
public function addressEdit(Request $request, Household $household)
|
|
||||||
{
|
|
||||||
// TODO ACL
|
|
||||||
//$address = $this->findAddressById($household, $address_id); //TODO
|
|
||||||
|
|
||||||
|
|
||||||
return $this->render('@ChillPerson/Household/address_edit.html.twig',
|
|
||||||
[
|
|
||||||
'household' => $household,
|
|
||||||
//'address' => $address,
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Route(
|
|
||||||
* "/{household_id}/members/metadata/edit",
|
|
||||||
* name="chill_person_household_members_metadata_edit",
|
|
||||||
* methods={"GET", "POST"}
|
|
||||||
* )
|
|
||||||
* @ParamConverter("household", options={"id" = "household_id"})
|
|
||||||
*/
|
|
||||||
public function editHouseholdMetadata(Request $request, Household $household)
|
|
||||||
{
|
|
||||||
// TODO ACL
|
|
||||||
$form = $this->createMetadataForm($household);
|
|
||||||
|
|
||||||
$form->handleRequest($request);
|
|
||||||
|
|
||||||
if ($form->isSubmitted() and $form->isValid()) {
|
|
||||||
$this->getDoctrine()->getManager()->flush();
|
|
||||||
|
|
||||||
$this->addFlash('success', $this->translator->trans('household.data_saved'));
|
|
||||||
|
|
||||||
return $this->redirectToRoute('chill_person_household_summary', [
|
|
||||||
'household_id' => $household->getId()
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->render('@ChillPerson/Household/edit_member_metadata.html.twig', [
|
|
||||||
'household' => $household,
|
|
||||||
'form' => $form->createView()
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function createMetadataForm(Household $household): FormInterface
|
|
||||||
{
|
|
||||||
$form = $this->createForm(
|
|
||||||
HouseholdType::class,
|
|
||||||
$household,
|
|
||||||
[
|
|
||||||
'action' => $this->generateUrl(
|
|
||||||
'chill_person_household_members_metadata_edit',
|
|
||||||
[
|
|
||||||
'household_id' => $household->getId()
|
|
||||||
]
|
|
||||||
)
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
return $form;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -3,7 +3,6 @@
|
|||||||
namespace Chill\PersonBundle\Controller;
|
namespace Chill\PersonBundle\Controller;
|
||||||
|
|
||||||
use Chill\PersonBundle\Entity\Household\Position;
|
use Chill\PersonBundle\Entity\Household\Position;
|
||||||
use Chill\PersonBundle\Repository\AccompanyingPeriodRepository;
|
|
||||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Chill\PersonBundle\Entity\Household\Household;
|
use Chill\PersonBundle\Entity\Household\Household;
|
||||||
@@ -26,17 +25,11 @@ class HouseholdMemberController extends ApiController
|
|||||||
|
|
||||||
private TranslatorInterface $translator;
|
private TranslatorInterface $translator;
|
||||||
|
|
||||||
private AccompanyingPeriodRepository $periodRepository;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(UrlGeneratorInterface $generator, TranslatorInterface $translator)
|
||||||
UrlGeneratorInterface $generator,
|
|
||||||
TranslatorInterface $translator,
|
|
||||||
AccompanyingPeriodRepository $periodRepository
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
$this->generator = $generator;
|
$this->generator = $generator;
|
||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
$this->periodRepository = $periodRepository;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -57,12 +50,8 @@ class HouseholdMemberController extends ApiController
|
|||||||
|
|
||||||
// TODO ACL
|
// TODO ACL
|
||||||
//
|
//
|
||||||
$errors = $editor->validate();
|
// TODO validation
|
||||||
|
//
|
||||||
if (count($errors) > 0) {
|
|
||||||
return $this->json($errors, 422);
|
|
||||||
}
|
|
||||||
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
// if new household, persist it
|
// if new household, persist it
|
||||||
@@ -151,23 +140,8 @@ class HouseholdMemberController extends ApiController
|
|||||||
'allowLeaveWithoutHousehold' => $allowLeaveWithoutHousehold ?? $request->query->has('allow_leave_without_household'),
|
'allowLeaveWithoutHousehold' => $allowLeaveWithoutHousehold ?? $request->query->has('allow_leave_without_household'),
|
||||||
];
|
];
|
||||||
|
|
||||||
// context
|
|
||||||
if ($request->query->has('accompanying_period_id')) {
|
|
||||||
$period = $this->periodRepository->find(
|
|
||||||
$request->query->getInt('accompanying_period_id')
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($period === null) {
|
|
||||||
throw $this->createNotFoundException('period not found');
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO add acl on accompanying Course
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->render('@ChillPerson/Household/members_editor.html.twig', [
|
return $this->render('@ChillPerson/Household/members_editor.html.twig', [
|
||||||
'data' => $data,
|
'data' => $data
|
||||||
'expandSuggestions' => (int) $request->query->getBoolean('expand_suggestions', false),
|
|
||||||
'accompanyingCourse' => $period ?? null,
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,9 +155,7 @@ class HouseholdMemberController extends ApiController
|
|||||||
{
|
{
|
||||||
// TODO ACL
|
// TODO ACL
|
||||||
|
|
||||||
$form = $this->createForm(HouseholdMemberType::class, $member, [
|
$form = $this->createForm(HouseholdMemberType::class, $member);
|
||||||
'validation_groups' => [ 'household_memberships' ]
|
|
||||||
]);
|
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
if ($form->isSubmitted() && $form->isValid()) {
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
@@ -195,7 +167,7 @@ class HouseholdMemberController extends ApiController
|
|||||||
|
|
||||||
return $this->redirect(
|
return $this->redirect(
|
||||||
$request->get('returnPath', null) ??
|
$request->get('returnPath', null) ??
|
||||||
$this->generator->generate('chill_person_household_summary', [ 'household_id' =>
|
$this->generator->generate('chill_person_household_members', [ 'household_id' =>
|
||||||
$member->getHousehold()->getId() ])
|
$member->getHousehold()->getId() ])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -45,7 +45,7 @@ class PersonAddressController extends AbstractController
|
|||||||
* @var ValidatorInterface
|
* @var ValidatorInterface
|
||||||
*/
|
*/
|
||||||
protected $validator;
|
protected $validator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PersonAddressController constructor.
|
* PersonAddressController constructor.
|
||||||
*
|
*
|
||||||
@@ -55,7 +55,7 @@ class PersonAddressController extends AbstractController
|
|||||||
{
|
{
|
||||||
$this->validator = $validator;
|
$this->validator = $validator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function listAction($person_id)
|
public function listAction($person_id)
|
||||||
{
|
{
|
||||||
$person = $this->getDoctrine()->getManager()
|
$person = $this->getDoctrine()->getManager()
|
||||||
@@ -297,16 +297,18 @@ class PersonAddressController extends AbstractController
|
|||||||
*/
|
*/
|
||||||
protected function findAddressById(Person $person, $address_id)
|
protected function findAddressById(Person $person, $address_id)
|
||||||
{
|
{
|
||||||
$address = $this->getDoctrine()->getManager()
|
// filtering address
|
||||||
->getRepository(Address::class)
|
$criteria = Criteria::create()
|
||||||
->find($address_id)
|
->where(Criteria::expr()->eq('id', $address_id))
|
||||||
;
|
->setMaxResults(1);
|
||||||
|
$addresses = $person->getAddresses()->matching($criteria);
|
||||||
|
|
||||||
if (!$person->getAddresses()->contains($address)) {
|
if (count($addresses) === 0) {
|
||||||
throw $this->createAccessDeniedException("Not allowed to see this address");
|
throw $this->createNotFoundException("Address with id $address_id "
|
||||||
|
. "matching person $person_id not found ");
|
||||||
}
|
}
|
||||||
|
|
||||||
return $address;
|
return $addresses->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -22,8 +22,7 @@ use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
|||||||
use Symfony\Component\Security\Core\Role\Role;
|
use Symfony\Component\Security\Core\Role\Role;
|
||||||
use Chill\MainBundle\CRUD\Controller\ApiController;
|
use Chill\MainBundle\CRUD\Controller\ApiController;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
|
||||||
use Chill\MainBundle\Entity\Address;
|
|
||||||
|
|
||||||
class PersonApiController extends ApiController
|
class PersonApiController extends ApiController
|
||||||
{
|
{
|
||||||
@@ -36,7 +35,7 @@ class PersonApiController extends ApiController
|
|||||||
{
|
{
|
||||||
$this->authorizationHelper = $authorizationHelper;
|
$this->authorizationHelper = $authorizationHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function createEntity(string $action, Request $request): object
|
protected function createEntity(string $action, Request $request): object
|
||||||
{
|
{
|
||||||
$person = parent::createEntity($action, $request);
|
$person = parent::createEntity($action, $request);
|
||||||
@@ -48,10 +47,4 @@ class PersonApiController extends ApiController
|
|||||||
|
|
||||||
return $person;
|
return $person;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function personAddressApi($id, Request $request, string $_format): Response
|
|
||||||
{
|
|
||||||
return $this->addRemoveSomething('address', $id, $request, $_format, 'address', Address::class, [ 'groups' => [ 'read' ] ]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -41,8 +41,6 @@ use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
|
|||||||
use Chill\PersonBundle\Repository\PersonNotDuplicateRepository;
|
use Chill\PersonBundle\Repository\PersonNotDuplicateRepository;
|
||||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
|
||||||
|
|
||||||
final class PersonController extends AbstractController
|
final class PersonController extends AbstractController
|
||||||
{
|
{
|
||||||
@@ -418,29 +416,4 @@ final class PersonController extends AbstractController
|
|||||||
|
|
||||||
return $person;
|
return $person;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @Route(
|
|
||||||
* "/{_locale}/person/household/{person_id}/history",
|
|
||||||
* name="chill_person_household_person_history",
|
|
||||||
* methods={"GET", "POST"}
|
|
||||||
* )
|
|
||||||
* @ParamConverter("person", options={"id" = "person_id"})
|
|
||||||
*/
|
|
||||||
public function householdHistoryByPerson(Request $request, Person $person): Response
|
|
||||||
{
|
|
||||||
$this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person,
|
|
||||||
"You are not allowed to see this person.");
|
|
||||||
|
|
||||||
$event = new PrivacyEvent($person);
|
|
||||||
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
|
|
||||||
|
|
||||||
return $this->render(
|
|
||||||
'@ChillPerson/Person/household_history.html.twig',
|
|
||||||
[
|
|
||||||
'person' => $person
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -1,21 +0,0 @@
|
|||||||
<?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());
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,40 +0,0 @@
|
|||||||
<?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" ]]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,47 +0,0 @@
|
|||||||
<?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" ]]);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,47 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Controller;
|
|
||||||
|
|
||||||
use Chill\MainBundle\Serializer\Model\Collection;
|
|
||||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
|
||||||
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
|
|
||||||
use Chill\MainBundle\CRUD\Controller\ApiController;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
|
||||||
|
|
||||||
class SocialWorkSocialActionApiController extends ApiController
|
|
||||||
{
|
|
||||||
private SocialIssueRepository $socialIssueRepository;
|
|
||||||
|
|
||||||
private PaginatorFactory $paginator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param SocialIssueRepository $socialIssueRepository
|
|
||||||
*/
|
|
||||||
public function __construct(SocialIssueRepository $socialIssueRepository, PaginatorFactory $paginator)
|
|
||||||
{
|
|
||||||
$this->socialIssueRepository = $socialIssueRepository;
|
|
||||||
$this->paginator = $paginator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function listBySocialIssueApi($id, Request $request)
|
|
||||||
{
|
|
||||||
$socialIssue = $this->socialIssueRepository
|
|
||||||
->find($id);
|
|
||||||
|
|
||||||
if (NULL === $socialIssue) {
|
|
||||||
throw $this->createNotFoundException("socialIssue not found");
|
|
||||||
}
|
|
||||||
|
|
||||||
$socialActions = $socialIssue->getRecursiveSocialActions();
|
|
||||||
$pagination = $this->paginator->create(count($socialActions));
|
|
||||||
// max one page
|
|
||||||
$pagination->setItemsPerPage(count($socialActions));
|
|
||||||
|
|
||||||
$collection = new Collection($socialActions, $pagination);
|
|
||||||
|
|
||||||
|
|
||||||
return $this->json($collection, JsonResponse::HTTP_OK, [], [ "groups" => [ "read" ]]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -4,15 +4,11 @@ namespace Chill\PersonBundle\DataFixtures\ORM;
|
|||||||
|
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Chill\PersonBundle\Entity\Household\Household;
|
use Chill\PersonBundle\Entity\Household\Household;
|
||||||
use Chill\MainBundle\Entity\PostalCode;
|
|
||||||
use Chill\MainBundle\Entity\Address;
|
|
||||||
use Chill\PersonBundle\Household\MembersEditorFactory;
|
use Chill\PersonBundle\Household\MembersEditorFactory;
|
||||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\Persistence\ObjectManager;
|
use Doctrine\Persistence\ObjectManager;
|
||||||
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
||||||
use Nelmio\Alice\Loader\NativeLoader;
|
|
||||||
use Chill\MainBundle\DataFixtures\ORM\LoadPostalCodes;
|
|
||||||
|
|
||||||
class LoadHousehold extends Fixture implements DependentFixtureInterface
|
class LoadHousehold extends Fixture implements DependentFixtureInterface
|
||||||
{
|
{
|
||||||
@@ -20,15 +16,12 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface
|
|||||||
|
|
||||||
private EntityManagerInterface $em;
|
private EntityManagerInterface $em;
|
||||||
|
|
||||||
private NativeLoader $loader;
|
|
||||||
|
|
||||||
private CONST NUMBER_OF_HOUSEHOLD = 10;
|
private CONST NUMBER_OF_HOUSEHOLD = 10;
|
||||||
|
|
||||||
public function __construct(MembersEditorFactory $editorFactory, EntityManagerInterface $em)
|
public function __construct(MembersEditorFactory $editorFactory, EntityManagerInterface $em)
|
||||||
{
|
{
|
||||||
$this->editorFactory = $editorFactory;
|
$this->editorFactory = $editorFactory;
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
$this->loader = new NativeLoader();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function load(ObjectManager $manager)
|
public function load(ObjectManager $manager)
|
||||||
@@ -60,8 +53,6 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface
|
|||||||
$household = new Household();
|
$household = new Household();
|
||||||
$manager->persist($household);
|
$manager->persist($household);
|
||||||
|
|
||||||
$this->addAddressToHousehold($household, clone $startDate, $manager);
|
|
||||||
|
|
||||||
$movement = $this->editorFactory->createEditor($household);
|
$movement = $this->editorFactory->createEditor($household);
|
||||||
|
|
||||||
// load adults
|
// load adults
|
||||||
@@ -98,55 +89,6 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function addAddressToHousehold(Household $household, \DateTimeImmutable $date, ObjectManager $manager)
|
|
||||||
{
|
|
||||||
if (\random_int(0, 10) > 8) {
|
|
||||||
// 20% of household without address
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$nb = \random_int(1, 6);
|
|
||||||
|
|
||||||
$i = 0;
|
|
||||||
while ($i < $nb) {
|
|
||||||
$address = $this->createAddress();
|
|
||||||
$address->setValidFrom(\DateTime::createFromImmutable($date));
|
|
||||||
|
|
||||||
if (\random_int(0, 20) < 1) {
|
|
||||||
$date = $date->add(new \DateInterval('P'.\random_int(8, 52).'W'));
|
|
||||||
$address->setValidTo(\DateTime::createFromImmutable($date));
|
|
||||||
}
|
|
||||||
|
|
||||||
$household->addAddress($address);
|
|
||||||
$manager->persist($address);
|
|
||||||
|
|
||||||
$date = $date->add(new \DateInterval('P'.\random_int(8, 52).'W'));
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function createAddress(): Address
|
|
||||||
{
|
|
||||||
$objectSet = $this->loader->loadData([
|
|
||||||
Address::class => [
|
|
||||||
'address1' => [
|
|
||||||
'street' => '<fr_FR:streetName()>',
|
|
||||||
'streetNumber' => '<fr_FR:buildingNumber()>',
|
|
||||||
'postCode' => $this->getPostalCode()
|
|
||||||
]
|
|
||||||
]
|
|
||||||
]);
|
|
||||||
|
|
||||||
return $objectSet->getObjects()['address1'];
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getPostalCode(): PostalCode
|
|
||||||
{
|
|
||||||
$ref = LoadPostalCodes::$refs[\array_rand(LoadPostalCodes::$refs)];
|
|
||||||
|
|
||||||
return $this->getReference($ref);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function preparePersonIds()
|
private function preparePersonIds()
|
||||||
{
|
{
|
||||||
$this->personIds = $this->em
|
$this->personIds = $this->em
|
||||||
|
@@ -201,7 +201,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
|||||||
'workflows' => [
|
'workflows' => [
|
||||||
'accompanying_period_lifecycle' => [
|
'accompanying_period_lifecycle' => [
|
||||||
'type' => 'state_machine',
|
'type' => 'state_machine',
|
||||||
'audit_trail' => [
|
'audit_trail' => [
|
||||||
'enabled' => true
|
'enabled' => true
|
||||||
],
|
],
|
||||||
'marking_store' => [
|
'marking_store' => [
|
||||||
@@ -354,15 +354,15 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
|||||||
'controller' => \Chill\PersonBundle\Controller\AccompanyingCourseApiController::class,
|
'controller' => \Chill\PersonBundle\Controller\AccompanyingCourseApiController::class,
|
||||||
'actions' => [
|
'actions' => [
|
||||||
'_entity' => [
|
'_entity' => [
|
||||||
'roles' => [
|
'roles' => [
|
||||||
Request::METHOD_GET => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
Request::METHOD_GET => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
||||||
Request::METHOD_PATCH => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
Request::METHOD_PATCH => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
||||||
Request::METHOD_PUT => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
Request::METHOD_PUT => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
||||||
],
|
],
|
||||||
'methods' => [
|
'methods' => [
|
||||||
Request::METHOD_GET => true,
|
Request::METHOD_GET => true,
|
||||||
Request::METHOD_PUT => true,
|
Request::METHOD_PUT => true,
|
||||||
Request::METHOD_PATCH => true,
|
Request::METHOD_PATCH => true,
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'participation' => [
|
'participation' => [
|
||||||
@@ -379,86 +379,73 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
|||||||
],
|
],
|
||||||
'resource' => [
|
'resource' => [
|
||||||
'methods' => [
|
'methods' => [
|
||||||
Request::METHOD_POST => true,
|
Request::METHOD_POST => true,
|
||||||
Request::METHOD_DELETE => true,
|
Request::METHOD_DELETE => true,
|
||||||
Request::METHOD_GET => false,
|
Request::METHOD_GET => false,
|
||||||
Request::METHOD_HEAD => false,
|
Request::METHOD_HEAD => false,
|
||||||
],
|
],
|
||||||
'roles' => [
|
'roles' => [
|
||||||
Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
||||||
Request::METHOD_DELETE=> \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE
|
Request::METHOD_DELETE=> \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'comment' => [
|
'comment' => [
|
||||||
'methods' => [
|
'methods' => [
|
||||||
Request::METHOD_POST => true,
|
Request::METHOD_POST => true,
|
||||||
Request::METHOD_DELETE => true,
|
Request::METHOD_DELETE => true,
|
||||||
Request::METHOD_GET => false,
|
Request::METHOD_GET => false,
|
||||||
Request::METHOD_HEAD => false,
|
Request::METHOD_HEAD => false,
|
||||||
],
|
],
|
||||||
'roles' => [
|
'roles' => [
|
||||||
Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
||||||
Request::METHOD_DELETE=> \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE
|
Request::METHOD_DELETE=> \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'requestor' => [
|
'requestor' => [
|
||||||
'methods' => [
|
'methods' => [
|
||||||
Request::METHOD_POST => true,
|
Request::METHOD_POST => true,
|
||||||
Request::METHOD_DELETE => true,
|
Request::METHOD_DELETE => true,
|
||||||
Request::METHOD_GET => false,
|
Request::METHOD_GET => false,
|
||||||
Request::METHOD_HEAD => false,
|
Request::METHOD_HEAD => false,
|
||||||
],
|
],
|
||||||
'roles' => [
|
'roles' => [
|
||||||
Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
||||||
Request::METHOD_DELETE=> \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE
|
Request::METHOD_DELETE=> \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'scope' => [
|
'scope' => [
|
||||||
'methods' => [
|
'methods' => [
|
||||||
Request::METHOD_POST => true,
|
Request::METHOD_POST => true,
|
||||||
Request::METHOD_DELETE => true,
|
Request::METHOD_DELETE => true,
|
||||||
Request::METHOD_GET => false,
|
Request::METHOD_GET => false,
|
||||||
Request::METHOD_HEAD => false,
|
Request::METHOD_HEAD => false,
|
||||||
],
|
],
|
||||||
'roles' => [
|
'roles' => [
|
||||||
Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
||||||
Request::METHOD_DELETE=> \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE
|
Request::METHOD_DELETE=> \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'socialissue' => [
|
'socialissue' => [
|
||||||
'methods' => [
|
'methods' => [
|
||||||
Request::METHOD_POST => true,
|
Request::METHOD_POST => true,
|
||||||
Request::METHOD_DELETE => true,
|
Request::METHOD_DELETE => true,
|
||||||
Request::METHOD_GET => false,
|
Request::METHOD_GET => false,
|
||||||
Request::METHOD_HEAD => false,
|
Request::METHOD_HEAD => false,
|
||||||
],
|
],
|
||||||
'controller_action' => 'socialIssueApi',
|
'controller_action' => 'socialIssueApi',
|
||||||
'roles' => [
|
'roles' => [
|
||||||
Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
||||||
Request::METHOD_DELETE=> \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE
|
Request::METHOD_DELETE=> \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'work' => [
|
|
||||||
'methods' => [
|
|
||||||
Request::METHOD_POST => true,
|
|
||||||
Request::METHOD_DELETE => false,
|
|
||||||
Request::METHOD_GET => false,
|
|
||||||
Request::METHOD_HEAD => false,
|
|
||||||
],
|
|
||||||
'controller_action' => 'workApi',
|
|
||||||
'roles' => [
|
|
||||||
Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
|
||||||
Request::METHOD_DELETE => 'ALWAYS_FAILS',
|
|
||||||
]
|
|
||||||
],
|
|
||||||
|
|
||||||
'confirm' => [
|
'confirm' => [
|
||||||
'methods' => [
|
'methods' => [
|
||||||
Request::METHOD_POST => true,
|
Request::METHOD_POST => true,
|
||||||
Request::METHOD_GET => false,
|
Request::METHOD_GET => false,
|
||||||
Request::METHOD_HEAD => false,
|
Request::METHOD_HEAD => false,
|
||||||
],
|
],
|
||||||
'roles' => [
|
'roles' => [
|
||||||
Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
@@ -488,7 +475,6 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
|||||||
[
|
[
|
||||||
'class' => \Chill\PersonBundle\Entity\SocialWork\SocialIssue::class,
|
'class' => \Chill\PersonBundle\Entity\SocialWork\SocialIssue::class,
|
||||||
'name' => 'social_work_social_issue',
|
'name' => 'social_work_social_issue',
|
||||||
'controller' => \Chill\PersonBundle\Controller\SocialIssueApiController::class,
|
|
||||||
'base_path' => '/api/1.0/person/social-work/social-issue',
|
'base_path' => '/api/1.0/person/social-work/social-issue',
|
||||||
'base_role' => 'ROLE_USER',
|
'base_role' => 'ROLE_USER',
|
||||||
'actions' => [
|
'actions' => [
|
||||||
@@ -524,61 +510,14 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
|||||||
Request::METHOD_HEAD => \Chill\PersonBundle\Security\Authorization\PersonVoter::SEE,
|
Request::METHOD_HEAD => \Chill\PersonBundle\Security\Authorization\PersonVoter::SEE,
|
||||||
Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\PersonVoter::CREATE,
|
Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\PersonVoter::CREATE,
|
||||||
|
|
||||||
],
|
]
|
||||||
],
|
|
||||||
'address' => [
|
|
||||||
'methods' => [
|
|
||||||
Request::METHOD_POST => true,
|
|
||||||
Request::METHOD_DELETE => true,
|
|
||||||
Request::METHOD_GET => false,
|
|
||||||
Request::METHOD_HEAD => false,
|
|
||||||
],
|
|
||||||
'controller_action' => 'personAddressApi'
|
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'class' => \Chill\PersonBundle\Entity\Household\Household::class,
|
'class' => \Chill\PersonBundle\Entity\Household\Household::class,
|
||||||
'controller' => \Chill\PersonBundle\Controller\HouseholdApiController::class,
|
|
||||||
'name' => 'household',
|
'name' => 'household',
|
||||||
'base_path' => '/api/1.0/person/household',
|
'base_path' => '/api/1.0/person/household',
|
||||||
'base_role' => 'ROLE_USER',
|
|
||||||
'actions' => [
|
|
||||||
'_index' => [
|
|
||||||
'methods' => [
|
|
||||||
Request::METHOD_GET => true,
|
|
||||||
Request::METHOD_HEAD => true,
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'_entity' => [
|
|
||||||
'methods' => [
|
|
||||||
Request::METHOD_GET => true,
|
|
||||||
Request::METHOD_HEAD => true,
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'address' => [
|
|
||||||
'methods' => [
|
|
||||||
Request::METHOD_POST => true,
|
|
||||||
Request::METHOD_DELETE => true,
|
|
||||||
Request::METHOD_GET => false,
|
|
||||||
Request::METHOD_HEAD => false,
|
|
||||||
],
|
|
||||||
'controller_action' => 'householdAddressApi'
|
|
||||||
],
|
|
||||||
'suggestHouseholdByAccompanyingPeriodParticipation' => [
|
|
||||||
'path' => '/suggest/by-person/{person_id}/through-accompanying-period-participation.{_format}',
|
|
||||||
'methods' => [
|
|
||||||
Request::METHOD_GET => true,
|
|
||||||
Request::METHOD_HEAD => true,
|
|
||||||
]
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'class' => \Chill\PersonBundle\Entity\SocialWork\SocialAction::class,
|
|
||||||
'name' => 'social_action',
|
|
||||||
'base_path' => '/api/1.0/person/social/social-action',
|
|
||||||
'controller' => \Chill\PersonBundle\Controller\SocialWorkSocialActionApiController::class,
|
|
||||||
// TODO: acl
|
// TODO: acl
|
||||||
'base_role' => 'ROLE_USER',
|
'base_role' => 'ROLE_USER',
|
||||||
'actions' => [
|
'actions' => [
|
||||||
@@ -592,150 +531,6 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
|||||||
Request::METHOD_HEAD => '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',
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'listBySocialIssue' => [
|
|
||||||
'single-collection' => 'collection',
|
|
||||||
'path' => '/by-social-issue/{id}.{_format}',
|
|
||||||
'methods' => [
|
|
||||||
Request::METHOD_GET => true,
|
|
||||||
Request::METHOD_HEAD => true,
|
|
||||||
],
|
|
||||||
'roles' => [
|
|
||||||
Request::METHOD_GET => 'ROLE_USER',
|
|
||||||
Request::METHOD_HEAD => 'ROLE_USER',
|
|
||||||
]
|
|
||||||
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'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',
|
|
||||||
]
|
|
||||||
],
|
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
|
@@ -78,7 +78,6 @@ class Configuration implements ConfigurationInterface
|
|||||||
->append($this->addFieldNode('address'))
|
->append($this->addFieldNode('address'))
|
||||||
->append($this->addFieldNode('accompanying_period'))
|
->append($this->addFieldNode('accompanying_period'))
|
||||||
->append($this->addFieldNode('memo'))
|
->append($this->addFieldNode('memo'))
|
||||||
->append($this->addFieldNode('number_of_children'))
|
|
||||||
->arrayNode('alt_names')
|
->arrayNode('alt_names')
|
||||||
->defaultValue([])
|
->defaultValue([])
|
||||||
->arrayPrototype()
|
->arrayPrototype()
|
||||||
@@ -131,7 +130,7 @@ class Configuration implements ConfigurationInterface
|
|||||||
{
|
{
|
||||||
$tree = new TreeBuilder($key,'enum');
|
$tree = new TreeBuilder($key,'enum');
|
||||||
$node = $tree->getRootNode($key);
|
$node = $tree->getRootNode($key);
|
||||||
|
|
||||||
switch($key) {
|
switch($key) {
|
||||||
case 'accompanying_period':
|
case 'accompanying_period':
|
||||||
$info = "If the accompanying periods are shown";
|
$info = "If the accompanying periods are shown";
|
||||||
|
@@ -25,7 +25,6 @@ namespace Chill\PersonBundle\Entity;
|
|||||||
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
||||||
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
||||||
use Chill\MainBundle\Entity\Scope;
|
use Chill\MainBundle\Entity\Scope;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\Origin;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\Origin;
|
||||||
@@ -40,7 +39,6 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
|||||||
use Chill\MainBundle\Entity\User;
|
use Chill\MainBundle\Entity\User;
|
||||||
use Symfony\Component\Serializer\Annotation\Groups;
|
use Symfony\Component\Serializer\Annotation\Groups;
|
||||||
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||||
use Symfony\Component\Validator\Constraints as Assert;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AccompanyingPeriod Class
|
* AccompanyingPeriod Class
|
||||||
@@ -282,15 +280,6 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
*/
|
*/
|
||||||
private \DateTimeInterface $updatedAt;
|
private \DateTimeInterface $updatedAt;
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\OneToMany(
|
|
||||||
* targetEntity=AccompanyingPeriodWork::class,
|
|
||||||
* mappedBy="accompanyingPeriod"
|
|
||||||
* )
|
|
||||||
* @Assert\Valid(traverse=true)
|
|
||||||
*/
|
|
||||||
private Collection $works;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AccompanyingPeriod constructor.
|
* AccompanyingPeriod constructor.
|
||||||
*
|
*
|
||||||
@@ -303,7 +292,6 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
$this->scopes = new ArrayCollection();
|
$this->scopes = new ArrayCollection();
|
||||||
$this->socialIssues = new ArrayCollection();
|
$this->socialIssues = new ArrayCollection();
|
||||||
$this->comments = new ArrayCollection();
|
$this->comments = new ArrayCollection();
|
||||||
$this->works = new ArrayCollection();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -848,6 +836,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $recursiveSocialIssues;
|
return $recursiveSocialIssues;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -907,28 +896,4 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return AccompanyingPeriodWork[]
|
|
||||||
*/
|
|
||||||
public function getWorks(): Collection
|
|
||||||
{
|
|
||||||
return $this->works;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addWork(AccompanyingPeriodWork $work): self
|
|
||||||
{
|
|
||||||
$this->works[] = $work;
|
|
||||||
$work->setAccompanyingPeriod($this);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeWork(AccompanyingPeriodWork $work): self
|
|
||||||
{
|
|
||||||
$this->work->removeElement($work);
|
|
||||||
$work->setAccompanyingPeriod(null);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -4,168 +4,103 @@ namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
|
|||||||
|
|
||||||
use Chill\PersonBundle\Entity\SocialWork\Result;
|
use Chill\PersonBundle\Entity\SocialWork\Result;
|
||||||
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
|
||||||
use Chill\MainBundle\Entity\User;
|
use Chill\MainBundle\Entity\User;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||||
use DateTimeInterface;
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
|
||||||
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
|
||||||
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
|
||||||
use Symfony\Component\Validator\Constraints as Assert;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Entity
|
* @ORM\Entity
|
||||||
* @ORM\Table(name="chill_person_accompanying_period_work")
|
* @ORM\Table(name="chill_person_accompanying_period_work")
|
||||||
* @Serializer\DiscriminatorMap(
|
|
||||||
* typeProperty="type",
|
|
||||||
* mapping={
|
|
||||||
* "accompanying_period_work":AccompanyingPeriodWork::class
|
|
||||||
* }
|
|
||||||
* )
|
|
||||||
*/
|
*/
|
||||||
class AccompanyingPeriodWork implements TrackCreationInterface, TrackUpdateInterface
|
class AccompanyingPeriodWork
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @ORM\Id
|
* @ORM\Id
|
||||||
* @ORM\GeneratedValue
|
* @ORM\GeneratedValue
|
||||||
* @ORM\Column(type="integer")
|
* @ORM\Column(type="integer")
|
||||||
* @Serializer\Groups({"read"})
|
|
||||||
*/
|
*/
|
||||||
private ?int $id;
|
private $id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="text")
|
* @ORM\Column(type="text")
|
||||||
* @Serializer\Groups({"read", "accompanying_period_work:edit"})
|
|
||||||
*/
|
*/
|
||||||
private string $note = "";
|
private $note;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class)
|
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class)
|
||||||
* @Serializer\Groups({"read"})
|
|
||||||
*/
|
*/
|
||||||
private ?AccompanyingPeriod $accompanyingPeriod = null;
|
private $accompanyingPeriod;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity=SocialAction::class)
|
* @ORM\ManyToOne(targetEntity=SocialAction::class)
|
||||||
* @Serializer\Groups({"read"})
|
|
||||||
* @Serializer\Groups({"accompanying_period_work:create"})
|
|
||||||
*/
|
*/
|
||||||
private ?SocialAction $socialAction = null;
|
private $socialAction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="datetime_immutable")
|
* @ORM\Column(type="datetime")
|
||||||
* @Serializer\Groups({"read"})
|
|
||||||
*/
|
*/
|
||||||
private ?\DateTimeImmutable $createdAt = null;
|
private $createdAt;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity=User::class)
|
* @ORM\ManyToOne(targetEntity=User::class)
|
||||||
* @ORM\JoinColumn(nullable=false)
|
* @ORM\JoinColumn(nullable=false)
|
||||||
* @Serializer\Groups({"read"})
|
|
||||||
*/
|
*/
|
||||||
private ?User $createdBy = null;
|
private $createdBy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="datetime_immutable")
|
* @ORM\Column(type="datetime")
|
||||||
* @Serializer\Groups({"read"})
|
|
||||||
*/
|
*/
|
||||||
private ?\DateTimeImmutable $updatedAt = null;
|
private $startDate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity=User::class)
|
* @ORM\Column(type="datetime")
|
||||||
* @ORM\JoinColumn(nullable=false)
|
|
||||||
* @Serializer\Groups({"read"})
|
|
||||||
*/
|
*/
|
||||||
private ?User $updatedBy = null;
|
private $endDate;
|
||||||
|
|
||||||
/**
|
|
||||||
* @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"})
|
|
||||||
* @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"
|
|
||||||
* )
|
|
||||||
*/
|
|
||||||
private ?\DateTimeImmutable $endDate = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity=ThirdParty::class)
|
* @ORM\ManyToOne(targetEntity=ThirdParty::class)
|
||||||
* @Serializer\Groups({"read"})
|
|
||||||
* @Serializer\Groups({"accompanying_period_work:edit"})
|
|
||||||
*
|
*
|
||||||
* In schema : traitant
|
* In schema : traitant
|
||||||
*/
|
*/
|
||||||
private ?ThirdParty $handlingThierParty = null;
|
private $handlingThierParty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="boolean")
|
* @ORM\Column(type="boolean")
|
||||||
*/
|
*/
|
||||||
private bool $createdAutomatically = false;
|
private $createdAutomatically;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="text")
|
* @ORM\Column(type="text")
|
||||||
*/
|
*/
|
||||||
private string $createdAutomaticallyReason = "";
|
private $createdAutomaticallyReason;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\OneToMany(
|
* @ORM\OneToMany(targetEntity=AccompanyingPeriodWorkGoal::class, mappedBy="accompanyingPeriodWork")
|
||||||
* targetEntity=AccompanyingPeriodWorkGoal::class,
|
|
||||||
* mappedBy="accompanyingPeriodWork",
|
|
||||||
* cascade={"persist"},
|
|
||||||
* orphanRemoval=true
|
|
||||||
* )
|
|
||||||
* @Serializer\Groups({"read"})
|
|
||||||
* @Serializer\Groups({"accompanying_period_work:edit"})
|
|
||||||
*/
|
*/
|
||||||
private Collection $goals;
|
private $goals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToMany(targetEntity=Result::class, inversedBy="accompanyingPeriodWorks")
|
* @ORM\ManyToMany(targetEntity=Result::class, inversedBy="accompanyingPeriodWorks")
|
||||||
* @ORM\JoinTable(name="chill_person_accompanying_period_work_result")
|
* @ORM\JoinTable(name="chill_person_accompanying_period_work_result")
|
||||||
* @Serializer\Groups({"read"})
|
|
||||||
* @Serializer\Groups({"accompanying_period_work:edit"})
|
|
||||||
*/
|
*/
|
||||||
private Collection $results;
|
private $results;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToMany(targetEntity=ThirdParty::class)
|
* @ORM\ManyToMany(targetEntity=ThirdParty::class)
|
||||||
* @ORM\JoinTable(name="chill_person_accompanying_period_work_third_party")
|
* @ORM\JoinTable(name="chill_person_accompanying_period_work_third_party")
|
||||||
*
|
*
|
||||||
* In schema : intervenants
|
* In schema : intervenants
|
||||||
* @Serializer\Groups({"read"})
|
|
||||||
* @Serializer\Groups({"accompanying_period_work:edit"})
|
|
||||||
*/
|
*/
|
||||||
private Collection $thirdParties;
|
private $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()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->goals = new ArrayCollection();
|
$this->goals = new ArrayCollection();
|
||||||
$this->results = new ArrayCollection();
|
$this->results = new ArrayCollection();
|
||||||
$this->thirdParties = new ArrayCollection();
|
$this->thirdParties = new ArrayCollection();
|
||||||
$this->persons = new ArrayCollection();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getId(): ?int
|
public function getId(): ?int
|
||||||
@@ -190,17 +125,8 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||||||
return $this->accompanyingPeriod;
|
return $this->accompanyingPeriod;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Internal: you should use `$accompanyingPeriod->removeWork($work);` or
|
|
||||||
* `$accompanyingPeriod->addWork($work);`
|
|
||||||
*/
|
|
||||||
public function setAccompanyingPeriod(?AccompanyingPeriod $accompanyingPeriod): self
|
public function setAccompanyingPeriod(?AccompanyingPeriod $accompanyingPeriod): self
|
||||||
{
|
{
|
||||||
if ($this->accompanyingPeriod instanceof AccompanyingPeriod &&
|
|
||||||
$accompanyingPeriod !== $this->accompanyingPeriod) {
|
|
||||||
throw new \LogicException("A work cannot change accompanyingPeriod");
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->accompanyingPeriod = $accompanyingPeriod;
|
$this->accompanyingPeriod = $accompanyingPeriod;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@@ -218,7 +144,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCreatedAt(): ?\DateTimeImmutable
|
public function getCreatedAt(): ?\DateTimeInterface
|
||||||
{
|
{
|
||||||
return $this->createdAt;
|
return $this->createdAt;
|
||||||
}
|
}
|
||||||
@@ -242,30 +168,6 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setUpdatedBy(User $user): TrackUpdateInterface
|
|
||||||
{
|
|
||||||
$this->updatedBy = $user;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setUpdatedAt(DateTimeInterface $datetime): TrackUpdateInterface
|
|
||||||
{
|
|
||||||
$this->updatedAt = $datetime;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getUpdatedAt(): ?\DateTimeImmutable
|
|
||||||
{
|
|
||||||
return $this->updatedAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getUpdatedBy(): ?User
|
|
||||||
{
|
|
||||||
return $this->updatedBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getStartDate(): ?\DateTimeInterface
|
public function getStartDate(): ?\DateTimeInterface
|
||||||
{
|
{
|
||||||
return $this->startDate;
|
return $this->startDate;
|
||||||
@@ -283,7 +185,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||||||
return $this->endDate;
|
return $this->endDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setEndDate(?\DateTimeInterface $endDate = null): self
|
public function setEndDate(\DateTimeInterface $endDate): self
|
||||||
{
|
{
|
||||||
$this->endDate = $endDate;
|
$this->endDate = $endDate;
|
||||||
|
|
||||||
@@ -338,7 +240,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||||||
{
|
{
|
||||||
if (!$this->goals->contains($goal)) {
|
if (!$this->goals->contains($goal)) {
|
||||||
$this->goals[] = $goal;
|
$this->goals[] = $goal;
|
||||||
$goal->setAccompanyingPeriodWork($this);
|
$goal->setAccompanyingPeriodWork2($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@@ -346,10 +248,10 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||||||
|
|
||||||
public function removeGoal(AccompanyingPeriodWorkGoal $goal): self
|
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)
|
// set the owning side to null (unless already changed)
|
||||||
if ($goal->getAccompanyingPeriodWork() === $this) {
|
if ($goal->getAccompanyingPeriodWork2() === $this) {
|
||||||
$goal->setAccompanyingPeriodWork(null);
|
$goal->setAccompanyingPeriodWork2(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -403,25 +305,4 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||||||
|
|
||||||
return $this;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -7,17 +7,10 @@ use Chill\PersonBundle\Entity\SocialWork\Result;
|
|||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Entity
|
* @ORM\Entity
|
||||||
* @ORM\Table(name="chill_person_accompanying_period_work_goal")
|
* @ORM\Table(name="chill_person_accompanying_period_work_goal")
|
||||||
* @Serializer\DiscriminatorMap(
|
|
||||||
* typeProperty="type",
|
|
||||||
* mapping={
|
|
||||||
* "accompanying_period_work_goal":AccompanyingPeriodWorkGoal::class
|
|
||||||
* }
|
|
||||||
* )
|
|
||||||
*/
|
*/
|
||||||
class AccompanyingPeriodWorkGoal
|
class AccompanyingPeriodWorkGoal
|
||||||
{
|
{
|
||||||
@@ -25,14 +18,11 @@ class AccompanyingPeriodWorkGoal
|
|||||||
* @ORM\Id
|
* @ORM\Id
|
||||||
* @ORM\GeneratedValue
|
* @ORM\GeneratedValue
|
||||||
* @ORM\Column(type="integer")
|
* @ORM\Column(type="integer")
|
||||||
* @Serializer\Groups({"read"})
|
|
||||||
*/
|
*/
|
||||||
private $id;
|
private $id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="text")
|
* @ORM\Column(type="text")
|
||||||
* @Serializer\Groups({"accompanying_period_work:edit"})
|
|
||||||
* @Serializer\Groups({"read"})
|
|
||||||
*/
|
*/
|
||||||
private $note;
|
private $note;
|
||||||
|
|
||||||
@@ -43,16 +33,12 @@ class AccompanyingPeriodWorkGoal
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity=Goal::class)
|
* @ORM\ManyToOne(targetEntity=Goal::class)
|
||||||
* @Serializer\Groups({"accompanying_period_work:edit"})
|
|
||||||
* @Serializer\Groups({"read"})
|
|
||||||
*/
|
*/
|
||||||
private $goal;
|
private $goal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToMany(targetEntity=Result::class, inversedBy="accompanyingPeriodWorkGoals")
|
* @ORM\ManyToMany(targetEntity=Result::class, inversedBy="accompanyingPeriodWorkGoals")
|
||||||
* @ORM\JoinTable(name="chill_person_accompanying_period_work_goal_result")
|
* @ORM\JoinTable(name="chill_person_accompanying_period_work_goal_result")
|
||||||
* @Serializer\Groups({"accompanying_period_work:edit"})
|
|
||||||
* @Serializer\Groups({"read"})
|
|
||||||
*/
|
*/
|
||||||
private $results;
|
private $results;
|
||||||
|
|
||||||
@@ -85,13 +71,6 @@ class AccompanyingPeriodWorkGoal
|
|||||||
|
|
||||||
public function setAccompanyingPeriodWork(?AccompanyingPeriodWork $accompanyingPeriodWork): self
|
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;
|
$this->accompanyingPeriodWork = $accompanyingPeriodWork;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@@ -7,12 +7,8 @@ use Doctrine\ORM\Mapping as ORM;
|
|||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\Common\Collections\Criteria;
|
use Doctrine\Common\Collections\Criteria;
|
||||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||||
use Symfony\Component\Validator\Constraints as Assert;
|
|
||||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
|
||||||
use Chill\MainBundle\Entity\Address;
|
use Chill\MainBundle\Entity\Address;
|
||||||
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
||||||
use Chill\PersonBundle\Validator\Constraints\Household\MaxHolder;
|
|
||||||
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Entity
|
* @ORM\Entity
|
||||||
@@ -22,7 +18,6 @@ use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
|
|||||||
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
|
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
|
||||||
* "household"=Household::class
|
* "household"=Household::class
|
||||||
* })
|
* })
|
||||||
* @MaxHolder(groups={"household_memberships"})
|
|
||||||
*/
|
*/
|
||||||
class Household
|
class Household
|
||||||
{
|
{
|
||||||
@@ -42,7 +37,6 @@ class Household
|
|||||||
* cascade={"persist", "remove", "merge", "detach"})
|
* cascade={"persist", "remove", "merge", "detach"})
|
||||||
* @ORM\JoinTable(name="chill_person_household_to_addresses")
|
* @ORM\JoinTable(name="chill_person_household_to_addresses")
|
||||||
* @ORM\OrderBy({"validFrom" = "DESC"})
|
* @ORM\OrderBy({"validFrom" = "DESC"})
|
||||||
* @Serializer\Groups({"write"})
|
|
||||||
*/
|
*/
|
||||||
private Collection $addresses;
|
private Collection $addresses;
|
||||||
|
|
||||||
@@ -55,26 +49,10 @@ class Household
|
|||||||
*/
|
*/
|
||||||
private Collection $members;
|
private Collection $members;
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Embedded(class=CommentEmbeddable::class, columnPrefix="comment_members_")
|
|
||||||
*/
|
|
||||||
private CommentEmbeddable $commentMembers;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="boolean", name="waiting_for_birth", options={"default": false})
|
|
||||||
*/
|
|
||||||
private bool $waitingForBirth = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="date_immutable", name="waiting_for_birth_date", nullable=true, options={"default": null})
|
|
||||||
*/
|
|
||||||
private ?\DateTimeImmutable $waitingForBirthDate = null;
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->addresses = new ArrayCollection();
|
$this->addresses = new ArrayCollection();
|
||||||
$this->members = new ArrayCollection();
|
$this->members = new ArrayCollection();
|
||||||
$this->commentMembers = new CommentEmbeddable();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getId(): ?int
|
public function getId(): ?int
|
||||||
@@ -88,12 +66,6 @@ class Household
|
|||||||
*/
|
*/
|
||||||
public function addAddress(Address $address)
|
public function addAddress(Address $address)
|
||||||
{
|
{
|
||||||
foreach ($this->getAddresses() as $a) {
|
|
||||||
if ($a->getValidFrom() < $address->getValidFrom() && $a->getValidTo() === NULL) {
|
|
||||||
$a->setValidTo($address->getValidFrom());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->addresses[] = $address;
|
$this->addresses[] = $address;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@@ -111,7 +83,6 @@ class Household
|
|||||||
* By default, the addresses are ordered by date, descending (the most
|
* By default, the addresses are ordered by date, descending (the most
|
||||||
* recent first)
|
* recent first)
|
||||||
*
|
*
|
||||||
* @Assert\Callback(methods={"validate"})
|
|
||||||
* @return \Chill\MainBundle\Entity\Address[]
|
* @return \Chill\MainBundle\Entity\Address[]
|
||||||
*/
|
*/
|
||||||
public function getAddresses()
|
public function getAddresses()
|
||||||
@@ -119,27 +90,6 @@ class Household
|
|||||||
return $this->addresses;
|
return $this->addresses;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @Serializer\Groups({ "read" })
|
|
||||||
* @Serializer\SerializedName("current_address")
|
|
||||||
*/
|
|
||||||
public function getCurrentAddress(\DateTime $at = null): ?Address
|
|
||||||
{
|
|
||||||
$at = $at === null ? new \DateTime('today') : $at;
|
|
||||||
|
|
||||||
$addrs = $this->getAddresses()->filter(function (Address $a) use ($at) {
|
|
||||||
return $a->getValidFrom() < $at && (
|
|
||||||
NULL === $a->getValidTo() || $at < $a->getValidTo()
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
if ($addrs->count() > 0) {
|
|
||||||
return $addrs->first();
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Collection|HouseholdMember[]
|
* @return Collection|HouseholdMember[]
|
||||||
*/
|
*/
|
||||||
@@ -148,59 +98,7 @@ class Household
|
|||||||
return $this->members;
|
return $this->members;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMembersOnRange(\DateTimeImmutable $from, ?\DateTimeImmutable $to): Collection
|
|
||||||
{
|
|
||||||
$criteria = new Criteria();
|
|
||||||
$expr = Criteria::expr();
|
|
||||||
|
|
||||||
$criteria->where(
|
|
||||||
$expr->gte('startDate', $from)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (NULL !== $to) {
|
|
||||||
$criteria->andWhere(
|
|
||||||
$expr->orX(
|
|
||||||
$expr->lte('endDate', $to),
|
|
||||||
$expr->eq('endDate', NULL)
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->getMembers()
|
|
||||||
->matching($criteria)
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getMembersDuringMembership(HouseholdMember $membership)
|
|
||||||
{
|
|
||||||
return $this->getMembersOnRange(
|
|
||||||
$membership->getStartDate(),
|
|
||||||
$membership->getEndDate()
|
|
||||||
)->filter(
|
|
||||||
function(HouseholdMember $m) use ($membership) {
|
|
||||||
return $m !== $membership;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getMembersHolder(): Collection
|
|
||||||
{
|
|
||||||
$criteria = new Criteria();
|
|
||||||
$expr = Criteria::expr();
|
|
||||||
|
|
||||||
$criteria->where(
|
|
||||||
$expr->eq('holder', true)
|
|
||||||
);
|
|
||||||
|
|
||||||
return $this->getMembers()->matching($criteria);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCurrentMembers(?\DateTimeImmutable $now = null): Collection
|
public function getCurrentMembers(?\DateTimeImmutable $now = null): Collection
|
||||||
{
|
|
||||||
return $this->getMembers()->matching($this->buildCriteriaCurrentMembers($now));
|
|
||||||
}
|
|
||||||
|
|
||||||
private function buildCriteriaCurrentMembers(?\DateTimeImmutable $now = null): Criteria
|
|
||||||
{
|
{
|
||||||
$criteria = new Criteria();
|
$criteria = new Criteria();
|
||||||
$expr = Criteria::expr();
|
$expr = Criteria::expr();
|
||||||
@@ -216,53 +114,7 @@ class Household
|
|||||||
$expr->gte('endDate', $date)
|
$expr->gte('endDate', $date)
|
||||||
));
|
));
|
||||||
|
|
||||||
return $criteria;
|
return $this->getMembers()->matching($criteria);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return HouseholdMember[]
|
|
||||||
*/
|
|
||||||
public function getCurrentMembersOrdered(?\DateTimeImmutable $now = null): Collection
|
|
||||||
{
|
|
||||||
$members = $this->getCurrentMembers($now);
|
|
||||||
|
|
||||||
$members->getIterator()
|
|
||||||
->uasort(
|
|
||||||
function (HouseholdMember $a, HouseholdMember $b) {
|
|
||||||
if ($a->getPosition()->getOrdering() < $b->getPosition()->getOrdering()) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if ($a->getPosition()->getOrdering() > $b->getPosition()->getOrdering()) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if ($a->isHolder() && !$b->isHolder()) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (!$a->isHolder() && $b->isHolder()) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
return $members;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get current members ids
|
|
||||||
*
|
|
||||||
* Used in serialization
|
|
||||||
*
|
|
||||||
* @Serializer\Groups({"read"})
|
|
||||||
* @Serializer\SerializedName("current_members_id")
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function getCurrentMembersIds(?\DateTimeImmutable $now = null): Collection
|
|
||||||
{
|
|
||||||
return $this->getCurrentMembers($now)->map(
|
|
||||||
fn (HouseholdMember $m) => $m->getId()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -340,54 +192,4 @@ class Household
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCommentMembers(): CommentEmbeddable
|
|
||||||
{
|
|
||||||
return $this->commentMembers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setCommentMembers(CommentEmbeddable $commentMembers): self
|
|
||||||
{
|
|
||||||
$this->commentMembers = $commentMembers;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getWaitingForBirth(): bool
|
|
||||||
{
|
|
||||||
return $this->waitingForBirth;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setWaitingForBirth(bool $waitingForBirth): self
|
|
||||||
{
|
|
||||||
$this->waitingForBirth = $waitingForBirth;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getWaitingForBirthDate(): ?\DateTimeImmutable
|
|
||||||
{
|
|
||||||
return $this->waitingForBirthDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setWaitingForBirthDate(?\DateTimeImmutable $waitingForBirthDate): self
|
|
||||||
{
|
|
||||||
$this->waitingForBirthDate = $waitingForBirthDate;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function validate(ExecutionContextInterface $context, $payload)
|
|
||||||
{
|
|
||||||
$addresses = $this->getAddresses();
|
|
||||||
$cond = True;
|
|
||||||
for ($i=0; $i < count($addresses) - 1; $i++) {
|
|
||||||
if ($addresses[$i]->getValidFrom() != $addresses[$i + 1]->getValidTo()) {
|
|
||||||
$cond = False;
|
|
||||||
$context->buildViolation('The address are not sequentials. The validFrom date of one address should be equal to the validTo date of the previous address.')
|
|
||||||
->atPath('addresses')
|
|
||||||
->addViolation();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dump($cond);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -7,7 +7,6 @@ use Chill\PersonBundle\Entity\Person;
|
|||||||
use Chill\PersonBundle\Entity\Household\Household;
|
use Chill\PersonBundle\Entity\Household\Household;
|
||||||
use Chill\PersonBundle\Entity\Household\Position;
|
use Chill\PersonBundle\Entity\Household\Position;
|
||||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||||
use Symfony\Component\Validator\Constraints as Assert;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,25 +28,18 @@ class HouseholdMember
|
|||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity=Position::class)
|
* @ORM\ManyToOne(targetEntity=Position::class)
|
||||||
* @Serializer\Groups({"read"})
|
* @Serializer\Groups({"read"})
|
||||||
* @Assert\NotNull(groups={"household_memberships"})
|
|
||||||
*/
|
*/
|
||||||
private ?Position $position = null;
|
private ?Position $position = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||||
* @Serializer\Groups({"read"})
|
* @Serializer\Groups({"read"})
|
||||||
* @Assert\NotNull(groups={"household_memberships"})
|
|
||||||
*/
|
*/
|
||||||
private ?\DateTimeImmutable $startDate = null;
|
private ?\DateTimeImmutable $startDate = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="date_immutable", nullable= true, options={"default": null})
|
* @ORM\Column(type="date_immutable", nullable= true, options={"default": null})
|
||||||
* @Serializer\Groups({"read"})
|
* @Serializer\Groups({"read"})
|
||||||
* @Assert\GreaterThan(
|
|
||||||
* propertyPath="startDate",
|
|
||||||
* message="household_membership.The end date must be after start date",
|
|
||||||
* groups={"household_memberships"}
|
|
||||||
* )
|
|
||||||
*/
|
*/
|
||||||
private ?\DateTimeImmutable $endDate = null;
|
private ?\DateTimeImmutable $endDate = null;
|
||||||
|
|
||||||
@@ -75,8 +67,6 @@ class HouseholdMember
|
|||||||
* targetEntity="\Chill\PersonBundle\Entity\Person"
|
* targetEntity="\Chill\PersonBundle\Entity\Person"
|
||||||
* )
|
* )
|
||||||
* @Serializer\Groups({"read"})
|
* @Serializer\Groups({"read"})
|
||||||
* @Assert\Valid(groups={"household_memberships"})
|
|
||||||
* @Assert\NotNull(groups={"household_memberships"})
|
|
||||||
*/
|
*/
|
||||||
private ?Person $person = null;
|
private ?Person $person = null;
|
||||||
|
|
||||||
@@ -86,8 +76,6 @@ class HouseholdMember
|
|||||||
* @ORM\ManyToOne(
|
* @ORM\ManyToOne(
|
||||||
* targetEntity="\Chill\PersonBundle\Entity\Household\Household"
|
* targetEntity="\Chill\PersonBundle\Entity\Household\Household"
|
||||||
* )
|
* )
|
||||||
* @Assert\Valid(groups={"household_memberships"})
|
|
||||||
* @Assert\NotNull(groups={"household_memberships"})
|
|
||||||
*/
|
*/
|
||||||
private ?Household $household = null;
|
private ?Household $household = null;
|
||||||
|
|
||||||
@@ -206,13 +194,4 @@ class HouseholdMember
|
|||||||
{
|
{
|
||||||
return $this->holder;
|
return $this->holder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isCurrent(\DateTimeImmutable $at = null): bool
|
|
||||||
{
|
|
||||||
$at = NULL === $at ? new \DateTimeImmutable('now'): $at;
|
|
||||||
|
|
||||||
return $this->getStartDate() < $at && (
|
|
||||||
NULL === $this->getEndDate() || $at < $this->getEndDate()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -1,72 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Entity\Household;
|
|
||||||
|
|
||||||
use Chill\MainBundle\Entity\Address;
|
|
||||||
use Chill\PersonBundle\Entity\Household\Household;
|
|
||||||
use Chill\PersonBundle\Entity\Person;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Entity(readOnly=true)
|
|
||||||
* @ORM\Table(name="view_chill_person_household_address")
|
|
||||||
*/
|
|
||||||
class PersonHouseholdAddress
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="date_immutable")
|
|
||||||
*/
|
|
||||||
private $validFrom;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="date_immutable", nullable=true)
|
|
||||||
*/
|
|
||||||
private $validTo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Id
|
|
||||||
* @ORM\ManyToOne(targetEntity=Person::class)
|
|
||||||
* @ORM\JoinColumn(nullable=false)
|
|
||||||
*/
|
|
||||||
private $person;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Id
|
|
||||||
* @ORM\ManyToOne(targetEntity=Household::class)
|
|
||||||
* @ORM\JoinColumn(nullable=false)
|
|
||||||
*/
|
|
||||||
private $household;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Id
|
|
||||||
* @ORM\ManyToOne(targetEntity=Address::class)
|
|
||||||
* @ORM\JoinColumn(nullable=false)
|
|
||||||
*/
|
|
||||||
private $address;
|
|
||||||
|
|
||||||
public function getValidFrom(): ?\DateTimeInterface
|
|
||||||
{
|
|
||||||
return $this->validFrom;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getValidTo(): ?\DateTimeImmutable
|
|
||||||
{
|
|
||||||
return $this->validTo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPerson(): ?Person
|
|
||||||
{
|
|
||||||
return $this->person;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getHousehold(): ?Household
|
|
||||||
{
|
|
||||||
return $this->relation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAddress(): ?Address
|
|
||||||
{
|
|
||||||
return $this->address;
|
|
||||||
}
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user