Compare commits

...

17 Commits

Author SHA1 Message Date
nobohan
bfb19d0670 [person] use the same rendering of person in similar person proposition 2022-02-17 14:00:38 +01:00
nobohan
574c3596d1 upd CHANGELOG 2022-02-17 11:58:45 +01:00
nobohan
d7f5de6570 php code style fix for SimilarPersonMatcher replacement 2022-02-17 11:56:51 +01:00
nobohan
bc08719c0c person: replace SimilarPersonMatcher by PersonACLAwareRepository method 2022-02-17 11:53:51 +01:00
nobohan
a3ffd2709d person: move similar person matcher to PersonACLEwareRepository 2022-02-17 11:33:06 +01:00
aebb21935b fix page "my accompanying period" and do not show drafts periods in
homepage (+ ordering)
2022-02-16 19:57:35 +01:00
f2221565c5 update changelog [ci-skip] 2022-02-14 16:39:04 +01:00
9ead38ee22 Merge branch 'issue_vendee_456_document_field_not_required' into 'master'
doc generation: add age and obele in the mainPerson, person1 and person2 list...

See merge request Chill-Projet/chill-bundles!336
2022-02-14 13:43:52 +00:00
6402962990 customize the 'none' into something more user-frieldly 2022-02-14 14:36:37 +01:00
9e9fa5039f fix cs 2022-02-14 14:26:12 +01:00
e6d503a1e2 Merge remote-tracking branch 'origin/master' into issue_vendee_456_document_field_not_required 2022-02-14 14:25:10 +01:00
4920142540 changelog updated 2022-02-14 14:14:05 +01:00
nobohan
eee38e9577 remove isDead from insert vue on the fly as dead sign (obele) is included in personRender->renderString 2022-02-11 15:18:54 +01:00
nobohan
1f5d529d33 php code fix 2022-02-11 14:30:31 +01:00
nobohan
c19099e76c upd CHANGELOG 2022-02-11 14:28:37 +01:00
nobohan
692343aae4 doc generation: add age and obele in the mainPerson, person1 and person2 list + add obele in person renderString if addAge 2022-02-11 14:24:12 +01:00
nobohan
4dd9bc1123 doc generation: do not set required fields for mainPerson, person1, person2 2022-02-11 14:22:20 +01:00
16 changed files with 166 additions and 64 deletions

View File

