New screen to find duplicate person manually

Signed-off-by: Mathieu Jaumotte <mathieu.jaumotte@champs-libres.coop>
This commit is contained in:
Mathieu Jaumotte 2021-03-21 14:19:31 +01:00
parent c34b992437
commit 3bcb5fb3dd
8 changed files with 167 additions and 11 deletions

View File

@ -0,0 +1,19 @@
; top-most EditorConfig file
root = true
; Unix-style newlines
[*]
charset = utf-8
end_of_line = LF
insert_final_newline = true
trim_trailing_whitespace = true
[*.{php,html,twig}]
indent_style = space
indent_size = 4
[*.md]
max_line_length = 80
[COMMIT_EDITMSG]
max_line_length = 0

View File

@ -7,6 +7,7 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Entity\PersonNotDuplicate; use Chill\PersonBundle\Entity\PersonNotDuplicate;
use Chill\PersonBundle\Form\PersonConfimDuplicateType; use Chill\PersonBundle\Form\PersonConfimDuplicateType;
use Chill\PersonBundle\Form\PersonFindManuallyDuplicateType;
use Chill\PersonBundle\Privacy\PrivacyEvent; use Chill\PersonBundle\Privacy\PrivacyEvent;
use Chill\PersonBundle\Repository\PersonRepository; use Chill\PersonBundle\Repository\PersonRepository;
use Chill\PersonBundle\Search\SimilarPersonMatcher; use Chill\PersonBundle\Search\SimilarPersonMatcher;
@ -83,10 +84,25 @@ class PersonDuplicateController extends Controller
public function confirmAction($person1_id, $person2_id, Request $request) public function confirmAction($person1_id, $person2_id, Request $request)
{ {
[$person1, $person2] = $this->_getPersonsByPriority($person1_id, $person2_id); if ($person1_id === $person2_id) {
throw new InvalidArgumentException('Can not merge same person');
}
$person1 = $this->_getPerson($person1_id);
$person2 = $this->_getPerson($person2_id);
if ($person1 === null) {
throw $this->createNotFoundException("Person with id $person1_id not"
. " found on this server");
}
$this->denyAccessUnlessGranted('CHILL_PERSON_DUPLICATE', $person1, $this->denyAccessUnlessGranted('CHILL_PERSON_DUPLICATE', $person1,
"You are not allowed to see this person."); "You are not allowed to see this person.");
if ($person2 === null) {
throw $this->createNotFoundException("Person with id $person2_id not"
. " found on this server");
}
$form = $this->createForm(PersonConfimDuplicateType::class); $form = $this->createForm(PersonConfimDuplicateType::class);
@ -94,8 +110,8 @@ class PersonDuplicateController extends Controller
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
$event = new PrivacyEvent($person1, array( $event = new PrivacyEvent($person1, array(
'element_class' => Person::class, 'element_class' => Person::class,
'action' => 'move' 'action' => 'move'
)); ));
$event->addPerson($person2); $event->addPerson($person2);
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
@ -161,6 +177,52 @@ class PersonDuplicateController extends Controller
return $this->redirectToRoute('chill_person_duplicate_view', ['person_id' => $person1->getId()]); return $this->redirectToRoute('chill_person_duplicate_view', ['person_id' => $person1->getId()]);
} }
public function findManuallyDuplicateAction($person_id, Request $request)
{
$person = $this->_getPerson($person_id);
if ($person === null) {
throw $this->createNotFoundException("Person with id $person_id not"
. " found on this server");
}
$this->denyAccessUnlessGranted('CHILL_PERSON_DUPLICATE', $person,
"You are not allowed to see this person.");
$form = $this->createForm(PersonFindManuallyDuplicateType::class);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$person2 = $form->get('person')->getData();
if ($person2 === null) {
throw $this->createNotFoundException("Person with id $person2->getId() not"
. " found on this server");
}
$direction = $form->get('direction')->getData();
if ($direction === 'starting') {
$params = [
'person1_id' => $person->getId(),
'person2_id' => $person2->getId(),
];
} else {
$params = [
'person1_id' => $person2->getId(),
'person2_id' => $person->getId(),
];
}
return $this->redirectToRoute('chill_person_duplicate_confirm', $params);
}
return $this->render('ChillPersonBundle:PersonDuplicate:find_manually.html.twig', [
'person' => $person,
'form' => $form->createView(),
]);
}
/** /**
* easy getting a person by his id * easy getting a person by his id
*/ */

View File

@ -0,0 +1,40 @@
<?php
namespace Chill\PersonBundle\Form;
use Chill\PersonBundle\Form\Type\PickPersonType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
class PersonFindManuallyDuplicateType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('person', PickPersonType::class, [
'label' => 'Find duplicate',
'mapped' => false,
])
->add('direction', ChoiceType::class, [
'choices' => [
'Starting' => 'starting',
'Arrival' => 'arrival',
],
])
;
}
/**
* @return string
*/
public function getBlockPrefix()
{
return 'chill_personbundle_person_find_manually_duplicate';
}
}

View File

