mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
person: add civility: entity, migration, form, twig, config
This commit is contained in:
parent
1dbf29beea
commit
fa05a6856a
@ -77,6 +77,7 @@ class Configuration implements ConfigurationInterface
|
||||
->append($this->addFieldNode('nationality'))
|
||||
->append($this->addFieldNode('country_of_birth'))
|
||||
->append($this->addFieldNode('marital_status'))
|
||||
->append($this->addFieldNode('civility'))
|
||||
->append($this->addFieldNode('spoken_languages'))
|
||||
->append($this->addFieldNode('address'))
|
||||
->append($this->addFieldNode('accompanying_period'))
|
||||
|
@ -34,6 +34,7 @@ use Chill\PersonBundle\Entity\MaritalStatus;
|
||||
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
||||
use Chill\MainBundle\Entity\HasCenterInterface;
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
use Chill\MainBundle\Entity\Civility;
|
||||
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
|
||||
use Chill\PersonBundle\Entity\Person\PersonCurrentAddress;
|
||||
use DateTime;
|
||||
@ -212,6 +213,15 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
*/
|
||||
private $maritalStatus;
|
||||
|
||||
/**
|
||||
* The marital status of the person
|
||||
* @var Civility
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Civility")
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*/
|
||||
private $civility;
|
||||
|
||||
/**
|
||||
* The date of the last marital status change of the person
|
||||
* @var \DateTime
|
||||
@ -962,6 +972,28 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
return $this->maritalStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set civility
|
||||
*
|
||||
* @param Civility $civility
|
||||
* @return Person
|
||||
*/
|
||||
public function setCivility(Civility $civility = null)
|
||||
{
|
||||
$this->civility = $civility;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get civility
|
||||
*
|
||||
* @return Civility
|
||||
*/
|
||||
public function getCivility()
|
||||
{
|
||||
return $this->civility;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set contactInfo
|
||||
*
|
||||
|
@ -22,6 +22,7 @@
|
||||
namespace Chill\PersonBundle\Form;
|
||||
|
||||
use Chill\CustomFieldsBundle\Form\Type\CustomFieldType;
|
||||
use Chill\MainBundle\Entity\Civility;
|
||||
use Chill\MainBundle\Form\Type\ChillCollectionType;
|
||||
use Chill\MainBundle\Form\Type\ChillTextareaType;
|
||||
use Chill\MainBundle\Form\Type\Select2CountryType;
|
||||
@ -35,6 +36,10 @@ use Chill\PersonBundle\Form\Type\Select2MaritalStatusType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||
use Chill\MainBundle\Form\Type\CommentType;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\CallbackTransformer;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TelType;
|
||||
@ -63,16 +68,20 @@ class PersonType extends AbstractType
|
||||
*/
|
||||
protected $configAltNamesHelper;
|
||||
|
||||
protected TranslatableStringHelper $translatableStringHelper;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string[] $personFieldsConfiguration configuration of visibility of some fields
|
||||
*/
|
||||
public function __construct(
|
||||
array $personFieldsConfiguration,
|
||||
ConfigPersonAltNamesHelper $configAltNamesHelper
|
||||
ConfigPersonAltNamesHelper $configAltNamesHelper,
|
||||
TranslatableStringHelper $translatableStringHelper
|
||||
) {
|
||||
$this->config = $personFieldsConfiguration;
|
||||
$this->configAltNamesHelper = $configAltNamesHelper;
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -190,6 +199,23 @@ class PersonType extends AbstractType
|
||||
));
|
||||
}
|
||||
|
||||
if ($this->config['civility'] === 'visible'){
|
||||
$builder
|
||||
->add('civility', EntityType::class, [
|
||||
'label' => 'Civility',
|
||||
'class' => Civility::class,
|
||||
'choice_label' => function (Civility $civility): string {
|
||||
return $this->translatableStringHelper->localize($civility->getName());
|
||||
},
|
||||
'query_builder' => function (EntityRepository $er): QueryBuilder {
|
||||
return $er->createQueryBuilder('c')
|
||||
->where('c.active = true');
|
||||
},
|
||||
'placeholder' => 'choose civility',
|
||||
'required' => false
|
||||
]);
|
||||
}
|
||||
|
||||
if ($this->config['marital_status'] === 'visible'){
|
||||
$builder
|
||||
->add('maritalStatus', Select2MaritalStatusType::class, array(
|
||||
|
@ -15,4 +15,5 @@ chill_person:
|
||||
phonenumber: hidden
|
||||
country_of_birth: hidden
|
||||
marital_status: hidden
|
||||
spoken_languages: hidden
|
||||
spoken_languages: hidden
|
||||
civility: hidden
|
@ -37,6 +37,9 @@
|
||||
|
||||
<fieldset>
|
||||
<legend><h2>{{ 'General information'|trans }}</h2></legend>
|
||||
{%- if form.civility is defined -%}
|
||||
{{ form_row(form.civility, {'label' : 'Civility'}) }}
|
||||
{% endif %}
|
||||
{{ form_row(form.firstName, {'label' : 'First name'}) }}
|
||||
{{ form_row(form.lastName, {'label' : 'Last name'}) }}
|
||||
{% if form.altNames is defined %}
|
||||
|
@ -51,6 +51,15 @@ This view should receive those arguments:
|
||||
<figure class="person-details">
|
||||
<h2 class="chill-red">{{ 'General information'|trans }}</h2>
|
||||
<dl>
|
||||
{% if person.civility is not null %}
|
||||
<dt>{{ 'Civility'|trans }} :</dt>
|
||||
<dd>
|
||||
{% if person.civility.name|length > 0 %}
|
||||
{{ person.civility.name|first }}
|
||||
{% endif %}
|
||||
</dd>
|
||||
{% endif %}
|
||||
|
||||
<dt>{{ 'First name'|trans }} :</dt>
|
||||
<dd>{{ person.firstName }}</dd>
|
||||
|
||||
|
@ -7,8 +7,9 @@ services:
|
||||
|
||||
Chill\PersonBundle\Form\PersonType:
|
||||
arguments:
|
||||
- '%chill_person.person_fields%'
|
||||
- '@Chill\PersonBundle\Config\ConfigPersonAltNamesHelper'
|
||||
$personFieldsConfiguration: '%chill_person.person_fields%'
|
||||
$configAltNamesHelper: '@Chill\PersonBundle\Config\ConfigPersonAltNamesHelper'
|
||||
$translatableStringHelper: '@Chill\MainBundle\Templating\TranslatableStringHelper'
|
||||
tags:
|
||||
- { name: form.type, alias: '@chill.person.form.person_creation' }
|
||||
|
||||
|
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Add Civility to Person
|
||||
*/
|
||||
final class Version20211108100849 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add Civility to Person';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_person_person ADD civility_id INT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_person_person ADD CONSTRAINT FK_BF210A1423D6A298 FOREIGN KEY (civility_id) REFERENCES chill_main_civility (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('CREATE INDEX IDX_BF210A1423D6A298 ON chill_person_person (civility_id)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_person_person DROP CONSTRAINT FK_BF210A1423D6A298');
|
||||
$this->addSql('DROP INDEX IDX_BF210A1423D6A298');
|
||||
$this->addSql('ALTER TABLE chill_person_person DROP civility_id');
|
||||
}
|
||||
}
|
@ -80,6 +80,8 @@ Married: Marié(e)
|
||||
'Contact information': 'Informations de contact'
|
||||
'Administrative information': Administratif
|
||||
File number: Dossier n°
|
||||
Civility: Civilité
|
||||
choose civility: --
|
||||
|
||||
# dédoublonnage
|
||||
Old person: Doublon
|
||||
|
Loading…
x
Reference in New Issue
Block a user