mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-29 01:55:01 +00:00
Compare commits
6 Commits
features/p
...
notificati
Author | SHA1 | Date | |
---|---|---|---|
|
1de370bab1 | ||
|
559d3dd756 | ||
|
4fd733dca7 | ||
|
1ecb0a1dbe | ||
|
6ea5a3088c | ||
|
e50bfd5129 |
@@ -22,6 +22,7 @@ class LoadActivityNotifications extends AbstractFixture implements DependentFixt
|
|||||||
'entityRef' => 'activity_gerard depardieu',
|
'entityRef' => 'activity_gerard depardieu',
|
||||||
'sender' => 'center a_social',
|
'sender' => 'center a_social',
|
||||||
'addressees' => [
|
'addressees' => [
|
||||||
|
'center a_social',
|
||||||
'center a_administrative',
|
'center a_administrative',
|
||||||
'center a_direction',
|
'center a_direction',
|
||||||
'multi_center'
|
'multi_center'
|
||||||
|
@@ -55,6 +55,7 @@ class ChillActivityExtension extends Extension implements PrependExtensionInterf
|
|||||||
$loader->load('services/controller.yaml');
|
$loader->load('services/controller.yaml');
|
||||||
$loader->load('services/form.yaml');
|
$loader->load('services/form.yaml');
|
||||||
$loader->load('services/templating.yaml');
|
$loader->load('services/templating.yaml');
|
||||||
|
$loader->load('services/notification.yaml');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function prepend(ContainerBuilder $container)
|
public function prepend(ContainerBuilder $container)
|
||||||
|
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Notification;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Entity\Notification;
|
||||||
|
use Chill\ActivityBundle\Entity\Activity;
|
||||||
|
|
||||||
|
final class ActivityNotificationRenderer
|
||||||
|
{
|
||||||
|
public function supports(Notification $notification, array $options = []): bool
|
||||||
|
{
|
||||||
|
return $notification->getRelatedEntityClass() == Activity::class;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTemplate()
|
||||||
|
{
|
||||||
|
return '@ChillActivity/Activity/showInNotification.html.twig';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTemplateData(Notification $notification)
|
||||||
|
{
|
||||||
|
return ['notification' => $notification];
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
{{ dump(notification) }}
|
||||||
|
|
||||||
|
<a href="{{ path('chill_activity_activity_show', {'id': notification.relatedEntityId }) }}">Go to Activity</a>
|
@@ -0,0 +1,4 @@
|
|||||||
|
services:
|
||||||
|
Chill\ActivityBundle\Notification\ActivityNotificationRenderer:
|
||||||
|
autoconfigure: true
|
||||||
|
autowire: true
|
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -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}';
|
||||||
|
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\MainBundle\Controller;
|
||||||
|
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Chill\MainBundle\Repository\NotificationRepository;
|
||||||
|
use Chill\MainBundle\Notification\NotificationRenderer;
|
||||||
|
use Symfony\Component\Security\Core\Security;
|
||||||
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Route("/{_locale}/notification")
|
||||||
|
*/
|
||||||
|
class NotificationController extends AbstractController
|
||||||
|
{
|
||||||
|
private $security;
|
||||||
|
|
||||||
|
public function __construct(Security $security)
|
||||||
|
{
|
||||||
|
$this->security = $security;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Route("/show", name="chill_main_notification_show")
|
||||||
|
*/
|
||||||
|
public function showAction(
|
||||||
|
NotificationRepository $notificationRepository, NotificationRenderer $notificationRenderer,
|
||||||
|
PaginatorFactory $paginatorFactory)
|
||||||
|
{
|
||||||
|
$currentUser = $this->security->getUser();
|
||||||
|
|
||||||
|
$notificationsNbr = $notificationRepository->countAllForAttendee(($currentUser));
|
||||||
|
$paginator = $paginatorFactory->create($notificationsNbr);
|
||||||
|
|
||||||
|
$notifications = $notificationRepository->findAllForAttendee(
|
||||||
|
$currentUser,
|
||||||
|
$limit=$paginator->getItemsPerPage(),
|
||||||
|
$offset= $paginator->getCurrentPage()->getFirstItemNumber());
|
||||||
|
|
||||||
|
$templateData = array();
|
||||||
|
foreach ($notifications as $notification) {
|
||||||
|
$data = [
|
||||||
|
'template' => $notificationRenderer->getTemplate($notification),
|
||||||
|
'template_data' => $notificationRenderer->getTemplateData($notification),
|
||||||
|
'notification' => $notification
|
||||||
|
];
|
||||||
|
$templateData[] = $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render('@ChillMain/Notification/show.html.twig', [
|
||||||
|
'datas' => $templateData,
|
||||||
|
'notifications' => $notifications,
|
||||||
|
'paginator' => $paginator,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
@@ -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,
|
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
|
@@ -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,7 +127,7 @@ 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, ...
|
||||||
|
@@ -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
|
||||||
*
|
*
|
||||||
|
@@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\MainBundle\Notification;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Entity\Notification;
|
||||||
|
use Chill\PersonBundle\Notification\AccompanyingPeriodNotificationRenderer;
|
||||||
|
use Chill\ActivityBundle\Notification\ActivityNotificationRenderer;
|
||||||
|
|
||||||
|
final class NotificationRenderer
|
||||||
|
{
|
||||||
|
private array $renderers;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
AccompanyingPeriodNotificationRenderer $accompanyingPeriodNotificationRenderer,
|
||||||
|
ActivityNotificationRenderer $activityNotificationRenderer)
|
||||||
|
{
|
||||||
|
// TODO configure automatically
|
||||||
|
// TODO CREER UNE INTERFACE POUR ETRE SUR QUE LES RENDERERS SONT OK
|
||||||
|
|
||||||
|
$this->renderers[] = $accompanyingPeriodNotificationRenderer;
|
||||||
|
$this->renderers[] = $activityNotificationRenderer;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getRenderer(Notification $notification)
|
||||||
|
{
|
||||||
|
foreach ($this->renderers as $renderer) {
|
||||||
|
if($renderer->supports($notification)) {
|
||||||
|
return $renderer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \Exception('No renderer for '. $notification);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTemplate(Notification $notification)
|
||||||
|
{
|
||||||
|
return $this->getRenderer($notification)->getTemplate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTemplateData(Notification $notification)
|
||||||
|
{
|
||||||
|
return $this->getRenderer($notification)->getTemplateData($notification);
|
||||||
|
}
|
||||||
|
}
|
@@ -23,6 +23,8 @@ use Chill\MainBundle\Entity\Notification;
|
|||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
use Doctrine\Persistence\ObjectRepository;
|
use Doctrine\Persistence\ObjectRepository;
|
||||||
|
use Chill\MainBundle\Entity\User;
|
||||||
|
use Doctrine\ORM\Query;
|
||||||
|
|
||||||
final class NotificationRepository implements ObjectRepository
|
final class NotificationRepository implements ObjectRepository
|
||||||
{
|
{
|
||||||
@@ -59,8 +61,54 @@ final class NotificationRepository implements ObjectRepository
|
|||||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function queryAllForAttendee(User $addressee, bool $countQuery=False): Query
|
||||||
|
{
|
||||||
|
$qb = $this->repository->createQueryBuilder('n');
|
||||||
|
|
||||||
|
$select = 'n';
|
||||||
|
if($countQuery) {
|
||||||
|
$select = 'count(n)';
|
||||||
|
}
|
||||||
|
|
||||||
|
$qb
|
||||||
|
->select($select)
|
||||||
|
->join('n.addressees', 'a')
|
||||||
|
->where('a = :addressee')
|
||||||
|
->setParameter('addressee', $addressee);
|
||||||
|
|
||||||
|
return $qb->getQuery();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function countAllForAttendee(User $addressee): int // TODO passer à attendees avec S
|
||||||
|
{
|
||||||
|
$query = $this->queryAllForAttendee($addressee, $countQuery=True);
|
||||||
|
|
||||||
|
return $query->getSingleScalarResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Notification[]
|
||||||
|
*/
|
||||||
|
public function findAllForAttendee(User $addressee, $limit = null, $offset = null): array // TODO passer à attendees avec S
|
||||||
|
{
|
||||||
|
$query = $this->queryAllForAttendee($addressee);
|
||||||
|
|
||||||
|
if($limit) {
|
||||||
|
$query = $query->setMaxResults($limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($offset) {
|
||||||
|
$query = $query->setFirstResult($offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query->getResult();
|
||||||
|
}
|
||||||
|
|
||||||
public function getClassName() {
|
public function getClassName() {
|
||||||
return Notification::class;
|
return Notification::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,12 +36,10 @@ 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('-'),
|
||||||
|
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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 {
|
||||||
@@ -252,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 {
|
||||||
@@ -262,20 +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,73 +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>
|
|
||||||
|
|
||||||
<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;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -76,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,
|
||||||
@@ -89,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,32 +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'
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -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,8 +9,6 @@ const store = createStore({
|
|||||||
strict: debug,
|
strict: debug,
|
||||||
state: {
|
state: {
|
||||||
address: {},
|
address: {},
|
||||||
editAddress: {}, //TODO or should be address?
|
|
||||||
person: {},
|
|
||||||
errorMsg: []
|
errorMsg: []
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
@@ -22,119 +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;
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
addAddress({ commit }, payload) {
|
addAddress({ commit }, payload) {
|
||||||
console.log('@A addAddress payload', payload);
|
console.log('@A addAddress payload', payload);
|
||||||
|
//commit('addAddress', payload); // à remplacer par la suite
|
||||||
|
|
||||||
if('newPostalCode' in payload){
|
//fetch POST qui envoie l'adresse, et récupère la confirmation que c'est ok.
|
||||||
let postalCodeBody = payload.newPostalCode;
|
//La confirmation est l'adresse elle-même.
|
||||||
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();
|
|
||||||
}))
|
|
||||||
.catch((error) => {
|
|
||||||
commit('catchError', error);
|
|
||||||
});
|
|
||||||
})
|
|
||||||
|
|
||||||
} else {
|
postAddress(payload)
|
||||||
postAddress(payload)
|
|
||||||
.then(address => new Promise((resolve, reject) => {
|
|
||||||
commit('addAddress', address);
|
|
||||||
resolve();
|
|
||||||
}))
|
|
||||||
.catch((error) => {
|
|
||||||
commit('catchError', error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
addDateToAddressAndAddressToPerson({ commit }, payload) {
|
|
||||||
console.log('@A addDateToAddressAndAddressToPerson payload', payload);
|
|
||||||
|
|
||||||
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();
|
|
||||||
}))
|
|
||||||
.catch((error) => {
|
|
||||||
commit('catchError', error);
|
|
||||||
})
|
|
||||||
))
|
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
commit('catchError', error);
|
commit('catchError', error);
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
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,8 +9,7 @@
|
|||||||
@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>
|
||||||
@@ -46,7 +42,6 @@
|
|||||||
</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>
|
||||||
@@ -105,14 +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"
|
||||||
},
|
},
|
||||||
address: {
|
address: {
|
||||||
writeNewAddress: false,
|
|
||||||
writeNewPostalCode: false,
|
|
||||||
loaded: {
|
loaded: {
|
||||||
countries: [],
|
countries: [],
|
||||||
cities: [],
|
cities: [],
|
||||||
@@ -123,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,
|
||||||
@@ -181,8 +167,8 @@ export default {
|
|||||||
getCities(country) {
|
getCities(country) {
|
||||||
console.log('getCities for', country.name);
|
console.log('getCities for', country.name);
|
||||||
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()
|
||||||
}))
|
}))
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.errorMsg.push(error.message);
|
this.errorMsg.push(error.message);
|
||||||
@@ -212,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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,56 +1,37 @@
|
|||||||
<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"
|
||||||
: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"
|
||||||
: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"
|
||||||
: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"
|
||||||
: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"
|
||||||
: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"
|
||||||
: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"
|
||||||
:placeholder="$t('distribution')"
|
:placeholder="$t('distribution')"
|
||||||
|
@@ -15,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>
|
||||||
@@ -42,31 +30,9 @@ 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) {
|
||||||
@@ -74,12 +40,14 @@ export default {
|
|||||||
},
|
},
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -8,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>
|
||||||
@@ -41,42 +25,18 @@ export default {
|
|||||||
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);
|
||||||
},
|
},
|
||||||
addPostalCode() {
|
},
|
||||||
this.address.writeNewPostalCode = true;
|
computed: {
|
||||||
|
cities() {
|
||||||
|
return this.address.loaded.cities;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -22,18 +22,13 @@ 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 }) {
|
||||||
|
@@ -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>
|
|
@@ -0,0 +1,42 @@
|
|||||||
|
{% extends "@ChillMain/layout.html.twig" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div id="container content">
|
||||||
|
<div class="grid-8 centered">
|
||||||
|
<h1>{{ "Notifications list" | trans }}</h1>
|
||||||
|
<!-- TODO : UNREAD & READ -->
|
||||||
|
|
||||||
|
{%for data in datas %}
|
||||||
|
{% set notification = data.notification %}
|
||||||
|
|
||||||
|
<dl class="chill_view_data">
|
||||||
|
<dt class="inline">{{ 'Message'|trans }}</dt>
|
||||||
|
<dd>{{ notification.message }}</dd>
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl class="chill_view_data">
|
||||||
|
<dt class="inline">{{ 'Date'|trans }}</dt>
|
||||||
|
<dd>{{ notification.date | date('long') }}</dd>
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
|
||||||
|
<dl class="chill_view_data">
|
||||||
|
<dt class="inline">{{ 'Sender'|trans }}</dt>
|
||||||
|
<dd>{{ notification.sender }}</dd>
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl class="chill_view_data">
|
||||||
|
<dt class="inline">{{ 'Addressees'|trans }}</dt>
|
||||||
|
<dd>{{ notification.addressees |join(', ') }}</dd>
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl class="chill_view_data">
|
||||||
|
<dt class="inline">{{ 'Entity'|trans }}</dt>
|
||||||
|
<dd>
|
||||||
|
{% include data.template with data.template_data %}
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock content %}
|
@@ -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>
|
|
||||||
|
@@ -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->getStreet().', '.$address->getStreetNumber();
|
$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,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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -17,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:
|
||||||
@@ -116,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.
|
||||||
@@ -142,286 +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"
|
|
||||||
|
@@ -34,6 +34,10 @@ chill_password_recover:
|
|||||||
resource: "@ChillMainBundle/config/routes/password_recover.yaml"
|
resource: "@ChillMainBundle/config/routes/password_recover.yaml"
|
||||||
prefix: "public/{_locale}/password"
|
prefix: "public/{_locale}/password"
|
||||||
|
|
||||||
|
chill_main_notification:
|
||||||
|
resource: "@ChillMainBundle/config/routes/notification.yaml"
|
||||||
|
prefix: "{_locale}/notification"
|
||||||
|
|
||||||
chill_crud:
|
chill_crud:
|
||||||
resource: "@ChillMainBundle"
|
resource: "@ChillMainBundle"
|
||||||
type: CRUD
|
type: CRUD
|
||||||
|
@@ -33,3 +33,8 @@ services:
|
|||||||
$logger: '@Psr\Log\LoggerInterface'
|
$logger: '@Psr\Log\LoggerInterface'
|
||||||
$validator: '@Symfony\Component\Validator\Validator\ValidatorInterface'
|
$validator: '@Symfony\Component\Validator\Validator\ValidatorInterface'
|
||||||
tags: ['controller.service_arguments']
|
tags: ['controller.service_arguments']
|
||||||
|
|
||||||
|
Chill\MainBundle\Controller\NotificationController:
|
||||||
|
arguments:
|
||||||
|
$security: '@Symfony\Component\Security\Core\Security'
|
||||||
|
tags: ['controller.service_arguments']
|
||||||
|
@@ -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
|
||||||
|
@@ -4,7 +4,11 @@ services:
|
|||||||
$logger: '@Psr\Log\LoggerInterface'
|
$logger: '@Psr\Log\LoggerInterface'
|
||||||
$twig: '@Twig\Environment'
|
$twig: '@Twig\Environment'
|
||||||
$mailer: '@swiftmailer.mailer.default'
|
$mailer: '@swiftmailer.mailer.default'
|
||||||
# $mailerTransporter: '@swiftmailer.transport'
|
# $mailerTransporter: '@swiftmailer.transport'
|
||||||
$router: '@Symfony\Component\Routing\RouterInterface'
|
$router: '@Symfony\Component\Routing\RouterInterface'
|
||||||
$translator: '@Symfony\Component\Translation\TranslatorInterface'
|
$translator: '@Symfony\Component\Translation\TranslatorInterface'
|
||||||
$routeParameters: '%chill_main.notifications%'
|
$routeParameters: '%chill_main.notifications%'
|
||||||
|
|
||||||
|
Chill\MainBundle\Notification\NotificationRenderer:
|
||||||
|
autoconfigure: true
|
||||||
|
autowire: true
|
||||||
|
@@ -2,13 +2,15 @@ services:
|
|||||||
chill_main.paginator_factory:
|
chill_main.paginator_factory:
|
||||||
class: Chill\MainBundle\Pagination\PaginatorFactory
|
class: Chill\MainBundle\Pagination\PaginatorFactory
|
||||||
public: true
|
public: true
|
||||||
|
autowire: true
|
||||||
|
autoconfigure: true
|
||||||
arguments:
|
arguments:
|
||||||
- "@request_stack"
|
- "@request_stack"
|
||||||
- "@router"
|
- "@router"
|
||||||
- "%chill_main.pagination.item_per_page%"
|
- "%chill_main.pagination.item_per_page%"
|
||||||
|
|
||||||
Chill\MainBundle\Pagination\PaginatorFactory: '@chill_main.paginator_factory'
|
Chill\MainBundle\Pagination\PaginatorFactory: '@chill_main.paginator_factory'
|
||||||
|
|
||||||
chill_main.paginator.twig_extensions:
|
chill_main.paginator.twig_extensions:
|
||||||
class: Chill\MainBundle\Pagination\ChillPaginationTwig
|
class: Chill\MainBundle\Pagination\ChillPaginationTwig
|
||||||
tags:
|
tags:
|
||||||
|
@@ -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 */
|
||||||
|
@@ -86,19 +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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->render('@ChillPerson/AccompanyingCourse/index.html.twig', [
|
return $this->render('@ChillPerson/AccompanyingCourse/index.html.twig', [
|
||||||
'accompanyingCourse' => $accompanyingCourse,
|
'accompanyingCourse' => $accompanyingCourse
|
||||||
'withoutHousehold' => $withoutHousehold
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,52 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Controller;
|
|
||||||
|
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
|
||||||
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;
|
|
||||||
|
|
||||||
class AccompanyingCourseWorkController extends AbstractController
|
|
||||||
{
|
|
||||||
private TranslatorInterface $trans;
|
|
||||||
private SerializerInterface $serializer;
|
|
||||||
|
|
||||||
public function __construct(TranslatorInterface $trans, SerializerInterface $serializer)
|
|
||||||
{
|
|
||||||
$this->trans = $trans;
|
|
||||||
$this->serializer = $serializer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Route(
|
|
||||||
* "{_locale}/person/accompanying-period/{id}/work/new",
|
|
||||||
* methods={"GET", "POST"}
|
|
||||||
* )
|
|
||||||
*/
|
|
||||||
public function createWork(AccompanyingPeriod $period)
|
|
||||||
{
|
|
||||||
// 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
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Controller;
|
|
||||||
|
|
||||||
use Chill\MainBundle\CRUD\Controller\ApiController;
|
|
||||||
use Chill\MainBundle\Entity\Address;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
|
||||||
|
|
||||||
class HouseholdApiController extends ApiController
|
|
||||||
{
|
|
||||||
|
|
||||||
public function householdAddressApi($id, Request $request, string $_format): Response
|
|
||||||
{
|
|
||||||
return $this->addRemoveSomething('address', $id, $request, $_format, 'address', Address::class, [ '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,8 +27,37 @@ class HouseholdController extends AbstractController
|
|||||||
{
|
{
|
||||||
// TODO ACL
|
// TODO ACL
|
||||||
|
|
||||||
$positions = $this->positionRepository
|
$positions = $this->getDoctrine()->getManager()
|
||||||
->findByActiveOrdered()
|
->getRepository(Position::class)
|
||||||
|
->findAll()
|
||||||
|
;
|
||||||
|
|
||||||
|
// little performance improvement:
|
||||||
|
// initialize members collection, which will avoid
|
||||||
|
// some queries
|
||||||
|
$household->getMembers()->initialize();
|
||||||
|
return $this->render('@ChillPerson/Household/summary.html.twig',
|
||||||
|
[
|
||||||
|
'household' => $household,
|
||||||
|
'positions' => $positions
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Route(
|
||||||
|
* "/{household_id}/members",
|
||||||
|
* name="chill_person_household_members",
|
||||||
|
* methods={"GET", "HEAD"}
|
||||||
|
* )
|
||||||
|
* @ParamConverter("household", options={"id" = "household_id"})
|
||||||
|
*/
|
||||||
|
public function members(Request $request, Household $household)
|
||||||
|
{
|
||||||
|
// TODO ACL
|
||||||
|
$positions = $this->getDoctrine()->getManager()
|
||||||
|
->getRepository(Position::class)
|
||||||
|
->findAll()
|
||||||
;
|
;
|
||||||
|
|
||||||
// little performance improvement:
|
// little performance improvement:
|
||||||
@@ -52,17 +65,10 @@ class HouseholdController extends AbstractController
|
|||||||
// some queries
|
// some queries
|
||||||
$household->getMembers()->initialize();
|
$household->getMembers()->initialize();
|
||||||
|
|
||||||
if ($request->query->has('edit')) {
|
return $this->render('@ChillPerson/Household/members.html.twig',
|
||||||
$form = $this->createMetadataForm($household);
|
|
||||||
} else {
|
|
||||||
$form = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->render('@ChillPerson/Household/summary.html.twig',
|
|
||||||
[
|
[
|
||||||
'household' => $household,
|
'household' => $household,
|
||||||
'positions' => $positions,
|
'positions' => $positions
|
||||||
'form' => NULL !== $form ? $form->createView() : null,
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -78,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
|
||||||
@@ -95,7 +91,6 @@ class HouseholdController extends AbstractController
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route(
|
* @Route(
|
||||||
* "/{household_id}/address/move",
|
* "/{household_id}/address/move",
|
||||||
@@ -107,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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -50,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
|
||||||
@@ -159,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()) {
|
||||||
@@ -173,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()
|
||||||
|
@@ -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,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" ]]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\DataFixtures\ORM;
|
||||||
|
|
||||||
|
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||||
|
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
|
use Chill\MainBundle\DataFixtures\ORM\LoadAbstractNotificationsTrait;
|
||||||
|
use Chill\PersonBundle\DataFixtures\ORM\LoadAccompanyingPeriod;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load notififications into database
|
||||||
|
*/
|
||||||
|
class LoadAccompanyingPeriodNotifications extends AbstractFixture implements DependentFixtureInterface
|
||||||
|
{
|
||||||
|
use LoadAbstractNotificationsTrait;
|
||||||
|
|
||||||
|
public $notifs = [
|
||||||
|
[
|
||||||
|
'message' => 'Hello !',
|
||||||
|
'entityClass' => AccompanyingPeriod::class,
|
||||||
|
'entityRef' => LoadAccompanyingPeriod::ACCOMPANYING_PERIOD,
|
||||||
|
'sender' => 'center a_social',
|
||||||
|
'addressees' => [
|
||||||
|
'center a_social',
|
||||||
|
'center a_administrative',
|
||||||
|
'center a_direction',
|
||||||
|
'multi_center'
|
||||||
|
],
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
public function getDependencies()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
LoadAccompanyingPeriod::class,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@@ -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
|
||||||
|
@@ -74,6 +74,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
|||||||
$loader->load('services/form.yaml');
|
$loader->load('services/form.yaml');
|
||||||
$loader->load('services/alt_names.yaml');
|
$loader->load('services/alt_names.yaml');
|
||||||
$loader->load('services/household.yaml');
|
$loader->load('services/household.yaml');
|
||||||
|
$loader->load('services/notification.yaml');
|
||||||
// We can get rid of this file when the service 'chill.person.repository.person' is no more used.
|
// We can get rid of this file when the service 'chill.person.repository.person' is no more used.
|
||||||
// We should use the PersonRepository service instead of a custom service name.
|
// We should use the PersonRepository service instead of a custom service name.
|
||||||
$loader->load('services/repository.yaml');
|
$loader->load('services/repository.yaml');
|
||||||
@@ -438,19 +439,6 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
|||||||
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' => [
|
||||||
@@ -523,48 +511,8 @@ 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,
|
|
||||||
'controller' => \Chill\PersonBundle\Controller\HouseholdApiController::class,
|
|
||||||
'name' => '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,
|
|
||||||
Request::METHOD_POST=> true,
|
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'address' => [
|
|
||||||
'methods' => [
|
|
||||||
Request::METHOD_POST => true,
|
|
||||||
Request::METHOD_DELETE => true,
|
|
||||||
Request::METHOD_GET => false,
|
|
||||||
Request::METHOD_HEAD => false,
|
|
||||||
],
|
|
||||||
'controller_action' => 'householdAddressApi'
|
|
||||||
],
|
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@@ -586,49 +534,6 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
|||||||
],
|
],
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
[
|
|
||||||
'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
|
|
||||||
'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',
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'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',
|
|
||||||
]
|
|
||||||
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@@ -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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -908,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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -7,123 +7,86 @@ use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
|||||||
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"})
|
|
||||||
*/
|
*/
|
||||||
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({"accompanying_period_work:create", "read"})
|
|
||||||
*/
|
*/
|
||||||
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({"read"})
|
|
||||||
*/
|
|
||||||
private \DateTimeImmutable $startDate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default":null})
|
|
||||||
* @Serializer\Groups({"accompanying_period_work:create", "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"})
|
|
||||||
*
|
*
|
||||||
* 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(targetEntity=AccompanyingPeriodWorkGoal::class, mappedBy="accompanyingPeriodWork")
|
* @ORM\OneToMany(targetEntity=AccompanyingPeriodWorkGoal::class, mappedBy="accompanyingPeriodWork")
|
||||||
*/
|
*/
|
||||||
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")
|
||||||
*/
|
*/
|
||||||
private Collection $results;
|
private $results;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToMany(targetEntity=ThirdParty::class)
|
* @ORM\ManyToMany(targetEntity=ThirdParty::class)
|
||||||
@@ -131,7 +94,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||||||
*
|
*
|
||||||
* In schema : intervenants
|
* In schema : intervenants
|
||||||
*/
|
*/
|
||||||
private Collection $thirdParties;
|
private $thirdParties;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
@@ -162,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;
|
||||||
@@ -190,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;
|
||||||
}
|
}
|
||||||
@@ -214,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;
|
||||||
|
@@ -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;
|
||||||
|
|
||||||
@@ -51,30 +45,14 @@ class Household
|
|||||||
* targetEntity=HouseholdMember::class,
|
* targetEntity=HouseholdMember::class,
|
||||||
* mappedBy="household"
|
* mappedBy="household"
|
||||||
* )
|
* )
|
||||||
* @Serializer\Groups({"write", "read"})
|
* @Serializer\Groups({"read"})
|
||||||
*/
|
*/
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -23,17 +23,13 @@ namespace Chill\PersonBundle\Entity;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use ArrayIterator;
|
use ArrayIterator;
|
||||||
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
|
||||||
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
|
||||||
use Chill\MainBundle\Entity\Center;
|
use Chill\MainBundle\Entity\Center;
|
||||||
use Chill\MainBundle\Entity\Country;
|
use Chill\MainBundle\Entity\Country;
|
||||||
use Chill\MainBundle\Entity\User;
|
|
||||||
use Chill\PersonBundle\Entity\Household\Household;
|
use Chill\PersonBundle\Entity\Household\Household;
|
||||||
use Chill\PersonBundle\Entity\MaritalStatus;
|
use Chill\PersonBundle\Entity\MaritalStatus;
|
||||||
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
||||||
use Chill\MainBundle\Entity\HasCenterInterface;
|
use Chill\MainBundle\Entity\HasCenterInterface;
|
||||||
use Chill\MainBundle\Entity\Address;
|
use Chill\MainBundle\Entity\Address;
|
||||||
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
@@ -41,7 +37,6 @@ use Doctrine\Common\Collections\ArrayCollection;
|
|||||||
use Doctrine\Common\Collections\Criteria;
|
use Doctrine\Common\Collections\Criteria;
|
||||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||||
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||||
use Chill\PersonBundle\Entity\Household\PersonHouseholdAddress;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Person Class
|
* Person Class
|
||||||
@@ -57,7 +52,7 @@ use Chill\PersonBundle\Entity\Household\PersonHouseholdAddress;
|
|||||||
* "person"=Person::class
|
* "person"=Person::class
|
||||||
* })
|
* })
|
||||||
*/
|
*/
|
||||||
class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateInterface
|
class Person implements HasCenterInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The person's id
|
* The person's id
|
||||||
@@ -104,14 +99,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
*/
|
*/
|
||||||
private $birthdate; //to change in birthdate
|
private $birthdate; //to change in birthdate
|
||||||
|
|
||||||
/**
|
|
||||||
* The person's deathdate
|
|
||||||
* @var \DateTimeImmutable
|
|
||||||
*
|
|
||||||
* @ORM\Column(type="date_immutable", nullable=true)
|
|
||||||
*/
|
|
||||||
private ?\DateTimeImmutable $deathdate;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The person's place of birth
|
* The person's place of birth
|
||||||
* @var string
|
* @var string
|
||||||
@@ -155,14 +142,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
const MALE_GENDER = 'man';
|
const MALE_GENDER = 'man';
|
||||||
const FEMALE_GENDER = 'woman';
|
const FEMALE_GENDER = 'woman';
|
||||||
const BOTH_GENDER = 'both';
|
const BOTH_GENDER = 'both';
|
||||||
const NO_INFORMATION = 'unknown';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Comment on gender
|
|
||||||
* @var CommentEmbeddable
|
|
||||||
* @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="genderComment_")
|
|
||||||
*/
|
|
||||||
private CommentEmbeddable $genderComment;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The marital status of the person
|
* The marital status of the person
|
||||||
@@ -173,21 +152,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
*/
|
*/
|
||||||
private $maritalStatus;
|
private $maritalStatus;
|
||||||
|
|
||||||
/**
|
|
||||||
* The date of the last marital status change of the person
|
|
||||||
* @var \DateTime
|
|
||||||
*
|
|
||||||
* @ORM\Column(type="date", nullable=true)
|
|
||||||
*/
|
|
||||||
private $maritalStatusDate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Comment on marital status
|
|
||||||
* @var CommentEmbeddable
|
|
||||||
* @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="maritalStatusComment_")
|
|
||||||
*/
|
|
||||||
private CommentEmbeddable $maritalStatusComment;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contact information for contacting the person
|
* Contact information for contacting the person
|
||||||
* @var string
|
* @var string
|
||||||
@@ -275,54 +239,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
*/
|
*/
|
||||||
private $memo = ''; // TO-CHANGE in remark
|
private $memo = ''; // TO-CHANGE in remark
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Accept short text message (aka SMS)
|
|
||||||
* @var boolean
|
|
||||||
*
|
|
||||||
* @ORM\Column(type="boolean", options={"default" : false})
|
|
||||||
*/
|
|
||||||
private ?bool $acceptSMS = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Accept receiving email
|
|
||||||
* @var boolean
|
|
||||||
*
|
|
||||||
* @ORM\Column(type="boolean", options={"default" : false})
|
|
||||||
*/
|
|
||||||
private ?bool $acceptEmail = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Number of children
|
|
||||||
* @var int
|
|
||||||
*
|
|
||||||
* @ORM\Column(type="integer", nullable=true)
|
|
||||||
*/
|
|
||||||
private ?int $numberOfChildren = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\ManyToOne(targetEntity=User::class)
|
|
||||||
* @ORM\JoinColumn(nullable=true)
|
|
||||||
*/
|
|
||||||
private $createdBy;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="datetime", nullable=true, options={"default": NULL})
|
|
||||||
*/
|
|
||||||
private \DateTimeInterface $createdAt;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\ManyToOne(
|
|
||||||
* targetEntity=User::class
|
|
||||||
* )
|
|
||||||
*/
|
|
||||||
private User $updatedBy;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="datetime", nullable=true, options={"default": NULL})
|
|
||||||
*/
|
|
||||||
private \DateTimeInterface $updatedAt;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var boolean
|
* @var boolean
|
||||||
* @deprecated
|
* @deprecated
|
||||||
@@ -371,14 +287,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
*/
|
*/
|
||||||
private array $currentHouseholdAt = [];
|
private array $currentHouseholdAt = [];
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\OneToMany(
|
|
||||||
* targetEntity=PersonHouseholdAddress::class,
|
|
||||||
* mappedBy="person"
|
|
||||||
* )
|
|
||||||
*/
|
|
||||||
private Collection $householdAddresses;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Person constructor.
|
* Person constructor.
|
||||||
*
|
*
|
||||||
@@ -392,17 +300,14 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
$this->altNames = new ArrayCollection();
|
$this->altNames = new ArrayCollection();
|
||||||
$this->otherPhoneNumbers = new ArrayCollection();
|
$this->otherPhoneNumbers = new ArrayCollection();
|
||||||
$this->householdParticipations = new ArrayCollection();
|
$this->householdParticipations = new ArrayCollection();
|
||||||
$this->householdAddresses = new ArrayCollection();
|
|
||||||
|
|
||||||
if ($opening === null) {
|
if ($opening === null) {
|
||||||
$opening = new \DateTime();
|
$opening = new \DateTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->open(new AccompanyingPeriod($opening));
|
$this->open(new AccompanyingPeriod($opening));
|
||||||
$this->genderComment = new CommentEmbeddable();
|
|
||||||
$this->maritalStatusComment = new CommentEmbeddable();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This private function scan accompanyingPeriodParticipations Collection,
|
* This private function scan accompanyingPeriodParticipations Collection,
|
||||||
* searching for a given AccompanyingPeriod
|
* searching for a given AccompanyingPeriod
|
||||||
@@ -414,10 +319,10 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
if ($accompanyingPeriod === $participation->getAccompanyingPeriod()) {
|
if ($accompanyingPeriod === $participation->getAccompanyingPeriod()) {
|
||||||
return $participation;
|
return $participation;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This public function is the same but return only true or false
|
* This public function is the same but return only true or false
|
||||||
*/
|
*/
|
||||||
@@ -425,7 +330,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
{
|
{
|
||||||
return ($this->participationsContainAccompanyingPeriod($accompanyingPeriod)) ? false : true;
|
return ($this->participationsContainAccompanyingPeriod($accompanyingPeriod)) ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add AccompanyingPeriodParticipation
|
* Add AccompanyingPeriodParticipation
|
||||||
*
|
*
|
||||||
@@ -435,7 +340,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
{
|
{
|
||||||
$participation = new AccompanyingPeriodParticipation($accompanyingPeriod, $this);
|
$participation = new AccompanyingPeriodParticipation($accompanyingPeriod, $this);
|
||||||
$this->accompanyingPeriodParticipations->add($participation);
|
$this->accompanyingPeriodParticipations->add($participation);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -445,7 +350,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
public function removeAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod) : void
|
public function removeAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod) : void
|
||||||
{
|
{
|
||||||
$participation = $this->participationsContainAccompanyingPeriod($accompanyingPeriod);
|
$participation = $this->participationsContainAccompanyingPeriod($accompanyingPeriod);
|
||||||
|
|
||||||
if (! null === $participation) {
|
if (! null === $participation) {
|
||||||
$participation->setEndDate(\DateTimeImmutable::class);
|
$participation->setEndDate(\DateTimeImmutable::class);
|
||||||
$this->accompanyingPeriodParticipations->removeElement($participation);
|
$this->accompanyingPeriodParticipations->removeElement($participation);
|
||||||
@@ -523,7 +428,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
}
|
}
|
||||||
return $accompanyingPeriods;
|
return $accompanyingPeriods;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get AccompanyingPeriodParticipations Collection
|
* Get AccompanyingPeriodParticipations Collection
|
||||||
*/
|
*/
|
||||||
@@ -532,7 +437,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
return $this->accompanyingPeriodParticipations;
|
return $this->accompanyingPeriodParticipations;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a collection of participation, where the participation
|
* Return a collection of participation, where the participation
|
||||||
* is still opened, not a draft, and the period is still opened
|
* is still opened, not a draft, and the period is still opened
|
||||||
*/
|
*/
|
||||||
@@ -550,9 +455,9 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
->filter(function (AccompanyingPeriodParticipation $app) {
|
->filter(function (AccompanyingPeriodParticipation $app) {
|
||||||
$period = $app->getAccompanyingPeriod();
|
$period = $app->getAccompanyingPeriod();
|
||||||
return (
|
return (
|
||||||
NULL === $period->getClosingDate()
|
NULL === $period->getClosingDate()
|
||||||
|| new \DateTime('now') < $period->getClosingDate()
|
|| new \DateTime('now') < $period->getClosingDate()
|
||||||
)
|
)
|
||||||
&& AccompanyingPeriod::STEP_DRAFT !== $period->getStep();
|
&& AccompanyingPeriod::STEP_DRAFT !== $period->getStep();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1280,12 +1185,12 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFullnameCanonical() : string
|
public function getFullnameCanonical() : string
|
||||||
{
|
{
|
||||||
return $this->fullnameCanonical;
|
return $this->fullnameCanonical;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setFullnameCanonical($fullnameCanonical) : Person
|
public function setFullnameCanonical($fullnameCanonical) : Person
|
||||||
{
|
{
|
||||||
$this->fullnameCanonical = $fullnameCanonical;
|
$this->fullnameCanonical = $fullnameCanonical;
|
||||||
@@ -1304,69 +1209,16 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
return $this->householdParticipations;
|
return $this->householdParticipations;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get participation where the person does share the household.
|
|
||||||
*
|
|
||||||
* Order by startDate, desc
|
|
||||||
*/
|
|
||||||
public function getHouseholdParticipationsShareHousehold(): Collection
|
|
||||||
{
|
|
||||||
$criteria = new Criteria();
|
|
||||||
$expr = Criteria::expr();
|
|
||||||
|
|
||||||
$criteria
|
|
||||||
->where(
|
|
||||||
$expr->eq('shareHousehold', true)
|
|
||||||
)
|
|
||||||
->orderBy(['startDate' => Criteria::DESC])
|
|
||||||
;
|
|
||||||
|
|
||||||
return $this->getHouseholdParticipations()
|
|
||||||
->matching($criteria)
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get participation where the person does not share the household.
|
|
||||||
*
|
|
||||||
* Order by startDate, desc
|
|
||||||
*/
|
|
||||||
public function getHouseholdParticipationsNotShareHousehold(): Collection
|
|
||||||
{
|
|
||||||
$criteria = new Criteria();
|
|
||||||
$expr = Criteria::expr();
|
|
||||||
|
|
||||||
$criteria
|
|
||||||
->where(
|
|
||||||
$expr->eq('shareHousehold', false)
|
|
||||||
)
|
|
||||||
->orderBy(['startDate' => Criteria::DESC])
|
|
||||||
;
|
|
||||||
|
|
||||||
return $this->getHouseholdParticipations()
|
|
||||||
->matching($criteria)
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCurrentHousehold(?\DateTimeImmutable $at = null): ?Household
|
public function getCurrentHousehold(?\DateTimeImmutable $at = null): ?Household
|
||||||
{
|
|
||||||
$participation = $this->getCurrentHouseholdParticipationShareHousehold($at);
|
|
||||||
|
|
||||||
return $participation instanceof HouseholdMember ?
|
|
||||||
$participation->getHousehold()
|
|
||||||
: null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCurrentHouseholdParticipationShareHousehold(?\DateTimeImmutable $at = null): ?HouseholdMember
|
|
||||||
{
|
{
|
||||||
$criteria = new Criteria();
|
$criteria = new Criteria();
|
||||||
$expr = Criteria::expr();
|
$expr = Criteria::expr();
|
||||||
$date = NULL === $at ? new \DateTimeImmutable('today') : $at;
|
$date = NULL === $at ? new \DateTimeImmutable('now') : $at;
|
||||||
$datef = $date->format('Y-m-d');
|
$datef = $date->format('Y-m-d');
|
||||||
|
|
||||||
if (
|
if (
|
||||||
NULL !== ($this->currentHouseholdParticipationAt[$datef] ?? NULL)) {
|
NULL !== ($this->currentHouseholdAt[$datef] ?? NULL)) {
|
||||||
return $this->currentHouseholdParticipationAt[$datef];
|
return $this->currentHouseholdAt[$datef];
|
||||||
}
|
}
|
||||||
|
|
||||||
$criteria
|
$criteria
|
||||||
@@ -1375,7 +1227,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
$expr->lte('startDate', $date),
|
$expr->lte('startDate', $date),
|
||||||
$expr->orX(
|
$expr->orX(
|
||||||
$expr->isNull('endDate'),
|
$expr->isNull('endDate'),
|
||||||
$expr->gt('endDate', $date)
|
$expr->gte('endDate', $date)
|
||||||
),
|
),
|
||||||
$expr->eq('shareHousehold', true)
|
$expr->eq('shareHousehold', true)
|
||||||
)
|
)
|
||||||
@@ -1386,7 +1238,8 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
;
|
;
|
||||||
|
|
||||||
return $participations->count() > 0 ?
|
return $participations->count() > 0 ?
|
||||||
$this->currentHouseholdParticipationAt[$datef] = $participations->first()
|
$this->currentHouseholdAt[$datef] = $participations->first()
|
||||||
|
->getHousehold()
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1394,36 +1247,4 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
{
|
{
|
||||||
return NULL !== $this->getCurrentHousehold($at);
|
return NULL !== $this->getCurrentHousehold($at);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHouseholdAddresses(): Collection
|
|
||||||
{
|
|
||||||
return $this->householdAddresses;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCurrentHouseholdAddress(?\DateTimeImmutable $at = null): ?Address
|
|
||||||
{
|
|
||||||
$at = $at === null ? new \DateTimeImmutable('today') : $at;
|
|
||||||
$criteria = new Criteria();
|
|
||||||
$expr = Criteria::expr();
|
|
||||||
|
|
||||||
$criteria->where(
|
|
||||||
$expr->lte('validFrom', $at)
|
|
||||||
)
|
|
||||||
->andWhere(
|
|
||||||
$expr->orX(
|
|
||||||
$expr->isNull('validTo'),
|
|
||||||
$expr->gte('validTo', $at)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$addrs = $this->getHouseholdAddresses()
|
|
||||||
->matching($criteria)
|
|
||||||
;
|
|
||||||
|
|
||||||
if ($addrs->count() > 0) {
|
|
||||||
return $addrs->first()->getAddress();
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -5,17 +5,10 @@ namespace Chill\PersonBundle\Entity\SocialWork;
|
|||||||
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_social_action")
|
* @ORM\Table(name="chill_person_social_action")
|
||||||
* @Serializer\DiscriminatorMap(
|
|
||||||
* typeProperty="type",
|
|
||||||
* mapping={
|
|
||||||
* "social_work_social_action":SocialAction::class
|
|
||||||
* }
|
|
||||||
* )
|
|
||||||
*/
|
*/
|
||||||
class SocialAction
|
class SocialAction
|
||||||
{
|
{
|
||||||
|
@@ -35,8 +35,7 @@ class HouseholdMemberType extends AbstractType
|
|||||||
}
|
}
|
||||||
$builder
|
$builder
|
||||||
->add('comment', ChillTextareaType::class, [
|
->add('comment', ChillTextareaType::class, [
|
||||||
'label' => 'household.Comment',
|
'label' => 'household.Comment'
|
||||||
'required' => false
|
|
||||||
])
|
])
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
@@ -1,40 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Form;
|
|
||||||
|
|
||||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
|
||||||
use Chill\MainBundle\Form\Type\CommentType;
|
|
||||||
use Chill\PersonBundle\Entity\Household\Household;
|
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
|
||||||
use Symfony\Component\Form\AbstractType;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
|
||||||
|
|
||||||
class HouseholdType extends AbstractType
|
|
||||||
{
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
|
||||||
{
|
|
||||||
$builder
|
|
||||||
->add('commentMembers', CommentType::class, [
|
|
||||||
'label' => 'household.comment_membership',
|
|
||||||
'required' => false
|
|
||||||
])
|
|
||||||
->add('waitingForBirth', CheckboxType::class, [
|
|
||||||
'required' => false,
|
|
||||||
'label' => 'household.expecting_birth'
|
|
||||||
])
|
|
||||||
->add('waitingForBirthDate', ChillDateType::class, [
|
|
||||||
'required' => false,
|
|
||||||
'label' => 'household.date_expecting_birth',
|
|
||||||
'input' => 'datetime_immutable'
|
|
||||||
])
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function configureOptions(OptionsResolver $resolver)
|
|
||||||
{
|
|
||||||
$resolver->setDefaults([
|
|
||||||
'data_class' => Household::class,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -34,13 +34,9 @@ use Chill\PersonBundle\Entity\PersonPhone;
|
|||||||
use Chill\PersonBundle\Form\Type\Select2MaritalStatusType;
|
use Chill\PersonBundle\Form\Type\Select2MaritalStatusType;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||||
use Chill\MainBundle\Form\Type\CommentType;
|
|
||||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TelType;
|
use Symfony\Component\Form\Extension\Core\Type\TelType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
|
||||||
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
@@ -86,19 +82,8 @@ class PersonType extends AbstractType
|
|||||||
->add('birthdate', ChillDateType::class, [
|
->add('birthdate', ChillDateType::class, [
|
||||||
'required' => false,
|
'required' => false,
|
||||||
])
|
])
|
||||||
->add('deathdate', DateType::class, [
|
|
||||||
'required' => false,
|
|
||||||
'input' => 'datetime_immutable',
|
|
||||||
'widget' => 'single_text'
|
|
||||||
])
|
|
||||||
->add('gender', GenderType::class, array(
|
->add('gender', GenderType::class, array(
|
||||||
'required' => true
|
'required' => true
|
||||||
))
|
|
||||||
->add('genderComment', CommentType::class, array(
|
|
||||||
'required' => false
|
|
||||||
))
|
|
||||||
->add('numberOfChildren', IntegerType::class, array(
|
|
||||||
'required' => false
|
|
||||||
));
|
));
|
||||||
|
|
||||||
if ($this->configAltNamesHelper->hasAltNames()) {
|
if ($this->configAltNamesHelper->hasAltNames()) {
|
||||||
@@ -126,12 +111,7 @@ class PersonType extends AbstractType
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->config['mobilenumber'] === 'visible') {
|
if ($this->config['mobilenumber'] === 'visible') {
|
||||||
$builder
|
$builder->add('mobilenumber', TelType::class, array('required' => false));
|
||||||
->add('mobilenumber', TelType::class, array('required' => false))
|
|
||||||
->add('acceptSMS', CheckboxType::class, array(
|
|
||||||
'value' => false,
|
|
||||||
'required' => true
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$builder->add('otherPhoneNumbers', ChillCollectionType::class, [
|
$builder->add('otherPhoneNumbers', ChillCollectionType::class, [
|
||||||
@@ -150,9 +130,7 @@ class PersonType extends AbstractType
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
if ($this->config['email'] === 'visible') {
|
if ($this->config['email'] === 'visible') {
|
||||||
$builder
|
$builder->add('email', EmailType::class, array('required' => false));
|
||||||
->add('email', EmailType::class, array('required' => false))
|
|
||||||
->add('acceptEmail', CheckboxType::class, array('required' => false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->config['country_of_birth'] === 'visible') {
|
if ($this->config['country_of_birth'] === 'visible') {
|
||||||
@@ -175,16 +153,9 @@ class PersonType extends AbstractType
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->config['marital_status'] === 'visible'){
|
if ($this->config['marital_status'] === 'visible'){
|
||||||
$builder
|
$builder->add('maritalStatus', Select2MaritalStatusType::class, array(
|
||||||
->add('maritalStatus', Select2MaritalStatusType::class, array(
|
'required' => false
|
||||||
'required' => false
|
));
|
||||||
))
|
|
||||||
->add('maritalStatusDate', ChillDateType::class, array(
|
|
||||||
'required' => false
|
|
||||||
))
|
|
||||||
->add('maritalStatusComment', CommentType::class, array(
|
|
||||||
'required' => false
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($options['cFGroup']) {
|
if($options['cFGroup']) {
|
||||||
|
@@ -3,7 +3,6 @@
|
|||||||
namespace Chill\PersonBundle\Household;
|
namespace Chill\PersonBundle\Household;
|
||||||
|
|
||||||
use Symfony\Component\Validator\ConstraintViolationListInterface;
|
use Symfony\Component\Validator\ConstraintViolationListInterface;
|
||||||
use Symfony\Component\Validator\ConstraintViolationList;
|
|
||||||
use Doctrine\Common\Collections\Criteria;
|
use Doctrine\Common\Collections\Criteria;
|
||||||
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
||||||
use Chill\PersonBundle\Entity\Household\Position;
|
use Chill\PersonBundle\Entity\Household\Position;
|
||||||
@@ -20,11 +19,9 @@ class MembersEditor
|
|||||||
private array $persistables = [];
|
private array $persistables = [];
|
||||||
private array $membershipsAffected = [];
|
private array $membershipsAffected = [];
|
||||||
|
|
||||||
public const VALIDATION_GROUP = 'household_memberships';
|
|
||||||
|
|
||||||
public function __construct(ValidatorInterface $validator, ?Household $household)
|
public function __construct(ValidatorInterface $validator, ?Household $household)
|
||||||
{
|
{
|
||||||
$this->validator = $validator;
|
$this->validation = $validator;
|
||||||
$this->household = $household;
|
$this->household = $household;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,12 +41,12 @@ class MembersEditor
|
|||||||
$this->household->addMember($membership);
|
$this->household->addMember($membership);
|
||||||
|
|
||||||
if ($position->getShareHousehold()) {
|
if ($position->getShareHousehold()) {
|
||||||
foreach ($person->getHouseholdParticipationsShareHousehold() as $participation) {
|
foreach ($person->getHouseholdParticipations() as $participation) {
|
||||||
if ($participation === $membership) {
|
if (FALSE === $participation->getShareHousehold()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($participation->getStartDate() > $membership->getStartDate()) {
|
if ($participation === $membership) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,18 +92,7 @@ class MembersEditor
|
|||||||
|
|
||||||
public function validate(): ConstraintViolationListInterface
|
public function validate(): ConstraintViolationListInterface
|
||||||
{
|
{
|
||||||
if ($this->hasHousehold()) {
|
|
||||||
$list = $this->validator
|
|
||||||
->validate($this->getHousehold(), null, [ self::VALIDATION_GROUP ]);
|
|
||||||
} else {
|
|
||||||
$list = new ConstraintViolationList();
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($this->membershipsAffected as $m) {
|
|
||||||
$list->addAll($this->validator->validate($m, null, [ self::VALIDATION_GROUP ]));
|
|
||||||
}
|
|
||||||
|
|
||||||
return $list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPersistable(): array
|
public function getPersistable(): array
|
||||||
@@ -114,7 +100,6 @@ class MembersEditor
|
|||||||
return $this->persistables;
|
return $this->persistables;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getHousehold(): ?Household
|
public function getHousehold(): ?Household
|
||||||
{
|
{
|
||||||
return $this->household;
|
return $this->household;
|
||||||
|
@@ -35,6 +35,13 @@ class HouseholdMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
'household_id' => $household->getId()
|
'household_id' => $household->getId()
|
||||||
]])
|
]])
|
||||||
->setExtras(['order' => 10]);
|
->setExtras(['order' => 10]);
|
||||||
|
|
||||||
|
$menu->addChild($this->translator->trans('household.Household members'), [
|
||||||
|
'route' => 'chill_person_household_members',
|
||||||
|
'routeParameters' => [
|
||||||
|
'household_id' => $household->getId()
|
||||||
|
]])
|
||||||
|
->setExtras(['order' => 20]);
|
||||||
|
|
||||||
$menu->addChild($this->translator->trans('household.Addresses'), [
|
$menu->addChild($this->translator->trans('household.Addresses'), [
|
||||||
'route' => 'chill_person_household_addresses',
|
'route' => 'chill_person_household_addresses',
|
||||||
|
@@ -64,16 +64,6 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
'order' => 50
|
'order' => 50
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$menu->addChild($this->translator->trans('household.person history'), [
|
|
||||||
'route' => 'chill_person_household_person_history',
|
|
||||||
'routeParameters' => [
|
|
||||||
'person_id' => $parameters['person']->getId()
|
|
||||||
]
|
|
||||||
])
|
|
||||||
->setExtras([
|
|
||||||
'order' => 99999
|
|
||||||
]);
|
|
||||||
|
|
||||||
$menu->addChild($this->translator->trans('Person duplicate'), [
|
$menu->addChild($this->translator->trans('Person duplicate'), [
|
||||||
'route' => 'chill_person_duplicate_view',
|
'route' => 'chill_person_duplicate_view',
|
||||||
'routeParameters' => [
|
'routeParameters' => [
|
||||||
@@ -81,7 +71,7 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
]
|
]
|
||||||
])
|
])
|
||||||
->setExtras([
|
->setExtras([
|
||||||
'order' => 99999
|
'order' => 51
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($this->showAccompanyingPeriod === 'visible') {
|
if ($this->showAccompanyingPeriod === 'visible') {
|
||||||
|
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Notification;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Entity\Notification;
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
|
|
||||||
|
final class AccompanyingPeriodNotificationRenderer
|
||||||
|
{
|
||||||
|
public function supports(Notification $notification)
|
||||||
|
{
|
||||||
|
return $notification->getRelatedEntityClass() == AccompanyingPeriod::class;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTemplate()
|
||||||
|
{
|
||||||
|
return 'ChillPersonBundle:AccompanyingPeriod:showInNotification.html.twig';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTemplateData(Notification $notification)
|
||||||
|
{
|
||||||
|
return ['notification' => $notification];
|
||||||
|
}
|
||||||
|
}
|
@@ -1,48 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Repository\Household;
|
|
||||||
|
|
||||||
use Chill\PersonBundle\Entity\Household\PersonHouseholdAddress;
|
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
|
||||||
use Doctrine\ORM\EntityRepository;
|
|
||||||
use Doctrine\Persistence\ObjectRepository;
|
|
||||||
|
|
||||||
final class PersonHouseholdAddressRepository implements ObjectRepository
|
|
||||||
{
|
|
||||||
private EntityRepository $repository;
|
|
||||||
|
|
||||||
public function __construct(EntityManagerInterface $em)
|
|
||||||
{
|
|
||||||
$this->repository = $em->getRepository(PersonHouseholdAddress::class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function find($id, $lockMode = null, $lockVersion = null): ?PersonHouseholdAddress
|
|
||||||
{
|
|
||||||
return $this->repository->find($id, $lockMode, $lockVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function findOneBy(array $criteria, array $orderBy = null): ?PersonHouseholdAddress
|
|
||||||
{
|
|
||||||
return $this->repository->findOneBy($criteria, $orderBy);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return PersonHouseholdAddress[]
|
|
||||||
*/
|
|
||||||
public function findAll(): array
|
|
||||||
{
|
|
||||||
return $this->repository->findAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return PersonHouseholdAddress[]
|
|
||||||
*/
|
|
||||||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array
|
|
||||||
{
|
|
||||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getClassName() {
|
|
||||||
return PersonHouseholdAddress::class;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -7,9 +7,14 @@ use Chill\PersonBundle\Entity\Household\Position;
|
|||||||
//use Doctrine\Persistence\ManagerRegistry;
|
//use Doctrine\Persistence\ManagerRegistry;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
use Doctrine\Persistence\ObjectRepository;
|
|
||||||
|
|
||||||
final class PositionRepository implements ObjectRepository
|
/**
|
||||||
|
* @method Position|null find($id, $lockMode = null, $lockVersion = null)
|
||||||
|
* @method Position|null findOneBy(array $criteria, array $orderBy = null)
|
||||||
|
* @method Position[] findAll()
|
||||||
|
* @method Position[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||||
|
*/
|
||||||
|
final class PositionRepository
|
||||||
{
|
{
|
||||||
private EntityRepository $repository;
|
private EntityRepository $repository;
|
||||||
|
|
||||||
@@ -25,45 +30,4 @@ final class PositionRepository implements ObjectRepository
|
|||||||
{
|
{
|
||||||
return $this->repository->findAll();
|
return $this->repository->findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Position[]
|
|
||||||
*/
|
|
||||||
public function findByActiveOrdered(): array
|
|
||||||
{
|
|
||||||
return $this->repository->createQueryBuilder('p')
|
|
||||||
->select('p')
|
|
||||||
->orderBy('p.ordering', 'ASC')
|
|
||||||
->getQuery()
|
|
||||||
->getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Position[]
|
|
||||||
*/
|
|
||||||
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
|
|
||||||
{
|
|
||||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Position[]
|
|
||||||
*/
|
|
||||||
public function findOneBy(array $criteria): array
|
|
||||||
{
|
|
||||||
return $this->repository->findOneBy($criteria);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Position
|
|
||||||
*/
|
|
||||||
public function find($id)
|
|
||||||
{
|
|
||||||
return $this->repository->find($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getClassName()
|
|
||||||
{
|
|
||||||
return Position::class;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -6,9 +6,8 @@ use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
|||||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
use Doctrine\Persistence\ObjectRepository;
|
|
||||||
|
|
||||||
final class SocialIssueRepository implements ObjectRepository
|
final class SocialIssueRepository
|
||||||
{
|
{
|
||||||
private EntityRepository $repository;
|
private EntityRepository $repository;
|
||||||
|
|
||||||
@@ -16,44 +15,4 @@ final class SocialIssueRepository implements ObjectRepository
|
|||||||
{
|
{
|
||||||
$this->repository = $entityManager->getRepository(SocialIssue::class);
|
$this->repository = $entityManager->getRepository(SocialIssue::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public function find($id)
|
|
||||||
{
|
|
||||||
return $this->repository->find($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public function findAll()
|
|
||||||
{
|
|
||||||
return $this->repository->findAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null)
|
|
||||||
{
|
|
||||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public function findOneBy(array $criteria)
|
|
||||||
{
|
|
||||||
return $this->findOneBy($criteria);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public function getClassName()
|
|
||||||
{
|
|
||||||
return SocialIssue::class;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -1,3 +1,2 @@
|
|||||||
require('./sass/person.scss');
|
require('./sass/person.scss');
|
||||||
require('./sass/person_with_period.scss');
|
require('./sass/person_with_period.scss');
|
||||||
require('./sass/household_banner.scss');
|
|
||||||
|
@@ -1,57 +0,0 @@
|
|||||||
import { ShowHide } from 'ShowHide/show_hide.js';
|
|
||||||
|
|
||||||
const maritalStatus = document.getElementById("maritalStatus");
|
|
||||||
const maritalStatusDate = document.getElementById("maritalStatusDate");
|
|
||||||
const personEmail = document.getElementById("personEmail");
|
|
||||||
const personAcceptEmail = document.getElementById("personAcceptEmail");
|
|
||||||
const personPhoneNumber = document.getElementById("personPhoneNumber");
|
|
||||||
const personAcceptSMS = document.getElementById("personAcceptSMS");
|
|
||||||
|
|
||||||
|
|
||||||
new ShowHide({
|
|
||||||
froms: [maritalStatus],
|
|
||||||
container: [maritalStatusDate],
|
|
||||||
test: function(froms) {
|
|
||||||
for (let f of froms.values()) {
|
|
||||||
for (let input of f.querySelectorAll('select').values()) {
|
|
||||||
if (input.value) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
event_name: 'change'
|
|
||||||
});
|
|
||||||
|
|
||||||
new ShowHide({
|
|
||||||
froms: [personEmail],
|
|
||||||
container: [personAcceptEmail],
|
|
||||||
test: function(froms) {
|
|
||||||
for (let f of froms.values()) {
|
|
||||||
for (let input of f.querySelectorAll('input').values()) {
|
|
||||||
if (input.value) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
event_name: 'input'
|
|
||||||
});
|
|
||||||
|
|
||||||
new ShowHide({
|
|
||||||
froms: [personPhoneNumber],
|
|
||||||
container: [personAcceptSMS],
|
|
||||||
test: function(froms) {
|
|
||||||
for (let f of froms.values()) {
|
|
||||||
for (let input of f.querySelectorAll('input').values()) {
|
|
||||||
if (input.value) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
event_name: 'input'
|
|
||||||
});
|
|
@@ -1,25 +0,0 @@
|
|||||||
import { ShowHide } from 'ShowHide/show_hide.js';
|
|
||||||
|
|
||||||
let
|
|
||||||
k = document.getElementById('waitingForBirthContainer'),
|
|
||||||
waitingForBirthDate = document.getElementById('waitingForBirthDateContainer')
|
|
||||||
;
|
|
||||||
|
|
||||||
console.log(k );
|
|
||||||
|
|
||||||
new ShowHide({
|
|
||||||
'container': [waitingForBirthDate],
|
|
||||||
'froms': [k ],
|
|
||||||
'event_name': 'input',
|
|
||||||
'debug': true,
|
|
||||||
'test': function(froms, event) {
|
|
||||||
for (let f of froms.values()) {
|
|
||||||
console.log(f);
|
|
||||||
for (let input of f.querySelectorAll('input').values()) {
|
|
||||||
return input.checked;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
@@ -1,5 +0,0 @@
|
|||||||
.banner-household {
|
|
||||||
.current-members-explain {
|
|
||||||
font-weight: 700;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -86,83 +86,3 @@ div.person-view {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* HOUSEHOLD
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
div.household__address, div.person__address {
|
|
||||||
div.row {
|
|
||||||
height: 100px;
|
|
||||||
width: 100%;
|
|
||||||
position: relative;
|
|
||||||
& > div {
|
|
||||||
position: absolute;
|
|
||||||
display: table;
|
|
||||||
height: 100%;
|
|
||||||
border: 1px dotted #c3c3c3;
|
|
||||||
}
|
|
||||||
div.household__address--date, div.person__address--date {
|
|
||||||
width: 30%;
|
|
||||||
background-color: #c3c3c3;
|
|
||||||
height: 100%;
|
|
||||||
div.cell {
|
|
||||||
box-sizing: border-box;
|
|
||||||
position: relative;
|
|
||||||
height: 100%;
|
|
||||||
width: 100%;
|
|
||||||
margin-left: 50%;
|
|
||||||
div.pill {
|
|
||||||
position: absolute;
|
|
||||||
box-sizing: border-box;
|
|
||||||
width: 120px;
|
|
||||||
height: 40px;
|
|
||||||
bottom: -20px;
|
|
||||||
background-color: white;
|
|
||||||
padding: 10px;
|
|
||||||
border-radius: 30px;
|
|
||||||
left: -60px;
|
|
||||||
text-align: center;
|
|
||||||
z-index: 10;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
div.household__address--content, div.person__address--content {
|
|
||||||
width: 70%;
|
|
||||||
left: 30%;
|
|
||||||
text-align: left;
|
|
||||||
background-color: #ececec;
|
|
||||||
border: 1px solid #888;
|
|
||||||
div.cell {
|
|
||||||
display: table-cell;
|
|
||||||
padding: 5px 30px;
|
|
||||||
vertical-align: middle;
|
|
||||||
& > div {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
}
|
|
||||||
i.dot::before, i.dot::after {
|
|
||||||
position: absolute;
|
|
||||||
width: 20px;
|
|
||||||
height: 20px;
|
|
||||||
content: '';
|
|
||||||
border: 0;
|
|
||||||
background-color: white;
|
|
||||||
border-radius: 50%;
|
|
||||||
border: 5px solid #c3c3c3;
|
|
||||||
z-index: 10;
|
|
||||||
left: -15px;
|
|
||||||
bottom: -15px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
div.household__address-move {
|
|
||||||
div.household__address-move__create {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
/// complete and overwrite flex-table in chillmain.scss
|
/// complete and overwrite flex-table in chillmain.scss
|
||||||
div.list-with-period,
|
div.list-with-period,
|
||||||
div.list-household-members {
|
div.list-household-members,
|
||||||
|
div.list-household-members--summary {
|
||||||
|
|
||||||
.chill-entity__person {
|
.chill-entity__person {
|
||||||
.chill-entity__person__first-name,
|
.chill-entity__person__first-name,
|
||||||
|
@@ -1,190 +0,0 @@
|
|||||||
<template>
|
|
||||||
|
|
||||||
<h2>{{ $t('pick_social_issue') }}</h2>
|
|
||||||
|
|
||||||
|
|
||||||
<div id="awc_create_form">
|
|
||||||
|
|
||||||
<div id="picking">
|
|
||||||
<p>{{ $t('pick_social_issue_linked_with_action') }}</p>
|
|
||||||
|
|
||||||
<div v-for="si in socialIssues">
|
|
||||||
<input type="radio" v-bind:value="si.id" name="socialIssue" v-model="socialIssuePicked"> {{ si.title.fr }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-if="hasSocialIssuePicked">
|
|
||||||
<h2>{{ $t('pick_an_action') }}</h2>
|
|
||||||
|
|
||||||
<vue-multiselect
|
|
||||||
v-model="socialActionPicked"
|
|
||||||
label="text"
|
|
||||||
:options="socialActionsReachables"
|
|
||||||
:searchable="true"
|
|
||||||
:close-on-select="true"
|
|
||||||
:show-labels="true"
|
|
||||||
track-by="id"
|
|
||||||
></vue-multiselect>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-if="isLoadingSocialActions">
|
|
||||||
<p>spinner</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-if="hasSocialActionPicked" id="start_date">
|
|
||||||
<p><label>{{ $t('startDate') }}</label> <input type="date" v-model="startDate" /></p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-if="hasSocialActionPicked" id="end_date">
|
|
||||||
<p><label>{{ $t('endDate') }}</label> <input type="date" v-model="endDate" /></p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="confirm">
|
|
||||||
<div v-if="hasErrors">
|
|
||||||
<p>{{ $t('form_has_errors') }}</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li v-for="e in errors">
|
|
||||||
{{ e }}
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<ul class="record_actions">
|
|
||||||
<li class="cancel">
|
|
||||||
<a href="#" class="sc-button bt-cancel">
|
|
||||||
{{ $t('action.cancel') }}
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li v-if="hasSocialActionPicked">
|
|
||||||
<button class="sc-button bt-save" v-show="!isPostingWork" @click="submit">
|
|
||||||
{{ $t('action.save') }}
|
|
||||||
</button>
|
|
||||||
<button class="sc-button bt-save" v-show="isPostingWork" disabled>
|
|
||||||
{{ $t('Save') }}
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style lang="scss">
|
|
||||||
|
|
||||||
#awc_create_form {
|
|
||||||
display: grid;
|
|
||||||
grid-template-areas:
|
|
||||||
"picking picking"
|
|
||||||
"start_date end_date"
|
|
||||||
"confirm confirm"
|
|
||||||
;
|
|
||||||
grid-template-columns: 50% 50%;
|
|
||||||
column-gap: 1.5rem;
|
|
||||||
|
|
||||||
#picking {
|
|
||||||
grid-area: picking;
|
|
||||||
}
|
|
||||||
|
|
||||||
#start_date {
|
|
||||||
grid-area: start_date;
|
|
||||||
}
|
|
||||||
|
|
||||||
#end_date {
|
|
||||||
grid-area: end_date;
|
|
||||||
}
|
|
||||||
|
|
||||||
#confirm {
|
|
||||||
grid-area: confirm;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { mapState, mapActions, mapGetters } from 'vuex';
|
|
||||||
import VueMultiselect from 'vue-multiselect';
|
|
||||||
import { dateToISO, ISOToDate } from 'ChillMainAssets/js/date.js';
|
|
||||||
|
|
||||||
const i18n = {
|
|
||||||
messages: {
|
|
||||||
fr: {
|
|
||||||
startDate: "Date de début",
|
|
||||||
endDate: "Date de fin",
|
|
||||||
form_has_errors: "Le formulaire comporte des erreurs",
|
|
||||||
pick_social_issue: "Choisir une problématique sociale",
|
|
||||||
pick_an_action: "Choisir une action d'accompagnement",
|
|
||||||
pick_social_issue_linked_with_action: "Indiquez la problématique sociale liée à l'action d'accompagnement",
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'App',
|
|
||||||
components: {
|
|
||||||
VueMultiselect,
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
submit() {
|
|
||||||
this.$store.dispatch('submit');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
i18n,
|
|
||||||
computed: {
|
|
||||||
...mapState([
|
|
||||||
'socialIssues',
|
|
||||||
'socialActionsReachables',
|
|
||||||
'errors',
|
|
||||||
]),
|
|
||||||
...mapGetters([
|
|
||||||
'hasSocialIssuePicked',
|
|
||||||
'hasSocialActionPicked',
|
|
||||||
'isLoadingSocialActions',
|
|
||||||
'isPostingWork',
|
|
||||||
'hasErrors',
|
|
||||||
]),
|
|
||||||
socialIssuePicked: {
|
|
||||||
get() {
|
|
||||||
let s = this.$store.state.socialIssuePicked;
|
|
||||||
|
|
||||||
if (s === null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return s.id;
|
|
||||||
},
|
|
||||||
set(value) {
|
|
||||||
this.$store.dispatch('pickSocialIssue', value);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
socialActionPicked: {
|
|
||||||
get() {
|
|
||||||
return this.$store.state.socialActionPicked;
|
|
||||||
},
|
|
||||||
set(value) {
|
|
||||||
this.$store.commit('setSocialAction', value);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
startDate: {
|
|
||||||
get() {
|
|
||||||
let d = this.$store.state.startDate;
|
|
||||||
return dateToISO(d);
|
|
||||||
},
|
|
||||||
set(value) {
|
|
||||||
this.$store.commit('setStartDate', ISOToDate(value));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
endDate: {
|
|
||||||
get() {
|
|
||||||
return dateToISO(this.$store.state.endDate);
|
|
||||||
},
|
|
||||||
set(value) {
|
|
||||||
this.$store.commit('setEndDate', ISOToDate(value));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
|
@@ -1,15 +0,0 @@
|
|||||||
import { createApp } from 'vue';
|
|
||||||
import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n';
|
|
||||||
import { store } from './store';
|
|
||||||
import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n'
|
|
||||||
import App from './App.vue';
|
|
||||||
|
|
||||||
const i18n = _createI18n(personMessages);
|
|
||||||
|
|
||||||
const app = createApp({
|
|
||||||
template: `<app></app>`,
|
|
||||||
})
|
|
||||||
.use(store)
|
|
||||||
.use(i18n)
|
|
||||||
.component('app', App)
|
|
||||||
.mount('#accompanying_course_work_create');
|
|
@@ -1,155 +0,0 @@
|
|||||||
|
|
||||||
import { createStore } from 'vuex';
|
|
||||||
import { datetimeToISO } from 'ChillMainAssets/js/date.js';
|
|
||||||
import { findSocialActionsBySocialIssue } from 'ChillPersonAssets/vuejs/_api/SocialWorkSocialAction.js';
|
|
||||||
import { create } from 'ChillPersonAssets/vuejs/_api/AccompanyingCourseWork.js';
|
|
||||||
|
|
||||||
const debug = process.env.NODE_ENV !== 'production';
|
|
||||||
|
|
||||||
const store = createStore({
|
|
||||||
strict: debug,
|
|
||||||
state: {
|
|
||||||
accompanyingCourse: window.accompanyingCourse,
|
|
||||||
socialIssues: window.accompanyingCourse.socialIssues,
|
|
||||||
socialIssuePicked: null,
|
|
||||||
socialActionsReachables: [],
|
|
||||||
socialActionPicked: null,
|
|
||||||
startDate: new Date(),
|
|
||||||
endDate: null,
|
|
||||||
isLoadingSocialActions: false,
|
|
||||||
isPostingWork: false,
|
|
||||||
errors: [],
|
|
||||||
},
|
|
||||||
getters: {
|
|
||||||
hasSocialActionPicked(state) {
|
|
||||||
console.log(state.socialActionPicked);
|
|
||||||
return null !== state.socialActionPicked;
|
|
||||||
},
|
|
||||||
hasSocialIssuePicked(state) {
|
|
||||||
console.log(state.socialIssuePicked);
|
|
||||||
return null !== state.socialIssuePicked;
|
|
||||||
},
|
|
||||||
isLoadingSocialActions(state) {
|
|
||||||
return state.isLoadingSocialActions;
|
|
||||||
},
|
|
||||||
isPostingWork(state) {
|
|
||||||
return state.isPostingWork;
|
|
||||||
},
|
|
||||||
buildPayloadCreate(state) {
|
|
||||||
let payload = {
|
|
||||||
type: 'accompanying_period_work',
|
|
||||||
social_action: {
|
|
||||||
type: 'social_work_social_action',
|
|
||||||
id: state.socialActionPicked.id
|
|
||||||
},
|
|
||||||
startDate: {
|
|
||||||
datetime: datetimeToISO(state.startDate)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (null !== state.endDate) {
|
|
||||||
payload.endDate = {
|
|
||||||
datetime: datetimeToISO(state.endDate)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return payload;
|
|
||||||
},
|
|
||||||
hasErrors(state) {
|
|
||||||
return state.errors.length > 0;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
mutations: {
|
|
||||||
setSocialActionsReachables(state, actions) {
|
|
||||||
console.log('set social action reachables');
|
|
||||||
console.log(actions);
|
|
||||||
|
|
||||||
state.socialActionsReachables = actions;
|
|
||||||
},
|
|
||||||
setSocialAction(state, socialAction) {
|
|
||||||
console.log('socialAction', socialAction);
|
|
||||||
state.socialActionPicked = socialAction;
|
|
||||||
},
|
|
||||||
setSocialIssue(state, socialIssueId) {
|
|
||||||
if (socialIssueId === null) {
|
|
||||||
state.socialIssuePicked = null;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
state.socialIssuePicked = state.socialIssues
|
|
||||||
.find(e => e.id === socialIssueId);
|
|
||||||
},
|
|
||||||
setIsLoadingSocialActions(state, s) {
|
|
||||||
state.isLoadingSocialActions = s;
|
|
||||||
},
|
|
||||||
setPostingWork(state) {
|
|
||||||
state.isPostingWork = true;
|
|
||||||
},
|
|
||||||
setStartDate(state, date) {
|
|
||||||
state.startDate = date;
|
|
||||||
},
|
|
||||||
setEndDate(state, date) {
|
|
||||||
state.endDate = date;
|
|
||||||
},
|
|
||||||
addErrors(state, { errors, cancel_posting }) {
|
|
||||||
console.log('add errors', errors);
|
|
||||||
state.errors = errors;
|
|
||||||
if (cancel_posting) {
|
|
||||||
state.isPostingWork = false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
actions: {
|
|
||||||
pickSocialIssue({ commit }, socialIssueId) {
|
|
||||||
console.log('pick social issue');
|
|
||||||
|
|
||||||
commit('setIsLoadingSocialActions', true);
|
|
||||||
commit('setSocialIssue', null);
|
|
||||||
commit('setSocialActionsReachables', []);
|
|
||||||
|
|
||||||
findSocialActionsBySocialIssue(socialIssueId).then(
|
|
||||||
(response) => {
|
|
||||||
console.log(response);
|
|
||||||
console.log(response.results);
|
|
||||||
commit('setSocialIssue', socialIssueId);
|
|
||||||
commit('setSocialActionsReachables', response.results);
|
|
||||||
commit('setIsLoadingSocialActions', false);
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
console.error(err);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
submit({ commit, getters, state }) {
|
|
||||||
console.log('submit');
|
|
||||||
let
|
|
||||||
payload = getters.buildPayloadCreate,
|
|
||||||
errors = [];
|
|
||||||
|
|
||||||
commit('setPostingWork');
|
|
||||||
|
|
||||||
create(state.accompanyingCourse.id, payload)
|
|
||||||
.then( ({status, data}) => {
|
|
||||||
console.log('created return', { status, data});
|
|
||||||
if (status === 200) {
|
|
||||||
console.log('created, nothing to do here any more. Bye-bye!');
|
|
||||||
window.location.assign(`/fr/person/accompanying-period/work/${data.id}/edit`);
|
|
||||||
} else if (status === 422) {
|
|
||||||
console.log(data);
|
|
||||||
for (let i in data.violations) {
|
|
||||||
console.log(i);
|
|
||||||
console.log(data.violations[i].title);
|
|
||||||
errors.push(data.violations[i].title);
|
|
||||||
}
|
|
||||||
console.log('errors after reseponse handling', errors);
|
|
||||||
console.log({errors, cancel_posting: true});
|
|
||||||
commit('addErrors', { errors, cancel_posting: true });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
export { store };
|
|
@@ -1,119 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class='household__address-move'>
|
|
||||||
<div class='household__address-move__create'>
|
|
||||||
<div>
|
|
||||||
<h2>{{ $t('create_a_new_address') }}</h2>
|
|
||||||
<add-address
|
|
||||||
@addNewAddress="addNewAddress">
|
|
||||||
</add-address>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<show-address
|
|
||||||
v-if="newAddress"
|
|
||||||
v-bind:address="newAddress">
|
|
||||||
</show-address>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='household__address-move__valid'>
|
|
||||||
<h2>{{ $t('move_date') }}</h2>
|
|
||||||
<input
|
|
||||||
type="date"
|
|
||||||
name="validFrom"
|
|
||||||
:placeholder="$t('validFrom')"
|
|
||||||
v-model="validFrom"/>
|
|
||||||
<div v-if="errors.length > 0">
|
|
||||||
{{ errors }}
|
|
||||||
</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>
|
|
||||||
<button type="submit" class="sc-button bt-update centered" @click="addToHousehold">
|
|
||||||
{{ $t('add_an_address_to_household') }}
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
|
|
||||||
import AddAddress from 'ChillMainAssets/vuejs/_components/AddAddress.vue';
|
|
||||||
import ShowAddress from 'ChillMainAssets/vuejs/_components/ShowAddress.vue';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'App',
|
|
||||||
components: {
|
|
||||||
AddAddress,
|
|
||||||
ShowAddress
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
edit: window.mode === 'edit',
|
|
||||||
householdId: window.householdId,
|
|
||||||
backUrl: `/fr/person/household/${householdId}/addresses`, //TODO better way to pass this
|
|
||||||
validFrom: new Date().toISOString().split('T')[0]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
newAddress() {
|
|
||||||
return this.$store.state.newAddress;
|
|
||||||
},
|
|
||||||
errors() {
|
|
||||||
return this.$store.state.errorMsg;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
addNewAddress({ address, modal }) {
|
|
||||||
console.log('@@@ CLICK button addNewAdress', address);
|
|
||||||
|
|
||||||
let createdAddress = {
|
|
||||||
'isNoAddress': address.isNoAddress,
|
|
||||||
'street': address.isNoAddress ? '' : address.street,
|
|
||||||
'streetNumber': address.isNoAddress ? '' : address.streetNumber,
|
|
||||||
'postcode': {'id': address.selected.city.id},
|
|
||||||
'floor': address.floor,
|
|
||||||
'corridor': address.corridor,
|
|
||||||
'steps': address.steps,
|
|
||||||
'flat': address.flat,
|
|
||||||
'buildingName': address.buildingName,
|
|
||||||
'distribution': address.distribution,
|
|
||||||
'extra': address.extra
|
|
||||||
};
|
|
||||||
|
|
||||||
if (address.selected.address.point !== undefined){
|
|
||||||
createdAddress = Object.assign(createdAddress, {
|
|
||||||
'point': address.selected.address.point.coordinates
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if(address.writeNewPostalCode){
|
|
||||||
let newPostalCode = address.newPostalCode;
|
|
||||||
newPostalCode = Object.assign(newPostalCode, {
|
|
||||||
'country': {'id': address.selected.country.id },
|
|
||||||
});
|
|
||||||
createdAddress = Object.assign(createdAddress, {
|
|
||||||
'newPostalCode': newPostalCode
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
this.$store.dispatch('addAddress', createdAddress);
|
|
||||||
|
|
||||||
modal.showModal = false;
|
|
||||||
},
|
|
||||||
addToHousehold() {
|
|
||||||
this.$store.dispatch('addDateToAddressAndAddressToHousehold', {
|
|
||||||
householdId: this.householdId,
|
|
||||||
addressId: this.$store.state.newAddress.address_id,
|
|
||||||
body: { validFrom: {datetime: `${this.validFrom}T00:00:00+0100`}}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
@@ -1,23 +0,0 @@
|
|||||||
/*
|
|
||||||
* Endpoint household
|
|
||||||
* method POST, post Household instance
|
|
||||||
*
|
|
||||||
* @id integer - id of household
|
|
||||||
* @body Object - dictionary with changes to post
|
|
||||||
*/
|
|
||||||
export const postAddressToHousehold = (householdId, addressId) => {
|
|
||||||
const body = {
|
|
||||||
'id': addressId
|
|
||||||
};
|
|
||||||
const url = `/api/1.0/person/household/${householdId}/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');
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
@@ -1,47 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="container">
|
|
||||||
<VueMultiselect
|
|
||||||
v-model="value"
|
|
||||||
@select="selectAddress"
|
|
||||||
name="field"
|
|
||||||
track-by="id"
|
|
||||||
label="value"
|
|
||||||
:custom-label="transName"
|
|
||||||
:multiple="false"
|
|
||||||
:placeholder="$t('select_address')"
|
|
||||||
:options="addresses">
|
|
||||||
</VueMultiselect>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import VueMultiselect from 'vue-multiselect';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'SelectHouseholdAddress',
|
|
||||||
components: { VueMultiselect },
|
|
||||||
props: ['address'],
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
value: null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
addresses() {
|
|
||||||
return this.address.loaded.addresses;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
transName(value) {
|
|
||||||
return `${value.text} ${value.postcode.name}`
|
|
||||||
},
|
|
||||||
selectAddress(value) {
|
|
||||||
this.address.selected.address = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style src="vue-multiselect/dist/vue-multiselect.css"></style>
|
|
||||||
|
|
||||||
|
|
@@ -1,25 +0,0 @@
|
|||||||
import { createApp } from 'vue'
|
|
||||||
import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n'
|
|
||||||
import { appMessages } from './js/i18n'
|
|
||||||
import { store } from './store'
|
|
||||||
|
|
||||||
import App from './App.vue';
|
|
||||||
|
|
||||||
const root = window.vueRootComponent;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Load all App component, for Household edition page
|
|
||||||
*/
|
|
||||||
|
|
||||||
const i18n = _createI18n(appMessages);
|
|
||||||
|
|
||||||
const app = createApp({
|
|
||||||
template: `<app></app>`,
|
|
||||||
})
|
|
||||||
.use(store)
|
|
||||||
.use(i18n)
|
|
||||||
.component('app', App)
|
|
||||||
.mount('#household-address');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@@ -1,18 +0,0 @@
|
|||||||
import { addressMessages } from 'ChillMainAssets/vuejs/Address/js/i18n'
|
|
||||||
|
|
||||||
const appMessages = {
|
|
||||||
fr: {
|
|
||||||
select_a_existing_address: 'Sélectionner une adresse existante',
|
|
||||||
create_a_new_address: 'Créer une nouvelle adresse',
|
|
||||||
add_an_address_to_household: 'Déménager le ménage',
|
|
||||||
validFrom: 'Date du déménagement',
|
|
||||||
move_date: 'Date du déménagement',
|
|
||||||
back_to_the_list: 'Retour à la liste'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Object.assign(appMessages.fr, addressMessages.fr);
|
|
||||||
|
|
||||||
export {
|
|
||||||
appMessages
|
|
||||||
};
|
|
@@ -1,90 +0,0 @@
|
|||||||
import 'es6-promise/auto';
|
|
||||||
import { createStore } from 'vuex';
|
|
||||||
|
|
||||||
import { postAddress, postPostalCode, patchAddress } from 'ChillMainAssets/vuejs/_api/AddAddress';
|
|
||||||
import { postAddressToHousehold } from '../api';
|
|
||||||
|
|
||||||
const debug = process.env.NODE_ENV !== 'production';
|
|
||||||
|
|
||||||
const store = createStore({
|
|
||||||
strict: debug,
|
|
||||||
state: {
|
|
||||||
newAddress: {},
|
|
||||||
household: {},
|
|
||||||
validFrom: {},
|
|
||||||
errorMsg: []
|
|
||||||
},
|
|
||||||
getters: {
|
|
||||||
},
|
|
||||||
mutations: {
|
|
||||||
catchError(state, error) {
|
|
||||||
state.errorMsg.push(error);
|
|
||||||
},
|
|
||||||
addAddress(state, address) {
|
|
||||||
console.log('@M addAddress address', address);
|
|
||||||
state.newAddress = address;
|
|
||||||
},
|
|
||||||
addAddressToHousehold(state, household) {
|
|
||||||
console.log('@M addAddressToHousehold household', household);
|
|
||||||
state.household = household;
|
|
||||||
},
|
|
||||||
addDateToAddress(state, validFrom) {
|
|
||||||
console.log('@M addDateToAddress address.validFrom', validFrom);
|
|
||||||
state.validFrom = validFrom;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
actions: {
|
|
||||||
addAddress({ commit }, payload) {
|
|
||||||
console.log('@A addAddress payload', payload);
|
|
||||||
|
|
||||||
if('newPostalCode' in payload){
|
|
||||||
postPostalCode(payload.newPostalCode)
|
|
||||||
.then(postalCode => {
|
|
||||||
let body = payload;
|
|
||||||
body.postcode = {'id': postalCode.id },
|
|
||||||
postAddress(body)
|
|
||||||
.then(address => new Promise((resolve, reject) => {
|
|
||||||
commit('addAddress', address);
|
|
||||||
resolve();
|
|
||||||
}))
|
|
||||||
.catch((error) => {
|
|
||||||
commit('catchError', error);
|
|
||||||
});
|
|
||||||
})
|
|
||||||
|
|
||||||
} else {
|
|
||||||
postAddress(payload)
|
|
||||||
.then(address => new Promise((resolve, reject) => {
|
|
||||||
commit('addAddress', address);
|
|
||||||
resolve();
|
|
||||||
}))
|
|
||||||
.catch((error) => {
|
|
||||||
commit('catchError', error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
addDateToAddressAndAddressToHousehold({ commit }, payload) {
|
|
||||||
console.log('@A addDateToAddressAndAddressToHousehold payload', payload);
|
|
||||||
|
|
||||||
patchAddress(payload.addressId, payload.body)
|
|
||||||
.then(address => new Promise((resolve, reject) => {
|
|
||||||
commit('addDateToAddress', address.validFrom);
|
|
||||||
resolve();
|
|
||||||
}).then(
|
|
||||||
postAddressToHousehold(payload.householdId, payload.addressId)
|
|
||||||
.then(household => new Promise((resolve, reject) => {
|
|
||||||
commit('addAddressToHousehold', household);
|
|
||||||
resolve();
|
|
||||||
}))
|
|
||||||
.catch((error) => {
|
|
||||||
commit('catchError', error);
|
|
||||||
})
|
|
||||||
))
|
|
||||||
.catch((error) => {
|
|
||||||
commit('catchError', error);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
export { store };
|
|
@@ -1,13 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<household></household>
|
<household></household>
|
||||||
<concerned v-if="hasHouseholdOrLeave"></concerned>
|
<concerned></concerned>
|
||||||
<dates v-if="showConfirm"></dates>
|
<dates></dates>
|
||||||
<confirmation v-if="showConfirm"></confirmation>
|
<confirmation></confirmation>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import { mapGetters } from 'vuex';
|
import { mapState } from 'vuex';
|
||||||
import Concerned from './components/Concerned.vue';
|
import Concerned from './components/Concerned.vue';
|
||||||
import Household from './components/Household.vue';
|
import Household from './components/Household.vue';
|
||||||
import Dates from './components/Dates.vue';
|
import Dates from './components/Dates.vue';
|
||||||
@@ -22,14 +22,11 @@ export default {
|
|||||||
Confirmation,
|
Confirmation,
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters([
|
// for debugging purpose
|
||||||
'hasHouseholdOrLeave',
|
// (not working)
|
||||||
'hasPersonsWellPositionnated',
|
//...mapState({
|
||||||
]),
|
// 'concerned', 'household', 'positions'
|
||||||
showConfirm () {
|
// })
|
||||||
return this.$store.getters.hasHouseholdOrLeave
|
|
||||||
&& this.$store.getters.hasPersonsWellPositionnated;
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,13 +16,32 @@ const householdMove = (payload) => {
|
|||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
return response.json();
|
return response.json();
|
||||||
}
|
}
|
||||||
|
throw Error('Error with testing move');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const householdMoveTest = (payload) => {
|
||||||
|
const url = `/api/1.0/person/household/members/move/test.json`;
|
||||||
|
return fetch(url, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
body: JSON.stringify(payload),
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
if (response.status === 422) {
|
if (response.status === 422) {
|
||||||
return response.json();
|
return response.json();
|
||||||
}
|
}
|
||||||
|
if (response.ok) {
|
||||||
|
// return an empty array if ok
|
||||||
|
return new Promise((resolve, reject) => resolve({ violations: [] }) );
|
||||||
|
}
|
||||||
throw Error('Error with testing move');
|
throw Error('Error with testing move');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export {
|
export {
|
||||||
householdMove,
|
householdMove,
|
||||||
|
householdMoveTest
|
||||||
};
|
};
|
||||||
|
@@ -21,13 +21,16 @@
|
|||||||
<div v-for="conc in concUnpositionned"
|
<div v-for="conc in concUnpositionned"
|
||||||
class="item-bloc"
|
class="item-bloc"
|
||||||
v-bind:key="conc.person.id"
|
v-bind:key="conc.person.id"
|
||||||
|
draggable="true"
|
||||||
|
@dragstart="onStartDragConcern($event, conc.person.id)"
|
||||||
>
|
>
|
||||||
<div class="item-row person">
|
<div class="item-row person">
|
||||||
<div class="item-col box-person">
|
<div class="item-col box-person">
|
||||||
<div>
|
<div>
|
||||||
|
<img src="~ChillMainAssets/img/draggable.svg" class="drag-icon" />
|
||||||
<person :person="conc.person"></person>
|
<person :person="conc.person"></person>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="conc.person.birthdate !== null">
|
<div>
|
||||||
{{ $t('person.born', {'gender': conc.person.gender} ) }}
|
{{ $t('person.born', {'gender': conc.person.gender} ) }}
|
||||||
{{ $d(conc.person.birthdate.datetime, 'short') }}
|
{{ $d(conc.person.birthdate.datetime, 'short') }}
|
||||||
</div>
|
</div>
|
||||||
@@ -86,18 +89,21 @@
|
|||||||
v-for="position in positions"
|
v-for="position in positions"
|
||||||
>
|
>
|
||||||
<h3>{{ position.label.fr }}</h3>
|
<h3>{{ position.label.fr }}</h3>
|
||||||
|
<div class="flex-table list-household-members">
|
||||||
<div v-if="concByPosition(position.id).length > 0" class="flex-table list-household-members">
|
|
||||||
<member-details
|
<member-details
|
||||||
v-for="conc in concByPosition(position.id)"
|
v-for="conc in concByPosition(position.id)"
|
||||||
v-bind:key="conc.person.id"
|
v-bind:key="conc.person.id"
|
||||||
v-bind:conc="conc"
|
v-bind:conc="conc"
|
||||||
>
|
>
|
||||||
</member-details>
|
</member-details>
|
||||||
</div>
|
<div
|
||||||
|
class="droppable_zone"
|
||||||
<div v-else>
|
@drop="onDropConcern($event, position.id)"
|
||||||
<p class="chill-no-data-statement">{{ $t('household_members_editor.concerned.no_person_in_position') }}</p>
|
@dragover.prevent
|
||||||
|
@dragenter.prevent
|
||||||
|
>
|
||||||
|
{{ $t('household_members_editor.drop_persons_here', {'position': position.label.fr }) }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -114,6 +120,22 @@ div.person {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.drag-icon {
|
||||||
|
height: 1.1em;
|
||||||
|
margin-right: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.droppable_zone {
|
||||||
|
background-color: var(--chill-llight-gray);
|
||||||
|
color: white;
|
||||||
|
font-size: large;
|
||||||
|
text-align: center;
|
||||||
|
display: table-cell;
|
||||||
|
vertical-align: middle;
|
||||||
|
padding: 1em;
|
||||||
|
background: linear-gradient(to top, var(--chill-light-gray), 30%, var(--chill-llight-gray));
|
||||||
|
}
|
||||||
|
|
||||||
.move_to {
|
.move_to {
|
||||||
.move_hint {
|
.move_hint {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
@@ -172,8 +194,18 @@ export default {
|
|||||||
this.$refs.addPersons.resetSearch(); // to cast child method
|
this.$refs.addPersons.resetSearch(); // to cast child method
|
||||||
modal.showModal = false;
|
modal.showModal = false;
|
||||||
},
|
},
|
||||||
|
onStartDragConcern(evt, person_id) {
|
||||||
|
evt.dataTransfer.dropEffect = 'move'
|
||||||
|
evt.dataTransfer.effectAllowed = 'move'
|
||||||
|
evt.dataTransfer.setData('application/x.person', person_id)
|
||||||
|
},
|
||||||
|
onDropConcern(evt, position_id) {
|
||||||
|
const person_id = Number(evt.dataTransfer.getData('application/x.person'));
|
||||||
|
this.moveToPosition(person_id, position_id);
|
||||||
|
},
|
||||||
moveToPosition(person_id, position_id) {
|
moveToPosition(person_id, position_id) {
|
||||||
this.$store.dispatch('markPosition', { person_id, position_id });
|
this.$store.dispatch('markPosition', { person_id, position_id });
|
||||||
|
|
||||||
},
|
},
|
||||||
removeConcerned(conc) {
|
removeConcerned(conc) {
|
||||||
this.$store.dispatch('removeConcerned', conc);
|
this.$store.dispatch('removeConcerned', conc);
|
||||||
|
@@ -12,9 +12,6 @@
|
|||||||
<li v-for="(msg, index) in warnings">
|
<li v-for="(msg, index) in warnings">
|
||||||
{{ $t(msg.m, msg.a) }}
|
{{ $t(msg.m, msg.a) }}
|
||||||
</li>
|
</li>
|
||||||
<li v-for="msg in errors">
|
|
||||||
{{ msg }}
|
|
||||||
</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<ul class="record_actions sticky-form-buttons">
|
<ul class="record_actions sticky-form-buttons">
|
||||||
@@ -37,9 +34,8 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
warnings: (state) => state.warnings,
|
warnings: (state) => state.warnings,
|
||||||
errors: (state) => state.errors,
|
hasNoWarnings: (state) => state.warnings.length === 0,
|
||||||
hasNoWarnings: (state) => state.warnings.length === 0 && state.errors.length === 0,
|
hasWarnings: (state) => state.warnings.length > 0,
|
||||||
hasWarnings: (state) => state.warnings.length > 0 || state.errors.length > 0,
|
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@@ -2,8 +2,11 @@
|
|||||||
<h2>{{ $t('household_members_editor.household_part') }}</h2>
|
<h2>{{ $t('household_members_editor.household_part') }}</h2>
|
||||||
|
|
||||||
<div v-if="hasHousehold">
|
<div v-if="hasHousehold">
|
||||||
<div>
|
<span v-if="isHouseholdNew">
|
||||||
<household-viewer :household="household"></household-viewer>
|
{{ $t('household_members_editor.household.new_household') }}
|
||||||
|
</span>
|
||||||
|
<div v-else>
|
||||||
|
Ménage existant
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="isForceLeaveWithoutHousehold">
|
<div v-else-if="isForceLeaveWithoutHousehold">
|
||||||
@@ -36,20 +39,16 @@
|
|||||||
<script>
|
<script>
|
||||||
|
|
||||||
import { mapGetters } from 'vuex';
|
import { mapGetters } from 'vuex';
|
||||||
import HouseholdViewer from 'ChillPersonAssets/vuejs/_components/Household/Household.vue';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Household',
|
name: 'Household',
|
||||||
components: {
|
|
||||||
HouseholdViewer,
|
|
||||||
},
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters([
|
...mapGetters([
|
||||||
'hasHousehold',
|
'hasHousehold',
|
||||||
'isHouseholdNew',
|
'isHouseholdNew',
|
||||||
]),
|
]),
|
||||||
household() {
|
household() {
|
||||||
return this.$store.state.household;
|
return this.$store.household;
|
||||||
},
|
},
|
||||||
allowHouseholdCreate() {
|
allowHouseholdCreate() {
|
||||||
return this.$store.state.allowHouseholdCreate;
|
return this.$store.state.allowHouseholdCreate;
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
{{ $t('household_members_editor.holder') }}
|
{{ $t('household_members_editor.holder') }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="conc.person.birthdate !== null">{{ $t('person.born', {'gender': conc.person.gender} ) }}</div>
|
<div>{{ $t('person.born', {'gender': conc.person.gender} ) }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="item-col box-where">
|
<div class="item-col box-where">
|
||||||
<ul class="list-content fa-ul">
|
<ul class="list-content fa-ul">
|
||||||
|
@@ -19,13 +19,12 @@ const appMessages = {
|
|||||||
move_to: "Déplacer vers",
|
move_to: "Déplacer vers",
|
||||||
persons_to_positionnate: 'Usagers à positionner',
|
persons_to_positionnate: 'Usagers à positionner',
|
||||||
persons_leaving: "Usagers quittant leurs ménages",
|
persons_leaving: "Usagers quittant leurs ménages",
|
||||||
no_person_in_position: "Aucun usager ne sera ajouté à cette position",
|
|
||||||
},
|
},
|
||||||
drop_persons_here: "Glissez-déposez ici les usagers pour la position \"{position}\"",
|
drop_persons_here: "Glissez-déposez ici les usagers pour la position \"{position}\"",
|
||||||
all_positionnated: "Tous les usagers sont positionnés",
|
all_positionnated: "Tous les usagers sont positionnés",
|
||||||
holder: "Titulaire",
|
holder: "Titulaire",
|
||||||
is_holder: "Est titulaire",
|
is_holder: "Sera titulaire",
|
||||||
is_not_holder: "N'est pas titulaire",
|
is_not_holder: "Ne sera pas titulaire",
|
||||||
remove_position: "Retirer des {position}",
|
remove_position: "Retirer des {position}",
|
||||||
remove_concerned: "Ne plus transférer",
|
remove_concerned: "Ne plus transférer",
|
||||||
household_part: "Ménage de destination",
|
household_part: "Ménage de destination",
|
||||||
|
@@ -19,22 +19,13 @@ const store = createStore({
|
|||||||
state: {
|
state: {
|
||||||
concerned,
|
concerned,
|
||||||
household: window.household_members_editor_data.household,
|
household: window.household_members_editor_data.household,
|
||||||
positions: window.household_members_editor_data.positions.sort((a, b) => {
|
positions: window.household_members_editor_data.positions,
|
||||||
if (a.ordering < b.ordering) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (a.ordering > b.ordering) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}),
|
|
||||||
startDate: new Date(),
|
startDate: new Date(),
|
||||||
allowHouseholdCreate: window.household_members_editor_data.allowHouseholdCreate,
|
allowHouseholdCreate: window.household_members_editor_data.allowHouseholdCreate,
|
||||||
allowHouseholdSearch: window.household_members_editor_data.allowHouseholdSearch,
|
allowHouseholdSearch: window.household_members_editor_data.allowHouseholdSearch,
|
||||||
allowLeaveWithoutHousehold: window.household_members_editor_data.allowLeaveWithoutHousehold,
|
allowLeaveWithoutHousehold: window.household_members_editor_data.allowLeaveWithoutHousehold,
|
||||||
forceLeaveWithoutHousehold: false,
|
forceLeaveWithoutHousehold: false,
|
||||||
warnings: [],
|
warnings: [],
|
||||||
errors: []
|
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
isHouseholdNew(state) {
|
isHouseholdNew(state) {
|
||||||
@@ -43,13 +34,6 @@ const store = createStore({
|
|||||||
hasHousehold(state) {
|
hasHousehold(state) {
|
||||||
return state.household !== null;
|
return state.household !== null;
|
||||||
},
|
},
|
||||||
hasHouseholdOrLeave(state) {
|
|
||||||
return state.household !== null || state.forceLeaveWithoutHousehold;
|
|
||||||
},
|
|
||||||
hasPersonsWellPositionnated(state, getters) {
|
|
||||||
return getters.needsPositionning === false
|
|
||||||
|| (getters.persons.length > 0 && getters.concUnpositionned.length === 0);
|
|
||||||
},
|
|
||||||
persons(state) {
|
persons(state) {
|
||||||
return state.concerned.map(conc => conc.person);
|
return state.concerned.map(conc => conc.person);
|
||||||
},
|
},
|
||||||
@@ -165,7 +149,7 @@ const store = createStore({
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
createHousehold(state) {
|
createHousehold(state) {
|
||||||
state.household = { type: 'household', members: [], current_address: null }
|
state.household = { type: 'household', members: [], address: null }
|
||||||
state.forceLeaveWithoutHousehold = false;
|
state.forceLeaveWithoutHousehold = false;
|
||||||
},
|
},
|
||||||
forceLeaveWithoutHousehold(state) {
|
forceLeaveWithoutHousehold(state) {
|
||||||
@@ -177,11 +161,6 @@ const store = createStore({
|
|||||||
},
|
},
|
||||||
setWarnings(state, warnings) {
|
setWarnings(state, warnings) {
|
||||||
state.warnings = warnings;
|
state.warnings = warnings;
|
||||||
// reset errors, which should come from servers
|
|
||||||
state.errors.splice(0, state.errors.length);
|
|
||||||
},
|
|
||||||
setErrors(state, errors) {
|
|
||||||
state.errors = errors;
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
@@ -193,9 +172,8 @@ const store = createStore({
|
|||||||
commit('markPosition', { person_id, position_id });
|
commit('markPosition', { person_id, position_id });
|
||||||
dispatch('computeWarnings');
|
dispatch('computeWarnings');
|
||||||
},
|
},
|
||||||
toggleHolder({ commit, dispatch }, conc) {
|
toggleHolder({ commit }, conc) {
|
||||||
commit('toggleHolder', conc);
|
commit('toggleHolder', conc);
|
||||||
dispatch('computeWarnings');
|
|
||||||
},
|
},
|
||||||
removePosition({ commit, dispatch }, conc) {
|
removePosition({ commit, dispatch }, conc) {
|
||||||
commit('removePosition', conc);
|
commit('removePosition', conc);
|
||||||
@@ -213,9 +191,8 @@ const store = createStore({
|
|||||||
commit('forceLeaveWithoutHousehold');
|
commit('forceLeaveWithoutHousehold');
|
||||||
dispatch('computeWarnings');
|
dispatch('computeWarnings');
|
||||||
},
|
},
|
||||||
setStartDate({ commit, dispatch }, date) {
|
setStartDate({ commit }, date) {
|
||||||
commit('setStartDate', date);
|
commit('setStartDate', date);
|
||||||
dispatch('computeWarnings');
|
|
||||||
},
|
},
|
||||||
setComment({ commit }, payload) {
|
setComment({ commit }, payload) {
|
||||||
commit('setComment', payload);
|
commit('setComment', payload);
|
||||||
@@ -239,34 +216,19 @@ const store = createStore({
|
|||||||
|
|
||||||
commit('setWarnings', warnings);
|
commit('setWarnings', warnings);
|
||||||
},
|
},
|
||||||
confirm({ getters, state, commit }) {
|
confirm({ getters, state }) {
|
||||||
let payload = getters.buildPayload,
|
let payload = getters.buildPayload,
|
||||||
errors = [],
|
|
||||||
person_id,
|
person_id,
|
||||||
household_id,
|
household_id;
|
||||||
error
|
householdMove(payload).then(household => {
|
||||||
;
|
if (household === null) {
|
||||||
|
person_id = getters.persons[0].id;
|
||||||
householdMove(payload).then(household => {
|
window.location.replace(`/fr/person/${person_id}/general`);
|
||||||
if (household === null) {
|
} else {
|
||||||
person_id = getters.persons[0].id;
|
household_id = household.id;
|
||||||
window.location.replace(`/fr/person/${person_id}/general`);
|
// nothing to do anymore here, bye-bye !
|
||||||
} else {
|
window.location.replace(`/fr/person/household/${household_id}/members`);
|
||||||
if (household.type === 'household') {
|
}
|
||||||
household_id = household.id;
|
|
||||||
// nothing to do anymore here, bye-bye !
|
|
||||||
window.location.replace(`/fr/person/household/${household_id}/members`);
|
|
||||||
} else {
|
|
||||||
// we assume the answer was 422...
|
|
||||||
error = household;
|
|
||||||
for (let i in error.violations) {
|
|
||||||
let e = error.violations[i];
|
|
||||||
errors.push(e.title);
|
|
||||||
}
|
|
||||||
|
|
||||||
commit('setErrors', errors);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@@ -1,30 +0,0 @@
|
|||||||
const create = (accompanying_period_id, payload) => {
|
|
||||||
const url = `/api/1.0/person/accompanying-course/${accompanying_period_id}/work.json`;
|
|
||||||
let status;
|
|
||||||
console.log('create', payload);
|
|
||||||
|
|
||||||
return fetch(url, {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
body: JSON.stringify(payload),
|
|
||||||
})
|
|
||||||
.then(response => {
|
|
||||||
if (response.ok || response.status === 422) {
|
|
||||||
status = response.status;
|
|
||||||
|
|
||||||
return response.json();
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new Error("Error while retrieving social actions: " + response.status +
|
|
||||||
" " + response.statusText);
|
|
||||||
})
|
|
||||||
.then(data => {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
resolve({ status, data });
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export { create };
|
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user