From 9623a35e6fa98b233a876409709ac4e15c0a4785 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 16 Nov 2022 10:57:06 +0100 Subject: [PATCH 01/17] #16 EventBundle participation (fix errors and improve ux) --- .../Form/Type/PickEventType.php | 2 +- .../views/Event/listByPerson.html.twig | 21 ++----------------- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/src/Bundle/ChillEventBundle/Form/Type/PickEventType.php b/src/Bundle/ChillEventBundle/Form/Type/PickEventType.php index 782bd7628..4e8179f10 100644 --- a/src/Bundle/ChillEventBundle/Form/Type/PickEventType.php +++ b/src/Bundle/ChillEventBundle/Form/Type/PickEventType.php @@ -151,7 +151,7 @@ class PickEventType extends AbstractType } else { $centers = $this->authorizationHelper->getReachableCenters( $this->user, - (string) $options['role'] + (string) $options['role']->getRole() ); } diff --git a/src/Bundle/ChillEventBundle/Resources/views/Event/listByPerson.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Event/listByPerson.html.twig index 53e97c3c4..9ffd5093c 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Event/listByPerson.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Event/listByPerson.html.twig @@ -108,31 +108,14 @@ {{ chill_pagination(paginator) }} {% endif %} -
+
{{ form_start(form_add_event_participation_by_person) }} - {# - - #} {{ form_widget(form_add_event_participation_by_person.event_id, { 'attr' : { 'class' : 'form-control' } } ) }}
- {# - - #} - {{ form_widget(form_add_event_participation_by_person.submit, { 'attr' : { 'class' : 'btn btn-success' } } ) }} + {{ form_widget(form_add_event_participation_by_person.submit, { 'attr' : { 'class' : 'btn btn-sm btn-success' } } ) }}
{{ form_rest(form_add_event_participation_by_person) }} {{ form_end(form_add_event_participation_by_person) }}
-{# -{{ form(form_add_event_participation_by_person) }} -#} - -
- -
- -
-
- {% endblock %} From 928869666c42db48e8b4a7f747228c877e18b24c Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 16 Nov 2022 13:03:25 +0100 Subject: [PATCH 02/17] #16 fix errors and some design regressions in eventBundle --- .../views/Event/confirm_delete.html.twig | 3 +- .../Resources/views/Event/edit.html.twig | 5 +- .../Resources/views/Event/list.html.twig | 73 ++++++++++--------- .../views/Event/listByPerson.html.twig | 63 ++++++++-------- .../Resources/views/Event/new.html.twig | 2 + .../views/Event/newPickCenter.html.twig | 3 +- .../Resources/views/Event/show.html.twig | 9 ++- .../Participation/confirm_delete.html.twig | 4 +- .../Participation/edit-multiple.html.twig | 8 +- .../views/Participation/edit.html.twig | 2 + .../Participation/new-multiple.html.twig | 4 +- .../views/Participation/new.html.twig | 3 +- .../Resources/views/layout.html.twig | 4 +- .../Form/Type/PickPersonType.php | 2 +- 14 files changed, 101 insertions(+), 84 deletions(-) diff --git a/src/Bundle/ChillEventBundle/Resources/views/Event/confirm_delete.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Event/confirm_delete.html.twig index 86b7c6fd2..c3a13b55a 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Event/confirm_delete.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Event/confirm_delete.html.twig @@ -5,6 +5,7 @@ {% block title 'Delete event'|trans %} {% block event_content %} +
{{ include('@ChillMain/Util/confirmation_template.html.twig', { @@ -15,6 +16,6 @@ 'form' : delete_form } ) }} - +
{% endblock %} diff --git a/src/Bundle/ChillEventBundle/Resources/views/Event/edit.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Event/edit.html.twig index 288c81edd..a528f1f5c 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Event/edit.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Event/edit.html.twig @@ -3,6 +3,7 @@ {% block title 'Event edit'|trans %} {% block event_content -%} +

{{ 'Event edit'|trans }}

{{ form_start(edit_form) }} @@ -28,6 +29,8 @@ {{ form_widget(edit_form.submit, { 'attr' : { 'class' : 'btn btn-update' } }) }} - + {{ form_end(edit_form) }} + +
{% endblock %} diff --git a/src/Bundle/ChillEventBundle/Resources/views/Event/list.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Event/list.html.twig index 6e77b6df8..8d5f49da8 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Event/list.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Event/list.html.twig @@ -6,42 +6,42 @@

{{ 'Results %start%-%end% of %total%'|trans({ '%start%' : start, '%end%': start + events|length, '%total%' : total } ) }}

- +
- - - - - - + + + + + + - {% for event in events %} - - - - - + + + + - - {% endfor %} + {% endif %} + + + + + {% endfor %}
{{ 'Name'|trans }}{{ 'Date'|trans }}{{ 'Event type'|trans }} 
{{ 'Name'|trans }}{{ 'Date'|trans }}{{ 'Event type'|trans }} 
{{ event.name }}{{ event.date|format_date('long') }}{{ event.type.name|localize_translatable_string }} -
    -
  • - {# {% if is_granted('CHILL_EVENT_SEE_DETAILS', event) %} #} - - {{ 'See'|trans }} - - {# {% endif %} #} - {% if is_granted('CHILL_EVENT_UPDATE', event) %} + {% for event in events %} +
{{ event.name }}{{ event.date|format_date('long') }}{{ event.type.name|localize_translatable_string }} + -
- + {% endif %} {% if preview == false %} -{{ chill_pagination(paginator) }} + {{ chill_pagination(paginator) }} {% endif %} + diff --git a/src/Bundle/ChillEventBundle/Resources/views/Event/listByPerson.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Event/listByPerson.html.twig index 9ffd5093c..ef2dae85c 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Event/listByPerson.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Event/listByPerson.html.twig @@ -44,59 +44,59 @@ {{ participation.role.name|localize_translatable_string }} {{ participation.status.name|localize_translatable_string }} -
    +
    {% set currentPath = path(app.request.attributes.get('_route'), app.request.attributes.get('_route_params')) %} {% set returnLabel = 'Back to %person% events'|trans({ '%person%' : currentPerson } ) %} {% if is_granted('CHILL_EVENT_SEE_DETAILS', participation.event) %} -
  • -
  • + class="btn btn-primary btn-sm" title="{{ 'See details of the event'|trans }}"> + + {% endif %} {% if is_granted('CHILL_EVENT_UPDATE', participation.event) and is_granted('CHILL_EVENT_PARTICIPATION_UPDATE', participation) %} -
  • -
  • + +
+
{% else %} -
  • {% if is_granted('CHILL_EVENT_UPDATE', participation.event) %} - - {{ 'Edit the event'|trans }} - + + {{ 'Edit the event'|trans }} + {% endif %} {% if is_granted('CHILL_EVENT_PARTICIPATION_UPDATE', participation) %} - - {{ 'Edit the participation'|trans }} - + + {{ 'Edit the participation'|trans }} + {% endif %} -
  • {% endif %} - + {% endfor %} @@ -108,11 +108,14 @@ {{ chill_pagination(paginator) }} {% endif %} -
    +
    {{ form_start(form_add_event_participation_by_person) }} - {{ form_widget(form_add_event_participation_by_person.event_id, { 'attr' : { 'class' : 'form-control' } } ) }} -
    - {{ form_widget(form_add_event_participation_by_person.submit, { 'attr' : { 'class' : 'btn btn-sm btn-success' } } ) }} + {{ form_widget(form_add_event_participation_by_person.event_id, { 'attr' : { + 'class' : 'custom-select', + 'style': 'min-width: 15em; max-width: 18em; display: inline-block;' + }}) }} +
    + {{ form_widget(form_add_event_participation_by_person.submit, { 'attr' : { 'class' : 'btn btn-sm btn-save' } } ) }}
    {{ form_rest(form_add_event_participation_by_person) }} {{ form_end(form_add_event_participation_by_person) }} diff --git a/src/Bundle/ChillEventBundle/Resources/views/Event/new.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Event/new.html.twig index 44d24040b..f0d1b0ea2 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Event/new.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Event/new.html.twig @@ -3,6 +3,7 @@ {% block title 'Event creation'|trans %} {% block event_content -%} +

    {{ 'Event creation'|trans }}

    {{ form_start(form) }} @@ -26,4 +27,5 @@ {{ form_end(form) }} +
    {% endblock %} diff --git a/src/Bundle/ChillEventBundle/Resources/views/Event/newPickCenter.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Event/newPickCenter.html.twig index c4fb4aacd..a10d754e6 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Event/newPickCenter.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Event/newPickCenter.html.twig @@ -3,6 +3,7 @@ {% block title 'Event creation'|trans %} {% block event_content -%} +

    {{ 'Event creation'|trans }}

    {{ form_start(form) }} @@ -22,5 +23,5 @@ {{ form_end(form) }} - +
    {% endblock %} diff --git a/src/Bundle/ChillEventBundle/Resources/views/Event/show.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Event/show.html.twig index 6af5dd80a..4ce92a200 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Event/show.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Event/show.html.twig @@ -5,9 +5,10 @@ {% import 'ChillPersonBundle:Person:macro.html.twig' as person_macro %} {% block event_content -%} +

    {{ 'Details of an event'|trans }}

    - +
    @@ -69,7 +70,7 @@

    {% transchoice count %}%count% participations to this event{% endtranschoice %}

    {% if count > 0 %} -
    {{ 'Name'|trans }}
    +
    @@ -117,7 +118,7 @@ {% endif %} -
    +
    {{ form_start(form_add_participation_by_person) }}
    @@ -150,5 +151,5 @@
    {{ chill_delegated_block('block_footer_show', { 'event': event }) }}
    - +
    {% endblock %} diff --git a/src/Bundle/ChillEventBundle/Resources/views/Participation/confirm_delete.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Participation/confirm_delete.html.twig index 9b023a915..0d993b075 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Participation/confirm_delete.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Participation/confirm_delete.html.twig @@ -5,7 +5,7 @@ {% block title 'Remove participation'|trans %} {% block event_content %} - +
    {{ include('@ChillMain/Util/confirmation_template.html.twig', { 'title' : 'Remove participation'|trans, @@ -15,6 +15,6 @@ 'form' : delete_form } ) }} - +
    {% endblock %} diff --git a/src/Bundle/ChillEventBundle/Resources/views/Participation/edit-multiple.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Participation/edit-multiple.html.twig index a50615414..f0f522a3d 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Participation/edit-multiple.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Participation/edit-multiple.html.twig @@ -3,9 +3,10 @@ {% import 'ChillPersonBundle:Person:macro.html.twig' as person_macro %} {% block event_content -%} +

    {{ 'Participation Edit'|trans }}

    -
    {{ 'Person'|trans }}
    +
    @@ -18,11 +19,11 @@
    {{ 'Associated event'|trans }}
    -

    {{ 'Participations'|trans }}

    +

    {{ 'Participations'|trans }}

    {{ form_start(form) }} - +
    @@ -59,4 +60,5 @@ {{ form_end(form) }} + {% endblock %} diff --git a/src/Bundle/ChillEventBundle/Resources/views/Participation/edit.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Participation/edit.html.twig index 19592526e..db716b3dc 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Participation/edit.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Participation/edit.html.twig @@ -3,6 +3,7 @@ {% import 'ChillPersonBundle:Person:macro.html.twig' as person_macro %} {% block event_content -%} +

    {{ 'Participation Edit'|trans }}

    {{ 'Person'|trans }}
    @@ -42,4 +43,5 @@ {{ form_end(form) }} + {% endblock %} diff --git a/src/Bundle/ChillEventBundle/Resources/views/Participation/new-multiple.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Participation/new-multiple.html.twig index a0551ff1a..224b7265f 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Participation/new-multiple.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Participation/new-multiple.html.twig @@ -18,7 +18,7 @@ {% block event_content -%}

    {{ 'Participation creation'|trans }}

    -
    +
    @@ -30,7 +30,7 @@ {% include 'ChillEventBundle:Participation:_ignored_participations.html.twig' with ignored_participations %} {{ form_start(form) }} -
    {{ 'Associated event'|trans }}
    +
    diff --git a/src/Bundle/ChillEventBundle/Resources/views/Participation/new.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Participation/new.html.twig index 33f7bc213..3fbea8b68 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Participation/new.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Participation/new.html.twig @@ -5,6 +5,7 @@ {% block title 'Participation creation'|trans %} {% block event_content -%} +

    {{ 'Participation creation'|trans }}

    {{ 'Person'|trans }}
    @@ -43,5 +44,5 @@ {{ form_end(form) }} - + {% endblock %} diff --git a/src/Bundle/ChillEventBundle/Resources/views/layout.html.twig b/src/Bundle/ChillEventBundle/Resources/views/layout.html.twig index 45eb6e481..e34a10e18 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/layout.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/layout.html.twig @@ -16,9 +16,9 @@ * along with this program. If not, see . #} -{% extends "@ChillMain/layoutWithVerticalMenu.html.twig" %} +{% extends "@ChillMain/layout.html.twig" %} -{% block layout_wvm_content %} +{% block content %} {% block event_content %}

    {{ 'Event' |trans }}

    {% endblock %} diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php index 9e7938675..501af5b9d 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php @@ -144,7 +144,7 @@ class PickPersonType extends AbstractType }, $this->user->getGroupCenters()->toArray()); } else { $centers = $this->authorizationHelper - ->getReachableCenters($this->user, $options['role']); + ->getReachableCenters($this->user, $options['role']->getRole()); } if (null === $options['centers']) { From 56a7833858245059a615960c4d995e861c4b107d Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 16 Nov 2022 17:44:48 +0100 Subject: [PATCH 03/17] #16 Fix html5 widget for ChillDateTimeType --- src/Bundle/ChillMainBundle/Form/Type/ChillDateTimeType.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Form/Type/ChillDateTimeType.php b/src/Bundle/ChillMainBundle/Form/Type/ChillDateTimeType.php index 639848d9a..0063ee7d9 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/ChillDateTimeType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/ChillDateTimeType.php @@ -27,7 +27,6 @@ class ChillDateTimeType extends AbstractType { $resolver ->setDefault('date_widget', 'single_text') - ->setDefault('date_format', 'dd-MM-yyyy') ->setDefault('time_widget', 'choice') ->setDefault('minutes', range(0, 59, 5)) ->setDefault('hours', range(8, 22)) From 53980dd75720ffc52fa3e199dedd2f67defd6d0f Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 16 Nov 2022 22:30:05 +0100 Subject: [PATCH 04/17] #16 replace hardcoded country and map_center in vue add-address by symfony config yaml variables --- .../DependencyInjection/ChillMainExtension.php | 8 +++++++- .../DependencyInjection/Configuration.php | 13 ++++++++++++- .../public/vuejs/Address/components/AddAddress.vue | 7 +++++-- .../Address/components/AddAddress/AddressMap.vue | 2 +- .../components/AddAddress/CountrySelection.vue | 2 +- .../public/vuejs/Address/components/ShowPane.vue | 2 +- .../Resources/public/vuejs/Address/index.js | 3 ++- .../views/Address/_insert_vue_address.html.twig | 2 ++ 8 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php index 627841364..48a4a164c 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php @@ -142,7 +142,12 @@ class ChillMainExtension extends Extension implements 'chill_main.access_permissions_group_list', $config['access_permissions_group_list'] ); - + + $container->setParameter( + 'chill_main.add_address', + $config['add_address'] + ); + $container->setParameter( 'chill_main.routing.resources', $config['routing']['resources'] @@ -215,6 +220,7 @@ class ChillMainExtension extends Extension implements 'installation' => [ 'name' => $config['installation_name'], ], 'available_languages' => $config['available_languages'], + 'add_address' => $config['add_address'] ], 'form_themes' => ['@ChillMain/Form/fields.html.twig'], ]; diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php index d3e4da1a6..2c957296e 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php @@ -266,7 +266,18 @@ class Configuration implements ConfigurationInterface ->end() ->end() // end of root/children ->end() // end of root -; + ; + + $rootNode->children() + ->arrayNode('add_address')->children() + ->scalarNode('default_country')->cannotBeEmpty()->end() + ->arrayNode('map_center')->children() + ->scalarNode('x')->cannotBeEmpty()->end() + ->scalarNode('y')->cannotBeEmpty()->end() + ->scalarNode('z')->cannotBeEmpty()->end() + ->end() + ->end() + ; return $treeBuilder; } diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue index fcd64ed70..b47ae520d 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue @@ -309,8 +309,11 @@ export default { addressMap: { // Note: LeafletJs demands [lat, lon] // cfr https://macwright.com/lonlat/ - center : [48.8589, 2.3469], - zoom: 12 + center : [ + this.context.defaults.map_center.x, + this.context.defaults.map_center.y + ], + zoom: this.context.defaults.map_center.z }, }, errorMsg: [] diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressMap.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressMap.vue index 80d2ca01a..2422dfdce 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressMap.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressMap.vue @@ -44,7 +44,7 @@ export default { //console.log('update map with : ', this.entity.addressMap.center) if (this.marker && this.entity.addressMap.center) { this.marker.setLatLng(this.entity.addressMap.center); - this.map.setView(this.entity.addressMap.center, 15); + this.map.setView(this.entity.addressMap.center, this.entity.addressMap.zoom); } } }, diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CountrySelection.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CountrySelection.vue index 6e64b2985..e82599c77 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CountrySelection.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CountrySelection.vue @@ -30,7 +30,7 @@ export default { data() { return { value: this.selectCountryByCode( - this.context.edit ? this.entity.selected.country.code : 'FR' + this.context.edit ? this.entity.selected.country.code : this.context.defaults.default_country ) } }, diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/ShowPane.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/ShowPane.vue index 7f7b1b529..bc246d542 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/ShowPane.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/ShowPane.vue @@ -102,7 +102,7 @@ export default { ], emits: ['openEditPane'], mounted() { - console.log('context', this.context) + //console.log('context', this.context) }, computed: { address() { diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/index.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/index.js index 9241aa29d..ab0fb0bd4 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/index.js +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/index.js @@ -20,7 +20,8 @@ containers.forEach((container) => { }, edit: container.dataset.mode === 'edit', //boolean addressId: parseInt(container.dataset.addressId) || null, - backUrl: container.dataset.backUrl || null + backUrl: container.dataset.backUrl || null, + defaults: JSON.parse(container.dataset.addressDefaults) }, options: { /// Options override default. diff --git a/src/Bundle/ChillMainBundle/Resources/views/Address/_insert_vue_address.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Address/_insert_vue_address.html.twig index 571f4257f..70780eb90 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Address/_insert_vue_address.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Address/_insert_vue_address.html.twig @@ -72,6 +72,8 @@ {% if onlyButton is defined and onlyButton == 1 %} data-hide-address="true" {% endif %} + + data-address-defaults="{{ add_address|json_encode|e('html') }}" > {{ encore_entry_script_tags('vue_address') }} From e90782500b58748950693f3d19b1851a07d73d2f Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 16 Nov 2022 23:10:11 +0100 Subject: [PATCH 05/17] #16 add default value for config variables --- .../ChillMainBundle/DependencyInjection/Configuration.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php index 2c957296e..07eb53d63 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php @@ -270,11 +270,11 @@ class Configuration implements ConfigurationInterface $rootNode->children() ->arrayNode('add_address')->children() - ->scalarNode('default_country')->cannotBeEmpty()->end() + ->scalarNode('default_country')->cannotBeEmpty()->defaultValue('BE')->end() ->arrayNode('map_center')->children() - ->scalarNode('x')->cannotBeEmpty()->end() - ->scalarNode('y')->cannotBeEmpty()->end() - ->scalarNode('z')->cannotBeEmpty()->end() + ->scalarNode('x')->cannotBeEmpty()->defaultValue(50.8443)->end() + ->scalarNode('y')->cannotBeEmpty()->defaultValue(4.3523)->end() + ->scalarNode('z')->cannotBeEmpty()->defaultValue(15)->end() ->end() ->end() ; From 3ca46efd2c92d9a8ae8be508fcde1862d6a1578b Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Thu, 17 Nov 2022 16:12:30 +0100 Subject: [PATCH 06/17] #16 pass default variables to add-address component when it is called from another vue component --- .../public/vuejs/Activity/components/Location/NewLocation.vue | 3 ++- .../Resources/views/Activity/editAccompanyingCourse.html.twig | 1 + .../Resources/views/Activity/editPerson.html.twig | 1 + .../Resources/views/Activity/newAccompanyingCourse.html.twig | 1 + .../Resources/views/Activity/newPerson.html.twig | 1 + src/Bundle/ChillMainBundle/Resources/views/layout.html.twig | 1 + .../vuejs/AccompanyingCourse/components/CourseLocation.vue | 3 ++- .../public/vuejs/HouseholdMembersEditor/store/index.js | 3 +++ .../Resources/public/vuejs/_components/OnTheFly/Person.vue | 3 ++- .../Resources/views/AccompanyingCourse/edit.html.twig | 1 + .../Resources/views/Household/members_editor.html.twig | 1 + .../Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue | 3 ++- 12 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location/NewLocation.vue b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location/NewLocation.vue index 6a6289875..568c8747a 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location/NewLocation.vue +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location/NewLocation.vue @@ -117,7 +117,8 @@ export default { target: { //name, id }, edit: false, - addressId: null + addressId: null, + defaults: window.addaddress } } } diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/editAccompanyingCourse.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/editAccompanyingCourse.html.twig index d0359e223..a07fde4aa 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/editAccompanyingCourse.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/editAccompanyingCourse.html.twig @@ -22,6 +22,7 @@ '{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}'); }); window.activity = {{ activity_json|json_encode|raw }}; + window.addaddress = {{ add_address|json_encode|raw }}; {{ encore_entry_script_tags('vue_activity') }} {% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/editPerson.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/editPerson.html.twig index 91b3867c1..efb511bab 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/editPerson.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/editPerson.html.twig @@ -37,6 +37,7 @@ '{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}'); }); window.activity = {{ activity_json|json_encode|raw }}; + window.addaddress = {{ add_address|json_encode|raw }}; {{ encore_entry_script_tags('vue_activity') }} {% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/newAccompanyingCourse.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/newAccompanyingCourse.html.twig index 47a61bd86..05a92fb5a 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/newAccompanyingCourse.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/newAccompanyingCourse.html.twig @@ -18,6 +18,7 @@ {{ encore_entry_script_tags('mod_async_upload') }} {{ encore_entry_script_tags('vue_activity') }} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/newPerson.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/newPerson.html.twig index d57fc3412..f1a13b61f 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/newPerson.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/newPerson.html.twig @@ -21,6 +21,7 @@ '{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}'); }); window.activity = {{ activity_json|json_encode|raw }}; + window.addaddress = {{ add_address|json_encode|raw }}; {{ encore_entry_script_tags('vue_activity') }} {% endblock %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig b/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig index 5543809fc..cafe8dd0d 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig @@ -109,6 +109,7 @@ }); chill.categoryLinkParentChildSelect(); }); + window.addaddress = {{ add_address|json_encode|raw }}; {% block js %}{% endblock %} diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue index 42f974dd1..99e3519f4 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue @@ -164,7 +164,8 @@ export default { id: this.accompanyingCourse.id }, edit: false, - addressId: null + addressId: null, + defaults: window.addaddress } if (this.accompanyingCourse.location) { context['edit'] = true; diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/store/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/store/index.js index f3801576d..bbdde0dfa 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/store/index.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/store/index.js @@ -5,6 +5,7 @@ import { fetchHouseholdByAddressReference } from 'ChillPersonAssets/lib/househol import { datetimeToISO, dateToISO, ISOToDate } from 'ChillMainAssets/chill/js/date.js'; const debug = process.env.NODE_ENV !== 'production'; +//console.log('AJAJAJA', window.addaddress); const concerned = window.household_members_editor_data.persons.map(p => { return { @@ -115,6 +116,7 @@ const store = createStore({ name: state.household.type, id: state.household.id }, + defaults: window.addaddress, suggestions: state.addressesSuggestion }; } else { @@ -125,6 +127,7 @@ const store = createStore({ name: state.household.type, id: state.household.id }, + defaults: window.addaddress, }; } }, diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue index 4f8909233..646d92b35 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue @@ -201,7 +201,8 @@ export default { context: { target: {}, // boilerplate for getting the address id edit: false, - addressId: null + addressId: null, + defaults: window.addaddress } }, errors: [] diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/edit.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/edit.html.twig index b3520349b..4197f6418 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/edit.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/edit.html.twig @@ -10,6 +10,7 @@ {{ encore_entry_script_tags('vue_accourse') }} {% endblock %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Household/members_editor.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Household/members_editor.html.twig index 8b0134f6b..12d1ddf57 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Household/members_editor.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Household/members_editor.html.twig @@ -19,6 +19,7 @@ {{ encore_entry_script_tags('vue_household_members_editor') }} {% endblock %} diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue index 0ea011dc4..765d67fe8 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue +++ b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue @@ -232,7 +232,8 @@ export default { id: this.id }, edit: false, - addressId: null + addressId: null, + defaults: window.addaddress }; if ( !(this.thirdparty.address === undefined || this.thirdparty.address === null) && this.thirdparty.address.address_id !== null From 8894491dac7162f2341fd1764f53df1218e931f8 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Thu, 17 Nov 2022 21:43:03 +0100 Subject: [PATCH 07/17] #16 fix error with vue_activity component in person context (when accompanyingPeriod is null) --- .../Resources/public/vuejs/Activity/store.js | 2 +- .../Resources/public/vuejs/Activity/store.locations.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js index ca56a5dae..9f710abeb 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js @@ -30,7 +30,7 @@ const store = createStore({ }, getters: { suggestedEntities(state) { - if (typeof state.activity.accompanyingPeriod === "undefined") { + if (typeof state.activity.accompanyingPeriod === "undefined" || state.activity.accompanyingPeriod === null) { return []; } const allEntities = [ diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.locations.js b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.locations.js index 6125140a5..051f0b4f6 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.locations.js +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.locations.js @@ -39,6 +39,9 @@ const makeConcernedThirdPartiesLocation = (locationType, store) => { return locations; }; const makeAccompanyingPeriodLocation = (locationType, store) => { + if (store.state.activity.accompanyingPeriod === null) { + return {}; + } const accPeriodLocation = store.state.activity.accompanyingPeriod.location; return { type: 'location', From 448d93cd029c1a72d541786323b7e8e34597339b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 18 Nov 2022 16:11:03 +0100 Subject: [PATCH 08/17] Fixed: [address] Add missing window.addaddress in person create page, and third party create and update page --- .../Resources/public/vuejs/Address/mod_input_address_index.js | 2 +- .../ChillPersonBundle/Resources/views/Person/create.html.twig | 3 +++ .../Resources/views/ThirdParty/new.html.twig | 3 +++ .../Resources/views/ThirdParty/update.html.twig | 3 +++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/mod_input_address_index.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/mod_input_address_index.js index cb7da6e07..6e9fd917c 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/mod_input_address_index.js +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/mod_input_address_index.js @@ -19,7 +19,6 @@ const addAddressInput = (inputs) => { if (container === null) { throw Error("no container"); } - console.log('useValidFrom', el.dataset.useValidFrom === '1'); const app = createApp({ template: ``, @@ -34,6 +33,7 @@ const addAddressInput = (inputs) => { }, edit: isEdit, addressId: addressIdInt, + defaults: window.addaddress, }, options: { /// Options override default. diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig index 03bece4d5..a731016b9 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig @@ -143,6 +143,9 @@ {{ encore_entry_script_tags('page_suggest_names') }} {{ encore_entry_script_tags('page_create_person') }} {{ encore_entry_script_tags('mod_input_address') }} + {% endblock js %} {% block css %} diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/new.html.twig b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/new.html.twig index 09a38c14f..dea9def7d 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/new.html.twig +++ b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/new.html.twig @@ -22,6 +22,9 @@ {% block js %} {{ encore_entry_script_tags('mod_input_address') }} + {% endblock %} {% block css %} diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/update.html.twig b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/update.html.twig index 2d9c39002..84de129bb 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/update.html.twig +++ b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/update.html.twig @@ -38,6 +38,9 @@ {% block js %} {{ encore_entry_script_tags('mod_input_address') }} + {% endblock %} {% block css %} From cd54fdd13f620e5d43a410ba1d88ac54a716e0d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 18 Nov 2022 16:12:49 +0100 Subject: [PATCH 09/17] Feature: [activity] automatically add a person to an activity, if created in the person context See https://gitlab.com/Chill-Projet/chill-bundles/-/issues/28 --- src/Bundle/ChillActivityBundle/Controller/ActivityController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index c7908fcaf..d76bffe80 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -359,6 +359,7 @@ final class ActivityController extends AbstractController if ($person instanceof Person) { $entity->setPerson($person); + $entity->getPersons()->add($person); } if ($accompanyingPeriod instanceof AccompanyingPeriod) { From d35dacf5627ce58aaccbdbec18293c2059870088 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sun, 20 Nov 2022 21:27:19 +0100 Subject: [PATCH 10/17] Fixed: [budget] Fix voter on household's budget --- .../ChillBudgetBundle/Entity/Charge.php | 18 +++++++------ .../ChillBudgetBundle/Entity/Resource.php | 18 +++++++------ .../Authorization/BudgetElementVoter.php | 25 ++++++++++++++++--- 3 files changed, 41 insertions(+), 20 deletions(-) diff --git a/src/Bundle/ChillBudgetBundle/Entity/Charge.php b/src/Bundle/ChillBudgetBundle/Entity/Charge.php index dc03eef80..eab153b2e 100644 --- a/src/Bundle/ChillBudgetBundle/Entity/Charge.php +++ b/src/Bundle/ChillBudgetBundle/Entity/Charge.php @@ -11,8 +11,8 @@ declare(strict_types=1); namespace Chill\BudgetBundle\Entity; -use Chill\MainBundle\Entity\Center; -use Chill\MainBundle\Entity\HasCenterInterface; +use Chill\MainBundle\Entity\HasCentersInterface; +use Chill\PersonBundle\Entity\Person; use DateTimeImmutable; use Doctrine\ORM\Mapping as ORM; @@ -22,7 +22,7 @@ use Doctrine\ORM\Mapping as ORM; * @ORM\Table(name="chill_budget.charge") * @ORM\Entity(repositoryClass="Chill\BudgetBundle\Repository\ChargeRepository") */ -class Charge extends AbstractElement implements HasCenterInterface +class Charge extends AbstractElement implements HasCentersInterface { public const HELP_ASKED = 'running'; @@ -46,22 +46,24 @@ class Charge extends AbstractElement implements HasCenterInterface private $help = self::HELP_NOT_RELEVANT; /** - * @var int - * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ - private $id; + private ?int $id = null; public function __construct() { $this->setStartDate(new DateTimeImmutable('today')); } - public function getCenter(): ?Center + public function getCenters(): array { - return $this->getPerson()->getCenter(); + if (null !== $this->getPerson()) { + return [$this->getPerson()->getCenter()]; + } + + return $this->getHousehold()->getCurrentPersons()->map(static fn (Person $p) => $p->getCenter())->toArray(); } public function getHelp() diff --git a/src/Bundle/ChillBudgetBundle/Entity/Resource.php b/src/Bundle/ChillBudgetBundle/Entity/Resource.php index 949872d6c..bed9f23c3 100644 --- a/src/Bundle/ChillBudgetBundle/Entity/Resource.php +++ b/src/Bundle/ChillBudgetBundle/Entity/Resource.php @@ -11,8 +11,8 @@ declare(strict_types=1); namespace Chill\BudgetBundle\Entity; -use Chill\MainBundle\Entity\Center; -use Chill\MainBundle\Entity\HasCenterInterface; +use Chill\MainBundle\Entity\HasCentersInterface; +use Chill\PersonBundle\Entity\Person; use DateTimeImmutable; use Doctrine\ORM\Mapping as ORM; @@ -22,25 +22,27 @@ use Doctrine\ORM\Mapping as ORM; * @ORM\Table(name="chill_budget.resource") * @ORM\Entity(repositoryClass="Chill\BudgetBundle\Repository\ResourceRepository") */ -class Resource extends AbstractElement implements HasCenterInterface +class Resource extends AbstractElement implements HasCentersInterface { /** - * @var int - * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ - private $id; + private ?int $id = null; public function __construct() { $this->setStartDate(new DateTimeImmutable('today')); } - public function getCenter(): ?Center + public function getCenters(): array { - return $this->getPerson()->getCenter(); + if (null !== $this->getPerson()) { + return [$this->getPerson()->getCenter()]; + } + + return $this->getHousehold()->getCurrentPersons()->map(static fn (Person $p) => $p->getCenter())->toArray(); } /** diff --git a/src/Bundle/ChillBudgetBundle/Security/Authorization/BudgetElementVoter.php b/src/Bundle/ChillBudgetBundle/Security/Authorization/BudgetElementVoter.php index 0a428d324..5203f9092 100644 --- a/src/Bundle/ChillBudgetBundle/Security/Authorization/BudgetElementVoter.php +++ b/src/Bundle/ChillBudgetBundle/Security/Authorization/BudgetElementVoter.php @@ -20,7 +20,7 @@ use Chill\PersonBundle\Entity\Household\Household; use Chill\PersonBundle\Entity\Person; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; -use function in_array; +use UnexpectedValueException; class BudgetElementVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface { @@ -68,12 +68,29 @@ class BudgetElementVoter extends AbstractChillVoter implements ProvideRoleHierar protected function supports($attribute, $subject) { - return (in_array($attribute, self::ROLES, true) && $subject instanceof AbstractElement) - || (($subject instanceof Person || $subject instanceof Household) && in_array($attribute, [self::SEE, self::CREATE], true)); + return $this->voter->supports($attribute, $subject); } protected function voteOnAttribute($attribute, $subject, TokenInterface $token) { - return $this->voter->voteOnAttribute($attribute, $subject, $token); + if ( + $subject instanceof Person + || ($subject instanceof AbstractElement && null !== $person = $subject->getPerson())) { + return $this->voter->voteOnAttribute($attribute, $person ?? $subject, $token); + } + + if ( + $subject instanceof Household + || ($subject instanceof AbstractElement && null !== $household = $subject->getHousehold())) { + foreach (($household ?? $subject)->getCurrentPersons() as $person) { + if ($this->voter->voteOnAttribute($attribute, $person, $token)) { + return true; + } + } + + return false; + } + + throw new UnexpectedValueException('This subject is not supported, or is an element not associated with person or household'); } } From d3e784de152a5fb9cb2c71f819962b57b19835a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sun, 20 Nov 2022 21:28:07 +0100 Subject: [PATCH 11/17] DX: fix cs --- .../DependencyInjection/ChillMainExtension.php | 6 +++--- .../DependencyInjection/Configuration.php | 17 ++++++++--------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php index 48a4a164c..7b2ed1861 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php @@ -142,12 +142,12 @@ class ChillMainExtension extends Extension implements 'chill_main.access_permissions_group_list', $config['access_permissions_group_list'] ); - + $container->setParameter( 'chill_main.add_address', $config['add_address'] ); - + $container->setParameter( 'chill_main.routing.resources', $config['routing']['resources'] @@ -220,7 +220,7 @@ class ChillMainExtension extends Extension implements 'installation' => [ 'name' => $config['installation_name'], ], 'available_languages' => $config['available_languages'], - 'add_address' => $config['add_address'] + 'add_address' => $config['add_address'], ], 'form_themes' => ['@ChillMain/Form/fields.html.twig'], ]; diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php index 07eb53d63..595321bed 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php @@ -266,18 +266,17 @@ class Configuration implements ConfigurationInterface ->end() ->end() // end of root/children ->end() // end of root - ; - +; + $rootNode->children() ->arrayNode('add_address')->children() - ->scalarNode('default_country')->cannotBeEmpty()->defaultValue('BE')->end() - ->arrayNode('map_center')->children() - ->scalarNode('x')->cannotBeEmpty()->defaultValue(50.8443)->end() - ->scalarNode('y')->cannotBeEmpty()->defaultValue(4.3523)->end() - ->scalarNode('z')->cannotBeEmpty()->defaultValue(15)->end() - ->end() + ->scalarNode('default_country')->cannotBeEmpty()->defaultValue('BE')->end() + ->arrayNode('map_center')->children() + ->scalarNode('x')->cannotBeEmpty()->defaultValue(50.8443)->end() + ->scalarNode('y')->cannotBeEmpty()->defaultValue(4.3523)->end() + ->scalarNode('z')->cannotBeEmpty()->defaultValue(15)->end() ->end() - ; + ->end(); return $treeBuilder; } From 1bc72213157e9ae84dd4ab283d27ec8fd65843a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 22 Dec 2022 11:21:05 +0100 Subject: [PATCH 12/17] Feature: Set defaults values for add_address configuration The default values were not set at the root of the array config. This create a default value to the array config --- .../ChillMainBundle/DependencyInjection/Configuration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php index db71d9df2..2f622878a 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php @@ -277,7 +277,7 @@ class Configuration implements ConfigurationInterface ; $rootNode->children() - ->arrayNode('add_address')->children() + ->arrayNode('add_address')->addDefaultsIfNotSet()->children() ->scalarNode('default_country')->cannotBeEmpty()->defaultValue('BE')->end() ->arrayNode('map_center')->children() ->scalarNode('x')->cannotBeEmpty()->defaultValue(50.8443)->end() From 3ca28114949022343ff38fd31ad22771c2b6697d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 22 Dec 2022 11:22:24 +0100 Subject: [PATCH 13/17] Feature: set parameters for add_address as global The parameter `window.addaddress` is now global and can be reached to all page. This ensure backward compatibility. --- .../views/Activity/editAccompanyingCourse.html.twig | 1 - .../Resources/views/Activity/editPerson.html.twig | 1 - .../views/Activity/newAccompanyingCourse.html.twig | 1 - .../Resources/views/Activity/newPerson.html.twig | 1 - src/Bundle/ChillMainBundle/Resources/views/layout.html.twig | 6 +++++- .../Resources/views/AccompanyingCourse/edit.html.twig | 1 - .../Resources/views/Household/members_editor.html.twig | 1 - .../Resources/views/Person/create.html.twig | 3 --- .../Resources/views/ThirdParty/new.html.twig | 3 --- .../Resources/views/ThirdParty/update.html.twig | 3 --- 10 files changed, 5 insertions(+), 16 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/editAccompanyingCourse.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/editAccompanyingCourse.html.twig index a07fde4aa..d0359e223 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/editAccompanyingCourse.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/editAccompanyingCourse.html.twig @@ -22,7 +22,6 @@ '{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}'); }); window.activity = {{ activity_json|json_encode|raw }}; - window.addaddress = {{ add_address|json_encode|raw }}; {{ encore_entry_script_tags('vue_activity') }} {% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/editPerson.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/editPerson.html.twig index efb511bab..91b3867c1 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/editPerson.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/editPerson.html.twig @@ -37,7 +37,6 @@ '{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}'); }); window.activity = {{ activity_json|json_encode|raw }}; - window.addaddress = {{ add_address|json_encode|raw }}; {{ encore_entry_script_tags('vue_activity') }} {% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/newAccompanyingCourse.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/newAccompanyingCourse.html.twig index 05a92fb5a..47a61bd86 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/newAccompanyingCourse.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/newAccompanyingCourse.html.twig @@ -18,7 +18,6 @@ {{ encore_entry_script_tags('mod_async_upload') }} {{ encore_entry_script_tags('vue_activity') }} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/newPerson.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/newPerson.html.twig index f1a13b61f..d57fc3412 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/newPerson.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/newPerson.html.twig @@ -21,7 +21,6 @@ '{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}'); }); window.activity = {{ activity_json|json_encode|raw }}; - window.addaddress = {{ add_address|json_encode|raw }}; {{ encore_entry_script_tags('vue_activity') }} {% endblock %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig b/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig index cafe8dd0d..319adad81 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig @@ -9,6 +9,11 @@ {% block head_custom %}{% endblock %} + + {{ encore_entry_link_tags('mod_bootstrap') }} {{ encore_entry_link_tags('mod_forkawesome') }} {{ encore_entry_link_tags('mod_ckeditor5') }} @@ -109,7 +114,6 @@ }); chill.categoryLinkParentChildSelect(); }); - window.addaddress = {{ add_address|json_encode|raw }}; {% block js %}{% endblock %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/edit.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/edit.html.twig index 4197f6418..b3520349b 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/edit.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/edit.html.twig @@ -10,7 +10,6 @@ {{ encore_entry_script_tags('vue_accourse') }} {% endblock %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Household/members_editor.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Household/members_editor.html.twig index 12d1ddf57..8b0134f6b 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Household/members_editor.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Household/members_editor.html.twig @@ -19,7 +19,6 @@ {{ encore_entry_script_tags('vue_household_members_editor') }} {% endblock %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig index a731016b9..03bece4d5 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig @@ -143,9 +143,6 @@ {{ encore_entry_script_tags('page_suggest_names') }} {{ encore_entry_script_tags('page_create_person') }} {{ encore_entry_script_tags('mod_input_address') }} - {% endblock js %} {% block css %} diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/new.html.twig b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/new.html.twig index dea9def7d..09a38c14f 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/new.html.twig +++ b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/new.html.twig @@ -22,9 +22,6 @@ {% block js %} {{ encore_entry_script_tags('mod_input_address') }} - {% endblock %} {% block css %} diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/update.html.twig b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/update.html.twig index 84de129bb..2d9c39002 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/update.html.twig +++ b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/update.html.twig @@ -38,9 +38,6 @@ {% block js %} {{ encore_entry_script_tags('mod_input_address') }} - {% endblock %} {% block css %} From ad94c7bcb7bc7236b107058c9fb531d870eb0ff7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 22 Dec 2022 11:22:49 +0100 Subject: [PATCH 14/17] DX: Fix CS and type hinting --- .../Widget/AddWidgetConfigurationTrait.php | 6 ++---- src/Bundle/ChillPersonBundle/Entity/Person.php | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AddWidgetConfigurationTrait.php b/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AddWidgetConfigurationTrait.php index 468314159..ea2a66c13 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AddWidgetConfigurationTrait.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AddWidgetConfigurationTrait.php @@ -136,11 +136,9 @@ trait AddWidgetConfigurationTrait /** * add configuration nodes for the widget at the given place. * - * @param type $place - * - * @return type + * @param string $place */ - protected function addWidgetsConfiguration($place, ContainerBuilder $containerBuilder) + protected function addWidgetsConfiguration(string $place, ContainerBuilder $containerBuilder) { $treeBuilder = new TreeBuilder($place); $root = $treeBuilder->getRootNode($place) diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index 3843a960f..4e2bd4e89 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -1581,7 +1581,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI return $this; } - $this->centerHistory[] = new PersonCenterHistory($this, $center, $modification); + $this->centerHistory[] = new PersonCenterHistory($this, $center, $modification); return $this; } From 6a14c2b9b36494fdf974d5bb9f06e4b5285619a3 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 12 Dec 2022 16:37:06 +0100 Subject: [PATCH 15/17] Fixed: [vue][add-address] fix map center when editing existing address https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/674 --- .../vuejs/Address/components/AddAddress/AddressMap.vue | 9 ++++++++- .../Address/components/AddAddress/AddressSelection.vue | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressMap.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressMap.vue index 2422dfdce..cbb8cb0c7 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressMap.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressMap.vue @@ -19,7 +19,7 @@ export default { }, computed: { center() { - return this.entity.selected.addressMap.center; + return this.entity.addressMap.center; }, }, methods:{ @@ -41,10 +41,17 @@ export default { this.marker.addTo(this.map); }, update() { +/*<<<<<<< HEAD //console.log('update map with : ', this.entity.addressMap.center) if (this.marker && this.entity.addressMap.center) { this.marker.setLatLng(this.entity.addressMap.center); this.map.setView(this.entity.addressMap.center, this.entity.addressMap.zoom); +=======*/ + console.log('update map with : ', this.center) + if (this.marker && this.center) { + this.marker.setLatLng(this.center); + this.map.setView(this.center, 15); +//>>>>>>> 52512e45f (Fixed: [vue][add-address] fix map center when editing existing address) } } }, diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressSelection.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressSelection.vue index 2c8e17687..bc5adbc89 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressSelection.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressSelection.vue @@ -98,6 +98,11 @@ export default { } }, }, + mounted() { + if (this.value.point) { + this.updateMapCenter(this.value.point); + } + }, methods: { transName(value) { return value.streetNumber === undefined ? value.street : `${value.streetNumber}, ${value.street}` From ce17f5f5c00bbc75145abf272146b87dc11ebb1e Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 13 Dec 2022 11:45:32 +0100 Subject: [PATCH 16/17] Fixed: [vue][add-address] fix map center when editing existing address (corrections post review) https://gitlab.com/Chill-Projet/chill-bundles/-/commit/52512e45fcb0c02c011f8f7bf3f0aa38c18da52c#note_1205935758 --- .../vuejs/Address/components/AddAddress/AddressSelection.vue | 2 +- .../vuejs/Address/components/AddAddress/CitySelection.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressSelection.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressSelection.vue index bc5adbc89..f1cac5254 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressSelection.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressSelection.vue @@ -99,7 +99,7 @@ export default { }, }, mounted() { - if (this.value.point) { + if (typeof this.value.point !== 'undefined') { this.updateMapCenter(this.value.point); } }, diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CitySelection.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CitySelection.vue index 292b0de16..ca10285d1 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CitySelection.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CitySelection.vue @@ -104,7 +104,7 @@ export default { this.entity.selected.postcode.name = this.value.name; this.entity.selected.postcode.code = this.value.code; this.$emit('getReferenceAddresses', this.value); - if (this.value.center) { + if (typeof this.value.center !== 'undefined') { this.updateMapCenter(this.value.center); if (this.value.center.coordinates) { this.entity.selected.postcode.coordinates = this.value.center.coordinates; From 4d3d9db1b33148b00eebac30122393b1041ca23e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 22 Dec 2022 19:29:56 +0100 Subject: [PATCH 17/17] Fixed: Fix map center on opening or editing address --- .../vuejs/Address/components/AddAddress.vue | 4 +- .../components/AddAddress/AddressMap.vue | 68 ++++++++++++++----- .../AddAddress/AddressSelection.vue | 5 -- .../AddAddress/CountrySelection.vue | 12 ++-- .../vuejs/Address/components/EditPane.vue | 4 +- 5 files changed, 61 insertions(+), 32 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue index b47ae520d..30a240938 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue @@ -310,8 +310,8 @@ export default { // Note: LeafletJs demands [lat, lon] // cfr https://macwright.com/lonlat/ center : [ - this.context.defaults.map_center.x, - this.context.defaults.map_center.y + this.context.defaults.map_center.x, + this.context.defaults.map_center.y, ], zoom: this.context.defaults.map_center.z }, diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressMap.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressMap.vue index cbb8cb0c7..d3c04260f 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressMap.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressMap.vue @@ -8,8 +8,12 @@ import L from 'leaflet'; import markerIconPng from 'leaflet/dist/images/marker-icon.png' import 'leaflet/dist/leaflet.css'; +const lonLatForLeaflet = (coordinates) => { + return [coordinates[1], coordinates[0]]; +} + export default { - name: 'AddressMap', + name: 'AddressMap', props: ['entity'], data() { return { @@ -21,10 +25,47 @@ export default { center() { return this.entity.addressMap.center; }, + hasAddressPoint() { + if (Object.keys(this.entity.address).length === 0) { + return false; + } + if (null !== this.entity.address.addressReference) { + return true; + } + if (null !== this.entity.address.postcode && null !== this.entity.address.postcode.center) { + return true; + } + return false; + }, + /** + * + * @returns {coordinates: [float, float], type: "Point"} + */ + addressPoint() { + if (Object.keys(this.entity.address).length === 0) { + return null; + } + + if (null !== this.entity.address.addressReference) { + return this.entity.address.addressReference.point; + } + + if (null !== this.entity.address.postcode && null !== this.entity.address.postcode.center) { + return this.entity.address.postcode.center; + } + + return null; + }, }, methods:{ init() { - this.map = L.map('address_map').setView([46.67059, -1.42683], 12); + this.map = L.map('address_map'); + + if (!this.hasAddressPoint) { + this.map.setView(lonLatForLeaflet(this.entity.addressMap.center), this.entity.addressMap.zoom); + } else { + this.map.setView(lonLatForLeaflet(this.addressPoint.coordinates), 15); + } this.map.scrollWheelZoom.disable(); @@ -37,27 +78,22 @@ export default { iconAnchor: [12, 41], }); - this.marker = L.marker([48.8589, 2.3469], {icon: markerIcon}); + if (!this.hasAddressPoint) { + this.marker = L.marker(lonLatForLeaflet(this.entity.addressMap.center), {icon: markerIcon}); + } else { + this.marker = L.marker(lonLatForLeaflet(this.addressPoint.coordinates), {icon: markerIcon}); + } this.marker.addTo(this.map); }, update() { -/*<<<<<<< HEAD - //console.log('update map with : ', this.entity.addressMap.center) if (this.marker && this.entity.addressMap.center) { - this.marker.setLatLng(this.entity.addressMap.center); - this.map.setView(this.entity.addressMap.center, this.entity.addressMap.zoom); -=======*/ - console.log('update map with : ', this.center) - if (this.marker && this.center) { - this.marker.setLatLng(this.center); - this.map.setView(this.center, 15); -//>>>>>>> 52512e45f (Fixed: [vue][add-address] fix map center when editing existing address) + this.marker.setLatLng(lonLatForLeaflet(this.entity.addressMap.center)); + this.map.panTo(lonLatForLeaflet(this.entity.addressMap.center)); } } }, - mounted(){ + mounted() { this.init(); - this.update(); - } + }, } diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressSelection.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressSelection.vue index f1cac5254..2c8e17687 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressSelection.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressSelection.vue @@ -98,11 +98,6 @@ export default { } }, }, - mounted() { - if (typeof this.value.point !== 'undefined') { - this.updateMapCenter(this.value.point); - } - }, methods: { transName(value) { return value.streetNumber === undefined ? value.street : `${value.streetNumber}, ${value.street}` diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CountrySelection.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CountrySelection.vue index e82599c77..1b220ff00 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CountrySelection.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CountrySelection.vue @@ -45,14 +45,12 @@ export default { }, }, mounted() { - this.init(); + console.log('country selection mounted', this.value); + if (this.value !== undefined) { + this.selectCountry(this.value); + } }, - methods: { - init() { - if (this.value !== undefined) { - this.selectCountry(this.value); - } - }, + methods: { selectCountryByCode(countryCode) { return this.entity.loaded.countries.filter(c => c.countryCode === countryCode)[0]; }, diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/EditPane.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/EditPane.vue index 9636a173f..4ab117395 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/EditPane.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/EditPane.vue @@ -174,8 +174,8 @@ export default { }, updateMapCenter(point) { console.log('point', point); - this.addressMap.center[0] = point.coordinates[1]; // TODO use reverse() - this.addressMap.center[1] = point.coordinates[0]; + this.addressMap.center[0] = point.coordinates[0]; + this.addressMap.center[1] = point.coordinates[1]; this.$refs.addressMap.update(); // cast child methods } }