From 9623a35e6fa98b233a876409709ac4e15c0a4785 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 16 Nov 2022 10:57:06 +0100 Subject: [PATCH 01/60] #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/60] #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/60] #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/60] #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/60] #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/60] #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/60] #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/60] 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/60] 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/60] 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/60] 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 58ede06dfeda9c3e78b042d72f6db8e2a8da7ec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 14 Dec 2022 13:37:49 +0100 Subject: [PATCH 12/60] Fixed: show list of workflow, event if some social action associated to a workflow are deleted --- .../_accompanying_period_work.html.twig | 38 +++++++++++-------- .../AccompanyingPeriodWorkWorkflowHandler.php | 4 ++ .../translations/messages.fr.yml | 1 + 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_accompanying_period_work.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_accompanying_period_work.html.twig index 57cf503b8..17ecb9072 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_accompanying_period_work.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Workflow/_accompanying_period_work.html.twig @@ -1,17 +1,23 @@ -
    - {% include '@ChillPerson/AccompanyingCourseWork/_item.html.twig' with { - 'w': work, - 'itemBlocClass': 'bg-chill-llight-gray' - } %} -
    +{% if work is null %} +
    + {{ 'workflow.SocialAction deleted'|trans }} +
    +{% else %} +
    + {% include '@ChillPerson/AccompanyingCourseWork/_item.html.twig' with { + 'w': work, + 'itemBlocClass': 'bg-chill-llight-gray' + } %} +
    -{% if display_action is defined and display_action == true %} - -{% endif %} \ No newline at end of file + {% if display_action is defined and display_action == true %} + + {% endif %} +{% endif %} diff --git a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php index 776eb1462..b6829ab77 100644 --- a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php +++ b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php @@ -56,6 +56,10 @@ class AccompanyingPeriodWorkWorkflowHandler implements EntityWorkflowHandlerInte { $work = $this->getRelatedEntity($entityWorkflow); + if (null === $work) { + return $this->translator->trans('workflow.SocialAction deleted'); + } + return $this->translator->trans('workflow.Work (n°%w%)', ['%w%' => $entityWorkflow->getRelatedEntityId()]) . ' - ' . $this->translatableStringHelper->localize($work->getSocialAction()->getTitle()); diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 7c9afba48..d76d7c2a9 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -967,6 +967,7 @@ Number of periods: Nombre de parcours workflow: Doc for evaluation (n°%eval%): Document de l'évaluation n°%eval% doc for evaluation deleted: Document supprimé dans une évaluation + SocialAction deleted: Action sociale supprimée period_by_user_list: Period by user: Parcours d'accompagnement par utilisateur From ba261ddeb9059dea15710e8bc8d7766ce76d2d95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 14 Dec 2022 13:52:37 +0100 Subject: [PATCH 13/60] Fixed: show list of workflow, event if some accompanying course document associated to a workflow are deleted --- .../_workflow.html.twig | 106 ++++++++++-------- ...ompanyingCourseDocumentWorkflowHandler.php | 4 + .../translations/messages.fr.yml | 3 + 3 files changed, 64 insertions(+), 49 deletions(-) diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/_workflow.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/_workflow.html.twig index e9147ed4a..299183cca 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/_workflow.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/_workflow.html.twig @@ -1,64 +1,72 @@ {% import "@ChillDocStore/Macro/macro.html.twig" as m %} {% import "@ChillDocStore/Macro/macro_mimeicon.html.twig" as mm %} -
    -
    -
    -
    - -
    -
    -

    {{ document.title }}

    +{% if document is null %} +
    + {{ 'workflow.Document deleted'|trans }} +
    +{% else %} +
    +
    +
    +
    + +
    +
    +

    {{ document.title }}

    - {{ mm.mimeIcon(document.object.type) }} + {{ mm.mimeIcon(document.object.type) }} - {% if document.description is not empty %} -
    - {{ document.description }} -
    - {% endif %} + {% if document.description is not empty %} +
    + {{ document.description }} +
    + {% endif %} +
    -
    -{% set freezed = false %} -{% for step in entity_workflow.stepsChained %} - {% if loop.last %} - {% if step.previous is not null and step.previous.freezeAfter == true %} - {% set freezed = true %} - {% endif %} - {% endif %} -{% endfor %} - -{% if display_action is defined and display_action == true %} -
      - {% if document.course != null and is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_SEE', document.course) %} -
    • - - {{ 'Course number'|trans }} {{ document.course.id }} - -
    • - {% endif %} -
    • - {{ m.download_button(document.object, document.title) }} -
    • -
    • - {% if chill_document_is_editable(document.object) %} - {% if not freezed %} - {{ document.object|chill_document_edit_button({'title': document.title|e('html') }) }} - {% else %} - - {{ 'Update document'|trans }} - + {% set freezed = false %} + {% for step in entity_workflow.stepsChained %} + {% if loop.last %} + {% if step.previous is not null and step.previous.freezeAfter == true %} + {% set freezed = true %} {% endif %} {% endif %} - {% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_SEE', document) and document.course != null %} + {% endfor %} + + {% if display_action is defined and display_action == true %} + + {% if chill_document_is_editable(document.object) %} + {% if not freezed %} +
    • + {{ document.object|chill_document_edit_button({'title': document.title|e('html') }) }} +
    • + {% else %} +
    • + + {{ 'Update document'|trans }} + +
    • + {% endif %} + {% endif %} + {% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_SEE', document) and document.course != null %} +
    • + +
    • + {% endif %} +
    + {% endif %} {% endif %} diff --git a/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php b/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php index 8e94dbd83..96787a6fc 100644 --- a/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php +++ b/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php @@ -65,6 +65,10 @@ class AccompanyingCourseDocumentWorkflowHandler implements EntityWorkflowHandler { $doc = $this->getRelatedEntity($entityWorkflow); + if (null === $doc) { + return $this->translator->trans('workflow.Document deleted'); + } + return $this->translator->trans('workflow.Document (n°%doc%)', ['%doc%' => $entityWorkflow->getRelatedEntityId()]) . ' - ' . $doc->getTitle(); } diff --git a/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml b/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml index 17326b299..400e37236 100644 --- a/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml @@ -63,3 +63,6 @@ Create new DocumentCategory: Créer une nouvelle catégorie de document # WOPI EDIT online_edit_document: Éditer en ligne + +workflow: + Document deleted: Document supprimé From 1585a739747c8575103169c66ccf3ec3a2148238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 22 Nov 2022 11:12:44 +0100 Subject: [PATCH 14/60] DX: [authorization helper] Create an authorization helper with current user already available See https://gitlab.com/Chill-Projet/chill-bundles/-/issues/14 --- .../AuthorizationHelperForCurrentUser.php | 46 +++++++++++++++++++ ...orizationHelperForCurrentUserInterface.php | 28 +++++++++++ 2 files changed, 74 insertions(+) create mode 100644 src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelperForCurrentUser.php create mode 100644 src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelperForCurrentUserInterface.php diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelperForCurrentUser.php b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelperForCurrentUser.php new file mode 100644 index 000000000..da9c285bd --- /dev/null +++ b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelperForCurrentUser.php @@ -0,0 +1,46 @@ +authorizationHelper = $authorizationHelper; + $this->security = $security; + } + + public function getReachableCenters(string $role, ?Scope $scope = null): array + { + if (!$this->security->getUser() instanceof User) { + return []; + } + + return $this->authorizationHelper->getReachableCenters($this->security->getUser(), $role, $scope); + } + + public function getReachableScopes(string $role, $center): array + { + if (!$this->security->getUser() instanceof User) { + return []; + } + + return $this->authorizationHelper->getReachableScopes($this->security->getUser(), $role, $center); + } +} diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelperForCurrentUserInterface.php b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelperForCurrentUserInterface.php new file mode 100644 index 000000000..cd3459aa9 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelperForCurrentUserInterface.php @@ -0,0 +1,28 @@ + Date: Tue, 22 Nov 2022 11:18:33 +0100 Subject: [PATCH 15/60] Feature: [person][creation] api for listing availables centers for person creation --- .../config/services/security.yaml | 5 +++ .../Controller/PersonApiController.php | 32 +++++++++++++--- .../AuthorizedCenterOnPersonCreation.php | 38 +++++++++++++++++++ ...horizedCenterOnPersonCreationInterface.php | 22 +++++++++++ .../ChillPersonBundle/chill.api.specs.yaml | 12 +++++- .../config/services/controller.yaml | 5 +-- .../config/services/security.yaml | 6 +++ 7 files changed, 111 insertions(+), 9 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Security/AuthorizedCenterOnPersonCreation.php create mode 100644 src/Bundle/ChillPersonBundle/Security/AuthorizedCenterOnPersonCreationInterface.php diff --git a/src/Bundle/ChillMainBundle/config/services/security.yaml b/src/Bundle/ChillMainBundle/config/services/security.yaml index 824144470..c0d9f98b9 100644 --- a/src/Bundle/ChillMainBundle/config/services/security.yaml +++ b/src/Bundle/ChillMainBundle/config/services/security.yaml @@ -3,6 +3,11 @@ services: autowire: true autoconfigure: true + Chill\MainBundle\Security\: + autoconfigure: true + autowire: true + resource: '../../Security' + Chill\MainBundle\Security\Resolver\CenterResolverDispatcher: arguments: - !tagged_iterator chill_main.center_resolver diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php index 745a64240..bf0d998ff 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php @@ -13,12 +13,13 @@ namespace Chill\PersonBundle\Controller; use Chill\MainBundle\CRUD\Controller\ApiController; use Chill\MainBundle\Entity\Address; -use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper; use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Security\Authorization\PersonVoter; +use Chill\PersonBundle\Security\AuthorizedCenterOnPersonCreationInterface; use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; @@ -26,16 +27,37 @@ use function in_array; class PersonApiController extends ApiController { - private AuthorizationHelper $authorizationHelper; + private AuthorizedCenterOnPersonCreationInterface $authorizedCenterOnPersonCreation; private ConfigPersonAltNamesHelper $configPersonAltNameHelper; + private bool $showCenters; + public function __construct( - AuthorizationHelper $authorizationHelper, - ConfigPersonAltNamesHelper $configPersonAltNameHelper + AuthorizedCenterOnPersonCreationInterface $authorizedCenterOnPersonCreation, + ConfigPersonAltNamesHelper $configPersonAltNameHelper, + ParameterBagInterface $parameterBag ) { - $this->authorizationHelper = $authorizationHelper; + $this->authorizedCenterOnPersonCreation = $authorizedCenterOnPersonCreation; $this->configPersonAltNameHelper = $configPersonAltNameHelper; + $this->showCenters = $parameterBag->get('chill_main')['acl']['form_show_centers']; + } + + /** + * @Route("/api/1.0/person/creation/authorized-centers", + * name="chill_person_person_creation_authorized_centers" + * ) + */ + public function authorizedCentersForCreation(): Response + { + $centers = $this->authorizedCenterOnPersonCreation->getCenters(); + + return $this->json( + ['showCenters' => $this->showCenters, 'centers' => $centers], + Response::HTTP_OK, + [], + ['gropus' => ['read']] + ); } /** diff --git a/src/Bundle/ChillPersonBundle/Security/AuthorizedCenterOnPersonCreation.php b/src/Bundle/ChillPersonBundle/Security/AuthorizedCenterOnPersonCreation.php new file mode 100644 index 000000000..6f8800d65 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Security/AuthorizedCenterOnPersonCreation.php @@ -0,0 +1,38 @@ +authorizationHelperForCurrentUser = $authorizationHelperForCurrentUser; + $this->showCenter = $parameterBag->get('chill_main')['acl']['form_show_centers']; + } + + public function getCenters(): array + { + if (!$this->showCenter) { + return []; + } + + return $this->authorizationHelperForCurrentUser->getReachableCenters(PersonVoter::CREATE); + } +} diff --git a/src/Bundle/ChillPersonBundle/Security/AuthorizedCenterOnPersonCreationInterface.php b/src/Bundle/ChillPersonBundle/Security/AuthorizedCenterOnPersonCreationInterface.php new file mode 100644 index 000000000..d0748b8c2 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Security/AuthorizedCenterOnPersonCreationInterface.php @@ -0,0 +1,22 @@ + Date: Tue, 22 Nov 2022 22:28:18 +0100 Subject: [PATCH 16/60] Feature: [person][creation] Add center field to OnTheFly/Person --- .../ChillPersonBundle/Entity/Person.php | 8 ++- .../vuejs/HouseholdMembersEditor/index.js | 8 +++ .../Resources/public/vuejs/_api/OnTheFly.js | 5 ++ .../vuejs/_components/OnTheFly/Person.vue | 54 ++++++++++++++++--- .../Resources/public/vuejs/_js/i18n.js | 4 ++ 5 files changed, 71 insertions(+), 8 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index a477f9adb..3843a960f 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -1567,7 +1567,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * * @return $this */ - public function setCenter(Center $center): self + public function setCenter(?Center $center): self { $modification = new DateTimeImmutable('now'); @@ -1577,7 +1577,11 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI } } - $this->centerHistory[] = $new = new PersonCenterHistory($this, $center, $modification); + if (null === $center) { + return $this; + } + + $this->centerHistory[] = new PersonCenterHistory($this, $center, $modification); return $this; } diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/index.js index c9f5bb111..d2b271e17 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/index.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/index.js @@ -2,6 +2,8 @@ import { createApp } from 'vue'; import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n'; import { appMessages } from './js/i18n'; import { store } from './store'; +import VueToast from 'vue-toast-notification'; +import 'vue-toast-notification/dist/theme-sugar.css'; import App from './App.vue'; @@ -12,5 +14,11 @@ const app = createApp({ }) .use(store) .use(i18n) +.use(VueToast, { + position: "bottom-right", + type: "error", + duration: 5000, + dismissible: true +}) .component('app', App) .mount('#household_members_editor'); diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/OnTheFly.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/OnTheFly.js index 338094122..c9c77991f 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/OnTheFly.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/OnTheFly.js @@ -1,3 +1,5 @@ +import {makeFetch} from 'ChillMainAssets/lib/api/apiMethods'; + /* * GET a person by id */ @@ -22,6 +24,8 @@ const getCivilities = () => throw Error('Error with request resource response'); }); +const getCentersForPersonCreation = () => makeFetch('GET', '/api/1.0/person/creation/authorized-centers', null); + /* * POST a new person */ @@ -59,6 +63,7 @@ const patchPerson = (id, body) => { }; export { + getCentersForPersonCreation, getPerson, getPersonAltNames, getCivilities, 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..8694da651 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue @@ -87,6 +87,18 @@
    +
    + + +
    +
    + {% for entity in entities %} - + + {% endfor %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/ActivityReasonCategory/index.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/ActivityReasonCategory/index.html.twig index 473059124..5f48180b3 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/ActivityReasonCategory/index.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/ActivityReasonCategory/index.html.twig @@ -7,6 +7,7 @@ + @@ -14,7 +15,11 @@ {% for entity in entities %} + {{ entity.name|localize_translatable_string }} + + diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Charge/confirm_delete.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Charge/confirm_delete.html.twig index f64184d6f..7a97731da 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Charge/confirm_delete.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Charge/confirm_delete.html.twig @@ -3,13 +3,13 @@ {% set indexPage = 'chill_budget_elements_index' %} {% set activeRouteKey = '' %} {% set person = element.person %} - {% set confirm_question = 'Are you sure you want to remove the charge "%type%" associated to "%name%" ?'|trans({ '%name%' : person.firstname ~ ' ' ~ person.lastname, '%type%': element.type|budget_element_type_display('charge') } ) %} + {% set confirm_question = 'Are you sure you want to remove the charge "%type%" associated to "%name%" ?'|trans({ '%name%' : person.firstname ~ ' ' ~ person.lastname, '%type%': element.charge.getName | localize_translatable_string } ) %} {% else %} {% set template = '@ChillPerson/Household/layout.html.twig' %} {% set indexPage = 'chill_budget_elements_household_index' %} {% set activeRouteKey = '' %} {% set household = element.household %} - {% set confirm_question = 'Are you sure you want to remove the charge "%type%" associated to household "%household%" ?'|trans({ '%household%' : household.id, '%type%': element.type|budget_element_type_display('charge') } ) %} + {% set confirm_question = 'Are you sure you want to remove the charge "%type%" associated to household "%household%" ?'|trans({ '%household%' : household.id, '%type%': element.charge.getName | localize_translatable_string } ) %} {% endif %} {% extends template %} diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Charge/edit.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Charge/edit.html.twig index fed80a5c0..ab68314d6 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Charge/edit.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Charge/edit.html.twig @@ -21,7 +21,7 @@ {{ form_start(form) }} -{{ form_row(form.type) }} +{{ form_row(form.charge) }} {{ form_row(form.amount) }} {{ form_row(form.help) }} {{ form_row(form.comment) }} diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Charge/new.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Charge/new.html.twig index 817d501ca..bdd7334bb 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Charge/new.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Charge/new.html.twig @@ -20,7 +20,7 @@ {{ form_start(form) }} -{{ form_row(form.type) }} +{{ form_row(form.charge) }} {{ form_row(form.amount) }} {{ form_row(form.help) }} {{ form_row(form.comment) }} diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Charge/view.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Charge/view.html.twig index d3b9ef71b..509c421b0 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Charge/view.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Charge/view.html.twig @@ -25,7 +25,7 @@

    - {{ element.type|budget_element_type_display('charge') }} + {{ element.charge.getName | localize_translatable_string }}

    diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Entity/budget_element_type.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Entity/budget_element_type.html.twig new file mode 100644 index 000000000..f2187a8b8 --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Entity/budget_element_type.html.twig @@ -0,0 +1 @@ +{{ entity.name|localize_translatable_string }} \ No newline at end of file diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Resource/confirm_delete.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Resource/confirm_delete.html.twig index 73ae173ff..f60c3b6de 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Resource/confirm_delete.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Resource/confirm_delete.html.twig @@ -3,13 +3,13 @@ {% set indexPage = 'chill_budget_elements_index' %} {% set activeRouteKey = '' %} {% set person = element.person %} - {% set confirm_question = 'Are you sure you want to remove the ressource "%type%" associated to "%name%" ?'|trans({ '%name%' : person.firstname ~ ' ' ~ person.lastname, '%type%': element.type|budget_element_type_display('resource') } ) %} + {% set confirm_question = 'Are you sure you want to remove the ressource "%type%" associated to "%name%" ?'|trans({ '%name%' : person.firstname ~ ' ' ~ person.lastname, '%type%': element.resource.getName | localize_translatable_string } ) %} {% else %} {% set template = '@ChillPerson/Household/layout.html.twig' %} {% set indexPage = 'chill_budget_elements_household_index' %} {% set activeRouteKey = '' %} {% set household = element.household %} - {% set confirm_question = 'Are you sure you want to remove the ressource "%type%" associated to household "%household%" ?'|trans({ '%household%' : household.id, '%type%': element.type|budget_element_type_display('resource') } ) %} + {% set confirm_question = 'Are you sure you want to remove the ressource "%type%" associated to household "%household%" ?'|trans({ '%household%' : household.id, '%type%': element.resource.getName | localize_translatable_string} ) %} {% endif %} {% extends template %} diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Resource/edit.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Resource/edit.html.twig index 8b051eeaf..85cf7e8e4 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Resource/edit.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Resource/edit.html.twig @@ -23,7 +23,7 @@ {{ form_start(form) }} -{{ form_row(form.type) }} +{{ form_row(form.resource) }} {{ form_row(form.amount) }} {{ form_row(form.comment) }} {{ form_row(form.startDate) }} diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Resource/new.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Resource/new.html.twig index 4ea71f4de..5c1b63d12 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Resource/new.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Resource/new.html.twig @@ -22,8 +22,7 @@

    {{ title }}

    {{ form_start(form) }} - -{{ form_row(form.type) }} +{{ form_row(form.resource) }} {{ form_row(form.amount) }} {{ form_row(form.comment) }} {{ form_row(form.startDate) }} diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Resource/view.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Resource/view.html.twig index 110aed9fe..c3618b498 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Resource/view.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Resource/view.html.twig @@ -25,7 +25,7 @@

    - {{ element.type|budget_element_type_display('resource') }} + {{ element.resource.getName | localize_translatable_string }}

    diff --git a/src/Bundle/ChillBudgetBundle/Templating/BudgetElementTypeRender.php b/src/Bundle/ChillBudgetBundle/Templating/BudgetElementTypeRender.php new file mode 100644 index 000000000..9cc89e2bf --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Templating/BudgetElementTypeRender.php @@ -0,0 +1,55 @@ +translatableStringHelper = $translatableStringHelper; + $this->engine = $engine; + } + + public function renderBox($entity, array $options): string + { + return $this->engine->render('@ChillBudget/Entity/budget_element_type.html.twig', [ + 'entity' => $entity, + 'options' => $options, + ]); + } + + public function renderString($entity, array $options): string + { + $title = ''; + + if (null !== $entity->getName()) { + return $this->translatableStringHelper->localize($entity->getName()); + } + + return $title; + } + + public function supports($entity, array $options): bool + { + return $entity instanceof ChargeKind || $entity instanceof ResourceKind; + } +} diff --git a/src/Bundle/ChillBudgetBundle/config/services/controller.yaml b/src/Bundle/ChillBudgetBundle/config/services/controller.yaml index 82c683536..ae6fb84d6 100644 --- a/src/Bundle/ChillBudgetBundle/config/services/controller.yaml +++ b/src/Bundle/ChillBudgetBundle/config/services/controller.yaml @@ -3,3 +3,7 @@ services: autowire: true resource: '../../Controller' tags: ['controller.service_arguments'] + Chill\BudgetBundle\Controller\Admin\: + autowire: true + autoconfigure: true + resource: '../../Controller/Admin' diff --git a/src/Bundle/ChillBudgetBundle/config/services/form.yaml b/src/Bundle/ChillBudgetBundle/config/services/form.yaml index 63862ce94..a033413d0 100644 --- a/src/Bundle/ChillBudgetBundle/config/services/form.yaml +++ b/src/Bundle/ChillBudgetBundle/config/services/form.yaml @@ -1,14 +1,9 @@ services: - Chill\BudgetBundle\Form\ResourceType: - arguments: - $configRepository: '@Chill\BudgetBundle\Config\ConfigRepository' - $translatableStringHelper: '@Chill\MainBundle\Templating\TranslatableStringHelper' - tags: - - { name: 'form.type' } - - Chill\BudgetBundle\Form\ChargeType: - arguments: - $configRepository: '@Chill\BudgetBundle\Config\ConfigRepository' - $translatableStringHelper: '@Chill\MainBundle\Templating\TranslatableStringHelper' + Chill\BudgetBundle\Form\: + autowire: true + resource: '../../Form' tags: - { name: 'form.type' } +# Chill\BudgetBundle\Form\Admin\: +# autowire: true +# resource: '../../Form/Admin' diff --git a/src/Bundle/ChillBudgetBundle/config/services/menu.yaml b/src/Bundle/ChillBudgetBundle/config/services/menu.yaml index 34128519b..ba8b301d5 100644 --- a/src/Bundle/ChillBudgetBundle/config/services/menu.yaml +++ b/src/Bundle/ChillBudgetBundle/config/services/menu.yaml @@ -1,8 +1,5 @@ services: - Chill\BudgetBundle\Menu\PersonMenuBuilder: - autowire: true - autoconfigure: true - - Chill\BudgetBundle\Menu\HouseholdMenuBuilder: + Chill\BudgetBundle\Menu\: autowire: true autoconfigure: true + resource: './../../Menu' diff --git a/src/Bundle/ChillBudgetBundle/config/services/repository.yaml b/src/Bundle/ChillBudgetBundle/config/services/repository.yaml new file mode 100644 index 000000000..7205a8378 --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/config/services/repository.yaml @@ -0,0 +1,5 @@ +services: + Chill\BudgetBundle\Repository\: + autowire: true + autoconfigure: true + resource: './../../Repository' \ No newline at end of file diff --git a/src/Bundle/ChillBudgetBundle/config/services/templating.yaml b/src/Bundle/ChillBudgetBundle/config/services/templating.yaml index 903db5d67..2646f3892 100644 --- a/src/Bundle/ChillBudgetBundle/config/services/templating.yaml +++ b/src/Bundle/ChillBudgetBundle/config/services/templating.yaml @@ -1,7 +1,5 @@ services: - Chill\BudgetBundle\Templating\Twig: - arguments: - $configRepository: '@Chill\BudgetBundle\Config\ConfigRepository' - $translatableStringHelper: '@Chill\MainBundle\Templating\TranslatableStringHelper' - tags: - - { name: 'twig.extension' } \ No newline at end of file + Chill\BudgetBundle\Templating\: + autowire: true + autoconfigure: true + resource: '../../Templating' diff --git a/src/Bundle/ChillBudgetBundle/migrations/Version20221116163445.php b/src/Bundle/ChillBudgetBundle/migrations/Version20221116163445.php new file mode 100644 index 000000000..118b7c30d --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/migrations/Version20221116163445.php @@ -0,0 +1,39 @@ +addSql('DROP SEQUENCE chill_budget.charge_type_id_seq CASCADE'); + $this->addSql('DROP SEQUENCE chill_budget.resource_type_id_seq CASCADE'); + $this->addSql('DROP TABLE chill_budget.charge_type'); + $this->addSql('DROP TABLE chill_budget.resource_type'); + } + + public function getDescription(): string + { + return 'Create resource type and charge type'; + } + + public function up(Schema $schema): void + { + $this->addSql('CREATE SEQUENCE chill_budget.charge_type_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE SEQUENCE chill_budget.resource_type_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE TABLE chill_budget.charge_type (id INT NOT NULL, isActive BOOLEAN DEFAULT TRUE NOT NULL, name JSONB DEFAULT \'{}\'::jsonb NOT NULL, ordering DOUBLE PRECISION DEFAULT \'0\' NOT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE TABLE chill_budget.resource_type (id INT NOT NULL, isActive BOOLEAN DEFAULT TRUE NOT NULL, name JSONB DEFAULT \'{}\'::jsonb NOT NULL, ordering DOUBLE PRECISION DEFAULT \'0\' NOT NULL, PRIMARY KEY(id))'); + } +} diff --git a/src/Bundle/ChillBudgetBundle/migrations/Version20221130101659.php b/src/Bundle/ChillBudgetBundle/migrations/Version20221130101659.php new file mode 100644 index 000000000..98d67b341 --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/migrations/Version20221130101659.php @@ -0,0 +1,41 @@ +addSql('ALTER TABLE chill_budget.resource_type DROP kind'); + $this->addSql('ALTER TABLE chill_budget.resource_type DROP tags'); + $this->addSql('ALTER TABLE chill_budget.charge_type DROP kind'); + $this->addSql('ALTER TABLE chill_budget.charge_type DROP tags'); + } + + public function getDescription(): string + { + return 'Add kind and tags property to charge and resource types'; + } + + public function up(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_budget.charge_type ADD kind VARCHAR(255) DEFAULT \'\' NOT NULL'); + $this->addSql('ALTER TABLE chill_budget.charge_type ADD tags JSONB DEFAULT \'{}\'::jsonb NOT NULL'); + $this->addSql('COMMENT ON COLUMN chill_budget.charge_type.tags IS \'(DC2Type:jsonb)\''); + $this->addSql('ALTER TABLE chill_budget.resource_type ADD kind VARCHAR(255) DEFAULT \'\' NOT NULL'); + $this->addSql('ALTER TABLE chill_budget.resource_type ADD tags JSONB DEFAULT \'{}\'::jsonb NOT NULL'); + $this->addSql('COMMENT ON COLUMN chill_budget.resource_type.tags IS \'(DC2Type:jsonb)\''); + } +} diff --git a/src/Bundle/ChillBudgetBundle/migrations/Version20221202165608.php b/src/Bundle/ChillBudgetBundle/migrations/Version20221202165608.php new file mode 100644 index 000000000..c2152100b --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/migrations/Version20221202165608.php @@ -0,0 +1,41 @@ +addSql('ALTER TABLE chill_budget.charge DROP CONSTRAINT FK_5C99D2C355284914'); + $this->addSql('ALTER TABLE chill_budget.charge DROP charge_id'); + $this->addSql('ALTER TABLE chill_budget.resource DROP CONSTRAINT FK_5E0A5E9789329D25'); + $this->addSql('ALTER TABLE chill_budget.resource DROP resource_id'); + } + + public function getDescription(): string + { + return 'Integrate budget admin entity'; + } + + public function up(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_budget.charge ADD charge_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_budget.charge ADD CONSTRAINT FK_5C99D2C355284914 FOREIGN KEY (charge_id) REFERENCES chill_budget.charge_type (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE INDEX IDX_5C99D2C355284914 ON chill_budget.charge (charge_id)'); + $this->addSql('ALTER TABLE chill_budget.resource ADD resource_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_budget.resource ADD CONSTRAINT FK_5E0A5E9789329D25 FOREIGN KEY (resource_id) REFERENCES chill_budget.resource_type (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE INDEX IDX_5E0A5E9789329D25 ON chill_budget.resource (resource_id)'); + } +} diff --git a/src/Bundle/ChillBudgetBundle/migrations/Version20221207105407.php b/src/Bundle/ChillBudgetBundle/migrations/Version20221207105407.php new file mode 100644 index 000000000..cfe3a0089 --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/migrations/Version20221207105407.php @@ -0,0 +1,81 @@ +addSql('DELETE FROM chill_budget.resource_type;'); + $this->addSql('DELETE FROM chill_budget.charge_type;'); + } + + public function getDescription(): string + { + return 'Use new budget admin entities'; + } + + public function setContainer(?ContainerInterface $container = null) + { + $this->container = $container; + } + + public function up(Schema $schema): void + { + $resources = $this->container->getParameter('chill_budget.resources'); + $charges = $this->container->getParameter('chill_budget.charges'); + + foreach ($resources as $value) { + $lang = $value['labels'][0]['lang']; + $label = $value['labels'][0]['label']; + $kind = $value['key']; + $this->addSql( + 'INSERT INTO chill_budget.resource_type (id, isActive, name, ordering, kind) VALUES ( + nextval(\'chill_budget.resource_type_id_seq\'), true, jsonb_build_object(:lang::text, :label::text), 0, :kind::text)', + ['lang' => $lang, 'label' => $label, 'kind' => $kind], + ['lang' => Types::STRING, 'label' => Types::STRING, 'kind' => Types::STRING] + ); + $this->addSql( + 'UPDATE chill_budget.resource SET resource_id = resource_type.id + FROM chill_budget.resource_type WHERE resource.type = :kind AND resource_type.kind = resource.type;', + ['kind' => $kind], + ['kind' => Types::STRING] + ); + } + + foreach ($charges as $value) { + $lang = $value['labels'][0]['lang']; + $label = $value['labels'][0]['label']; + $kind = $value['key']; + $this->addSql( + 'INSERT INTO chill_budget.charge_type VALUES (nextval(\'chill_budget.charge_type_id_seq\'), true, + jsonb_build_object(:lang::text, :label::text), 0, :kind::text);', + ['lang' => $lang, 'label' => $label, 'kind' => $kind], + ['lang' => Types::STRING, 'label' => Types::STRING, 'kind' => Types::STRING] + ); + $this->addSql( + 'UPDATE chill_budget.charge SET charge_id = charge_type.id + FROM chill_budget.charge_type WHERE charge.type = :kind AND charge_type.kind = charge.type;', + ['kind' => $kind], + ['kind' => Types::STRING] + ); + } + } +} diff --git a/src/Bundle/ChillBudgetBundle/translations/messages.fr.yml b/src/Bundle/ChillBudgetBundle/translations/messages.fr.yml index 299fa295e..5fd8fa6f6 100644 --- a/src/Bundle/ChillBudgetBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillBudgetBundle/translations/messages.fr.yml @@ -58,6 +58,8 @@ Charge updated: charge mise à jour Choose a resource type: Choisissez un type de ressource Choose a charge type: Choisissez un type de charge +Resource type: Type de ressource +Charge type: Type de charge Amount: Montant Comment: Commentaire @@ -74,3 +76,28 @@ The balance: Différence entre ressources et charges Valid since %startDate% until %endDate%: Valide depuis le %startDate% jusqu'au %endDate% Valid since %startDate%: Valide depuis le %startDate% + +## admin + +crud: + resource_kind: + title_new: Nouveau type de ressource + title_edit: Modifier le type de ressource + charge_kind: + title_new: Nouveau type de charge + title_edit: Modifier le type de charge + +admin: + menu: + Resource types: Types de ressource + Charge types: Types de charge + title: + Charge Type List: Liste des types de charge + Resource Type List: Liste des types de ressource + Budget configuration: Configuration des éléments de budget + new: + Create a new charge type: Créér un nouveau type de charge + Create a new resource type: Créér un nouveau type de ressource + form: + Choose the type of resource: Choisissez une type de ressource + Choose the type of charge: Choisissez une type de charge diff --git a/src/Bundle/ChillMainBundle/Controller/RegroupmentController.php b/src/Bundle/ChillMainBundle/Controller/RegroupmentController.php new file mode 100644 index 000000000..c73b03027 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Controller/RegroupmentController.php @@ -0,0 +1,26 @@ +addOrderBy('e.id', 'ASC'); + + return parent::orderQuery($action, $query, $request, $paginator); + } +} diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php index 9c2148a14..23a4bee89 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php @@ -18,6 +18,7 @@ use Chill\MainBundle\Controller\CountryController; use Chill\MainBundle\Controller\LanguageController; use Chill\MainBundle\Controller\LocationController; use Chill\MainBundle\Controller\LocationTypeController; +use Chill\MainBundle\Controller\RegroupmentController; use Chill\MainBundle\Controller\UserController; use Chill\MainBundle\Controller\UserJobApiController; use Chill\MainBundle\Controller\UserJobController; @@ -48,6 +49,7 @@ use Chill\MainBundle\Entity\Country; use Chill\MainBundle\Entity\Language; use Chill\MainBundle\Entity\Location; use Chill\MainBundle\Entity\LocationType; +use Chill\MainBundle\Entity\Regroupment; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\UserJob; use Chill\MainBundle\Form\CivilityType; @@ -55,6 +57,7 @@ use Chill\MainBundle\Form\CountryType; use Chill\MainBundle\Form\LanguageType; use Chill\MainBundle\Form\LocationFormType; use Chill\MainBundle\Form\LocationTypeType; +use Chill\MainBundle\Form\RegroupmentType; use Chill\MainBundle\Form\UserJobType; use Chill\MainBundle\Form\UserType; use Exception; @@ -499,6 +502,27 @@ class ChillMainExtension extends Extension implements ], ], ], + [ + 'class' => Regroupment::class, + 'name' => 'regroupment', + 'base_path' => '/admin/regroupment', + 'form_class' => RegroupmentType::class, + 'controller' => RegroupmentController::class, + 'actions' => [ + 'index' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillMain/Admin/Regroupment/index.html.twig', + ], + 'new' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillMain/Admin/Regroupment/new.html.twig', + ], + 'edit' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillMain/Admin/Regroupment/edit.html.twig', + ], + ], + ], ], 'apis' => [ [ diff --git a/src/Bundle/ChillMainBundle/Entity/Regroupment.php b/src/Bundle/ChillMainBundle/Entity/Regroupment.php new file mode 100644 index 000000000..5faffd17c --- /dev/null +++ b/src/Bundle/ChillMainBundle/Entity/Regroupment.php @@ -0,0 +1,95 @@ +centers = new ArrayCollection(); + } + + public function getCenters(): ?Collection + { + return $this->centers; + } + + public function getId(): ?int + { + return $this->id; + } + + public function getIsActive(): bool + { + return $this->isActive; + } + + public function getName(): string + { + return $this->name; + } + + public function setCenters(?Collection $centers): self + { + $this->centers = $centers; + + return $this; + } + + public function setIsActive(bool $isActive): self + { + $this->isActive = $isActive; + + return $this; + } + + public function setName(string $name): self + { + $this->name = $name; + + return $this; + } +} diff --git a/src/Bundle/ChillMainBundle/Form/RegroupmentType.php b/src/Bundle/ChillMainBundle/Form/RegroupmentType.php new file mode 100644 index 000000000..bc8e6684f --- /dev/null +++ b/src/Bundle/ChillMainBundle/Form/RegroupmentType.php @@ -0,0 +1,47 @@ +add('name', TextType::class, [ + 'label' => 'Nom', + ]) + ->add('centers', EntityType::class, [ + 'class' => Center::class, + 'multiple' => true, + 'attr' => ['class' => 'select2'], + ]) + ->add('isActive', CheckboxType::class, [ + 'label' => 'Actif ?', + 'required' => false, + ]); + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver + ->setDefault('class', Regroupment::class); + } +} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Admin/Regroupment/edit.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/Regroupment/edit.html.twig new file mode 100644 index 000000000..4d55c480c --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/Admin/Regroupment/edit.html.twig @@ -0,0 +1,11 @@ +{% extends '@ChillMain/CRUD/Admin/index.html.twig' %} + +{% block title %} + {% include('@ChillMain/CRUD/_edit_title.html.twig') %} +{% endblock %} + +{% block admin_content %} + {% embed '@ChillMain/CRUD/_edit_content.html.twig' %} + {% block content_form_actions_save_and_show %}{% endblock %} + {% endembed %} +{% endblock admin_content %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Admin/Regroupment/index.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/Regroupment/index.html.twig new file mode 100644 index 000000000..06e646083 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/Admin/Regroupment/index.html.twig @@ -0,0 +1,39 @@ +{% extends '@ChillMain/CRUD/Admin/index.html.twig' %} + +{% block admin_content %} + {% embed '@ChillMain/CRUD/_index.html.twig' %} + {% block table_entities_thead_tr %} +
    + + + {% endblock %} + + {% block table_entities_tbody %} + {% for entity in entities %} + + + + + + {% endfor %} + {% endblock %} + + {% block actions_before %} +
  • + {{'Back to the admin'|trans}} +
  • + {% endblock %} + {% endembed %} +{% endblock %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Admin/Regroupment/new.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/Regroupment/new.html.twig new file mode 100644 index 000000000..7c204dddd --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/Admin/Regroupment/new.html.twig @@ -0,0 +1,11 @@ +{% extends '@ChillMain/CRUD/Admin/index.html.twig' %} + +{% block title %} + {% include('@ChillMain/CRUD/_new_title.html.twig') %} +{% endblock %} + +{% block admin_content %} + {% embed '@ChillMain/CRUD/_new_content.html.twig' %} + {% block content_form_actions_save_and_show %}{% endblock %} + {% endembed %} +{% endblock admin_content %} diff --git a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/AdminUserMenuBuilder.php b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/AdminUserMenuBuilder.php index 5cb4e087b..96fdcb60d 100644 --- a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/AdminUserMenuBuilder.php +++ b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/AdminUserMenuBuilder.php @@ -53,6 +53,10 @@ class AdminUserMenuBuilder implements LocalMenuBuilderInterface 'route' => 'admin_center', ])->setExtras(['order' => 1010]); + $menu->addChild('Regroupements des centres', [ + 'route' => 'chill_crud_regroupment_index', + ])->setExtras(['order' => 1015]); + $menu->addChild('List circles', [ 'route' => 'admin_scope', ])->setExtras(['order' => 1020]); diff --git a/src/Bundle/ChillMainBundle/config/services/controller.yaml b/src/Bundle/ChillMainBundle/config/services/controller.yaml index 28abc94e8..16c545a81 100644 --- a/src/Bundle/ChillMainBundle/config/services/controller.yaml +++ b/src/Bundle/ChillMainBundle/config/services/controller.yaml @@ -33,3 +33,7 @@ services: arguments: $security: '@Symfony\Component\Security\Core\Security' tags: ['controller.service_arguments'] + + Chill\MainBundle\Controller\RegroupmentController: + autowire: true + autoconfigure: true diff --git a/src/Bundle/ChillMainBundle/config/services/form.yaml b/src/Bundle/ChillMainBundle/config/services/form.yaml index 58f01883f..8157c27e9 100644 --- a/src/Bundle/ChillMainBundle/config/services/form.yaml +++ b/src/Bundle/ChillMainBundle/config/services/form.yaml @@ -138,6 +138,10 @@ services: autowire: true autoconfigure: true + Chill\MainBundle\Form\RegroupmentType: + autowire: true + autoconfigure: true + Chill\MainBundle\Form\DataTransformer\IdToLocationDataTransformer: ~ Chill\MainBundle\Form\DataTransformer\IdToUserDataTransformer: ~ Chill\MainBundle\Form\DataTransformer\IdToUsersDataTransformer: ~ diff --git a/src/Bundle/ChillMainBundle/migrations/Version20230111104315.php b/src/Bundle/ChillMainBundle/migrations/Version20230111104315.php new file mode 100644 index 000000000..aa6e0f4c5 --- /dev/null +++ b/src/Bundle/ChillMainBundle/migrations/Version20230111104315.php @@ -0,0 +1,43 @@ +addSql('DROP SEQUENCE regroupment_id_seq CASCADE'); + $this->addSql('ALTER TABLE regroupment_center DROP CONSTRAINT FK_2BCCE2F9EC6D1029'); + $this->addSql('ALTER TABLE regroupment_center DROP CONSTRAINT FK_2BCCE2F95932F377'); + $this->addSql('DROP TABLE regroupment'); + $this->addSql('DROP TABLE regroupment_center'); + } + + public function getDescription(): string + { + return 'Add regroupment admin entity'; + } + + public function up(Schema $schema): void + { + $this->addSql('CREATE SEQUENCE regroupment_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE TABLE regroupment (id INT NOT NULL, name VARCHAR(15) DEFAULT \'\' NOT NULL, isActive BOOLEAN NOT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE TABLE regroupment_center (regroupment_id INT NOT NULL, center_id INT NOT NULL, PRIMARY KEY(regroupment_id, center_id))'); + $this->addSql('CREATE INDEX IDX_2BCCE2F9EC6D1029 ON regroupment_center (regroupment_id)'); + $this->addSql('CREATE INDEX IDX_2BCCE2F95932F377 ON regroupment_center (center_id)'); + $this->addSql('ALTER TABLE regroupment_center ADD CONSTRAINT FK_2BCCE2F9EC6D1029 FOREIGN KEY (regroupment_id) REFERENCES regroupment (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE regroupment_center ADD CONSTRAINT FK_2BCCE2F95932F377 FOREIGN KEY (center_id) REFERENCES centers (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + } +} diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index b416480a9..f779cf87f 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -409,6 +409,12 @@ crud: add_new: Ajouter une civilité title_new: Nouvelle civilité title_edit: Modifier une civilité + regroupment: + index: + title: Liste des regroupements + add_new: Ajouter un regroupement + title_new: Nouveau regroupement + title_edit: Modifier un regroupement No entities: Aucun élément diff --git a/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentLockManager.php b/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentLockManager.php index fce25de58..185256238 100644 --- a/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentLockManager.php +++ b/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentLockManager.php @@ -22,7 +22,7 @@ class ChillDocumentLockManager implements DocumentLockManagerInterface private const LOCK_DURATION = 60 * 30; /** - * Number of seconds to keep the lock after the delete lock operation. + * Number of seconds to keep the lock after the delete lock operation */ private const LOCK_GRACEFUL_DURATION_TIME = 3;
    {{ 'Name'|trans }}{{ 'Active'|trans }} {{ 'Actions'|trans }}
    {{ entity.name|localize_translatable_string }} -
      -
    • - -
    • -
    • - -
    • -
    + {% if entity.category is not null -%} + {{ entity.category.name|localize_translatable_string }} > + {% endif -%} + {{ entity.name|localize_translatable_string }} +
    + + {% if entity.active and not entity.isActiveAndParentActive %} + {{ 'Associated activity reason category is inactive'|trans }} + {% endif %} + +
      +
    • + +
    • +
    • + +
    • +
    {{ 'Name'|trans }}{{ 'Active'|trans }} {{ 'Actions'|trans }}
    - {{ entity.name|localize_translatable_string }} + +
    • diff --git a/src/Bundle/ChillActivityBundle/config/services/controller.yaml b/src/Bundle/ChillActivityBundle/config/services/controller.yaml index 96ace0a64..c14c40475 100644 --- a/src/Bundle/ChillActivityBundle/config/services/controller.yaml +++ b/src/Bundle/ChillActivityBundle/config/services/controller.yaml @@ -1,4 +1,11 @@ services: - Chill\ActivityBundle\Controller\ActivityController: + _defaults: autowire: true + autoconfigure: true + + Chill\ActivityBundle\Controller\: + resource: '../../Controller/' + tags: ['controller.service_arguments'] + + Chill\ActivityBundle\Controller\ActivityController: tags: ['controller.service_arguments'] diff --git a/src/Bundle/ChillActivityBundle/config/services/form.yaml b/src/Bundle/ChillActivityBundle/config/services/form.yaml index fd034b2da..2b29dd1b2 100644 --- a/src/Bundle/ChillActivityBundle/config/services/form.yaml +++ b/src/Bundle/ChillActivityBundle/config/services/form.yaml @@ -1,11 +1,8 @@ --- services: - chill.activity.form.type.translatableactivityreasoncategory: - class: Chill\ActivityBundle\Form\Type\TranslatableActivityReasonCategory - arguments: - - "@request_stack" - tags: - - { name: form.type, alias: translatable_activity_reason_category } + Chill\ActivityBundle\Form\Type\TranslatableActivityReasonCategoryType: + autowire: true + autoconfigure: true chill.activity.form.type.translatableactivityreason: class: Chill\ActivityBundle\Form\Type\TranslatableActivityReason diff --git a/src/Bundle/ChillActivityBundle/config/services/repositories.yaml b/src/Bundle/ChillActivityBundle/config/services/repositories.yaml index c9fe8d843..096528221 100644 --- a/src/Bundle/ChillActivityBundle/config/services/repositories.yaml +++ b/src/Bundle/ChillActivityBundle/config/services/repositories.yaml @@ -1,5 +1,8 @@ --- services: + Chill\ActivityBundle\Repository\ActivityReasonRepository: + autowire: true + chill_activity.repository.activity_type: '@Chill\ActivityBundle\Repository\ActivityTypeRepository' chill_activity.repository.reason: '@Chill\ActivityBundle\Repository\ActivityReasonRepository' chill_activity.repository.reason_category: '@Chill\ActivityBundle\Repository\ActivityReasonCategoryRepository' diff --git a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml index 2f7aee6ac..20d72e7b3 100644 --- a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml @@ -117,6 +117,7 @@ Activity Reasons: Sujets d'une activité Activity Reasons Category: Catégories de sujet d'activités Activity Types Categories: Catégories des types d'activité Activity Presences: Presences aux activités +Associated activity reason category is inactive: La catégorie de sujet attachée est inactive # Crud @@ -276,7 +277,7 @@ Creators: Créateurs Filter activity by userscope: Filtrer les activités par service du créateur 'Filtered activity by userscope: only %scopes%': "Filtré par service du créateur: uniquement %scopes%" Accepted userscope: Services - + Filter acp which has no activity: Filtrer les parcours qui n’ont pas d’activité Filtered acp which has no activities: Filtrer les parcours sans activité associée Group acp by activity number: Grouper les parcours par nombre d’activité diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index b19a7a52f..b416480a9 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -42,6 +42,8 @@ by_user: "par " lifecycleUpdate: Evenements de création et mise à jour address_fields: Données liées à l'adresse +inactive: inactif + Edit: Modifier Update: Mettre à jour Back to the list: Retour à la liste From 164beb3ca9c341530a6bd7ad676a963e777b95ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 13 Jan 2023 16:15:05 +0100 Subject: [PATCH 50/60] Fixed: [Activity] fix appearance of reason list in Activity form Fix https://gitlab.com/Chill-Projet/chill-bundles/-/issues/44 --- .../Controller/ActivityController.php | 13 +++++--- .../ChillActivityBundle/Form/ActivityType.php | 13 ++------ ...yReason.php => PickActivityReasonType.php} | 33 ++++++++----------- .../Type/TranslatableActivityReasonTest.php | 4 +-- .../config/services/form.yaml | 10 ++---- 5 files changed, 30 insertions(+), 43 deletions(-) rename src/Bundle/ChillActivityBundle/Form/Type/{TranslatableActivityReason.php => PickActivityReasonType.php} (68%) diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index e67e0f3c2..b7d5fcbd2 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -43,6 +43,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Serializer\SerializerInterface; +use Symfony\Contracts\Translation\TranslatorInterface; use function array_key_exists; final class ActivityController extends AbstractController @@ -73,6 +74,8 @@ final class ActivityController extends AbstractController private ThirdPartyRepository $thirdPartyRepository; + private TranslatorInterface $translator; + private UserRepositoryInterface $userRepository; public function __construct( @@ -89,7 +92,8 @@ final class ActivityController extends AbstractController LoggerInterface $logger, SerializerInterface $serializer, UserRepositoryInterface $userRepository, - CenterResolverManagerInterface $centerResolver + CenterResolverManagerInterface $centerResolver, + TranslatorInterface $translator ) { $this->activityACLAwareRepository = $activityACLAwareRepository; $this->activityTypeRepository = $activityTypeRepository; @@ -105,6 +109,7 @@ final class ActivityController extends AbstractController $this->serializer = $serializer; $this->userRepository = $userRepository; $this->centerResolver = $centerResolver; + $this->translator = $translator; } /** @@ -160,7 +165,7 @@ final class ActivityController extends AbstractController $this->entityManager->remove($activity); $this->entityManager->flush(); - $this->addFlash('success', $this->get('translator') + $this->addFlash('success', $this->translator ->trans('The activity has been successfully removed.')); $params = $this->buildParamsToUrl($person, $accompanyingPeriod); @@ -245,7 +250,7 @@ final class ActivityController extends AbstractController ); } - $this->addFlash('success', $this->get('translator')->trans('Success : activity updated!')); + $this->addFlash('success', $this->translator->trans('Success : activity updated!')); return $this->redirectToRoute('chill_activity_activity_show', $params); } @@ -473,7 +478,7 @@ final class ActivityController extends AbstractController ); } - $this->addFlash('success', $this->get('translator')->trans('Success : activity created!')); + $this->addFlash('success', $this->translator->trans('Success : activity created!')); $params = $this->buildParamsToUrl($person, $accompanyingPeriod); diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityType.php b/src/Bundle/ChillActivityBundle/Form/ActivityType.php index cabfc0e76..6d198c5fa 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityType.php @@ -13,7 +13,7 @@ namespace Chill\ActivityBundle\Form; use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Entity\ActivityPresence; -use Chill\ActivityBundle\Entity\ActivityReason; +use Chill\ActivityBundle\Form\Type\PickActivityReasonType; use Chill\ActivityBundle\Security\Authorization\ActivityVoter; use Chill\DocStoreBundle\Form\StoredObjectType; use Chill\MainBundle\Entity\Center; @@ -229,19 +229,10 @@ class ActivityType extends AbstractType } if ($activityType->isVisible('reasons')) { - $builder->add('reasons', EntityType::class, [ + $builder->add('reasons', PickActivityReasonType::class, [ 'label' => $activityType->getLabel('reasons'), 'required' => $activityType->isRequired('reasons'), - 'class' => ActivityReason::class, 'multiple' => true, - 'choice_label' => function (ActivityReason $activityReason) { - return $this->translatableStringHelper->localize($activityReason->getName()); - }, - 'attr' => ['class' => 'select2 '], - 'query_builder' => static function (EntityRepository $er) { - return $er->createQueryBuilder('a') - ->where('a.active = true'); - }, ]); } diff --git a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReason.php b/src/Bundle/ChillActivityBundle/Form/Type/PickActivityReasonType.php similarity index 68% rename from src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReason.php rename to src/Bundle/ChillActivityBundle/Form/Type/PickActivityReasonType.php index d8ac89963..a951ef940 100644 --- a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReason.php +++ b/src/Bundle/ChillActivityBundle/Form/Type/PickActivityReasonType.php @@ -12,9 +12,9 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Form\Type; use Chill\ActivityBundle\Entity\ActivityReason; +use Chill\ActivityBundle\Repository\ActivityReasonRepository; use Chill\ActivityBundle\Templating\Entity\ActivityReasonRender; -use Chill\MainBundle\Templating\TranslatableStringHelper; -use Doctrine\ORM\EntityRepository; +use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -22,31 +22,29 @@ use Symfony\Component\OptionsResolver\OptionsResolver; /** * FormType to choose amongst activity reasons. */ -class TranslatableActivityReason extends AbstractType +class PickActivityReasonType extends AbstractType { - /** - * @var ActivityReasonRender - */ - protected $reasonRender; + private ActivityReasonRepository $activityReasonRepository; - /** - * @var TranslatableStringHelper - */ - protected $translatableStringHelper; + private ActivityReasonRender $reasonRender; + + private TranslatableStringHelperInterface $translatableStringHelper; public function __construct( - TranslatableStringHelper $translatableStringHelper, - ActivityReasonRender $reasonRender + ActivityReasonRepository $activityReasonRepository, + ActivityReasonRender $reasonRender, + TranslatableStringHelperInterface $translatableStringHelper ) { - $this->translatableStringHelper = $translatableStringHelper; + $this->activityReasonRepository = $activityReasonRepository; $this->reasonRender = $reasonRender; + $this->translatableStringHelper = $translatableStringHelper; } public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults( [ - 'class' => 'ChillActivityBundle:ActivityReason', + 'class' => ActivityReason::class, 'choice_label' => function (ActivityReason $choice) { return $this->reasonRender->renderString($choice, []); }, @@ -57,10 +55,7 @@ class TranslatableActivityReason extends AbstractType return null; }, - 'query_builder' => static function (EntityRepository $er) { - return $er->createQueryBuilder('r') - ->where('r.active = true'); - }, + 'choices' => $this->activityReasonRepository->findAll(), 'attr' => ['class' => ' select2 '], ] ); diff --git a/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php b/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php index 59659e40f..3c9777051 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php @@ -11,7 +11,7 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Tests\Form\Type; -use Chill\ActivityBundle\Form\Type\TranslatableActivityReason; +use Chill\ActivityBundle\Form\Type\PickActivityReasonType; use Chill\MainBundle\Templating\TranslatableStringHelper; use Symfony\Component\Form\PreloadedExtension; use Symfony\Component\Form\Test\TypeTestCase; @@ -36,7 +36,7 @@ final class TranslatableActivityReasonTest extends TypeTestCase public function testSimple() { - $translatableActivityReasonType = new TranslatableActivityReason( + $translatableActivityReasonType = new PickActivityReasonType( $this->getTranslatableStringHelper() ); diff --git a/src/Bundle/ChillActivityBundle/config/services/form.yaml b/src/Bundle/ChillActivityBundle/config/services/form.yaml index 2b29dd1b2..f4945d8ce 100644 --- a/src/Bundle/ChillActivityBundle/config/services/form.yaml +++ b/src/Bundle/ChillActivityBundle/config/services/form.yaml @@ -4,13 +4,9 @@ services: autowire: true autoconfigure: true - chill.activity.form.type.translatableactivityreason: - class: Chill\ActivityBundle\Form\Type\TranslatableActivityReason - arguments: - $translatableStringHelper: "@chill.main.helper.translatable_string" - $reasonRender: '@Chill\ActivityBundle\Templating\Entity\ActivityReasonRender' - tags: - - { name: form.type, alias: translatable_activity_reason } + Chill\ActivityBundle\Form\Type\PickActivityReasonType: + autowire: true + autoconfigure: true chill.activity.form.type.translatableactivitytype: class: Chill\ActivityBundle\Form\Type\TranslatableActivityType From 6bba6f68b34b166b6498d4d7407adc29bcf3fd83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 13 Jan 2023 16:15:58 +0100 Subject: [PATCH 51/60] DX: Remove deprecation on `$this->get` inside controller --- .../Controller/CalendarController.php | 17 +++++++++++------ .../Entity/SocialWork/SocialIssue.php | 4 +++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php index db5f2ec16..550c6e984 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php @@ -45,6 +45,7 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Serializer\SerializerInterface; +use Symfony\Contracts\Translation\TranslatorInterface; class CalendarController extends AbstractController { @@ -68,6 +69,8 @@ class CalendarController extends AbstractController private TranslatableStringHelperInterface $translatableStringHelper; + private TranslatorInterface $translator; + private UserRepositoryInterface $userRepository; public function __construct( @@ -81,7 +84,8 @@ class CalendarController extends AbstractController TranslatableStringHelperInterface $translatableStringHelper, PersonRepository $personRepository, AccompanyingPeriodRepository $accompanyingPeriodRepository, - UserRepositoryInterface $userRepository + UserRepositoryInterface $userRepository, + TranslatorInterface $translator ) { $this->calendarACLAwareRepository = $calendarACLAwareRepository; $this->docGeneratorTemplateRepository = $docGeneratorTemplateRepository; @@ -94,6 +98,7 @@ class CalendarController extends AbstractController $this->personRepository = $personRepository; $this->accompanyingPeriodRepository = $accompanyingPeriodRepository; $this->userRepository = $userRepository; + $this->translator = $translator; } /** @@ -131,7 +136,7 @@ class CalendarController extends AbstractController $em->remove($entity); $em->flush(); - $this->addFlash('success', $this->get('translator') + $this->addFlash('success', $this->translator ->trans('The calendar item has been successfully removed.')); return new RedirectResponse($redirectRoute); @@ -190,7 +195,7 @@ class CalendarController extends AbstractController if ($form->isSubmitted() && $form->isValid()) { $em->flush(); - $this->addFlash('success', $this->get('translator')->trans('Success : calendar item updated!')); + $this->addFlash('success', $this->translator->trans('Success : calendar item updated!')); if ($form->get('save_and_upload_doc')->isClicked()) { return $this->redirectToRoute('chill_calendar_calendardoc_new', ['id' => $entity->getId()]); @@ -210,7 +215,7 @@ class CalendarController extends AbstractController } if ($form->isSubmitted() && !$form->isValid()) { - $this->addFlash('error', $this->get('translator')->trans('This form contains errors')); + $this->addFlash('error', $this->translator->trans('This form contains errors')); } $entity_array = $this->serializer->normalize($entity, 'json', ['groups' => 'read']); @@ -369,7 +374,7 @@ class CalendarController extends AbstractController $em->persist($entity); $em->flush(); - $this->addFlash('success', $this->get('translator')->trans('Success : calendar item created!')); + $this->addFlash('success', $this->translator->trans('Success : calendar item created!')); if ($form->get('save_and_upload_doc')->isClicked()) { return $this->redirectToRoute('chill_calendar_calendardoc_new', ['id' => $entity->getId()]); @@ -393,7 +398,7 @@ class CalendarController extends AbstractController } if ($form->isSubmitted() && !$form->isValid()) { - $this->addFlash('error', $this->get('translator')->trans('This form contains errors')); + $this->addFlash('error', $this->translator->trans('This form contains errors')); } if (null === $view) { diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php index 42c8442c1..675a1a923 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php @@ -356,7 +356,9 @@ class SocialIssue { $this->parent = $parent; - $parent->addChild($this); + if (null !== $parent) { + $parent->addChild($this); + } return $this; } From b2dec3e587007e4ab6a9ce24a51acf5c9e99bf0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 13 Jan 2023 16:41:45 +0100 Subject: [PATCH 52/60] Fixed: [social issue][admin] do not remove the parent when editing a social issue https://gitlab.com/Chill-Projet/chill-bundles/-/issues/46 --- .../SocialWork/SocialIssueController.php | 15 +++++++++++++ .../Form/SocialWork/SocialIssueType.php | 22 ++++++++++++++----- .../SocialWork/SocialIssue/edit.html.twig | 20 ++++++++++------- 3 files changed, 43 insertions(+), 14 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/SocialWork/SocialIssueController.php b/src/Bundle/ChillPersonBundle/Controller/SocialWork/SocialIssueController.php index 97b85263c..769e90de7 100644 --- a/src/Bundle/ChillPersonBundle/Controller/SocialWork/SocialIssueController.php +++ b/src/Bundle/ChillPersonBundle/Controller/SocialWork/SocialIssueController.php @@ -13,10 +13,25 @@ namespace Chill\PersonBundle\Controller\SocialWork; use Chill\MainBundle\CRUD\Controller\CRUDController; use Chill\MainBundle\Pagination\PaginatorInterface; +use LogicException; +use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\Request; class SocialIssueController extends CRUDController { + protected function createFormFor(string $action, $entity, ?string $formClass = null, array $formOptions = []): FormInterface + { + if ('new' === $action) { + return parent::createFormFor($action, $entity, $formClass, ['step' => 'create']); + } + + if ('edit' === $action) { + return parent::createFormFor($action, $entity, $formClass, ['step' => 'edit']); + } + + throw new LogicException('action is not supported: ' . $action); + } + protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator) { $query->addOrderBy('e.ordering', 'ASC'); diff --git a/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialIssueType.php b/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialIssueType.php index d8b9fdba9..0435b5573 100644 --- a/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialIssueType.php +++ b/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialIssueType.php @@ -36,12 +36,19 @@ class SocialIssueType extends AbstractType $builder ->add('title', TranslatableStringFormType::class, [ 'label' => 'Nom', - ]) - ->add('parent', EntityType::class, [ - 'class' => SocialIssue::class, - 'required' => false, - 'choice_label' => fn (SocialIssue $issue): ?string => $this->translatableStringHelper->localize($issue->getTitle()), - ]) + ]); + + if ('create' === $options['step']) { + $builder + ->add('parent', EntityType::class, [ + 'class' => SocialIssue::class, + 'required' => false, + 'choice_label' => fn (SocialIssue $issue): ?string => $this->translatableStringHelper->localize($issue->getTitle()), + 'mapped' => 'create' === $options['step'], + ]); + } + + $builder ->add('ordering', NumberType::class, [ 'required' => true, 'scale' => 6, @@ -55,5 +62,8 @@ class SocialIssueType extends AbstractType public function configureOptions(OptionsResolver $resolver) { $resolver->setDefault('class', SocialIssue::class); + + $resolver->setRequired('step') + ->setAllowedValues('step', ['create', 'edit']); } } diff --git a/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialIssue/edit.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialIssue/edit.html.twig index ffad69128..34c524132 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialIssue/edit.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialIssue/edit.html.twig @@ -8,15 +8,19 @@ {% embed '@ChillMain/CRUD/_edit_content.html.twig' %} {% block crud_content_form_rows %} - {% for f in form %} - {% if f.vars.name == 'parent' %} - {{ form_row(f, { 'attr':{'disabled':'disabled'}}) }} - {% else %} - {{ form_row(f) }} - {% endif %} - {% endfor %} + {{ form_row(form.title) }} +
      + +
      + {{ entity.parent|chill_entity_render_box }} +
      +
      + {{ form_row(form.ordering) }} + {{ form_row(form.desactivationDate) }} {% endblock crud_content_form_rows %} {% block content_form_actions_save_and_show %}{% endblock %} {% endembed %} -{% endblock admin_content %} \ No newline at end of file +{% endblock admin_content %} From 239a978adb382d0c5dcc4ad6ae0f8f66a813a5dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 13 Jan 2023 18:15:51 +0100 Subject: [PATCH 53/60] Fixed: [wopi] effectively use the ChillDocumentLockManager --- src/Bundle/ChillWopiBundle/src/Resources/config/services.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillWopiBundle/src/Resources/config/services.php b/src/Bundle/ChillWopiBundle/src/Resources/config/services.php index e7ca90dbc..5f38ebb74 100644 --- a/src/Bundle/ChillWopiBundle/src/Resources/config/services.php +++ b/src/Bundle/ChillWopiBundle/src/Resources/config/services.php @@ -15,6 +15,7 @@ use ChampsLibres\AsyncUploaderBundle\TempUrl\TempUrlGeneratorInterface; use ChampsLibres\WopiBundle\Contracts\AuthorizationManagerInterface; use ChampsLibres\WopiBundle\Contracts\UserManagerInterface; use ChampsLibres\WopiBundle\Service\Wopi as CLWopi; +use ChampsLibres\WopiLib\Contract\Service\DocumentLockManagerInterface; use ChampsLibres\WopiLib\Contract\Service\DocumentManagerInterface; use Chill\WopiBundle\Service\Wopi\AuthorizationManager; use Chill\WopiBundle\Service\Wopi\ChillDocumentLockManager; @@ -47,7 +48,9 @@ return static function (ContainerConfigurator $container) { ->alias(DocumentManagerInterface::class, ChillDocumentManager::class); $services - ->set(ChillDocumentLockManager::class); + ->set(ChillDocumentLockManager::class) + ->decorate(DocumentLockManagerInterface::class) + ; $services ->set(AuthorizationManager::class); From 4a56c4c9450ef6c14e03e76bf080c0684180f93c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 16 Jan 2023 11:19:25 +0100 Subject: [PATCH 54/60] Fixed: correct link for "edit wopi document" in javascript The link was hardcoded, but not correctly adapted --- .../AccompanyingCourseWorkEdit/components/FormEvaluation.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue index e423838d1..66918ad71 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue @@ -360,7 +360,7 @@ export default { ; }, buildEditLink(storedObject) { - return `/wopi/edit/${storedObject.uuid}?returnPath=` + encodeURIComponent( + return `/chill/wopi/edit/${storedObject.uuid}?returnPath=` + encodeURIComponent( window.location.pathname + window.location.search + window.location.hash); }, submitBeforeGenerate({template}) { From 4fec18f3aa519a842b12f63113fcfb025ed44cdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 19 Jan 2023 13:20:10 +0100 Subject: [PATCH 55/60] Fixed: [wopi] add a "graceful period" when removing a lock This ensure that requests like putFile, which comes in the same time frame, encounter a "document is unlocked" error. --- .../src/Service/Wopi/ChillDocumentLockManager.php | 13 ++++++++++--- .../src/Service/Wopi/ChillDocumentManager.php | 4 +++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentLockManager.php b/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentLockManager.php index 30388852b..185256238 100644 --- a/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentLockManager.php +++ b/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentLockManager.php @@ -21,7 +21,10 @@ class ChillDocumentLockManager implements DocumentLockManagerInterface { private const LOCK_DURATION = 60 * 30; - private int $postDeleteLockDurationMs; + /** + * Number of seconds to keep the lock after the delete lock operation + */ + private const LOCK_GRACEFUL_DURATION_TIME = 3; private ChillRedis $redis; @@ -32,9 +35,13 @@ class ChillDocumentLockManager implements DocumentLockManagerInterface public function deleteLock(Document $document, RequestInterface $request): bool { - $this->redis->del($this->getCacheId($document)); + if (0 === $this->redis->exists($this->getCacheId($document))) { + return true; + } - return true; + // some queries (ex.: putFile) may be executed on the same time than the unlock, so + // we add a delay before unlocking the file, instead of deleting it immediatly + return $this->redis->expire($this->getCacheId($document), self::LOCK_GRACEFUL_DURATION_TIME); } public function getLock(Document $document, RequestInterface $request): string diff --git a/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentManager.php b/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentManager.php index 8b6e3f846..7eb738469 100644 --- a/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentManager.php +++ b/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentManager.php @@ -87,7 +87,9 @@ final class ChillDocumentManager implements DocumentManagerInterface public function deleteLock(Document $document): void { - $this->documentLockManager->deleteLock($document, $this->request); + if (false ===$this->documentLockManager->deleteLock($document, $this->request)) { + throw new \RuntimeException("could not remove the lock"); + } } /** From 7915aae86fcd8eb68a5468229cc2dbc519acbaaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 19 Jan 2023 13:27:08 +0100 Subject: [PATCH 56/60] Feature: [workflow] do not send a notification for each step to creator's workflow Now, by default: - the creator will receive a notification for the last step only; - the participant / assignee for each step won't receive a notification (unless they explicitly choose to receive one) --- src/Bundle/ChillMainBundle/Controller/WorkflowController.php | 1 - .../ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php | 4 ---- 2 files changed, 5 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php index 9be2f04fd..17b5db75e 100644 --- a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php +++ b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php @@ -85,7 +85,6 @@ class WorkflowController extends AbstractController ->setRelatedEntityClass($request->query->get('entityClass')) ->setRelatedEntityId($request->query->getInt('entityId')) ->setWorkflowName($request->query->get('workflow')) - ->addSubscriberToStep($this->getUser()) ->addSubscriberToFinal($this->getUser()); $errors = $this->validator->validate($entityWorkflow, null, ['creation']); diff --git a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php index d86770560..4bff7a3f5 100644 --- a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php +++ b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php @@ -132,8 +132,6 @@ class EntityWorkflowStep { if (!$this->destUser->contains($user)) { $this->destUser[] = $user; - $this->getEntityWorkflow() - ->addSubscriberToFinal($user); } return $this; @@ -143,8 +141,6 @@ class EntityWorkflowStep { if (!$this->destUserByAccessKey->contains($user) && !$this->destUser->contains($user)) { $this->destUserByAccessKey[] = $user; - $this->getEntityWorkflow() - ->addSubscriberToFinal($user); } return $this; From bd324753f38997d0a60af17caa905c655895a09e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 19 Jan 2023 13:28:13 +0100 Subject: [PATCH 57/60] DX: fix cs --- src/Bundle/ChillWopiBundle/src/Resources/config/services.php | 3 +-- .../src/Service/Wopi/ChillDocumentLockManager.php | 2 +- .../ChillWopiBundle/src/Service/Wopi/ChillDocumentManager.php | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillWopiBundle/src/Resources/config/services.php b/src/Bundle/ChillWopiBundle/src/Resources/config/services.php index 5f38ebb74..fc19e9c0d 100644 --- a/src/Bundle/ChillWopiBundle/src/Resources/config/services.php +++ b/src/Bundle/ChillWopiBundle/src/Resources/config/services.php @@ -49,8 +49,7 @@ return static function (ContainerConfigurator $container) { $services ->set(ChillDocumentLockManager::class) - ->decorate(DocumentLockManagerInterface::class) - ; + ->decorate(DocumentLockManagerInterface::class); $services ->set(AuthorizationManager::class); diff --git a/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentLockManager.php b/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentLockManager.php index 185256238..fce25de58 100644 --- a/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentLockManager.php +++ b/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentLockManager.php @@ -22,7 +22,7 @@ class ChillDocumentLockManager implements DocumentLockManagerInterface private const LOCK_DURATION = 60 * 30; /** - * Number of seconds to keep the lock after the delete lock operation + * Number of seconds to keep the lock after the delete lock operation. */ private const LOCK_GRACEFUL_DURATION_TIME = 3; diff --git a/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentManager.php b/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentManager.php index 7eb738469..19b4dc9b4 100644 --- a/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentManager.php +++ b/src/Bundle/ChillWopiBundle/src/Service/Wopi/ChillDocumentManager.php @@ -87,8 +87,8 @@ final class ChillDocumentManager implements DocumentManagerInterface public function deleteLock(Document $document): void { - if (false ===$this->documentLockManager->deleteLock($document, $this->request)) { - throw new \RuntimeException("could not remove the lock"); + if (false === $this->documentLockManager->deleteLock($document, $this->request)) { + throw new RuntimeException('could not remove the lock'); } } From e87f0bf34869bd70759ab4a61468c8f9ec6dffbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 19 Jan 2023 13:52:24 +0100 Subject: [PATCH 58/60] Fixed: a userid can be null --- src/Bundle/ChillMainBundle/Entity/User.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Entity/User.php b/src/Bundle/ChillMainBundle/Entity/User.php index 1317edf83..dda6b63e4 100644 --- a/src/Bundle/ChillMainBundle/Entity/User.php +++ b/src/Bundle/ChillMainBundle/Entity/User.php @@ -224,7 +224,7 @@ class User implements UserInterface /** * Get id. */ - public function getId(): int + public function getId(): ?int { return $this->id; } From 99482edf0da9984585b807bf2fff45769aa40c56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 19 Jan 2023 23:21:28 +0100 Subject: [PATCH 59/60] Fixed: remove the "preload" component, and do not preload the period's json This didn't accelerated the loading of period's pages, and make the period's json loaded twice. --- composer.json | 1 - .../Resources/views/AccompanyingCourse/layout.html.twig | 4 ---- 2 files changed, 5 deletions(-) diff --git a/composer.json b/composer.json index 7a6b5cf7a..9447d6db5 100644 --- a/composer.json +++ b/composer.json @@ -52,7 +52,6 @@ "symfony/translation": "^4.4", "symfony/twig-bundle": "^4.4", "symfony/validator": "^4.4", - "symfony/web-link": "*", "symfony/webpack-encore-bundle": "^1.11", "symfony/workflow": "^4.4", "symfony/yaml": "^4.4", diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/layout.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/layout.html.twig index f54cbbb33..bd16a1fbe 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/layout.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/layout.html.twig @@ -1,9 +1,5 @@ {% extends "@ChillMain/layoutWithVerticalMenu.html.twig" %} -{% block head_custom %} - -{% endblock %} - {% block top_banner %} {{ include('@ChillPerson/AccompanyingCourse/banner.html.twig', { title: block('title') }) }} {% endblock %} From c4eb45edccae0301af76d39cad341beb96eeb1e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 23 Jan 2023 20:40:01 +0000 Subject: [PATCH 60/60] Feature: allow to administrate budget resources and charges from the admin --- .../Controller/Admin/AdminController.php | 26 +++++ .../Controller/Admin/ChargeKindController.php | 28 +++++ .../Admin/ResourceKindController.php | 28 +++++ .../ChillBudgetExtension.php | 56 +++++++++ .../DependencyInjection/Configuration.php | 2 + .../ChillBudgetBundle/Entity/Charge.php | 18 +++ .../ChillBudgetBundle/Entity/ChargeKind.php | 108 ++++++++++++++++++ .../ChillBudgetBundle/Entity/Resource.php | 18 +++ .../ChillBudgetBundle/Entity/ResourceKind.php | 108 ++++++++++++++++++ .../Form/Admin/ChargeKindType.php | 42 +++++++ .../Form/Admin/ResourceKindType.php | 42 +++++++ .../ChillBudgetBundle/Form/ChargeType.php | 29 ++++- .../ChillBudgetBundle/Form/ResourceType.php | 31 +++-- .../Menu/AdminMenuBuilder.php | 62 ++++++++++ .../Repository/ChargeKindRepository.php | 84 ++++++++++++++ .../Repository/ResourceKindRepository.php | 84 ++++++++++++++ .../views/Admin/Charge/edit.html.twig | 12 ++ .../views/Admin/Charge/index.html.twig | 49 ++++++++ .../views/Admin/Charge/new.html.twig | 11 ++ .../views/Admin/Resource/edit.html.twig | 12 ++ .../views/Admin/Resource/index.html.twig | 49 ++++++++ .../views/Admin/Resource/new.html.twig | 11 ++ .../Resources/views/Admin/index.html.twig | 14 +++ .../Resources/views/Budget/_macros.html.twig | 6 +- .../views/Charge/confirm_delete.html.twig | 4 +- .../Resources/views/Charge/edit.html.twig | 2 +- .../Resources/views/Charge/new.html.twig | 2 +- .../Resources/views/Charge/view.html.twig | 2 +- .../Entity/budget_element_type.html.twig | 1 + .../views/Resource/confirm_delete.html.twig | 4 +- .../Resources/views/Resource/edit.html.twig | 2 +- .../Resources/views/Resource/new.html.twig | 3 +- .../Resources/views/Resource/view.html.twig | 2 +- .../Templating/BudgetElementTypeRender.php | 55 +++++++++ .../config/services/controller.yaml | 4 + .../config/services/form.yaml | 17 +-- .../config/services/menu.yaml | 7 +- .../config/services/repository.yaml | 5 + .../config/services/templating.yaml | 10 +- .../migrations/Version20221116163445.php | 39 +++++++ .../migrations/Version20221130101659.php | 41 +++++++ .../migrations/Version20221202165608.php | 41 +++++++ .../migrations/Version20221207105407.php | 81 +++++++++++++ .../translations/messages.fr.yml | 27 +++++ .../Controller/RegroupmentController.php | 26 +++++ .../ChillMainExtension.php | 24 ++++ .../ChillMainBundle/Entity/Regroupment.php | 95 +++++++++++++++ .../ChillMainBundle/Form/RegroupmentType.php | 47 ++++++++ .../views/Admin/Regroupment/edit.html.twig | 11 ++ .../views/Admin/Regroupment/index.html.twig | 39 +++++++ .../views/Admin/Regroupment/new.html.twig | 11 ++ .../MenuBuilder/AdminUserMenuBuilder.php | 4 + .../config/services/controller.yaml | 4 + .../ChillMainBundle/config/services/form.yaml | 4 + .../migrations/Version20230111104315.php | 43 +++++++ .../translations/messages.fr.yml | 6 + .../Service/Wopi/ChillDocumentLockManager.php | 2 +- 57 files changed, 1546 insertions(+), 49 deletions(-) create mode 100644 src/Bundle/ChillBudgetBundle/Controller/Admin/AdminController.php create mode 100644 src/Bundle/ChillBudgetBundle/Controller/Admin/ChargeKindController.php create mode 100644 src/Bundle/ChillBudgetBundle/Controller/Admin/ResourceKindController.php create mode 100644 src/Bundle/ChillBudgetBundle/Entity/ChargeKind.php create mode 100644 src/Bundle/ChillBudgetBundle/Entity/ResourceKind.php create mode 100644 src/Bundle/ChillBudgetBundle/Form/Admin/ChargeKindType.php create mode 100644 src/Bundle/ChillBudgetBundle/Form/Admin/ResourceKindType.php create mode 100644 src/Bundle/ChillBudgetBundle/Menu/AdminMenuBuilder.php create mode 100644 src/Bundle/ChillBudgetBundle/Repository/ChargeKindRepository.php create mode 100644 src/Bundle/ChillBudgetBundle/Repository/ResourceKindRepository.php create mode 100644 src/Bundle/ChillBudgetBundle/Resources/views/Admin/Charge/edit.html.twig create mode 100644 src/Bundle/ChillBudgetBundle/Resources/views/Admin/Charge/index.html.twig create mode 100644 src/Bundle/ChillBudgetBundle/Resources/views/Admin/Charge/new.html.twig create mode 100644 src/Bundle/ChillBudgetBundle/Resources/views/Admin/Resource/edit.html.twig create mode 100644 src/Bundle/ChillBudgetBundle/Resources/views/Admin/Resource/index.html.twig create mode 100644 src/Bundle/ChillBudgetBundle/Resources/views/Admin/Resource/new.html.twig create mode 100644 src/Bundle/ChillBudgetBundle/Resources/views/Admin/index.html.twig create mode 100644 src/Bundle/ChillBudgetBundle/Resources/views/Entity/budget_element_type.html.twig create mode 100644 src/Bundle/ChillBudgetBundle/Templating/BudgetElementTypeRender.php create mode 100644 src/Bundle/ChillBudgetBundle/config/services/repository.yaml create mode 100644 src/Bundle/ChillBudgetBundle/migrations/Version20221116163445.php create mode 100644 src/Bundle/ChillBudgetBundle/migrations/Version20221130101659.php create mode 100644 src/Bundle/ChillBudgetBundle/migrations/Version20221202165608.php create mode 100644 src/Bundle/ChillBudgetBundle/migrations/Version20221207105407.php create mode 100644 src/Bundle/ChillMainBundle/Controller/RegroupmentController.php create mode 100644 src/Bundle/ChillMainBundle/Entity/Regroupment.php create mode 100644 src/Bundle/ChillMainBundle/Form/RegroupmentType.php create mode 100644 src/Bundle/ChillMainBundle/Resources/views/Admin/Regroupment/edit.html.twig create mode 100644 src/Bundle/ChillMainBundle/Resources/views/Admin/Regroupment/index.html.twig create mode 100644 src/Bundle/ChillMainBundle/Resources/views/Admin/Regroupment/new.html.twig create mode 100644 src/Bundle/ChillMainBundle/migrations/Version20230111104315.php diff --git a/src/Bundle/ChillBudgetBundle/Controller/Admin/AdminController.php b/src/Bundle/ChillBudgetBundle/Controller/Admin/AdminController.php new file mode 100644 index 000000000..998775fbe --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Controller/Admin/AdminController.php @@ -0,0 +1,26 @@ +render('@ChillBudget/Admin/index.html.twig'); + } +} diff --git a/src/Bundle/ChillBudgetBundle/Controller/Admin/ChargeKindController.php b/src/Bundle/ChillBudgetBundle/Controller/Admin/ChargeKindController.php new file mode 100644 index 000000000..e1989176d --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Controller/Admin/ChargeKindController.php @@ -0,0 +1,28 @@ +addOrderBy('e.ordering', 'ASC'); + + return $query; + } +} diff --git a/src/Bundle/ChillBudgetBundle/Controller/Admin/ResourceKindController.php b/src/Bundle/ChillBudgetBundle/Controller/Admin/ResourceKindController.php new file mode 100644 index 000000000..90b8e750a --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Controller/Admin/ResourceKindController.php @@ -0,0 +1,28 @@ +addOrderBy('e.ordering', 'ASC'); + + return $query; + } +} diff --git a/src/Bundle/ChillBudgetBundle/DependencyInjection/ChillBudgetExtension.php b/src/Bundle/ChillBudgetBundle/DependencyInjection/ChillBudgetExtension.php index b5cb3a9c1..ed7fd1ae9 100644 --- a/src/Bundle/ChillBudgetBundle/DependencyInjection/ChillBudgetExtension.php +++ b/src/Bundle/ChillBudgetBundle/DependencyInjection/ChillBudgetExtension.php @@ -11,6 +11,10 @@ declare(strict_types=1); namespace Chill\BudgetBundle\DependencyInjection; +use Chill\BudgetBundle\Controller\Admin\ChargeKindController; +use Chill\BudgetBundle\Controller\Admin\ResourceKindController; +use Chill\BudgetBundle\Entity\ChargeKind; +use Chill\BudgetBundle\Entity\ResourceKind; use Chill\BudgetBundle\Security\Authorization\BudgetElementVoter; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -33,6 +37,7 @@ class ChillBudgetExtension extends Extension implements PrependExtensionInterfac $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../config')); $loader->load('services/config.yaml'); $loader->load('services/form.yaml'); + $loader->load('services/repository.yaml'); $loader->load('services/security.yaml'); $loader->load('services/controller.yaml'); $loader->load('services/templating.yaml'); @@ -48,6 +53,7 @@ class ChillBudgetExtension extends Extension implements PrependExtensionInterfac { $this->prependAuthorization($container); $this->prependRoutes($container); + $this->prependCruds($container); } /** (non-PHPdoc). @@ -75,6 +81,56 @@ class ChillBudgetExtension extends Extension implements PrependExtensionInterfac ]); } + protected function prependCruds(ContainerBuilder $container) + { + $container->prependExtensionConfig('chill_main', [ + 'cruds' => [ + [ + 'class' => ChargeKind::class, + 'name' => 'charge_kind', + 'base_path' => '/admin/budget/charge-kind', + 'form_class' => \Chill\BudgetBundle\Form\Admin\ChargeKindType::class, + 'controller' => ChargeKindController::class, + 'actions' => [ + 'index' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillBudget/Admin/Charge/index.html.twig', + ], + 'new' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillBudget/Admin/Charge/new.html.twig', + ], + 'edit' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillBudget/Admin/Charge/edit.html.twig', + ], + ], + ], + [ + 'class' => ResourceKind::class, + 'name' => 'resource_kind', + 'base_path' => '/admin/budget/resource-kind', + 'form_class' => \Chill\BudgetBundle\Form\Admin\ResourceKindType::class, + 'controller' => ResourceKindController::class, + 'actions' => [ + 'index' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillBudget/Admin/Resource/index.html.twig', + ], + 'new' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillBudget/Admin/Resource/new.html.twig', + ], + 'edit' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillBudget/Admin/Resource/edit.html.twig', + ], + ], + ], + ], + ]); + } + protected function storeConfig($position, array $config, ContainerBuilder $container) { $container diff --git a/src/Bundle/ChillBudgetBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillBudgetBundle/DependencyInjection/Configuration.php index cf8f72a16..8856df22b 100644 --- a/src/Bundle/ChillBudgetBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillBudgetBundle/DependencyInjection/Configuration.php @@ -26,6 +26,7 @@ class Configuration implements ConfigurationInterface // ressources ->arrayNode('resources')->defaultValue([]) + ->setDeprecated('Chill', '2.0', 'Since the introduction of budget admin entities, config is no longer used') ->arrayPrototype() ->children() ->scalarNode('key')->isRequired()->cannotBeEmpty() @@ -49,6 +50,7 @@ class Configuration implements ConfigurationInterface ->end() ->end() ->arrayNode('charges')->defaultValue([]) + ->setDeprecated('Chill', '2.0', 'Since the introduction of budget admin entities, config is no longer used') ->arrayPrototype() ->children() ->scalarNode('key')->isRequired()->cannotBeEmpty() diff --git a/src/Bundle/ChillBudgetBundle/Entity/Charge.php b/src/Bundle/ChillBudgetBundle/Entity/Charge.php index eab153b2e..056e4abff 100644 --- a/src/Bundle/ChillBudgetBundle/Entity/Charge.php +++ b/src/Bundle/ChillBudgetBundle/Entity/Charge.php @@ -39,6 +39,12 @@ class Charge extends AbstractElement implements HasCentersInterface self::HELP_NOT_RELEVANT, ]; + /** + * @ORM\ManyToOne(targetEntity=ChargeKind::class, inversedBy="AbstractElement") + * @ORM\JoinColumn + */ + private ?ChargeKind $charge = null; + /** * @var string * @ORM\Column(name="help", type="string", nullable=true) @@ -66,6 +72,11 @@ class Charge extends AbstractElement implements HasCentersInterface return $this->getHousehold()->getCurrentPersons()->map(static fn (Person $p) => $p->getCenter())->toArray(); } + public function getCharge(): ?ChargeKind + { + return $this->charge; + } + public function getHelp() { return $this->help; @@ -91,6 +102,13 @@ class Charge extends AbstractElement implements HasCentersInterface return false; } + public function setCharge(?ChargeKind $charge): self + { + $this->charge = $charge; + + return $this; + } + public function setHelp($help) { $this->help = $help; diff --git a/src/Bundle/ChillBudgetBundle/Entity/ChargeKind.php b/src/Bundle/ChillBudgetBundle/Entity/ChargeKind.php new file mode 100644 index 000000000..d1393eafb --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Entity/ChargeKind.php @@ -0,0 +1,108 @@ +id; + } + + public function getIsActive(): bool + { + return $this->isActive; + } + + public function getKind(): ?string + { + return $this->kind; + } + + public function getName(): ?array + { + return $this->name; + } + + public function getOrdering(): float + { + return $this->ordering; + } + + public function setIsActive(bool $isActive): self + { + $this->isActive = $isActive; + + return $this; + } + + public function setKind(?string $kind): self + { + $this->kind = $kind; + + return $this; + } + + public function setName(array $name): self + { + $this->name = $name; + + return $this; + } + + public function setOrdering(float $ordering): ChargeKind + { + $this->ordering = $ordering; + + return $this; + } +} diff --git a/src/Bundle/ChillBudgetBundle/Entity/Resource.php b/src/Bundle/ChillBudgetBundle/Entity/Resource.php index bed9f23c3..28b8645e0 100644 --- a/src/Bundle/ChillBudgetBundle/Entity/Resource.php +++ b/src/Bundle/ChillBudgetBundle/Entity/Resource.php @@ -31,6 +31,12 @@ class Resource extends AbstractElement implements HasCentersInterface */ private ?int $id = null; + /** + * @ORM\ManyToOne(targetEntity=ResourceKind::class, inversedBy="AbstractElement") + * @ORM\JoinColumn + */ + private ?ResourceKind $resource = null; + public function __construct() { $this->setStartDate(new DateTimeImmutable('today')); @@ -55,6 +61,11 @@ class Resource extends AbstractElement implements HasCentersInterface return $this->id; } + public function getResource(): ?ResourceKind + { + return $this->resource; + } + public function isCharge(): bool { return false; @@ -64,4 +75,11 @@ class Resource extends AbstractElement implements HasCentersInterface { return true; } + + public function setResource(?ResourceKind $resource): self + { + $this->resource = $resource; + + return $this; + } } diff --git a/src/Bundle/ChillBudgetBundle/Entity/ResourceKind.php b/src/Bundle/ChillBudgetBundle/Entity/ResourceKind.php new file mode 100644 index 000000000..5d88af298 --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Entity/ResourceKind.php @@ -0,0 +1,108 @@ +id; + } + + public function getIsActive(): bool + { + return $this->isActive; + } + + public function getKind(): ?string + { + return $this->kind; + } + + public function getName(): ?array + { + return $this->name; + } + + public function getOrdering(): float + { + return $this->ordering; + } + + public function setIsActive(bool $isActive): self + { + $this->isActive = $isActive; + + return $this; + } + + public function setKind(?string $kind): self + { + $this->kind = $kind; + + return $this; + } + + public function setName(array $name): self + { + $this->name = $name; + + return $this; + } + + public function setOrdering(float $ordering): self + { + $this->ordering = $ordering; + + return $this; + } +} diff --git a/src/Bundle/ChillBudgetBundle/Form/Admin/ChargeKindType.php b/src/Bundle/ChillBudgetBundle/Form/Admin/ChargeKindType.php new file mode 100644 index 000000000..661199aec --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Form/Admin/ChargeKindType.php @@ -0,0 +1,42 @@ +add('name', TranslatableStringFormType::class, [ + 'label' => 'Nom', + ]) + ->add('ordering', NumberType::class) + ->add('isActive', CheckboxType::class, [ + 'label' => 'Actif ?', + 'required' => false, + ]); + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver + ->setDefault('class', ChargeKind::class); + } +} diff --git a/src/Bundle/ChillBudgetBundle/Form/Admin/ResourceKindType.php b/src/Bundle/ChillBudgetBundle/Form/Admin/ResourceKindType.php new file mode 100644 index 000000000..7b2622c5d --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Form/Admin/ResourceKindType.php @@ -0,0 +1,42 @@ +add('name', TranslatableStringFormType::class, [ + 'label' => 'Nom', + ]) + ->add('ordering', NumberType::class) + ->add('isActive', CheckboxType::class, [ + 'label' => 'Actif ?', + 'required' => false, + ]); + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver + ->setDefault('class', ResourceKind::class); + } +} diff --git a/src/Bundle/ChillBudgetBundle/Form/ChargeType.php b/src/Bundle/ChillBudgetBundle/Form/ChargeType.php index 387c1e424..3dc2e230c 100644 --- a/src/Bundle/ChillBudgetBundle/Form/ChargeType.php +++ b/src/Bundle/ChillBudgetBundle/Form/ChargeType.php @@ -13,15 +13,18 @@ namespace Chill\BudgetBundle\Form; use Chill\BudgetBundle\Config\ConfigRepository; use Chill\BudgetBundle\Entity\Charge; +use Chill\BudgetBundle\Entity\ChargeKind; +use Chill\BudgetBundle\Repository\ChargeKindRepository; use Chill\MainBundle\Form\Type\ChillDateType; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\MoneyType; use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; - +use Symfony\Contracts\Translation\TranslatorInterface; use function array_flip; use function asort; @@ -31,21 +34,35 @@ class ChargeType extends AbstractType protected TranslatableStringHelperInterface $translatableStringHelper; + private ChargeKindRepository $repository; + + private TranslatorInterface $translator; + public function __construct( ConfigRepository $configRepository, - TranslatableStringHelperInterface $translatableStringHelper + TranslatableStringHelperInterface $translatableStringHelper, + ChargeKindRepository $repository, + TranslatorInterface $translator ) { $this->configRepository = $configRepository; $this->translatableStringHelper = $translatableStringHelper; + $this->repository = $repository; + $this->translator = $translator; } public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('type', ChoiceType::class, [ - 'choices' => $this->getTypes(), - 'placeholder' => 'Choose a charge type', - 'attr' => ['class' => ' select2 '], + ->add('charge', EntityType::class, [ + 'class' => ChargeKind::class, + 'choices' => $this->repository->findAllActive(), + 'label' => 'Charge type', + 'required' => true, + 'placeholder' => $this->translator->trans('admin.form.Choose the type of charge'), + 'choice_label' => function (ChargeKind $resource) { + return $this->translatableStringHelper->localize($resource->getName()); + }, + 'attr' => ['class' => 'select2'], ]) ->add('amount', MoneyType::class) ->add('comment', TextareaType::class, [ diff --git a/src/Bundle/ChillBudgetBundle/Form/ResourceType.php b/src/Bundle/ChillBudgetBundle/Form/ResourceType.php index 6239dace8..106f50ad1 100644 --- a/src/Bundle/ChillBudgetBundle/Form/ResourceType.php +++ b/src/Bundle/ChillBudgetBundle/Form/ResourceType.php @@ -13,15 +13,17 @@ namespace Chill\BudgetBundle\Form; use Chill\BudgetBundle\Config\ConfigRepository; use Chill\BudgetBundle\Entity\Resource; +use Chill\BudgetBundle\Entity\ResourceKind; +use Chill\BudgetBundle\Repository\ResourceKindRepository; use Chill\MainBundle\Form\Type\ChillDateType; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\MoneyType; use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; - +use Symfony\Contracts\Translation\TranslatorInterface; use function array_flip; class ResourceType extends AbstractType @@ -30,22 +32,35 @@ class ResourceType extends AbstractType protected TranslatableStringHelperInterface $translatableStringHelper; + private ResourceKindRepository $repository; + + private TranslatorInterface $translator; + public function __construct( ConfigRepository $configRepository, - TranslatableStringHelperInterface $translatableStringHelper + TranslatableStringHelperInterface $translatableStringHelper, + ResourceKindRepository $repository, + TranslatorInterface $translator ) { $this->configRepository = $configRepository; $this->translatableStringHelper = $translatableStringHelper; + $this->repository = $repository; + $this->translator = $translator; } public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('type', ChoiceType::class, [ - 'choices' => $this->getTypes(), - 'placeholder' => 'Choose a resource type', - 'label' => 'Resource element type', - 'attr' => ['class' => ' select2 '], + ->add('resource', EntityType::class, [ + 'class' => ResourceKind::class, + 'choices' => $this->repository->findAllActive(), + 'label' => 'Resource type', + 'required' => true, + 'placeholder' => $this->translator->trans('admin.form.Choose the type of resource'), + 'choice_label' => function (ResourceKind $resource) { + return $this->translatableStringHelper->localize($resource->getName()); + }, + 'attr' => ['class' => 'select2'], ]) ->add('amount', MoneyType::class) ->add('comment', TextareaType::class, [ diff --git a/src/Bundle/ChillBudgetBundle/Menu/AdminMenuBuilder.php b/src/Bundle/ChillBudgetBundle/Menu/AdminMenuBuilder.php new file mode 100644 index 000000000..894230ad9 --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Menu/AdminMenuBuilder.php @@ -0,0 +1,62 @@ +security = $security; + } + + public function buildMenu($menuId, MenuItem $menu, array $parameters) + { + // all the entries below must have ROLE_ADMIN permissions + if (!$this->security->isGranted('ROLE_ADMIN')) { + return; + } + + $menu->addChild('Budget', [ + 'route' => 'chill_admin_budget', + ]) + ->setAttribute('class', 'list-group-item-header') + ->setExtras([ + 'order' => 7050, + 'explain' => 'Budget resource and charge type configuration', + ]); + $menu + ->addChild('admin.menu.Resource types', [ + 'route' => 'chill_crud_resource_kind_index', + ]) + ->setExtras([ + 'order' => 7060, + ]); + $menu + ->addChild('admin.menu.Charge types', [ + 'route' => 'chill_crud_charge_kind_index', + ]) + ->setExtras([ + 'order' => 7070, + ]); + } + + public static function getMenuIds(): array + { + return ['admin_section', 'admin_budget']; + } +} diff --git a/src/Bundle/ChillBudgetBundle/Repository/ChargeKindRepository.php b/src/Bundle/ChillBudgetBundle/Repository/ChargeKindRepository.php new file mode 100644 index 000000000..e170a362a --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Repository/ChargeKindRepository.php @@ -0,0 +1,84 @@ +repository = $entityManager->getRepository(ChargeKind::class); + } + + public function find($id): ?ChargeKind + { + return $this->repository->find($id); + } + + /** + * @return ChargeType[] + */ + public function findAll(): array + { + return $this->repository->findAll(); + } + + /** + * @return ChargeType[] + */ + public function findAllActive(): array + { + $qb = $this->repository->createQueryBuilder('c'); + + return $qb + ->select('c') + ->where($qb->expr()->eq('c.isActive', 'true')) + ->orderBy('c.ordering', 'ASC') + ->getQuery() + ->getResult(); + } + + /** + * @return ChargeType[] + */ + public function findAllByType(string $type): array + { + return $this->findBy(['elementType' => $type]); + } + + /** + * @param mixed|null $limit + * @param mixed|null $offset + * + * @return ChargeType[] + */ + public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array + { + return $this->repository->findBy($criteria, $orderBy, $limit, $offset); + } + + public function findOneBy(array $criteria): ?ChargeKind + { + return $this->repository->findOneBy($criteria); + } + + public function getClassName(): string + { + return ChargeKind::class; + } +} diff --git a/src/Bundle/ChillBudgetBundle/Repository/ResourceKindRepository.php b/src/Bundle/ChillBudgetBundle/Repository/ResourceKindRepository.php new file mode 100644 index 000000000..03af9e083 --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Repository/ResourceKindRepository.php @@ -0,0 +1,84 @@ +repository = $entityManager->getRepository(ResourceKind::class); + } + + public function find($id): ?ResourceKind + { + return $this->repository->find($id); + } + + /** + * @return ResourceType[] + */ + public function findAll(): array + { + return $this->repository->findAll(); + } + + /** + * @return ResourceType[] + */ + public function findAllActive(): array + { + $qb = $this->repository->createQueryBuilder('r'); + + return $qb + ->select('r') + ->where($qb->expr()->eq('r.isActive', 'true')) + ->orderBy('r.ordering', 'ASC') + ->getQuery() + ->getResult(); + } + + /** + * @return ResourceType[] + */ + public function findAllByType(string $type): array + { + return $this->findBy(['elementType' => $type]); + } + + /** + * @param mixed|null $limit + * @param mixed|null $offset + * + * @return ResourceType[] + */ + public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array + { + return $this->repository->findBy($criteria, $orderBy, $limit, $offset); + } + + public function findOneBy(array $criteria): ?ResourceKind + { + return $this->repository->findOneBy($criteria); + } + + public function getClassName(): string + { + return ResourceKind::class; + } +} diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Charge/edit.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Charge/edit.html.twig new file mode 100644 index 000000000..3a60d3e9c --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Charge/edit.html.twig @@ -0,0 +1,12 @@ +{% extends '@ChillMain/CRUD/Admin/index.html.twig' %} + +{% block title %} + {% include('@ChillMain/CRUD/_edit_title.html.twig') %} +{% endblock %} + +{% block admin_content %} + {% embed '@ChillMain/CRUD/_edit_content.html.twig' %} + {% block content_form_actions_view %}{% endblock %} + {% block content_form_actions_save_and_show %}{% endblock %} + {% endembed %} +{% endblock %} diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Charge/index.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Charge/index.html.twig new file mode 100644 index 000000000..2486aaecf --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Charge/index.html.twig @@ -0,0 +1,49 @@ +{% extends '@ChillMain/Admin/layoutWithVerticalMenu.html.twig' %} + +{% block title %}{{ 'admin.title.Charge Type List'|trans }}{% endblock title %} + +{% block admin_content %} + +

      {{ 'admin.title.Charge Type List'|trans }}

      + + + + + + + + + + + + {% for entity in entities %} + + + + + + + {% endfor %} + +
      {{ 'Ordering'|trans }}{{ 'Name'|trans }}{{ 'Active'|trans }} 
      {{ entity.ordering }}{{ entity|chill_entity_render_box }} + {%- if entity.isActive -%} + + {%- else -%} + + {%- endif -%} + +
        +
      • + +
      • +
      +
      + + +{% endblock %} diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Charge/new.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Charge/new.html.twig new file mode 100644 index 000000000..00ebd2938 --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Charge/new.html.twig @@ -0,0 +1,11 @@ +{% extends '@ChillMain/CRUD/Admin/index.html.twig' %} + +{% block title %} + {% include('@ChillMain/CRUD/_new_title.html.twig') %} +{% endblock %} + +{% block admin_content %} + {% embed '@ChillMain/CRUD/_new_content.html.twig' %} + {% block content_form_actions_save_and_show %}{% endblock %} + {% endembed %} +{% endblock %} diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Resource/edit.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Resource/edit.html.twig new file mode 100644 index 000000000..3a60d3e9c --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Resource/edit.html.twig @@ -0,0 +1,12 @@ +{% extends '@ChillMain/CRUD/Admin/index.html.twig' %} + +{% block title %} + {% include('@ChillMain/CRUD/_edit_title.html.twig') %} +{% endblock %} + +{% block admin_content %} + {% embed '@ChillMain/CRUD/_edit_content.html.twig' %} + {% block content_form_actions_view %}{% endblock %} + {% block content_form_actions_save_and_show %}{% endblock %} + {% endembed %} +{% endblock %} diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Resource/index.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Resource/index.html.twig new file mode 100644 index 000000000..35bf88609 --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Resource/index.html.twig @@ -0,0 +1,49 @@ +{% extends '@ChillMain/Admin/layoutWithVerticalMenu.html.twig' %} + +{% block title %}{{ 'admin.title.Resource Type List'|trans }}{% endblock title %} + +{% block admin_content %} + +

      {{ 'admin.title.Resource Type List'|trans }}

      + + + + + + + + + + + + {% for entity in entities %} + + + + + + + {% endfor %} + +
      {{ 'Ordering'|trans }}{{ 'Name'|trans }}{{ 'Active'|trans }} 
      {{ entity.ordering }}{{ entity|chill_entity_render_box }} + {%- if entity.isActive -%} + + {%- else -%} + + {%- endif -%} + +
        +
      • + +
      • +
      +
      + + +{% endblock %} diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Resource/new.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Resource/new.html.twig new file mode 100644 index 000000000..00ebd2938 --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Resource/new.html.twig @@ -0,0 +1,11 @@ +{% extends '@ChillMain/CRUD/Admin/index.html.twig' %} + +{% block title %} + {% include('@ChillMain/CRUD/_new_title.html.twig') %} +{% endblock %} + +{% block admin_content %} + {% embed '@ChillMain/CRUD/_new_content.html.twig' %} + {% block content_form_actions_save_and_show %}{% endblock %} + {% endembed %} +{% endblock %} diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Admin/index.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Admin/index.html.twig new file mode 100644 index 000000000..0e3beca04 --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Admin/index.html.twig @@ -0,0 +1,14 @@ +{% extends "@ChillMain/Admin/layoutWithVerticalMenu.html.twig" %} + +{% block vertical_menu_content %} + {{ chill_menu('admin_budget', { + 'layout': '@ChillMain/Admin/menu_admin_section.html.twig', + }) }} +{% endblock %} + +{% block layout_wvm_content %} + {% block admin_content %} + +

      {{ 'admin.title.Budget configuration'|trans }}

      + {% endblock %} +{% endblock %} diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_macros.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_macros.html.twig index 41b6f36df..e8d10578b 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_macros.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_macros.html.twig @@ -16,7 +16,11 @@
    - {{ f.type|budget_element_type_display(family) }} + {% if f.isResource %} + {{ f.resource.name|localize_translatable_string }} + {% else %} + {{ f.charge.name|localize_translatable_string }} + {% endif %} {{ f.amount|format_currency('EUR') }} {{ 'Label'|trans }}{{ 'Active'|trans }} 
    {{ entity.name }} + {% if entity.isActive %} + + {% else %} + + {% endif %} + +
      +
    • + +
    • +
    +