adapt thirdparty templates

This commit is contained in:
Mathieu Jaumotte 2021-07-16 17:01:32 +02:00
parent 1e626d573f
commit 25b00296ca
6 changed files with 157 additions and 122 deletions

View File

@ -2,6 +2,7 @@
namespace Chill\ThirdPartyBundle\Form;
use Chill\MainBundle\Form\Type\ChillTextareaType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
@ -25,21 +26,21 @@ class ThirdPartyType extends AbstractType
* @var AuthorizationHelper
*/
protected $authorizationHelper;
/**
*
* @var TokenStorageInterface
*/
protected $tokenStorage;
/**
*
* @var ThirdPartyTypeManager
*/
protected $typesManager;
public function __construct(
AuthorizationHelper $authorizationHelper,
AuthorizationHelper $authorizationHelper,
TokenStorageInterface $tokenStorage,
ThirdPartyTypeManager $typesManager
) {
@ -47,7 +48,7 @@ class ThirdPartyType extends AbstractType
$this->tokenStorage = $tokenStorage;
$this->typesManager = $typesManager;
}
/**
* {@inheritdoc}
*/
@ -57,7 +58,7 @@ class ThirdPartyType extends AbstractType
foreach ($this->typesManager->getProviders() as $key => $provider) {
$types['chill_3party.key_label.'.$key] = $key;
}
$builder
->add('name', TextType::class, [
'required' => true
@ -69,7 +70,7 @@ class ThirdPartyType extends AbstractType
->add('email', EmailType::class, [
'required' => false
])
->add('comment', TextareaType::class, [
->add('comment', ChillTextareaType::class, [
'required' => false
])
->add('type', ChoiceType::class, [
@ -99,9 +100,9 @@ class ThirdPartyType extends AbstractType
])
;
}
/**
*
*
* @param array $options
* @return \Chill\MainBundle\Entity\Center[]
*/
@ -113,11 +114,11 @@ class ThirdPartyType extends AbstractType
case 'update': $role = new Role(ThirdPartyVoter::UPDATE);
break;
}
return $this->authorizationHelper->getReachableCenters(
$this->tokenStorage->getToken()->getUser(), $role);
}
/**
* {@inheritdoc}
*/
@ -126,7 +127,7 @@ class ThirdPartyType extends AbstractType
$resolver->setDefaults(array(
'data_class' => 'Chill\ThirdPartyBundle\Entity\ThirdParty'
));
$resolver->setRequired('usage')
->setAllowedValues('usage', ['create', 'update'])
;

View File

@ -15,6 +15,7 @@
<nav class="filter-actions border border-secondary my-4 p-3">
filter nav
{{ dump() }}
</nav>
</div>

View File

@ -3,32 +3,38 @@
{% block title 'Create third party'|trans %}
{% block content %}
<div class="col-10 centered">
<h1>{{ 'Create third party'|trans }}</h1>
<div class="thirdparty-new my-5">
<div class="row justify-content-center">
<div class="col-md-10 col-xxl">
{{ form_start(form) }}
{{ form_row(form.name) }}
{{ form_row(form.type) }}
{{ form_row(form.telephone) }}
{{ form_row(form.email) }}
{{ form_row(form.address) }}
{{ form_row(form.active) }}
{{ form_row(form.centers) }}
{{ form_row(form.comment) }}
<h1>{{ 'Create third party'|trans }}</h1>
{{ form_start(form) }}
{{ form_row(form.name) }}
{{ form_row(form.type) }}
{{ form_row(form.telephone) }}
{{ form_row(form.email) }}
{{ form_row(form.address) }}
{{ form_row(form.active) }}
{{ form_row(form.centers) }}
{{ form_row(form.comment) }}
<ul class="record_actions">
<li class="cancel">
<a href="{{ chill_return_path_or('chill_3party_3party_index') }}" class="btn btn-cancel">
{{ 'Back to the list'|trans }}
</a>
</li>
<li>
{{ form_widget(form.submit, {'label': 'Create', 'attr': {'class': 'btn btn-new' }}) }}
</li>
</ul>
{{ form_end(form) }}
<ul class="record_actions">
<li class="cancel">
<a href="{{ chill_return_path_or('chill_3party_3party_index') }}" class="btn btn-cancel">
{{ 'Back to the list'|trans }}
</a>
</li>
<li>
{{ form_widget(form.submit, {'label': 'Create', 'attr': {'class': 'btn btn-new' }}) }}
</li>
</ul>
{{ form_end(form) }}
</div>
</div>
</div>
{% endblock %}

View File

@ -7,61 +7,75 @@
{% block title title_ %}
{% block content %}
<div class="col-10 centered">
<h1>
{{ title_ }}
<span class="chill__box {{ thirdParty.active ? 'green' : 'red' }}">{{ (thirdParty.active ? 'Active, shown to users' : 'Inactive, not shown to users')|trans }}</span>
</h1>
<dl class="chill_view_data">
<dt>{{ 'Name'|trans }}</dt>
<dd>{{ thirdParty.name }}</dd>
<dt>{{ 'Type'|trans }}</dt>
{% set types = [] %}
{% for t in thirdParty.type %}
{% set types = types|merge( [ ('chill_3party.key_label.'~t)|trans ] ) %}
{% endfor %}
<dd>{{ types|join(', ') }}</dd>
<dt>{{ 'Centers'|trans }}</dt>
<dd>{{ 'The party is visible in those centers'|trans }}&nbsp;: {{ thirdParty.centers|join(', ') }}</dd>
<dt>{{ 'Phonenumber'|trans }}</dt>
<dd>{{ thirdParty.telephone|chill_print_or_message("thirdparty.No_phonenumber") }}</dd>
<dt>{{ 'email'|trans }}<dt>
<dd>{{ thirdParty.email|chill_print_or_message("thirdparty.No_email") }}</dd>
<dt>{{ 'Address'|trans }}</dt>
<dd>
{% if thirdParty.address == null %}
<span class="chill-no-data-statement">{{ 'No address given'|trans }}</span>
{% else %}
{{ address._render(thirdParty.address, {'with_valid_from': false }) }}
{% endif %}
</dd>
<dt>{{ 'Comment'|trans }}</dt>
<dd>{{ thirdParty.comment|chill_print_or_message("thirdparty.No_comment") }}</dd>
</dl>
<ul class="record_actions">
<li class="cancel">
<a class="btn btn-cancel" href="{{ chill_return_path_or('chill_3party_3party_index') }}">
{{ 'Cancel'|trans }}
</a>
</li>
{% if is_granted('CHILL_3PARTY_3PARTY_UPDATE', thirdParty) %}
<li>
<a class="btn btn-update" href="{{ chill_path_forward_return_path('chill_3party_3party_update', { 'thirdparty_id': thirdParty.id }) }}">
{{ 'Update'|trans }}
</a>
</li>
{% endif %}
</ul>
<div class="thirdparty-show my-5">
<div class="row justify-content-center">
<div class="col-md-10 col-xxl">
<h1>
{{ title_ }}
<span class="badge bg-{{ thirdParty.active ? 'success' : 'danger' }}"
title="{{ (thirdParty.active ? 'shown to users' : 'not shown to users')|trans }}">
{{ (thirdParty.active ? 'Active' : 'Inactive')|trans }}
</span>
</h1>
<dl class="chill_view_data">
<dt>{{ 'Name'|trans }}</dt>
<dd>{{ thirdParty.name }}</dd>
<dt>{{ 'Type'|trans }}</dt>
{% set types = [] %}
{% for t in thirdParty.type %}
{% set types = types|merge( [ ('chill_3party.key_label.'~t)|trans ] ) %}
{% endfor %}
<dd>{{ types|join(', ') }}</dd>
<dt>{{ 'Centers'|trans }}</dt>
<dd>{{ 'The party is visible in those centers'|trans }}&nbsp;: {{ thirdParty.centers|join(', ') }}</dd>
<dt>{{ 'Phonenumber'|trans }}</dt>
<dd>{{ thirdParty.telephone|chill_print_or_message("thirdparty.No_phonenumber") }}</dd>
<dt>{{ 'email'|trans }}<dt>
<dd>{{ thirdParty.email|chill_print_or_message("thirdparty.No_email") }}</dd>
<dt>{{ 'Address'|trans }}</dt>
<dd>
{% if thirdParty.address == null %}
<span class="chill-no-data-statement">{{ 'No address given'|trans }}</span>
{% else %}
{{ address._render(thirdParty.address, {'with_valid_from': false }) }}
{% endif %}
</dd>
<dt>{{ 'Comment'|trans }}</dt>
<dd>
{% if thirdParty.comment is not empty %}
<blockquote class="chill-user-quote">
{{ thirdParty.comment|chill_markdown_to_html }}
</blockquote>
{% endif %}
</dd>
</dl>
<ul class="record_actions sticky-form-buttons">
<li class="cancel">
<a class="btn btn-cancel" href="{{ chill_return_path_or('chill_3party_3party_index') }}">
{{ 'Cancel'|trans }}
</a>
</li>
{% if is_granted('CHILL_3PARTY_3PARTY_UPDATE', thirdParty) %}
<li>
<a class="btn btn-update" href="{{ chill_path_forward_return_path('chill_3party_3party_update', { 'thirdparty_id': thirdParty.id }) }}">
{{ 'Update'|trans }}
</a>
</li>
{% endif %}
</ul>
</div>
</div>
</div>
{% endblock %}
{% endblock %}

View File

@ -3,35 +3,44 @@
{% block title 'Update third party %name%'|trans({ '%name%': thirdParty.name }) %}
{% block content %}
<div class="col-10 centered">
<h1>
{{ 'Update third party %name%'|trans({ '%name%': thirdParty.name }) }}
<span class="chill__box {{ thirdParty.active ? 'green' : 'red' }}">{{ (thirdParty.active ? 'Active, shown to users' : 'Inactive, not shown to users')|trans }}</span>
<div class="thirdparty-edit my-5">
<div class="row justify-content-center">
<div class="col-md-10 col-xxl">
</h1>
{{ form_start(form) }}
{{ form_row(form.name) }}
{{ form_row(form.type) }}
{{ form_row(form.telephone) }}
{{ form_row(form.email) }}
{{ form_row(form.address) }}
{{ form_row(form.active) }}
{{ form_row(form.centers) }}
{{ form_row(form.comment) }}
<h1>
{{ 'Update third party %name%'|trans({ '%name%': thirdParty.name }) }}
<span class="badge bg-{{ thirdParty.active ? 'success' : 'danger' }}"
title="{{ (thirdParty.active ? 'shown to users' : 'not shown to users')|trans }}">
{{ (thirdParty.active ? 'Active' : 'Inactive')|trans }}
</span>
</h1>
<ul class="record_actions">
<li class="cancel">
<a class="btn btn-cancel" href="{{ chill_path_forward_return_path('chill_3party_3party_index') }}">
{{ 'Back to the list'|trans }}
</a>
<li>
{{ form_row(form.submit, {'label': 'Update', 'attr': {'class': 'btn btn-update' }}) }}
</li>
</ul>
{{ form_end(form) }}
{{ form_start(form) }}
{{ form_row(form.name) }}
{{ form_row(form.type) }}
{{ form_row(form.telephone) }}
{{ form_row(form.email) }}
{{ form_row(form.address) }}
{{ form_row(form.active) }}
{{ form_row(form.centers) }}
{{ form_row(form.comment) }}
<ul class="record_actions sticky-form-buttons">
<li class="cancel">
<a class="btn btn-cancel" href="{{ chill_path_forward_return_path('chill_3party_3party_index') }}">
{{ 'Back to the list'|trans }}
</a>
<li>
{{ form_widget(form.submit, {'label': 'Update', 'attr': {'class': 'btn btn-update' }}) }}
</li>
</ul>
{{ form_end(form) }}
</div>
</div>
</div>
{% endblock %}

View File

@ -19,8 +19,12 @@ Update third party %name%: Mettre à jour "%name%"
List of third parties: Liste des tiers
Third party updated: Le tiers a été mis à jour
Third party created: Le tiers a été créé
Active, shown to users: Actif, visible par les utilisateurs
Inactive, not shown to users: Inactif, invisible par les utilisateurs
Active, shown to users: Actif, visible pour les utilisateurs
Active: Actif
shown to users: visible pour les utilisateurs
Inactive, not shown to users: Inactif, invisible pour les utilisateurs
Inactive: Inactif
not shown to users: invisible pour les utilisateurs
The party is visible in those centers: Le tiers est visible dans ces centres