add new / create address + tests

This commit is contained in:
2016-03-13 22:14:40 +01:00
parent 545e155334
commit ff5bda12b6
10 changed files with 477 additions and 17 deletions

View File

@@ -74,6 +74,7 @@ Chill\PersonBundle\Entity\Person:
referencedColumnName: id
addresses:
targetEntity: Chill\MainBundle\Entity\Address
orderBy: { 'validFrom': 'DESC' }
joinTable:
name: chill_person_persons_to_addresses
cascade: [persist, remove, merge, detach]

View File

@@ -70,6 +70,19 @@ chill_person_accompanying_period_open:
path: /{_locale}/person/{person_id}/accompanying-period/open
defaults: { _controller: ChillPersonBundle:AccompanyingPeriod:open }
chill_person_address_list:
path: /{_locale}/person/{person_id}/address/list
defaults: { _controller: ChillPersonBundle:PersonAddress:list }
chill_person_address_create:
path: /{_locale}/person/{person_id}/address/create
defaults: { _controller: ChillPersonBundle:PersonAddress:create }
methods: [POST]
chill_person_address_new:
path: /{_locale}/person/{person_id}/address/new
defaults: { _controller: ChillPersonBundle:PersonAddress:new }
chill_person_address_edit:
path: /{_locale}/person/{person_id}/address/{address_id}/edit
defaults: { _controller: ChillPersonBundle:PersonAddress:edit }

View File

@@ -76,6 +76,12 @@ Since %date%: Depuis le %date%
No address given: Pas d'adresse renseignée
The address has been successfully updated: L'adresse a été mise à jour avec succès
Update address for %name%: Mettre à jour une adresse pour %name%
Addresses'history for %name%: Historique des adresses de %name%
Addresses'history: Historique des adresses
New address for %name% : Nouvelle adresse pour %name%
The new address was created successfully: La nouvelle adresse a été créée
Add an address: Ajouter une adresse
Back to the person details: Retour aux détails de la personne
#timeline
'An accompanying period is opened for %person% on %date%': Une période d'accompagnement a été ouverte le %date% pour %person%

View File

@@ -18,10 +18,12 @@
{% set activeRouteKey = '' %}
{% block title %}{{ 'Update address for %name%'|trans({ '%name%': person.firstName|capitalize ~ ' ' ~ person.lastName } )|capitalize }}{% endblock %}
{% block title 'Update address for %name%'|trans({ '%name%': person.firstName ~ ' ' ~ person.lastName } ) %}
{% block personcontent %}
<h1>{{ 'Update address for %name%'|trans({ '%name%': person.firstName ~ ' ' ~ person.lastName } ) }}</h1>
{{ form_start(form) }}
{{ form_row(form.streetAddress1) }}
@@ -29,7 +31,16 @@
{{ form_row(form.postCode) }}
{{ form_row(form.validFrom) }}
{{ form_row(form.submit, { 'attr' : { 'class': 'sc-button bt-edit' } } ) }}
<ul class="record_actions">
<li>
<a href="{{ path('chill_person_address_list', { 'person_id' : person.id } ) }}" class="sc-button btn-cancel">
{{ 'Back to the list'|trans }}
</a>
</li>
<li>
{{ form_row(form.submit, { 'attr' : { 'class': 'sc-button bt-edit' } } ) }}
</li>
</ul>
{{ form_end(form) }}

View File

@@ -0,0 +1,84 @@
{#
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
#}
{% extends "ChillPersonBundle::layout.html.twig" %}
{% import 'ChillMainBundle:Address:macro.html.twig' as address_macros %}
{% set activeRouteKey = '' %}
{% block title %}{{ 'Addresses\'history for %name%'|trans({ '%name%': person.firstName ~ ' ' ~ person.lastName } ) }}{% endblock %}
{% block personcontent %}
<h1>{{ 'Addresses\'history for %name%'|trans({ '%name%': person.firstName ~ ' ' ~ person.lastName } ) }}</h1>
<table class="records_list">
<thead>
<tr>
<th>{{ 'Valid from'|trans }}</th>
<th>{{ 'Address'|trans }}</th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
{% if person.addresses|length == 0 %}
<tr>
<td colspan="3">
<span class="chill-no-data-statement">{{ 'No address given'|trans }}</span>
<a href="{{ path('chill_person_address_new', { 'person_id' : person.id } ) }}">
{{ 'Add an address'|trans }}
</a>
</td>
</tr>
{% else %}
{% for address in person.addresses %}
<tr>
<td><strong>{{ 'Since %date%'|trans( { '%date%' : address.validFrom|localizeddate('long', 'none') } ) }}</strong></td>
<td>
{{ address_macros._render(address, { 'with_valid_from' : false } ) }}
</td>
<td>
<ul class="record_actions">
<li>
<a href="{{ path('chill_person_address_edit', { 'person_id': person.id, 'address_id' : address.id } ) }}" class="sc-button bt-edit">
{{ 'Edit'|trans }}
</a>
</li>
</ul>
</td>
</tr>
{% endfor %}
{% endif %}
</tbody>
</table>
<ul class="record_actions">
<li>
<a href="{{ path('chill_person_view', { 'person_id' : person.id } ) }}" class="sc-button btn-cancel">
{{ 'Back to the person details'|trans }}
</a>
</li>
<li>
<a href="{{ path('chill_person_address_new', { 'person_id' : person.id } ) }}" class="sc-button btn-create">
{{ 'Add an address'|trans }}
</a>
</li>
</ul>
{% endblock personcontent %}

View File

@@ -0,0 +1,47 @@
{#
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
#}
{% extends "ChillPersonBundle::layout.html.twig" %}
{% set activeRouteKey = '' %}
{% block title %}{{ 'New address for %name%'|trans({ '%name%': person.firstName|capitalize ~ ' ' ~ person.lastName } )|capitalize }}{% endblock %}
{% block personcontent %}
<h1>{{ 'New address for %name%'|trans({ '%name%': person.firstName ~ ' ' ~ person.lastName } ) }}</h1>
{{ form_start(form) }}
{{ form_row(form.streetAddress1) }}
{{ form_row(form.streetAddress2) }}
{{ form_row(form.postCode) }}
{{ form_row(form.validFrom) }}
<ul class="record_actions">
<li>
<a href="{{ path('chill_person_address_list', { 'person_id' : person.id } ) }}" class="sc-button btn-cancel">
{{ 'Back to the list'|trans }}
</a>
</li>
<li>
{{ form_row(form.submit, { 'attr' : { 'class': 'sc-button bt-create' } } ) }}
</li>
</ul>
{{ form_end(form) }}
{% endblock personcontent %}

View File

@@ -175,9 +175,15 @@ This view should receive those arguments:
{{ address._render(person.lastAddress) }}
<a href="{{ path('chill_person_address_edit', { 'person_id': person.id, 'address_id' : person.lastAddress.id } ) }}">
{{ 'Edit'|trans }}
</a><br/>
<a href="{{ path('chill_person_address_list', { 'person_id': person.id } ) }}">
{{ 'Addresses\'history'|trans }}
</a>
{%- else -%}
<span class="chill-no-data-statement">{{ 'No address given'|trans }}</span>
<span class="chill-no-data-statement">{{ 'No address given'|trans }}</span>
<a href="{{ path('chill_person_address_new', { 'person_id' : person.id } ) }}" class="">
{{ 'Add an address'|trans }}
</a>
{%- endif -%}
</dd>
</dl>