@@ -9,12 +9,21 @@ and this project adheres to
* date versioning for test releases
## Unreleased
* AddPersons: remove ul-li html tags from AddPersons (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/419)
<!-- write down unreleased development here -->
* [person] use the same rendering of person in similar person proposition (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/348)
* [person] move similar person matcher to PersonACLAwareRepository and replace the SimilarPersonMatcher uses (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/451)
## Test releases
### test release 2022-02-14
* AddPersons: remove ul-li html tags from AddPersons (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/419)
* [doc-generator] do not set required fields for mainPerson, person1, person2 (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement#456)
* [doc-generation] add age and obele in the mainPerson, person1 and person2 list + add obele in person renderString if addAge (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/370)
* [person] accompanying course work: fix on-the-fly update of thirdParty
* fix normalisation of accompanying course requestor api (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/378)
* [person] add a returnPath when clicking on some Person or ThirdParty badge (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/427)
* [person] accompanying course work: fix on-the-fly update of thirdParty
* [person] accompanying course work: fix on-the-fly update of thirdParty
* [on-the-fly] close modal only after validation
* [person] correct thirdparty PATCH url + add email and altnames in AddPerson and serializer (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/433)
* change order for accompanying course work list
@@ -30,8 +39,7 @@ and this project adheres to
* [address]: Correction residential address 'depuis le' (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/459)
* [Documents]: List view adapted to display more information (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/414)
* [Thirdparty_contact]: address blurred if confidential in view page (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/450)
## Test releases
* [homepage_widget]: If no sender then display as 'notification automatique' (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/435)
### test release 2021-02-01

View File

@@ -11,7 +11,6 @@
* buttonText string
* displayBadge boolean (default: false) replace button by badge, need to define buttonText for content
* parent object (optional) pass parent context of the targetEntity (used for course resource comment)
* isDead boolean (default: false) is the person dead
#}
<span class="onthefly-container"
@@ -29,10 +28,6 @@
data-button-text="{{ buttonText|e('html_attr') }}"
{% endif %}
{% if isDead is defined and isDead == 1 %}
data-is-dead="true"
{% endif %}
{% if displayBadge is defined and displayBadge == 1 %}
data-display-badge="true"
{% endif %}

View File

@@ -16,8 +16,8 @@ use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Form\CreationPersonType;
use Chill\PersonBundle\Form\PersonType;
use Chill\PersonBundle\Privacy\PrivacyEvent;
use Chill\PersonBundle\Repository\PersonACLAwareRepositoryInterface;
use Chill\PersonBundle\Repository\PersonRepository;
use Chill\PersonBundle\Search\SimilarPersonMatcher;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
@@ -56,11 +56,6 @@ final class PersonController extends AbstractController
*/
protected $personRepository;
/**
* @var SimilarPersonMatcher
*/
protected $similarPersonMatcher;
/**
* @var TranslatorInterface
*/
@@ -76,13 +71,14 @@ final class PersonController extends AbstractController
*/
private $logger;
private PersonACLAwareRepositoryInterface $personACLAwareRepository;
/**
* @var ValidatorInterface
*/
private $validator;
public function __construct(
SimilarPersonMatcher $similarPersonMatcher,
TranslatorInterface $translator,
EventDispatcherInterface $eventDispatcher,
PersonRepository $personRepository,
@@ -90,9 +86,9 @@ final class PersonController extends AbstractController
LoggerInterface $logger,
ValidatorInterface $validator,
EntityManagerInterface $em,
Security $security
Security $security,
PersonACLAwareRepositoryInterface $personACLAwareRepository
) {
$this->similarPersonMatcher = $similarPersonMatcher;
$this->translator = $translator;
$this->eventDispatcher = $eventDispatcher;
$this->configPersonAltNameHelper = $configPersonAltNameHelper;
@@ -101,6 +97,7 @@ final class PersonController extends AbstractController
$this->validator = $validator;
$this->em = $em;
$this->security = $security;
$this->personACLAwareRepository = $personACLAwareRepository;
}
public function editAction($person_id, Request $request)
@@ -236,8 +233,8 @@ final class PersonController extends AbstractController
$request->getMethod() === Request::METHOD_POST
&& $form->isValid()
) {
$alternatePersons = $this->similarPersonMatcher
->matchPerson($person);
$alternatePersons = $this->personACLAwareRepository
->findMatchingPersons($person);
if (
false === $this->isLastPostDataChanges($form, $request, true)

View File

@@ -20,9 +20,9 @@ use Chill\PersonBundle\Entity\PersonNotDuplicate;
use Chill\PersonBundle\Form\PersonConfimDuplicateType;
use Chill\PersonBundle\Form\PersonFindManuallyDuplicateType;
use Chill\PersonBundle\Privacy\PrivacyEvent;
use Chill\PersonBundle\Repository\PersonACLAwareRepositoryInterface;
use Chill\PersonBundle\Repository\PersonNotDuplicateRepository;
use Chill\PersonBundle\Repository\PersonRepository;
use Chill\PersonBundle\Search\SimilarPersonMatcher;
use Chill\TaskBundle\Entity\SingleTask;
use http\Exception\InvalidArgumentException;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
@@ -39,6 +39,11 @@ class PersonDuplicateController extends Controller
*/
private $eventDispatcher;
/**
* @var PersonACLAwareRepositoryInterface
*/
private $personACLAwareRepository;
/**
* @var \Chill\PersonBundle\Actions\Remove\PersonMove
*/
@@ -49,24 +54,19 @@ class PersonDuplicateController extends Controller
*/
private $personRepository;
/**
* @var \Chill\PersonBundle\Search\SimilarPersonMatcher
*/
private $similarPersonMatcher;
/**
* @var \Symfony\Component\Translation\TranslatorInterface
*/
private $translator;
public function __construct(
SimilarPersonMatcher $similarPersonMatcher,
PersonACLAwareRepositoryInterface $personACLAwareRepository,
TranslatorInterface $translator,
PersonRepository $personRepository,
PersonMove $personMove,
EventDispatcherInterface $eventDispatcher
) {
$this->similarPersonMatcher = $similarPersonMatcher;
$this->personACLAwareRepository = $personACLAwareRepository;
$this->translator = $translator;
$this->personRepository = $personRepository;
$this->personMove = $personMove;
@@ -246,8 +246,11 @@ class PersonDuplicateController extends Controller
'You are not allowed to see this person.'
);
$duplicatePersons = $this->similarPersonMatcher->
matchPerson($person, $personNotDuplicateRepository, 0.5, SimilarPersonMatcher::SIMILAR_SEARCH_ORDER_BY_ALPHABETICAL);
$duplicatePersons = $this->personACLAwareRepository->findMatchingPersons(
$person,
0.5,
PersonACLAwareRepositoryInterface::SIMILAR_SEARCH_ORDER_BY_ALPHABETICAL
);
$notDuplicatePersons = $personNotDuplicateRepository->findNotDuplicatePerson($person);

View File

@@ -30,7 +30,7 @@ class UserAccompanyingPeriodController extends AbstractController
}
/**
* @Route("/{_locale}/accompanying-periods", name="chill_person_accompanying_period_user")
* @Route("/{_locale}/person/accompanying-periods/my", name="chill_person_accompanying_period_user")
*/
public function listAction(Request $request)
{
@@ -44,13 +44,13 @@ class UserAccompanyingPeriodController extends AbstractController
);
return $this->render('@ChillPerson/AccompanyingPeriod/user_periods_list.html.twig', [
'accompanyingds' => $accompanyingPeriods,
'accompanyingPeriods' => $accompanyingPeriods,
'pagination' => $pagination,
]);
}
/**
* @Route("/{_locale}/accompanying-periods/drafts", name="chill_person_accompanying_period_draft_user")
* @Route("/{_locale}/person/accompanying-periods/my/drafts", name="chill_person_accompanying_period_draft_user")
*/
public function listDraftsAction(Request $request)
{

View File

@@ -71,7 +71,7 @@ final class AccompanyingPeriodRepository implements ObjectRepository
$qb = $this->buildQueryByRecentUserHistory($user, $since);
return $qb->select('a')
->distinct(true)
->addOrderBy('userHistory.startDate', 'DESC')
->getQuery()
->setMaxResults($limit)
->setFirstResult($offset)
@@ -95,6 +95,7 @@ final class AccompanyingPeriodRepository implements ObjectRepository
$qb
->join('a.userHistories', 'userHistory')
->where($qb->expr()->eq('a.user', ':user'))
->andWhere($qb->expr()->neq('a.step', "'" . AccompanyingPeriod::STEP_DRAFT . "'"))
->andWhere($qb->expr()->gte('userHistory.startDate', ':since'))
->andWhere($qb->expr()->isNull('userHistory.endDate'))
->setParameter('user', $user)

View File

@@ -18,6 +18,7 @@ use Chill\MainBundle\Search\SearchApiQuery;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Chill\PersonBundle\Templating\Entity\PersonRender;
use DateTimeInterface;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\NonUniqueResultException;
@@ -40,18 +41,26 @@ final class PersonACLAwareRepository implements PersonACLAwareRepositoryInterfac
private EntityManagerInterface $em;
private PersonNotDuplicateRepository $personNotDuplicateRepository;
private PersonRender $personRender;
private Security $security;
public function __construct(
Security $security,
EntityManagerInterface $em,
CountryRepository $countryRepository,
AuthorizationHelper $authorizationHelper
AuthorizationHelper $authorizationHelper,
PersonRender $personRender,
PersonNotDuplicateRepository $personNotDuplicateRepository
) {
$this->security = $security;
$this->em = $em;
$this->countryRepository = $countryRepository;
$this->authorizationHelper = $authorizationHelper;
$this->personRender = $personRender;
$this->personNotDuplicateRepository = $personNotDuplicateRepository;
}
public function buildAuthorizedQuery(
@@ -297,6 +306,70 @@ final class PersonACLAwareRepository implements PersonACLAwareRepositoryInterfac
return $this->fetchQueryPerson($query);
}
/**
* @throws NonUniqueResultException
* @throws ParsingException
*
* @return array|Person[]
*/
public function findMatchingPersons(
Person $person,
float $precision = 0.15,
string $orderBy = self::SIMILAR_SEARCH_ORDER_BY_SIMILARITY
): array {
$query = $this->matchPerson($person, $precision, $orderBy);
$authorizedQuery = $this->addAuthorizations($query);
return $this->fetchQueryPerson($authorizedQuery);
}
public function matchPerson(
Person $person,
float $precision = 0.15,
string $orderBy = self::SIMILAR_SEARCH_ORDER_BY_SIMILARITY
): SearchApiQuery {
$fullName = $this->personRender->renderString($person, []);
$query = new SearchApiQuery();
$query->setFromClause('chill_person_person AS person');
$query->andWhereClause(
'SIMILARITY(person.fullnameCanonical, UNACCENT(LOWER(?))) >= ?',
[$fullName, $precision]
);
if (null !== $person->getId()) {
$query->andWhereClause(
'person.id != ?',
[$person->getId()]
);
$notDuplicatePersons = $this->personNotDuplicateRepository->findNotDuplicatePerson($person);
if (count($notDuplicatePersons)) {
$query->andWhereClause(
'person.id NOT IN (?)',
[$notDuplicatePersons]
);
}
}
switch ($orderBy) {
case self::SIMILAR_SEARCH_ORDER_BY_ALPHABETICAL:
$query->setSelectPertinence('person.fullnameCanonical');
break;
case self::SIMILAR_SEARCH_ORDER_BY_SIMILARITY:
default:
$query->setSelectPertinence(
'SIMILARITY(person.fullnameCanonical, UNACCENT(LOWER(?)))',
[$fullName]
);
}
return $query;
}
private function addAuthorizations(SearchApiQuery $query): SearchApiQuery
{
$authorizedCenters = $this->authorizationHelper

View File

@@ -17,6 +17,10 @@ use DateTimeInterface;
interface PersonACLAwareRepositoryInterface
{
public const SIMILAR_SEARCH_ORDER_BY_ALPHABETICAL = 'alphabetical';
public const SIMILAR_SEARCH_ORDER_BY_SIMILARITY = 'similarity';
public function buildAuthorizedQuery(
?string $default = null,
?string $firstname = null,
@@ -61,4 +65,13 @@ interface PersonACLAwareRepositoryInterface
?string $phonenumber = null,
?string $city = null
): array;
/**
* @return array|Person[]
*/
public function findMatchingPersons(
Person $person,
float $precision = 0.15,
string $orderBy = self::SIMILAR_SEARCH_ORDER_BY_SIMILARITY
): array;
}

View File

@@ -20,6 +20,8 @@
<div class="flex-table accompanyingcourse-list">
{% for period in accompanyingPeriods %}
{% include '@ChillPerson/AccompanyingPeriod/_list_item.html.twig' with {'period': period, 'recordAction': _self.recordAction(period)} %}
{% else %}
<p class="chill-no-data-statement">{{ 'Any accompanying period'|trans }}</p>
{% endfor %}
</div>

View File

@@ -17,6 +17,15 @@
{% block title %}{{ 'Add a person'|trans }}{% endblock title %}
{% macro button_person_after(person) %}
{% set household = person.getCurrentHousehold %}
{% if household is not null %}
<li>
<a href="{{ path('chill_person_household_summary', { 'household_id': household.id }) }}" class="btn btn-sm btn-chill-beige"><i class="fa fa-home"></i></a>
</li>
{% endif %}
{% endmacro %}
{% block content %}
<div class="col-md-10 col-xxl person-new">
@@ -31,34 +40,24 @@
</span>
</div>
<table class="table table-bordered border-dark">
<thead>
<tr>
<th class="chill-red">{{ 'Name'|trans }}</th>
<th class="chill-green">{{ 'Date of birth'|trans }}</th>
<th class="chill-orange">{{ 'Nationality'|trans }}</th>
</tr>
</thead>
<tbody>
<div class="flex-table">
{% for person in alternatePersons %}
<tr>
<td>
<a href="{{ path('chill_person_view', {'person_id': person.id } ) }}">
{{ person|chill_entity_render_string }}{% apply spaceless %}
{% if person.isOpen == false %}
<i class="icon-lock"></i>
{% endif %}
{% endapply %}
</a>
</td>
<td>{% if person.birthdate is not null %}{{ person.birthdate|format_date('long') }}{% else %}&nbsp;{% endif %}</td>
<td>
{% if person.nationality is not null %}{{ person.nationality.name|localize_translatable_string }}{% else %}{{ 'Without nationality'|trans }}{% endif %}
</td>
</tr>
<div class="item-bloc">
{{ person|chill_entity_render_box({
'render': 'bloc',
'addLink': true,
'addInfo': true,
'addAge': true,
'addAltNames': true,
'addCenter': true,
'address_multiline': false,
'customButtons': { 'after': _self.button_person_after(person) }
}) }}
</div>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
{{ form_start(form, {'attr' : {'id' : 'create-form'}}) }}

View File

@@ -21,6 +21,9 @@ use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInt
use function count;
/**
* @deprecated
*/
class SimilarPersonMatcher
{
public const SIMILAR_SEARCH_ORDER_BY_ALPHABETICAL = 'alphabetical';

View File

@@ -62,7 +62,6 @@ class AccompanyingPeriodWorkVoter extends Voter
case self::UPDATE:
return $this->security->isGranted(AccompanyingPeriodVoter::EDIT, $subject->getAccompanyingPeriod());
default:
throw new UnexpectedValueException("attribute {$attribute} is not supported");
}

View File

@@ -161,11 +161,13 @@ class AccompanyingPeriodContext implements
'class' => Person::class,
'choices' => $persons,
'choice_label' => function (Person $p) {
return $this->personRender->renderString($p, []);
return $this->personRender->renderString($p, ['addAge' => true]);
},
'multiple' => false,
'expanded' => true,
'required' => false,
'label' => $options[$key . 'Label'],
'placeholder' => $this->translator->trans('Any person selected'),
]);
}
}

