mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge branch 'master' of gitlab.com:Chill-Projet/chill-bundles
This commit is contained in:
commit
bf0ad88cf0
22
CHANGELOG.md
22
CHANGELOG.md
@ -11,13 +11,19 @@ and this project adheres to
|
|||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
<!-- write down unreleased development here -->
|
<!-- write down unreleased development here -->
|
||||||
|
* unnecessary whitespace removed from person banner after person-id + double parentheses removed (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/290)
|
||||||
|
* [person]: delete accompanying period work, including related objects (cascade) (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/36)
|
||||||
|
* [address]: Display of incomplete address adjusted.
|
||||||
|
* [household]: improve relationship graph
|
||||||
|
* add form to create/edit/delete relationship link,
|
||||||
|
* improve graph refresh mechanism
|
||||||
|
* add feature to export canvas as image (png)
|
||||||
|
|
||||||
## Test releases
|
## Test releases
|
||||||
|
|
||||||
### Test release 2021-11-08
|
### Test release 2021-11-08
|
||||||
|
|
||||||
|
* [person]: Display the name of a user when searching after a User (TMS)
|
||||||
* [person]: Add civility to the person
|
* [person]: Add civility to the person
|
||||||
* [person]: Various improvements on the edit person form
|
* [person]: Various improvements on the edit person form
|
||||||
* [person]: Set available_languages and available_countries as parameters for use in the edit person form
|
* [person]: Set available_languages and available_countries as parameters for use in the edit person form
|
||||||
@ -42,10 +48,9 @@ and this project adheres to
|
|||||||
* [tasks]: different layout for task list / my tasks, and fix link to tasks in alert or in warning
|
* [tasks]: different layout for task list / my tasks, and fix link to tasks in alert or in warning
|
||||||
* [admin]: links to activity admin section added again.
|
* [admin]: links to activity admin section added again.
|
||||||
* [household]: household addresses ordered by ValidFrom date and by id to show the last created address on top.
|
* [household]: household addresses ordered by ValidFrom date and by id to show the last created address on top.
|
||||||
* [socialWorkAction]: display of social issue and parent issues + banner context added.
|
* [socialWorkAction]: display of social issue and parent issues + banner context added.
|
||||||
* [DBAL dependencies] Upgrade to DBAL 3.1
|
* [DBAL dependencies] Upgrade to DBAL 3.1
|
||||||
|
|
||||||
|
|
||||||
### Test release 2021-10-27
|
### Test release 2021-10-27
|
||||||
|
|
||||||
* [person]: delete double actions buttons on search person page
|
* [person]: delete double actions buttons on search person page
|
||||||
@ -63,7 +68,10 @@ and this project adheres to
|
|||||||
* [3party]: fix address creation
|
* [3party]: fix address creation
|
||||||
* [household members editor] finalisation of editor
|
* [household members editor] finalisation of editor
|
||||||
* [AccompanyingCourse banner]: replace translation referrer (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/70)
|
* [AccompanyingCourse banner]: replace translation referrer (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/70)
|
||||||
* [Location]: add location system in activity and RV (calendar). User can choose in location list or create a new location.
|
* [Location]: add location system in activity and RV (calendar). User can choose in location list or create a new location.
|
||||||
|
* [household]: add relationship page with dynamic data visualisation graph
|
||||||
|
|
||||||
|
## Test releases
|
||||||
|
|
||||||
### Test release 2021-10-11
|
### Test release 2021-10-11
|
||||||
|
|
||||||
@ -130,7 +138,7 @@ and this project adheres to
|
|||||||
|
|
||||||
## Test released
|
## Test released
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
Coming soon...
|
Coming soon...
|
||||||
|
|
||||||
@ -143,4 +151,4 @@ DO NOT ADD unreleased items here. Add them under "Unreleased" title
|
|||||||
## Stable releases
|
## Stable releases
|
||||||
|
|
||||||
No stable releases for v2+
|
No stable releases for v2+
|
||||||
|
|
||||||
|
@ -905,11 +905,6 @@ parameters:
|
|||||||
count: 1
|
count: 1
|
||||||
path: src/Bundle/ChillMainBundle/Timeline/TimelineBuilder.php
|
path: src/Bundle/ChillMainBundle/Timeline/TimelineBuilder.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Call to function array_search\\(\\) requires parameter \\#3 to be set\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: src/Bundle/ChillMainBundle/Util/DateRangeCovering.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
|
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
|
||||||
count: 2
|
count: 2
|
||||||
|
@ -40,7 +40,6 @@
|
|||||||
},
|
},
|
||||||
{ 'title': 'Users concerned'|trans,
|
{ 'title': 'Users concerned'|trans,
|
||||||
'items': entity.users,
|
'items': entity.users,
|
||||||
'path' : 'admin_user_show',
|
|
||||||
'key' : 'id'
|
'key' : 'id'
|
||||||
},
|
},
|
||||||
] %}
|
] %}
|
||||||
@ -58,6 +57,7 @@
|
|||||||
<ul class="list-content">
|
<ul class="list-content">
|
||||||
{% for item in bloc.items %}
|
{% for item in bloc.items %}
|
||||||
<li>
|
<li>
|
||||||
|
{% if bloc.path is defined %}
|
||||||
<a href="{{ _self.href(bloc.path, bloc.key, item.id) }}">
|
<a href="{{ _self.href(bloc.path, bloc.key, item.id) }}">
|
||||||
<span class="{% if (badge_person is defined and badge_person == true) %}badge-person{% else %}badge bg-primary{% endif %}">
|
<span class="{% if (badge_person is defined and badge_person == true) %}badge-person{% else %}badge bg-primary{% endif %}">
|
||||||
{{ item|chill_entity_render_box({
|
{{ item|chill_entity_render_box({
|
||||||
@ -66,6 +66,14 @@
|
|||||||
}) }}
|
}) }}
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
|
{% else %}
|
||||||
|
<span class="{% if (badge_person is defined and badge_person == true) %}badge-person{% else %}badge bg-primary{% endif %}">
|
||||||
|
{{ item|chill_entity_render_box({
|
||||||
|
'render': 'raw',
|
||||||
|
'addAltNames': false
|
||||||
|
}) }}
|
||||||
|
</span>
|
||||||
|
{% endif %}
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
@ -85,6 +93,7 @@
|
|||||||
<ul class="list-content">
|
<ul class="list-content">
|
||||||
{% for item in bloc.items %}
|
{% for item in bloc.items %}
|
||||||
<li>
|
<li>
|
||||||
|
{% if bloc.path is defined %}
|
||||||
<a href="{{ _self.href(bloc.path, bloc.key, item.id) }}">
|
<a href="{{ _self.href(bloc.path, bloc.key, item.id) }}">
|
||||||
<span class="{% if (badge_person is defined and badge_person == true) %}badge-person{% else %}badge bg-primary{% endif %}">
|
<span class="{% if (badge_person is defined and badge_person == true) %}badge-person{% else %}badge bg-primary{% endif %}">
|
||||||
{{ item|chill_entity_render_box({
|
{{ item|chill_entity_render_box({
|
||||||
@ -93,6 +102,12 @@
|
|||||||
}) }}
|
}) }}
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
|
{% else %}
|
||||||
|
{{ item|chill_entity_render_box({
|
||||||
|
'render': 'raw',
|
||||||
|
'addAltNames': false
|
||||||
|
}) }}
|
||||||
|
{% endif %}
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
@ -114,12 +129,19 @@
|
|||||||
{% for item in bloc.items %}
|
{% for item in bloc.items %}
|
||||||
|
|
||||||
<span class="wl-item {% if (badge_person is defined and badge_person == true) %}badge-person{% else %}badge bg-primary{% endif %}">
|
<span class="wl-item {% if (badge_person is defined and badge_person == true) %}badge-person{% else %}badge bg-primary{% endif %}">
|
||||||
|
{% if bloc.path is defined %}
|
||||||
<a href="{{ _self.href(bloc.path, bloc.key, item.id) }}">
|
<a href="{{ _self.href(bloc.path, bloc.key, item.id) }}">
|
||||||
{{ item|chill_entity_render_box({
|
{{ item|chill_entity_render_box({
|
||||||
'render': 'raw',
|
'render': 'raw',
|
||||||
'addAltNames': false
|
'addAltNames': false
|
||||||
}) }}
|
}) }}
|
||||||
</a>
|
</a>
|
||||||
|
{% else %}
|
||||||
|
{{ item|chill_entity_render_box({
|
||||||
|
'render': 'raw',
|
||||||
|
'addAltNames': false
|
||||||
|
}) }}
|
||||||
|
{% endif %}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
'title' : 'Remove activity'|trans,
|
'title' : 'Remove activity'|trans,
|
||||||
'confirm_question' : 'Are you sure you want to remove the activity about "%name%" ?'|trans({ '%name%' : accompanyingCourse.id } ),
|
'confirm_question' : 'Are you sure you want to remove the activity about "%name%" ?'|trans({ '%name%' : accompanyingCourse.id } ),
|
||||||
'cancel_route' : 'chill_activity_activity_list',
|
'cancel_route' : 'chill_activity_activity_list',
|
||||||
'cancel_parameters' : { 'accompanying_course_id' : accompanyingCourse.id, 'id' : activity.id },
|
'cancel_parameters' : { 'accompanying_period_id' : accompanyingCourse.id, 'id' : activity.id },
|
||||||
'form' : delete_form
|
'form' : delete_form
|
||||||
} ) }}
|
} ) }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -45,7 +45,8 @@ const messages = {
|
|||||||
redirect: {
|
redirect: {
|
||||||
person: "Quitter la page et ouvrir la fiche de l'usager",
|
person: "Quitter la page et ouvrir la fiche de l'usager",
|
||||||
thirdparty: "Quitter la page et voir le tiers",
|
thirdparty: "Quitter la page et voir le tiers",
|
||||||
}
|
},
|
||||||
|
refresh: 'Rafraîchir'
|
||||||
},
|
},
|
||||||
nav: {
|
nav: {
|
||||||
next: "Suivant",
|
next: "Suivant",
|
||||||
|
@ -58,6 +58,13 @@
|
|||||||
|
|
||||||
{% macro inline(address, options) %}
|
{% macro inline(address, options) %}
|
||||||
{% if options['has_no_address'] == true and address.isNoAddress == true %}
|
{% if options['has_no_address'] == true and address.isNoAddress == true %}
|
||||||
|
{% if address.postCode is not empty %}
|
||||||
|
<p class="postcode">
|
||||||
|
<span class="code">{{ address.postCode.code }}</span>
|
||||||
|
<span class="name">{{ address.postCode.name }}</span>
|
||||||
|
</p>
|
||||||
|
<p class="country">{{ address.postCode.country.name|localize_translatable_string }}</p>
|
||||||
|
{% endif %}
|
||||||
<span class="noaddress">
|
<span class="noaddress">
|
||||||
{{ 'address.consider homeless'|trans }}
|
{{ 'address.consider homeless'|trans }}
|
||||||
</span>
|
</span>
|
||||||
@ -108,9 +115,19 @@
|
|||||||
{%- if render == 'bloc' -%}
|
{%- if render == 'bloc' -%}
|
||||||
<div class="chill-entity entity-address">
|
<div class="chill-entity entity-address">
|
||||||
{% if options['has_no_address'] == true and address.isNoAddress == true %}
|
{% if options['has_no_address'] == true and address.isNoAddress == true %}
|
||||||
|
{% if address.postCode is not empty %}
|
||||||
|
<div class="address{% if options['multiline'] %} multiline{% endif %}{% if options['with_delimiter'] %} delimiter{% endif %}">
|
||||||
|
<p class="postcode">
|
||||||
|
<span class="code">{{ address.postCode.code }}</span>
|
||||||
|
<span class="name">{{ address.postCode.name }}</span>
|
||||||
|
</p>
|
||||||
|
<p class="country">{{ address.postCode.country.name|localize_translatable_string }}</p>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
<div class="noaddress">
|
<div class="noaddress">
|
||||||
{{ 'address.consider homeless'|trans }}
|
{{ 'address.consider homeless'|trans }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="address{% if options['multiline'] %} multiline{% endif %}{% if options['with_delimiter'] %} delimiter{% endif %}">
|
<div class="address{% if options['multiline'] %} multiline{% endif %}{% if options['with_delimiter'] %} delimiter{% endif %}">
|
||||||
{% if options['with_picto'] %}
|
{% if options['with_picto'] %}
|
||||||
|
@ -37,6 +37,18 @@ class DateRangeCoveringTest extends TestCase
|
|||||||
$this->assertNotContains(3, $cover->getIntersections()[0][2]);
|
$this->assertNotContains(3, $cover->getIntersections()[0][2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testCoveringWithMinCover1_NoCoveringWithNullDates()
|
||||||
|
{
|
||||||
|
$cover = new DateRangeCovering(1, new \DateTimeZone('Europe/Brussels'));
|
||||||
|
$cover
|
||||||
|
->add(new \DateTime('2021-10-05'), new \DateTime('2021-10-18'), 521)
|
||||||
|
->add(new \DateTime('2021-10-26'), null, 663)
|
||||||
|
->compute()
|
||||||
|
;
|
||||||
|
|
||||||
|
$this->assertFalse($cover->hasIntersections());
|
||||||
|
}
|
||||||
|
|
||||||
public function testCoveringWithMinCover1WithTwoIntersections()
|
public function testCoveringWithMinCover1WithTwoIntersections()
|
||||||
{
|
{
|
||||||
$cover = new DateRangeCovering(1, new \DateTimeZone('Europe/Brussels'));
|
$cover = new DateRangeCovering(1, new \DateTimeZone('Europe/Brussels'));
|
||||||
|
@ -140,67 +140,6 @@ class DateRangeCovering
|
|||||||
return $this;
|
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
|
public function hasIntersections(): bool
|
||||||
{
|
{
|
||||||
if (!$this->computed) {
|
if (!$this->computed) {
|
||||||
|
@ -74,7 +74,7 @@ Choose a postal code: Choisir un code postal
|
|||||||
address:
|
address:
|
||||||
address_homeless: L'adresse est-elle celle d'un domicile fixe ?
|
address_homeless: L'adresse est-elle celle d'un domicile fixe ?
|
||||||
real address: Adresse d'un domicile
|
real address: Adresse d'un domicile
|
||||||
consider homeless: N'est pas l'adresse d'un domicile (SDF)
|
consider homeless: Cette adresse est incomplète
|
||||||
address more:
|
address more:
|
||||||
floor: ét
|
floor: ét
|
||||||
corridor: coul
|
corridor: coul
|
||||||
|
@ -24,7 +24,9 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\Resource;
|
|||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment;
|
||||||
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
||||||
use Chill\MainBundle\Entity\Scope;
|
use Chill\MainBundle\Entity\Scope;
|
||||||
|
use Chill\PersonBundle\Repository\AccompanyingPeriodACLAwareRepository;
|
||||||
use Symfony\Component\Workflow\Registry;
|
use Symfony\Component\Workflow\Registry;
|
||||||
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||||
|
|
||||||
class AccompanyingCourseApiController extends ApiController
|
class AccompanyingCourseApiController extends ApiController
|
||||||
{
|
{
|
||||||
@ -40,11 +42,13 @@ class AccompanyingCourseApiController extends ApiController
|
|||||||
EventDispatcherInterface $eventDispatcher,
|
EventDispatcherInterface $eventDispatcher,
|
||||||
ValidatorInterface $validator,
|
ValidatorInterface $validator,
|
||||||
Registry $registry,
|
Registry $registry,
|
||||||
|
AccompanyingPeriodACLAwareRepository $accompanyingPeriodACLAwareRepository,
|
||||||
ReferralsSuggestionInterface $referralAvailable
|
ReferralsSuggestionInterface $referralAvailable
|
||||||
) {
|
) {
|
||||||
$this->eventDispatcher = $eventDispatcher;
|
$this->eventDispatcher = $eventDispatcher;
|
||||||
$this->validator = $validator;
|
$this->validator = $validator;
|
||||||
$this->registry = $registry;
|
$this->registry = $registry;
|
||||||
|
$this->accompanyingPeriodACLAwareRepository = $accompanyingPeriodACLAwareRepository;
|
||||||
$this->referralAvailable = $referralAvailable;
|
$this->referralAvailable = $referralAvailable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,10 +58,14 @@ class AccompanyingCourseApiController extends ApiController
|
|||||||
$accompanyingPeriod = $this->getEntity('participation', $id, $request);
|
$accompanyingPeriod = $this->getEntity('participation', $id, $request);
|
||||||
|
|
||||||
$this->checkACL('confirm', $request, $_format, $accompanyingPeriod);
|
$this->checkACL('confirm', $request, $_format, $accompanyingPeriod);
|
||||||
$workflow = $this->registry->get($accompanyingPeriod);
|
$workflow = $this->registry->get($accompanyingPeriod);
|
||||||
|
|
||||||
if (FALSE === $workflow->can($accompanyingPeriod, 'confirm')) {
|
if (FALSE === $workflow->can($accompanyingPeriod, 'confirm')) {
|
||||||
throw new BadRequestException('It is not possible to confirm this period');
|
// throw new BadRequestException('It is not possible to confirm this period');
|
||||||
|
$errors = $this->validator->validate($accompanyingPeriod, null, [$accompanyingPeriod::STEP_CONFIRMED]);
|
||||||
|
if( count($errors) > 0 ){
|
||||||
|
return $this->json($errors, 422);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$workflow->apply($accompanyingPeriod, 'confirm');
|
$workflow->apply($accompanyingPeriod, 'confirm');
|
||||||
@ -109,6 +117,13 @@ $workflow = $this->registry->get($accompanyingPeriod);
|
|||||||
|
|
||||||
public function resourceApi($id, Request $request, string $_format): Response
|
public function resourceApi($id, Request $request, string $_format): Response
|
||||||
{
|
{
|
||||||
|
$accompanyingPeriod = $this->getEntity('resource', $id, $request);
|
||||||
|
$errors = $this->validator->validate($accompanyingPeriod);
|
||||||
|
|
||||||
|
if ($errors->count() > 0) {
|
||||||
|
return $this->json($errors, 422);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->addRemoveSomething('resource', $id, $request, $_format, 'resource', Resource::class);
|
return $this->addRemoveSomething('resource', $id, $request, $_format, 'resource', Resource::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,6 +213,18 @@ $workflow = $this->registry->get($accompanyingPeriod);
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ParamConverter("person", options={"id" = "person_id"})
|
||||||
|
*/
|
||||||
|
public function getAccompanyingPeriodsByPerson(Person $person){
|
||||||
|
$accompanyingPeriods = $person->getCurrentAccompanyingPeriods();
|
||||||
|
$accompanyingPeriodsChecked = array_filter($accompanyingPeriods,
|
||||||
|
function(AccompanyingPeriod $period){
|
||||||
|
return $this->isGranted(AccompanyingPeriodVoter::SEE, $period);
|
||||||
|
});
|
||||||
|
return $this->json(\array_values($accompanyingPeriodsChecked), Response::HTTP_OK, [], ['groups' => [ 'read']]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/api/1.0/person/accompanying-course/{id}/referrers-suggested.{_format}",
|
* @Route("/api/1.0/person/accompanying-course/{id}/referrers-suggested.{_format}",
|
||||||
* requirements={ "_format"="json"},
|
* requirements={ "_format"="json"},
|
||||||
|
@ -11,7 +11,10 @@ use Symfony\Component\HttpFoundation\Request;
|
|||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Component\Serializer\SerializerInterface;
|
use Symfony\Component\Serializer\SerializerInterface;
|
||||||
use Symfony\Component\Translation\TranslatorInterface;
|
use Symfony\Component\Translation\TranslatorInterface;
|
||||||
|
use Symfony\Component\Form\Form;
|
||||||
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
|
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
|
|
||||||
class AccompanyingCourseWorkController extends AbstractController
|
class AccompanyingCourseWorkController extends AbstractController
|
||||||
{
|
{
|
||||||
@ -19,17 +22,20 @@ class AccompanyingCourseWorkController extends AbstractController
|
|||||||
private SerializerInterface $serializer;
|
private SerializerInterface $serializer;
|
||||||
private AccompanyingPeriodWorkRepository $workRepository;
|
private AccompanyingPeriodWorkRepository $workRepository;
|
||||||
private PaginatorFactory $paginator;
|
private PaginatorFactory $paginator;
|
||||||
|
private LoggerInterface $chillLogger;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
TranslatorInterface $trans,
|
TranslatorInterface $trans,
|
||||||
SerializerInterface $serializer,
|
SerializerInterface $serializer,
|
||||||
AccompanyingPeriodWorkRepository $workRepository,
|
AccompanyingPeriodWorkRepository $workRepository,
|
||||||
PaginatorFactory $paginator
|
PaginatorFactory $paginator,
|
||||||
|
LoggerInterface $chillLogger
|
||||||
) {
|
) {
|
||||||
$this->trans = $trans;
|
$this->trans = $trans;
|
||||||
$this->serializer = $serializer;
|
$this->serializer = $serializer;
|
||||||
$this->workRepository = $workRepository;
|
$this->workRepository = $workRepository;
|
||||||
$this->paginator = $paginator;
|
$this->paginator = $paginator;
|
||||||
|
$this->chillLogger = $chillLogger;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -106,4 +112,66 @@ class AccompanyingCourseWorkController extends AbstractController
|
|||||||
'paginator' => $paginator
|
'paginator' => $paginator
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Route(
|
||||||
|
* "{_locale}/person/accompanying-period/work/{id}/delete",
|
||||||
|
* name="chill_person_accompanying_period_work_delete",
|
||||||
|
* methods={"GET", "POST", "DELETE"}
|
||||||
|
* )
|
||||||
|
*/
|
||||||
|
public function deleteWork(AccompanyingPeriodWork $work, Request $request): Response
|
||||||
|
{
|
||||||
|
// TODO ACL
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
|
$form = $this->createDeleteForm($work->getId());
|
||||||
|
|
||||||
|
if ($request->getMethod() === Request::METHOD_DELETE) {
|
||||||
|
$form->handleRequest($request);
|
||||||
|
|
||||||
|
if ($form->isValid()) {
|
||||||
|
|
||||||
|
$this->chillLogger->notice("An accompanying period work has been removed", [
|
||||||
|
'by_user' => $this->getUser()->getUsername(),
|
||||||
|
'work_id' => $work->getId(),
|
||||||
|
'accompanying_period_id' => $work->getAccompanyingPeriod()->getId()
|
||||||
|
]);
|
||||||
|
|
||||||
|
$em->remove($work);
|
||||||
|
$em->flush();
|
||||||
|
|
||||||
|
$this->addFlash(
|
||||||
|
'success',
|
||||||
|
$this->trans->trans("The accompanying period work has been successfully removed.")
|
||||||
|
);
|
||||||
|
|
||||||
|
return $this->redirectToRoute('chill_person_accompanying_period_work_list', [
|
||||||
|
'id' => $work->getAccompanyingPeriod()->getId()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render('@ChillPerson/AccompanyingCourseWork/delete.html.twig', [
|
||||||
|
'accompanyingCourse' => $work->getAccompanyingPeriod(),
|
||||||
|
'work' => $work,
|
||||||
|
'delete_form' => $form->createView()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function createDeleteForm(int $id): Form
|
||||||
|
{
|
||||||
|
$params = [];
|
||||||
|
$params['id'] = $id;
|
||||||
|
|
||||||
|
return $this->createFormBuilder()
|
||||||
|
->setAction($this->generateUrl('chill_person_accompanying_period_work_delete', $params))
|
||||||
|
->setMethod('DELETE')
|
||||||
|
->add('submit', SubmitType::class, ['label' => 'Delete'])
|
||||||
|
->getForm()
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,8 @@ 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\Serializer\Normalizer\AbstractNormalizer;
|
||||||
|
use Symfony\Component\Serializer\SerializerInterface;
|
||||||
use Symfony\Component\Translation\TranslatorInterface;
|
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;
|
||||||
@ -26,13 +28,19 @@ class HouseholdController extends AbstractController
|
|||||||
|
|
||||||
private PositionRepository $positionRepository;
|
private PositionRepository $positionRepository;
|
||||||
|
|
||||||
|
private SerializerInterface $serializer;
|
||||||
|
|
||||||
private Security $security;
|
private Security $security;
|
||||||
|
|
||||||
public function __construct(TranslatorInterface $translator, PositionRepository $positionRepository, Security $security)
|
public function __construct(
|
||||||
|
TranslatorInterface $translator,
|
||||||
{
|
PositionRepository $positionRepository,
|
||||||
|
SerializerInterface $serializer,
|
||||||
|
Security $security
|
||||||
|
) {
|
||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
$this->positionRepository = $positionRepository;
|
$this->positionRepository = $positionRepository;
|
||||||
|
$this->serializer = $serializer;
|
||||||
$this->security = $security;
|
$this->security = $security;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,9 +219,13 @@ class HouseholdController extends AbstractController
|
|||||||
*/
|
*/
|
||||||
public function showRelationship(Request $request, Household $household)
|
public function showRelationship(Request $request, Household $household)
|
||||||
{
|
{
|
||||||
|
$jsonString = $this->serializer->serialize($household->getCurrentPersons(),
|
||||||
|
'json', [ AbstractNormalizer::GROUPS => ['read']]);
|
||||||
|
|
||||||
return $this->render('@ChillPerson/Household/relationship.html.twig',
|
return $this->render('@ChillPerson/Household/relationship.html.twig',
|
||||||
[
|
[
|
||||||
'household' => $household
|
'household' => $household,
|
||||||
|
'persons' => $jsonString
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Controller;
|
||||||
|
|
||||||
|
use Chill\MainBundle\CRUD\Controller\ApiController;
|
||||||
|
use Chill\PersonBundle\Entity\Person;
|
||||||
|
use Chill\PersonBundle\Repository\Relationships\RelationshipRepository;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||||
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||||
|
|
||||||
|
class RelationshipApiController extends ApiController
|
||||||
|
{
|
||||||
|
private ValidatorInterface $validator;
|
||||||
|
private RelationshipRepository $repository;
|
||||||
|
|
||||||
|
public function __construct(ValidatorInterface $validator, RelationshipRepository $repository)
|
||||||
|
{
|
||||||
|
$this->validator = $validator;
|
||||||
|
$this->repository = $repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ParamConverter("person", options={"id" = "person_id"})
|
||||||
|
*/
|
||||||
|
public function getRelationshipsByPerson(Person $person)
|
||||||
|
{
|
||||||
|
//TODO: add permissions? (voter?)
|
||||||
|
$relationships = $this->repository->findByPerson($person);
|
||||||
|
|
||||||
|
return $this->json(\array_values($relationships), Response::HTTP_OK, [], ['groups' => [ 'read']]);
|
||||||
|
}
|
||||||
|
}
|
@ -40,7 +40,7 @@ class LoadAccompanyingPeriodOrigin extends AbstractFixture implements OrderedFix
|
|||||||
|
|
||||||
public function getOrder()
|
public function getOrder()
|
||||||
{
|
{
|
||||||
return 10005;
|
return 9000;
|
||||||
}
|
}
|
||||||
|
|
||||||
private $phoneCall = ['en' => 'phone call', 'fr' => 'appel téléphonique'];
|
private $phoneCall = ['en' => 'phone call', 'fr' => 'appel téléphonique'];
|
||||||
|
@ -10,8 +10,8 @@ class LoadHouseholdPosition extends Fixture
|
|||||||
{
|
{
|
||||||
const POSITIONS_DATA = [
|
const POSITIONS_DATA = [
|
||||||
["Adulte", true, true, 1.0, self::ADULT ],
|
["Adulte", true, true, 1.0, self::ADULT ],
|
||||||
["Enfants", true, false, 2.0, self::CHILD ],
|
["Enfant", true, false, 2.0, self::CHILD ],
|
||||||
["Enfants hors ménage", false, false, 3.0, self::CHILD_OUT ]
|
["Enfant hors ménage", false, false, 3.0, self::CHILD_OUT ]
|
||||||
];
|
];
|
||||||
|
|
||||||
const ADULT = "position_adulte";
|
const ADULT = "position_adulte";
|
||||||
|
@ -106,6 +106,8 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
|
|||||||
|
|
||||||
protected UserRepository $userRepository;
|
protected UserRepository $userRepository;
|
||||||
|
|
||||||
|
public const PERSON = 'person';
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
Registry $workflowRegistry,
|
Registry $workflowRegistry,
|
||||||
SocialIssueRepository $socialIssueRepository,
|
SocialIssueRepository $socialIssueRepository,
|
||||||
@ -247,7 +249,9 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
|
|||||||
if (\random_int(0, 10) > 3) {
|
if (\random_int(0, 10) > 3) {
|
||||||
// always add social scope:
|
// always add social scope:
|
||||||
$accompanyingPeriod->addScope($this->getReference('scope_social'));
|
$accompanyingPeriod->addScope($this->getReference('scope_social'));
|
||||||
|
$origin = $this->getReference(LoadAccompanyingPeriodOrigin::ACCOMPANYING_PERIOD_ORIGIN);
|
||||||
|
$accompanyingPeriod->setOrigin($origin);
|
||||||
|
$accompanyingPeriod->setIntensity('regular');
|
||||||
$accompanyingPeriod->setAddressLocation($this->createAddress());
|
$accompanyingPeriod->setAddressLocation($this->createAddress());
|
||||||
$manager->persist($accompanyingPeriod->getAddressLocation());
|
$manager->persist($accompanyingPeriod->getAddressLocation());
|
||||||
$workflow = $this->workflowRegistry->get($accompanyingPeriod);
|
$workflow = $this->workflowRegistry->get($accompanyingPeriod);
|
||||||
@ -257,6 +261,8 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
|
|||||||
$manager->persist($person);
|
$manager->persist($person);
|
||||||
$manager->persist($accompanyingPeriod);
|
$manager->persist($accompanyingPeriod);
|
||||||
echo "add person'".$person->__toString()."'\n";
|
echo "add person'".$person->__toString()."'\n";
|
||||||
|
|
||||||
|
$this->addReference(self::PERSON, $person);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getRandomUser(): User
|
private function getRandomUser(): User
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\DataFixtures\ORM;
|
||||||
|
|
||||||
|
use Chill\PersonBundle\Entity\Relationships\Relation;
|
||||||
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||||
|
use Doctrine\Bundle\FixturesBundle\FixtureGroupInterface;
|
||||||
|
use Doctrine\Persistence\ObjectManager;
|
||||||
|
|
||||||
|
class LoadRelations extends Fixture implements FixtureGroupInterface
|
||||||
|
{
|
||||||
|
public const RELATIONS = 'relations';
|
||||||
|
|
||||||
|
public static function getGroups(): array
|
||||||
|
{
|
||||||
|
return ['person_relations'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function load(ObjectManager $manager)
|
||||||
|
{
|
||||||
|
$relations = [
|
||||||
|
['title' => ['fr' => 'Mère'], 'reverseTitle' => ['fr' => 'Fille']],
|
||||||
|
['title' => ['fr' => 'Mère'], 'reverseTitle' => ['fr' => 'Fils']],
|
||||||
|
['title' => ['fr' => 'Père'], 'reverseTitle' => ['fr' => 'Fille']],
|
||||||
|
['title' => ['fr' => 'Père'], 'reverseTitle' => ['fr' => 'Fils']],
|
||||||
|
|
||||||
|
['title' => ['fr' => 'Frère'], 'reverseTitle' => ['fr' => 'Frère']],
|
||||||
|
['title' => ['fr' => 'Soeur'], 'reverseTitle' => ['fr' => 'Soeur']],
|
||||||
|
['title' => ['fr' => 'Frère'], 'reverseTitle' => ['fr' => 'Soeur']],
|
||||||
|
|
||||||
|
['title' => ['fr' => 'Demi-frère'], 'reverseTitle' => ['fr' => 'Demi-frère']],
|
||||||
|
['title' => ['fr' => 'Demi-soeur'], 'reverseTitle' => ['fr' => 'Demi-soeur']],
|
||||||
|
['title' => ['fr' => 'Demi-frère'], 'reverseTitle' => ['fr' => 'Demi-soeur']],
|
||||||
|
|
||||||
|
['title' => ['fr' => 'Oncle'], 'reverseTitle' => ['fr' => 'Neveu']],
|
||||||
|
['title' => ['fr' => 'Oncle'], 'reverseTitle' => ['fr' => 'Nièce']],
|
||||||
|
['title' => ['fr' => 'Tante'], 'reverseTitle' => ['fr' => 'Neveu']],
|
||||||
|
['title' => ['fr' => 'Tante'], 'reverseTitle' => ['fr' => 'Nièce']],
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach($relations as $value){
|
||||||
|
print "Creating a new relation type: relation" . $value['title']['fr'] . "reverse relation: " . $value['reverseTitle']['fr'] . "\n";
|
||||||
|
$relation = new Relation();
|
||||||
|
$relation->setTitle($value['title'])
|
||||||
|
->setReverseTitle($value['reverseTitle']);
|
||||||
|
$manager->persist($relation);
|
||||||
|
$this->addReference(self::RELATIONS, $relation);
|
||||||
|
}
|
||||||
|
|
||||||
|
$manager->flush();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\DataFixtures\ORM;
|
||||||
|
|
||||||
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||||
|
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
||||||
|
use Doctrine\Persistence\ObjectManager;
|
||||||
|
use Chill\PersonBundle\DataFixtures\ORM\LoadPeople;
|
||||||
|
use Chill\PersonBundle\DataFixtures\ORM\LoadRelations;
|
||||||
|
use Chill\PersonBundle\Entity\Relationships\Relationship;
|
||||||
|
|
||||||
|
class LoadRelationships extends Fixture implements DependentFixtureInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function getDependencies()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
LoadPeople::class,
|
||||||
|
LoadRelations::class
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function load(ObjectManager $manager)
|
||||||
|
{
|
||||||
|
$relationship = new Relationship;
|
||||||
|
$relationship->setFromPerson($this->getReference(LoadPeople::PERSON));
|
||||||
|
$relationship->setToPerson($this->getReference(LoadPeople::PERSON));
|
||||||
|
$relationship->setRelation($this->getReference(LoadRelations::RELATIONS));
|
||||||
|
$relationship->setReverse((bool)random_int(0, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -585,6 +585,14 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
|||||||
Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
'findAccompanyingPeriodsByPerson' => [
|
||||||
|
'path' => '/by-person/{person_id}.{_format}',
|
||||||
|
'controller_action' => 'getAccompanyingPeriodsByPerson',
|
||||||
|
'methods' => [
|
||||||
|
Request::METHOD_GET => true,
|
||||||
|
Request::METHOD_HEAD => true,
|
||||||
|
]
|
||||||
|
]
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -862,6 +870,59 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
|||||||
],
|
],
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'class' => \Chill\PersonBundle\Entity\Relationships\Relationship::class,
|
||||||
|
'controller' => \Chill\PersonBundle\Controller\RelationshipApiController::class,
|
||||||
|
'name' => 'relationship_by_person',
|
||||||
|
'base_path' => '/api/1.0/relations/relationship',
|
||||||
|
'base_role' => 'ROLE_USER',
|
||||||
|
'actions' => [
|
||||||
|
'_entity' => [
|
||||||
|
'methods' => [
|
||||||
|
Request::METHOD_POST => true,
|
||||||
|
Request::METHOD_PATCH => true,
|
||||||
|
Request::METHOD_DELETE => true,
|
||||||
|
],
|
||||||
|
'roles' => [
|
||||||
|
Request::METHOD_POST => 'ROLE_USER',
|
||||||
|
Request::METHOD_PATCH => 'ROLE_USER',
|
||||||
|
Request::METHOD_DELETE => 'ROLE_USER',
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'relationship-by-person' => [
|
||||||
|
'path' => '/by-person/{person_id}.json',
|
||||||
|
'controller_action' => 'getRelationshipsByPerson',
|
||||||
|
'methods' => [
|
||||||
|
Request::METHOD_GET => true,
|
||||||
|
Request::METHOD_HEAD => true,
|
||||||
|
],
|
||||||
|
'roles' => [
|
||||||
|
Request::METHOD_GET => 'ROLE_USER',
|
||||||
|
Request::METHOD_HEAD => 'ROLE_USER',
|
||||||
|
]
|
||||||
|
],
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'class' => \Chill\PersonBundle\Entity\Relationships\Relation::class,
|
||||||
|
'name' => 'relations',
|
||||||
|
'base_path' => '/api/1.0/relations/relation',
|
||||||
|
'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
|
||||||
|
]
|
||||||
|
],
|
||||||
|
]
|
||||||
|
],
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,9 @@ 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;
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
use Symfony\Component\Validator\GroupSequenceProviderInterface;
|
||||||
|
use Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\ParticipationOverlap;
|
||||||
|
use Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\ResourceDuplicateCheck;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AccompanyingPeriod Class
|
* AccompanyingPeriod Class
|
||||||
@ -54,9 +57,10 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||||||
* @DiscriminatorMap(typeProperty="type", mapping={
|
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||||
* "accompanying_period"=AccompanyingPeriod::class
|
* "accompanying_period"=AccompanyingPeriod::class
|
||||||
* })
|
* })
|
||||||
|
* @Assert\GroupSequenceProvider
|
||||||
*/
|
*/
|
||||||
class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface,
|
class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface,
|
||||||
HasScopesInterface, HasCentersInterface
|
HasScopesInterface, HasCentersInterface, GroupSequenceProviderInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Mark an accompanying period as "occasional"
|
* Mark an accompanying period as "occasional"
|
||||||
@ -132,6 +136,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
* cascade={"persist", "remove"},
|
* cascade={"persist", "remove"},
|
||||||
* orphanRemoval=true
|
* orphanRemoval=true
|
||||||
* )
|
* )
|
||||||
|
* @Assert\NotBlank(groups={AccompanyingPeriod::STEP_DRAFT})
|
||||||
*/
|
*/
|
||||||
private $comments;
|
private $comments;
|
||||||
|
|
||||||
@ -147,9 +152,10 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
* @var Collection
|
* @var Collection
|
||||||
*
|
*
|
||||||
* @ORM\OneToMany(targetEntity=AccompanyingPeriodParticipation::class,
|
* @ORM\OneToMany(targetEntity=AccompanyingPeriodParticipation::class,
|
||||||
* mappedBy="accompanyingPeriod",
|
* mappedBy="accompanyingPeriod", orphanRemoval=true,
|
||||||
* cascade={"persist", "refresh", "remove", "merge", "detach"})
|
* cascade={"persist", "refresh", "remove", "merge", "detach"})
|
||||||
* @Groups({"read"})
|
* @Groups({"read"})
|
||||||
|
* @ParticipationOverlap(groups={AccompanyingPeriod::STEP_DRAFT, AccompanyingPeriod::STEP_CONFIRMED})
|
||||||
*/
|
*/
|
||||||
private $participations;
|
private $participations;
|
||||||
|
|
||||||
@ -188,6 +194,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
* @ORM\ManyToOne(targetEntity=Origin::class)
|
* @ORM\ManyToOne(targetEntity=Origin::class)
|
||||||
* @ORM\JoinColumn(nullable=true)
|
* @ORM\JoinColumn(nullable=true)
|
||||||
* @Groups({"read", "write"})
|
* @Groups({"read", "write"})
|
||||||
|
* @Assert\NotBlank(groups={AccompanyingPeriod::STEP_CONFIRMED})
|
||||||
*/
|
*/
|
||||||
private $origin;
|
private $origin;
|
||||||
|
|
||||||
@ -195,8 +202,9 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
* @var string
|
* @var string
|
||||||
* @ORM\Column(type="string", nullable=true)
|
* @ORM\Column(type="string", nullable=true)
|
||||||
* @Groups({"read", "write"})
|
* @Groups({"read", "write"})
|
||||||
|
* @Assert\NotBlank(groups={AccompanyingPeriod::STEP_CONFIRMED})
|
||||||
*/
|
*/
|
||||||
private $intensity;
|
private $intensity = self::INTENSITY_OCCASIONAL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Collection
|
* @var Collection
|
||||||
@ -210,6 +218,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
* inverseJoinColumns={@ORM\JoinColumn(name="scope_id", referencedColumnName="id")}
|
* inverseJoinColumns={@ORM\JoinColumn(name="scope_id", referencedColumnName="id")}
|
||||||
* )
|
* )
|
||||||
* @Groups({"read"})
|
* @Groups({"read"})
|
||||||
|
* @Assert\Count(min=1, groups={AccompanyingPeriod::STEP_CONFIRMED})
|
||||||
*/
|
*/
|
||||||
private $scopes;
|
private $scopes;
|
||||||
|
|
||||||
@ -256,6 +265,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
* orphanRemoval=true
|
* orphanRemoval=true
|
||||||
* )
|
* )
|
||||||
* @Groups({"read"})
|
* @Groups({"read"})
|
||||||
|
* @ResourceDuplicateCheck(groups={AccompanyingPeriod::STEP_DRAFT, AccompanyingPeriod::STEP_CONFIRMED, "Default", "default"})
|
||||||
*/
|
*/
|
||||||
private $resources;
|
private $resources;
|
||||||
|
|
||||||
@ -267,6 +277,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
* name="chill_person_accompanying_period_social_issues"
|
* name="chill_person_accompanying_period_social_issues"
|
||||||
* )
|
* )
|
||||||
* @Groups({"read"})
|
* @Groups({"read"})
|
||||||
|
* @Assert\Count(min=1, groups={AccompanyingPeriod::STEP_CONFIRMED})
|
||||||
*/
|
*/
|
||||||
private Collection $socialIssues;
|
private Collection $socialIssues;
|
||||||
|
|
||||||
@ -606,6 +617,14 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
return $participation;
|
return $participation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove Participation
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function removeParticipation(AccompanyingPeriodParticipation $participation)
|
||||||
|
{
|
||||||
|
$participation->setAccompanyingPeriod(null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove Person
|
* Remove Person
|
||||||
@ -1115,4 +1134,18 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
|
|
||||||
return $centers ?? null;
|
return $centers ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getGroupSequence()
|
||||||
|
{
|
||||||
|
if ($this->getStep() == self::STEP_DRAFT)
|
||||||
|
{
|
||||||
|
return [[self::STEP_DRAFT]];
|
||||||
|
} elseif ($this->getStep() == self::STEP_CONFIRMED)
|
||||||
|
{
|
||||||
|
return [[self::STEP_DRAFT, self::STEP_CONFIRMED]];
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \LogicException("no validation group permitted with this step");
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||||||
* @ORM\OneToMany(
|
* @ORM\OneToMany(
|
||||||
* targetEntity=AccompanyingPeriodWorkEvaluation::class,
|
* targetEntity=AccompanyingPeriodWorkEvaluation::class,
|
||||||
* mappedBy="accompanyingPeriodWork",
|
* mappedBy="accompanyingPeriodWork",
|
||||||
* cascade={"persist"},
|
* cascade={"remove", "persist"},
|
||||||
* orphanRemoval=true
|
* orphanRemoval=true
|
||||||
* )
|
* )
|
||||||
* @Serializer\Groups({"read"})
|
* @Serializer\Groups({"read"})
|
||||||
|
@ -70,7 +70,8 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(
|
* @ORM\ManyToOne(
|
||||||
* targetEntity=StoredObject::class
|
* targetEntity=StoredObject::class,
|
||||||
|
* cascade={"remove"},
|
||||||
* )
|
* )
|
||||||
* @Serializer\Groups({"read"})
|
* @Serializer\Groups({"read"})
|
||||||
*/
|
*/
|
||||||
|
@ -33,7 +33,13 @@ use Symfony\Component\Serializer\Annotation\Groups;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Entity
|
* @ORM\Entity
|
||||||
* @ORM\Table(name="chill_person_accompanying_period_resource")
|
* @ORM\Table(
|
||||||
|
* name="chill_person_accompanying_period_resource",
|
||||||
|
* uniqueConstraints={
|
||||||
|
* @ORM\UniqueConstraint(name="person_unique", columns={"person_id", "accompanyingperiod_id"}),
|
||||||
|
* @ORM\UniqueConstraint(name="thirdparty_unique", columns={"thirdparty_id", "accompanyingperiod_id"})
|
||||||
|
* }
|
||||||
|
* )
|
||||||
* @DiscriminatorMap(typeProperty="type", mapping={
|
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||||
* "accompanying_period_resource"=Resource::class
|
* "accompanying_period_resource"=Resource::class
|
||||||
* })
|
* })
|
||||||
|
@ -134,4 +134,11 @@ class AccompanyingPeriodParticipation
|
|||||||
{
|
{
|
||||||
return $this->endDate === null;
|
return $this->endDate === null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function checkSameStartEnd()
|
||||||
|
{
|
||||||
|
if($this->endDate == $this->startDate) {
|
||||||
|
$this->accompanyingPeriod->removeParticipation($this);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -931,13 +931,19 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
* return gender as a Numeric form.
|
* return gender as a Numeric form.
|
||||||
* This is used for translations
|
* This is used for translations
|
||||||
* @return int
|
* @return int
|
||||||
|
* @deprecated Keep for legacy. Used in Chill 1.5 for feminize before icu translations
|
||||||
*/
|
*/
|
||||||
public function getGenderNumeric()
|
public function getGenderNumeric()
|
||||||
{
|
{
|
||||||
if ($this->getGender() == self::FEMALE_GENDER) {
|
switch ($this->getGender()) {
|
||||||
return 1;
|
case self::FEMALE_GENDER:
|
||||||
} else {
|
return 1;
|
||||||
return 0;
|
case self::MALE_GENDER:
|
||||||
|
return 0;
|
||||||
|
case self::BOTH_GENDER:
|
||||||
|
return 2;
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,85 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Entity\Relationships;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use Doctrine\ORM\Mapping\DiscriminatorColumn;
|
||||||
|
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||||
|
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Entity()
|
||||||
|
* @ORM\Table(name="chill_person_relations")
|
||||||
|
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||||
|
* "relation"=Relation::class
|
||||||
|
* })
|
||||||
|
*/
|
||||||
|
class Relation
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @ORM\Id
|
||||||
|
* @ORM\GeneratedValue
|
||||||
|
* @ORM\Column(type="integer")
|
||||||
|
* @Serializer\Groups({"read"})
|
||||||
|
*/
|
||||||
|
private ?int $id = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="json", nullable=true)
|
||||||
|
* @Serializer\Groups({"read"})
|
||||||
|
*/
|
||||||
|
private array $title = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="json", nullable=true)
|
||||||
|
* @Serializer\Groups({"read"})
|
||||||
|
*/
|
||||||
|
private array $reverseTitle = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="boolean", nullable=true)
|
||||||
|
* @Serializer\Groups({"read"})
|
||||||
|
*/
|
||||||
|
private bool $isActive = true;
|
||||||
|
|
||||||
|
public function getId(): ?int
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTitle(): ?array
|
||||||
|
{
|
||||||
|
return $this->title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setTitle(?array $title): self
|
||||||
|
{
|
||||||
|
$this->title = $title;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getReverseTitle(): ?array
|
||||||
|
{
|
||||||
|
return $this->reverseTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setReverseTitle(?array $reverseTitle): self
|
||||||
|
{
|
||||||
|
$this->reverseTitle = $reverseTitle;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getIsActive(): bool
|
||||||
|
{
|
||||||
|
return $this->isActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setIsActive(?bool $isActive): self
|
||||||
|
{
|
||||||
|
$this->isActive = $isActive;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,192 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Entity\Relationships;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
||||||
|
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
||||||
|
use Chill\MainBundle\Entity\User;
|
||||||
|
use Chill\PersonBundle\Entity\Person;
|
||||||
|
use Chill\PersonBundle\Entity\Relationships\Relation;
|
||||||
|
use DateTimeImmutable;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||||
|
use Doctrine\ORM\Mapping\DiscriminatorColumn;
|
||||||
|
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Entity()
|
||||||
|
* @ORM\Table(name="chill_person_relationships")
|
||||||
|
* @DiscriminatorColumn(name="relation_id", type="integer")
|
||||||
|
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||||
|
* "relationship"=Relationship::class
|
||||||
|
* })
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class Relationship implements TrackCreationInterface, TrackUpdateInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @ORM\Id
|
||||||
|
* @ORM\GeneratedValue
|
||||||
|
* @ORM\Column(type="integer")
|
||||||
|
* @Serializer\Groups({"read"})
|
||||||
|
*/
|
||||||
|
private ?int $id = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\ManyToOne(targetEntity=Person::class)
|
||||||
|
* @ORM\JoinColumn(nullable=false)
|
||||||
|
* @Assert\NotNull()
|
||||||
|
* @Serializer\Groups({"read", "write"})
|
||||||
|
*/
|
||||||
|
private ?Person $fromPerson = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\ManyToOne(targetEntity=Person::class)
|
||||||
|
* @ORM\JoinColumn(nullable=false)
|
||||||
|
* @Assert\NotNull()
|
||||||
|
* @Serializer\Groups({"read", "write"})
|
||||||
|
*/
|
||||||
|
private ?Person $toPerson = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\ManyToOne(targetEntity=Relation::class)
|
||||||
|
* @ORM\JoinColumn(nullable=false, name="relation_id", referencedColumnName="id")
|
||||||
|
* @Assert\NotNull()
|
||||||
|
* @Serializer\Groups({"read", "write"})
|
||||||
|
*/
|
||||||
|
private ?Relation $relation = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="boolean")
|
||||||
|
* @Assert\Type(
|
||||||
|
* type="bool",
|
||||||
|
* message="This must be of type boolean"
|
||||||
|
* )
|
||||||
|
* @Serializer\Groups({"read", "write"})
|
||||||
|
*/
|
||||||
|
private bool $reverse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\ManyToOne(targetEntity=User::class)
|
||||||
|
* @ORM\JoinColumn(nullable=false)
|
||||||
|
*/
|
||||||
|
private ?User $createdBy = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="datetime_immutable")
|
||||||
|
*/
|
||||||
|
private ?DateTimeImmutable $createdAt = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\ManyToOne(targetEntity=User::class)
|
||||||
|
*/
|
||||||
|
private ?User $updatedBy = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="datetime_immutable", nullable=true)
|
||||||
|
*/
|
||||||
|
private ?DateTimeImmutable $updatedAt = null;
|
||||||
|
|
||||||
|
|
||||||
|
public function getId(): ?int
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFromPerson(): ?Person
|
||||||
|
{
|
||||||
|
return $this->fromPerson;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setFromPerson(?Person $fromPerson): self
|
||||||
|
{
|
||||||
|
$this->fromPerson = $fromPerson;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getToPerson(): ?Person
|
||||||
|
{
|
||||||
|
return $this->toPerson;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setToPerson(?Person $toPerson): self
|
||||||
|
{
|
||||||
|
$this->toPerson = $toPerson;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getReverse(): ?bool
|
||||||
|
{
|
||||||
|
return $this->reverse;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setReverse(bool $reverse): self
|
||||||
|
{
|
||||||
|
$this->reverse = $reverse;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCreatedBy(): ?User
|
||||||
|
{
|
||||||
|
return $this->createdBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCreatedBy(?User $user): self
|
||||||
|
{
|
||||||
|
$this->createdBy = $user;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCreatedAt(): ?\DateTimeImmutable
|
||||||
|
{
|
||||||
|
return $this->createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCreatedAt(\DateTimeInterface $createdAt): self
|
||||||
|
{
|
||||||
|
$this->createdAt = $createdAt;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUpdatedBy(): ?User
|
||||||
|
{
|
||||||
|
return $this->updatedBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setUpdatedBy(?User $updatedBy): self
|
||||||
|
{
|
||||||
|
$this->updatedBy = $updatedBy;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUpdatedAt(): ?\DateTimeImmutable
|
||||||
|
{
|
||||||
|
return $this->updatedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
|
||||||
|
{
|
||||||
|
$this->updatedAt = $updatedAt;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRelation(): ?Relation
|
||||||
|
{
|
||||||
|
return $this->relation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setRelation(?Relation $relation): self
|
||||||
|
{
|
||||||
|
$this->relation = $relation;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Repository\Relationships;
|
||||||
|
|
||||||
|
use Chill\PersonBundle\Entity\Relationships\Relation;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
use Doctrine\Persistence\ObjectRepository;
|
||||||
|
|
||||||
|
class RelationRepository implements ObjectRepository
|
||||||
|
{
|
||||||
|
private EntityRepository $repository;
|
||||||
|
|
||||||
|
public function __construct(EntityManagerInterface $entityManager)
|
||||||
|
{
|
||||||
|
$this->repository = $entityManager->getRepository(Relation::class);
|
||||||
|
}
|
||||||
|
public function find($id): ?Relation
|
||||||
|
{
|
||||||
|
return $this->repository->find($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findAll(): array
|
||||||
|
{
|
||||||
|
return $this->repository->findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
|
||||||
|
{
|
||||||
|
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findOneBy(array $criteria): ?Relation
|
||||||
|
{
|
||||||
|
return $this->findOneBy($criteria);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getClassName(): string
|
||||||
|
{
|
||||||
|
return MaritalStatus::class;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Repository\Relationships;
|
||||||
|
|
||||||
|
use Chill\PersonBundle\Entity\Relationships\Relationship;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
use Doctrine\Persistence\ObjectRepository;
|
||||||
|
|
||||||
|
class RelationshipRepository implements ObjectRepository
|
||||||
|
{
|
||||||
|
|
||||||
|
private EntityRepository $repository;
|
||||||
|
|
||||||
|
public function __construct(EntityManagerInterface $em)
|
||||||
|
{
|
||||||
|
$this->repository = $em->getRepository(Relationship::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function find($id): ?Relationship
|
||||||
|
{
|
||||||
|
return $this->repository->find($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findAll(): array
|
||||||
|
{
|
||||||
|
return $this->repository->findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
|
||||||
|
{
|
||||||
|
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findOneBy(array $criteria): ?Relationship
|
||||||
|
{
|
||||||
|
return $this->findOneBy($criteria);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getClassName(): string
|
||||||
|
{
|
||||||
|
return MaritalStatus::class;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findByPerson($personId): array
|
||||||
|
{
|
||||||
|
// return all relationships of which person is part? or only where person is the fromPerson?
|
||||||
|
return $this->repository->createQueryBuilder('r')
|
||||||
|
->select('r, t') // entity Relationship
|
||||||
|
->join('r.relation', 't')
|
||||||
|
->where('r.fromPerson = :val')
|
||||||
|
->orWhere('r.toPerson = :val')
|
||||||
|
->setParameter('val', $personId)
|
||||||
|
->getQuery()
|
||||||
|
->getResult()
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,32 +0,0 @@
|
|||||||
import vis from 'vis-network/dist/vis-network.min';
|
|
||||||
|
|
||||||
require('./scss/vis.scss');
|
|
||||||
|
|
||||||
// create an array with nodes
|
|
||||||
let nodes = new vis.DataSet([
|
|
||||||
{ id: 1, label: "Node 1" },
|
|
||||||
{ id: 2, label: "Node 2" },
|
|
||||||
{ id: 3, label: "Node 3" },
|
|
||||||
{ id: 4, label: "Node 4" },
|
|
||||||
{ id: 5, label: "Node 5", cid: 1 },
|
|
||||||
]);
|
|
||||||
|
|
||||||
// create an array with edges
|
|
||||||
let edges = new vis.DataSet([
|
|
||||||
{ from: 1, to: 3 },
|
|
||||||
{ from: 1, to: 2 },
|
|
||||||
{ from: 2, to: 4 },
|
|
||||||
{ from: 2, to: 5 },
|
|
||||||
{ from: 3, to: 3 },
|
|
||||||
]);
|
|
||||||
|
|
||||||
// create a network
|
|
||||||
let container = document.getElementById("graph-relationship");
|
|
||||||
let data = {
|
|
||||||
nodes: nodes,
|
|
||||||
edges: edges,
|
|
||||||
};
|
|
||||||
let options = {};
|
|
||||||
|
|
||||||
//
|
|
||||||
let network = new vis.Network(container, data, options);
|
|
@ -1,5 +0,0 @@
|
|||||||
div#graph-relationship {
|
|
||||||
margin: 2em auto;
|
|
||||||
height: 500px;
|
|
||||||
border: 1px solid lightgray;
|
|
||||||
}
|
|
@ -16,16 +16,15 @@
|
|||||||
<comment v-if="accompanyingCourse.step === 'DRAFT'"></comment>
|
<comment v-if="accompanyingCourse.step === 'DRAFT'"></comment>
|
||||||
<confirm v-if="accompanyingCourse.step === 'DRAFT'"></confirm>
|
<confirm v-if="accompanyingCourse.step === 'DRAFT'"></confirm>
|
||||||
|
|
||||||
<div v-for="error in errorMsg" class="vue-component errors alert alert-danger">
|
<!-- <div v-for="error in errorMsg" v-bind:key="error.id" class="vue-component errors alert alert-danger">
|
||||||
<p>
|
<p>
|
||||||
<span>{{ error.sta }} {{ error.txt }}</span><br>
|
<span>{{ error.sta }} {{ error.txt }}</span><br>
|
||||||
<span>{{ $t(error.msg) }}</span>
|
<span>{{ $t(error.msg) }}</span>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div> -->
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapState } from 'vuex'
|
import { mapGetters, mapState } from 'vuex'
|
||||||
import Banner from './components/Banner.vue';
|
import Banner from './components/Banner.vue';
|
||||||
import StickyNav from './components/StickyNav.vue';
|
import StickyNav from './components/StickyNav.vue';
|
||||||
import OriginDemand from './components/OriginDemand.vue';
|
import OriginDemand from './components/OriginDemand.vue';
|
||||||
@ -55,11 +54,12 @@ export default {
|
|||||||
Comment,
|
Comment,
|
||||||
Confirm,
|
Confirm,
|
||||||
},
|
},
|
||||||
computed: mapState([
|
computed: {
|
||||||
'accompanyingCourse',
|
...mapState([
|
||||||
'addressContext',
|
'accompanyingCourse',
|
||||||
'errorMsg'
|
'addressContext'
|
||||||
])
|
]),
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -86,7 +86,8 @@ const postParticipation = (id, payload, method) => {
|
|||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.ok) { return response.json(); }
|
if (response.ok) { return response.json(); }
|
||||||
throw { msg: 'Error while sending AccompanyingPeriod Course participation.', sta: response.status, txt: response.statusText, err: new Error(), body: response.body };
|
// TODO: adjust message according to status code? Or how to access the message from the violation array?
|
||||||
|
throw { msg: 'Error while sending AccompanyingPeriod Course participation', sta: response.status, txt: response.statusText, err: new Error(), body: response.body };
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -10,13 +10,13 @@
|
|||||||
<VueMultiselect
|
<VueMultiselect
|
||||||
name="selectOrigin"
|
name="selectOrigin"
|
||||||
label="text"
|
label="text"
|
||||||
v-bind:custom-label="transText"
|
:custom-label="transText"
|
||||||
track-by="id"
|
track-by="id"
|
||||||
v-bind:multiple="false"
|
:multiple="false"
|
||||||
v-bind:searchable="true"
|
:searchable="true"
|
||||||
v-bind:placeholder="$t('origin.placeholder')"
|
:placeholder="$t('origin.placeholder')"
|
||||||
v-model="value"
|
v-model="value"
|
||||||
v-bind:options="options"
|
:options="options"
|
||||||
@select="updateOrigin">
|
@select="updateOrigin">
|
||||||
</VueMultiselect>
|
</VueMultiselect>
|
||||||
|
|
||||||
@ -47,18 +47,18 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getOptions() {
|
getOptions() {
|
||||||
//console.log('loading origins list');
|
|
||||||
getListOrigins().then(response => new Promise((resolve, reject) => {
|
getListOrigins().then(response => new Promise((resolve, reject) => {
|
||||||
this.options = response.results;
|
this.options = response.results;
|
||||||
resolve();
|
resolve();
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
updateOrigin(value) {
|
updateOrigin(value) {
|
||||||
//console.log('value', value);
|
console.log('value', value);
|
||||||
this.$store.dispatch('updateOrigin', value);
|
this.$store.dispatch('updateOrigin', value);
|
||||||
},
|
},
|
||||||
transText ({ text }) {
|
transText ({ text }) {
|
||||||
return text.fr //TODO multilang
|
const parsedText = JSON.parse(text);
|
||||||
|
return parsedText.fr;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@ import { createApp } from 'vue'
|
|||||||
import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n'
|
import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n'
|
||||||
import { appMessages } from './js/i18n'
|
import { appMessages } from './js/i18n'
|
||||||
import { initPromise } from './store'
|
import { initPromise } from './store'
|
||||||
|
import VueToast from 'vue-toast-notification';
|
||||||
|
import 'vue-toast-notification/dist/theme-sugar.css';
|
||||||
|
|
||||||
import App from './App.vue';
|
import App from './App.vue';
|
||||||
import Banner from './components/Banner.vue';
|
import Banner from './components/Banner.vue';
|
||||||
@ -21,6 +23,7 @@ if (root === 'app') {
|
|||||||
})
|
})
|
||||||
.use(store)
|
.use(store)
|
||||||
.use(i18n)
|
.use(i18n)
|
||||||
|
.use(VueToast)
|
||||||
.component('app', App)
|
.component('app', App)
|
||||||
.mount('#accompanying-course');
|
.mount('#accompanying-course');
|
||||||
});
|
});
|
||||||
|
@ -77,7 +77,7 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
|
|||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
catchError(state, error) {
|
catchError(state, error) {
|
||||||
console.log('### mutation: a new error have been catched and pushed in store !', error);
|
// console.log('### mutation: a new error have been catched and pushed in store !', error);
|
||||||
state.errorMsg.push(error);
|
state.errorMsg.push(error);
|
||||||
},
|
},
|
||||||
removeParticipation(state, participation) {
|
removeParticipation(state, participation) {
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="isLoadingSocialActions">
|
<div v-if="isLoadingSocialActions">
|
||||||
<p>spinner</p>
|
<i class="fa fa-circle-o-notch fa-spin fa-fw"></i>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="hasSocialActionPicked" id="persons">
|
<div v-if="hasSocialActionPicked" id="persons">
|
||||||
@ -72,7 +72,7 @@
|
|||||||
{{ $t('action.save') }}
|
{{ $t('action.save') }}
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-save" v-show="isPostingWork" disabled>
|
<button class="btn btn-save" v-show="isPostingWork" disabled>
|
||||||
{{ $t('Save') }}
|
{{ $t('action.save') }}
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -0,0 +1,508 @@
|
|||||||
|
<template>
|
||||||
|
|
||||||
|
<div id="visgraph"></div>
|
||||||
|
|
||||||
|
<teleport to="#visgraph-legend">
|
||||||
|
<div class="post-menu">
|
||||||
|
<div class="list-group mt-4">
|
||||||
|
<button type="button" class="list-group-item list-group-item-action btn btn-create" @click="createRelationship">
|
||||||
|
{{ $t('visgraph.add_link') }}
|
||||||
|
</button>
|
||||||
|
<a type="button" class="list-group-item list-group-item-action btn btn-misc" id="exportCanvasBtn" @click="exportCanvasAsImage">
|
||||||
|
<i class="fa fa-camera fa-fw"></i> {{ $t('visgraph.screenshot') }}
|
||||||
|
</a>
|
||||||
|
<button type="button" class="list-group-item list-group-item-action btn btn-light" @click="refreshNetwork">
|
||||||
|
<i class="fa fa-refresh fa-fw"></i> {{ $t('visgraph.refresh') }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="displayHelpMessage" class="alert alert-info mt-3">
|
||||||
|
{{ $t('visgraph.create_link_help') }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="my-4 legend">
|
||||||
|
<h3>{{ $t('visgraph.Legend') }}</h3>
|
||||||
|
<div class="list-group">
|
||||||
|
<label class="list-group-item" v-for="layer in legendLayers">
|
||||||
|
<input
|
||||||
|
class="form-check-input me-1"
|
||||||
|
type="checkbox"
|
||||||
|
:value="layer.id"
|
||||||
|
v-model="checkedLayers"
|
||||||
|
@change="toggleLayer"
|
||||||
|
/>
|
||||||
|
{{ layer.label }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</teleport>
|
||||||
|
|
||||||
|
<teleport to="body">
|
||||||
|
<modal v-if="modal.showModal" :modalDialogClass="modal.modalDialogClass" @close="modal.showModal = false">
|
||||||
|
<template v-slot:header>
|
||||||
|
<h2 class="modal-title">{{ $t(modal.title) }}</h2>
|
||||||
|
<!-- {{ modal.data.id }} -->
|
||||||
|
</template>
|
||||||
|
<template v-slot:body>
|
||||||
|
<div v-if="modal.action === 'delete'">
|
||||||
|
<p>{{ $t('visgraph.delete_confirmation_text') }}</p>
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<form>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12 text-center">{{ $t('visgraph.between') }}<br>{{ $t('visgraph.and') }}</div>
|
||||||
|
<div class="col">
|
||||||
|
<h4>{{ getPerson(modal.data.from).text }}</h4>
|
||||||
|
<p class="text-start" v-if="relation && relation.title">
|
||||||
|
<span v-if="reverse">
|
||||||
|
{{ $t('visgraph.relation_from_to_like', [ getPerson(modal.data.from).text, getPerson(modal.data.to).text, relation.reverseTitle.fr.toLowerCase() ])}}
|
||||||
|
</span>
|
||||||
|
<span v-else>
|
||||||
|
{{ $t('visgraph.relation_from_to_like', [ getPerson(modal.data.from).text, getPerson(modal.data.to).text, relation.title.fr.toLowerCase() ])}}
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="col text-end">
|
||||||
|
<h4>{{ getPerson(modal.data.to).text }}</h4>
|
||||||
|
<p class="text-end" v-if="relation && relation.title">
|
||||||
|
<span v-if="reverse">
|
||||||
|
{{ $t('visgraph.relation_from_to_like', [ getPerson(modal.data.to).text, getPerson(modal.data.from).text, relation.title.fr.toLowerCase() ])}}
|
||||||
|
</span>
|
||||||
|
<span v-else>
|
||||||
|
{{ $t('visgraph.relation_from_to_like', [ getPerson(modal.data.to).text, getPerson(modal.data.from).text, relation.reverseTitle.fr.toLowerCase() ])}}
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="my-3">
|
||||||
|
<VueMultiselect
|
||||||
|
id="relation"
|
||||||
|
label="title"
|
||||||
|
track-by="id"
|
||||||
|
:custom-label="customLabel"
|
||||||
|
:placeholder="$t('visgraph.choose_relation')"
|
||||||
|
:close-on-select="true"
|
||||||
|
:multiple="false"
|
||||||
|
:searchable="true"
|
||||||
|
:options="relations"
|
||||||
|
v-model="relation"
|
||||||
|
:value="relation"
|
||||||
|
>
|
||||||
|
</VueMultiselect>
|
||||||
|
</div>
|
||||||
|
<div class="form-check form-switch">
|
||||||
|
<input
|
||||||
|
class="form-check-input"
|
||||||
|
type="checkbox"
|
||||||
|
id="reverse"
|
||||||
|
v-model="reverse"
|
||||||
|
>
|
||||||
|
<label class="form-check-label" for="reverse">{{ $t('visgraph.reverse_relation') }}</label>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template v-slot:footer>
|
||||||
|
<button class="btn" :class="modal.button.class" @click="submitRelationship">
|
||||||
|
{{ $t(modal.button.text)}}
|
||||||
|
</button>
|
||||||
|
<button class="btn btn-delete" v-if="modal.action === 'edit'" @click="dropRelationship"></button>
|
||||||
|
</template>
|
||||||
|
</modal>
|
||||||
|
</teleport>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import vis from 'vis-network/dist/vis-network'
|
||||||
|
import { mapState, mapGetters } from "vuex"
|
||||||
|
import Modal from 'ChillMainAssets/vuejs/_components/Modal'
|
||||||
|
import VueMultiselect from 'vue-multiselect'
|
||||||
|
import { getRelationsList, postRelationship, patchRelationship, deleteRelationship } from "./api";
|
||||||
|
import { splitId } from "./vis-network";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "App",
|
||||||
|
components: {
|
||||||
|
Modal,
|
||||||
|
VueMultiselect
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
container: '',
|
||||||
|
checkedLayers: [],
|
||||||
|
relations: [],
|
||||||
|
displayHelpMessage: false,
|
||||||
|
listenPersonFlag: 'normal',
|
||||||
|
newEdgeData: {},
|
||||||
|
modal: {
|
||||||
|
showModal: false,
|
||||||
|
modalDialogClass: "modal-md",
|
||||||
|
title: null,
|
||||||
|
action: null,
|
||||||
|
data: {
|
||||||
|
type: 'relationship',
|
||||||
|
from: null,
|
||||||
|
to: null,
|
||||||
|
relation: null,
|
||||||
|
reverse: false
|
||||||
|
},
|
||||||
|
button: {
|
||||||
|
class: null,
|
||||||
|
text: null
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['nodes', 'edges',
|
||||||
|
// not used 'isInWhitelist', 'isHouseholdLoading', 'isCourseLoaded', 'isRelationshipLoaded', 'isPersonLoaded', 'isExcludedNode', 'countLinksByNode', 'getParticipationsByCourse', 'getMembersByHousehold', 'getPersonsGroup',
|
||||||
|
]),
|
||||||
|
...mapState(['persons', 'households', 'courses', 'excludedNodesIds', 'updateHack',
|
||||||
|
// not used 'links', 'relationships', 'whitelistIds', 'personLoadedIds', 'householdLoadingIds', 'courseLoadedIds', 'relationshipLoadedIds',
|
||||||
|
]),
|
||||||
|
|
||||||
|
visgraph_data() {
|
||||||
|
console.log('::: visgraph_data :::', this.nodes.length, 'nodes,', this.edges.length, 'edges')
|
||||||
|
return {
|
||||||
|
nodes: this.nodes,
|
||||||
|
edges: this.edges
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
refreshNetwork() {
|
||||||
|
console.log('--- refresh network')
|
||||||
|
window.network.setData(this.visgraph_data)
|
||||||
|
},
|
||||||
|
|
||||||
|
legendLayers() {
|
||||||
|
console.log('--- refresh legend and rebuild checked Layers')
|
||||||
|
this.checkedLayers = []
|
||||||
|
let layersDisplayed = [
|
||||||
|
...this.nodes.filter(n => n.id.startsWith('household')),
|
||||||
|
...this.nodes.filter(n => n.id.startsWith('accompanying'))
|
||||||
|
]
|
||||||
|
layersDisplayed.forEach(layer => {
|
||||||
|
this.checkedLayers.push(layer.id)
|
||||||
|
})
|
||||||
|
return [
|
||||||
|
...this.households,
|
||||||
|
...this.courses
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
checkedLayers() { // required to refresh data checkedLayers
|
||||||
|
console.log('--- checkedLayers')
|
||||||
|
return this.checkedLayers
|
||||||
|
},
|
||||||
|
|
||||||
|
relation: {
|
||||||
|
get() {
|
||||||
|
return this.modal.data.relation
|
||||||
|
},
|
||||||
|
set(value) {
|
||||||
|
this.modal.data.relation = value
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
reverse: {
|
||||||
|
get() {
|
||||||
|
return this.modal.data.reverse
|
||||||
|
},
|
||||||
|
set(value) {
|
||||||
|
this.modal.data.reverse = value
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
updateHack(newValue, oldValue) {
|
||||||
|
console.log(`--- updateHack ${oldValue} <> ${newValue}`)
|
||||||
|
if (oldValue !== newValue) {
|
||||||
|
this.forceUpdateComponent()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
//console.log('=== mounted: init graph')
|
||||||
|
this.initGraph()
|
||||||
|
this.listenOnGraph()
|
||||||
|
this.getRelationsList()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
|
||||||
|
initGraph() {
|
||||||
|
this.container = document.getElementById('visgraph')
|
||||||
|
// Instanciate vis objects in separate window variables, see vis-network.js
|
||||||
|
window.network = new vis.Network(this.container, this.visgraph_data, window.options)
|
||||||
|
},
|
||||||
|
forceUpdateComponent() {
|
||||||
|
//console.log('!! forceUpdateComponent !!')
|
||||||
|
this.refreshNetwork
|
||||||
|
this.$forceUpdate()
|
||||||
|
},
|
||||||
|
|
||||||
|
// events
|
||||||
|
listenOnGraph() {
|
||||||
|
window.network.on('selectNode', (data) => {
|
||||||
|
if (data.nodes.length > 1) {
|
||||||
|
throw 'Multi selection is not allowed. Disable it in options.interaction !'
|
||||||
|
}
|
||||||
|
let node = data.nodes[0]
|
||||||
|
let nodeType = splitId(node, 'type')
|
||||||
|
switch (nodeType) {
|
||||||
|
|
||||||
|
case 'person':
|
||||||
|
let person = this.nodes.filter(n => n.id === node)[0]
|
||||||
|
console.log('@@@@@@ event on selected Node', person.id)
|
||||||
|
if (this.listenPersonFlag === 'normal') {
|
||||||
|
if (person.folded === true) {
|
||||||
|
console.log(' @@> expand mode event')
|
||||||
|
this.$store.commit('unfoldPerson', person)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log(' @@> create link mode event')
|
||||||
|
this.listenStepsToAddRelationship(person)
|
||||||
|
}
|
||||||
|
break
|
||||||
|
|
||||||
|
case 'household':
|
||||||
|
let household = this.nodes.filter(n => n.id === node)[0]
|
||||||
|
console.log('@@@@@@ event on selected Node', household.id)
|
||||||
|
this.$store.dispatch('unfoldPersonsByHousehold', household)
|
||||||
|
break
|
||||||
|
|
||||||
|
case 'accompanying_period':
|
||||||
|
let course = this.nodes.filter(n => n.id === node)[0]
|
||||||
|
console.log('@@@@@@ event on selected Node', course.id)
|
||||||
|
this.$store.dispatch('unfoldPersonsByCourse', course)
|
||||||
|
break
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw 'event is undefined for this type of node'
|
||||||
|
}
|
||||||
|
this.forceUpdateComponent()
|
||||||
|
})
|
||||||
|
window.network.on('selectEdge', (data) => {
|
||||||
|
if (data.nodes.length !== 0 || data.edges.length !== 1) {
|
||||||
|
return false //we don't want to trigger nodeEdge or multiselect !
|
||||||
|
}
|
||||||
|
let link = data.edges[0]
|
||||||
|
let linkType = splitId(link, 'link')
|
||||||
|
console.log('@@@@@ event on selected Edge', data.edges.length, linkType, data)
|
||||||
|
|
||||||
|
if (linkType.startsWith('relationship')) {
|
||||||
|
//console.log('linkType relationship')
|
||||||
|
|
||||||
|
let relationships = this.edges.filter(l => l.id === link)
|
||||||
|
if (relationships.length > 1) {
|
||||||
|
throw 'error: only one link is allowed between two person!'
|
||||||
|
}
|
||||||
|
|
||||||
|
let relationship = relationships[0]
|
||||||
|
//console.log(relationship)
|
||||||
|
|
||||||
|
this.editRelationshipModal({
|
||||||
|
from: relationship.from,
|
||||||
|
to: relationship.to,
|
||||||
|
id: relationship.id,
|
||||||
|
relation: relationship.relation,
|
||||||
|
reverse: relationship.reverse
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
listenStepsToAddRelationship(person) {
|
||||||
|
console.log(' @@> listenStep', this.listenPersonFlag)
|
||||||
|
if (this.listenPersonFlag === 'step2') {
|
||||||
|
//console.log(' @@> person 2', person)
|
||||||
|
this.newEdgeData.to = person.id
|
||||||
|
this.addRelationshipModal(this.newEdgeData)
|
||||||
|
this.displayHelpMessage = false
|
||||||
|
this.listenPersonFlag = 'normal'
|
||||||
|
this.newEdgeData = {}
|
||||||
|
}
|
||||||
|
if (this.listenPersonFlag === 'step1') {
|
||||||
|
//console.log(' @@> person 1', person)
|
||||||
|
this.newEdgeData.from = person.id
|
||||||
|
this.listenPersonFlag = 'step2'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/// control Layers
|
||||||
|
toggleLayer(value) {
|
||||||
|
let id = value.target.value
|
||||||
|
console.log('@@@@@@ toggle Layer', id)
|
||||||
|
this.forceUpdateComponent()
|
||||||
|
if (this.checkedLayers.includes(id)) {
|
||||||
|
this.removeLayer(id)
|
||||||
|
} else {
|
||||||
|
this.addLayer(id)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
addLayer(id) {
|
||||||
|
//console.log('+ addLayer', id)
|
||||||
|
this.checkedLayers.push(id)
|
||||||
|
this.$store.dispatch('excludedNode', ['remove', id])
|
||||||
|
},
|
||||||
|
removeLayer(id) {
|
||||||
|
//console.log('- removeLayer', id)
|
||||||
|
this.checkedLayers = this.checkedLayers.filter(i => i !== id)
|
||||||
|
this.$store.dispatch('excludedNode', ['add', id])
|
||||||
|
},
|
||||||
|
|
||||||
|
/// control Modal
|
||||||
|
addRelationshipModal(edgeData) {
|
||||||
|
//console.log('==- addRelationshipModal', edgeData)
|
||||||
|
this.modal = {
|
||||||
|
data: { from: edgeData.from, to: edgeData.to },
|
||||||
|
action: 'create',
|
||||||
|
showModal: true,
|
||||||
|
title: 'visgraph.add_relationship_link',
|
||||||
|
button: { class: 'btn-create', text: 'action.create' }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
editRelationshipModal(edgeData) {
|
||||||
|
//console.log('==- editRelationshipModal', edgeData)
|
||||||
|
this.modal = {
|
||||||
|
data: edgeData,
|
||||||
|
action: 'edit',
|
||||||
|
showModal: true,
|
||||||
|
title: 'visgraph.edit_relationship_link',
|
||||||
|
button: { class: 'btn-edit', text: 'action.edit' }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// form
|
||||||
|
resetForm() {
|
||||||
|
this.modal = {
|
||||||
|
data: { type: 'relationship', from: null, to: null, relation: null, reverse: false },
|
||||||
|
action: null,
|
||||||
|
title: null,
|
||||||
|
button: { class: null, text: null, }
|
||||||
|
}
|
||||||
|
console.log('==- reset Form', this.modal.data)
|
||||||
|
},
|
||||||
|
getRelationsList() {
|
||||||
|
//console.log('fetch relationsList')
|
||||||
|
return getRelationsList().then(relations => new Promise(resolve => {
|
||||||
|
//console.log('+ relations list', relations.results.length)
|
||||||
|
this.relations = relations.results.filter(r => r.isActive === true)
|
||||||
|
resolve()
|
||||||
|
})).catch()
|
||||||
|
},
|
||||||
|
customLabel(value) {
|
||||||
|
//console.log('customLabel', value)
|
||||||
|
return (value.title && value.reverseTitle) ? `${value.title.fr} ↔ ${value.reverseTitle.fr}` : ''
|
||||||
|
},
|
||||||
|
getPerson(id) {
|
||||||
|
let person = this.persons.filter(p => p.id === id)
|
||||||
|
return person[0]
|
||||||
|
},
|
||||||
|
|
||||||
|
// actions
|
||||||
|
createRelationship() {
|
||||||
|
this.displayHelpMessage = true
|
||||||
|
this.listenPersonFlag = 'step1' // toggle listener in create link mode
|
||||||
|
console.log(' @@> switch listener to create link mode:', this.listenPersonFlag)
|
||||||
|
},
|
||||||
|
dropRelationship() {
|
||||||
|
//console.log('delete', this.modal.data)
|
||||||
|
deleteRelationship(this.modal.data)
|
||||||
|
.catch()
|
||||||
|
this.$store.commit('removeLink', this.modal.data.id)
|
||||||
|
this.modal.showModal = false
|
||||||
|
this.resetForm()
|
||||||
|
},
|
||||||
|
submitRelationship() {
|
||||||
|
console.log('submitRelationship', this.modal.action)
|
||||||
|
switch (this.modal.action) {
|
||||||
|
|
||||||
|
case 'create':
|
||||||
|
return postRelationship(this.modal.data)
|
||||||
|
.then(relationship => new Promise(resolve => {
|
||||||
|
console.log('post relationship response', relationship)
|
||||||
|
this.$store.dispatch('addLinkFromRelationship', relationship)
|
||||||
|
this.modal.showModal = false
|
||||||
|
this.resetForm()
|
||||||
|
resolve()
|
||||||
|
}))
|
||||||
|
.catch()
|
||||||
|
|
||||||
|
case 'edit':
|
||||||
|
return patchRelationship(this.modal.data)
|
||||||
|
.then(relationship => new Promise(resolve => {
|
||||||
|
console.log('patch relationship response', relationship)
|
||||||
|
this.$store.commit('updateLink', relationship)
|
||||||
|
this.modal.showModal = false
|
||||||
|
this.resetForm()
|
||||||
|
resolve()
|
||||||
|
}))
|
||||||
|
.catch()
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw "uncaught action"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// export image
|
||||||
|
exportCanvasAsImage() {
|
||||||
|
const canvas = document.getElementById('visgraph')
|
||||||
|
.querySelector('canvas')
|
||||||
|
console.log(canvas)
|
||||||
|
|
||||||
|
let link = document.getElementById('exportCanvasBtn')
|
||||||
|
link.download = "filiation.png"
|
||||||
|
|
||||||
|
canvas.toBlob(blob => {
|
||||||
|
console.log(blob)
|
||||||
|
link.href = URL.createObjectURL(blob)
|
||||||
|
}, 'image/png')
|
||||||
|
|
||||||
|
/*
|
||||||
|
TODO improve feature
|
||||||
|
|
||||||
|
// 1. fonctionne, mais pas de contrôle sur le nom
|
||||||
|
if (canvas && canvas.getContext('2d')) {
|
||||||
|
let img = canvas.toDataURL('image/png;base64;')
|
||||||
|
img = img.replace('image/png','image/octet-stream')
|
||||||
|
window.open(img, '', 'width=1000, height=1000')
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. fonctionne, mais 2 click et pas compatible avec tous les browsers
|
||||||
|
let link = document.getElementById('exportCanvasBtn')
|
||||||
|
link.download = "image.png"
|
||||||
|
canvas.toBlob(blob => {
|
||||||
|
link.href = URL.createObjectURL(blob)
|
||||||
|
}, 'image/png')
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style src="vis-network/dist/dist/vis-network.min.css"></style>
|
||||||
|
<style src="vue-multiselect/dist/vue-multiselect.css"></style>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
div#visgraph {
|
||||||
|
height: 700px;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
div#visgraph-legend {
|
||||||
|
div.post-menu.legend {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.modal-mask {
|
||||||
|
background-color: rgba(0, 0, 0, 0.25);
|
||||||
|
}
|
||||||
|
.debug {
|
||||||
|
margin: 1em; padding: 1em;
|
||||||
|
color: dimgray;
|
||||||
|
font-style: italic;
|
||||||
|
font-size: 80%;
|
||||||
|
}
|
||||||
|
</style>
|
@ -0,0 +1,195 @@
|
|||||||
|
import { splitId } from './vis-network'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function makeFetch
|
||||||
|
* @param method
|
||||||
|
* @param url
|
||||||
|
* @param body
|
||||||
|
* @returns {Promise<Response>}
|
||||||
|
*/
|
||||||
|
const makeFetch = (method, url, body) => {
|
||||||
|
return fetch(url, {
|
||||||
|
method: method,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json;charset=utf-8'
|
||||||
|
},
|
||||||
|
body: (body !== null) ? JSON.stringify(body) : null
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
|
||||||
|
if (response.ok) {
|
||||||
|
return response.json();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (response.status === 422) {
|
||||||
|
return response.json().then(violations => {
|
||||||
|
throw ValidationException(violations)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
throw {
|
||||||
|
msg: 'Error while updating AccompanyingPeriod Course.',
|
||||||
|
sta: response.status,
|
||||||
|
txt: response.statusText,
|
||||||
|
err: new Error(),
|
||||||
|
body: response.body
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param violations
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
const ValidationException = (violations) => {
|
||||||
|
this.violations = violations
|
||||||
|
this.name = 'ValidationException'
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function getFetch
|
||||||
|
* @param url
|
||||||
|
* @returns {Promise<Response>}
|
||||||
|
*/
|
||||||
|
const getFetch = (url) => {
|
||||||
|
return makeFetch('GET', url, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function postFetch
|
||||||
|
* @param url
|
||||||
|
* @param body
|
||||||
|
* @returns {Promise<Response>}
|
||||||
|
*/
|
||||||
|
const postFetch = (url, body) => {
|
||||||
|
return makeFetch('POST', url, body)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function patchFetch
|
||||||
|
* @param url
|
||||||
|
* @param body
|
||||||
|
* @returns {Promise<Response>}
|
||||||
|
*/
|
||||||
|
const patchFetch = (url, body) => {
|
||||||
|
return makeFetch('PATCH', url, body)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function deleteFetch
|
||||||
|
* @param url
|
||||||
|
* @param body
|
||||||
|
* @returns {Promise<Response>}
|
||||||
|
*/
|
||||||
|
const deleteFetch = (url, body) => {
|
||||||
|
return makeFetch('DELETE', url, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function getHouseholdByPerson
|
||||||
|
* @param person
|
||||||
|
* @returns {Promise<Response>}
|
||||||
|
*/
|
||||||
|
const getHouseholdByPerson = (person) => {
|
||||||
|
//console.log('getHouseholdByPerson', person.id)
|
||||||
|
if (person.current_household_id === null) {
|
||||||
|
throw 'Currently the person has not household!'
|
||||||
|
}
|
||||||
|
return getFetch(
|
||||||
|
`/api/1.0/person/household/${person.current_household_id}.json`)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function getCoursesByPerson
|
||||||
|
* @param person
|
||||||
|
* @returns {Promise<Response>}
|
||||||
|
*/
|
||||||
|
const getCoursesByPerson = (person) => {
|
||||||
|
//console.log('getCoursesByPerson', person._id)
|
||||||
|
return getFetch(
|
||||||
|
`/api/1.0/person/accompanying-course/by-person/${person._id}.json`)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function getRelationshipsByPerson
|
||||||
|
* @param person
|
||||||
|
* @returns {Promise<Response>}
|
||||||
|
*/
|
||||||
|
const getRelationshipsByPerson = (person) => {
|
||||||
|
//console.log('getRelationshipsByPerson', person.id)
|
||||||
|
return getFetch(
|
||||||
|
`/api/1.0/relations/relationship/by-person/${person._id}.json`)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return list of relations
|
||||||
|
* @returns {Promise<Response>}
|
||||||
|
*/
|
||||||
|
const getRelationsList = () => {
|
||||||
|
return getFetch(`/api/1.0/relations/relation.json`)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function postRelationship
|
||||||
|
* @param relationship
|
||||||
|
* @returns {Promise<Response>}
|
||||||
|
*/
|
||||||
|
const postRelationship = (relationship) => {
|
||||||
|
//console.log(relationship)
|
||||||
|
return postFetch(
|
||||||
|
`/api/1.0/relations/relationship.json`,
|
||||||
|
{
|
||||||
|
type: 'relationship',
|
||||||
|
fromPerson: { type: 'person', id: splitId(relationship.from, 'id') },
|
||||||
|
toPerson: { type: 'person', id: splitId(relationship.to, 'id') },
|
||||||
|
relation: { type: 'relation', id: relationship.relation.id },
|
||||||
|
reverse: relationship.reverse
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function patchRelationship
|
||||||
|
* @param relationship
|
||||||
|
* @returns {Promise<Response>}
|
||||||
|
*/
|
||||||
|
const patchRelationship = (relationship) => {
|
||||||
|
//console.log(relationship)
|
||||||
|
let linkType = splitId(relationship.id, 'link')
|
||||||
|
let id = splitId(linkType, 'id')
|
||||||
|
return patchFetch(
|
||||||
|
`/api/1.0/relations/relationship/${id}.json`,
|
||||||
|
{
|
||||||
|
type: 'relationship',
|
||||||
|
fromPerson: { type: 'person', id: splitId(relationship.from, 'id') },
|
||||||
|
toPerson: { type: 'person', id: splitId(relationship.to, 'id') },
|
||||||
|
relation: { type: 'relation', id: relationship.relation.id },
|
||||||
|
reverse: relationship.reverse
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function deleteRelationship
|
||||||
|
* @param relationship
|
||||||
|
* @returns {Promise<Response>}
|
||||||
|
*/
|
||||||
|
const deleteRelationship = (relationship) => {
|
||||||
|
//console.log(relationship)
|
||||||
|
let linkType = splitId(relationship.id, 'link')
|
||||||
|
let id = splitId(linkType, 'id')
|
||||||
|
return deleteFetch(
|
||||||
|
`/api/1.0/relations/relationship/${id}.json`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
getHouseholdByPerson,
|
||||||
|
getCoursesByPerson,
|
||||||
|
getRelationshipsByPerson,
|
||||||
|
getRelationsList,
|
||||||
|
postRelationship,
|
||||||
|
patchRelationship,
|
||||||
|
deleteRelationship
|
||||||
|
}
|
@ -0,0 +1,62 @@
|
|||||||
|
const visMessages = {
|
||||||
|
fr: {
|
||||||
|
visgraph: {
|
||||||
|
Course: 'Parcours',
|
||||||
|
Household: 'Ménage',
|
||||||
|
Holder: 'Titulaire',
|
||||||
|
Legend: 'Calques',
|
||||||
|
concerned: 'concerné',
|
||||||
|
both: 'neutre, non binaire',
|
||||||
|
woman: 'féminin',
|
||||||
|
man: 'masculin',
|
||||||
|
years: 'ans',
|
||||||
|
click_to_expand: 'cliquez pour étendre',
|
||||||
|
add_relationship_link: "Créer un lien de filiation",
|
||||||
|
edit_relationship_link: "Modifier le lien de filiation",
|
||||||
|
delete_relationship_link: "Êtes-vous sûr ?",
|
||||||
|
delete_confirmation_text: "Vous allez supprimer le lien entre ces 2 usagers.",
|
||||||
|
reverse_relation: "Inverser la relation",
|
||||||
|
relation_from_to_like: "{2} de {1}", // disable {0}
|
||||||
|
between: "entre",
|
||||||
|
and: "et",
|
||||||
|
add_link: "Créer un lien de filiation",
|
||||||
|
create_link_help: "Pour créer un lien de filiation, cliquez d'abord sur un usager, puis sur un second ; précisez ensuite la nature du lien dans le formulaire d'édition.",
|
||||||
|
refresh: "Rafraîchir",
|
||||||
|
screenshot: "Prendre une photo",
|
||||||
|
choose_relation: "Choisissez le lien de parenté",
|
||||||
|
},
|
||||||
|
edit: 'Éditer',
|
||||||
|
del: 'Supprimer',
|
||||||
|
back: 'Revenir en arrière',
|
||||||
|
addNode: 'Ajouter un noeuds',
|
||||||
|
addEdge: 'Ajouter un lien de filiation',
|
||||||
|
editNode: 'Éditer le noeuds',
|
||||||
|
editEdge: 'Éditer le lien',
|
||||||
|
addDescription: 'Cliquez dans un espace vide pour créer un nouveau nœud.',
|
||||||
|
edgeDescription: 'Cliquez sur un usager et faites glisser le lien vers un autre usager pour les connecter.',
|
||||||
|
editEdgeDescription: 'Cliquez sur les points de contrôle et faites-les glisser vers un nœud pour les relier.',
|
||||||
|
createEdgeError: 'Il est impossible de relier des arêtes à un cluster.',
|
||||||
|
deleteClusterError: 'Les clusters ne peuvent pas être supprimés.',
|
||||||
|
editClusterError: 'Les clusters ne peuvent pas être modifiés.'
|
||||||
|
},
|
||||||
|
en: {
|
||||||
|
edit: 'Edit',
|
||||||
|
del: 'Delete selected',
|
||||||
|
back: 'Back',
|
||||||
|
addNode: 'Add Node',
|
||||||
|
addEdge: 'Add Link',
|
||||||
|
editNode: 'Edit Switch',
|
||||||
|
editEdge: 'Edit Link',
|
||||||
|
addDescription: 'Click in an empty space to place a new node.',
|
||||||
|
edgeDescription: 'Click on a node and drag the link to another node to connect them.',
|
||||||
|
editEdgeDescription: 'Click on the control points and drag them to a node to connect to it.',
|
||||||
|
createEdgeError: 'Cannot link edges to a cluster.',
|
||||||
|
deleteClusterError: 'Clusters cannot be deleted.',
|
||||||
|
editClusterError: 'Clusters cannot be edited.'
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
visMessages
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
import { createApp } from "vue"
|
||||||
|
import { store } from "./store.js"
|
||||||
|
import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n'
|
||||||
|
import { visMessages } from './i18n'
|
||||||
|
import App from './App.vue'
|
||||||
|
|
||||||
|
import './vis-network'
|
||||||
|
|
||||||
|
const i18n = _createI18n(visMessages)
|
||||||
|
const container = document.getElementById('relationship-graph')
|
||||||
|
const persons = JSON.parse(container.dataset.persons)
|
||||||
|
|
||||||
|
persons.forEach(person => {
|
||||||
|
store.dispatch('addPerson', person)
|
||||||
|
store.commit('markInWhitelist', person)
|
||||||
|
})
|
||||||
|
|
||||||
|
const app = createApp({
|
||||||
|
template: `<app></app>`
|
||||||
|
})
|
||||||
|
.use(store)
|
||||||
|
.use(i18n)
|
||||||
|
.component('app', App)
|
||||||
|
.mount('#relationship-graph')
|
@ -0,0 +1,534 @@
|
|||||||
|
import { createStore } from 'vuex'
|
||||||
|
import { getHouseholdByPerson, getCoursesByPerson, getRelationshipsByPerson } from './api'
|
||||||
|
import { getHouseholdLabel, getHouseholdWidth, getRelationshipLabel, getRelationshipTitle, getRelationshipDirection, splitId, getGender, getAge } from './vis-network'
|
||||||
|
import {visMessages} from "./i18n";
|
||||||
|
|
||||||
|
const debug = process.env.NODE_ENV !== 'production'
|
||||||
|
|
||||||
|
const store = createStore({
|
||||||
|
strict: debug,
|
||||||
|
state: {
|
||||||
|
persons: [],
|
||||||
|
households: [],
|
||||||
|
courses: [],
|
||||||
|
relationships: [],
|
||||||
|
links: [],
|
||||||
|
whitelistIds: [],
|
||||||
|
personLoadedIds: [],
|
||||||
|
householdLoadingIds: [],
|
||||||
|
courseLoadedIds: [],
|
||||||
|
relationshipLoadedIds: [],
|
||||||
|
excludedNodesIds: [],
|
||||||
|
updateHack: 0
|
||||||
|
},
|
||||||
|
getters: {
|
||||||
|
nodes(state) {
|
||||||
|
let nodes = []
|
||||||
|
state.persons.forEach(p => {
|
||||||
|
nodes.push(p)
|
||||||
|
})
|
||||||
|
state.households.forEach(h => {
|
||||||
|
nodes.push(h)
|
||||||
|
})
|
||||||
|
state.courses.forEach(c => {
|
||||||
|
nodes.push(c)
|
||||||
|
})
|
||||||
|
// except excluded nodes (unchecked layers)
|
||||||
|
state.excludedNodesIds.forEach(excluded => {
|
||||||
|
nodes = nodes.filter(n => n.id !== excluded)
|
||||||
|
})
|
||||||
|
return nodes
|
||||||
|
},
|
||||||
|
edges(state) {
|
||||||
|
return state.links
|
||||||
|
},
|
||||||
|
isInWhitelist: (state) => (person_id) => {
|
||||||
|
return state.whitelistIds.includes(person_id)
|
||||||
|
},
|
||||||
|
isHouseholdLoading: (state) => (household_id) => {
|
||||||
|
return state.householdLoadingIds.includes(household_id)
|
||||||
|
},
|
||||||
|
isCourseLoaded: (state) => (course_id) => {
|
||||||
|
return state.courseLoadedIds.includes(course_id)
|
||||||
|
},
|
||||||
|
isRelationshipLoaded: (state) => (relationship_id) => {
|
||||||
|
return state.relationshipLoadedIds.includes(relationship_id)
|
||||||
|
},
|
||||||
|
isPersonLoaded: (state) => (person_id) => {
|
||||||
|
return state.personLoadedIds.includes(person_id)
|
||||||
|
},
|
||||||
|
isExcludedNode: (state) => (id) => {
|
||||||
|
return state.excludedNodesIds.includes(id)
|
||||||
|
},
|
||||||
|
|
||||||
|
countLinksByNode: (state) => (node_id) => {
|
||||||
|
let array = []
|
||||||
|
state.links.filter(link => ! link.id.startsWith('relationship'))
|
||||||
|
.forEach(link => {
|
||||||
|
if (link.from === node_id || link.to === node_id) {
|
||||||
|
if (state.excludedNodesIds.indexOf(splitId(link.id, 'link')) === -1) {
|
||||||
|
array.push(link)
|
||||||
|
}
|
||||||
|
//console.log(link.id, state.excludedNodesIds.indexOf(splitId(link.id, 'link')))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
//console.log('count links', array.length, array.map(i => i.id))
|
||||||
|
return array.length
|
||||||
|
},
|
||||||
|
|
||||||
|
getParticipationsByCourse: (state) => (course_id) => {
|
||||||
|
const course = state.courses.filter(c => c.id === course_id)[0]
|
||||||
|
const currentParticipations = course.participations.filter(p => p.endDate === null)
|
||||||
|
//console.log('get persons in', course_id, currentParticipations.map(p => p.person.id),
|
||||||
|
// 'with folded', currentParticipations.filter(p => p.person.folded === true).map(p => p.person.id))
|
||||||
|
return currentParticipations
|
||||||
|
},
|
||||||
|
|
||||||
|
getMembersByHousehold: (state) => (household_id) => {
|
||||||
|
const household = state.households.filter(h => h.id === household_id)[0]
|
||||||
|
const currentMembers = household.members.filter(m => household.current_members_id.includes(m.id))
|
||||||
|
//console.log('get persons in', household_id, currentMembers.map(m => m.person.id),
|
||||||
|
// 'with folded', currentMembers.filter(m => m.person.folded === true).map(m => m.person.id))
|
||||||
|
return currentMembers
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This getter is a little bit mysterious :
|
||||||
|
* The 2 previous getters return complete array, but folded (missing) persons are not taken into consideration and are not displayed (!?!)
|
||||||
|
* This getter compare input array (participations|members) to personLoadedIds array
|
||||||
|
* and return complete array with folded persons taken into consideration
|
||||||
|
*
|
||||||
|
* @param state
|
||||||
|
* @param array - An array of persons from course or household.
|
||||||
|
* This array is dirty, melting persons adapted (or not) to vis, with _id and _label.
|
||||||
|
* @return array - An array of persons mapped and taken in state.persons
|
||||||
|
*/
|
||||||
|
getPersonsGroup: (state) => (array) => {
|
||||||
|
let group = []
|
||||||
|
array.forEach(item => {
|
||||||
|
let id = splitId(item.person.id, 'id')
|
||||||
|
if (state.personLoadedIds.includes(id)) {
|
||||||
|
group.push(state.persons.filter(person => person._id === id)[0])
|
||||||
|
}
|
||||||
|
})
|
||||||
|
//console.log('array', array.map(item => item.person.id))
|
||||||
|
console.log('get persons group', group.map(f => f.id))
|
||||||
|
return group
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
mutations: {
|
||||||
|
addPerson(state, [person, options]) {
|
||||||
|
let debug = ''
|
||||||
|
/// Debug mode: uncomment to display person_id on visgraph
|
||||||
|
//debug = `\nid ${person.id}`
|
||||||
|
person.group = person.type
|
||||||
|
person._id = person.id
|
||||||
|
person.id = `person_${person.id}`
|
||||||
|
person.label = `*${person.text}*\n_${getGender(person.gender)} - ${getAge(person.birthdate)}_${debug}` //
|
||||||
|
person.folded = false
|
||||||
|
// folded is used for missing persons
|
||||||
|
if (options.folded) {
|
||||||
|
person.title = visMessages.fr.visgraph.click_to_expand
|
||||||
|
person._label = person.label // keep label
|
||||||
|
person.label = null
|
||||||
|
person.folded = true
|
||||||
|
}
|
||||||
|
state.persons.push(person)
|
||||||
|
},
|
||||||
|
addHousehold(state, household) {
|
||||||
|
household.group = household.type
|
||||||
|
household._id = household.id
|
||||||
|
household.label = `${visMessages.fr.visgraph.Household} n° ${household.id}`
|
||||||
|
household.id = `household_${household.id}`
|
||||||
|
state.households.push(household)
|
||||||
|
},
|
||||||
|
addCourse(state, course) {
|
||||||
|
course.group = course.type
|
||||||
|
course._id = course.id
|
||||||
|
course.label = `${visMessages.fr.visgraph.Course} n° ${course.id}`
|
||||||
|
course.id = `accompanying_period_${course.id}`
|
||||||
|
state.courses.push(course)
|
||||||
|
},
|
||||||
|
addRelationship(state, relationship) {
|
||||||
|
relationship.group = relationship.type
|
||||||
|
relationship._id = relationship.id
|
||||||
|
relationship.id = `relationship_${relationship.id}`
|
||||||
|
state.relationships.push(relationship)
|
||||||
|
},
|
||||||
|
addLink(state, link) {
|
||||||
|
state.links.push(link)
|
||||||
|
},
|
||||||
|
updateLink(state, link) {
|
||||||
|
console.log('updateLink', link)
|
||||||
|
let link_ = {
|
||||||
|
from: `person_${link.fromPerson.id}`,
|
||||||
|
to: `person_${link.toPerson.id}`,
|
||||||
|
id: 'relationship_' + splitId(link.id,'id')
|
||||||
|
+ '-person_' + link.fromPerson.id + '-person_' + link.toPerson.id,
|
||||||
|
arrows: getRelationshipDirection(link),
|
||||||
|
color: 'lightblue',
|
||||||
|
font: { color: '#33839d' },
|
||||||
|
dashes: true,
|
||||||
|
label: getRelationshipLabel(link),
|
||||||
|
title: getRelationshipTitle(link),
|
||||||
|
relation: link.relation,
|
||||||
|
reverse: link.reverse
|
||||||
|
}
|
||||||
|
// find row position and replace by updatedLink
|
||||||
|
state.links.splice(
|
||||||
|
state.links.findIndex(item => item.id === link_.id), 1, link_
|
||||||
|
)
|
||||||
|
},
|
||||||
|
removeLink(state, link_id) {
|
||||||
|
state.links = state.links.filter(l => l.id !== link_id)
|
||||||
|
},
|
||||||
|
|
||||||
|
//// id markers
|
||||||
|
markInWhitelist(state, person) {
|
||||||
|
state.whitelistIds.push(person.id)
|
||||||
|
},
|
||||||
|
markPersonLoaded(state, id) {
|
||||||
|
state.personLoadedIds.push(id)
|
||||||
|
},
|
||||||
|
unmarkPersonLoaded(state, id) {
|
||||||
|
state.personLoadedIds = state.personLoadedIds.filter(i => i !== id)
|
||||||
|
},
|
||||||
|
markHouseholdLoading(state, id) {
|
||||||
|
//console.log('..loading household', id)
|
||||||
|
state.householdLoadingIds.push(id)
|
||||||
|
},
|
||||||
|
unmarkHouseholdLoading(state, id) {
|
||||||
|
state.householdLoadingIds = state.householdLoadingIds.filter(i => i !== id)
|
||||||
|
},
|
||||||
|
markCourseLoaded(state, id) {
|
||||||
|
state.courseLoadedIds.push(id)
|
||||||
|
},
|
||||||
|
unmarkCourseLoaded(state, id) {
|
||||||
|
state.courseLoadedIds = state.courseLoadedIds.filter(i => i !== id)
|
||||||
|
},
|
||||||
|
markRelationshipLoaded(state, id) {
|
||||||
|
state.relationshipLoadedIds.push(id)
|
||||||
|
},
|
||||||
|
unmarkRelationshipLoaded(state, id) {
|
||||||
|
state.relationshipLoadedIds = state.relationshipLoadedIds.filter(i => i !== id)
|
||||||
|
},
|
||||||
|
|
||||||
|
//// excluded
|
||||||
|
addExcludedNode(state, id) {
|
||||||
|
//console.log('==> exclude list: +', id)
|
||||||
|
state.excludedNodesIds.push(id)
|
||||||
|
},
|
||||||
|
removeExcludedNode(state, id) {
|
||||||
|
//console.log('<== exclude list: -', id)
|
||||||
|
state.excludedNodesIds = state.excludedNodesIds.filter(e => e !== id)
|
||||||
|
},
|
||||||
|
|
||||||
|
//// unfold
|
||||||
|
unfoldPerson(state, person) {
|
||||||
|
//console.log('unfoldPerson', person)
|
||||||
|
person.label = person._label
|
||||||
|
delete person._label
|
||||||
|
delete person.title
|
||||||
|
person.folded = false
|
||||||
|
},
|
||||||
|
|
||||||
|
//// force update hack
|
||||||
|
updateHack(state) {
|
||||||
|
state.updateHack = state.updateHack + 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
/**
|
||||||
|
* Expand loop (steps 1->10), always start from a person.
|
||||||
|
* Fetch household, courses, relationships, and others persons.
|
||||||
|
* These persons are "missing" and will be first display in fold mode.
|
||||||
|
*
|
||||||
|
* 1) Add a new person
|
||||||
|
* @param object
|
||||||
|
* @param person
|
||||||
|
*/
|
||||||
|
addPerson({ commit, dispatch }, person) {
|
||||||
|
commit('markPersonLoaded', person.id)
|
||||||
|
commit('addPerson', [person, { folded: false }])
|
||||||
|
commit('updateHack')
|
||||||
|
dispatch('fetchInfoForPerson', person)
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 2) Fetch infos for this person (hub)
|
||||||
|
* @param object
|
||||||
|
* @param person
|
||||||
|
*/
|
||||||
|
fetchInfoForPerson({ dispatch }, person) {
|
||||||
|
// TODO enfants hors ménages
|
||||||
|
// example: household 61
|
||||||
|
// console.log(person.text, 'household', person.current_household_id)
|
||||||
|
if (null !== person.current_household_id) {
|
||||||
|
dispatch('fetchHouseholdForPerson', person)
|
||||||
|
}
|
||||||
|
dispatch('fetchCoursesByPerson', person)
|
||||||
|
dispatch('fetchRelationshipByPerson', person)
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 3) Fetch person current household (if it is not already loading)
|
||||||
|
* check first isHouseholdLoading to fetch household once
|
||||||
|
* @param object
|
||||||
|
* @param person
|
||||||
|
*/
|
||||||
|
fetchHouseholdForPerson({ commit, getters, dispatch }, person) {
|
||||||
|
//console.log(' isHouseholdLoading ?', getters.isHouseholdLoading(person.current_household_id))
|
||||||
|
if (! getters.isHouseholdLoading(person.current_household_id)) {
|
||||||
|
commit('markHouseholdLoading', person.current_household_id)
|
||||||
|
getHouseholdByPerson(person)
|
||||||
|
.then(household => new Promise(resolve => {
|
||||||
|
commit('addHousehold', household)
|
||||||
|
// DISABLED: in init or expand loop, layer is uncheck when added
|
||||||
|
//commit('addExcludedNode', household.id)
|
||||||
|
//commit('updateHack')
|
||||||
|
dispatch('addLinkFromPersonsToHousehold', household)
|
||||||
|
commit('updateHack')
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
|
).catch( () => {
|
||||||
|
commit('unmarkHouseholdLoading', person.current_household_id)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 4) Add an edge for each household member (household -> person)
|
||||||
|
* @param object
|
||||||
|
* @param household
|
||||||
|
*/
|
||||||
|
addLinkFromPersonsToHousehold({ commit, getters, dispatch }, household) {
|
||||||
|
let members = getters.getMembersByHousehold(household.id)
|
||||||
|
console.log('add link for', members.length, 'members')
|
||||||
|
members.forEach(m => {
|
||||||
|
commit('addLink', {
|
||||||
|
from: `${m.person.type}_${m.person.id}`,
|
||||||
|
to: `household_${m.person.current_household_id}`,
|
||||||
|
id: `household_${m.person.current_household_id}-person_${m.person.id}`,
|
||||||
|
arrows: 'from',
|
||||||
|
color: 'pink',
|
||||||
|
font: { color: '#D04A60' },
|
||||||
|
label: getHouseholdLabel(m),
|
||||||
|
width: getHouseholdWidth(m),
|
||||||
|
})
|
||||||
|
if (!getters.isPersonLoaded(m.person.id)) {
|
||||||
|
dispatch('addMissingPerson', [m.person, household])
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 5) Fetch AccompanyingCourses for the person
|
||||||
|
* @param object
|
||||||
|
* @param person
|
||||||
|
*/
|
||||||
|
fetchCoursesByPerson({ commit, dispatch }, person) {
|
||||||
|
getCoursesByPerson(person)
|
||||||
|
.then(courses => new Promise(resolve => {
|
||||||
|
dispatch('addCourses', courses)
|
||||||
|
resolve()
|
||||||
|
}))
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 6) Add each distinct course (a person can have multiple courses)
|
||||||
|
* @param object
|
||||||
|
* @param courses
|
||||||
|
*/
|
||||||
|
addCourses({ commit, getters, dispatch }, courses) {
|
||||||
|
let currentCourses = courses.filter(c => c.closingDate === null)
|
||||||
|
currentCourses.forEach(course => {
|
||||||
|
//console.log(' isCourseLoaded ?', getters.isCourseLoaded(course.id))
|
||||||
|
if (! getters.isCourseLoaded(course.id)) {
|
||||||
|
commit('markCourseLoaded', course.id)
|
||||||
|
commit('addCourse', course)
|
||||||
|
commit('addExcludedNode', course.id) // in init or expand loop, layer is uncheck when added
|
||||||
|
dispatch('addLinkFromPersonsToCourse', course)
|
||||||
|
commit('updateHack')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 7) Add an edge for each course participation (course <- person)
|
||||||
|
* @param object
|
||||||
|
* @param course
|
||||||
|
*/
|
||||||
|
addLinkFromPersonsToCourse({ commit, getters, dispatch }, course) {
|
||||||
|
const participations = getters.getParticipationsByCourse(course.id)
|
||||||
|
console.log('add link for', participations.length, 'participations')
|
||||||
|
participations.forEach(p => {
|
||||||
|
//console.log(p.person.id)
|
||||||
|
commit('addLink', {
|
||||||
|
from: `${p.person.type}_${p.person.id}`,
|
||||||
|
to: `${course.id}`,
|
||||||
|
id: `accompanying_period_${splitId(course.id,'id')}-person_${p.person.id}`,
|
||||||
|
arrows: 'from',
|
||||||
|
color: 'orange',
|
||||||
|
font: { color: 'darkorange' },
|
||||||
|
})
|
||||||
|
if (!getters.isPersonLoaded(p.person.id)) {
|
||||||
|
dispatch('addMissingPerson', [p.person, course])
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 8) Fetch Relationship
|
||||||
|
* @param object
|
||||||
|
* @param person
|
||||||
|
*/
|
||||||
|
fetchRelationshipByPerson({ dispatch }, person) {
|
||||||
|
//console.log('fetchRelationshipByPerson', person)
|
||||||
|
getRelationshipsByPerson(person)
|
||||||
|
.then(relationships => new Promise(resolve => {
|
||||||
|
dispatch('addRelationships', relationships)
|
||||||
|
resolve()
|
||||||
|
}))
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 9) Add each distinct relationship
|
||||||
|
* @param object
|
||||||
|
* @param relationships
|
||||||
|
*/
|
||||||
|
addRelationships({ commit, getters, dispatch }, relationships) {
|
||||||
|
relationships.forEach(relationship => {
|
||||||
|
//console.log(' isRelationshipLoaded ?', getters.isRelationshipLoaded(relationship.id))
|
||||||
|
if (! getters.isRelationshipLoaded(relationship.id)) {
|
||||||
|
commit('markRelationshipLoaded', relationship.id)
|
||||||
|
commit('addRelationship', relationship)
|
||||||
|
dispatch('addLinkFromRelationship', relationship)
|
||||||
|
commit('updateHack')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 10) Add an edge for each relationship (person -> person)
|
||||||
|
* @param object
|
||||||
|
* @param relationship
|
||||||
|
*/
|
||||||
|
addLinkFromRelationship({ commit, getters, dispatch }, relationship) {
|
||||||
|
//console.log('-> addLink from person', relationship.fromPerson.id, 'to person', relationship.toPerson.id)
|
||||||
|
commit('addLink', {
|
||||||
|
from: `person_${relationship.fromPerson.id}`,
|
||||||
|
to: `person_${relationship.toPerson.id}`,
|
||||||
|
id: 'relationship_' + splitId(relationship.id,'id')
|
||||||
|
+ '-person_' + relationship.fromPerson.id + '-person_' + relationship.toPerson.id,
|
||||||
|
arrows: getRelationshipDirection(relationship),
|
||||||
|
color: 'lightblue',
|
||||||
|
font: { color: '#33839d' },
|
||||||
|
dashes: true,
|
||||||
|
label: getRelationshipLabel(relationship),
|
||||||
|
title: getRelationshipTitle(relationship),
|
||||||
|
relation: relationship.relation,
|
||||||
|
reverse: relationship.reverse
|
||||||
|
})
|
||||||
|
for (let person of [relationship.fromPerson, relationship.toPerson]) {
|
||||||
|
if (!getters.isPersonLoaded(person.id)) {
|
||||||
|
dispatch('addMissingPerson', [person, relationship])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add missing person. node is displayed without label (folded).
|
||||||
|
* We stop here and listen on events to unfold person and expand its fetch infos
|
||||||
|
* @param object
|
||||||
|
* @param array
|
||||||
|
*/
|
||||||
|
addMissingPerson({ commit, getters, dispatch }, [person, parent]) {
|
||||||
|
console.log('! add missing Person', person.id)
|
||||||
|
commit('markPersonLoaded', person.id)
|
||||||
|
commit('addPerson', [person, { folded: true }])
|
||||||
|
if (getters.isExcludedNode(parent.id)) {
|
||||||
|
// in init or expand loop, exclude too missing persons if parent have been excluded
|
||||||
|
commit('addExcludedNode', person.id)
|
||||||
|
}
|
||||||
|
commit('updateHack')
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ==================================================================
|
||||||
|
* Triggered by a vis-network event when clicking on a Course Node.
|
||||||
|
* Each folded node is unfold, then expanded with fetch infos
|
||||||
|
* @param object
|
||||||
|
* @param course
|
||||||
|
*/
|
||||||
|
unfoldPersonsByCourse({ getters, commit, dispatch }, course) {
|
||||||
|
const participations = getters.getParticipationsByCourse(course.id)
|
||||||
|
getters.getPersonsGroup(participations)
|
||||||
|
.forEach(person => {
|
||||||
|
if (person.folded === true) {
|
||||||
|
console.log('-=. unfold and expand person', person.id)
|
||||||
|
commit('unfoldPerson', person)
|
||||||
|
dispatch('fetchInfoForPerson', person)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Triggered by a vis-network event when clicking on a Household Node.
|
||||||
|
* Each folded node is unfold, then expanded with fetch infos
|
||||||
|
* @param object
|
||||||
|
* @param household
|
||||||
|
*/
|
||||||
|
unfoldPersonsByHousehold({ getters, commit, dispatch }, household) {
|
||||||
|
const members = getters.getMembersByHousehold(household.id)
|
||||||
|
getters.getPersonsGroup(members)
|
||||||
|
.forEach(person => {
|
||||||
|
if (person.folded === true) {
|
||||||
|
console.log('-=. unfold and expand person', person.id)
|
||||||
|
commit('unfoldPerson', person)
|
||||||
|
dispatch('fetchInfoForPerson', person)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ==================================================================
|
||||||
|
* For an excluded node, add|remove relative persons excluded too
|
||||||
|
* @param object
|
||||||
|
* @param array (add|remove action, id)
|
||||||
|
*/
|
||||||
|
excludedNode({ getters, commit }, [action, id]) {
|
||||||
|
const personGroup = () => {
|
||||||
|
switch (splitId(id, 'type')) {
|
||||||
|
case 'accompanying_period':
|
||||||
|
return getters.getParticipationsByCourse(id)
|
||||||
|
case 'household':
|
||||||
|
return getters.getMembersByHousehold(id)
|
||||||
|
default:
|
||||||
|
throw 'undefined case with this id'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let group = getters.getPersonsGroup(personGroup())
|
||||||
|
if (action === 'add') {
|
||||||
|
commit('addExcludedNode', id)
|
||||||
|
group.forEach(person => {
|
||||||
|
// countLinks < 2 but parent has just already been added !
|
||||||
|
if (!getters.isInWhitelist(person.id) && getters.countLinksByNode(person.id) < 1) {
|
||||||
|
commit('addExcludedNode', person.id)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (action === 'remove') {
|
||||||
|
commit('removeExcludedNode', id)
|
||||||
|
group.forEach(person => {
|
||||||
|
commit('removeExcludedNode', person.id)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
commit('updateHack')
|
||||||
|
},
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
export { store }
|
@ -0,0 +1,262 @@
|
|||||||
|
import { visMessages } from './i18n'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vis-network initial data/configuration script
|
||||||
|
* Notes:
|
||||||
|
* Use window.network and window.options to avoid conflict between vue and vis
|
||||||
|
* cfr. https://github.com/almende/vis/issues/2524#issuecomment-307108271
|
||||||
|
*/
|
||||||
|
|
||||||
|
window.network = {}
|
||||||
|
|
||||||
|
window.options = {
|
||||||
|
locale: 'fr',
|
||||||
|
locales: visMessages,
|
||||||
|
/*
|
||||||
|
configure: {
|
||||||
|
enabled: true,
|
||||||
|
filter: 'nodes,edges',
|
||||||
|
//container: undefined,
|
||||||
|
showButton: true
|
||||||
|
},
|
||||||
|
*/
|
||||||
|
physics: {
|
||||||
|
enabled: true,
|
||||||
|
barnesHut: {
|
||||||
|
theta: 0.5,
|
||||||
|
gravitationalConstant: -2000,
|
||||||
|
centralGravity: 0.08, //// 0.3
|
||||||
|
springLength: 220, //// 95
|
||||||
|
springConstant: 0.04,
|
||||||
|
damping: 0.09,
|
||||||
|
avoidOverlap: 0
|
||||||
|
},
|
||||||
|
forceAtlas2Based: {
|
||||||
|
theta: 0.5,
|
||||||
|
gravitationalConstant: -50,
|
||||||
|
centralGravity: 0.01,
|
||||||
|
springLength: 100,
|
||||||
|
springConstant: 0.08,
|
||||||
|
damping: 0.4,
|
||||||
|
avoidOverlap: 0
|
||||||
|
},
|
||||||
|
repulsion: {
|
||||||
|
centralGravity: 0.2,
|
||||||
|
springLength: 200,
|
||||||
|
springConstant: 0.05,
|
||||||
|
nodeDistance: 100,
|
||||||
|
damping: 0.09
|
||||||
|
},
|
||||||
|
hierarchicalRepulsion: {
|
||||||
|
centralGravity: 0.0,
|
||||||
|
springLength: 100,
|
||||||
|
springConstant: 0.01,
|
||||||
|
nodeDistance: 120,
|
||||||
|
damping: 0.09,
|
||||||
|
avoidOverlap: 0
|
||||||
|
},
|
||||||
|
maxVelocity: 50,
|
||||||
|
minVelocity: 0.1,
|
||||||
|
solver: 'forceAtlas2Based', //'barnesHut', //
|
||||||
|
stabilization: {
|
||||||
|
enabled: true,
|
||||||
|
iterations: 1000,
|
||||||
|
updateInterval: 100,
|
||||||
|
onlyDynamicEdges: false,
|
||||||
|
fit: true
|
||||||
|
},
|
||||||
|
timestep: 0.5,
|
||||||
|
adaptiveTimestep: true,
|
||||||
|
wind: { x: 0, y: 0 }
|
||||||
|
},
|
||||||
|
interaction: {
|
||||||
|
hover: true,
|
||||||
|
multiselect: true,
|
||||||
|
navigationButtons: false,
|
||||||
|
},
|
||||||
|
manipulation: {
|
||||||
|
enabled: false,
|
||||||
|
initiallyActive: false,
|
||||||
|
addNode: false,
|
||||||
|
deleteNode: false
|
||||||
|
},
|
||||||
|
nodes: {
|
||||||
|
borderWidth: 1,
|
||||||
|
borderWidthSelected: 3,
|
||||||
|
font: {
|
||||||
|
multi: 'md'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
edges: {
|
||||||
|
font: {
|
||||||
|
color: '#b0b0b0',
|
||||||
|
size: 9,
|
||||||
|
face: 'arial',
|
||||||
|
background: 'none',
|
||||||
|
strokeWidth: 2, // px
|
||||||
|
strokeColor: '#ffffff',
|
||||||
|
align: 'middle',
|
||||||
|
multi: false,
|
||||||
|
vadjust: 0,
|
||||||
|
},
|
||||||
|
scaling:{
|
||||||
|
label: true,
|
||||||
|
},
|
||||||
|
smooth: true,
|
||||||
|
},
|
||||||
|
groups: {
|
||||||
|
person: {
|
||||||
|
shape: 'box',
|
||||||
|
shapeProperties: {
|
||||||
|
borderDashes: false,
|
||||||
|
borderRadius: 3,
|
||||||
|
},
|
||||||
|
color: {
|
||||||
|
border: '#b0b0b0',
|
||||||
|
background: 'rgb(193,229,222)',
|
||||||
|
highlight: {
|
||||||
|
border: '#89c9a9',
|
||||||
|
background: 'rgb(156,213,203)'
|
||||||
|
},
|
||||||
|
hover: {
|
||||||
|
border: '#89c9a9',
|
||||||
|
background: 'rgb(156,213,203)'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
opacity: 0.85,
|
||||||
|
shadow:{
|
||||||
|
enabled: true,
|
||||||
|
color: 'rgba(0,0,0,0.5)',
|
||||||
|
size:10,
|
||||||
|
x:5,
|
||||||
|
y:5
|
||||||
|
},
|
||||||
|
},
|
||||||
|
household: {
|
||||||
|
color: 'pink'
|
||||||
|
},
|
||||||
|
accompanying_period: {
|
||||||
|
color: 'orange',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param gender
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
const getGender = (gender) => {
|
||||||
|
switch (gender) {
|
||||||
|
case 'both':
|
||||||
|
return visMessages.fr.visgraph.both
|
||||||
|
case 'woman':
|
||||||
|
return visMessages.fr.visgraph.woman
|
||||||
|
case 'man':
|
||||||
|
return visMessages.fr.visgraph.man
|
||||||
|
default:
|
||||||
|
throw 'gender undefined'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO Repeat getAge() in PersonRenderBox.vue
|
||||||
|
* @param birthdate
|
||||||
|
* @returns {string|null}
|
||||||
|
*/
|
||||||
|
const getAge = (birthdate) => {
|
||||||
|
if (null === birthdate) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
const birthday = new Date(birthdate.datetime)
|
||||||
|
const now = new Date()
|
||||||
|
return (now.getFullYear() - birthday.getFullYear()) + ' '+ visMessages.fr.visgraph.years
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return member position in household
|
||||||
|
* @param member
|
||||||
|
* @returns string
|
||||||
|
*/
|
||||||
|
const getHouseholdLabel = (member) => {
|
||||||
|
let position = member.position.label.fr
|
||||||
|
let holder = member.holder ? ` ${visMessages.fr.visgraph.Holder}` : ''
|
||||||
|
return position + holder
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return edge width for member (depends of position in household)
|
||||||
|
* @param member
|
||||||
|
* @returns integer (width)
|
||||||
|
*/
|
||||||
|
const getHouseholdWidth = (member) => {
|
||||||
|
if (member.holder) {
|
||||||
|
return 5
|
||||||
|
}
|
||||||
|
if (member.shareHousehold) {
|
||||||
|
return 2
|
||||||
|
}
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return direction edge
|
||||||
|
* @param relationship
|
||||||
|
* @returns string
|
||||||
|
*/
|
||||||
|
const getRelationshipDirection = (relationship) => {
|
||||||
|
return (!relationship.reverse) ? 'to' : 'from'
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return label edge
|
||||||
|
* !! always set label in title direction (arrow is reversed, see in previous method) !!
|
||||||
|
* @param relationship
|
||||||
|
* @returns string
|
||||||
|
*/
|
||||||
|
const getRelationshipLabel = (relationship) => {
|
||||||
|
return relationship.relation.title.fr
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return title edge
|
||||||
|
* @param relationship
|
||||||
|
* @returns string
|
||||||
|
*/
|
||||||
|
const getRelationshipTitle = (relationship) => {
|
||||||
|
return (!relationship.reverse) ?
|
||||||
|
relationship.relation.title.fr + ': ' + relationship.fromPerson.text + '\n' + relationship.relation.reverseTitle.fr + ': ' + relationship.toPerson.text :
|
||||||
|
relationship.relation.title.fr + ': ' + relationship.toPerson.text + '\n' + relationship.relation.reverseTitle.fr + ': ' + relationship.fromPerson.text
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Split string id and return type|id substring
|
||||||
|
* @param id
|
||||||
|
* @param position
|
||||||
|
* @returns string|integer
|
||||||
|
*/
|
||||||
|
const splitId = (id, position) => {
|
||||||
|
//console.log(id, position)
|
||||||
|
switch (position) {
|
||||||
|
case 'type': // return 'accompanying_period'
|
||||||
|
return /(.+)_/.exec(id)[1]
|
||||||
|
case 'id': // return 124
|
||||||
|
return parseInt(id.toString()
|
||||||
|
.split("_")
|
||||||
|
.pop())
|
||||||
|
case 'link':
|
||||||
|
return id.split("-")[0] // return first segment
|
||||||
|
default:
|
||||||
|
throw 'position undefined'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
getGender,
|
||||||
|
getAge,
|
||||||
|
getHouseholdLabel,
|
||||||
|
getHouseholdWidth,
|
||||||
|
getRelationshipDirection,
|
||||||
|
getRelationshipLabel,
|
||||||
|
getRelationshipTitle,
|
||||||
|
splitId
|
||||||
|
}
|
@ -20,18 +20,25 @@
|
|||||||
v-bind:item="item">
|
v-bind:item="item">
|
||||||
</suggestion-third-party>
|
</suggestion-third-party>
|
||||||
|
|
||||||
|
<suggestion-user
|
||||||
|
v-if="item.result.type === 'user'"
|
||||||
|
v-bind:item="item">
|
||||||
|
</suggestion-user>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import SuggestionPerson from './TypePerson';
|
import SuggestionPerson from './TypePerson';
|
||||||
import SuggestionThirdParty from './TypeThirdParty';
|
import SuggestionThirdParty from './TypeThirdParty';
|
||||||
|
import SuggestionUser from './TypeUser';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'PersonSuggestion',
|
name: 'PersonSuggestion',
|
||||||
components: {
|
components: {
|
||||||
SuggestionPerson,
|
SuggestionPerson,
|
||||||
SuggestionThirdParty,
|
SuggestionThirdParty,
|
||||||
|
SuggestionUser,
|
||||||
},
|
},
|
||||||
props: [
|
props: [
|
||||||
'item',
|
'item',
|
||||||
|
@ -0,0 +1,47 @@
|
|||||||
|
<template>
|
||||||
|
<div class="container usercontainer">
|
||||||
|
<div class="user-identification">
|
||||||
|
<span class="name">
|
||||||
|
{{ item.result.text }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="right_actions">
|
||||||
|
<span class="badge rounded-pill bg-secondary">
|
||||||
|
{{ $t('user')}}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
const i18n = {
|
||||||
|
messages: {
|
||||||
|
fr: {
|
||||||
|
user: 'Utilisateur' // TODO how to define other translations?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'SuggestionUser',
|
||||||
|
props: ['item'],
|
||||||
|
i18n,
|
||||||
|
computed: {
|
||||||
|
hasParent() {
|
||||||
|
return this.$props.item.result.parent !== null;
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.usercontainer {
|
||||||
|
.userparent {
|
||||||
|
.name {
|
||||||
|
font-weight: bold;
|
||||||
|
font-variant: all-small-caps;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
@ -0,0 +1,34 @@
|
|||||||
|
{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %}
|
||||||
|
|
||||||
|
{% set activeRouteKey = 'chill_person_accompanying_period_work_list' %}
|
||||||
|
|
||||||
|
{% block title 'accompanying_course_work.remove'|trans %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<div class="accompanying_course_work-list">
|
||||||
|
<h2 class="badge-title">
|
||||||
|
<span class="title_label">{{ 'accompanying_course_work.action'|trans }}</span>
|
||||||
|
<span class="title_action">{{ work.socialAction|chill_entity_render_string }}</span>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<h3>{{ "Associated peoples"|trans }}</h3>
|
||||||
|
<ul>
|
||||||
|
{% for p in work.persons %}
|
||||||
|
{{ p|chill_entity_render_box }}
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
{{ include('@ChillMain/Util/confirmation_template.html.twig',
|
||||||
|
{
|
||||||
|
'title' : 'accompanying_course_work.remove'|trans,
|
||||||
|
'confirm_question' : 'Are you sure you want to remove this work of the accompanying period %name% ?'|trans({ '%name%' : accompanyingCourse.id } ),
|
||||||
|
'cancel_route' : 'chill_person_accompanying_period_work_list',
|
||||||
|
'cancel_parameters' : {'id' : accompanyingCourse.id},
|
||||||
|
'form' : delete_form
|
||||||
|
} ) }}
|
||||||
|
{% endblock %}
|
@ -103,6 +103,11 @@
|
|||||||
href="{{ chill_path_add_return_path('chill_person_accompanying_period_work_edit', { 'id': w.id }) }}"
|
href="{{ chill_path_add_return_path('chill_person_accompanying_period_work_edit', { 'id': w.id }) }}"
|
||||||
>{% if buttonText is not defined or buttonText == true %}{{ 'Edit'|trans }}{% endif %}</a>
|
>{% if buttonText is not defined or buttonText == true %}{{ 'Edit'|trans }}{% endif %}</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<a class="btn btn-delete" title="{{ 'Delete'|trans }}"
|
||||||
|
href="{{ path('chill_person_accompanying_period_work_delete', { 'id': w.id } ) }}"
|
||||||
|
>{% if buttonText is not defined or buttonText == true %}{{ 'Delete'|trans }}{% endif %}</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -2,26 +2,34 @@
|
|||||||
|
|
||||||
{% block title 'household.Relationship'|trans %}
|
{% block title 'household.Relationship'|trans %}
|
||||||
|
|
||||||
{% block content %}
|
{#
|
||||||
<h1>{{ block('title') }}</h1>
|
Give more space to graph:
|
||||||
<div id="graph-relationship"></div>
|
* use parent twig block (layout_wvm_content)
|
||||||
|
* hide title (d-none)
|
||||||
|
* apply negative margin-top
|
||||||
|
#}
|
||||||
|
{% block layout_wvm_content %}
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
|
||||||
{% for m in household.members %}
|
<div class="col-md-10 col-xxl d-none">
|
||||||
{% if m.endDate is null %}
|
<h1>{{ block('title') }}</h1>
|
||||||
{{ dump(m) }}
|
</div>
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
|
<div id="relationship-graph"
|
||||||
|
style="margin-top: -3rem"
|
||||||
|
data-persons="{{ persons|e('html_attr') }}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block block_post_menu %}
|
||||||
|
<div id="visgraph-legend"></div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block js %}
|
{% block js %}
|
||||||
{{ parent() }}
|
{{ encore_entry_script_tags('vue_visgraph') }}
|
||||||
{{ encore_entry_script_tags('page_vis') }}
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block css %}
|
{% block css %}
|
||||||
{{ parent() }}
|
{{ encore_entry_link_tags('vue_visgraph') }}
|
||||||
{{ encore_entry_link_tags('page_vis') }}
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block block_post_menu %}{% endblock %}
|
|
||||||
|
@ -86,7 +86,6 @@ class PersonNormalizer implements
|
|||||||
'mobilenumber' => $person->getMobilenumber(),
|
'mobilenumber' => $person->getMobilenumber(),
|
||||||
'altNames' => $this->normalizeAltNames($person->getAltNames()),
|
'altNames' => $this->normalizeAltNames($person->getAltNames()),
|
||||||
'gender' => $person->getGender(),
|
'gender' => $person->getGender(),
|
||||||
'gender_numeric' => $person->getGenderNumeric(),
|
|
||||||
'current_household_address' => $this->normalizer->normalize($person->getCurrentHouseholdAddress()),
|
'current_household_address' => $this->normalizer->normalize($person->getCurrentHouseholdAddress()),
|
||||||
'current_household_id' => $household ? $this->normalizer->normalize($household->getId()) : null,
|
'current_household_id' => $household ? $this->normalizer->normalize($household->getId()) : null,
|
||||||
];
|
];
|
||||||
|
@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Tests\Controller;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Chill\PersonBundle\Repository\PersonRepository;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||||
|
|
||||||
|
class RelationshipApiControllerTest extends WebTestCase
|
||||||
|
{
|
||||||
|
public static function setUpBeforeClass()
|
||||||
|
{
|
||||||
|
static::bootKernel();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
$this->client = static::createClient(array(), array(
|
||||||
|
'PHP_AUTH_USER' => 'fred',
|
||||||
|
'PHP_AUTH_PW' => 'password',
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider personProvider
|
||||||
|
*/
|
||||||
|
public function testGetRelationshipByPerson($personId)
|
||||||
|
{
|
||||||
|
$this->client->request(Request::METHOD_GET, sprintf('/api/1.0/relations/relationship/by-person/%d.json', $personId));
|
||||||
|
|
||||||
|
$response = $this->client->getResponse();
|
||||||
|
$this->assertEquals(200, $response->getStatusCode(), 'Test to see that API response returns a status code 200');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider relationProvider
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function testPostRelationship($fromPersonId, $toPersonId, $relationId, $isReverse): void
|
||||||
|
{
|
||||||
|
$this->client->request(Request::METHOD_POST,
|
||||||
|
'/api/1.0/person/relations/relationship.json',
|
||||||
|
[],
|
||||||
|
[],
|
||||||
|
[],
|
||||||
|
\json_encode([
|
||||||
|
'type' => 'relationship',
|
||||||
|
'fromPerson' => ['id' => $fromPersonId, 'type' => 'person'],
|
||||||
|
'toPerson' => ['id' => $toPersonId, 'type' => 'person'],
|
||||||
|
'relation' => ['id' => $relationId, 'type' => 'relation'],
|
||||||
|
'reverse' => $isReverse
|
||||||
|
]));
|
||||||
|
|
||||||
|
$response = $this->client->getResponse();
|
||||||
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function relationProvider(): array
|
||||||
|
{
|
||||||
|
//TODO: which different cases to test?
|
||||||
|
return [
|
||||||
|
[333, 334, 1, true],
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function personProvider(): array
|
||||||
|
{
|
||||||
|
//TODO: which different cases to test?
|
||||||
|
return [
|
||||||
|
[333],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -11,7 +11,7 @@ class LocationValidity extends Constraint
|
|||||||
{
|
{
|
||||||
public $messagePersonLocatedMustBeAssociated = "The person where the course is located must be associated to the course. Change course's location before removing the person.";
|
public $messagePersonLocatedMustBeAssociated = "The person where the course is located must be associated to the course. Change course's location before removing the person.";
|
||||||
|
|
||||||
public $messagePeriodMustRemainsLocated = "The period must remains located";
|
public $messagePeriodMustRemainsLocated = "The period must remain located";
|
||||||
|
|
||||||
public function getTargets()
|
public function getTargets()
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Constraint;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Annotation
|
||||||
|
*/
|
||||||
|
class ParticipationOverlap extends Constraint
|
||||||
|
{
|
||||||
|
public $message = 'This participation already exists.';
|
||||||
|
}
|
@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Util\DateRangeCovering;
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
|
||||||
|
use Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\ParticipationOverlap;
|
||||||
|
use Doctrine\Common\Collections\Collection;
|
||||||
|
use Symfony\Component\Validator\Constraint;
|
||||||
|
use Symfony\Component\Validator\ConstraintValidator;
|
||||||
|
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||||
|
|
||||||
|
class ParticipationOverlapValidator extends ConstraintValidator
|
||||||
|
{
|
||||||
|
private const MAX_PARTICIPATION = 1;
|
||||||
|
|
||||||
|
public function validate($participations, Constraint $constraint)
|
||||||
|
{
|
||||||
|
if (!$constraint instanceof ParticipationOverlap) {
|
||||||
|
throw new UnexpectedTypeException($constraint, ParticipationOverlap::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$participations instanceof Collection) {
|
||||||
|
throw new UnexpectedTypeException($participations, 'This should be a collection');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($participations) <= self::MAX_PARTICIPATION) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$overlaps = new DateRangeCovering(self::MAX_PARTICIPATION, $participations[0]->getStartDate()->getTimezone());
|
||||||
|
$participationList = [];
|
||||||
|
|
||||||
|
foreach ($participations as $participation) {
|
||||||
|
|
||||||
|
if (!$participation instanceof AccompanyingPeriodParticipation) {
|
||||||
|
throw new UnexpectedTypeException($participation, AccompanyingPeriodParticipation::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
$personId = $participation->getPerson()->getId();
|
||||||
|
|
||||||
|
$participationList[$personId][] = $participation;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($participationList as $group) {
|
||||||
|
if (count($group) > 1) {
|
||||||
|
foreach ($group as $p) {
|
||||||
|
$overlaps->add($p->getStartDate(), $p->getEndDate(), $p->getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$overlaps->compute();
|
||||||
|
|
||||||
|
if ($overlaps->hasIntersections()) {
|
||||||
|
foreach ($overlaps->getIntersections() as list($start, $end, $ids)) {
|
||||||
|
$msg = $end === null ? $constraint->message :
|
||||||
|
$constraint->message;
|
||||||
|
|
||||||
|
$this->context->buildViolation($msg)
|
||||||
|
->setParameters([
|
||||||
|
'{{ start }}' => $start->format('d-m-Y'),
|
||||||
|
'{{ end }}' => $end === null ? null : $end->format('d-m-Y'),
|
||||||
|
'{{ ids }}' => $ids,
|
||||||
|
])
|
||||||
|
->addViolation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Constraint;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Annotation
|
||||||
|
*/
|
||||||
|
class ResourceDuplicateCheck extends Constraint
|
||||||
|
{
|
||||||
|
public $message = '{{ name }} is already associated to this accompanying course.';
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod;
|
||||||
|
|
||||||
|
use Chill\PersonBundle\Entity\Person;
|
||||||
|
use Chill\PersonBundle\Templating\Entity\PersonRender;
|
||||||
|
use Doctrine\Common\Collections\Collection;
|
||||||
|
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||||
|
use Symfony\Component\Validator\Constraint;
|
||||||
|
use Symfony\Component\Validator\ConstraintValidator;
|
||||||
|
use Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\ResourceDuplicateCheck;
|
||||||
|
use Chill\ThirdPartyBundle\Templating\Entity\ThirdPartyRender;
|
||||||
|
|
||||||
|
class ResourceDuplicateCheckValidator extends ConstraintValidator
|
||||||
|
{
|
||||||
|
|
||||||
|
private PersonRender $personRender;
|
||||||
|
private ThirdPartyRender $thirdpartyRender;
|
||||||
|
|
||||||
|
public function __construct(PersonRender $personRender, ThirdPartyRender $thirdPartyRender)
|
||||||
|
{
|
||||||
|
$this->personRender = $personRender;
|
||||||
|
$this->thirdpartyRender = $thirdPartyRender;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function validate($resources, Constraint $constraint)
|
||||||
|
{
|
||||||
|
if (!$constraint instanceof ResourceDuplicateCheck) {
|
||||||
|
throw new UnexpectedTypeException($constraint, ParticipationOverlap::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$resources instanceof Collection) {
|
||||||
|
throw new UnexpectedTypeException($resources, Collection::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
$resourceList = [];
|
||||||
|
|
||||||
|
foreach ($resources as $resource) {
|
||||||
|
$id = ($resource->getResource() instanceof Person ? 'p' :
|
||||||
|
't').$resource->getResource()->getId();
|
||||||
|
|
||||||
|
if (\in_array($id, $resourceList, true)) {
|
||||||
|
$this->context->buildViolation($constraint->message)
|
||||||
|
->setParameter('{{ name }}', $resource->getResource() instanceof Person ? $this->personRender->renderString($resource->getResource(), []) :
|
||||||
|
$this->thirdpartyRender->renderString($resource->getResource(), []))
|
||||||
|
->addViolation();
|
||||||
|
}
|
||||||
|
|
||||||
|
$resourceList[] = $id;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -274,6 +274,41 @@ components:
|
|||||||
enum:
|
enum:
|
||||||
- "social_work_goal"
|
- "social_work_goal"
|
||||||
|
|
||||||
|
RelationById:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
type:
|
||||||
|
type: string
|
||||||
|
enum:
|
||||||
|
- "relation"
|
||||||
|
required:
|
||||||
|
- id
|
||||||
|
- type
|
||||||
|
Relationship:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
type:
|
||||||
|
type: string
|
||||||
|
enum:
|
||||||
|
- "relationship"
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
readOnly: true
|
||||||
|
fromPerson:
|
||||||
|
anyOf:
|
||||||
|
- $ref: "#/components/schemas/PersonById"
|
||||||
|
toPerson:
|
||||||
|
anyOf:
|
||||||
|
- $ref: "#/components/schemas/PersonById"
|
||||||
|
relation:
|
||||||
|
anyOf:
|
||||||
|
- $ref: "#/components/schemas/RelationById"
|
||||||
|
reverse:
|
||||||
|
type: boolean
|
||||||
|
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
/1.0/person/person/{id}.json:
|
/1.0/person/person/{id}.json:
|
||||||
get:
|
get:
|
||||||
@ -1079,6 +1114,29 @@ paths:
|
|||||||
400:
|
400:
|
||||||
description: "transition cannot be applyed"
|
description: "transition cannot be applyed"
|
||||||
|
|
||||||
|
/1.0/person/accompanying-course/by-person/{person_id}.json:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- accompanying period
|
||||||
|
summary: get a list of accompanying periods for a person
|
||||||
|
description: Returns a list of the current accompanying periods for a person
|
||||||
|
parameters:
|
||||||
|
- name: person_id
|
||||||
|
in: path
|
||||||
|
required: true
|
||||||
|
description: The person id
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
format: integer
|
||||||
|
minimum: 1
|
||||||
|
responses:
|
||||||
|
401:
|
||||||
|
description: "Unauthorized"
|
||||||
|
404:
|
||||||
|
description: "Not found"
|
||||||
|
200:
|
||||||
|
description: "OK"
|
||||||
|
|
||||||
/1.0/person/accompanying-period/origin.json:
|
/1.0/person/accompanying-period/origin.json:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
@ -1586,3 +1644,115 @@ paths:
|
|||||||
description: "OK"
|
description: "OK"
|
||||||
400:
|
400:
|
||||||
description: "Bad Request"
|
description: "Bad Request"
|
||||||
|
|
||||||
|
/1.0/relations/relationship/by-person/{id}.json:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- relationships
|
||||||
|
parameters:
|
||||||
|
- name: id
|
||||||
|
in: path
|
||||||
|
required: true
|
||||||
|
description: The person's id
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
format: integer
|
||||||
|
minimum: 1
|
||||||
|
responses:
|
||||||
|
401:
|
||||||
|
description: "Unauthorized"
|
||||||
|
404:
|
||||||
|
description: "Not found"
|
||||||
|
200:
|
||||||
|
description: "OK"
|
||||||
|
400:
|
||||||
|
description: "Bad Request"
|
||||||
|
|
||||||
|
/1.0/relations/relationship.json:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- relationships
|
||||||
|
summary: Create a new relationship
|
||||||
|
requestBody:
|
||||||
|
description: "A relationship"
|
||||||
|
required: true
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/Relationship"
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: "OK"
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/Relationship"
|
||||||
|
403:
|
||||||
|
description: "Unauthorized"
|
||||||
|
422:
|
||||||
|
description: "Invalid data: the data is a valid json, could be deserialized, but does not pass validation"
|
||||||
|
|
||||||
|
/1.0/relations/relationship/{id}.json:
|
||||||
|
patch:
|
||||||
|
tags:
|
||||||
|
- relationships
|
||||||
|
summary: "Alter a relationship"
|
||||||
|
parameters:
|
||||||
|
- name: id
|
||||||
|
in: path
|
||||||
|
required: true
|
||||||
|
description: The relationship's id
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
format: integer
|
||||||
|
minimum: 1
|
||||||
|
requestBody:
|
||||||
|
description: "A relationship"
|
||||||
|
required: true
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/Relationship"
|
||||||
|
responses:
|
||||||
|
401:
|
||||||
|
description: "Unauthorized"
|
||||||
|
404:
|
||||||
|
description: "Not found"
|
||||||
|
200:
|
||||||
|
description: "OK"
|
||||||
|
422:
|
||||||
|
description: "Object with validation errors"
|
||||||
|
delete:
|
||||||
|
tags:
|
||||||
|
- relationships
|
||||||
|
summary: "Remove the relationship"
|
||||||
|
parameters:
|
||||||
|
- name: id
|
||||||
|
in: path
|
||||||
|
required: true
|
||||||
|
description: The relationship's id
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
format: integer
|
||||||
|
minimum: 1
|
||||||
|
responses:
|
||||||
|
401:
|
||||||
|
description: "Unauthorized"
|
||||||
|
404:
|
||||||
|
description: "Not found"
|
||||||
|
200:
|
||||||
|
description: "OK"
|
||||||
|
422:
|
||||||
|
description: "object with validation errors"
|
||||||
|
|
||||||
|
|
||||||
|
/1.0/relations/relation.json:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- relations
|
||||||
|
summary: get a list of relations
|
||||||
|
responses:
|
||||||
|
401:
|
||||||
|
description: "Unauthorized"
|
||||||
|
200:
|
||||||
|
description: "OK"
|
||||||
|
@ -12,9 +12,9 @@ module.exports = function(encore, entries)
|
|||||||
encore.addEntry('vue_accourse', __dirname + '/Resources/public/vuejs/AccompanyingCourse/index.js');
|
encore.addEntry('vue_accourse', __dirname + '/Resources/public/vuejs/AccompanyingCourse/index.js');
|
||||||
encore.addEntry('vue_accourse_work_create', __dirname + '/Resources/public/vuejs/AccompanyingCourseWorkCreate/index.js');
|
encore.addEntry('vue_accourse_work_create', __dirname + '/Resources/public/vuejs/AccompanyingCourseWorkCreate/index.js');
|
||||||
encore.addEntry('vue_accourse_work_edit', __dirname + '/Resources/public/vuejs/AccompanyingCourseWorkEdit/index.js');
|
encore.addEntry('vue_accourse_work_edit', __dirname + '/Resources/public/vuejs/AccompanyingCourseWorkEdit/index.js');
|
||||||
|
encore.addEntry('vue_visgraph', __dirname + '/Resources/public/vuejs/VisGraph/index.js');
|
||||||
|
|
||||||
encore.addEntry('page_household_edit_metadata', __dirname + '/Resources/public/page/household_edit_metadata/index.js');
|
encore.addEntry('page_household_edit_metadata', __dirname + '/Resources/public/page/household_edit_metadata/index.js');
|
||||||
encore.addEntry('page_person', __dirname + '/Resources/public/page/person/index.js');
|
encore.addEntry('page_person', __dirname + '/Resources/public/page/person/index.js');
|
||||||
encore.addEntry('page_accompanying_course_index_person_locate', __dirname + '/Resources/public/page/accompanying_course_index/person_locate.js');
|
encore.addEntry('page_accompanying_course_index_person_locate', __dirname + '/Resources/public/page/accompanying_course_index/person_locate.js');
|
||||||
//encore.addEntry('page_vis', __dirname + '/Resources/public/page/vis/index.js');
|
|
||||||
};
|
};
|
||||||
|
@ -65,3 +65,7 @@ services:
|
|||||||
Chill\PersonBundle\Controller\HouseholdApiController:
|
Chill\PersonBundle\Controller\HouseholdApiController:
|
||||||
autowire: true
|
autowire: true
|
||||||
tags: ['controller.service_arguments']
|
tags: ['controller.service_arguments']
|
||||||
|
|
||||||
|
Chill\PersonBundle\Controller\RelationshipApiController:
|
||||||
|
autowire: true
|
||||||
|
tags: ['controller.service_arguments']
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
services:
|
||||||
|
Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod:
|
||||||
|
autowire: true
|
||||||
|
autoconfigure: true
|
||||||
|
tags: ['validator.service_arguments']
|
||||||
|
|
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\Migrations\Person;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validation added to accompanying period resources and accompanying period.
|
||||||
|
*/
|
||||||
|
final class Version20211020131133 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return 'Validation added to accompanying period resources and accompanying period.';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('CREATE UNIQUE INDEX person_unique ON chill_person_accompanying_period_resource (person_id, accompanyingperiod_id) WHERE person_id IS NOT NULL');
|
||||||
|
$this->addSql('CREATE UNIQUE INDEX thirdparty_unique ON chill_person_accompanying_period_resource (thirdparty_id, accompanyingperiod_id) WHERE thirdparty_id IS NOT NULL');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('DROP INDEX person_unique');
|
||||||
|
$this->addSql('DROP INDEX thirdparty_unique');
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\Migrations\Person;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom constraint added to database to prevent identical participations.
|
||||||
|
*/
|
||||||
|
final class Version20211021125359 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return 'Custom constraint added to database to prevent identical participations.';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
// creates a constraint 'participations may not overlap'
|
||||||
|
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation ADD CONSTRAINT '.
|
||||||
|
"participations_no_overlap EXCLUDE USING GIST(
|
||||||
|
-- extension btree_gist required to include comparaison with integer
|
||||||
|
person_id WITH =, accompanyingperiod_id WITH =,
|
||||||
|
daterange(startdate, enddate) WITH &&
|
||||||
|
)
|
||||||
|
INITIALLY DEFERRED");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('CREATE UNIQUE INDEX participation_unique ON chill_person_accompanying_period_participation (accompanyingperiod_id, person_id)');
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\Migrations\Person;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the relationship and relation entity
|
||||||
|
*/
|
||||||
|
final class Version20211025141226 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return 'Create the relationship and relation entity';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('CREATE SEQUENCE chill_person_relations_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||||
|
$this->addSql('CREATE SEQUENCE chill_person_relationships_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||||
|
$this->addSql('CREATE TABLE chill_person_relations (id INT NOT NULL, title JSON DEFAULT NULL, reverseTitle JSON DEFAULT NULL, PRIMARY KEY(id))');
|
||||||
|
$this->addSql('CREATE TABLE chill_person_relationships (id INT NOT NULL, relation_id INT NOT NULL, reverse BOOLEAN NOT NULL, createdAt TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updatedAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, fromPerson_id INT NOT NULL, toPerson_id INT NOT NULL, createdBy_id INT NOT NULL, updatedBy_id INT DEFAULT NULL, PRIMARY KEY(id))');
|
||||||
|
$this->addSql('CREATE INDEX IDX_23D47C51CBA59C1E ON chill_person_relationships (fromPerson_id)');
|
||||||
|
$this->addSql('CREATE INDEX IDX_23D47C514013E22A ON chill_person_relationships (toPerson_id)');
|
||||||
|
$this->addSql('CREATE INDEX IDX_23D47C513256915B ON chill_person_relationships (relation_id)');
|
||||||
|
$this->addSql('CREATE INDEX IDX_23D47C513174800F ON chill_person_relationships (createdBy_id)');
|
||||||
|
$this->addSql('CREATE INDEX IDX_23D47C5165FF1AEC ON chill_person_relationships (updatedBy_id)');
|
||||||
|
$this->addSql('COMMENT ON COLUMN chill_person_relationships.createdAt IS \'(DC2Type:datetime_immutable)\'');
|
||||||
|
$this->addSql('COMMENT ON COLUMN chill_person_relationships.updatedAt IS \'(DC2Type:datetime_immutable)\'');
|
||||||
|
$this->addSql('ALTER TABLE chill_person_relationships ADD CONSTRAINT FK_23D47C51CBA59C1E FOREIGN KEY (fromPerson_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||||
|
$this->addSql('ALTER TABLE chill_person_relationships ADD CONSTRAINT FK_23D47C514013E22A FOREIGN KEY (toPerson_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||||
|
$this->addSql('ALTER TABLE chill_person_relationships ADD CONSTRAINT FK_23D47C513256915B FOREIGN KEY (relation_id) REFERENCES chill_person_relations (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||||
|
$this->addSql('ALTER TABLE chill_person_relationships ADD CONSTRAINT FK_23D47C513174800F FOREIGN KEY (createdBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||||
|
$this->addSql('ALTER TABLE chill_person_relationships ADD CONSTRAINT FK_23D47C5165FF1AEC FOREIGN KEY (updatedBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->addSql('ALTER TABLE chill_person_relationships DROP CONSTRAINT FK_23D47C513256915B');
|
||||||
|
$this->addSql('DROP SEQUENCE chill_person_relations_id_seq CASCADE');
|
||||||
|
$this->addSql('DROP SEQUENCE chill_person_relationships_id_seq CASCADE');
|
||||||
|
$this->addSql('DROP TABLE chill_person_relations');
|
||||||
|
$this->addSql('DROP TABLE chill_person_relationships');
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\Migrations\Person;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* isActive property added to Relation entity.
|
||||||
|
*/
|
||||||
|
final class Version20211029075117 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return 'isActive property added to Relation entity.';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('ALTER TABLE chill_person_relations ADD isActive BOOLEAN DEFAULT true NOT NULL');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('ALTER TABLE chill_person_relations DROP isActive');
|
||||||
|
}
|
||||||
|
}
|
@ -57,8 +57,8 @@ household:
|
|||||||
Household summary: Résumé du ménage
|
Household summary: Résumé du ménage
|
||||||
Accompanying period: Parcours d'accompagnement
|
Accompanying period: Parcours d'accompagnement
|
||||||
Addresses: Historique adresse
|
Addresses: Historique adresse
|
||||||
Relationship: Composition familiale
|
Relationship: Filiation
|
||||||
Household relationships: Composition du ménage
|
Household relationships: Filiations dans le ménage
|
||||||
Current address: Adresse actuelle
|
Current address: Adresse actuelle
|
||||||
Household does not have any address currently: Le ménage n'a pas d'adresse renseignée actuellement
|
Household does not have any address currently: Le ménage n'a pas d'adresse renseignée actuellement
|
||||||
Edit household members: Modifier l'appartenance au ménage
|
Edit household members: Modifier l'appartenance au ménage
|
||||||
|
@ -405,6 +405,8 @@ Back to household: Revenir au ménage
|
|||||||
# accompanying course work
|
# accompanying course work
|
||||||
Accompanying Course Actions: Actions d'accompagnements
|
Accompanying Course Actions: Actions d'accompagnements
|
||||||
Accompanying Course Action: Action d'accompagnement
|
Accompanying Course Action: Action d'accompagnement
|
||||||
|
Are you sure you want to remove this work of the accompanying period %name% ?: Êtes-vous sûr de vouloir supprimer cette action de la période d'accompagnement %name% ?
|
||||||
|
The accompanying period work has been successfully removed.: L'action d'accompagnement a été supprimée.
|
||||||
accompanying_course_work:
|
accompanying_course_work:
|
||||||
create: Créer une action
|
create: Créer une action
|
||||||
Create accompanying course work: Créer une action d'accompagnement
|
Create accompanying course work: Créer une action d'accompagnement
|
||||||
@ -419,6 +421,7 @@ accompanying_course_work:
|
|||||||
results: Résultats - orientations
|
results: Résultats - orientations
|
||||||
goal: Objectif - motif - dispositif
|
goal: Objectif - motif - dispositif
|
||||||
Any work: Aucune action d'accompagnement
|
Any work: Aucune action d'accompagnement
|
||||||
|
remove: Supprimer une action d'accompagnement
|
||||||
|
|
||||||
#
|
#
|
||||||
Person addresses: Adresses de résidence
|
Person addresses: Adresses de résidence
|
||||||
|
@ -41,3 +41,6 @@ household:
|
|||||||
household_membership:
|
household_membership:
|
||||||
The end date must be after start date: La date de la fin de l'appartenance doit être postérieure à la date de début.
|
The end date must be after start date: La date de la fin de l'appartenance doit être postérieure à la date de début.
|
||||||
Person with membership covering: Une personne ne peut pas appartenir à deux ménages simultanément. Or, avec cette modification, %person_name% appartiendrait à %nbHousehold% ménages à partir du %from%.
|
Person with membership covering: Une personne ne peut pas appartenir à deux ménages simultanément. Or, avec cette modification, %person_name% appartiendrait à %nbHousehold% ménages à partir du %from%.
|
||||||
|
|
||||||
|
# Accompanying period
|
||||||
|
'{{ name }} is already associated to this accompanying course.': '{{ name }} est déjà associé avec ce parcours.'
|
Loading…
x
Reference in New Issue
Block a user