tp form: call vue_address to manage address, wip

show some limits with AddAddress:
* bug with option buttonText overriding default
* need to improve step1
This commit is contained in:
Mathieu Jaumotte 2021-09-15 12:57:37 +02:00
parent 92fae5cba2
commit e94790b8ab
4 changed files with 134 additions and 2 deletions

View File

@ -74,6 +74,7 @@ address:
address_homeless: L'adresse est-elle celle d'un domicile fixe ?
real address: Adresse d'un domicile
consider homeless: N'est pas l'adresse d'un domicile (SDF)
Create a new address: Créer une nouvelle adresse
#serach
Your search is empty. Please provide search terms.: La recherche est vide. Merci de fournir des termes de recherche.

View File

@ -0,0 +1,77 @@
{#
This Twig template include load vue_address component.
It push all variables from context in Address/App.vue.
OPTIONS
* mode string ['edit*'|'new'|'create']
* address_id integer
* backUrl twig route: path('route', {parameters})
* modalTitle twig translated chain
* buttonText twig translated chain
* buttonSize bootstrap class like 'btn-sm'
* buttonDisplayText bool
* binModalStep1 bool
* binModalStep2 bool
#}
<div id="address"></div>
<script type="text/javascript">
window.vueRootComponent = 'app';
window.entityType = 'thirdParty';
window.entityId = {{ thirdParty.id|e('js') }};
{% if 'edit' in app.request.get('_route') %}
window.addressId = {{ app.request.get('address_id')|e('js') }};
window.mode = 'edit';
{% elseif mode is defined and mode == 'edit' %}
window.addressId = {{ address_id|e('js') }};
window.mode = 'edit';
{% endif %}
{% if backUrl is not defined %}
window.backUrl = '{{ path('chill_3party_3party_show', { 'thirdparty_id': thirdParty.id })|e('js') }}';
{% else %}
window.backUrl = '{{ backUrl|e('js') }}';
{% endif %}
{% if modalTitle is defined %}
window.modalTitle = '{{ modalTitle|trans|e('js') }}';
{% endif %}
{% if buttonText is defined %}
window.buttonText = '{{ buttonText|trans|e('js') }}';
{% endif %}
{% if buttonSize is defined %}
window.buttonSize = '{{ buttonSize|e('js') }}';
{% endif %}
{% if buttonDisplayText is defined and buttonDisplayText == false %}
window.buttonDisplayText = false;
{% endif %}
{% if binModalStep1 is defined and binModalStep1 == false %}
window.binModalStep1 = false;
{% endif %}
{% if binModalStep2 is defined and binModalStep2 == false %}
window.binModalStep2 = false;
{% endif %}
</script>
{{ encore_entry_script_tags('vue_address') }}
{{ encore_entry_link_tags('vue_address') }}
{# TODO
* un seul fichier include twig qui fais la liaison avec vue_address
* dans main
* enlever les références à household, person, thirdparty
* addAddress
* option buttonText est buggée
* gestion du step1
*
#}

View File

@ -31,7 +31,36 @@
{{ form_row(form.telephone) }}
{{ form_row(form.email) }}
{{ form_row(form.address) }}
<div class="mb-3 row">
{{ form_label(form.address) }}
{{ form_widget(form.address) }}
<div class="col-sm-8">
new tp =>
{% if thirdParty.address %}
edit address
{# include vue_address component #}
{% include '@ChillThirdParty/Address/_insert_vue_address.html.twig' with {
mode: 'edit',
address_id: thirdParty.address.id,
buttonSize: 'btn-sm',
binModalStep1: false,
backUrl: path('chill_3party_3party_new')
} %}
{% else %}
create address
{# include vue_address component #}
{% include '@ChillThirdParty/Address/_insert_vue_address.html.twig' with {
mode: 'create',
buttonSize: 'btn-sm',
buttonText: 'Create a new address',
modalTitle: 'Create a new address',
binModalStep1: false,
backUrl: path('chill_3party_3party_new')
} %}
{% endif %}
</div>
</div>
{{ form_row(form.comment) }}
{{ form_row(form.centers) }}

View File

@ -48,7 +48,32 @@
{{ form_row(form.telephone) }}
{{ form_row(form.email) }}
{{ form_row(form.address) }}
<div class="mb-3 row">
{{ form_label(form.address) }}
{{ form_widget(form.address) }}
<div class="col-sm-8">
update tp =>
{% if thirdParty.address %}
edit address
{# include vue_address component #}
{% include '@ChillThirdParty/Address/_insert_vue_address.html.twig' with {
mode: 'edit',
address_id: thirdParty.address.id,
buttonSize: 'btn-sm',
binModalStep1: false
} %}
{% else %}
create address
{# include vue_address component #}
{% include '@ChillThirdParty/Address/_insert_vue_address.html.twig' with {
mode: 'create',
buttonSize: 'btn-sm',
binModalStep1: false
} %}
{% endif %}
</div>
</div>
{{ form_row(form.comment) }}
{{ form_row(form.centers) }}