View File

@@ -83,6 +83,12 @@ class PersonRender extends AbstractChillEntityRender
. $this->addAltNames($person, false) . ' (' . $this->translator->trans('years_old', ['age' => $person->getAge()]) . ')';
}
if (null !== $person->getDeathDate() && $options['addAge']) {
return $person->getFirstName() . ' ' . $person->getLastName()
. ' (‡)'
. $this->addAltNames($person, false);
}
return $person->getFirstName() . ' ' . $person->getLastName()
. $this->addAltNames($person, false);
}

View File

@@ -24,7 +24,7 @@ services:
Chill\PersonBundle\Controller\PersonDuplicateController:
arguments:
$similarPersonMatcher: '@Chill\PersonBundle\Search\SimilarPersonMatcher'
$personACLAwareRepository: '@Chill\PersonBundle\Repository\PersonACLAwareRepositoryInterface'
$translator: '@Symfony\Component\Translation\TranslatorInterface'
$personRepository: '@Chill\PersonBundle\Repository\PersonRepository'
$personMove: '@Chill\PersonBundle\Actions\Remove\PersonMove'

View File

@@ -85,6 +85,7 @@ Course number: Parcours n°
Civility: Civilité
choose civility: --
All genders: tous les genres
Any person selected: Aucune personne sélectionnée
# dédoublonnage
Old person: Doublon