Merge remote-tracking branch 'origin/master' into issue412_413_activity

This commit is contained in:
Julien Fastré 2022-01-31 14:22:34 +01:00
commit 08c13b8c98
97 changed files with 1982 additions and 369 deletions

View File

@ -13,12 +13,34 @@ and this project adheres to
<!-- write down unreleased development here --> <!-- write down unreleased development here -->
* [activity] show activity attendee (présence) in the activity list (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/412) * [activity] show activity attendee (présence) in the activity list (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/412)
* [activity] admin: change validation rule for social action visible field (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/413) * [activity] admin: change validation rule for social action visible field (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/413)
* [parcours]: component added to change the opening date of a parcours (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/411)
* [search]: listing of parcours display changed (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/410)
* [user]: page with accompanying periods to which is user is referent (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/408)
* [person] age added to renderstring + renderbox/ vue component created to display person text (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/389)
* [household member editor] allow to push to existing household
## Test releases
### test release 2021-01-28
* [person] improve filiations vis graph: disable physics, use chill colors for persons-households-course, increase label of relations, remove labels on household arrows and other improvements (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/286, https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/362)
* [activity] Order activity by date and by id (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/364)
* [main] increase length of 4 Address fields (change to TEXT, no size limits) (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/277)
* [main] Add confidential option for address, in edit and view (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/165)
* [person] name suggestions within create person form when person is created departing from a search input (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/377)
* [person] Add residential address entity, form and list for each person
* [aside_activity]: dynamicUserPickerType used (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/399)
* dispatching list
### test release 2021-01-26
>>>>>>> origin/master
* [parcours] comments truncated if too long + link added (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/406) * [parcours] comments truncated if too long + link added (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/406)
* [person]: possibility to add person resources (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/382) * [person]: possibility to add person resources (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/382)
* [person ressources]: module added * [person ressources]: module added
* [person]: possibility to add person resources (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/382)
## Test releases
### test release 2022-01-24 ### test release 2022-01-24

View File

