Use twig formatter from ChillFormTypesBundle.

This commit is contained in:
Pol Dellaiera 2021-05-19 20:04:21 +02:00
parent c388f91e88
commit e449efc695
No known key found for this signature in database
GPG Key ID: D476DFE9C67467CA
3 changed files with 87 additions and 60 deletions

View File

@ -1,40 +0,0 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\MainBundle\Phonenumber;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
class Templating extends AbstractExtension
{
/**
* @var PhonenumberHelper
*/
protected $phonenumberHelper;
public function __construct(PhonenumberHelper $phonenumberHelper)
{
$this->phonenumberHelper = $phonenumberHelper;
}
public function formatPhonenumber($phonenumber)
{
return $this->phonenumberHelper->format($phonenumber) ?? $phonenumber;
}
public function getFilters()
{
return [
new TwigFilter('chill_format_phonenumber', [$this, 'formatPhonenumber']),
];
}
}

View File

@ -91,17 +91,58 @@
<a href="{{ path('chill_person_new') }}" class="btn btn-create">
{{ 'Add a person'|trans }}
</a>
</li>
{% endif %}
{% if preview == true and persons|length < total %}
<li>
<a href="{{ path('chill_main_search', { "name": search_name|default('abcd'), "q" : pattern }) }}" class="btn btn-misc">
{{ 'See all results'|trans }}
</a>
</li>
{% endif %}
</ul>
{% endif %}
</td>
<td>
{% if person.birthdate is not null %}{{person.birthdate|format_date('long') }}{% else %}{{ 'Unknown date of birth'|trans }}{% endif %}
</td>
<td class="person-list__--by-phonenumber__phones">
<ul>
{% if person.phonenumber is not empty %}
<li>
<a href="tel:{{ person.phonenumber }}"><img src="{{ asset('build/images/mobile-alt-solid.svg') }}">&nbsp;<pre>{{ person.phonenumber|phone_number_format('INTERNATIONAL') }}</pre></a>
</li>
{% endif %}
{% if person.mobilenumber is not empty%}
<li>
<a href="tel:{{ person.mobilenumber }}"><img src="{{ asset('build/images/phone-alt-solid.svg') }}">&nbsp;<pre>{{ person.mobilenumber|phone_number_format('INTERNATIONAL') }}</pre></a>
</li>
{% endif %}
</ul>
</td>
<td>
<ul class="record_actions">
<li><a class="sc-button bt-show" href="{{ path('chill_person_view', { person_id : person.getId }) }}"></a></li>
{% if is_granted('CHILL_PERSON_UPDATE', person) %}
<li><a class="sc-button bt-update" href="{{ path('chill_person_general_edit', { person_id : person.getId }) }}"></a></li>
{% endif %}
</ul>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<ul class="record_actions">
{% if is_granted('CHILL_PERSON_CREATE') %}
<li>
<a href="{{ path('chill_person_new') }}" class="sc-button bt-create">
{{ 'Add a person'|trans }}
</a>
</li>
{% endif %}
{% if preview == true and persons|length < total %}
<li>
<a href="{{ path('chill_main_search', { "name": search_name|default('abcd'), "q" : pattern }) }}" class="sc-button">
{{ 'See all results'|trans }}
</a>
</li>
{% endif %}
</ul>
{% endif %}
{% if preview == false %}
{{ chill_pagination(paginator) }}
{% endif %}
{% if preview == false %}
{{ chill_pagination(paginator) }}

View File

@ -119,14 +119,40 @@ This view should receive those arguments:
{% endapply %}</dd>
{%- endif -%}
</dl>
</figure>
</div>
{% if person.genderComment.comment is not empty %}
<div class="col-12">
<figure class="person-details">
<h2 class="chill-beige">{{ 'Gender comment'|trans }}&nbsp;:</h2>
{%- if chill_person.fields.email == 'visible' -%}
<dl>
<dt>{{ 'Email'|trans }}&nbsp;:</dt>
<dd>{% if person.email is not empty %}<a href="mailto:{{ person.email|escape('html_attr') }}">{{ person.email }}</a>{% else %}<span class="chill-no-data-statement">{{ 'No data given'|trans }}</span>{% endif %}</dd>
</dl>
{%- endif -%}
{%- if chill_person.fields.phonenumber == 'visible' -%}
<dl>
<dt>{{ 'Phonenumber'|trans }}&nbsp;:</dt>
<dd>{% if person.phonenumber is not empty %}<a href="tel:{{ person.phonenumber|phone_number_format('INTERNATIONAL') }}"><pre>{{ person.phonenumber|phone_number_format('INTERNATIONAL') }}</pre></a>{% 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 %}<a href="tel:{{ person.mobilenumber|phone_number_format('INTERNATIONAL') }}"><pre>{{ person.mobilenumber|phone_number_format('INTERNATIONAL') }}</pre></a>{% else %}<span class="chill-no-data-statement">{{ 'No data given'|trans }}{% endif %}</dd>
</dl>
{% endif %}
{% for pp in person.otherPhoneNumbers %}
<dt>{{ 'Other phonenumber'|trans }}&nbsp;:</dt>
<dd>
<a href="tel:{{ pp.phoneNumber|phone_number_format('INTERNATIONAL') }}"><pre>{{ pp.phoneNumber|phone_number_format('INTERNATIONAL') }}</pre></a>
{% if pp.description is not empty %}
<blockquote class="chill-user-quote">
{{ pp.description|nl2br }}
{% endif %}
</blockquote>
</dd>
{% endfor %}
{%- if chill_person.fields.contact_info == 'visible' -%}
<dl>
<dt>{{ 'Notes on contact information'|trans }}&nbsp;:</dt>
<dd>
{% if person.contactInfo is not empty %}
<div class="chill-user-quote">
{{ person.genderComment.comment|chill_markdown_to_html }}
</div>