@ -21,7 +21,7 @@
<ul class="grid-12 sticky-form-buttons record_actions "> <ul class="grid-12 sticky-form-buttons record_actions ">
<li class="cancel"> <li class="cancel">
<a href="{{ path('chill_person_duplicate_view', {'person_id' : person.id}) }}" class="sc-button grey center margin-5"> <a href="{{ app.request.headers.get('referer') }}" class="sc-button grey center margin-5">
<i class="fa fa-arrow-left"></i> <i class="fa fa-arrow-left"></i>
{{ 'Return'|trans }} {{ 'Return'|trans }}
</a> </a>

View File

@ -0,0 +1,29 @@
{% extends "@ChillPerson/layout.html.twig" %}
{% set activeRouteKey = 'chill_person_duplicate' %}
{% block title %}{{ 'Find duplicate'|trans|capitalize ~ ' ' ~ person.firstName|capitalize ~
' ' ~ person.lastName }}{% endblock %}
{% block personcontent %}
{{ form_start(form) }}
{{ form_rest(form) }}
<ul class="grid-12 sticky-form-buttons record_actions ">
<li class="cancel">
<a href="{{ path('chill_person_duplicate_view', {'person_id' : person.id}) }}" class="sc-button grey center margin-5">
<i class="fa fa-arrow-left"></i>
{{ 'Return'|trans }}
</a>
</li>
<li>
<button class="sc-button bt-save" type="submit">{{ 'Confirm'|trans }}</button>
</li>
</ul>
{{ form_end(form) }}
{% endblock %}

View File

@ -63,9 +63,10 @@
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
</table>
{% endif %} {% endif %}
<a href="{{ path('chill_person_find_manually_duplicate', {person_id: person.id}) }}" class="sc-button">{{ 'Associate manually a duplicate person' | trans }}</a>
{% if notDuplicatePersons|length > 0 %} {% if notDuplicatePersons|length > 0 %}
<h2>{{ 'Person flaged as duplicate' | trans }}</h2> <h2>{{ 'Person flaged as duplicate' | trans }}</h2>
@ -122,5 +123,4 @@
</table> </table>
{% endif %} {% endif %}
</table>
{% endblock %} {% endblock %}

View File

@ -89,6 +89,10 @@ chill_person_admin:
path: "/{_locale}/admin/person" path: "/{_locale}/admin/person"
controller: Chill\PersonBundle\Controller\AdminController::indexAction controller: Chill\PersonBundle\Controller\AdminController::indexAction
chill_person_find_manually_duplicate:
path: /{_locale}/person/{person_id}/find-manually
controller: Chill\PersonBundle\Controller\PersonDuplicateController::findManuallyDuplicateAction
chill_person_admin_redirect_to_admin_index: chill_person_admin_redirect_to_admin_index:
path: /{_locale}/admin/person_redirect_to_main path: /{_locale}/admin/person_redirect_to_main
controller: Chill\PersonBundle\Controller\AdminController::redirectToAdminIndexAction controller: Chill\PersonBundle\Controller\AdminController::redirectToAdminIndexAction

View File

@ -70,6 +70,8 @@ Old person: Ancien dossier
New person: Nouveau dossier New person: Nouveau dossier
I confirm the merger of these 2 people : Je confime la fusion de ces 2 dossiers I confirm the merger of these 2 people : Je confime la fusion de ces 2 dossiers
Person flaged as duplicate: Dossiers marqués comme faux-positif Person flaged as duplicate: Dossiers marqués comme faux-positif
Associate manually a duplicate person: Associer manuellement une personne en double
Find duplicate: Trouver un doublon
# addresses part # addresses part
address_street_address_1: Adresse ligne 1 address_street_address_1: Adresse ligne 1
@ -227,7 +229,7 @@ Calculate age in relation to this date: Calculer l'âge par rapport à cette dat
Group people by country of birth: Aggréger les personnes par pays de naissance Group people by country of birth: Aggréger les personnes par pays de naissance
Similar persons: Personnes similaires Similar persons: Personnes similaires
crud: crud:
closing_motive: closing_motive:
index: index:
title: Liste des motifs de clotûre title: Liste des motifs de clotûre
@ -240,12 +242,12 @@ crud:
add_new: Ajouter un nouveau add_new: Ajouter un nouveau
title_new: Nouvel état civil title_new: Nouvel état civil
title_edit: Modifier l'état civil title_edit: Modifier l'état civil
# specific to closing motive # specific to closing motive
closing_motive: closing_motive:
any parent: Aucun parent any parent: Aucun parent
new child: Nouvel enfant new child: Nouvel enfant
Configuration of person bundle: Configuration du module "Personnes" Configuration of person bundle: Configuration du module "Personnes"
person_admin: person_admin:
What would you like to configure ?: Que souhaitez-vous configurer ? What would you like to configure ?: Que souhaitez-vous configurer ?
@ -258,7 +260,7 @@ person_admin:
marital status list: Liste des états civils marital status list: Liste des états civils
marital status explanation: > marital status explanation: >
Configurer la liste des états civils. Configurer la liste des états civils.
accompanying_period: accompanying_period:
dates: Période dates: Période
dates_from_%opening_date%: Ouvert depuis le %opening_date% dates_from_%opening_date%: Ouvert depuis le %opening_date%