add email and phonenumber: wrote migration file, changed templates, changed validation rules

This commit is contained in:
nobohan
2018-05-18 17:41:33 +02:00
parent 3eb96c4479
commit e9698f2cbc
9 changed files with 118 additions and 16 deletions

View File

@@ -31,8 +31,12 @@ Chill\PersonBundle\Entity\Person:
memo:
type: text
default: ''
contactInfo:
type: text
nullable: true
email:
type: text
nullable: true
proxyAccompanyingPeriodOpenState:
type: boolean
name: proxy_open
@@ -41,6 +45,11 @@ Chill\PersonBundle\Entity\Person:
phonenumber:
type: text
nullable: true
length: 40
mobilenumber:
type: text
nullable: true
length: 40
manyToOne:
countryOfBirth:
targetEntity: Chill\MainBundle\Entity\Country

View File

@@ -34,11 +34,12 @@ Chill\PersonBundle\Entity\Person:
- Email:
groups: [general, creation]
message: 'The email "{{ value }}" is not a valid email.'
checkMX: true
phonenumber:
- Regex:
pattern: '/^([\+{1}]|[0])([0-9\s*]{4,20})$/'
pattern: '/^([\+{1}])([0-9\s*]{4,20})$/'
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:

View 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');
}
}

View File

@@ -38,6 +38,10 @@ Address: Adresse
Memo: Mémo
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%'
'Spoken languages': 'Langues parlées'
'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
Group people by country of birth: Aggréger les personnes par pays de naissance

View File

@@ -21,7 +21,7 @@
{% block title %}{{ 'Update details for %name%'|trans({ '%name%': person.firstName|capitalize ~ ' ' ~ person.lastName } )|capitalize }}{% endblock %}
{% block personcontent %}
<h1>{{ 'Update details for %name%'|trans({ '%name%': person.firstName|capitalize ~ ' ' ~ person.lastName|capitalize } ) }}</h1>
{% form_theme form 'ChillMainBundle:Form:fields.html.twig' %}
@@ -66,7 +66,7 @@
</fieldset>
{%- 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>
<legend><h2>{{ 'Contact information'|trans }}</h2></legend>
{%- if form.email is defined -%}
@@ -75,6 +75,12 @@
{%- if form.phonenumber is defined -%}
{{ form_row(form.phonenumber, {'label': 'Phonenumber'}) }}
{%- 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>
{%- endif -%}
@@ -93,4 +99,4 @@
{{ form_end(form) }}
{% endblock personcontent %}
{% endblock personcontent %}

View File

@@ -173,7 +173,7 @@ This view should receive those arguments:
<dd>
{%- if person.lastAddress is not empty -%}
{{ address._render(person.lastAddress) }}
<ul class="record_actions record_actions_small">
<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">
@@ -196,6 +196,7 @@ This view should receive those arguments:
</dl>
{%- endif -%}
{%- if chill_person.fields.email == 'visible' -%}
<dl>
<dt>{{ 'Email'|trans }}&nbsp;:</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>
</dl>
{% endif %}
{%- if chill_person.fields.mobilenumber == 'visible' -%}
<dl>
<dt>{{ 'Mobilenumber'|trans }}&nbsp;:</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 }}&nbsp;:</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) %}
{{ include(edit_tmp_name, edit_tmp_args) }}