mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
add email and phonenumber: wrote migration file, changed templates, changed validation rules
This commit is contained in:
parent
3eb96c4479
commit
e9698f2cbc
@ -12,7 +12,7 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
|
|||||||
*/
|
*/
|
||||||
class Configuration implements ConfigurationInterface
|
class Configuration implements ConfigurationInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
private $validationBirthdateNotAfterInfos = "The period before today during which"
|
private $validationBirthdateNotAfterInfos = "The period before today during which"
|
||||||
. " any birthdate is not allowed. The birthdate is expressed as ISO8601 : "
|
. " any birthdate is not allowed. The birthdate is expressed as ISO8601 : "
|
||||||
. "https://en.wikipedia.org/wiki/ISO_8601#Durations";
|
. "https://en.wikipedia.org/wiki/ISO_8601#Durations";
|
||||||
@ -23,7 +23,7 @@ class Configuration implements ConfigurationInterface
|
|||||||
{
|
{
|
||||||
$treeBuilder = new TreeBuilder();
|
$treeBuilder = new TreeBuilder();
|
||||||
$rootNode = $treeBuilder->root('cl_chill_person');
|
$rootNode = $treeBuilder->root('cl_chill_person');
|
||||||
|
|
||||||
$rootNode
|
$rootNode
|
||||||
->canBeDisabled()
|
->canBeDisabled()
|
||||||
->children()
|
->children()
|
||||||
@ -50,14 +50,14 @@ class Configuration implements ConfigurationInterface
|
|||||||
$interval = new \DateInterval($period);
|
$interval = new \DateInterval($period);
|
||||||
} catch (\Exception $ex) {
|
} catch (\Exception $ex) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
})
|
})
|
||||||
->thenInvalid('Invalid period for birthdate validation : "%s" '
|
->thenInvalid('Invalid period for birthdate validation : "%s" '
|
||||||
. 'The parameter should match duration as defined by ISO8601 : '
|
. 'The parameter should match duration as defined by ISO8601 : '
|
||||||
. 'https://en.wikipedia.org/wiki/ISO_8601#Durations')
|
. 'https://en.wikipedia.org/wiki/ISO_8601#Durations')
|
||||||
->end() // birthdate_not_after, parent = children of validation
|
->end() // birthdate_not_after, parent = children of validation
|
||||||
|
|
||||||
->end() // children for 'validation', parent = validation
|
->end() // children for 'validation', parent = validation
|
||||||
->end() //validation, parent = children of root
|
->end() //validation, parent = children of root
|
||||||
->end() // children of root, parent = root
|
->end() // children of root, parent = root
|
||||||
@ -67,6 +67,8 @@ class Configuration implements ConfigurationInterface
|
|||||||
->append($this->addFieldNode('place_of_birth'))
|
->append($this->addFieldNode('place_of_birth'))
|
||||||
->append($this->addFieldNode('email'))
|
->append($this->addFieldNode('email'))
|
||||||
->append($this->addFieldNode('phonenumber'))
|
->append($this->addFieldNode('phonenumber'))
|
||||||
|
->append($this->addFieldNode('mobilenumber'))
|
||||||
|
->append($this->addFieldNode('contact_info'))
|
||||||
->append($this->addFieldNode('nationality'))
|
->append($this->addFieldNode('nationality'))
|
||||||
->append($this->addFieldNode('country_of_birth'))
|
->append($this->addFieldNode('country_of_birth'))
|
||||||
->append($this->addFieldNode('marital_status'))
|
->append($this->addFieldNode('marital_status'))
|
||||||
@ -76,22 +78,22 @@ class Configuration implements ConfigurationInterface
|
|||||||
->end() // person_fields, parent = children of root
|
->end() // person_fields, parent = children of root
|
||||||
->end() // children of 'root', parent = root
|
->end() // children of 'root', parent = root
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
return $treeBuilder;
|
return $treeBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function addFieldNode($key)
|
private function addFieldNode($key)
|
||||||
{
|
{
|
||||||
$tree = new TreeBuilder();
|
$tree = new TreeBuilder();
|
||||||
$node = $tree->root($key, 'enum');
|
$node = $tree->root($key, 'enum');
|
||||||
|
|
||||||
$node
|
$node
|
||||||
->values(array('hidden', 'visible'))
|
->values(array('hidden', 'visible'))
|
||||||
->defaultValue('visible')
|
->defaultValue('visible')
|
||||||
->info("If the field $key must be shown")
|
->info("If the field $key must be shown")
|
||||||
->end();
|
->end();
|
||||||
|
|
||||||
return $node;
|
return $node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,9 @@ class Person implements HasCenterInterface {
|
|||||||
|
|
||||||
//TO-ADD : address
|
//TO-ADD : address
|
||||||
|
|
||||||
|
/** @var string Contact information for contacting the person */
|
||||||
|
private $contactInfo = '';
|
||||||
|
|
||||||
/** @var string The person's email */
|
/** @var string The person's email */
|
||||||
private $email = '';
|
private $email = '';
|
||||||
|
|
||||||
@ -456,6 +459,32 @@ class Person implements HasCenterInterface {
|
|||||||
return $this->maritalStatus;
|
return $this->maritalStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set contactInfo
|
||||||
|
*
|
||||||
|
* @param string $contactInfo
|
||||||
|
* @return Person
|
||||||
|
*/
|
||||||
|
public function setcontactInfo($contactInfo)
|
||||||
|
{
|
||||||
|
if ($contactInfo === null) {
|
||||||
|
$contactInfo = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->contactInfo = $contactInfo;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get contactInfo
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getcontactInfo()
|
||||||
|
{
|
||||||
|
return $this->contactInfo;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set email
|
* Set email
|
||||||
|
@ -76,9 +76,17 @@ class PersonType extends AbstractType
|
|||||||
$builder->add('placeOfBirth', TextType::class, array('required' => false));
|
$builder->add('placeOfBirth', TextType::class, array('required' => false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->config['contact_info'] === 'visible') {
|
||||||
|
$builder->add('contactInfo', TextareaType::class, array('required' => false));
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->config['phonenumber'] === 'visible') {
|
if ($this->config['phonenumber'] === 'visible') {
|
||||||
$builder->add('phonenumber', TextareaType::class, array('required' => false));
|
$builder->add('phonenumber', TextareaType::class, array('required' => false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->config['mobilenumber'] === 'visible') {
|
||||||
|
$builder->add('mobilenumber', TextareaType::class, array('required' => false));
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->config['email'] === 'visible') {
|
if ($this->config['email'] === 'visible') {
|
||||||
$builder->add('email', EmailType::class, array('required' => false));
|
$builder->add('email', EmailType::class, array('required' => false));
|
||||||
|
@ -31,8 +31,12 @@ Chill\PersonBundle\Entity\Person:
|
|||||||
memo:
|
memo:
|
||||||
type: text
|
type: text
|
||||||
default: ''
|
default: ''
|
||||||
|
contactInfo:
|
||||||
|
type: text
|
||||||
|
nullable: true
|
||||||
email:
|
email:
|
||||||
type: text
|
type: text
|
||||||
|
nullable: true
|
||||||
proxyAccompanyingPeriodOpenState:
|
proxyAccompanyingPeriodOpenState:
|
||||||
type: boolean
|
type: boolean
|
||||||
name: proxy_open
|
name: proxy_open
|
||||||
@ -41,6 +45,11 @@ Chill\PersonBundle\Entity\Person:
|
|||||||
phonenumber:
|
phonenumber:
|
||||||
type: text
|
type: text
|
||||||
nullable: true
|
nullable: true
|
||||||
|
length: 40
|
||||||
|
mobilenumber:
|
||||||
|
type: text
|
||||||
|
nullable: true
|
||||||
|
length: 40
|
||||||
manyToOne:
|
manyToOne:
|
||||||
countryOfBirth:
|
countryOfBirth:
|
||||||
targetEntity: Chill\MainBundle\Entity\Country
|
targetEntity: Chill\MainBundle\Entity\Country
|
||||||
|
@ -34,11 +34,12 @@ Chill\PersonBundle\Entity\Person:
|
|||||||
- Email:
|
- Email:
|
||||||
groups: [general, creation]
|
groups: [general, creation]
|
||||||
message: 'The email "{{ value }}" is not a valid email.'
|
message: 'The email "{{ value }}" is not a valid email.'
|
||||||
|
checkMX: true
|
||||||
phonenumber:
|
phonenumber:
|
||||||
- Regex:
|
- Regex:
|
||||||
pattern: '/^([\+{1}]|[0])([0-9\s*]{4,20})$/'
|
pattern: '/^([\+{1}])([0-9\s*]{4,20})$/'
|
||||||
groups: [general, creation]
|
groups: [general, creation]
|
||||||
message: 'Invalid phone number: it should begin with "0" or "+", hold only digits and be smaller than 20 characters '
|
message: 'Invalid phone number: it should begin with the international prefix starting with "+", hold only digits and be smaller than 20 characters. Ex: +33123456789 '
|
||||||
|
|
||||||
|
|
||||||
constraints:
|
constraints:
|
||||||
|
32
Resources/migrations/Version201805181442210.php
Normal file
32
Resources/migrations/Version201805181442210.php
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Application\Migrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Migrations\AbstractMigration;
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a contactInfo and a mobilenumber columns on person. Change the email column.
|
||||||
|
*/
|
||||||
|
final class Version20180518144221 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function up(Schema $schema) : void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||||
|
|
||||||
|
$this->addSql('ALTER TABLE chill_person_person ADD contactInfo TEXT DEFAULT NULL');
|
||||||
|
$this->addSql('ALTER TABLE chill_person_person ADD mobilenumber TEXT DEFAULT NULL');
|
||||||
|
$this->addSql('ALTER TABLE chill_person_person ALTER email DROP NOT NULL');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema) : void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||||
|
|
||||||
|
$this->addSql('ALTER TABLE chill_person_person DROP contactInfo');
|
||||||
|
$this->addSql('ALTER TABLE chill_person_person DROP mobilenumber');
|
||||||
|
$this->addSql('ALTER TABLE chill_person_person ALTER email SET NOT NULL');
|
||||||
|
}
|
||||||
|
}
|
@ -38,6 +38,10 @@ Address: Adresse
|
|||||||
Memo: Mémo
|
Memo: Mémo
|
||||||
Phonenumber: 'Numéro de téléphone'
|
Phonenumber: 'Numéro de téléphone'
|
||||||
phonenumber: numéro de téléphone
|
phonenumber: numéro de téléphone
|
||||||
|
Mobilenumber: 'Numéro de téléphone portable'
|
||||||
|
mobilenumber: numéro de téléphone portable
|
||||||
|
'Contact information: remarks': 'Remarques'
|
||||||
|
'Remarks': 'Remarques'
|
||||||
'{0} Born the %date% | {1} Born the %date%': '{0} Né le %date% | {1} Née le %date%'
|
'{0} Born the %date% | {1} Born the %date%': '{0} Né le %date% | {1} Née le %date%'
|
||||||
'Spoken languages': 'Langues parlées'
|
'Spoken languages': 'Langues parlées'
|
||||||
'Unknown spoken languages': 'Langues parlées inconnues'
|
'Unknown spoken languages': 'Langues parlées inconnues'
|
||||||
@ -194,4 +198,3 @@ Aggregate by age: Aggréger par âge
|
|||||||
Calculate age in relation to this date: Calculer l'âge par rapport à cette date
|
Calculate age in relation to this date: Calculer l'âge par rapport à cette date
|
||||||
|
|
||||||
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
|
||||||
|
|
@ -21,7 +21,7 @@
|
|||||||
{% block title %}{{ 'Update details for %name%'|trans({ '%name%': person.firstName|capitalize ~ ' ' ~ person.lastName } )|capitalize }}{% endblock %}
|
{% block title %}{{ 'Update details for %name%'|trans({ '%name%': person.firstName|capitalize ~ ' ' ~ person.lastName } )|capitalize }}{% endblock %}
|
||||||
|
|
||||||
{% block personcontent %}
|
{% block personcontent %}
|
||||||
|
|
||||||
<h1>{{ 'Update details for %name%'|trans({ '%name%': person.firstName|capitalize ~ ' ' ~ person.lastName|capitalize } ) }}</h1>
|
<h1>{{ 'Update details for %name%'|trans({ '%name%': person.firstName|capitalize ~ ' ' ~ person.lastName|capitalize } ) }}</h1>
|
||||||
|
|
||||||
{% form_theme form 'ChillMainBundle:Form:fields.html.twig' %}
|
{% form_theme form 'ChillMainBundle:Form:fields.html.twig' %}
|
||||||
@ -66,7 +66,7 @@
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
|
|
||||||
{%- if form.email is defined or form.phonenumber is defined -%}
|
{%- if form.email is defined or form.phonenumber is defined or form.mobilenumber is defined or form.contact_info is defined-%}
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend><h2>{{ 'Contact information'|trans }}</h2></legend>
|
<legend><h2>{{ 'Contact information'|trans }}</h2></legend>
|
||||||
{%- if form.email is defined -%}
|
{%- if form.email is defined -%}
|
||||||
@ -75,6 +75,12 @@
|
|||||||
{%- if form.phonenumber is defined -%}
|
{%- if form.phonenumber is defined -%}
|
||||||
{{ form_row(form.phonenumber, {'label': 'Phonenumber'}) }}
|
{{ form_row(form.phonenumber, {'label': 'Phonenumber'}) }}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
|
{%- if form.mobilenumber is defined -%}
|
||||||
|
{{ form_row(form.mobilenumber, {'label': 'Mobilenumber'}) }}
|
||||||
|
{%- endif -%}
|
||||||
|
{%- if form.contact_info is defined -%}
|
||||||
|
{{ form_row(form.contact_info, {'label': 'Contact information: remarks'}) }}
|
||||||
|
{%- endif -%}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
|
|
||||||
@ -93,4 +99,4 @@
|
|||||||
{{ form_end(form) }}
|
{{ form_end(form) }}
|
||||||
|
|
||||||
|
|
||||||
{% endblock personcontent %}
|
{% endblock personcontent %}
|
||||||
|
@ -173,7 +173,7 @@ This view should receive those arguments:
|
|||||||
<dd>
|
<dd>
|
||||||
{%- if person.lastAddress is not empty -%}
|
{%- if person.lastAddress is not empty -%}
|
||||||
{{ address._render(person.lastAddress) }}
|
{{ address._render(person.lastAddress) }}
|
||||||
|
|
||||||
<ul class="record_actions record_actions_small">
|
<ul class="record_actions record_actions_small">
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ path('chill_person_address_edit', { 'person_id': person.id, 'address_id' : person.lastAddress.id } ) }}" class="sc-button has-hidden button-small bt-edit">
|
<a href="{{ path('chill_person_address_edit', { 'person_id': person.id, 'address_id' : person.lastAddress.id } ) }}" class="sc-button has-hidden button-small bt-edit">
|
||||||
@ -196,6 +196,7 @@ This view should receive those arguments:
|
|||||||
</dl>
|
</dl>
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
|
|
||||||
|
|
||||||
{%- if chill_person.fields.email == 'visible' -%}
|
{%- if chill_person.fields.email == 'visible' -%}
|
||||||
<dl>
|
<dl>
|
||||||
<dt>{{ 'Email'|trans }} :</dt>
|
<dt>{{ 'Email'|trans }} :</dt>
|
||||||
@ -208,7 +209,18 @@ This view should receive those arguments:
|
|||||||
<dd>{% if person.phonenumber is not empty %}<pre>{{ person.phonenumber}}</pre>{% else %}<span class="chill-no-data-statement">{{ 'No data given'|trans }}{% endif %}</dd>
|
<dd>{% if person.phonenumber is not empty %}<pre>{{ person.phonenumber}}</pre>{% else %}<span class="chill-no-data-statement">{{ 'No data given'|trans }}{% endif %}</dd>
|
||||||
</dl>
|
</dl>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{%- if chill_person.fields.mobilenumber == 'visible' -%}
|
||||||
|
<dl>
|
||||||
|
<dt>{{ 'Mobilenumber'|trans }} :</dt>
|
||||||
|
<dd>{% if person.mobilenumber is not empty %}<pre>{{ person.mobilenumber}}</pre>{% else %}<span class="chill-no-data-statement">{{ 'No data given'|trans }}{% endif %}</dd>
|
||||||
|
</dl>
|
||||||
|
{% endif %}
|
||||||
|
{%- if chill_person.fields.contact_info == 'visible' -%}
|
||||||
|
<dl>
|
||||||
|
<dt>{{ 'Remarks'|trans }} :</dt>
|
||||||
|
<dd>{% if person.contactInfo is not empty %}<blockquote class="chill-user-quote">{{ person.contactInfo|nl2br }}</blockquote>{% else %}<span class="chill-no-data-statement">{{ 'No data given'|trans }}</span>{% endif %}</dd>
|
||||||
|
</dl>
|
||||||
|
{%- endif -%}
|
||||||
|
|
||||||
{% if is_granted('CHILL_PERSON_UPDATE', person) %}
|
{% if is_granted('CHILL_PERSON_UPDATE', person) %}
|
||||||
{{ include(edit_tmp_name, edit_tmp_args) }}
|
{{ include(edit_tmp_name, edit_tmp_args) }}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user