From ec38dc4d215da08abe78d55970b9625d85a1fd70 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 13 Jul 2022 10:08:18 +0200 Subject: [PATCH] add person exports in a group --- .../Resources/views/Export/layout.html.twig | 13 +++++-------- .../ChillPersonBundle/Export/Export/CountPerson.php | 8 +++++++- .../ChillPersonBundle/Export/Export/ListPerson.php | 8 +++++++- .../Export/Export/ListPersonDuplicate.php | 8 +++++++- .../ChillPersonBundle/translations/messages.fr.yml | 1 + 5 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/views/Export/layout.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Export/layout.html.twig index c9682621a..a51871b2c 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Export/layout.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Export/layout.html.twig @@ -26,10 +26,10 @@

{{ 'Exports list'|trans }}

+ {% for group, exports in grouped_exports %}{% if group != '_' %} -

{{ group }}

- -
+

{{ group|trans }}

+
{% for export_alias, export in exports %}

{{ export.title|trans }}

@@ -45,13 +45,10 @@ {% endif %}{% endfor %} {% if grouped_exports|keys|length > 1 %} -

{{ 'Ungrouped exports'|trans }}

+

{{ 'Ungrouped exports'|trans }}

{% endif %} -
-
- -
+
{% for export_alias,export in grouped_exports['_'] %}
diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php b/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php index 27774c885..115b3489e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php @@ -13,6 +13,7 @@ namespace Chill\PersonBundle\Export\Export; use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FormatterInterface; +use Chill\MainBundle\Export\GroupedExportInterface; use Chill\PersonBundle\Export\Declarations; use Chill\PersonBundle\Security\Authorization\PersonVoter; use Doctrine\ORM\EntityManagerInterface; @@ -22,7 +23,7 @@ use LogicException; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Security\Core\Role\Role; -class CountPerson implements ExportInterface +class CountPerson implements ExportInterface, GroupedExportInterface { /** * @var EntityManagerInterface @@ -114,4 +115,9 @@ class CountPerson implements ExportInterface { return [Declarations::PERSON_TYPE, Declarations::PERSON_IMPLIED_IN]; } + + public function getGroup(): string + { + return 'Exports of persons'; + } } diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php index d3bc2728a..f2f72aa29 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php @@ -16,6 +16,7 @@ use Chill\CustomFieldsBundle\Entity\CustomField; use Chill\CustomFieldsBundle\Service\CustomFieldProvider; use Chill\MainBundle\Export\ExportElementValidatedInterface; use Chill\MainBundle\Export\FormatterInterface; +use Chill\MainBundle\Export\GroupedExportInterface; use Chill\MainBundle\Export\ListInterface; use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Entity\Person; @@ -45,7 +46,7 @@ use function uniqid; /** * Render a list of people. */ -class ListPerson implements ExportElementValidatedInterface, ListInterface +class ListPerson implements ExportElementValidatedInterface, ListInterface, GroupedExportInterface { protected CustomFieldProvider $customFieldProvider; @@ -474,4 +475,9 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface return $uid; } + + public function getGroup(): string + { + return 'Exports of persons'; + } } diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php index d66c6be57..2c65acb84 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPersonDuplicate.php @@ -13,6 +13,7 @@ namespace Chill\PersonBundle\Export\Export; use Chill\MainBundle\Export\DirectExportInterface; use Chill\MainBundle\Export\ExportElementValidatedInterface; +use Chill\MainBundle\Export\GroupedExportInterface; use Chill\PersonBundle\Security\Authorization\PersonVoter; use Doctrine\ORM\EntityManagerInterface; use PhpOffice\PhpSpreadsheet\Spreadsheet; @@ -30,7 +31,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; /** * Render a list of duplicate peoples. */ -class ListPersonDuplicate implements DirectExportInterface, ExportElementValidatedInterface +class ListPersonDuplicate implements DirectExportInterface, ExportElementValidatedInterface, GroupedExportInterface { /** * @var float @@ -196,4 +197,9 @@ class ListPersonDuplicate implements DirectExportInterface, ExportElementValidat return $result->fetchAllAssociative(); } + + public function getGroup(): string + { + return 'Exports of persons'; + } } diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 5b0f571af..aad43627f 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -326,6 +326,7 @@ Pediod closing form is not valide: Le formulaire de fermeture n'est pas valide Accompanyied people: Personnes accompagnées ## exports +Exports of persons: Exports des personnes Count peoples by various parameters.: Compte le nombre de personnes en fonction de différents filtres. Count peoples: Nombre de personnes List peoples: Liste des personnes