move _insert_vue_address include template in main, make it more generic

because it is used with person and household,
but prepare to extend for thirdparty
This commit is contained in:
2021-09-15 18:17:06 +02:00
parent b80d109d8e
commit c2f75654dd
8 changed files with 42 additions and 33 deletions

View File

@@ -1,75 +0,0 @@
{#
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';
{% if person is defined %}
window.entityType = 'person';
window.entityId = {{ person.id|e('js') }};
{% elseif household is defined %}
window.entityType = 'household';
window.entityId = {{ household.id|e('js') }};
{% endif %}
{% 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 %}
{% if person is defined %}
window.backUrl = '{{ path('chill_person_address_list', { 'person_id': person.id })|e('js') }}';
{% elseif household is defined %}
window.backUrl = '{{ path('chill_person_household_addresses', { 'household_id': household.id })|e('js') }}';
{% endif %}
{% 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') }}

View File

@@ -27,7 +27,9 @@
<h1>{{ block('title') }}</h1>
{# include vue_address component #}
{% include '@ChillPerson/Address/_insert_vue_address.html.twig' with {
{% include '@ChillMain/Address/_insert_vue_address.html.twig' with {
targetEntity: { name: 'person', id: person.id },
backUrl: path('chill_person_address_list', { 'person_id': person.id }),
binModalStep1: false,
binModalStep2: false,
} %}

View File

@@ -29,8 +29,10 @@
<li style="margin: auto;">
{# include vue_address component #}
{% include '@ChillPerson/Address/_insert_vue_address.html.twig' with {
mode: 'new',
{% include '@ChillMain/Address/_insert_vue_address.html.twig' with {
targetEntity: { name: 'person', id: person.id },
backUrl: path('chill_person_address_list', { 'person_id': person.id }),
mode: 'create',
buttonSize: 'btn-lg',
buttonText: 'Add an address',
modalTitle: 'Add an address',
@@ -67,9 +69,11 @@
{# include vue_address component #}
<a href="" class="btn btn-sm btn-create">{{ 'Insert an address'|trans }}</a></div>
{#
{% include '@ChillPerson/Address/_insert_vue_address.html.twig' with {
address_id: address.id,
{% include '@ChillMain/Address/_insert_vue_address.html.twig' with {
targetEntity: { name: 'person', id: person.id },
backUrl: path('chill_person_address_list', { 'person_id': person.id }),
mode: 'edit',
addressId: address.id,
binModalStep1: false,
binModalStep2: false,
} %}
@@ -81,9 +85,11 @@
{# include vue_address component #}
<a href="" class="btn btn-sm btn-create">{{ 'Insert an address'|trans }}</a></div>
{#
{% include '@ChillPerson/Address/_insert_vue_address.html.twig' with {
address_id: address.id,
{% include '@ChillMain/Address/_insert_vue_address.html.twig' with {
targetEntity: { name: 'person', id: person.id },
backUrl: path('chill_person_address_list', { 'person_id': person.id }),
mode: 'edit',
addressId: address.id,
binModalStep1: false,
binModalStep2: false,
} %}

View File

@@ -27,7 +27,9 @@
<h1>{{ block('title') }}</h1>
{# include vue_address component #}
{% include '@ChillPerson/Address/_insert_vue_address.html.twig' with {
{% include '@ChillMain/Address/_insert_vue_address.html.twig' with {
targetEntity: { name: 'person', id: person.id },
backUrl: path('chill_person_address_list', { 'person_id': person.id }),
binModalStep1: false,
binModalStep2: false,
} %}

View File

@@ -7,7 +7,9 @@
<div>
{# include vue_address component #}
{% include '@ChillPerson/Address/_insert_vue_address.html.twig' with {
{% include '@ChillMain/Address/_insert_vue_address.html.twig' with {
targetEntity: { name: 'household', id: household.id },
backUrl: path('chill_person_household_addresses', { 'household_id': household.id })
binModalStep1: false,
binModalStep2: false,
} %}

View File

@@ -7,7 +7,9 @@
<div>
{# include vue_address component #}
{% include '@ChillPerson/Address/_insert_vue_address.html.twig' with {
{% include '@ChillMain/Address/_insert_vue_address.html.twig' with {
targetEntity: { name: 'household', id: household.id },
backUrl: path('chill_person_household_addresses', { 'household_id': household.id })
binModalStep1: false,
binModalStep2: false,
} %}

View File

@@ -15,9 +15,10 @@
<li style="margin: auto;">
{# include vue_address component #}
{% include '@ChillPerson/Address/_insert_vue_address.html.twig' with {
mode: 'new',
backUrl: chill_path_add_return_path('chill_person_household_address_move', { 'household_id': household.id }),
{% include '@ChillMain/Address/_insert_vue_address.html.twig' with {
targetEntity: { name: 'household', id: household.id },
backUrl: path('chill_person_household_address_move', { 'household_id': household.id }),
mode: 'create',
buttonSize: 'btn-lg',
buttonText: 'Move household',
modalTitle: 'Move household',

View File

@@ -30,7 +30,9 @@
<ul class="list-inline text-right mt-2">
<li class="list-inline-item">
{# include vue_address component #}
{% include '@ChillPerson/Address/_insert_vue_address.html.twig' with {
{% include '@ChillMain/Address/_insert_vue_address.html.twig' with {
targetEntity: { name: 'household', id: household.id },
backUrl: path('chill_person_household_addresses', { 'household_id': household.id }),
mode: 'create',
buttonSize: 'btn-sm',
buttonText: 'Move household',