From be71decee567ea1a2164c70a97ab0182330aa8ab Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Thu, 25 Nov 2021 14:03:45 +0100 Subject: [PATCH] concernedGroups.html.twig check if block isVisible, count block and adjust width --- .../views/Activity/concernedGroups.html.twig | 132 +++++++++--------- .../Activity/showAccompanyingCourse.html.twig | 2 +- 2 files changed, 69 insertions(+), 65 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/concernedGroups.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/concernedGroups.html.twig index 39c993dd3..f6b052265 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/concernedGroups.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/concernedGroups.html.twig @@ -3,89 +3,93 @@ {{ path(pathname, parms) }} {% endmacro %} -{% if context == 'person' %} - {% set blocs = [ - { 'title': 'Others persons'|trans, +{% macro computeWidth(nbBlocks) %} + {{ 'flex-basis: ' ~ (100 / nbBlocks)|round(1) ~ '%;' }} +{% endmacro %} + +{% set blocks = [] %} +{% if entity.activityType.personsVisible %} + {% if context == 'person' %} + {% set blocks = blocks|merge([{ + 'title': 'Others persons'|trans, 'items': entity.persons, 'path' : 'chill_person_view', 'key' : 'person_id' - }, - { 'title': 'Third parties'|trans, - 'items': entity.thirdParties, - 'path' : 'chill_crud_3party_3party_view', - 'key' : 'id' - }, - { 'title': 'Users concerned'|trans, - 'items': entity.users, - 'key' : 'id' - }, - ] %} -{% else %} - {% set blocs = [ - { 'title': 'Persons in accompanying course'|trans, + }]) %} + {% else %} + {% set blocks = blocks|merge([{ + 'title': 'Persons in accompanying course'|trans, 'items': entity.personsAssociated, 'path' : 'chill_person_view', 'key' : 'person_id' - }, - { 'title': 'Third persons'|trans, + },{ + 'title': 'Third persons'|trans, 'items': entity.personsNotAssociated, 'path' : 'chill_person_view', - 'key' : 'person_id' - }, - { 'title': 'Third parties'|trans, - 'items': entity.thirdParties, - 'path' : 'chill_crud_3party_3party_view', - 'key' : 'id' - }, - { 'title': 'Users concerned'|trans, - 'items': entity.users, - 'key' : 'id' - }, - ] %} + 'key' : 'person_id', + }]) %} + {% endif %} +{% endif %} +{% if entity.activityType.thirdPartiesVisible %} + {% set blocks = blocks|merge([{ + 'title': 'Third parties'|trans, + 'items': entity.thirdParties, + 'path' : 'chill_crud_3party_3party_view', + 'key' : 'id', + }]) %} +{% endif %} +{% if entity.activityType.usersVisible %} + {% set blocks = blocks|merge([{ + 'title': 'Users concerned'|trans, + 'items': entity.users, + 'key' : 'id', + }]) %} {% endif %} {% if (with_display == 'bloc') %}
- {% for bloc in blocs %} -
-
-
-

{{ bloc.title }}

-
-
- + {% for bloc in blocks %} + +
+
+
+

{{ bloc.title }}

+
+
+ +
-
+ {% endfor %}
{% endif %} {% if (with_display == 'row') %}
- {% for bloc in blocs %} + {% for bloc in blocks %}
{% if bloc.items|length > 0 %}

{{ bloc.title }}

@@ -118,7 +122,7 @@ {% if (with_display == 'wrap-list') %}
- {% for bloc in blocs %} + {% for bloc in blocks %}
{% if bloc.items|length > 0 %}
diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/showAccompanyingCourse.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/showAccompanyingCourse.html.twig index c6a87b87d..ada3ebbd6 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/showAccompanyingCourse.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/showAccompanyingCourse.html.twig @@ -9,7 +9,7 @@ {% block content -%}
- {% include 'ChillActivityBundle:Activity:show.html.twig' with {'context': 'accompanyingCourse'} %} + {% include 'ChillActivityBundle:Activity:show.html.twig' with {'context': 'accompanyingCourse'} %}
{% endblock content %}