@ -256,7 +256,7 @@ final class ActivityController extends AbstractController
if ($person instanceof Person) { if ($person instanceof Person) {
$this->denyAccessUnlessGranted(ActivityVoter::SEE, $person); $this->denyAccessUnlessGranted(ActivityVoter::SEE, $person);
$activities = $this->activityACLAwareRepository $activities = $this->activityACLAwareRepository
->findByPerson($person, ActivityVoter::SEE, 0, null); ->findByPerson($person, ActivityVoter::SEE, 0, null, ['date' => 'DESC', 'id' => 'DESC']);
$event = new PrivacyEvent($person, [ $event = new PrivacyEvent($person, [
'element_class' => Activity::class, 'element_class' => Activity::class,
@ -269,7 +269,7 @@ final class ActivityController extends AbstractController
$this->denyAccessUnlessGranted(ActivityVoter::SEE, $accompanyingPeriod); $this->denyAccessUnlessGranted(ActivityVoter::SEE, $accompanyingPeriod);
$activities = $this->activityACLAwareRepository $activities = $this->activityACLAwareRepository
->findByAccompanyingPeriod($accompanyingPeriod, ActivityVoter::SEE); ->findByAccompanyingPeriod($accompanyingPeriod, ActivityVoter::SEE, 0, null, ['date' => 'DESC', 'id' => 'DESC']);
$view = 'ChillActivityBundle:Activity:listAccompanyingCourse.html.twig'; $view = 'ChillActivityBundle:Activity:listAccompanyingCourse.html.twig';
} }

View File

@ -13,7 +13,8 @@
<div v-if="getContext === 'accompanyingCourse' && suggestedEntities.length > 0"> <div v-if="getContext === 'accompanyingCourse' && suggestedEntities.length > 0">
<ul class="list-suggest add-items inline"> <ul class="list-suggest add-items inline">
<li v-for="(p, i) in suggestedEntities" @click="addSuggestedEntity(p)" :key="`suggestedEntities-${i}`"> <li v-for="(p, i) in suggestedEntities" @click="addSuggestedEntity(p)" :key="`suggestedEntities-${i}`">
<span>{{ p.text }}</span> <person-text v-if="p.type === 'person'" :person="p"></person-text>
<span v-else>{{ p.text }}</span>
</li> </li>
</ul> </ul>
</div> </div>
@ -34,12 +35,14 @@
import { mapState, mapGetters } from 'vuex'; import { mapState, mapGetters } from 'vuex';
import AddPersons from 'ChillPersonAssets/vuejs/_components/AddPersons.vue'; import AddPersons from 'ChillPersonAssets/vuejs/_components/AddPersons.vue';
import PersonsBloc from './ConcernedGroups/PersonsBloc.vue'; import PersonsBloc from './ConcernedGroups/PersonsBloc.vue';
import PersonText from 'ChillPersonAssets/vuejs/_components/Entity/PersonText.vue';
export default { export default {
name: "ConcernedGroups", name: "ConcernedGroups",
components: { components: {
AddPersons, AddPersons,
PersonsBloc PersonsBloc,
PersonText
}, },
data() { data() {
return { return {

View File

@ -1,21 +1,29 @@
<template> <template>
<li> <li>
<span :title="person.text"> <span :title="person.text">
<span class="chill_denomination" @click.prevent="$emit('remove', person)">{{ textCutted }}</span> <span class="chill_denomination" @click.prevent="$emit('remove', person)">
<person-text :person="person" :isCut="true"></person-text>
</span>
</span> </span>
</li> </li>
</template> </template>
<script> <script>
import PersonText from 'ChillPersonAssets/vuejs/_components/Entity/PersonText.vue';
export default { export default {
name: "PersonBadge", name: "PersonBadge",
props: ['person'], props: ['person'],
computed: { components: {
textCutted() { PersonText
let more = (this.person.text.length > 15) ?'…' : '';
return this.person.text.slice(0,15) + more;
}
}, },
// computed: {
// textCutted() {
// let more = (this.person.text.length > 15) ?'' : '';
// return this.person.text.slice(0,15) + more;
// }
// },
emits: ['remove'], emits: ['remove'],
} }
</script> </script>

View File

@ -48,7 +48,7 @@
<li class="associated-persons"> <li class="associated-persons">
<span class="item-key">{{ 'Participants'|trans ~ ' : ' }}</span> <span class="item-key">{{ 'Participants'|trans ~ ' : ' }}</span>
{% for p in activity.personsAssociated %} {% for p in activity.personsAssociated %}
<span class="badge-person">{{ p|chill_entity_render_box }}</span> <span class="badge-person">{{ p|chill_entity_render_box({'addAgeBadge': true}) }}</span>
{% endfor %} {% endfor %}
</li> </li>
</ul> </ul>

View File

@ -29,9 +29,13 @@ use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
final class ActivityVoterTest extends KernelTestCase final class ActivityVoterTest extends KernelTestCase
{ {
use PrepareActivityTrait; use PrepareActivityTrait;
use PrepareCenterTrait; use PrepareCenterTrait;
use PreparePersonTrait; use PreparePersonTrait;
use PrepareScopeTrait; use PrepareScopeTrait;
use PrepareUserTrait; use PrepareUserTrait;
/** /**

View File

@ -32,6 +32,8 @@ final class AsideActivityController extends CRUDController
{ {
$asideActivity = new AsideActivity(); $asideActivity = new AsideActivity();
$asideActivity->setAgent($this->getUser());
$duration = $request->query->get('duration', '300'); $duration = $request->query->get('duration', '300');
$duration = DateTime::createFromFormat('U', $duration); $duration = DateTime::createFromFormat('U', $duration);
$asideActivity->setDuration($duration); $asideActivity->setDuration($duration);

View File

@ -14,9 +14,9 @@ namespace Chill\AsideActivityBundle\Form;
use Chill\AsideActivityBundle\Entity\AsideActivity; use Chill\AsideActivityBundle\Entity\AsideActivity;
use Chill\AsideActivityBundle\Entity\AsideActivityCategory; use Chill\AsideActivityBundle\Entity\AsideActivityCategory;
use Chill\AsideActivityBundle\Templating\Entity\CategoryRender; use Chill\AsideActivityBundle\Templating\Entity\CategoryRender;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Form\Type\ChillDateType; use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\MainBundle\Form\Type\ChillTextareaType; use Chill\MainBundle\Form\Type\ChillTextareaType;
use Chill\MainBundle\Form\Type\PickUserDynamicType;
use DateInterval; use DateInterval;
use DateTime; use DateTime;
use DateTimeImmutable; use DateTimeImmutable;
@ -68,22 +68,10 @@ final class AsideActivityFormType extends AbstractType
]; ];
$builder $builder
->add( ->add('agent', PickUserDynamicType::class, [
'agent',
EntityType::class,
[
'label' => 'For agent', 'label' => 'For agent',
'required' => true, 'required' => true,
'class' => User::class, ])
'data' => $this->storage->getToken()->getUser(),
'query_builder' => static function (EntityRepository $er) {
return $er->createQueryBuilder('u')->where('u.enabled = true');
},
'attr' => ['class' => 'select2 '],
'placeholder' => 'Choose the agent for whom this activity is created',
'choice_label' => 'username',
]
)
->add( ->add(
'date', 'date',
ChillDateType::class, ChillDateType::class,

View File

@ -1,5 +1,15 @@
{% extends '@ChillMain/Admin/layout.html.twig' %} {% extends '@ChillMain/Admin/layout.html.twig' %}
{% block js %}
{{ parent() }}
{{ encore_entry_script_tags('mod_pickentity_type') }}
{% endblock %}
{% block css %}
{{ parent() }}
{{ encore_entry_link_tags('mod_pickentity_type') }}
{% endblock %}
{% block title %} {% block title %}
{% include('@ChillMain/CRUD/_new_title.html.twig') %} {% include('@ChillMain/CRUD/_new_title.html.twig') %}
{% endblock %} {% endblock %}
@ -9,3 +19,4 @@
{% block content_form_actions_save_and_show %}{% endblock %} {% block content_form_actions_save_and_show %}{% endblock %}
{% endembed %} {% endembed %}
{% endblock %} {% endblock %}

View File

@ -42,10 +42,16 @@ class Address
*/ */
private $buildingName; private $buildingName;
/**
* @ORM\Column(type="boolean")
* @Groups({"write"})
*/
private bool $confidential = false;
/** /**
* @var string|null * @var string|null
* *
* @ORM\Column(type="string", length=16, nullable=true) * @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"write"}) * @Groups({"write"})
*/ */
private $corridor; private $corridor;
@ -78,7 +84,7 @@ class Address
/** /**
* @var string|null * @var string|null
* *
* @ORM\Column(type="string", length=16, nullable=true) * @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"write"}) * @Groups({"write"})
*/ */
private $flat; private $flat;
@ -86,7 +92,7 @@ class Address
/** /**
* @var string|null * @var string|null
* *
* @ORM\Column(type="string", length=16, nullable=true) * @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"write"}) * @Groups({"write"})
*/ */
private $floor; private $floor;
@ -143,7 +149,7 @@ class Address
/** /**
* @var string|null * @var string|null
* *
* @ORM\Column(type="string", length=16, nullable=true) * @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"write"}) * @Groups({"write"})
*/ */
private $steps; private $steps;
@ -192,6 +198,7 @@ class Address
return (new Address()) return (new Address())
->setAddressReference($original->getAddressReference()) ->setAddressReference($original->getAddressReference())
->setBuildingName($original->getBuildingName()) ->setBuildingName($original->getBuildingName())
->setConfidential($original->getConfidential())
->setCorridor($original->getCorridor()) ->setCorridor($original->getCorridor())
->setCustoms($original->getCustoms()) ->setCustoms($original->getCustoms())
->setDistribution($original->getDistribution()) ->setDistribution($original->getDistribution())
@ -229,6 +236,11 @@ class Address
return $this->buildingName; return $this->buildingName;
} }
public function getConfidential(): bool
{
return $this->confidential;
}
public function getCorridor(): ?string public function getCorridor(): ?string
{ {
return $this->corridor; return $this->corridor;
@ -369,6 +381,13 @@ class Address
return $this; return $this;
} }
public function setConfidential(bool $confidential): self
{
$this->confidential = $confidential;
return $this;
}
public function setCorridor(?string $corridor): self public function setCorridor(?string $corridor): self
{ {
$this->corridor = $corridor; $this->corridor = $corridor;

View File

@ -20,10 +20,9 @@ use Doctrine\ORM\Mapping as ORM;
class CommentEmbeddable class CommentEmbeddable
{ {
/** /**
* @var string
* @ORM\Column(type="text", nullable=true) * @ORM\Column(type="text", nullable=true)
*/ */
private $comment; private ?string $comment = null;
/** /**
* @var DateTime * @var DateTime
@ -39,10 +38,7 @@ class CommentEmbeddable
*/ */
private $userId; private $userId;
/** public function getComment(): ?string
* @return string
*/
public function getComment()
{ {
return $this->comment; return $this->comment;
} }
@ -68,9 +64,6 @@ class CommentEmbeddable
return empty($this->getComment()); return empty($this->getComment());
} }
/**
* @param string $comment
*/
public function setComment(?string $comment) public function setComment(?string $comment)
{ {
$this->comment = $comment; $this->comment = $comment;

View File

@ -0,0 +1,166 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\MainBundle\Entity;
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
use Chill\MainBundle\Repository\ResidentialAddressRepository;
use Chill\PersonBundle\Entity\Person;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=ResidentialAddressRepository::class)
* @ORM\Table(name="chill_main_residential_address")
*/
class ResidentialAddress
{
/**
* @ORM\ManyToOne(targetEntity=Address::class)
* @ORM\JoinColumn(nullable=true)
*/
private ?Address $address = null;
/**
* @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="residentialAddressComment_")
*/
private CommentEmbeddable $comment;
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*/
private ?DateTimeImmutable $endDate = null;
/**
* @ORM\ManyToOne(targetEntity=Person::class)
* @ORM\JoinColumn(nullable=true)
*/
private ?Person $hostPerson = null;
/**
* @ORM\ManyToOne(targetEntity=ThirdParty::class)
* @ORM\JoinColumn(nullable=true)
*/
private ?ThirdParty $hostThirdParty = null;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=Person::class)
* @ORM\JoinColumn(nullable=false)
*/
private Person $person;
/**
* @ORM\Column(type="datetime_immutable")
*/
private ?DateTimeImmutable $startDate = null;
public function __construct()
{
$this->comment = new CommentEmbeddable();
}
public function getAddress(): ?Address
{
return $this->address;
}
public function getComment(): CommentEmbeddable
{
return $this->comment;
}
public function getEndDate(): ?DateTimeImmutable
{
return $this->endDate;
}
public function getHostPerson(): ?Person
{
return $this->hostPerson;
}
public function getHostThirdParty(): ?ThirdParty
{
return $this->hostThirdParty;
}
public function getId(): ?int
{
return $this->id;
}
public function getPerson(): ?Person
{
return $this->person;
}
public function getStartDate(): ?DateTimeImmutable
{
return $this->startDate;
}
public function setAddress(?Address $address): self
{
$this->address = $address;
return $this;
}
public function setComment(CommentEmbeddable $comment): self
{
$this->comment = $comment;
return $this;
}
public function setEndDate(?DateTimeImmutable $endDate): self
{
$this->endDate = $endDate;
return $this;
}
public function setHostPerson(?Person $hostPerson): self
{
$this->hostPerson = $hostPerson;
return $this;
}
public function setHostThirdParty(?ThirdParty $hostThirdParty): self
{
$this->hostThirdParty = $hostThirdParty;
return $this;
}
public function setPerson(?Person $person): self
{
$this->person = $person;
return $this;
}
public function setStartDate(DateTimeImmutable $startDate): self
{
$this->startDate = $startDate;
return $this;
}
}

View File

@ -37,6 +37,7 @@ use function count;
class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface
{ {
use TrackCreationTrait; use TrackCreationTrait;
use TrackUpdateTrait; use TrackUpdateTrait;
/** /**

View File

@ -24,6 +24,7 @@ use Doctrine\ORM\Mapping as ORM;
class EntityWorkflowComment implements TrackCreationInterface, TrackUpdateInterface class EntityWorkflowComment implements TrackCreationInterface, TrackUpdateInterface
{ {
use TrackCreationTrait; use TrackCreationTrait;
use TrackUpdateTrait; use TrackUpdateTrait;
/** /**

View File

@ -0,0 +1,73 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\MainBundle\Form\Type;
use Chill\MainBundle\Entity\ResidentialAddress;
use Chill\PersonBundle\Form\Type\PickPersonDynamicType;
use Chill\ThirdPartyBundle\Form\Type\PickThirdpartyDynamicType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
final class ResidentialAddressType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('startDate', DateType::class, [
'required' => true,
'input' => 'datetime_immutable',
'widget' => 'single_text',
])
->add('endDate', DateType::class, [
'required' => false,
'input' => 'datetime_immutable',
'widget' => 'single_text',
])
->add('comment', CommentType::class, [
'required' => false,
]);
if ('person' === $options['kind']) {
$builder
->add('hostPerson', PickPersonDynamicType::class, [
'label' => 'Person',
]);
}
if ('thirdparty' === $options['kind']) {
$builder
->add('hostThirdParty', PickThirdpartyDynamicType::class, [
'label' => 'Third party',
]);
}
if ('address' === $options['kind']) {
$builder
->add('address', PickAddressType::class, [
'required' => false,
'label' => 'Address',
'use_valid_from' => false,
'use_valid_to' => false,
]);
}
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => ResidentialAddress::class,
'kind' => null,
]);
}
}

View File

@ -0,0 +1,59 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\MainBundle\Repository;
use Chill\MainBundle\Entity\ResidentialAddress;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @method ResidentialAddress|null find($id, $lockMode = null, $lockVersion = null)
* @method ResidentialAddress|null findOneBy(array $criteria, array $orderBy = null)
* @method ResidentialAddress[] findAll()
* @method ResidentialAddress[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class ResidentialAddressRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, ResidentialAddress::class);
}
// /**
// * @return ResidentialAddress[] Returns an array of ResidentialAddress objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('r')
->andWhere('r.exampleField = :val')
->setParameter('val', $value)
->orderBy('r.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/
/*
public function findOneBySomeField($value): ?ResidentialAddress
{
return $this->createQueryBuilder('r')
->andWhere('r.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
}

View File

@ -12,6 +12,7 @@
display: block; display: block;
top: calc(50% - 7px); top: calc(50% - 7px);
right: 10px; right: 10px;
line-height: 11px;
} }
} }
@ -62,14 +63,19 @@ ul.list-suggest {
& span:hover { & span:hover {
color: $chill-l-gray; color: $chill-l-gray;
} }
.person-text {
span {
padding-left: 0px;
}
}
} }
} }
&.remove-items { &.remove-items {
li { li {
position: relative; position: relative;
span { & > span {
display: block; display: block;
padding-right: .75rem; padding-right: 1.75rem;
@include remove_link; @include remove_link;
} }
} }

View File

@ -22,6 +22,7 @@ $chill-theme-buttons: (
"cancel": $gray-300, "cancel": $gray-300,
"choose": $gray-300, "choose": $gray-300,
"notify": $gray-300, "notify": $gray-300,
"search": $gray-300,
"unlink": $chill-red, "unlink": $chill-red,
"tpchild": $chill-pink, "tpchild": $chill-pink,
); );
@ -80,6 +81,7 @@ $chill-theme-buttons: (
&.btn-notify::before, &.btn-notify::before,
&.btn-tpchild::before, &.btn-tpchild::before,
&.btn-download::before, &.btn-download::before,
&.btn-search::before,
&.btn-cancel::before { &.btn-cancel::before {
font: normal normal normal 14px/1 ForkAwesome; font: normal normal normal 14px/1 ForkAwesome;
margin-right: 0.5em; margin-right: 0.5em;
@ -108,6 +110,7 @@ $chill-theme-buttons: (
&.btn-notify::before { content: "\f1d8"; } // fa-paper-plane &.btn-notify::before { content: "\f1d8"; } // fa-paper-plane
&.btn-tpchild::before { content: "\f007"; } // fa-user &.btn-tpchild::before { content: "\f007"; } // fa-user
&.btn-download::before { content: "\f019"; } // fa-download &.btn-download::before { content: "\f019"; } // fa-download
&.btn-search::before { content: "\f002"; } // fa-search
} }

View File

@ -1,21 +1,19 @@
require('./blur.scss'); require('./blur.scss');
var toggleBlur = function(e){ document.querySelectorAll('.confidential').forEach(function (el) {
let i = document.createElement('i');
var btn = e.target; const classes = ['fa', 'fa-eye', 'toggle'];
i.classList.add(...classes);
btn.previousElementSibling.classList.toggle("blur"); el.appendChild(i);
btn.classList.toggle("fa-eye"); const toggleBlur = function(e) {
btn.classList.toggle("fa-eye-slash"); for (let child of el.children) {
if (!child.classList.contains('toggle')) {
} child.classList.toggle('blur');
}
var infos = document.getElementsByClassName("confidential"); }
for(var i=0; i < infos.length; i++){ i.classList.toggle('fa-eye');
infos[i].insertAdjacentHTML('beforeend', '<i class="fa fa-eye toggle" aria-hidden="true"></i>'); i.classList.toggle('fa-eye-slash');
} }
i.addEventListener('click', toggleBlur);
var toggles = document.getElementsByClassName("toggle"); toggleBlur();
for(var i=0; i < toggles.length; i++){ });
toggles[i].addEventListener("click", toggleBlur);
}

View File

@ -19,6 +19,12 @@ function loadDynamicPicker(element) {
input = element.querySelector('[data-input-uniqid="'+ el.dataset.uniqid +'"]'), input = element.querySelector('[data-input-uniqid="'+ el.dataset.uniqid +'"]'),
picked = (isMultiple) ? (JSON.parse(input.value)) : ((input.value === '[]') ? (null) : ([JSON.parse(input.value)])); picked = (isMultiple) ? (JSON.parse(input.value)) : ((input.value === '[]') ? (null) : ([JSON.parse(input.value)]));
if (!isMultiple) {
if (input.value === '[]'){
input.value = null;
}
}
const app = createApp({ const app = createApp({
template: '<pick-entity ' + template: '<pick-entity ' +
':multiple="multiple" ' + ':multiple="multiple" ' +

View File

@ -562,6 +562,7 @@ export default {
this.entity.loaded.cities = []; this.entity.loaded.cities = [];
this.entity.loaded.countries = []; this.entity.loaded.countries = [];
this.entity.selected.confidential = this.context.edit ? this.entity.address.confidential : false;
this.entity.selected.isNoAddress = (this.context.edit && this.entity.address.text === '') ? true : false; this.entity.selected.isNoAddress = (this.context.edit && this.entity.address.text === '') ? true : false;
this.entity.selected.country = this.context.edit ? this.entity.address.country : {}; this.entity.selected.country = this.context.edit ? this.entity.address.country : {};
@ -593,6 +594,7 @@ export default {
{ {
console.log('apply changes'); console.log('apply changes');
let newAddress = { let newAddress = {
'confidential': this.entity.selected.confidential,
'isNoAddress': this.entity.selected.isNoAddress, 'isNoAddress': this.entity.selected.isNoAddress,
'street': this.entity.selected.isNoAddress ? '' : this.entity.selected.address.street, 'street': this.entity.selected.isNoAddress ? '' : this.entity.selected.address.street,
'streetNumber': this.entity.selected.isNoAddress ? '' : this.entity.selected.address.streetNumber, 'streetNumber': this.entity.selected.isNoAddress ? '' : this.entity.selected.address.streetNumber,

View File

@ -6,7 +6,6 @@
<input class="form-control" <input class="form-control"
type="text" type="text"
name="floor" name="floor"
maxlength=16
:placeholder="$t('floor')" :placeholder="$t('floor')"
v-model="floor"/> v-model="floor"/>
<label for="floor">{{ $t('floor') }}</label> <label for="floor">{{ $t('floor') }}</label>
@ -15,7 +14,6 @@
<input class="form-control" <input class="form-control"
type="text" type="text"
name="corridor" name="corridor"
maxlength=16
:placeholder="$t('corridor')" :placeholder="$t('corridor')"
v-model="corridor"/> v-model="corridor"/>
<label for="corridor">{{ $t('corridor') }}</label> <label for="corridor">{{ $t('corridor') }}</label>
@ -24,7 +22,6 @@
<input class="form-control" <input class="form-control"
type="text" type="text"
name="steps" name="steps"
maxlength=16
:placeholder="$t('steps')" :placeholder="$t('steps')"
v-model="steps"/> v-model="steps"/>
<label for="steps">{{ $t('steps') }}</label> <label for="steps">{{ $t('steps') }}</label>
@ -33,7 +30,6 @@
<input class="form-control" <input class="form-control"
type="text" type="text"
name="flat" name="flat"
maxlength=16
:placeholder="$t('flat')" :placeholder="$t('flat')"
v-model="flat"/> v-model="flat"/>
<label for="flat">{{ $t('flat') }}</label> <label for="flat">{{ $t('flat') }}</label>

View File

@ -17,12 +17,22 @@
<div class="row my-3"> <div class="row my-3">
<div class="col-lg-6"> <div class="col-lg-6">
<div class="form-check">
<input type="checkbox"
class="form-check-input"
id="isConfidential"
v-model="isConfidential"
:value="valueConfidential" />
<label class="form-check-label" for="isConfidential">
{{ $t('isConfidential') }}
</label>
</div>
<div class="form-check"> <div class="form-check">
<input type="checkbox" <input type="checkbox"
class="form-check-input" class="form-check-input"
id="isNoAddress" id="isNoAddress"
v-model="isNoAddress" v-model="isNoAddress"
v-bind:value="value" /> :value="value" />
<label class="form-check-label" for="isNoAddress"> <label class="form-check-label" for="isNoAddress">
{{ $t('isNoAddress') }} {{ $t('isNoAddress') }}
</label> </label>
@ -118,7 +128,8 @@ export default {
emits: ['getCities', 'getReferenceAddresses'], emits: ['getCities', 'getReferenceAddresses'],
data() { data() {
return { return {
value: false value: false,
valueConfidential: false,
} }
}, },
computed: { computed: {
@ -134,6 +145,14 @@ export default {
addressMap() { addressMap() {
return this.entity.addressMap; return this.entity.addressMap;
}, },
isConfidential: {
set(value) {
this.entity.selected.confidential = value;
},
get() {
return this.entity.selected.confidential;
}
},
isNoAddress: { isNoAddress: {
set(value) { set(value) {
console.log('isNoAddress value', value); console.log('isNoAddress value', value);

View File

@ -18,6 +18,7 @@ const addressMessages = {
other_address: 'Autre adresse', other_address: 'Autre adresse',
create_address: 'Adresse inconnue. Cliquez ici pour créer une nouvelle adresse', create_address: 'Adresse inconnue. Cliquez ici pour créer une nouvelle adresse',
isNoAddress: 'Pas d\'adresse complète', isNoAddress: 'Pas d\'adresse complète',
isConfidential: 'Adresse confidentielle',
street: 'Nom de rue', street: 'Nom de rue',
streetNumber: 'Numéro', streetNumber: 'Numéro',
floor: 'Étage', floor: 'Étage',

View File

@ -24,6 +24,11 @@
{{ $t('user')}} {{ $t('user')}}
</span> </span>
<span v-if="entity.type === 'household'" class="badge rounded-pill bg-user">
{{ $t('household')}}
</span>
</template> </template>
<script> <script>
@ -40,7 +45,8 @@ export default {
company: "Personne morale", company: "Personne morale",
contact: "Personne physique", contact: "Personne physique",
}, },
user: 'TMS' user: 'TMS',
household: 'Ménage',
} }
} }
} }

View File

@ -1,22 +1,26 @@
<template> <template>
<div class="confidential" v-on:click="toggleBlur"> <div :class="classes">
<div class="confidential-content blur"> <div class="confidential-content" :class="{ 'blur': isBlurred }">
<slot name="confidential-content"></slot> <slot name="confidential-content"></slot>
</div> </div>
<i class="fa fa-eye toggle" aria-hidden="true"></i> <div>
<i class="fa fa-eye toggle" aria-hidden="true" @click="toggleBlur"></i>
</div>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
name: "Confidential", name: "Confidential",
data() {
return {
isBlurred: true,
};
},
methods : { methods : {
toggleBlur: function(e){ toggleBlur() {
if(e.target.matches('.toggle')){ console.log('toggle blur');
e.target.previousElementSibling.classList.toggle("blur"); this.isBlurred = !this.isBlurred;
e.target.classList.toggle("fa-eye");
e.target.classList.toggle("fa-eye-slash");
}
}, },
} }
} }

View File

@ -1,7 +1,12 @@
<template> <template>
<component :is="component" class="chill-entity entity-address my-3"> <component :is="component" class="chill-entity entity-address my-3">
<component :is="component" class="address" :class="multiline"> <component :is="component" class="address" :class="multiline">
<div v-if="isConfidential">
<confidential>
<template v-slot:confidential-content>
<div v-if="isMultiline === true"> <div v-if="isMultiline === true">
<p v-for="(l, i) in address.lines" :key="`line-${i}`"> <p v-for="(l, i) in address.lines" :key="`line-${i}`">
{{ l }} {{ l }}
@ -21,6 +26,33 @@
{{ address.country.name.fr }} {{ address.country.name.fr }}
</p> </p>
</div> </div>
</template>
</confidential>
</div>
<div v-if="!isConfidential">
<div v-if="isMultiline === true">
<p v-for="(l, i) in address.lines" :key="`line-${i}`">
{{ l }}
</p>
</div>
<div v-else>
<p v-if="address.text"
class="street">
{{ address.text }}
</p>
<p v-if="address.postcode"
class="postcode">
{{ address.postcode.code }} {{ address.postcode.name }}
</p>
<p v-if="address.country"
class="country">
{{ address.country.name.fr }}
</p>
</div>
</div>
</component> </component>
<!-- <div v-if="isMultiline === true" class="address-more"> <!-- <div v-if="isMultiline === true" class="address-more">
@ -78,8 +110,14 @@
</template> </template>
<script> <script>
import Confidential from 'ChillMainAssets/vuejs/_components/Confidential.vue';
export default { export default {
name: 'AddressRenderBox', name: 'AddressRenderBox',
components: {
Confidential
},
props: { props: {
address: { address: {
type: Object type: Object
@ -100,6 +138,9 @@ export default {
multiline() { multiline() {
//console.log(this.isMultiline, typeof this.isMultiline); //console.log(this.isMultiline, typeof this.isMultiline);
return this.isMultiline === true ? "multiline" : ""; return this.isMultiline === true ? "multiline" : "";
},
isConfidential() {
return this.address.confidential;
} }
} }
}; };

View File

@ -61,14 +61,15 @@ const messages = {
woman: "Née le" woman: "Née le"
}, },
deathdate: "Date de décès", deathdate: "Date de décès",
years_old: "ans",
household_without_address: "Le ménage de l'usager est sans adresse", household_without_address: "Le ménage de l'usager est sans adresse",
no_data: "Aucune information renseignée", no_data: "Aucune information renseignée",
type: { type: {
thirdparty: "Tiers", thirdparty: "Tiers",
person: "Usager" person: "Usager"
}, },
holder: "Titulaire" holder: "Titulaire",
years_old: "an | {n} an | {n} ans",
} }
} }
}; };

View File

@ -59,7 +59,7 @@
must be shown in such list must be shown in such list
#} #}
{%- if render == 'list' -%} {%- if render == 'list' -%}
<li class="chill-entity entity-address"> <li class="chill-entity entity-address {% if address.confidential %}confidential{% endif %}">
{% if options['with_picto'] %} {% if options['with_picto'] %}
<i class="fa fa-li fa-map-marker"></i> <i class="fa fa-li fa-map-marker"></i>
{% endif %} {% endif %}
@ -68,7 +68,7 @@
{%- endif -%} {%- endif -%}
{%- if render == 'inline' -%} {%- if render == 'inline' -%}
<span class="chill-entity entity-address"> <span class="chill-entity entity-address {% if address.confidential %}confidential{% endif %}">
{% if options['with_picto'] %} {% if options['with_picto'] %}
<i class="fa fa-fw fa-map-marker"></i> <i class="fa fa-fw fa-map-marker"></i>
{% endif %} {% endif %}
@ -77,7 +77,7 @@
{%- endif -%} {%- endif -%}
{%- if render == 'bloc' -%} {%- if render == 'bloc' -%}
<div class="chill-entity entity-address"> <div class="chill-entity entity-address {% if address.confidential %}confidential{% endif %}">
{% 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 %} {% if address.postCode is not empty %}
<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 %}">

View File

@ -42,6 +42,3 @@
{% endif %} {% endif %}
></span> ></span>
{{ encore_entry_script_tags('vue_onthefly') }}
{{ encore_entry_link_tags('vue_onthefly') }}

View File

@ -13,6 +13,7 @@
{{ encore_entry_link_tags('mod_ckeditor5') }} {{ encore_entry_link_tags('mod_ckeditor5') }}
{{ encore_entry_link_tags('chill') }} {{ encore_entry_link_tags('chill') }}
{{ encore_entry_link_tags('mod_blur') }} {{ encore_entry_link_tags('mod_blur') }}
{{ encore_entry_link_tags('vue_onthefly') }}
{% block css %}<!-- nothing added to css -->{% endblock %} {% block css %}<!-- nothing added to css -->{% endblock %}
</head> </head>
@ -94,6 +95,7 @@
{{ encore_entry_script_tags('mod_ckeditor5') }} {{ encore_entry_script_tags('mod_ckeditor5') }}
{{ encore_entry_script_tags('mod_blur') }} {{ encore_entry_script_tags('mod_blur') }}
{{ encore_entry_script_tags('chill') }} {{ encore_entry_script_tags('chill') }}
{{ encore_entry_script_tags('vue_onthefly') }}
<script type="text/javascript"> <script type="text/javascript">
window.addEventListener('DOMContentLoaded', function(e) { window.addEventListener('DOMContentLoaded', function(e) {

View File

@ -45,13 +45,15 @@ class SearchUserApiProvider implements SearchApiInterface
$query $query
->setSelectKey('user') ->setSelectKey('user')
->setSelectJsonbMetadata("jsonb_build_object('id', u.id)") ->setSelectJsonbMetadata("jsonb_build_object('id', u.id)")
->setSelectPertinence('GREATEST(SIMILARITY(LOWER(UNACCENT(?)), u.usernamecanonical), ->setSelectPertinence('GREATEST(SIMILARITY(LOWER(UNACCENT(?)), u.label),
SIMILARITY(LOWER(UNACCENT(?)), u.emailcanonical))', [$pattern, $pattern]) SIMILARITY(LOWER(UNACCENT(?)), u.usernamecanonical))', [$pattern, $pattern])
->setFromClause('users AS u') ->setFromClause('users AS u')
->setWhereClauses('SIMILARITY(LOWER(UNACCENT(?)), u.usernamecanonical) > 0.15 ->setWhereClauses('
OR SIMILARITY(LOWER(UNACCENT(?)), u.usernamecanonical) > 0.15
SIMILARITY(LOWER(UNACCENT(?)), u.emailcanonical) > 0.15 OR u.usernamecanonical LIKE \'%\' || LOWER(UNACCENT(?)) || \'%\'
', [$pattern, $pattern]); OR SIMILARITY(LOWER(UNACCENT(?)), LOWER(UNACCENT(u.label))) > 0.15
OR u.label LIKE \'%\' || LOWER(UNACCENT(?)) || \'%\'
', [$pattern, $pattern, $pattern, $pattern]);
return $query; return $query;
} }

View File

@ -22,6 +22,10 @@ class SearchApiQuery
private array $fromClauseParams = []; private array $fromClauseParams = [];
private bool $isDistinct = false;
private ?string $isDistinctKey = null;
private ?string $jsonbMetadata = null; private ?string $jsonbMetadata = null;
private array $jsonbMetadataParams = []; private array $jsonbMetadataParams = [];
@ -105,6 +109,11 @@ class SearchApiQuery
]); ]);
} }
public function getDistinct(): bool
{
return $this->isDistinct;
}
public function getFromClause(): string public function getFromClause(): string
{ {
return $this->fromClause; return $this->fromClause;
@ -139,6 +148,14 @@ class SearchApiQuery
return $this; return $this;
} }
public function setDistinct(bool $distinct, string $distinctKey): self
{
$this->isDistinct = $distinct;
$this->isDistinctKey = $distinctKey;
return $this;
}
public function setFromClause(string $fromClause, array $params = []): self public function setFromClause(string $fromClause, array $params = []): self
{ {
$this->fromClause = $fromClause; $this->fromClause = $fromClause;
@ -185,9 +202,13 @@ class SearchApiQuery
private function buildSelectClause(bool $countOnly = false): string private function buildSelectClause(bool $countOnly = false): string
{ {
if ($countOnly) { if ($countOnly) {
if (!$this->isDistinct) {
return 'count(*) AS c'; return 'count(*) AS c';
} }
return 'count(distinct ' . $this->isDistinctKey . ') AS c';
}
$selects = $this->getSelectClauses(); $selects = $this->getSelectClauses();
if (null !== $this->selectKey) { if (null !== $this->selectKey) {
@ -202,7 +223,7 @@ class SearchApiQuery
$selects[] = strtr('{pertinence} AS pertinence', ['{pertinence}' => $this->pertinence]); $selects[] = strtr('{pertinence} AS pertinence', ['{pertinence}' => $this->pertinence]);
} }
return implode(', ', $selects); return ($this->isDistinct ? 'DISTINCT ' : '') . implode(', ', $selects);
} }
private function buildSelectParams(bool $count = false): array private function buildSelectParams(bool $count = false): array

View File

@ -45,6 +45,7 @@ class AddressNormalizer implements ContextAwareNormalizerInterface, NormalizerAw
'extra', 'extra',
'validFrom' => DateTimeInterface::class, 'validFrom' => DateTimeInterface::class,
'validTo' => DateTimeInterface::class, 'validTo' => DateTimeInterface::class,
'confidential',
]; ];
private AddressRender $addressRender; private AddressRender $addressRender;
@ -83,6 +84,7 @@ class AddressNormalizer implements ContextAwareNormalizerInterface, NormalizerAw
'buildingName' => $address->getBuildingName(), 'buildingName' => $address->getBuildingName(),
'distribution' => $address->getDistribution(), 'distribution' => $address->getDistribution(),
'extra' => $address->getExtra(), 'extra' => $address->getExtra(),
'confidential' => $address->getConfidential(),
'lines' => $this->addressRender->renderLines($address), 'lines' => $this->addressRender->renderLines($address),
]; ];

View File

@ -55,7 +55,7 @@ class CommentEmbeddableDocGenNormalizer implements ContextAwareNormalizerInterfa
$user = $this->userRepository->find($object->getUserId()); $user = $this->userRepository->find($object->getUserId());
return [ return [
'comment' => (string) $object->getComment(), 'comment' => $object->getComment(),
'isNull' => false, 'isNull' => false,
'date' => $this->normalizer->normalize($object->getDate(), $format, array_merge($context, [ 'date' => $this->normalizer->normalize($object->getDate(), $format, array_merge($context, [
'docgen:expects' => DateTime::class, 'docgen:expects' => DateTime::class,

View File

@ -44,7 +44,9 @@ use function count;
final class ExportManagerTest extends KernelTestCase final class ExportManagerTest extends KernelTestCase
{ {
use PrepareCenterTrait; use PrepareCenterTrait;
use PrepareScopeTrait; use PrepareScopeTrait;
use PrepareUserTrait; use PrepareUserTrait;
private Prophet $prophet; private Prophet $prophet;

View File

@ -34,8 +34,11 @@ use function in_array;
final class AuthorizationHelperTest extends KernelTestCase final class AuthorizationHelperTest extends KernelTestCase
{ {
use PrepareCenterTrait; use PrepareCenterTrait;
use PrepareScopeTrait; use PrepareScopeTrait;
use PrepareUserTrait; use PrepareUserTrait;
use ProphecyTrait; use ProphecyTrait;
protected function setUp(): void protected function setUp(): void

View File

@ -134,6 +134,7 @@ paths:
- search - search
- person - person
- thirdparty - thirdparty
- household
description: > description: >
The search is performed across multiple entities. The entities must be listed into The search is performed across multiple entities. The entities must be listed into
`type` parameters. `type` parameters.
@ -159,6 +160,7 @@ paths:
- person - person
- thirdparty - thirdparty
- user - user
- household
responses: responses:
200: 200:
description: "OK" description: "OK"

View File

@ -0,0 +1,44 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\Migrations\Main;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Alter some address fields + add confidential field on Address.
*/
final class Version20220124085957 extends AbstractMigration
{
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE chill_main_address DROP confidential');
$this->addSql('ALTER TABLE chill_main_address ALTER corridor TYPE VARCHAR(16)');
$this->addSql('ALTER TABLE chill_main_address ALTER flat TYPE VARCHAR(16)');
$this->addSql('ALTER TABLE chill_main_address ALTER floor TYPE VARCHAR(16)');
$this->addSql('ALTER TABLE chill_main_address ALTER steps TYPE VARCHAR(16)');
}
public function getDescription(): string
{
return 'Alter some address fields + add confidential field on Address';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE chill_main_address ADD confidential BOOLEAN DEFAULT FALSE');
$this->addSql('ALTER TABLE chill_main_address ALTER floor TYPE TEXT');
$this->addSql('ALTER TABLE chill_main_address ALTER corridor TYPE TEXT');
$this->addSql('ALTER TABLE chill_main_address ALTER steps TYPE TEXT');
$this->addSql('ALTER TABLE chill_main_address ALTER flat TYPE TEXT');
}
}

View File

@ -0,0 +1,48 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\Migrations\Main;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Create a new entity ResidentialAddress.
*/
final class Version20220125134253 extends AbstractMigration
{
public function down(Schema $schema): void
{
$this->addSql('DROP SEQUENCE chill_main_residential_address_id_seq CASCADE');
$this->addSql('DROP TABLE chill_main_residential_address');
}
public function getDescription(): string
{
return 'Create a new entity ResidentialAddress';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE SEQUENCE chill_main_residential_address_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE chill_main_residential_address (id INT NOT NULL, person_id INT NOT NULL, address_id INT DEFAULT NULL, startDate TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, endDate TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, residentialAddressComment_comment TEXT DEFAULT NULL, residentialAddressComment_date TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, residentialAddressComment_userId INT DEFAULT NULL, hostPerson_id INT DEFAULT NULL, hostThirdParty_id INT DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_9BC1FD50217BBB47 ON chill_main_residential_address (person_id)');
$this->addSql('CREATE INDEX IDX_9BC1FD50DCA38092 ON chill_main_residential_address (hostPerson_id)');
$this->addSql('CREATE INDEX IDX_9BC1FD508DFC48DC ON chill_main_residential_address (hostThirdParty_id)');
$this->addSql('CREATE INDEX IDX_9BC1FD50F5B7AF75 ON chill_main_residential_address (address_id)');
$this->addSql('COMMENT ON COLUMN chill_main_residential_address.startDate IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('COMMENT ON COLUMN chill_main_residential_address.endDate IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('ALTER TABLE chill_main_residential_address ADD CONSTRAINT FK_9BC1FD50217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_main_residential_address ADD CONSTRAINT FK_9BC1FD50DCA38092 FOREIGN KEY (hostPerson_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_main_residential_address ADD CONSTRAINT FK_9BC1FD508DFC48DC FOREIGN KEY (hostThirdParty_id) REFERENCES chill_3party.third_party (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_main_residential_address ADD CONSTRAINT FK_9BC1FD50F5B7AF75 FOREIGN KEY (address_id) REFERENCES chill_main_address (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
}
}

View File

@ -52,6 +52,8 @@ Since %date%: Depuis le %date%
since %date%: depuis le %date% since %date%: depuis le %date%
Until %date%: Jusqu'au %date% Until %date%: Jusqu'au %date%
until %date%: jusqu'au %date% until %date%: jusqu'au %date%
Since: Depuis le
Until: Jusqu'au
#elements used in software #elements used in software
centers: centres centers: centres
Centers: Centres Centers: Centres

View File

@ -0,0 +1,161 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\PersonBundle\Controller;
use Chill\MainBundle\Entity\ResidentialAddress;
use Chill\MainBundle\Form\Type\ResidentialAddressType;
use Chill\MainBundle\Repository\ResidentialAddressRepository;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
final class ResidentialAddressController extends AbstractController
{
private UrlGeneratorInterface $generator;
private ResidentialAddressRepository $residentialAddressRepository;
private TranslatorInterface $translator;
public function __construct(
UrlGeneratorInterface $generator,
TranslatorInterface $translator,
ResidentialAddressRepository $residentialAddressRepository
) {
$this->generator = $generator;
$this->translator = $translator;
$this->residentialAddressRepository = $residentialAddressRepository;
}
/**
* @Route("/{_locale}/person/residential-address/{id}/delete", name="chill_person_residential_address_delete")
*/
public function deleteAction(Request $request, ResidentialAddress $residentialAddress): Response
{
$this->denyAccessUnlessGranted(PersonVoter::UPDATE, $residentialAddress->getPerson());
$form = $this->createForm(FormType::class);
$form->add('submit', SubmitType::class, ['label' => 'Delete']);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->remove($residentialAddress);
$em->flush();
$this->addFlash('success', $this->translator->trans('Residential address had been deleted'));
return $this->redirectToRoute('chill_person_residential_address_list', ['id' => $residentialAddress->getPerson()->getId()]);
}
return $this->render('@ChillPerson/ResidentialAddress/delete.html.twig', [
'person' => $residentialAddress->getPerson(),
'residentialAddress' => $residentialAddress,
'delete_form' => $form->createView(),
]);
}
/**
* @Route("/{_locale}/person/residential-address/{id}/edit", name="chill_person_residential_address_edit")
*/
public function editAction(Request $request, ResidentialAddress $residentialAddress): Response
{
if ($request->query->has('kind')) {
$kind = $request->query->getAlpha('kind', '');
} else {
$kind = null;
}
$person = $residentialAddress->getPerson();
$this->denyAccessUnlessGranted(PersonVoter::UPDATE, $person);
$form = $this->createForm(ResidentialAddressType::class, $residentialAddress, ['kind' => $kind]);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$this->getDoctrine()->getManager()->flush();
$this->addFlash('success', $this->translator
->trans('The residential address was updated successfully'));
return $this->redirect(
$request->get('returnPath', null) ??
$this->generator->generate('chill_person_residential_address_list', ['id' => $person->getId()])
);
}
return $this->render('@ChillPerson/ResidentialAddress/edit.html.twig', [
'residentialAddress' => $residentialAddress,
'person' => $person,
'form' => $form->createView(),
]);
}
/**
* @Route("/{_locale}/person/{id}/residential-address/list", name="chill_person_residential_address_list")
*/
public function listAction(Request $request, Person $person): Response
{
$this->denyAccessUnlessGranted(PersonVoter::SEE, $person);
$residentialAddresses = $this->residentialAddressRepository->findBy(['person' => $person], ['startDate' => 'DESC']);
return $this->render('@ChillPerson/ResidentialAddress/list.html.twig', [
'person' => $person,
'addresses' => $residentialAddresses,
]);
}
/**
* @Route("/{_locale}/person/{id}/residential-address/new", name="chill_person_residential_address_new")
*/
public function newAction(Request $request, Person $person): Response
{
$residentialAddress = new ResidentialAddress();
$residentialAddress->setPerson($person);
$this->denyAccessUnlessGranted(PersonVoter::UPDATE, $person);
if (!$request->query->has('kind')) {
return $this->render('@ChillPerson/ResidentialAddress/new_pick_kind.html.twig', ['person' => $person]);
}
$kind = $request->query->getAlpha('kind', '');
$form = $this->createForm(ResidentialAddressType::class, $residentialAddress, ['kind' => $kind]);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$this->getDoctrine()->getManager()->persist($residentialAddress);
$this->getDoctrine()->getManager()->flush();
$this->addFlash('success', $this->translator
->trans('The new residential address was created successfully'));
return $this->redirect(
$request->get('returnPath', null) ??
$this->generator->generate('chill_person_residential_address_list', ['id' => $residentialAddress->getPerson()->getId()])
);
}
return $this->render('@ChillPerson/ResidentialAddress/new.html.twig', [
'person' => $person,
'form' => $form->createView(),
]);
}
}

View File

@ -0,0 +1,51 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\PersonBundle\Controller;
use Chill\MainBundle\Pagination\PaginatorFactory;
use Chill\PersonBundle\Repository\AccompanyingPeriodRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
class UserAccompanyingPeriodController extends AbstractController
{
private AccompanyingPeriodRepository $accompanyingPeriodRepository;
private PaginatorFactory $paginatorFactory;
public function __construct(AccompanyingPeriodRepository $accompanyingPeriodRepository, PaginatorFactory $paginatorFactory)
{
$this->accompanyingPeriodRepository = $accompanyingPeriodRepository;
$this->paginatorFactory = $paginatorFactory;
}
/**
* @Route("/{_locale}/accompanying-periods", name="chill_person_accompanying_period_user")
*/
public function listAction(Request $request)
{
$total = $this->accompanyingPeriodRepository->countBy(['user' => $this->getUser()]);
$pagination = $this->paginatorFactory->create($total);
$accompanyingPeriods = $this->accompanyingPeriodRepository->findBy(
['user' => $this->getUser()],
['openingDate' => 'DESC'],
$pagination->getItemsPerPage(),
$pagination->getCurrentPageFirstItemNumber()
);
return $this->render('@ChillPerson/AccompanyingPeriod/user_periods_list.html.twig', [
'accompanyingPeriods' => $accompanyingPeriods,
'pagination' => $pagination,
]);
}
}

View File

@ -212,6 +212,8 @@ class AccompanyingPeriod implements
* *
* @ORM\Column(type="date") * @ORM\Column(type="date")
* @Groups({"read", "write", "docgen:read"}) * @Groups({"read", "write", "docgen:read"})
* @Assert\LessThan(value= "today", groups={AccompanyingPeriod::STEP_CONFIRMED})
* @Assert\LessThan(propertyPath="closingDate", groups={AccompanyingPeriod::STEP_CONFIRMED})
*/ */
private ?DateTime $openingDate = null; private ?DateTime $openingDate = null;

View File

@ -33,6 +33,7 @@ use Symfony\Component\Validator\Constraints as Assert;
class HouseholdComposition implements TrackCreationInterface, TrackUpdateInterface class HouseholdComposition implements TrackCreationInterface, TrackUpdateInterface
{ {
use TrackCreationTrait; use TrackCreationTrait;
use TrackUpdateTrait; use TrackUpdateTrait;
/** /**

View File

@ -784,12 +784,18 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
* If the `$at` parameter is now, use the method `getCurrentPersonAddress`, which is optimized * If the `$at` parameter is now, use the method `getCurrentPersonAddress`, which is optimized
* on database side. * on database side.
* *
* @deprecated since chill2.0, address is linked to the household. Use @see{Person::getCurrentHouseholdAddress}
*
* @throws Exception * @throws Exception
*/ */
public function getAddressAt(?DateTime $at = null): ?Address public function getAddressAt(?DateTimeInterface $at = null): ?Address
{ {
$at ??= new DateTime('now'); $at ??= new DateTime('now');
if ($at instanceof DateTimeImmutable) {
$at = DateTime::createFromImmutable($at);
}
/** @var ArrayIterator $addressesIterator */ /** @var ArrayIterator $addressesIterator */
$addressesIterator = $this->getAddresses() $addressesIterator = $this->getAddresses()
->filter(static fn (Address $address): bool => $address->getValidFrom() <= $at) ->filter(static fn (Address $address): bool => $address->getValidFrom() <= $at)
@ -950,6 +956,12 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
: null; : null;
} }
/**
* Get the household address at the given date.
*
* if the given date is 'now', use instead @see{getCurrentPersonAddress}, which is optimized on
* database side.
*/
public function getCurrentHouseholdAddress(?DateTimeImmutable $at = null): ?Address public function getCurrentHouseholdAddress(?DateTimeImmutable $at = null): ?Address
{ {
if ( if (

View File

@ -34,6 +34,7 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
class PersonResource implements TrackCreationInterface, TrackUpdateInterface class PersonResource implements TrackCreationInterface, TrackUpdateInterface
{ {
use TrackCreationTrait; use TrackCreationTrait;
use TrackUpdateTrait; use TrackUpdateTrait;
/** /**

View File

@ -62,6 +62,16 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface
'order' => 50, 'order' => 50,
]); ]);
$menu->addChild($this->translator->trans('Residential addresses'), [
'route' => 'chill_person_residential_address_list',
'routeParameters' => [
'id' => $parameters['person']->getId(),
],
])
->setExtras([
'order' => 60,
]);
$menu->addChild($this->translator->trans('household.person history'), [ $menu->addChild($this->translator->trans('household.person history'), [
'route' => 'chill_person_household_person_history', 'route' => 'chill_person_household_person_history',
'routeParameters' => [ 'routeParameters' => [

View File

@ -0,0 +1,54 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\PersonBundle\Menu;
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
use Knp\Menu\MenuItem;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
class UserMenuBuilder implements LocalMenuBuilderInterface
{
/**
* @var AuthorizationCheckerInterface
*/
public $authorizationChecker;
/**
* @var TranslatorInterface
*/
public $translator;
public function __construct(
AuthorizationCheckerInterface $authorizationChecker
) {
$this->authorizationChecker = $authorizationChecker;
}
public function buildMenu($menuId, MenuItem $menu, array $parameters)
{
if ($this->authorizationChecker->isGranted('ROLE_USER')) {
$menu->addChild('My accompanying periods', [
'route' => 'chill_person_accompanying_period_user',
])
->setExtras([
'order' => 20,
'icon' => 'tasks',
]);
}
}
public static function getMenuIds(): array
{
return ['user'];
}
}

View File

@ -26,6 +26,11 @@ final class AccompanyingPeriodRepository implements ObjectRepository
$this->repository = $entityManager->getRepository(AccompanyingPeriod::class); $this->repository = $entityManager->getRepository(AccompanyingPeriod::class);
} }
public function countBy(array $criteria): int
{
return $this->repository->count($criteria);
}
public function createQueryBuilder(string $alias, ?string $indexBy = null): QueryBuilder public function createQueryBuilder(string $alias, ?string $indexBy = null): QueryBuilder
{ {
return $this->repository->createQueryBuilder($alias, $indexBy); return $this->repository->createQueryBuilder($alias, $indexBy);

View File

@ -14,6 +14,7 @@
<scopes></scopes> <scopes></scopes>
<referrer></referrer> <referrer></referrer>
<resources></resources> <resources></resources>
<start-date v-if="accompanyingCourse.step === 'CONFIRMED'"></start-date>
<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>
@ -39,6 +40,7 @@ import Referrer from './components/Referrer.vue';
import Resources from './components/Resources.vue'; import Resources from './components/Resources.vue';
import Comment from './components/Comment.vue'; import Comment from './components/Comment.vue';
import Confirm from './components/Confirm.vue'; import Confirm from './components/Confirm.vue';
import StartDate from './components/StartDate.vue';
export default { export default {
name: 'App', name: 'App',
@ -56,6 +58,7 @@ export default {
Resources, Resources,
Comment, Comment,
Confirm, Confirm,
StartDate
}, },
computed: { computed: {
...mapState([ ...mapState([

View File

@ -4,7 +4,7 @@
<i class="fa fa-home fa-fw text-light" :title="$t('persons_associated.show_household_number', { id: h.id })"></i> <i class="fa fa-home fa-fw text-light" :title="$t('persons_associated.show_household_number', { id: h.id })"></i>
</a> </a>
<span v-for="person in h.persons" class="me-1" :key="person.id"> <span v-for="person in h.persons" class="me-1" :key="person.id">
<on-the-fly :type="person.type" :id="person.id" :buttonText="person.text" :displayBadge="'true' === 'true'" action="show"></on-the-fly> <on-the-fly :type="person.type" :id="person.id" :buttonText="person.textAge" :displayBadge="'true' === 'true'" action="show"></on-the-fly>
</span> </span>
</span> </span>
</template> </template>

View File

@ -27,7 +27,7 @@
:value="p.person.id" :value="p.person.id"
/> />
<label class="form-check-label"> <label class="form-check-label">
{{ p.person.text }} <person-text :person="p.person"></person-text>
</label> </label>
</div> </div>
<input type="hidden" name="expand_suggestions" value="true"> <input type="hidden" name="expand_suggestions" value="true">
@ -50,7 +50,7 @@
<div v-if="suggestedPersons.length > 0"> <div v-if="suggestedPersons.length > 0">
<ul class="list-suggest add-items inline"> <ul class="list-suggest add-items inline">
<li v-for="p in suggestedPersons" :key="p.id" @click="addSuggestedPerson(p)"> <li v-for="p in suggestedPersons" :key="p.id" @click="addSuggestedPerson(p)">
<span>{{ p.text }}</span> <person-text :person="p"></person-text>
</li> </li>
</ul> </ul>
</div> </div>
@ -76,12 +76,14 @@
import {mapGetters, mapState} from 'vuex'; import {mapGetters, mapState} from 'vuex';
import ParticipationItem from "./PersonsAssociated/ParticipationItem.vue"; import ParticipationItem from "./PersonsAssociated/ParticipationItem.vue";
import AddPersons from 'ChillPersonAssets/vuejs/_components/AddPersons.vue'; import AddPersons from 'ChillPersonAssets/vuejs/_components/AddPersons.vue';
import PersonText from 'ChillPersonAssets/vuejs/_components/Entity/PersonText.vue';
export default { export default {
name: 'PersonsAssociated', name: 'PersonsAssociated',
components: { components: {
ParticipationItem, ParticipationItem,
AddPersons AddPersons,
PersonText
}, },
data() { data() {
return { return {

View File

@ -45,7 +45,8 @@
addInfo: true, addInfo: true,
hLevel: 3, hLevel: 3,
isMultiline: true, isMultiline: true,
isConfidential: false isConfidential: false,
addAge: true,
}" }"
> >
<template v-slot:record-actions> <template v-slot:record-actions>
@ -136,7 +137,8 @@
<div v-if="accompanyingCourse.requestor === null && suggestedEntities.length > 0"> <div v-if="accompanyingCourse.requestor === null && suggestedEntities.length > 0">
<ul class="list-suggest add-items inline"> <ul class="list-suggest add-items inline">
<li v-for="p in suggestedEntities" :key="uniqueId(p)" @click="addSuggestedEntity(p)"> <li v-for="p in suggestedEntities" :key="uniqueId(p)" @click="addSuggestedEntity(p)">
<span>{{ p.text }}</span> <person-text v-if="p.type === 'person'" :person="p"></person-text>
<span v-else>{{ p.text }}</span>
</li> </li>
</ul> </ul>
</div> </div>
@ -162,6 +164,8 @@ import PersonRenderBox from '../../_components/Entity/PersonRenderBox.vue';
import ThirdPartyRenderBox from 'ChillThirdPartyAssets/vuejs/_components/Entity/ThirdPartyRenderBox.vue'; import ThirdPartyRenderBox from 'ChillThirdPartyAssets/vuejs/_components/Entity/ThirdPartyRenderBox.vue';
import Confidential from 'ChillMainAssets/vuejs/_components/Confidential.vue'; import Confidential from 'ChillMainAssets/vuejs/_components/Confidential.vue';
import { mapState } from 'vuex'; import { mapState } from 'vuex';
import PersonText from 'ChillPersonAssets/vuejs/_components/Entity/PersonText.vue';
export default { export default {
name: 'Requestor', name: 'Requestor',
@ -170,7 +174,8 @@ export default {
OnTheFly, OnTheFly,
PersonRenderBox, PersonRenderBox,
ThirdPartyRenderBox, ThirdPartyRenderBox,
Confidential Confidential,
PersonText
}, },
props: ['isAnonymous'], props: ['isAnonymous'],
data() { data() {

View File

@ -22,7 +22,8 @@
<div v-if="suggestedEntities.length > 0"> <div v-if="suggestedEntities.length > 0">
<ul class="list-suggest add-items inline"> <ul class="list-suggest add-items inline">
<li v-for="p in suggestedEntities" :key="uniqueId(p)" @click="addSuggestedEntity(p)"> <li v-for="p in suggestedEntities" :key="uniqueId(p)" @click="addSuggestedEntity(p)">
<span>{{ p.text }}</span> <person-text v-if="p.type === 'person'" :person="p"></person-text>
<span v-else>{{ p.text }}</span>
</li> </li>
</ul> </ul>
</div> </div>
@ -45,12 +46,15 @@
import { mapState } from 'vuex'; import { mapState } from 'vuex';
import AddPersons from 'ChillPersonAssets/vuejs/_components/AddPersons.vue'; import AddPersons from 'ChillPersonAssets/vuejs/_components/AddPersons.vue';
import ResourceItem from './Resources/ResourceItem.vue'; import ResourceItem from './Resources/ResourceItem.vue';
import PersonText from 'ChillPersonAssets/vuejs/_components/Entity/PersonText.vue';
export default { export default {
name: 'Resources', name: 'Resources',
components: { components: {
AddPersons, AddPersons,
ResourceItem ResourceItem,
PersonText
}, },
data() { data() {
return { return {

View File

@ -0,0 +1,46 @@
<template>
<div class="vue-component">
<h2><a id="section-110"></a>
{{ $t('startdate.change') }}
</h2>
<div>
<div class="mb-3 row">
<label class="col-form-label col-sm-4">{{ $t('startdate.date') }}</label>
<div class="col-sm-8">
<input class="form-control" type="date" v-model="startDate" @change="updateStartDate" />
</div>
</div>
</div>
</div>
</template>
<script>
import { datetimeToISO, dateToISO, ISOToDate, ISOToDatetime} from 'ChillMainAssets/chill/js/date.js';
import { mapState, mapGetters } from 'vuex';
export default {
name: 'startDate',
methods: {
updateStartDate(event) {
const date = event.target.value;
// console.log(date)
this.$store.dispatch('updateStartDate', date)
.catch(({name, violations}) => {
if (name === 'ValidationException' || name === 'AccessException') {
violations.forEach((violation) => this.$toast.open({message: violation}));
} else {
this.$toast.open({message: 'An error occurred'})
}
});
},
},
computed: {
...mapState({
startDate: state => dateToISO(ISOToDatetime(state.accompanyingCourse.openingDate.datetime))
})
}
}
</script>

View File

@ -151,6 +151,10 @@ const appMessages = {
placeholder: "Choisir un métier", placeholder: "Choisir un métier",
not_valid: "Sélectionnez un métier du référent" not_valid: "Sélectionnez un métier du référent"
}, },
startdate: {
change: "Modifier la date de début",
date: "Date de début",
},
// catch errors // catch errors
'Error while updating AccompanyingPeriod Course.': "Erreur du serveur lors de la mise à jour du parcours d'accompagnement.", 'Error while updating AccompanyingPeriod Course.': "Erreur du serveur lors de la mise à jour du parcours d'accompagnement.",
'Error while retriving AccompanyingPeriod Course.': "Erreur du serveur lors du chargement du parcours d'accompagnement.", 'Error while retriving AccompanyingPeriod Course.': "Erreur du serveur lors du chargement du parcours d'accompagnement.",

View File

@ -8,6 +8,7 @@ import { getAccompanyingCourse,
import { patchPerson } from "ChillPersonAssets/vuejs/_api/OnTheFly"; import { patchPerson } from "ChillPersonAssets/vuejs/_api/OnTheFly";
import { patchThirdparty } from "ChillThirdPartyAssets/vuejs/_api/OnTheFly"; import { patchThirdparty } from "ChillThirdPartyAssets/vuejs/_api/OnTheFly";
import { makeFetch } from 'ChillMainAssets/lib/api/apiMethods'; import { makeFetch } from 'ChillMainAssets/lib/api/apiMethods';
import { datetimeToISO, ISOToDate, ISOToDatetime } from 'ChillMainAssets/chill/js/date.js';
const debug = process.env.NODE_ENV !== 'production'; const debug = process.env.NODE_ENV !== 'production';
@ -278,6 +279,10 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
if (scopeIds.includes(scope.id)) { if (scopeIds.includes(scope.id)) {
state.scopesAtBackend = state.scopesAtBackend.filter(s => s.id !== scope.id); state.scopesAtBackend = state.scopesAtBackend.filter(s => s.id !== scope.id);
} }
},
updateStartDate(state, date) {
console.log('new state date', date)
state.accompanyingCourse.openingDate = date;
} }
}, },
actions: { actions: {
@ -701,6 +706,21 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
throw error; throw error;
}) })
}, },
updateStartDate({commit}, payload) {
console.log('payload', payload)
const date = ISOToDate(payload);
const url = `/api/1.0/person/accompanying-course/${id}.json`;
const body = { type: "accompanying_period", openingDate: { datetime: datetimeToISO(date) }};
console.log('body', body)
return makeFetch('PATCH', url, body)
.then((response) => {
commit('updateStartDate', response.openingDate);
})
.catch((error) => {
commit('catchError', error);
throw error;
})
},
async fetchReferrersSuggested({ state, commit}) { async fetchReferrersSuggested({ state, commit}) {
let users = await getReferrersSuggested(state.accompanyingCourse); let users = await getReferrersSuggested(state.accompanyingCourse);
commit('setReferrersSuggested', users); commit('setReferrersSuggested', users);

View File

@ -5,7 +5,7 @@
<div id="awc_create_form"> <div id="awc_create_form">
<div id="picking"> <div id="picking" class="">
<p>{{ $t('pick_social_issue_linked_with_action') }}</p> <p>{{ $t('pick_social_issue_linked_with_action') }}</p>
<div v-for="si in socialIssues" :key="si.id"> <div v-for="si in socialIssues" :key="si.id">
<input type="radio" v-bind:value="si.id" name="socialIssue" v-model="socialIssuePicked"><span class="badge bg-chill-l-gray text-dark">{{ si.text }}</span> <input type="radio" v-bind:value="si.id" name="socialIssue" v-model="socialIssuePicked"><span class="badge bg-chill-l-gray text-dark">{{ si.text }}</span>
@ -33,7 +33,7 @@
</vue-multiselect> </vue-multiselect>
</div> </div>
</div> </div>
<div v-if="hasSocialIssuePicked"> <div v-if="hasSocialIssuePicked" class="mb-3">
<h2>{{ $t('pick_an_action') }}</h2> <h2>{{ $t('pick_an_action') }}</h2>
<div class="col-11"> <div class="col-11">
<vue-multiselect <vue-multiselect
@ -52,26 +52,43 @@
<i class="fa fa-circle-o-notch fa-spin fa-fw"></i> <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" class="mb-5">
<h2>{{ $t('persons_involved') }}</h2> <h2>{{ $t('persons_involved') }}</h2>
<ul> <ul>
<li v-for="p in personsReachables" :key="p.id"> <li v-for="p in personsReachables" :key="p.id">
<input type="checkbox" :value="p.id" v-model="personsPicked"> <div class="form-check">
<person-render-box render="badge" :options="{}" :person="p"></person-render-box> <input type="checkbox" :value="p.id" v-model="personsPicked" class="form-check-input" :id="'person_check'+p.id">
<label class="form-check-label" :for="'person_check' + p.id">
<person-text :person="p"></person-text>
</label>
</div>
</li> </li>
</ul> </ul>
</div> </div>
</div> </div>
<div v-if="hasSocialActionPicked" id="start_date"> <!-- <div v-if="hasSocialActionPicked" id="start_date">
<p><label>{{ $t('startDate') }}</label> <input type="date" v-model="startDate" /></p> <p><label>{{ $t('startDate') }}</label> <input type="date" v-model="startDate" /></p>
</div> -->
<div class="row">
<div v-if="hasSocialActionPicked" id="start_date" class="mb-3 row">
<label class="col-form-label col-sm-4">{{ $t('startDate') }}</label>
<div class="col-sm-8">
<input class="form-control" type="date" v-model="startDate"/>
</div>
</div> </div>
<div v-if="hasSocialActionPicked" id="end_date"> <!-- <div v-if="hasSocialActionPicked" id="end_date">
<p><label>{{ $t('endDate') }}</label> <input type="date" v-model="endDate" /></p> <p><label>{{ $t('endDate') }}</label> <input type="date" v-model="endDate" /></p>
</div> -->
<div v-if="hasSocialActionPicked" id="end_date" class="mb-3 row">
<label class="col-form-label col-sm-4">{{ $t('endDate') }}</label>
<div class="col-sm-8">
<input class="form-control" type="date" v-model="endDate"/>
</div>
</div>
</div> </div>
<div id="confirm"> <div id="confirm">
<div v-if="hasErrors"> <div v-if="hasErrors">
<p>{{ $t('form_has_errors') }}</p> <p>{{ $t('form_has_errors') }}</p>
@ -111,7 +128,7 @@
import { mapState, mapActions, mapGetters } from 'vuex'; import { mapState, mapActions, mapGetters } from 'vuex';
import VueMultiselect from 'vue-multiselect'; import VueMultiselect from 'vue-multiselect';
import { dateToISO, ISOToDate } from 'ChillMainAssets/chill/js/date.js'; import { dateToISO, ISOToDate } from 'ChillMainAssets/chill/js/date.js';
import PersonRenderBox from 'ChillPersonAssets/vuejs/_components/Entity/PersonRenderBox.vue'; import PersonText from 'ChillPersonAssets/vuejs/_components/Entity/PersonText.vue';
const i18n = { const i18n = {
messages: { messages: {
@ -133,7 +150,7 @@ export default {
name: 'App', name: 'App',
components: { components: {
VueMultiselect, VueMultiselect,
PersonRenderBox, PersonText,
}, },
methods: { methods: {
submit() { submit() {

View File

@ -141,10 +141,12 @@
<ul class="list-unstyled"> <ul class="list-unstyled">
<li v-for="p in personsReachables" :key="p.id"> <li v-for="p in personsReachables" :key="p.id">
<label :for="p.id"> <div class="form-check">
<input v-model="personsPicked" :value="p.id" :id="p.id" type="checkbox" class="me-2"> <input v-model="personsPicked" :value="p.id" type="checkbox" class="me-2 form-check-input" :id="'person_check'+p.id">
{{ p.text }} <label :for="'person_check'+p.id" class="form-check-label">
<person-text :person="p"></person-text>
</label> </label>
</div>
</li> </li>
</ul> </ul>
</div> </div>
@ -281,6 +283,7 @@ import ThirdPartyRenderBox from 'ChillThirdPartyAssets/vuejs/_components/Entity/
import PickTemplate from 'ChillDocGeneratorAssets/vuejs/_components/PickTemplate.vue'; import PickTemplate from 'ChillDocGeneratorAssets/vuejs/_components/PickTemplate.vue';
import OnTheFly from 'ChillMainAssets/vuejs/OnTheFly/components/OnTheFly.vue'; import OnTheFly from 'ChillMainAssets/vuejs/OnTheFly/components/OnTheFly.vue';
import PickWorkflow from 'ChillMainAssets/vuejs/_components/EntityWorkflow/PickWorkflow.vue'; import PickWorkflow from 'ChillMainAssets/vuejs/_components/EntityWorkflow/PickWorkflow.vue';
import PersonText from 'ChillPersonAssets/vuejs/_components/Entity/PersonText.vue';
const i18n = { const i18n = {
messages: { messages: {
@ -329,7 +332,8 @@ export default {
ThirdPartyRenderBox, ThirdPartyRenderBox,
PickTemplate, PickTemplate,
PickWorkflow, PickWorkflow,
OnTheFly OnTheFly,
PersonText,
}, },
i18n, i18n,
data() { data() {

View File

@ -11,7 +11,7 @@
<ul class="list-suggest remove-items inline"> <ul class="list-suggest remove-items inline">
<li v-for="c in concerned" :key="c.person.id" @click="removeConcerned(c)"> <li v-for="c in concerned" :key="c.person.id" @click="removeConcerned(c)">
<span>{{ c.person.text }}</span> <span><person-text :person="c.person"></person-text></span>
</li> </li>
</ul> </ul>
@ -57,12 +57,14 @@
import { mapState, mapGetters } from 'vuex'; import { mapState, mapGetters } from 'vuex';
import AddPersons from 'ChillPersonAssets/vuejs/_components/AddPersons.vue'; import AddPersons from 'ChillPersonAssets/vuejs/_components/AddPersons.vue';
import PersonRenderBox from 'ChillPersonAssets/vuejs/_components/Entity/PersonRenderBox.vue'; import PersonRenderBox from 'ChillPersonAssets/vuejs/_components/Entity/PersonRenderBox.vue';
import PersonText from 'ChillPersonAssets/vuejs/_components/Entity/PersonText.vue';
export default { export default {
name: 'Concerned', name: 'Concerned',
components: { components: {
AddPersons, AddPersons,
PersonRenderBox, PersonRenderBox,
PersonText,
}, },
computed: { computed: {
...mapState([ ...mapState([

View File

@ -61,6 +61,16 @@
<li v-if="hasHousehold"> <li v-if="hasHousehold">
<button @click="resetMode" class="btn btn-sm btn-misc">{{ $t('household_members_editor.household.reset_mode')}}</button> <button @click="resetMode" class="btn btn-sm btn-misc">{{ $t('household_members_editor.household.reset_mode')}}</button>
</li> </li>
<li v-if="!hasHousehold">
<add-persons
modalTitle="Chercher un ménage existant"
buttonTitle="Chercher un ménage existant"
v-bind:key="addPersons.key"
v-bind:options="addPersons.options"
@addNewPersons="pickHouseholdFound"
ref="pickHousehold"> <!-- to cast child method -->
</add-persons>
</li>
<li v-if="!hasHousehold"> <li v-if="!hasHousehold">
<button @click="setModeNew" class="btn btn-sm btn-create">{{ $t('household_members_editor.household.create_household') }}</button> <button @click="setModeNew" class="btn btn-sm btn-create">{{ $t('household_members_editor.household.create_household') }}</button>
</li> </li>
@ -77,16 +87,30 @@
import { mapGetters, mapState } from 'vuex'; import { mapGetters, mapState } from 'vuex';
import HouseholdRenderBox from 'ChillPersonAssets/vuejs/_components/Entity/HouseholdRenderBox.vue'; import HouseholdRenderBox from 'ChillPersonAssets/vuejs/_components/Entity/HouseholdRenderBox.vue';
import CurrentHousehold from './CurrentHousehold'; import CurrentHousehold from './CurrentHousehold';
import AddPersons from 'ChillPersonAssets/vuejs/_components/AddPersons';
export default { export default {
name: 'Household', name: 'Household',
components: { components: {
AddPersons,
CurrentHousehold, CurrentHousehold,
HouseholdRenderBox, HouseholdRenderBox,
}, },
emits: ['readyToGo'], emits: ['readyToGo'],
data() { data() {
return { return {
addPersons: {
key: 'household_find',
options: {
type: ['household'],
priority: null,
uniq: true,
button: {
size: 'btn-sm',
type: 'btn-search',
}
}
},
addAddress: { addAddress: {
key: 'household_new', key: 'household_new',
options: { options: {
@ -166,6 +190,13 @@ export default {
this.$store.dispatch('selectHousehold', h); this.$store.dispatch('selectHousehold', h);
this.$emit('readyToGo'); this.$emit('readyToGo');
}, },
pickHouseholdFound({selected, modal}) {
selected.forEach(function(item) {
this.selectHousehold(item.result);
}, this);
this.$refs.pickHousehold.resetSearch(); // to cast child method
modal.showModal = false;
},
removeHouseholdAddress() { removeHouseholdAddress() {
this.$store.commit('removeHouseholdAddress'); this.$store.commit('removeHouseholdAddress');
}, },

View File

@ -11,7 +11,8 @@
> >
<div class="pick-position item-row"> <div class="pick-position item-row">
<div class="person"> <div class="person">
<h3>{{ conc.person.text }}</h3> <!-- <h3>{{ conc.person.text }}</h3> -->
<h3><person-text :person="conc.person"></person-text></h3>
</div> </div>
<div class="holder"> <div class="holder">
<button <button
@ -53,6 +54,7 @@ import {mapGetters, mapState} from "vuex";
import CurrentHousehold from "./CurrentHousehold"; import CurrentHousehold from "./CurrentHousehold";
import PersonRenderBox from 'ChillPersonAssets/vuejs/_components/Entity/PersonRenderBox.vue'; import PersonRenderBox from 'ChillPersonAssets/vuejs/_components/Entity/PersonRenderBox.vue';
import PersonComment from './PersonComment'; import PersonComment from './PersonComment';
import PersonText from '../../_components/Entity/PersonText.vue';
export default { export default {
name: "Positioning", name: "Positioning",
@ -60,6 +62,7 @@ export default {
CurrentHousehold, CurrentHousehold,
PersonRenderBox, PersonRenderBox,
PersonComment, PersonComment,
PersonText
}, },
computed: { computed: {
...mapState([ ...mapState([

View File

@ -0,0 +1,6 @@
export const lightGreen = '#43b29d';
export const darkGreen = '#368e7e';
export const lightBrown = '#a2ac80';
export const darkBrown = '#929d69';
export const lightBlue = '#8d9dab';
export const darkBlue = '#718596';

View File

@ -2,6 +2,7 @@ import { createStore } from 'vuex'
import { getHouseholdByPerson, getCoursesByPerson, getRelationshipsByPerson } from './api' import { getHouseholdByPerson, getCoursesByPerson, getRelationshipsByPerson } from './api'
import { getHouseholdLabel, getHouseholdWidth, getRelationshipLabel, getRelationshipTitle, getRelationshipDirection, splitId, getGender, getAge } from './vis-network' import { getHouseholdLabel, getHouseholdWidth, getRelationshipLabel, getRelationshipTitle, getRelationshipDirection, splitId, getGender, getAge } from './vis-network'
import {visMessages} from "./i18n"; import {visMessages} from "./i18n";
import { darkBlue, darkBrown, darkGreen, lightBlue, lightBrown, lightGreen } from './colors';
const debug = process.env.NODE_ENV !== 'production' const debug = process.env.NODE_ENV !== 'production'
@ -172,8 +173,8 @@ const store = createStore({
id: 'relationship_' + splitId(link.id,'id') id: 'relationship_' + splitId(link.id,'id')
+ '-person_' + link.fromPerson.id + '-person_' + link.toPerson.id, + '-person_' + link.fromPerson.id + '-person_' + link.toPerson.id,
arrows: getRelationshipDirection(link), arrows: getRelationshipDirection(link),
color: 'lightblue', color: lightGreen,
font: { color: '#33839d' }, font: { color: darkGreen },
dashes: true, dashes: true,
label: getRelationshipLabel(link), label: getRelationshipLabel(link),
title: getRelationshipTitle(link), title: getRelationshipTitle(link),
@ -316,10 +317,10 @@ const store = createStore({
to: `${household.id}`, to: `${household.id}`,
id: `${household.id}-person_${m.person.id}`, id: `${household.id}-person_${m.person.id}`,
arrows: 'from', arrows: 'from',
color: 'pink', color: lightBrown,
font: { color: '#D04A60' }, font: { color: darkBrown },
dashes: (getHouseholdWidth(m) === 1)? [0,4] : false, //edge style: [dash, gap, dash, gap] dashes: (getHouseholdWidth(m) === 1)? [0,4] : false, //edge style: [dash, gap, dash, gap]
label: getHouseholdLabel(m), //label: getHouseholdLabel(m),
width: getHouseholdWidth(m), width: getHouseholdWidth(m),
}) })
if (!getters.isPersonLoaded(m.person.id)) { if (!getters.isPersonLoaded(m.person.id)) {
@ -375,8 +376,8 @@ const store = createStore({
to: `${course.id}`, to: `${course.id}`,
id: `accompanying_period_${splitId(course.id,'id')}-person_${p.person.id}`, id: `accompanying_period_${splitId(course.id,'id')}-person_${p.person.id}`,
arrows: 'from', arrows: 'from',
color: 'orange', color: lightBlue,
font: { color: 'darkorange' }, font: { color: darkBlue },
}) })
if (!getters.isPersonLoaded(p.person.id)) { if (!getters.isPersonLoaded(p.person.id)) {
dispatch('addMissingPerson', [p.person, course]) dispatch('addMissingPerson', [p.person, course])
@ -428,8 +429,8 @@ const store = createStore({
id: 'relationship_' + splitId(relationship.id,'id') id: 'relationship_' + splitId(relationship.id,'id')
+ '-person_' + relationship.fromPerson.id + '-person_' + relationship.toPerson.id, + '-person_' + relationship.fromPerson.id + '-person_' + relationship.toPerson.id,
arrows: getRelationshipDirection(relationship), arrows: getRelationshipDirection(relationship),
color: 'lightblue', color: lightGreen,
font: { color: '#33839d' }, font: { color: darkGreen },
dashes: true, dashes: true,
label: getRelationshipLabel(relationship), label: getRelationshipLabel(relationship),
title: getRelationshipTitle(relationship), title: getRelationshipTitle(relationship),

View File

@ -1,4 +1,5 @@
import { visMessages } from './i18n' import { darkGreen, lightBlue, lightBrown, lightGreen } from './colors';
import { visMessages } from './i18n';
/** /**
* Vis-network initial data/configuration script * Vis-network initial data/configuration script
@ -15,12 +16,12 @@ window.options = {
/* /*
*/ */
configure: { configure: {
enabled: true, enabled: false,
filter: 'physics', filter: 'physics',
showButton: true showButton: true
}, },
physics: { physics: {
enabled: true, enabled: false,
barnesHut: { barnesHut: {
theta: 0.5, theta: 0.5,
gravitationalConstant: -2000, gravitationalConstant: -2000,
@ -89,7 +90,7 @@ window.options = {
edges: { edges: {
font: { font: {
color: '#b0b0b0', color: '#b0b0b0',
size: 9, size: 14,
face: 'arial', face: 'arial',
background: 'none', background: 'none',
strokeWidth: 2, // px strokeWidth: 2, // px
@ -112,30 +113,30 @@ window.options = {
}, },
color: { color: {
border: '#b0b0b0', border: '#b0b0b0',
background: 'rgb(193,229,222)', background: lightGreen,
highlight: { highlight: {
border: '#89c9a9', border: '#216458',
background: 'rgb(156,213,203)' background: darkGreen,
}, },
hover: { hover: {
border: '#89c9a9', border: '#216458',
background: 'rgb(156,213,203)' background: darkGreen,
} }
}, },
opacity: 0.85, opacity: 0.9,
shadow:{ shadow:{
enabled: true, enabled: true,
color: 'rgba(0,0,0,0.5)', color: 'rgba(0,0,0,0.5)',
size:10, size:10,
x:5, x:5,
y:5 y:5,
}, },
}, },
household: { household: {
color: 'pink' color: lightBrown,
}, },
accompanying_period: { accompanying_period: {
color: 'orange', color: lightBlue,
}, },
} }
} }

View File

@ -181,7 +181,7 @@ export default {
}, },
hasPriorSuggestion() { hasPriorSuggestion() {
return this.search.priorSuggestion.key ? true : false; return this.search.priorSuggestion.key ? true : false;
} },
}, },
methods: { methods: {
openModal() { openModal() {

View File

@ -25,6 +25,11 @@
v-if="item.result.type === 'user'" v-if="item.result.type === 'user'"
v-bind:item="item"> v-bind:item="item">
</suggestion-user> </suggestion-user>
<suggestion-household
v-if="item.result.type === 'household'"
v-bind:item="item">
</suggestion-household>
</label> </label>
</div> </div>
@ -34,6 +39,7 @@
import SuggestionPerson from './TypePerson'; import SuggestionPerson from './TypePerson';
import SuggestionThirdParty from './TypeThirdParty'; import SuggestionThirdParty from './TypeThirdParty';
import SuggestionUser from './TypeUser'; import SuggestionUser from './TypeUser';
import SuggestionHousehold from './TypeHousehold';
export default { export default {
name: 'PersonSuggestion', name: 'PersonSuggestion',
@ -41,6 +47,7 @@ export default {
SuggestionPerson, SuggestionPerson,
SuggestionThirdParty, SuggestionThirdParty,
SuggestionUser, SuggestionUser,
SuggestionHousehold,
}, },
props: [ props: [
'item', 'item',
@ -70,7 +77,7 @@ export default {
}; };
</script> </script>
<style lang="scss"> <style lang="scss" scoped>
div.results { div.results {
div.list-item { div.list-item {
padding: 0.4em 0.8em; padding: 0.4em 0.8em;
@ -83,11 +90,11 @@ export default {
label { label {
display: inline-flex; display: inline-flex;
width: 100%; width: 100%;
div.container { div.container:not(.household) {
& > input { & > input {
margin-right: 0.8em; margin-right: 0.8em;
} }
span:not(.name) { > span:not(.name) {
margin-left: 0.5em; margin-left: 0.5em;
opacity: 0.5; opacity: 0.5;
font-size: 90%; font-size: 90%;

View File

@ -0,0 +1,27 @@
<template>
<div class="container household">
<household-render-box :household="item.result" :isAddressMultiline="false"></household-render-box>
</div>
<div class="right_actions">
<badge-entity
:entity="item.result"
:options="{ displayLong: true }">
</badge-entity>
</div>
</template>
<script>
import BadgeEntity from 'ChillMainAssets/vuejs/_components/BadgeEntity.vue';
import HouseholdRenderBox from 'ChillPersonAssets/vuejs/_components/Entity/HouseholdRenderBox.vue';
export default {
name: 'SuggestionHousehold',
components: {
BadgeEntity,
HouseholdRenderBox,
},
props: ['item'],
}
</script>

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="container"> <div class="container">
<span class="name"> <span class="name">
{{ item.result.text }} <person-text :person="item.result"></person-text>
</span> </span>
<span class="birthday" v-if="hasBirthdate"> <span class="birthday" v-if="hasBirthdate">
{{ $d(item.result.birthdate.datetime, 'short') }} {{ $d(item.result.birthdate.datetime, 'short') }}
@ -28,12 +28,14 @@
<script> <script>
import OnTheFly from 'ChillMainAssets/vuejs/OnTheFly/components/OnTheFly.vue'; import OnTheFly from 'ChillMainAssets/vuejs/OnTheFly/components/OnTheFly.vue';
import BadgeEntity from 'ChillMainAssets/vuejs/_components/BadgeEntity.vue'; import BadgeEntity from 'ChillMainAssets/vuejs/_components/BadgeEntity.vue';
import PersonText from 'ChillPersonAssets/vuejs/_components/Entity/PersonText.vue';
export default { export default {
name: 'SuggestionPerson', name: 'SuggestionPerson',
components: { components: {
OnTheFly, OnTheFly,
BadgeEntity BadgeEntity,
PersonText,
}, },
props: ['item'], props: ['item'],
computed: { computed: {

View File

@ -2,7 +2,7 @@
<div class="container tpartycontainer"> <div class="container tpartycontainer">
<div class="tparty-identification"> <div class="tparty-identification">
<span class="name"> <span class="name">
{{ item.result.text }} {{ item.result.text }}&nbsp;
</span> </span>
<span class="location"> <span class="location">
<template v-if="hasAddress"> <template v-if="hasAddress">

View File

@ -1,5 +1,5 @@
<template> <template>
<div v-if="render === 'bloc'" class="item-bloc"> <div v-if="render === 'bloc'" class="item-bloc">
<section class="chill-entity entity-person"> <section class="chill-entity entity-person">
<div class="item-row entity-bloc"> <div class="item-row entity-bloc">
@ -9,6 +9,7 @@
<div :class="'denomination h' + options.hLevel"> <div :class="'denomination h' + options.hLevel">
<a v-if="options.addLink === true" :href="getUrl"> <a v-if="options.addLink === true" :href="getUrl">
<!-- use person-text here to avoid code duplication ? TODO -->
<span class="firstname">{{ person.firstName }}</span> <span class="firstname">{{ person.firstName }}</span>
<span class="lastname">{{ person.lastName }}</span> <span class="lastname">{{ person.lastName }}</span>
<span v-if="person.altNames && options.addAltNames == true" class="altnames"> <span v-if="person.altNames && options.addAltNames == true" class="altnames">
@ -16,6 +17,7 @@
</span> </span>
</a> </a>
<!-- use person-text here to avoid code duplication ? TODO -->
<span class="firstname">{{ person.firstName }}</span> <span class="firstname">{{ person.firstName }}</span>
<span class="lastname">{{ person.lastName }}</span> <span class="lastname">{{ person.lastName }}</span>
<span v-if="person.deathdate" class="deathdate"> ()</span> <span v-if="person.deathdate" class="deathdate"> ()</span>
@ -47,7 +49,7 @@
{{ $t('renderbox.deathdate') + ' ' + deathdate }} {{ $t('renderbox.deathdate') + ' ' + deathdate }}
</time> </time>
<span v-if="options.addAge && person.birthdate" class="age">{{ getAge }} {{ $t('renderbox.years_old')}}</span> <span v-if="options.addAge && person.birthdate" class="age">{{ $tc('renderbox.years_old', person.age) }}</span>
</p> </p>
</div> </div>
</div> </div>
@ -59,7 +61,6 @@
<slot name="record-actions"></slot> <slot name="record-actions"></slot>
</div> </div>
<ul class="list-content fa-ul"> <ul class="list-content fa-ul">
<li v-if="person.current_household_id"> <li v-if="person.current_household_id">
<i class="fa fa-li fa-map-marker"></i> <i class="fa fa-li fa-map-marker"></i>
<address-render-box v-if="person.current_household_address" <address-render-box v-if="person.current_household_address"
@ -118,27 +119,26 @@
</div> </div>
</section> </section>
</div> </div>
<span v-if="render === 'badge'" class="chill-entity entity-person badge-person"> <span v-if="render === 'badge'" class="chill-entity entity-person badge-person">
<a v-if="options.addLink === true" :href="getUrl"> <a v-if="options.addLink === true" :href="getUrl">
<span v-if="options.isHolder" class="fa-stack fa-holder" :title="$t('renderbox.holder')"> <span v-if="options.isHolder" class="fa-stack fa-holder" :title="$t('renderbox.holder')">
<i class="fa fa-circle fa-stack-1x text-success"></i> <i class="fa fa-circle fa-stack-1x text-success"></i>
<i class="fa fa-stack-1x">T</i> <i class="fa fa-stack-1x">T</i>
</span> </span>
{{ person.text }}
<span v-if="person.deathdate" class="deathdate"> ()</span> <person-text :person="person"></person-text>
</a> </a>
<span v-else> <span v-else>
<span v-if="options.isHolder" class="fa-stack fa-holder" :title="$t('renderbox.holder')"> <span v-if="options.isHolder" class="fa-stack fa-holder" :title="$t('renderbox.holder')">
<i class="fa fa-circle fa-stack-1x text-success"></i> <i class="fa fa-circle fa-stack-1x text-success"></i>
<i class="fa fa-stack-1x">T</i> <i class="fa fa-stack-1x">T</i>
</span> </span>
{{ person.text }} <person-text :person="person"></person-text>
<span v-if="person.deathdate" class="deathdate"> ()</span>
</span> </span>
<slot name="post-badge"></slot> <slot name="post-badge"></slot>
</span> </span>
</template> </template>
@ -147,13 +147,15 @@ import {dateToISO} from 'ChillMainAssets/chill/js/date.js';
import AddressRenderBox from 'ChillMainAssets/vuejs/_components/Entity/AddressRenderBox.vue'; import AddressRenderBox from 'ChillMainAssets/vuejs/_components/Entity/AddressRenderBox.vue';
import Confidential from 'ChillMainAssets/vuejs/_components/Confidential.vue'; import Confidential from 'ChillMainAssets/vuejs/_components/Confidential.vue';
import BadgeEntity from 'ChillMainAssets/vuejs/_components/BadgeEntity.vue'; import BadgeEntity from 'ChillMainAssets/vuejs/_components/BadgeEntity.vue';
import PersonText from 'ChillPersonAssets/vuejs/_components/Entity/PersonText.vue';
export default { export default {
name: "PersonRenderBox", name: "PersonRenderBox",
components: { components: {
AddressRenderBox, AddressRenderBox,
Confidential, Confidential,
BadgeEntity BadgeEntity,
PersonText
}, },
props: ['person', 'options', 'render', 'returnPath'], props: ['person', 'options', 'render', 'returnPath'],
computed: { computed: {
@ -200,24 +202,6 @@ export default {
getUrl: function() { getUrl: function() {
return `/fr/person/${this.person.id}/general`; return `/fr/person/${this.person.id}/general`;
}, },
getAge: function() {
// TODO only one abstract function
if(this.person.birthdate && !this.person.deathdate){
const birthday = new Date(this.person.birthdate.datetime)
const now = new Date()
return (now.getFullYear() - birthday.getFullYear())
} else if(this.person.birthdate && this.person.deathdate){
const birthday = new Date(this.person.birthdate.datetime)
const deathdate = new Date(this.person.deathdate.datetime)
return (deathdate.getFullYear() - birthday.getFullYear())
} else if(!this.person.birthdate && this.person.deathdate.datetime) {
// todo: change this
return "Age unknown"
} else {
// todo: change this
return "Age unknown"
}
},
getCurrentHouseholdUrl: function() { getCurrentHouseholdUrl: function() {
let returnPath = this.returnPath ? `?returnPath=${this.returnPath}` : ``; let returnPath = this.returnPath ? `?returnPath=${this.returnPath}` : ``;
return `/fr/person/household/${this.person.current_household_id}/summary${returnPath}` return `/fr/person/household/${this.person.current_household_id}/summary${returnPath}`

View File

@ -0,0 +1,50 @@
<template>
<span v-if="isCut">{{ cutText }}</span>
<span v-else class="person-text">
<span class="firstname">{{ person.firstName }}</span>
<span class="lastname">{{ person.lastName }}</span>
<span v-if="person.altNames && person.altNames.length > 0" class="altnames">
<span :class="'altname altname-' + altNameKey"> ({{ altNameLabel }})</span>
</span>
<span class="age" v-if="this.addAge && person.birthdate !== null && person.deathdate === null">{{ $tc('renderbox.years_old', person.age) }}</span>
<span v-else-if="this.addAge && person.deathdate !== null">&nbsp;()</span>
</span>
</template>
<script>
export default {
name: "PersonText",
props: {
person: {
required: true,
},
isCut: {
type: Boolean,
required: false,
default: false
},
addAge: {
type: Boolean,
required: false,
default: true,
}
},
computed: {
altNameLabel: function() {
for(let i = 0; i < this.person.altNames.length; i++){
return this.person.altNames[i].label
}
},
altNameKey: function() {
for(let i = 0; i < this.person.altNames.length; i++){
return this.person.altNames[i].key
}
},
cutText: function() {
let more = (this.person.text.length > 15) ?'…' : '';
return this.person.text.slice(0,15) + more;
}
}
}
</script>

View File

@ -151,14 +151,14 @@
{% if accompanyingCourse.requestorPerson is not null %} {% if accompanyingCourse.requestorPerson is not null %}
<h4 class="item-key">{{ 'Requestor'|trans }}</h4> <h4 class="item-key">{{ 'Requestor'|trans }}</h4>
{% if accompanyingCourse.requestorAnonymous %} {% if accompanyingCourse.requestorAnonymous %}
<div class="confidential"><p class="blur">{{ _self.insert_onthefly('person', accompanyingCourse.requestorPerson) }}</p></div> <div class="confidential"><p>{{ _self.insert_onthefly('person', accompanyingCourse.requestorPerson) }}</p></div>
{% else %} {% else %}
{{ _self.insert_onthefly('person', accompanyingCourse.requestorPerson) }} {{ _self.insert_onthefly('person', accompanyingCourse.requestorPerson) }}
{% endif %} {% endif %}
{% elseif accompanyingCourse.requestorThirdParty is not null %} {% elseif accompanyingCourse.requestorThirdParty is not null %}
<h4 class="item-key">{{ 'Requestor'|trans }}</h4> <h4 class="item-key">{{ 'Requestor'|trans }}</h4>
{% if accompanyingCourse.requestorAnonymous %} {% if accompanyingCourse.requestorAnonymous %}
<div class="confidential"><p class="blur">{{ _self.insert_onthefly('thirdparty', accompanyingCourse.requestorThirdParty) }}</p></div> <div class="confidential"><p>{{ _self.insert_onthefly('thirdparty', accompanyingCourse.requestorThirdParty) }}</p></div>
{% else %} {% else %}
{{ _self.insert_onthefly('thirdparty', accompanyingCourse.requestorThirdParty) }} {{ _self.insert_onthefly('thirdparty', accompanyingCourse.requestorThirdParty) }}
{% endif %} {% endif %}

View File

@ -31,7 +31,7 @@
<li class="associated-persons"> <li class="associated-persons">
<span class="item-key">{{ 'Participants'|trans ~ ' : ' }}</span> <span class="item-key">{{ 'Participants'|trans ~ ' : ' }}</span>
{% for p in w.persons %} {% for p in w.persons %}
<span class="badge-person">{{ p|chill_entity_render_box }}</span> <span class="badge-person">{{ p|chill_entity_render_box({'addAgeBadge': true}) }}</span>
{% endfor %} {% endfor %}
</li> </li>
</ul> </ul>

View File

@ -0,0 +1,30 @@
{% extends "@ChillMain/layout.html.twig" %}
{% set activeRouteKey = 'chill_person_accompanying_period_user_list' %}
{% block title %}{{ 'My accompanying periods'|trans }}{% endblock title %}
{% macro recordAction(period) %}
<li>
<a href="{{ path('chill_person_accompanying_course_index', { 'accompanying_period_id': period.id }) }}"
class="btn btn-show" title="{{ 'See accompanying period'|trans }}"></a>
</li>
{% endmacro %}
{% block content %}
<div class="col-md-10">
<h1>{{ 'My accompanying periods'|trans }}</h1>
<div class="flex-table accompanyingcourse-list">
{% for period in accompanyingPeriods %}
{% include '@ChillPerson/AccompanyingPeriod/_list_item.html.twig' with {'period': period, 'recordAction': _self.recordAction(period)} %}
{% endfor %}
</div>
{{ chill_pagination(pagination) }}
</div>
{% endblock %}

View File

@ -11,6 +11,7 @@
* addCenter bool * addCenter bool
* hLevel integer * hLevel integer
* addDeath bool * addDeath bool
* addAgeBadge bool
* address_multiline bool * address_multiline bool
* customButtons [ * customButtons [
'before' Twig\Markup, (injected with macro) 'before' Twig\Markup, (injected with macro)
@ -40,6 +41,11 @@
{%- endfor -%} {%- endfor -%}
</span> </span>
{%- endif -%} {%- endif -%}
{%- if options['addAgeBadge'] -%}
{% if person.age is not null and person.deathDate is null %}
<span>({{- 'years_old'|trans({ 'age': person.age }) -}})</span>
{% endif %}
{% endif %}
{% endmacro raw %} {% endmacro raw %}
{% macro label(person, options) %} {% macro label(person, options) %}

View File

@ -14,6 +14,7 @@
'render': 'label', 'render': 'label',
'addLink': true, 'addLink': true,
'addInfo': true, 'addInfo': true,
'addAgeBadge': true,
'customArea': { 'customArea': {
'afterLabel': _self.addHolder(member.holder) 'afterLabel': _self.addHolder(member.holder)
} }

View File

@ -78,16 +78,11 @@
{% set app = person.findParticipationForPeriod(acp) %} {% set app = person.findParticipationForPeriod(acp) %}
<div class="item-row separator"> <div class="item-row separator">
<div class="wrap-list periods-list"> <div class="wrap-list periods-list">
<div class="wl-row"> <div class="wl-row">
<div class="wl-col title"> <div class="wl-col title">
<h3 class="courseid mb-2"> <h3 class="courseid mb-2">
<a href="{{ path('chill_person_accompanying_course_index', { 'accompanying_period_id': acp.id }) }}"
title="{{ 'See accompanying period'|trans }}" class="btn btn-outline-primary">
<i class="fa fa-random fa-fw"></i> <i class="fa fa-random fa-fw"></i>
{{ 'File number'|trans }} {{ acp.id }} {{ 'File number'|trans }} {{ acp.id }}
</a>
</h3> </h3>
</div> </div>
<div class="wl-col list"> <div class="wl-col list">
@ -104,6 +99,11 @@
{% endif %} {% endif %}
</div> </div>
<div class="ms-auto"> <div class="ms-auto">
{% if acp.requestorPerson == person %}
<span class="as-requestor badge bg-info" title="{{ 'Requestor'|trans|e('html_attr') }}">
{{ 'Requestor'|trans({'gender': person.gender}) }}
</span>
{% endif %}
{% if acp.emergency %} {% if acp.emergency %}
<span class="badge rounded-pill bg-danger">{{- 'Emergency'|trans|upper -}}</span> <span class="badge rounded-pill bg-danger">{{- 'Emergency'|trans|upper -}}</span>
{% endif %} {% endif %}
@ -115,6 +115,10 @@
{% if acp.step == 'DRAFT' %} {% if acp.step == 'DRAFT' %}
<span class="badge bg-secondary" style="font-size: 85%;" title="{{ 'course.draft'|trans }}">{{ 'course.draft'|trans }}</span> <span class="badge bg-secondary" style="font-size: 85%;" title="{{ 'course.draft'|trans }}">{{ 'course.draft'|trans }}</span>
{% endif %} {% endif %}
{% if acp.step == 'CLOSED' %}
<span class="badge bg-secondary" style="font-size: 85%;" title="{{ 'course.closed'|trans }}">{{ 'course.closed'|trans }}</span>
{% endif %}
</div> </div>
</div> </div>
</div> </div>
@ -145,23 +149,6 @@
</div> </div>
{% endif %} {% endif %}
{# ????
{% if acp.requestorPerson == person %}
<div class="wl-row">
<div class="wl-col title">
<h3>
</h3>
</div>
<div class="wl-col list">
<span class="as-requestor badge bg-info" title="{{ 'Requestor'|trans|e('html_attr') }}">
{{ 'Requestor'|trans({'gender': person.gender}) }}
</span>
</div>
</div>
{% endif %}
#}
{% if acp.currentParticipations|length > 1 %} {% if acp.currentParticipations|length > 1 %}
<div class="wl-row"> <div class="wl-row">
<div class="wl-col title"> <div class="wl-col title">
@ -191,6 +178,15 @@
</div> </div>
{% endif %} {% endif %}
<ul class="record_actions record_actions_column">
<li>
<a href="{{ path('chill_person_accompanying_course_index', { 'accompanying_period_id': acp.id }) }}"
class="btn btn-sm btn-outline-primary" title="{{ 'See accompanying period'|trans }}">
<i class="fa fa-random fa-fw"></i>
</a>
</li>
</ul>
{% if (acp.requestorPerson is not null and acp.requestorPerson.id != person.id) or acp.requestorThirdParty is not null %} {% if (acp.requestorPerson is not null and acp.requestorPerson.id != person.id) or acp.requestorThirdParty is not null %}
<div class="wl-row"> <div class="wl-row">
<div class="wl-col title"> <div class="wl-col title">

View File

@ -84,6 +84,8 @@
<p class="chill-no-data-statement">{{ 'There are no available resources'|trans }}</p> <p class="chill-no-data-statement">{{ 'There are no available resources'|trans }}</p>
{% endif %} {% endif %}
<h1 style="margin-bottom: 2rem;">{{ 'Add a person resource'|trans }}</h1>
{% include "@ChillPerson/PersonResource/create.html.twig" %} {% include "@ChillPerson/PersonResource/create.html.twig" %}
{% endblock %} {% endblock %}

View File

@ -0,0 +1,37 @@
{{ form_start(form) }}
{{ form_row(form.startDate) }}
{{ form_row(form.endDate) }}
{% if form.hostPerson is defined %}
{{ form_row(form.hostPerson) }}
{% endif %}
{% if form.hostThirdParty is defined %}
{{ form_row(form.hostThirdParty) }}
{% endif %}
{% if form.address is defined %}
{{ form_row(form.address) }}
{% block js %}
{{ encore_entry_script_tags('mod_input_address') }}
{% endblock %}
{% block css %}
{{ encore_entry_link_tags('mod_input_address') }}
{% endblock %}
{% endif %}
{{ form_row(form.comment) }}
<ul class="record_actions sticky-form-buttons">
<li>
<button class="btn btn-update" type="submit">{{ 'Save'|trans }}</button>
</li>
</ul>
{{ form_end(form) }}

View File

@ -0,0 +1,58 @@
{% extends "@ChillPerson/Person/layout.html.twig" %}
{% set activeRouteKey = '' %}
{% block title %}{{ 'Delete residential address'|trans }}{% endblock %}
{% block personcontent %}
<div class="address-new">
<h1>{{ block('title') }}</h1>
{% set a = residentialAddress %}
<ul class="list-content fa-ul">
{% if a.hostPerson is not null %}
<li>
<i class="fa fa-li fa-home"></i>
<span class="item-key">{{ "Address of"|trans}} </span>
<span class="chill-entity entity-person badge-person">{{ a.hostPerson|chill_entity_render_box }}</span>
</li>
<li>
{% set address_date = date(a.startDate|date("m/d/Y")) %}
{% if a.hostPerson.getCurrentHouseholdAddress(a.endDate) is not null %}
<i class="fa fa-li fa-map-marker"></i>
{{ a.hostPerson.getCurrentHouseholdAddress(a.endDate)|chill_entity_render_box }}
{% endif %}
</li>
{% elseif a.hostThirdParty is not null %}
<li>
<i class="fa fa-li fa-home"></i>
<span class="item-key">{{ "Address of"|trans}}</span>
<span class="chill-entity entity-person badge-person">{{ a.hostThirdParty|chill_entity_render_box }}</span>
</li>
<li>
{% if a.hostThirdParty.address is not null %}
<i class="fa fa-li fa-map-marker"></i>
{{ a.hostThirdParty.address|chill_entity_render_box }}
{% endif %}
</li>
{% else %}
<li>
{% if a.address is not null %}
<i class="fa fa-li fa-map-marker"></i>
{{ a.address|chill_entity_render_box }}
{% endif %}
{% endif %}
</li>
</ul>
{{ include('@ChillMain/Util/confirmation_template.html.twig',
{
'title' : 'Delete residential address ?'|trans,
'confirm_question' : 'Are you sure you want to remove this residential address for %name% ?'|trans({'%name%': person|chill_entity_render_string }),
'cancel_route' : 'chill_person_residential_address_list',
'cancel_parameters' : {'id' : person.Id},
'form' : delete_form
} ) }}
</div>
{% endblock %}

View File

@ -0,0 +1,51 @@
{% extends "@ChillPerson/Person/layout.html.twig" %}
{% set activeRouteKey = '' %}
{% block title 'Edit a residential address'|trans %}
{% block personcontent %}
<div class="address-edit">
{% block content %}
<h1>{{ block('title') }}</h1>
{{ form_start(form) }}
{{ form_row(form.startDate) }}
{{ form_row(form.endDate) }}
{% if residentialAddress.address is not null %}
{% if form.address is defined %}
{{ form_row(form.address) }}
{% block js %}
{{ encore_entry_script_tags('mod_input_address') }}
{% endblock %}
{% block css %}
{{ encore_entry_link_tags('mod_input_address') }}
{% endblock %}
{% endif %}
{% endif %}
{{ form_row(form.comment) }}
<ul class="record_actions sticky-form-buttons">
<li class="cancel">
<a href="{{ chill_path_add_return_path('chill_person_residential_address_list', {'id': person.id}) }}" class="btn btn-cancel">
{{ 'Cancel'|trans|chill_return_path_label }}
</a>
</li>
<li>
<button class="btn btn-update" type="submit">{{ 'Save'|trans }}</button>
</li>
</ul>
{{ form_end(form) }}
{% endblock %}
</div>
{% endblock %}

View File

@ -0,0 +1,116 @@
{% extends "@ChillPerson/Person/layout.html.twig" %}
{% set activeRouteKey = '' %}
{% block title %}{{ 'Residential addresses history for %name%'|trans({ '%name%': person.firstName ~ ' ' ~ person.lastName } ) }}{% endblock %}
{% block personcontent %}
<div class="person-address">
<h1>{{ 'Residential addresses history'|trans }}</h1>
{% if is_granted('CHILL_PERSON_SEE', person) %}
{% if addresses|length == 0 %}
<span class="chill-no-data-statement">{{ 'No address given'|trans }}</span>
{% else %}
<div class="flex-table">
{% for a in addresses %}
{% if a.address is not null %}
{% set kind = 'address' %}
{% else %}
{% set kind = null %}
{% endif %}
<div class="item-bloc">
<div class="item-row">
<div class="item-col" style="width: 33%;">
<ul class="list-unstyled h3">
{% if a.endDate is not null %}
<li><span class="item-key">{{'Since'|trans}} : </span>{{ a.startDate|format_date('long') }}</li>
{% endif %}
<li><span class="item-key">{{'Until'|trans}} : </span><b>{{ a.endDate|format_date('long') }}</b></li>
</ul>
</div>
<div class="item-col flex-column justify-content-start">
<div class="float-button top">
<div class="box">
<div class="action">
{% if is_granted('CHILL_PERSON_UPDATE', person) %}
<a href="{{ path('chill_person_residential_address_edit', { 'id' : a.id, 'kind' : kind } ) }}" class="btn btn-update" title="{{ 'Update'|trans|e('html_attr') }}"></a>
<a href="{{ path('chill_person_residential_address_delete', { 'id' : a.id, 'kind' : kind } ) }}" class="btn btn-delete" title="{{ 'Delete'|trans|e('html_attr') }}"></a>
{% endif %}
</div>
<ul class="list-content fa-ul">
{% if a.hostPerson is not null %}
<li>
<i class="fa fa-li fa-home"></i>
<span class="item-key">{{ "Address of"|trans}} </span>
<span class="chill-entity entity-person badge-person">{{ a.hostPerson|chill_entity_render_box }}</span>
</li>
<li>
{% set address_date = date(a.startDate|date("m/d/Y")) %}
{% if a.hostPerson.getCurrentHouseholdAddress(a.endDate) is not null %}
<i class="fa fa-li fa-map-marker"></i>
{{ a.hostPerson.getCurrentHouseholdAddress(a.endDate)|chill_entity_render_box }}
{% endif %}
</li>
{% elseif a.hostThirdParty is not null %}
<li>
<i class="fa fa-li fa-home"></i>
<span class="item-key">{{ "Address of"|trans}}</span>
<span class="chill-entity entity-person badge-person">{{ a.hostThirdParty|chill_entity_render_box }}</span>
</li>
<li>
{% if a.hostThirdParty.address is not null %}
<i class="fa fa-li fa-map-marker"></i>
{{ a.hostThirdParty.address|chill_entity_render_box }}
{% endif %}
</li>
{% else %}
<li>
{% if a.address is not null %}
<i class="fa fa-li fa-map-marker"></i>
{{ a.address|chill_entity_render_box }}
{% endif %}
{% endif %}
</li>
</ul>
<div class="item-row">
{% if not a.comment.isEmpty %}
{{ a.comment|chill_entity_render_box }}
{% endif %}
</div>
</div>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
{% endif %}
{% endif %}
<ul class="record_actions sticky-form-buttons">
<li class="cancel">
<a href="{{ path('chill_person_view', { 'person_id' : person.id } ) }}" class="btn btn-cancel">
{{ 'Back to the person details'|trans }}
</a>
</li>
{% if is_granted('CHILL_PERSON_UPDATE', person) %}
<li>
<a class="btn btn-create"
href="{{ path('chill_person_residential_address_new', { 'id' : person.id } ) }}">
{{ 'Add a residential address'|trans }}
</a>
</li>
{% endif %}
</ul>
</div>
{% endblock %}

View File

@ -0,0 +1,29 @@
{% extends "@ChillPerson/Person/layout.html.twig" %}
{% set activeRouteKey = '' %}
{% block title %}{{ 'New residential address'|trans }}{% endblock %}
{% block personcontent %}
<div class="address-new">
{% block content %}
<h1>{{ block('title') }}</h1>
{# TODO #}
{% block form %}
{% include '@ChillPerson/ResidentialAddress/_form.html.twig' %}
{% endblock %}
{% endblock %}
</div>
{% endblock %}
{% block js %}
{{ encore_entry_script_tags('mod_pickentity_type') }}
{% endblock %}
{% block css %}
{{ encore_entry_link_tags('mod_pickentity_type') }}
{% endblock %}

View File

@ -0,0 +1,49 @@
{% extends "@ChillMain/layout.html.twig" %}
{% block title 'Which kind of residential address would you create ?'|trans %}
{% block content %}
<div class="col-10 centered">
<h1>{{ block('title') }}</h1>
<div class="container" style="margin-top: 2rem;">
<div class="row">
<div class="col-md-4 mb-4">
<a
href="{{ chill_path_forward_return_path('chill_person_residential_address_new', {'id': person.id, 'kind': 'person'}) }}"
class="btn btn-outline-chill-green-dark">
{{ 'The address of another person'|trans }}
</a>
</div>
<div class="col-md-8">
<p>{{ 'residential_address_person_explanation'|trans }}</p>
</div>
</div>
<div class="row">
<div class="col-md-4 mb-4">
<a
href="{{ chill_path_forward_return_path('chill_person_residential_address_new', {'id': person.id, 'kind': 'thirdparty'}) }}"
class="btn btn-outline-chill-green-dark">
{{ 'The address of a third party'|trans }}
</a>
</div>
<div class="col-md-8">
<p>{{ 'residential_address_third_party_explanation'|trans }}</p>
</div>
</div>
<div class="row">
<div class="col-md-4 mb-4">
<a
href="{{ chill_path_forward_return_path('chill_person_residential_address_new', {'id': person.id, 'kind': 'address'}) }}"
class="btn btn-outline-chill-green-dark">
{{ 'A new address'|trans }}
</a>
</div>
<div class="col-md-8">
<p>{{ 'residential_address_new_address_explanation'|trans }}</p>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@ -0,0 +1,109 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\PersonBundle\Search;
use Chill\MainBundle\Search\SearchApiInterface;
use Chill\MainBundle\Search\SearchApiQuery;
use Chill\MainBundle\Search\Utils\ExtractDateFromPattern;
use Chill\MainBundle\Search\Utils\ExtractPhonenumberFromPattern;
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
use Chill\PersonBundle\Repository\Household\HouseholdRepository;
use Chill\PersonBundle\Repository\PersonACLAwareRepositoryInterface;
use Symfony\Component\Security\Core\Security;
use function array_map;
use function count;
use function in_array;
class SearchHouseholdApiProvider implements SearchApiInterface
{
private AuthorizationHelperInterface $authorizationHelper;
private ExtractDateFromPattern $extractDateFromPattern;
private ExtractPhonenumberFromPattern $extractPhonenumberFromPattern;
private HouseholdRepository $householdRepository;
private PersonACLAwareRepositoryInterface $personACLAwareRepository;
private Security $security;
public function __construct(
HouseholdRepository $householdRepository,
PersonACLAwareRepositoryInterface $personACLAwareRepository,
Security $security,
AuthorizationHelperInterface $authorizationHelper,
ExtractDateFromPattern $extractDateFromPattern,
ExtractPhonenumberFromPattern $extractPhonenumberFromPattern
) {
$this->householdRepository = $householdRepository;
$this->personACLAwareRepository = $personACLAwareRepository;
$this->security = $security;
$this->authorizationHelper = $authorizationHelper;
$this->extractDateFromPattern = $extractDateFromPattern;
$this->extractPhonenumberFromPattern = $extractPhonenumberFromPattern;
}
public function getResult(string $key, array $metadata, float $pertinence)
{
return $this->householdRepository->find($metadata['id']);
}
public function prepare(array $metadatas): void
{
$ids = array_map(static fn ($m) => $m['id'], $metadatas);
$this->householdRepository->findBy(['id' => $ids]);
}
public function provideQuery(string $pattern, array $parameters): SearchApiQuery
{
$datesResult = $this->extractDateFromPattern->extractDates($pattern);
$phoneResult = $this->extractPhonenumberFromPattern->extractPhonenumber($datesResult->getFilteredSubject());
$filtered = $phoneResult->getFilteredSubject();
$query = $this->personACLAwareRepository->buildAuthorizedQuery(
$filtered,
null,
null,
count($datesResult->getFound()) > 0 ? $datesResult->getFound()[0] : null,
null,
null,
null,
null,
count($phoneResult->getFound()) > 0 ? $phoneResult->getFound()[0] : null
);
$query
->setDistinct(true, 'household_id')
->setFromClause(
'view_chill_person_household_address AS vcpha ' .
'JOIN chill_person_person AS person ON vcpha.person_id = person.id'
)
->setSelectKey('household')
->andWhereClause('vcpha.validTo IS NULL', [])
->setSelectJsonbMetadata("jsonb_build_object('id', vcpha.household_id)");
return $query;
}
public function supportsResult(string $key, array $metadatas): bool
{
return 'household' === $key;
}
public function supportsTypes(string $pattern, array $types, array $parameters): bool
{
return in_array('household', $types, true);
}
}

View File

@ -29,6 +29,7 @@ use function count;
class AccompanyingPeriodResourceNormalizer implements DenormalizerAwareInterface, DenormalizerInterface class AccompanyingPeriodResourceNormalizer implements DenormalizerAwareInterface, DenormalizerInterface
{ {
use DenormalizerAwareTrait; use DenormalizerAwareTrait;
use ObjectToPopulateTrait; use ObjectToPopulateTrait;
private ResourceRepository $repository; private ResourceRepository $repository;

View File

@ -33,6 +33,7 @@ use function is_array;
class AccompanyingPeriodWorkDenormalizer implements ContextAwareDenormalizerInterface, DenormalizerAwareInterface class AccompanyingPeriodWorkDenormalizer implements ContextAwareDenormalizerInterface, DenormalizerAwareInterface
{ {
use DenormalizerAwareTrait; use DenormalizerAwareTrait;
use ObjectToPopulateTrait; use ObjectToPopulateTrait;
public const GROUP_CREATE = 'accompanying_period_work:create'; public const GROUP_CREATE = 'accompanying_period_work:create';

View File

@ -40,7 +40,9 @@ class PersonJsonNormalizer implements
NormalizerInterface NormalizerInterface
{ {
use DenormalizerAwareTrait; use DenormalizerAwareTrait;
use NormalizerAwareTrait; use NormalizerAwareTrait;
use ObjectToPopulateTrait; use ObjectToPopulateTrait;
private CenterResolverManagerInterface $centerResolverManager; private CenterResolverManagerInterface $centerResolverManager;
@ -177,11 +179,13 @@ class PersonJsonNormalizer implements
return [ return [
'type' => 'person', 'type' => 'person',
'id' => $person->getId(), 'id' => $person->getId(),
'text' => $this->render->renderString($person), 'text' => $this->render->renderString($person, ['addAge' => false]),
'textAge' => $this->render->renderString($person, ['addAge' => true]),
'firstName' => $person->getFirstName(), 'firstName' => $person->getFirstName(),
'lastName' => $person->getLastName(), 'lastName' => $person->getLastName(),
'birthdate' => $this->normalizer->normalize($person->getBirthdate(), $format, $context), 'birthdate' => $this->normalizer->normalize($person->getBirthdate(), $format, $context),
'deathdate' => $this->normalizer->normalize($person->getDeathdate(), $format, $context), 'deathdate' => $this->normalizer->normalize($person->getDeathdate(), $format, $context),
'age' => $this->normalizer->normalize($person->getAge(), $format, $context),
'centers' => $this->normalizer->normalize($this->centerResolverManager->resolveCenters($person), $format, $context), 'centers' => $this->normalizer->normalize($this->centerResolverManager->resolveCenters($person), $format, $context),
'phonenumber' => $person->getPhonenumber(), 'phonenumber' => $person->getPhonenumber(),
'mobilenumber' => $person->getMobilenumber(), 'mobilenumber' => $person->getMobilenumber(),

View File

@ -15,6 +15,7 @@ use Chill\MainBundle\Templating\Entity\AbstractChillEntityRender;
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper; use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;
use Symfony\Component\Templating\EngineInterface; use Symfony\Component\Templating\EngineInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use function array_key_exists; use function array_key_exists;
@ -27,12 +28,16 @@ class PersonRender extends AbstractChillEntityRender
private EngineInterface $engine; private EngineInterface $engine;
private TranslatorInterface $translator;
public function __construct( public function __construct(
ConfigPersonAltNamesHelper $configAltNamesHelper, ConfigPersonAltNamesHelper $configAltNamesHelper,
EngineInterface $engine EngineInterface $engine,
TranslatorInterface $translator
) { ) {
$this->configAltNamesHelper = $configAltNamesHelper; $this->configAltNamesHelper = $configAltNamesHelper;
$this->engine = $engine; $this->engine = $engine;
$this->translator = $translator;
} }
/** /**
@ -53,6 +58,7 @@ class PersonRender extends AbstractChillEntityRender
'customButtons' => $options['customButtons'] ?? [], 'customButtons' => $options['customButtons'] ?? [],
'customArea' => $options['customArea'] ?? [], 'customArea' => $options['customArea'] ?? [],
'addDeath' => $options['addDeath'] ?? true, 'addDeath' => $options['addDeath'] ?? true,
'addAgeBadge' => $options['addAgeBadge'] ?? false,
]; ];
return return
@ -70,6 +76,13 @@ class PersonRender extends AbstractChillEntityRender
*/ */
public function renderString($person, array $options): string public function renderString($person, array $options): string
{ {
$options = array_merge(['addAge' => true], $options);
if (null !== $person->getAge() && $person->getDeathDate() === null && $options['addAge']) {
return $person->getFirstName() . ' ' . $person->getLastName()
. $this->addAltNames($person, false) . ' (' . $this->translator->trans('years_old', ['age' => $person->getAge()]) . ')';
}
return $person->getFirstName() . ' ' . $person->getLastName() return $person->getFirstName() . ' ' . $person->getLastName()
. $this->addAltNames($person, false); . $this->addAltNames($person, false);
} }

View File

@ -29,7 +29,9 @@ use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
final class PersonVoterTest extends KernelTestCase final class PersonVoterTest extends KernelTestCase
{ {
use PrepareCenterTrait; use PrepareCenterTrait;
use PrepareScopeTrait; use PrepareScopeTrait;
use PrepareUserTrait; use PrepareUserTrait;
/** /**

View File

@ -11,3 +11,7 @@ services:
Chill\PersonBundle\Search\SearchPersonApiProvider: Chill\PersonBundle\Search\SearchPersonApiProvider:
autowire: true autowire: true
autoconfigure: true autoconfigure: true
Chill\PersonBundle\Search\SearchHouseholdApiProvider:
autowire: true
autoconfigure: true

View File

@ -121,7 +121,6 @@ address_postcode_code: Code postal
address_country_name: Pays address_country_name: Pays
address_country_code: Code pays address_country_code: Code pays
'Alreay existing person': 'Dossiers déjà encodés' 'Alreay existing person': 'Dossiers déjà encodés'
'Add the person': 'Ajouter la personne' 'Add the person': 'Ajouter la personne'
'Add the person and create an accompanying period': "Créer la personne & créer une période d'accompagnement" 'Add the person and create an accompanying period': "Créer la personne & créer une période d'accompagnement"
@ -225,15 +224,15 @@ Concerned scopes: Services concernés
# person resource # person resource
person_resources_menu: "Personnes ressources" person_resources_menu: "Ressources"
Person resources: "Ressources de la personne" Person resources: "Ressources de la personne"
Add a person resource: "Ajouter une personne ressource" Add a person resource: "Ajouter une ressource"
edit resource: "Modifier une personne ressource" edit resource: "Modifier ressource"
Remove resource: "Supprimer une personne ressource" Remove resource: "Supprimer ressource"
Are you sure you want to remove the resource for "%name%" ?: Étes-vous sûr de vouloir supprimer cette ressource de %name%? Are you sure you want to remove the resource for "%name%" ?: Étes-vous sûr de vouloir supprimer cette ressource de %name%?
The resource has been successfully removed.: "La ressource a été supprimée." The resource has been successfully removed.: "La ressource a été supprimée."
List of resources: "Liste des ressources" List of resources: "Liste des ressources"
There are no available resources: "Aucune personne ressources renseignée" There are no available resources: "Aucun ressource"
no comment found: "Aucun commentaire" no comment found: "Aucun commentaire"
Select a type: "Choisissez un type" Select a type: "Choisissez un type"
Select a person: "Choisissez un usager" Select a person: "Choisissez un usager"
@ -243,6 +242,7 @@ Select a thirdparty: "Choisissez un tiers"
# pickAPersonType # pickAPersonType
Pick a person: Choisir une personne Pick a person: Choisir une personne
# Address
No address given: Pas d'adresse renseignée No address given: Pas d'adresse renseignée
The address has been successfully updated: L'adresse a été mise à jour avec succès The address has been successfully updated: L'adresse a été mise à jour avec succès
Update address for %name%: Mettre à jour une adresse pour %name% Update address for %name%: Mettre à jour une adresse pour %name%
@ -257,6 +257,31 @@ The new address was created successfully: La nouvelle adresse a été créée
Add an address: Ajouter une adresse Add an address: Ajouter une adresse
Back to the person details: Retour aux détails de la personne Back to the person details: Retour aux détails de la personne
# Residential address
Residential addresses history for %name%: Historique des adresses de résidence de %name%
Residential addresses history: Historique des adresses de résidence
Add a residential address: Ajouter une adresse de résidence
Which kind of residential address would you create ?: Quel type d'adresse de résidence voulez-vous créer?
The address of another person: L'adresse d'une autre personne
The address of a third party: L'adresse d'un tiers
A new address: Une nouvelle adresse
residential_address_person_explanation: L'adresse sera positionnée auprès d'un usager. Lorsque l'usager déménage, l'adresse de résidence suivra également cet usager
residential_address_third_party_explanation: L'adresse sera associée à celle d'un tiers.
residential_address_new_address_explanation: Créer une nouvelle adresse. L'adresse sera fixe.
New residential address: Nouvelle adresse de résidence
Host person: Choisir l'adresse d'un usager
Host third party: Choisir l'adresse d'un tiers
The new residential address was created successfully: La nouvelle adresse de résidence a été créée
Edit a residential address: Modifier l'addresse de résidence
The residential address was updated successfully: L'adresse de résidence a été mise à jour
Residential addresses: Adresses de résidence
Address of: Adresse de
Delete residential address: Supprimer l'adresse de résidence
Delete residential address ?: Supprimer l'adresse de résidence ?
Are you sure you want to remove this residential address for %name% ?: Êtes-vous sûr de vouloir supprimer l'adresse de résidence pour %name% ?
Residential address had been deleted: L'adresse de résidence a été supprimée
#timeline #timeline
Timeline: Historique Timeline: Historique
Closing the accompanying period: Fermeture de la période d'accompagnement Closing the accompanying period: Fermeture de la période d'accompagnement
@ -533,3 +558,6 @@ household_composition:
# docgen # docgen
Linked evaluations: Évaluations associées Linked evaluations: Évaluations associées
# Accompanying period per user
My accompanying periods: Mes parcours

View File

@ -28,7 +28,9 @@ use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
final class ReportVoterTest extends KernelTestCase final class ReportVoterTest extends KernelTestCase
{ {
use PrepareCenterTrait; use PrepareCenterTrait;
use PrepareScopeTrait; use PrepareScopeTrait;
use PrepareUserTrait; use PrepareUserTrait;
/** /**

View File

@ -99,7 +99,7 @@
<div class="item-col"> <div class="item-col">
{% if options['isConfidential'] %} {% if options['isConfidential'] %}
<div class="confidential"> <div class="confidential">
<div class="confidential-content blur"> <div class="confidential-content">
<ul class="list-content fa-ul"> <ul class="list-content fa-ul">
<li> <li>
{{ thirdparty.getAddress|chill_entity_render_box({ {{ thirdparty.getAddress|chill_entity_render_box({