mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge branch 'issue557_address_civility_in_form_person' into 'master'
Issue557 address and civility in form person See merge request Chill-Projet/chill-bundles!410
This commit is contained in:
commit
f55c06d5c5
13
CHANGELOG.md
13
CHANGELOG.md
@ -11,15 +11,20 @@ and this project adheres to
|
||||
## Unreleased
|
||||
|
||||
<!-- write down unreleased development here -->
|
||||
* [person] add civility when creating a person (with the on-the-fly component or in the php form) (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/557)
|
||||
* [person] add address when creating a person (with the on-the-fly component or in the php form) (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/557)
|
||||
* [person] add household creation API point (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/557)
|
||||
|
||||
|
||||
## Test releases
|
||||
|
||||
### 2021-04-29
|
||||
|
||||
* [person] prevent circular references in PersonDocGenNormalizer (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/527)
|
||||
* [person] add maritalStatusComment to PersonDocGenNormalizer (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/582)
|
||||
* Load relationships without gender in french fixtures
|
||||
* Add command to remove old draft accompanying periods
|
||||
|
||||
|
||||
|
||||
## Test releases
|
||||
|
||||
### 2021-04-28
|
||||
|
||||
* [address] fix bug when editing address: update location and addressreferenceId + better update of the map in edition (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/593)
|
||||
|
@ -210,10 +210,10 @@ export default {
|
||||
let
|
||||
type = this.type,
|
||||
data = {} ;
|
||||
|
||||
switch (type) {
|
||||
case 'person':
|
||||
data = this.$refs.castPerson.$data.person;
|
||||
console.log('person data are', data);
|
||||
break;
|
||||
|
||||
case 'thirdparty':
|
||||
@ -238,7 +238,7 @@ export default {
|
||||
if (typeof data.civility !== 'undefined' && null !== data.civility) {
|
||||
data.civility = data.civility !== null ? {type: 'chill_main_civility', id: data.civility.id} : null;
|
||||
}
|
||||
if (typeof data.civility !== 'undefined' && null !== data.profession) {
|
||||
if (typeof data.profession !== 'undefined' && null !== data.profession) {
|
||||
data.profession = data.profession !== null ? {type: 'third_party_profession', id: data.profession.id} : null;
|
||||
}
|
||||
// console.log('onthefly data', data);
|
||||
|
@ -36,33 +36,35 @@
|
||||
|
||||
{# Flash messages ! #}
|
||||
{% if app.session.flashbag.keys()|length > 0 %}
|
||||
<div class="col-8 mb-5 flash_message">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-10 mb-5 flash_message">
|
||||
|
||||
{% for flashMessage in app.session.flashbag.get('success') %}
|
||||
<div class="alert alert-success flash_message">
|
||||
<span>{{ flashMessage|raw }}</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
{% for flashMessage in app.session.flashbag.get('error') %}
|
||||
<div class="alert alert-danger flash_message">
|
||||
<span>{{ flashMessage|raw }}</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
{% for flashMessage in app.session.flashbag.get('notice') %}
|
||||
<div class="alert alert-warning flash_message">
|
||||
<span>{{ flashMessage|raw }}</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
{% for flashMessage in app.session.flashbag.get('success') %}
|
||||
<div class="alert alert-success flash_message">
|
||||
<span>{{ flashMessage|raw }}</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
{% for flashMessage in app.session.flashbag.get('error') %}
|
||||
<div class="alert alert-danger flash_message">
|
||||
<span>{{ flashMessage|raw }}</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
{% for flashMessage in app.session.flashbag.get('notice') %}
|
||||
<div class="alert alert-warning flash_message">
|
||||
<span>{{ flashMessage|raw }}</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% block content %}
|
||||
<div class="col-8 main_search">
|
||||
<h2>{{ 'Search'|trans }}</h2>
|
||||
|
||||
|
||||
<form action="{{ path('chill_main_search') }}" method="get">
|
||||
<input class="form-control form-control-lg" name="q" type="search" placeholder="{{ 'Search persons, ...'|trans }}" />
|
||||
<center>
|
||||
@ -75,11 +77,11 @@
|
||||
</center>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
{# DISABLED {{ chill_widget('homepage', {} ) }} #}
|
||||
|
||||
|
||||
{% include '@ChillMain/Homepage/index.html.twig' %}
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
||||
</div>
|
||||
|
@ -12,12 +12,15 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Controller;
|
||||
|
||||
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Form\CreationPersonType;
|
||||
use Chill\PersonBundle\Form\PersonType;
|
||||
use Chill\PersonBundle\Privacy\PrivacyEvent;
|
||||
use Chill\PersonBundle\Repository\PersonRepository;
|
||||
use Chill\PersonBundle\Search\SimilarPersonMatcher;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||
@ -31,8 +34,8 @@ use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use function count;
|
||||
use function hash;
|
||||
use function implode;
|
||||
@ -248,6 +251,31 @@ final class PersonController extends AbstractController
|
||||
$this->em->flush();
|
||||
$this->lastPostDataReset();
|
||||
|
||||
$address = $form->get('address')->getData();
|
||||
$addressForm = (bool) $form->get('addressForm')->getData();
|
||||
|
||||
if (null !== $address && $addressForm) {
|
||||
$household = new Household();
|
||||
|
||||
$member = new HouseholdMember();
|
||||
$member->setPerson($person);
|
||||
$member->setStartDate(new DateTimeImmutable());
|
||||
|
||||
$household->addMember($member);
|
||||
$household->setForceAddress($address);
|
||||
|
||||
$this->em->persist($member);
|
||||
$this->em->persist($household);
|
||||
$this->em->flush();
|
||||
|
||||
if ($form->get('createHousehold')->isClicked()) {
|
||||
return $this->redirectToRoute('chill_person_household_members_editor', [
|
||||
'persons' => [$person->getId()],
|
||||
'household' => $household->getId(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($form->get('createPeriod')->isClicked()) {
|
||||
return $this->redirectToRoute('chill_person_accompanying_course_new', [
|
||||
'person_id' => [$person->getId()],
|
||||
|
@ -555,6 +555,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
'methods' => [
|
||||
Request::METHOD_GET => true,
|
||||
Request::METHOD_HEAD => true,
|
||||
Request::METHOD_POST => true,
|
||||
],
|
||||
],
|
||||
'suggestHouseholdByAccompanyingPeriodParticipation' => [
|
||||
|
@ -35,7 +35,7 @@ class HouseholdMember
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
* @Assert\GreaterThan(
|
||||
* @Assert\GreaterThanOrEqual(
|
||||
* propertyPath="startDate",
|
||||
* message="household_membership.The end date must be after start date",
|
||||
* groups={"household_memberships"}
|
||||
@ -82,14 +82,13 @@ class HouseholdMember
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Position::class)
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
* @Assert\NotNull(groups={"household_memberships_created"})
|
||||
*/
|
||||
private ?Position $position = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", name="sharedhousehold")
|
||||
*/
|
||||
private bool $shareHousehold = false;
|
||||
private bool $shareHousehold = true;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
@ -201,15 +200,18 @@ class HouseholdMember
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setPosition(Position $position): self
|
||||
public function setPosition(?Position $position): self
|
||||
{
|
||||
if ($this->position instanceof Position) {
|
||||
if ($this->position instanceof Position && $this->position !== $position) {
|
||||
throw new LogicException('The position is already set. You cannot change ' .
|
||||
'a position of a membership');
|
||||
}
|
||||
|
||||
$this->position = $position;
|
||||
$this->shareHousehold = $position->getShareHousehold();
|
||||
|
||||
if (null !== $position) {
|
||||
$this->shareHousehold = $position->getShareHousehold();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -11,10 +11,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Form;
|
||||
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
use Chill\MainBundle\Form\Event\CustomizeFormEvent;
|
||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||
use Chill\MainBundle\Form\Type\ChillPhoneNumberType;
|
||||
use Chill\MainBundle\Form\Type\PickAddressType;
|
||||
use Chill\MainBundle\Form\Type\PickCenterType;
|
||||
use Chill\MainBundle\Form\Type\PickCivilityType;
|
||||
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Form\Type\GenderType;
|
||||
@ -24,9 +27,12 @@ use libphonenumber\PhoneNumberType;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Validator\Constraints\Callback;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
|
||||
final class CreationPersonType extends AbstractType
|
||||
{
|
||||
@ -55,6 +61,11 @@ final class CreationPersonType extends AbstractType
|
||||
$builder
|
||||
->add('firstName')
|
||||
->add('lastName')
|
||||
->add('civility', PickCivilityType::class, [
|
||||
'required' => false,
|
||||
'label' => 'Civility',
|
||||
'placeholder' => 'choose civility',
|
||||
])
|
||||
->add('gender', GenderType::class, [
|
||||
'required' => true, 'placeholder' => null,
|
||||
])
|
||||
@ -71,6 +82,17 @@ final class CreationPersonType extends AbstractType
|
||||
])
|
||||
->add('email', EmailType::class, [
|
||||
'required' => false,
|
||||
])
|
||||
->add('addressForm', CheckboxType::class, [
|
||||
'label' => 'Create a household and add an address',
|
||||
'required' => false,
|
||||
'mapped' => false,
|
||||
'help' => 'A new household will be created. The person will be member of this household.',
|
||||
])
|
||||
->add('address', PickAddressType::class, [
|
||||
'required' => false,
|
||||
'mapped' => false,
|
||||
'label' => false,
|
||||
]);
|
||||
|
||||
if ($this->askCenters) {
|
||||
@ -97,6 +119,9 @@ final class CreationPersonType extends AbstractType
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Person::class,
|
||||
'constraints' => [
|
||||
new Callback([$this, 'validateCheckedAddress']),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
@ -107,4 +132,18 @@ final class CreationPersonType extends AbstractType
|
||||
{
|
||||
return self::NAME;
|
||||
}
|
||||
|
||||
public function validateCheckedAddress($data, ExecutionContextInterface $context, $payload): void
|
||||
{
|
||||
/** @var bool $addressFrom */
|
||||
$addressFrom = $context->getObject()->get('addressForm')->getData();
|
||||
/** @var ?Address $address */
|
||||
$address = $context->getObject()->get('address')->getData();
|
||||
|
||||
if ($addressFrom && null === $address) {
|
||||
$context->buildViolation('person_creation.If you want to create an household, an address is required')
|
||||
->atPath('addressForm')
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,12 +26,15 @@ class HouseholdMemberType extends AbstractType
|
||||
'input' => 'datetime_immutable',
|
||||
]);
|
||||
|
||||
if (!$options['data']->getPosition()->getShareHousehold()) {
|
||||
$builder->add('endDate', ChillDateType::class, [
|
||||
'label' => 'household.End date',
|
||||
'input' => 'datetime_immutable',
|
||||
]);
|
||||
if (null !== $options['data']->getPosition()) {
|
||||
if (!$options['data']->getPosition()->getShareHousehold()) {
|
||||
$builder->add('endDate', ChillDateType::class, [
|
||||
'label' => 'household.End date',
|
||||
'input' => 'datetime_immutable',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
$builder
|
||||
->add('comment', ChillTextareaType::class, [
|
||||
'label' => 'household.Comment',
|
||||
|
@ -55,7 +55,7 @@ class MembersEditor
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
}
|
||||
|
||||
public function addMovement(DateTimeImmutable $date, Person $person, Position $position, ?bool $holder = false, ?string $comment = null): self
|
||||
public function addMovement(DateTimeImmutable $date, Person $person, ?Position $position, ?bool $holder = false, ?string $comment = null): self
|
||||
{
|
||||
if (null === $this->household) {
|
||||
throw new LogicException('You must define a household first');
|
||||
@ -69,68 +69,70 @@ class MembersEditor
|
||||
->setComment($comment);
|
||||
$this->household->addMember($membership);
|
||||
|
||||
if ($position->getShareHousehold()) {
|
||||
// launch event only if moving to a "share household" position,
|
||||
// and if the destination household is different than the previous one
|
||||
$event = new PersonAddressMoveEvent($person);
|
||||
$event->setNextMembership($membership);
|
||||
if (null !== $position) {
|
||||
if ($position->getShareHousehold()) {
|
||||
// launch event only if moving to a "share household" position,
|
||||
// and if the destination household is different than the previous one
|
||||
$event = new PersonAddressMoveEvent($person);
|
||||
$event->setNextMembership($membership);
|
||||
|
||||
$counter = 0;
|
||||
$counter = 0;
|
||||
|
||||
foreach ($person->getHouseholdParticipationsShareHousehold() as $participation) {
|
||||
if ($participation === $membership) {
|
||||
continue;
|
||||
}
|
||||
foreach ($person->getHouseholdParticipationsShareHousehold() as $participation) {
|
||||
if ($participation === $membership) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($participation->getStartDate() > $membership->getStartDate()) {
|
||||
continue;
|
||||
}
|
||||
if ($participation->getStartDate() > $membership->getStartDate()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
++$counter;
|
||||
++$counter;
|
||||
|
||||
if ($participation->getEndDate() === null || $participation->getEndDate() > $date) {
|
||||
$participation->setEndDate($date);
|
||||
$this->membershipsAffected[] = $participation;
|
||||
$this->oldMembershipsHashes[] = spl_object_hash($participation);
|
||||
if ($participation->getEndDate() === null || $participation->getEndDate() > $date) {
|
||||
$participation->setEndDate($date);
|
||||
$this->membershipsAffected[] = $participation;
|
||||
$this->oldMembershipsHashes[] = spl_object_hash($participation);
|
||||
|
||||
if ($participation->getHousehold() !== $this->household) {
|
||||
$event->setPreviousMembership($participation);
|
||||
$this->events[] = $event;
|
||||
if ($participation->getHousehold() !== $this->household) {
|
||||
$event->setPreviousMembership($participation);
|
||||
$this->events[] = $event;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// send also the event if there was no participation before
|
||||
if (0 === $counter) {
|
||||
$this->events[] = $event;
|
||||
}
|
||||
|
||||
foreach ($person->getHouseholdParticipationsNotShareHousehold() as $participation) {
|
||||
if ($participation->getHousehold() === $this->household
|
||||
&& $participation->getEndDate() === null || $participation->getEndDate() > $membership->getStartDate()
|
||||
&& $participation->getStartDate() <= $membership->getStartDate()
|
||||
) {
|
||||
$participation->setEndDate($membership->getStartDate());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// if a members is moved to the same household than the one he belongs to,
|
||||
// we should make it leave the household
|
||||
if ($person->getCurrentHousehold($date) === $this->household) {
|
||||
$this->leaveMovement($date, $person);
|
||||
}
|
||||
|
||||
// if there are multiple belongings not sharing household, close the others
|
||||
foreach ($person->getHouseholdParticipationsNotShareHousehold() as $participation) {
|
||||
if ($participation === $membership) {
|
||||
continue;
|
||||
// send also the event if there was no participation before
|
||||
if (0 === $counter) {
|
||||
$this->events[] = $event;
|
||||
}
|
||||
|
||||
if ($participation->getHousehold() === $this->household
|
||||
&& ($participation->getEndDate() === null || $participation->getEndDate() > $membership->getStartDate())
|
||||
&& $participation->getStartDate() <= $membership->getStartDate()
|
||||
) {
|
||||
$participation->setEndDate($membership->getStartDate());
|
||||
foreach ($person->getHouseholdParticipationsNotShareHousehold() as $participation) {
|
||||
if ($participation->getHousehold() === $this->household
|
||||
&& $participation->getEndDate() === null || $participation->getEndDate() > $membership->getStartDate()
|
||||
&& $participation->getStartDate() <= $membership->getStartDate()
|
||||
) {
|
||||
$participation->setEndDate($membership->getStartDate());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// if a members is moved to the same household than the one he belongs to,
|
||||
// we should make it leave the household
|
||||
if ($person->getCurrentHousehold($date) === $this->household) {
|
||||
$this->leaveMovement($date, $person);
|
||||
}
|
||||
|
||||
// if there are multiple belongings not sharing household, close the others
|
||||
foreach ($person->getHouseholdParticipationsNotShareHousehold() as $participation) {
|
||||
if ($participation === $membership) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($participation->getHousehold() === $this->household
|
||||
&& ($participation->getEndDate() === null || $participation->getEndDate() > $membership->getStartDate())
|
||||
&& $participation->getStartDate() <= $membership->getStartDate()
|
||||
) {
|
||||
$participation->setEndDate($membership->getStartDate());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,18 @@
|
||||
import { ShowHide } from 'ShowHide';
|
||||
|
||||
const addressForm = document.getElementById("addressForm");
|
||||
const address = document.getElementById("address");
|
||||
|
||||
new ShowHide({
|
||||
froms: [addressForm],
|
||||
container: [address],
|
||||
test: function(froms) {
|
||||
for (let f of froms.values()) {
|
||||
for (let input of f.querySelectorAll('input').values()) {
|
||||
return input.checked;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
event_name: 'change'
|
||||
});
|
@ -123,6 +123,7 @@ export default {
|
||||
body.email = payload.data.email;
|
||||
body.altNames = payload.data.altNames;
|
||||
body.gender = payload.data.gender;
|
||||
body.civility = payload.data.civility;
|
||||
|
||||
makeFetch('PATCH', `/api/1.0/person/person/${payload.data.id}.json`, body)
|
||||
.then(response => {
|
||||
|
@ -150,6 +150,7 @@ export default {
|
||||
body.email = payload.data.email;
|
||||
body.altNames = payload.data.altNames;
|
||||
body.gender = payload.data.gender;
|
||||
body.civility = payload.data.civility;
|
||||
|
||||
makeFetch('PATCH', `/api/1.0/person/person/${payload.data.id}.json`, body)
|
||||
.then(response => {
|
||||
|
@ -14,8 +14,13 @@ const getPersonAltNames = () =>
|
||||
fetch('/api/1.0/person/config/alt_names.json').then(response => {
|
||||
if (response.ok) { return response.json(); }
|
||||
throw Error('Error with request resource response');
|
||||
});;
|
||||
});
|
||||
|
||||
const getCivilities = () =>
|
||||
fetch('/api/1.0/main/civility.json').then(response => {
|
||||
if (response.ok) { return response.json(); }
|
||||
throw Error('Error with request resource response');
|
||||
});
|
||||
|
||||
/*
|
||||
* POST a new person
|
||||
@ -56,6 +61,7 @@ const patchPerson = (id, body) => {
|
||||
export {
|
||||
getPerson,
|
||||
getPersonAltNames,
|
||||
getCivilities,
|
||||
postPerson,
|
||||
patchPerson
|
||||
};
|
||||
|
@ -277,12 +277,79 @@ export default {
|
||||
}
|
||||
},
|
||||
saveFormOnTheFly({ type, data }) {
|
||||
// console.log('saveFormOnTheFly from addPersons, type', type, ', data', data);
|
||||
console.log('saveFormOnTheFly from addPersons, type', type, ', data', data);
|
||||
if (type === 'person') {
|
||||
|
||||
makeFetch('POST', '/api/1.0/person/person.json', data)
|
||||
.then(response => {
|
||||
this.newPriorSuggestion(response);
|
||||
.then(responsePerson => {
|
||||
|
||||
this.newPriorSuggestion(responsePerson);
|
||||
this.$refs.onTheFly.closeModal();
|
||||
|
||||
if (null !== data.addressId) {
|
||||
const household = {
|
||||
'type': 'household'
|
||||
};
|
||||
const address = {
|
||||
'id': data.addressId
|
||||
};
|
||||
makeFetch('POST', '/api/1.0/person/household.json', household)
|
||||
.then(responseHousehold => {
|
||||
const member = {
|
||||
'concerned': [
|
||||
{
|
||||
'person': {
|
||||
'type': 'person',
|
||||
'id': responsePerson.id
|
||||
},
|
||||
'start_date': {
|
||||
// TODO: use date.js methods (low priority)
|
||||
'datetime': `${new Date().toISOString().split('T')[0]}T00:00:00+02:00`
|
||||
},
|
||||
'holder': false,
|
||||
'comment': null
|
||||
}
|
||||
],
|
||||
'destination': {
|
||||
'type': 'household',
|
||||
'id': responseHousehold.id
|
||||
},
|
||||
'composition': null
|
||||
};
|
||||
return makeFetch('POST', '/api/1.0/person/household/members/move.json', member)
|
||||
.then(_response => {
|
||||
makeFetch('POST', `/api/1.0/person/household/${responseHousehold.id}/address.json`, address)
|
||||
.then(_response => {})
|
||||
.catch((error) => {
|
||||
if (error.name === 'ValidationException') {
|
||||
for (let v of error.violations) {
|
||||
this.$toast.open({message: v });
|
||||
}
|
||||
} else {
|
||||
this.$toast.open({message: 'An error occurred'});
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
if (error.name === 'ValidationException') {
|
||||
for (let v of error.violations) {
|
||||
this.$toast.open({message: v });
|
||||
}
|
||||
} else {
|
||||
this.$toast.open({message: 'An error occurred'});
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
if (error.name === 'ValidationException') {
|
||||
for (let v of error.violations) {
|
||||
this.$toast.open({message: v });
|
||||
}
|
||||
} else {
|
||||
this.$toast.open({message: 'An error occurred'});
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
if (error.name === 'ValidationException') {
|
||||
@ -292,7 +359,8 @@ export default {
|
||||
} else {
|
||||
this.$toast.open({message: 'An error occurred'});
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
}
|
||||
else if (type === 'thirdparty') {
|
||||
makeFetch('POST', '/api/1.0/thirdparty/thirdparty.json', data)
|
||||
|
@ -87,6 +87,20 @@
|
||||
<label>{{ $t('person.gender.title') }}</label>
|
||||
</div>
|
||||
|
||||
<div class="form-floating mb-3">
|
||||
<select
|
||||
class="form-select form-select-lg"
|
||||
id="civility"
|
||||
v-model="civility"
|
||||
>
|
||||
<option selected disabled >{{ $t('person.civility.placeholder') }}</option>
|
||||
<option v-for="c in config.civilities" :value="c.id" :key="c.id">
|
||||
{{ c.name.fr }}
|
||||
</option>
|
||||
</select>
|
||||
<label>{{ $t('person.civility.title') }}</label>
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text" id="birthdate"><i class="fa fa-fw fa-birthday-cake"></i></span>
|
||||
<input type="date"
|
||||
@ -124,6 +138,24 @@
|
||||
aria-describedby="email" />
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-3 form-check">
|
||||
<input class="form-check-input"
|
||||
type='checkbox'
|
||||
v-model="showAddressForm"
|
||||
name='showAddressForm'/>
|
||||
<label class="form-check-label">{{ $t('person.address.show_address_form') }}</label>
|
||||
</div>
|
||||
<div v-if="action === 'create' && showAddressFormValue" class="form-floating mb-3">
|
||||
<p>{{ $t('person.address.warning') }}</p>
|
||||
<add-address
|
||||
:context="addAddress.context"
|
||||
:options="addAddress.options"
|
||||
:addressChangedCallback="submitNewAddress"
|
||||
ref="addAddress">
|
||||
</add-address>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="alert alert-warning" v-if="errors.length">
|
||||
<ul>
|
||||
<li v-for="(e, i) in errors" :key="i">{{ e }}</li>
|
||||
@ -134,24 +166,43 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getPerson, getPersonAltNames } from '../../_api/OnTheFly';
|
||||
import { getCivilities, getPerson, getPersonAltNames } from '../../_api/OnTheFly';
|
||||
import PersonRenderBox from '../Entity/PersonRenderBox.vue';
|
||||
import AddAddress from "ChillMainAssets/vuejs/Address/components/AddAddress.vue";
|
||||
|
||||
export default {
|
||||
name: "OnTheFlyPerson",
|
||||
props: ['id', 'type', 'action', 'query'],
|
||||
//emits: ['createAction'],
|
||||
components: {
|
||||
PersonRenderBox
|
||||
PersonRenderBox,
|
||||
AddAddress
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
person: {
|
||||
type: 'person',
|
||||
altNames: []
|
||||
altNames: [],
|
||||
addressId: null
|
||||
},
|
||||
config: {
|
||||
altNames: []
|
||||
altNames: [],
|
||||
civilities: []
|
||||
},
|
||||
showAddressFormValue: false,
|
||||
addAddress: {
|
||||
options: {
|
||||
button: {
|
||||
text: { create: 'person.address.create_address' },
|
||||
size: 'btn-sm'
|
||||
},
|
||||
title: { create: 'person.address.create_address' },
|
||||
},
|
||||
context: {
|
||||
target: {}, // boilerplate for getting the address id
|
||||
edit: false,
|
||||
addressId: null
|
||||
}
|
||||
},
|
||||
errors: []
|
||||
}
|
||||
@ -171,6 +222,10 @@ export default {
|
||||
set(value) { this.person.gender = value; },
|
||||
get() { return this.person.gender; }
|
||||
},
|
||||
civility: {
|
||||
set(value) { this.person.civility = {id: value, type: 'chill_main_civility'}; },
|
||||
get() { return this.person.civility ? this.person.civility.id : null; }
|
||||
},
|
||||
birthDate: {
|
||||
set(value) {
|
||||
if (this.person.birthdate) {
|
||||
@ -195,6 +250,10 @@ export default {
|
||||
set(value) { this.person.email = value; },
|
||||
get() { return this.person.email; }
|
||||
},
|
||||
showAddressForm: {
|
||||
set(value) { this.showAddressFormValue = value; },
|
||||
get() { return this.showAddressFormValue; }
|
||||
},
|
||||
genderClass() {
|
||||
switch (this.person.gender) {
|
||||
case 'woman':
|
||||
@ -230,6 +289,13 @@ export default {
|
||||
.then(altNames => {
|
||||
this.config.altNames = altNames;
|
||||
});
|
||||
getCivilities()
|
||||
.then(civilities => {
|
||||
if ('results' in civilities) {
|
||||
this.config.civilities = civilities.results;
|
||||
}
|
||||
});
|
||||
|
||||
if (this.action !== 'create') {
|
||||
this.loadData();
|
||||
}
|
||||
@ -273,6 +339,9 @@ export default {
|
||||
this.person.firstName = queryItem;
|
||||
break;
|
||||
}
|
||||
},
|
||||
submitNewAddress(payload) {
|
||||
this.person.addressId = payload.addressId;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -293,4 +362,9 @@ dl {
|
||||
margin-left: 1em;
|
||||
}
|
||||
}
|
||||
div.form-check {
|
||||
label {
|
||||
margin-left: 0.5em!important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@ -38,6 +38,15 @@ const personMessages = {
|
||||
man: "Masculin",
|
||||
neuter: "Neutre, non binaire",
|
||||
undefined: "Non renseigné"
|
||||
},
|
||||
civility: {
|
||||
title: "Civilité",
|
||||
placeholder: "Choisissez la civilité",
|
||||
},
|
||||
address: {
|
||||
create_address: "Ajouter une adresse",
|
||||
show_address_form: "Créer un ménage et ajouter une adresse",
|
||||
warning: "Un nouveau ménage va être créé. L'usager sera membre de ce ménage."
|
||||
}
|
||||
},
|
||||
error_only_one_person: "Une seule personne peut être sélectionnée !"
|
||||
|
@ -93,6 +93,8 @@
|
||||
|
||||
{{ form_row(form.gender, { 'label' : 'Gender'|trans }) }}
|
||||
|
||||
{{ form_row(form.civility, { 'label' : 'Civility'|trans }) }}
|
||||
|
||||
{{ form_row(form.birthdate, { 'label' : 'Date of birth'|trans }) }}
|
||||
|
||||
{{ form_row(form.phonenumber, { 'label' : 'Phonenumber'|trans }) }}
|
||||
@ -105,6 +107,13 @@
|
||||
{{ form_row(form.center) }}
|
||||
{% endif %}
|
||||
|
||||
<div id=addressForm>
|
||||
{{ form_row(form.addressForm) }}
|
||||
</div>
|
||||
<div id=address>
|
||||
{{ form_row(form.address) }}
|
||||
</div>
|
||||
|
||||
<ul class="record_actions sticky-form-buttons">
|
||||
<li class="dropdown">
|
||||
<a class="btn btn-create dropdown-toggle"
|
||||
@ -132,4 +141,10 @@
|
||||
|
||||
{% block js %}
|
||||
{{ encore_entry_script_tags('page_suggest_names') }}
|
||||
{{ encore_entry_script_tags('page_create_person') }}
|
||||
{{ encore_entry_script_tags('mod_input_address') }}
|
||||
{% endblock js %}
|
||||
|
||||
{% block css %}
|
||||
{{ encore_entry_link_tags('mod_input_address') }}
|
||||
{% endblock %}
|
||||
|
@ -48,7 +48,9 @@
|
||||
</div>
|
||||
<div class="wl-col list">
|
||||
<p class="item">
|
||||
{{ p.position.label|localize_translatable_string }}
|
||||
{% if p.position %}
|
||||
{{ p.position.label|localize_translatable_string }}
|
||||
{% endif %}
|
||||
{% if p.holder %}
|
||||
<span class="fa-stack fa-holder" title="{{ 'houshold.holder'|trans|e('html_attr') }}">
|
||||
<i class="fa fa-circle fa-stack-1x text-success"></i>
|
||||
|
@ -116,12 +116,18 @@ class MembersEditorNormalizer implements DenormalizerAwareInterface, Denormalize
|
||||
$format,
|
||||
$context
|
||||
);
|
||||
$position = $this->denormalizer->denormalize(
|
||||
$concerned['position'] ?? null,
|
||||
Position::class,
|
||||
$format,
|
||||
$context
|
||||
);
|
||||
|
||||
if (array_key_exists('position', $concerned)) {
|
||||
$position = $this->denormalizer->denormalize(
|
||||
$concerned['position'] ?? null,
|
||||
Position::class,
|
||||
$format,
|
||||
$context
|
||||
);
|
||||
} else {
|
||||
$position = null;
|
||||
}
|
||||
|
||||
$startDate = $this->denormalizer->denormalize(
|
||||
$concerned['start_date'] ?? null,
|
||||
DateTimeImmutable::class,
|
||||
|
@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Serializer\Normalizer;
|
||||
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
use Chill\MainBundle\Entity\Civility;
|
||||
use Chill\MainBundle\Phonenumber\PhoneNumberHelperInterface;
|
||||
use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
|
||||
use Chill\MainBundle\Templating\Entity\ChillEntityRenderExtension;
|
||||
@ -101,6 +102,7 @@ class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwar
|
||||
'center',
|
||||
'altNames',
|
||||
'email',
|
||||
'civility',
|
||||
];
|
||||
|
||||
$fields = array_filter(
|
||||
@ -176,6 +178,13 @@ class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwar
|
||||
case 'email':
|
||||
$person->setEmail($data[$item]);
|
||||
|
||||
break;
|
||||
|
||||
case 'civility':
|
||||
$civility = $this->denormalizer->denormalize($data[$item], Civility::class, $format, []);
|
||||
|
||||
$person->setCivility($civility);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -212,6 +221,7 @@ class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwar
|
||||
'mobilenumber' => $this->normalizer->normalize($person->getMobilenumber(), $format, $context),
|
||||
'email' => $person->getEmail(),
|
||||
'gender' => $person->getGender(),
|
||||
'civility' => $this->normalizer->normalize($person->getCivility(), $format, $context),
|
||||
];
|
||||
|
||||
if (in_array('minimal', $groups, true) && 1 === count($groups)) {
|
||||
|
@ -1137,7 +1137,7 @@ paths:
|
||||
200:
|
||||
description: "OK"
|
||||
400:
|
||||
description: "transition cannot be applyed"
|
||||
description: "transition cannot be applied"
|
||||
|
||||
/1.0/person/accompanying-course/{id}/confidential.json:
|
||||
post:
|
||||
@ -1327,6 +1327,28 @@ paths:
|
||||
responses:
|
||||
200:
|
||||
description: "ok"
|
||||
post:
|
||||
tags:
|
||||
- household
|
||||
requestBody:
|
||||
description: "A household"
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Household"
|
||||
summary: Post a new household
|
||||
responses:
|
||||
401:
|
||||
description: "Unauthorized"
|
||||
404:
|
||||
description: "Not found"
|
||||
200:
|
||||
description: "OK"
|
||||
422:
|
||||
description: "Unprocessable entity (validation errors)"
|
||||
400:
|
||||
description: "transition cannot be applied"
|
||||
|
||||
/1.0/person/household/{id}.json:
|
||||
get:
|
||||
@ -1507,7 +1529,7 @@ paths:
|
||||
422:
|
||||
description: "Unprocessable entity (validation errors)"
|
||||
400:
|
||||
description: "transition cannot be applyed"
|
||||
description: "transition cannot be applied"
|
||||
|
||||
/1.0/person/household/{id}/address.json:
|
||||
post:
|
||||
@ -1543,7 +1565,7 @@ paths:
|
||||
422:
|
||||
description: "Unprocessable entity (validation errors)"
|
||||
400:
|
||||
description: "transition cannot be applyed"
|
||||
description: "transition cannot be applied"
|
||||
|
||||
/1.0/person/social/social-action.json:
|
||||
get:
|
||||
|
@ -22,4 +22,5 @@ module.exports = function(encore, entries)
|
||||
encore.addEntry('page_accompanying_course_index_masonry', __dirname + '/Resources/public/page/accompanying_course_index/masonry.js');
|
||||
encore.addEntry('page_person_resource_showhide_input', __dirname + '/Resources/public/page/person_resource/showhide-input.js');
|
||||
encore.addEntry('page_suggest_names', __dirname + '/Resources/public/page/person/suggest-names.js');
|
||||
encore.addEntry('page_create_person', __dirname + '/Resources/public/page/person/create-person.js');
|
||||
};
|
||||
|
@ -86,6 +86,8 @@ Civility: Civilité
|
||||
choose civility: --
|
||||
All genders: tous les genres
|
||||
Any person selected: Aucune personne sélectionnée
|
||||
Create a household and add an address: Créer un ménage et ajouter une adresse
|
||||
A new household will be created. The person will be member of this household.: Un nouveau ménage va être créé. L'usager sera membre de ce ménage.
|
||||
|
||||
# dédoublonnage
|
||||
Old person: Doublon
|
||||
|
@ -65,4 +65,7 @@ The person where the course is located must be associated to the course. Change
|
||||
|
||||
#relationship
|
||||
relationship:
|
||||
duplicate: Une relation de filiation existe déjà entre ces 2 personnes
|
||||
duplicate: Une relation de filiation existe déjà entre ces 2 personnes
|
||||
|
||||
person_creation:
|
||||
If you want to create an household, an address is required: Pour la création d'un ménage, une adresse est requise
|
||||
|
Loading…
x
Reference in New Issue
Block a user