From ff8a32a321c7682a22d116d4f6a7761fa738e855 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 20 Jul 2022 11:23:03 +0200 Subject: [PATCH 01/17] user scope filter: change query (TO CHECK) --- .../ChillPersonBundle/Export/Filter/UserScopeFilter.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/UserScopeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/UserScopeFilter.php index 58aaf1b67..8f4eefb88 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/UserScopeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/UserScopeFilter.php @@ -56,13 +56,10 @@ class UserScopeFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb - ->join('acp.user', 'u') - ->join('u.mainScope', 's') - ; + $qb->join('acp.scopes', 's'); $where = $qb->getDQLPart('where'); - $clause = $qb->expr()->in('u.mainScope', ':userscope'); + $clause = $qb->expr()->in('s.id', ':userscope'); if ($where instanceof Andx) { $where->add($clause); From 7f1dadc136eef38bfb536f96d1ae801096075e49 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 20 Jul 2022 11:24:13 +0200 Subject: [PATCH 02/17] user scope/job filters: improve translation in csv --- .../Export/Filter/UserJobFilter.php | 16 ++++++++++++++-- .../Export/Filter/UserScopeFilter.php | 16 ++++++++++++++-- .../translations/messages.fr.yml | 4 ++-- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/UserJobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/UserJobFilter.php index 6e2c7d19f..a3fe907b1 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/UserJobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/UserJobFilter.php @@ -46,8 +46,20 @@ class UserJobFilter implements FilterInterface public function describeAction($data, $format = 'string') { - // to complete.. - return ['Filtered by user jobs']; + $jobs = []; + + foreach ($data['accepted_userjob'] as $j) { + if ('null' === $j) { + $jobs[] = $this->translator->trans('Not given'); + } else { + $jobs[] = $this->translatableStringHelper->localize($j->getLabel()); + } + } + + return [ + 'Filtered by user jobs: only %jobs%', + ['%jobs%' => implode(', ', $jobs)], + ]; } public function addRole() diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/UserScopeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/UserScopeFilter.php index 8f4eefb88..f235d9b86 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/UserScopeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/UserScopeFilter.php @@ -45,8 +45,20 @@ class UserScopeFilter implements FilterInterface public function describeAction($data, $format = 'string') { - // to complete.. - return ['Filtered by user scopes']; + $scopes = []; + + foreach ($data['accepted_userscope'] as $s) { + if ('null' === $s) { + $scopes[] = $this->translator->trans('Not given'); + } else { + $scopes[] = $this->translatableStringHelper->localize($s->getName()); + } + } + + return [ + 'Filtered by user scopes: only %scopes%', + ['%scopes%' => implode(', ', $scopes)], + ]; } public function addRole() diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 122571198..7939a083d 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -378,11 +378,11 @@ Having an accompanying period closed after this date: Ayant une période d'accom Filter by user scope: Filtrer par service du référent Accepted userscope: Services -Filtered by user scopes: Filtré par service du référent +"Filtered by user scopes: only %scopes%": "Filtré par service du référent: uniquement %scopes%" Filter by user job: Filtrer par métier du référent Accepted userjob: Métiers -Filtered by user jobs: Filtré par métier du référent +"Filtered by user jobs: only %jobs%": "Filtré par métier du référent: uniquement %jobs%" ## aggregators Group people by nationality: Aggréger les personnes par nationalités From b60897632659a3e8c3e46750bd63586a3b6c0ab9 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 20 Jul 2022 13:47:15 +0200 Subject: [PATCH 03/17] exports: add new step filter --- .../Export/Filter/StepFilter.php | 85 +++++++++++++++++++ .../config/services/exports.yaml | 17 ++-- .../translations/messages.fr.yml | 10 ++- 3 files changed, 103 insertions(+), 9 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Export/Filter/StepFilter.php diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/StepFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/StepFilter.php new file mode 100644 index 000000000..4c2183a7a --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Filter/StepFilter.php @@ -0,0 +1,85 @@ + AccompanyingPeriod::STEP_DRAFT, + 'Confirmed' => AccompanyingPeriod::STEP_CONFIRMED, + 'Closed' => AccompanyingPeriod::STEP_CLOSED, + ]; + + private const DEFAULT_CHOICE = AccompanyingPeriod::STEP_CONFIRMED; + + /** + * @var TranslatorInterface + */ + protected $translator; + + public function __construct(TranslatorInterface $translator) + { + $this->translator = $translator; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('accepted_step', ChoiceType::class, [ + 'choices' => self::STEPS, + 'multiple' => false, + 'expanded' => true, + 'empty_data' => self::DEFAULT_CHOICE, + 'data' => self::DEFAULT_CHOICE, + ]); + } + + public function getTitle() + { + return 'Filter by step'; + } + + public function describeAction($data, $format = 'string') + { + $step = array_flip(self::STEPS)[$data['accepted_step']]; + + return ["Filtered by steps: only %step%", [ + '%step%' => $this->translator->trans($step) + ]]; + } + + public function addRole() + { + return null; + } + + public function alterQuery(QueryBuilder $qb, $data) + { + $where = $qb->getDQLPart('where'); + $clause = $qb->expr()->eq('acp.step', ':step'); + + // override original where clause + $where = $qb->expr()->andX($clause); + + $qb->add('where', $where); + $qb->setParameter('step', $data['accepted_step']); + } + + public function applyOn() + { + return Declarations::ACP_TYPE; + } + +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/config/services/exports.yaml b/src/Bundle/ChillPersonBundle/config/services/exports.yaml index 4cf752870..e58ba3ef5 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports.yaml @@ -61,19 +61,24 @@ services: chill.person.export.filter_userscope: class: Chill\PersonBundle\Export\Filter\UserScopeFilter - arguments: - $translator: '@translator' - $translatableStringHelper: '@Chill\MainBundle\Templating\TranslatableStringHelper' + autowire: true + autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_userscope_filter } chill.person.export.filter_userjob: class: Chill\PersonBundle\Export\Filter\UserJobFilter - arguments: - $translator: '@translator' - $translatableStringHelper: '@Chill\MainBundle\Templating\TranslatableStringHelper' + autowire: true + autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_userjob_filter } + + chill.person.export.filter_step: + class: Chill\PersonBundle\Export\Filter\StepFilter + autowire: true + autoconfigure: true + tags: + - { name: chill.export_filter, alias: accompanyingcourse_step_filter } chill.person.export.aggregator_nationality: class: Chill\PersonBundle\Export\Aggregator\NationalityAggregator diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 7939a083d..42b6e6840 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -384,6 +384,10 @@ Filter by user job: Filtrer par métier du référent Accepted userjob: Métiers "Filtered by user jobs: only %jobs%": "Filtré par métier du référent: uniquement %jobs%" +Filter by step: Filtrer par statut du parcours +Accepted step: Statuts +"Filtered by steps: only %step%": "Filtré par statut du parcours: uniquement %step%" + ## aggregators Group people by nationality: Aggréger les personnes par nationalités Group by level: Grouper par niveau @@ -536,9 +540,9 @@ occasional: ponctuel regular: régulier Confidential: confidentiel confidential: confidentiel -Draft: brouillon -Confirmed: en file active -Closed: Cloturé +Draft: Brouillon +Confirmed: En file active +Closed: Clôturé # Accompanying Course Accompanying Course: Parcours d'accompagnement From bb22317eb108380c3af0c25131e2953472c10603 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 20 Jul 2022 16:38:46 +0200 Subject: [PATCH 04/17] exports: add new social issues filter (wip) --- .../Export/Filter/SocialIssueFilter.php | 97 +++++++++++++++++++ .../config/services/exports.yaml | 7 ++ .../translations/messages.fr.yml | 4 + 3 files changed, 108 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/Export/Filter/SocialIssueFilter.php diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialIssueFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialIssueFilter.php new file mode 100644 index 000000000..eac3544f8 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialIssueFilter.php @@ -0,0 +1,97 @@ +translator = $translator; + $this->translatableStringHelper = $translatableStringHelper; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('accepted_socialissue', EntityType::class, [ + 'class' => SocialIssue::class, + 'choice_label' => function(SocialIssue $s) { + return $this->translatableStringHelper->localize($s->getTitle()); + }, + 'multiple' => true, + 'expanded' => true, + ]); + } + + public function getTitle() + { + return 'Filter by social issue'; + } + + public function describeAction($data, $format = 'string') + { + $issues = []; + + foreach ($data['accepted_socialissue'] as $i) { + if ('null' === $i) { + $issues[] = $this->translator->trans('Not given'); + } else { + $issues[] = $this->translatableStringHelper->localize($i->getTitle()); + } + } + + return [ + 'Filtered by socialissues: only %socialissues%', [ + '%socialissues%' => implode(', ', $issues) + ]]; + } + + public function addRole() + { + return null; + } + + public function alterQuery(QueryBuilder $qb, $data) + { + $qb->join('acp.socialIssues', 's'); + + $where = $qb->getDQLPart('where'); + $clause = $qb->expr()->in('s.id', ':socialissues'); + + if ($where instanceof Andx) { + $where->add($clause); + } else { + $where = $qb->expr()->andX($clause); + } + + $qb->add('where', $where); + $qb->setParameter('socialissues', $data['accepted_socialissue']); + } + + public function applyOn() + { + return Declarations::ACP_TYPE; + } + +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/config/services/exports.yaml b/src/Bundle/ChillPersonBundle/config/services/exports.yaml index e58ba3ef5..2a02707ed 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports.yaml @@ -73,6 +73,13 @@ services: tags: - { name: chill.export_filter, alias: accompanyingcourse_userjob_filter } + chill.person.export.filter_socialissue: + class: Chill\PersonBundle\Export\Filter\SocialIssueFilter + autowire: true + autoconfigure: true + tags: + - { name: chill.export_filter, alias: accompanyingcourse_socialissue_filter } + chill.person.export.filter_step: class: Chill\PersonBundle\Export\Filter\StepFilter autowire: true diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 42b6e6840..690936ae4 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -384,6 +384,10 @@ Filter by user job: Filtrer par métier du référent Accepted userjob: Métiers "Filtered by user jobs: only %jobs%": "Filtré par métier du référent: uniquement %jobs%" +Filter by social issue: Filtrer par problématiques sociales +Accepted socialissue: Problématiques sociales +"Filtered by socialissues: only %socialissues%": "Filtré par problématique sociale: uniquement %socialissues%" + Filter by step: Filtrer par statut du parcours Accepted step: Statuts "Filtered by steps: only %step%": "Filtré par statut du parcours: uniquement %step%" From 0d38d4df40b497758e9f58a4501e6755f2590ebf Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 20 Jul 2022 19:33:42 +0200 Subject: [PATCH 05/17] social issues filter: improve render with parents, add parents in where clause --- .../Export/Filter/SocialIssueFilter.php | 55 +++++++++++++++++-- 1 file changed, 50 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialIssueFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialIssueFilter.php index eac3544f8..f82873dcd 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialIssueFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialIssueFilter.php @@ -6,6 +6,7 @@ use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Entity\SocialWork\SocialIssue; use Chill\PersonBundle\Export\Declarations; +use Chill\PersonBundle\Templating\Entity\SocialIssueRender; use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; @@ -24,20 +25,27 @@ class SocialIssueFilter implements FilterInterface */ private TranslatableStringHelper $translatableStringHelper; + /** + * @var SocialIssueRender + */ + private SocialIssueRender $socialIssueRender; + public function __construct( TranslatorInterface $translator, - TranslatableStringHelper $translatableStringHelper + TranslatableStringHelper $translatableStringHelper, + SocialIssueRender $socialIssueRender ) { $this->translator = $translator; $this->translatableStringHelper = $translatableStringHelper; + $this->socialIssueRender = $socialIssueRender; } public function buildForm(FormBuilderInterface $builder) { $builder->add('accepted_socialissue', EntityType::class, [ 'class' => SocialIssue::class, - 'choice_label' => function(SocialIssue $s) { - return $this->translatableStringHelper->localize($s->getTitle()); + 'choice_label' => function ($socialIssue) { + return $this->socialIssueRender->renderString($socialIssue, []); }, 'multiple' => true, 'expanded' => true, @@ -57,7 +65,7 @@ class SocialIssueFilter implements FilterInterface if ('null' === $i) { $issues[] = $this->translator->trans('Not given'); } else { - $issues[] = $this->translatableStringHelper->localize($i->getTitle()); + $issues[] = $this->socialIssueRender->renderString($i, []); } } @@ -86,7 +94,44 @@ class SocialIssueFilter implements FilterInterface } $qb->add('where', $where); - $qb->setParameter('socialissues', $data['accepted_socialissue']); + $qb->setParameter('socialissues', + $this->addParentIssues($data['accepted_socialissue']) + ); + } + + /** + * "Le filtre retiendra les parcours qui comportent cette problématique, + * ou une problématique parente à celles choisies." + * + * Add parent of each socialissue selected, and remove duplicates + * + * @param $accepted_issues + * @return array + */ + private function addParentIssues($accepted_issues) + { + $array = []; + foreach ($accepted_issues as $i) + { + /** @var SocialIssue $i */ + if ($i->hasParent()) { + $array[] = $i->getParent(); + } + $array[] = $i; + } + return $this->removeDuplicate($array); + } + + private function removeDuplicate(array $array): array + { + $ids = array_map(function ($item) { + return $item->getId(); + }, $array); + + $unique_ids = array_unique($ids); dump($unique_ids); + + return array_values( + array_intersect_key($array, $unique_ids)); } public function applyOn() From d5d3866122c1ffb6d636c2a980962ed70ece0a79 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 20 Jul 2022 23:17:05 +0200 Subject: [PATCH 06/17] fix conflict with where clause in indicator ; initiate a filter test --- .../Export/Export/CountAccompanyingCourse.php | 3 - .../Export/StatAccompanyingCourseDuration.php | 3 - .../Export/Filter/SocialIssueFilter.php | 6 +- .../Export/Filter/StepFilter.php | 7 ++- .../Export/Filter/SocialIssueFilterTest.php | 63 +++++++++++++++++++ 5 files changed, 71 insertions(+), 11 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialIssueFilterTest.php diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php index 69ab19a55..b7b57d3cd 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php @@ -93,9 +93,6 @@ class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface $qb->select('COUNT(acp.id) AS export_result') ->from('ChillPersonBundle:AccompanyingPeriod', 'acp') - ->where($expr->neq( - 'acp.step', $expr->literal('DRAFT') - )) ; return $qb; diff --git a/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php b/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php index 639fa56a4..8747c288a 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php @@ -131,9 +131,6 @@ class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportIn ELSE :force_closingDate END ) - acp.openingDate ) AS export_result') - ->where($expr->neq( - 'acp.step', $expr->literal('DRAFT') - )) ->setParameter('force_closingDate', $force_closingdate) ; diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialIssueFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialIssueFilter.php index f82873dcd..b26e523eb 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialIssueFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialIssueFilter.php @@ -82,10 +82,10 @@ class SocialIssueFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb->join('acp.socialIssues', 's'); + $qb->join('acp.socialIssues', 'si'); $where = $qb->getDQLPart('where'); - $clause = $qb->expr()->in('s.id', ':socialissues'); + $clause = $qb->expr()->in('si.id', ':socialissues'); if ($where instanceof Andx) { $where->add($clause); @@ -128,7 +128,7 @@ class SocialIssueFilter implements FilterInterface return $item->getId(); }, $array); - $unique_ids = array_unique($ids); dump($unique_ids); + $unique_ids = array_unique($ids); return array_values( array_intersect_key($array, $unique_ids)); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/StepFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/StepFilter.php index 4c2183a7a..ac47be949 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/StepFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/StepFilter.php @@ -70,8 +70,11 @@ class StepFilter implements FilterInterface $where = $qb->getDQLPart('where'); $clause = $qb->expr()->eq('acp.step', ':step'); - // override original where clause - $where = $qb->expr()->andX($clause); + if ($where instanceof Andx) { + $where->add($clause); + } else { + $where = $qb->expr()->andX($clause); + } $qb->add('where', $where); $qb->setParameter('step', $data['accepted_step']); diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialIssueFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialIssueFilterTest.php new file mode 100644 index 000000000..ed520e90b --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialIssueFilterTest.php @@ -0,0 +1,63 @@ +filter = self::$container->get('chill.person.export.filter_socialissue'); + } catch (ServiceNotFoundException $e) { + $this->markTestSkipped('Filter service is not found'); + } + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData() + { + return [ + ['accepted_socialissue' => [ + + ]], + ['accepted_socialissue' => [ + + ]], + ['accepted_socialissue' => [ + + ]], + ]; + } + + public function getQueryBuilders() + { + // TODO: Implement getQueryBuilders() method. + } + +} \ No newline at end of file From 97e8b3c9c14ab2e8ec1cb6cacf4e3a6ab17488a6 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 25 Jul 2022 09:56:15 +0200 Subject: [PATCH 07/17] fix yarn/webpack error when compiling (correction on commit 340310be626fd2d0870687d6bd1af7fe68d34ae0) --- src/Bundle/ChillMainBundle/Resources/public/chill/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/chill/index.js b/src/Bundle/ChillMainBundle/Resources/public/chill/index.js index dda7b7e67..d60ebdff8 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/chill/index.js +++ b/src/Bundle/ChillMainBundle/Resources/public/chill/index.js @@ -46,7 +46,6 @@ require('../lib/collection/index.js'); require('../lib/breadcrumb/index.js'); require('../lib/download-report/index.js'); require('../lib/select_interactive_loading/index.js'); -require('../lib/export-list/index.js'); //require('../lib/show_hide/index.js'); //require('../lib/tabs/index.js'); From bf0ca7b777e0931a78d98e70c44e400c3a657467 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 25 Jul 2022 11:51:23 +0200 Subject: [PATCH 08/17] exports: fix logic in userScope and userJob filter --- .../Export/Filter/SocialIssueFilter.php | 6 ++- .../Export/Filter/UserJobFilter.php | 52 ++++++++----------- .../Export/Filter/UserScopeFilter.php | 46 ++++++++-------- .../translations/messages.fr.yml | 6 +-- 4 files changed, 48 insertions(+), 62 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialIssueFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialIssueFilter.php index b26e523eb..c6a031134 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialIssueFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialIssueFilter.php @@ -61,7 +61,9 @@ class SocialIssueFilter implements FilterInterface { $issues = []; - foreach ($data['accepted_socialissue'] as $i) { + $socialissues = $this->addParentIssues($data['accepted_socialissue']); + + foreach ($socialissues as $i) { if ('null' === $i) { $issues[] = $this->translator->trans('Not given'); } else { @@ -71,7 +73,7 @@ class SocialIssueFilter implements FilterInterface return [ 'Filtered by socialissues: only %socialissues%', [ - '%socialissues%' => implode(', ', $issues) + '%socialissues%' => implode(', ou ', $issues) ]]; } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/UserJobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/UserJobFilter.php index a3fe907b1..d641d9a74 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/UserJobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/UserJobFilter.php @@ -22,6 +22,7 @@ use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\Security\Core\Security; use Symfony\Contracts\Translation\TranslatorInterface; class UserJobFilter implements FilterInterface @@ -31,6 +32,8 @@ class UserJobFilter implements FilterInterface */ protected $translator; + private Security $security; + /** * @var TranslatableStringHelper */ @@ -38,27 +41,22 @@ class UserJobFilter implements FilterInterface public function __construct( TranslatorInterface $translator, - TranslatableStringHelper $translatableStringHelper + TranslatableStringHelper $translatableStringHelper, + Security $security ) { $this->translator = $translator; $this->translatableStringHelper = $translatableStringHelper; + $this->security = $security; } public function describeAction($data, $format = 'string') { - $jobs = []; - - foreach ($data['accepted_userjob'] as $j) { - if ('null' === $j) { - $jobs[] = $this->translator->trans('Not given'); - } else { - $jobs[] = $this->translatableStringHelper->localize($j->getLabel()); - } - } - return [ - 'Filtered by user jobs: only %jobs%', - ['%jobs%' => implode(', ', $jobs)], + 'Filtered by user job: only %job%', [ + '%job%' => $this->translatableStringHelper->localize( + $this->getUserJob()->getLabel() + ) + ], ]; } @@ -69,13 +67,8 @@ class UserJobFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb - ->join('acp.user', 'u') - ->join('u.userJob', 'j') - ; - $where = $qb->getDQLPart('where'); - $clause = $qb->expr()->in('u.userJob', ':userjob'); + $clause = $qb->expr()->eq('acp.job', ':userjob'); if ($where instanceof Andx) { $where->add($clause); @@ -84,8 +77,7 @@ class UserJobFilter implements FilterInterface } $qb->add('where', $where); - $qb->setParameter('userjob', $data['accepted_userjob']); - + $qb->setParameter('userjob', $this->getUserJob()); } public function applyOn() @@ -95,20 +87,18 @@ class UserJobFilter implements FilterInterface public function buildForm(FormBuilderInterface $builder) { - $builder - ->add('accepted_userjob', EntityType::class, [ - 'class' => UserJob::class, - 'choice_label' => function(UserJob $j) { - return $this->translatableStringHelper->localize($j->getLabel()); - }, - 'multiple' => true, - 'expanded' => true, - ]) - ; } public function getTitle() { return 'Filter by user job'; } + + private function getUserJob():UserJob + { + /** @var User $user */ + $user = $this->security->getUser(); + + return $user->getUserJob(); + } } \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/UserScopeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/UserScopeFilter.php index f235d9b86..bc7a1b9d3 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/UserScopeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/UserScopeFilter.php @@ -21,6 +21,7 @@ use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\Security\Core\Security; use Symfony\Contracts\Translation\TranslatorInterface; class UserScopeFilter implements FilterInterface @@ -30,6 +31,8 @@ class UserScopeFilter implements FilterInterface */ protected $translator; + private Security $security; + /** * @var TranslatableStringHelper */ @@ -37,27 +40,22 @@ class UserScopeFilter implements FilterInterface public function __construct( TranslatorInterface $translator, - TranslatableStringHelper $translatableStringHelper + TranslatableStringHelper $translatableStringHelper, + Security $security ) { $this->translator = $translator; $this->translatableStringHelper = $translatableStringHelper; + $this->security = $security; } public function describeAction($data, $format = 'string') { - $scopes = []; - - foreach ($data['accepted_userscope'] as $s) { - if ('null' === $s) { - $scopes[] = $this->translator->trans('Not given'); - } else { - $scopes[] = $this->translatableStringHelper->localize($s->getName()); - } - } - return [ - 'Filtered by user scopes: only %scopes%', - ['%scopes%' => implode(', ', $scopes)], + 'Filtered by user main scope: only %scope%', [ + '%scope%' => $this->translatableStringHelper->localize( + $this->getUserMainScope()->getName() + ) + ] ]; } @@ -71,7 +69,7 @@ class UserScopeFilter implements FilterInterface $qb->join('acp.scopes', 's'); $where = $qb->getDQLPart('where'); - $clause = $qb->expr()->in('s.id', ':userscope'); + $clause = $qb->expr()->eq('s.id', ':userscope'); if ($where instanceof Andx) { $where->add($clause); @@ -80,7 +78,7 @@ class UserScopeFilter implements FilterInterface } $qb->add('where', $where); - $qb->setParameter('userscope', $data['accepted_userscope']); + $qb->setParameter('userscope', $this->getUserMainScope()); } @@ -91,20 +89,18 @@ class UserScopeFilter implements FilterInterface public function buildForm(FormBuilderInterface $builder) { - $builder - ->add('accepted_userscope', EntityType::class, [ - 'class' => Scope::class, - 'choice_label' => function(Scope $s) { - return $this->translatableStringHelper->localize($s->getName()); - }, - 'multiple' => true, - 'expanded' => true, - ]) - ; } public function getTitle() { return 'Filter by user scope'; } + + private function getUserMainScope():Scope + { + /** @var User $user */ + $user = $this->security->getUser(); + + return $user->getMainScope(); + } } \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 690936ae4..ed82fdae6 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -377,12 +377,10 @@ Having an accompanying period closed after this date: Ayant une période d'accom "Filtered by accompanying period: persons having an accompanying period closed between the %date_from% and %date_to%": "Filtrer par période d'accompagnement: ayant une période fermée entre le %date_from% et le %date_to%" Filter by user scope: Filtrer par service du référent -Accepted userscope: Services -"Filtered by user scopes: only %scopes%": "Filtré par service du référent: uniquement %scopes%" +"Filtered by user main scope: only %scope%": "Filtré par service du référent: uniquement %scope%" Filter by user job: Filtrer par métier du référent -Accepted userjob: Métiers -"Filtered by user jobs: only %jobs%": "Filtré par métier du référent: uniquement %jobs%" +"Filtered by user job: only %job%": "Filtré par métier du référent: uniquement %job%" Filter by social issue: Filtrer par problématiques sociales Accepted socialissue: Problématiques sociales From 04ca61be818b0f8effab5460a58e884e4e49a54d Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 25 Jul 2022 12:35:35 +0200 Subject: [PATCH 09/17] rename data attribute --- .../Export/Filter/SocialIssueFilter.php | 10 +++++----- .../ChillPersonBundle/Export/Filter/StepFilter.php | 6 +++--- .../ChillPersonBundle/translations/messages.fr.yml | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialIssueFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialIssueFilter.php index c6a031134..27f01cb86 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialIssueFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialIssueFilter.php @@ -42,7 +42,7 @@ class SocialIssueFilter implements FilterInterface public function buildForm(FormBuilderInterface $builder) { - $builder->add('accepted_socialissue', EntityType::class, [ + $builder->add('accepted_socialissues', EntityType::class, [ 'class' => SocialIssue::class, 'choice_label' => function ($socialIssue) { return $this->socialIssueRender->renderString($socialIssue, []); @@ -61,7 +61,7 @@ class SocialIssueFilter implements FilterInterface { $issues = []; - $socialissues = $this->addParentIssues($data['accepted_socialissue']); + $socialissues = $this->addParentIssues($data['accepted_socialissues']); foreach ($socialissues as $i) { if ('null' === $i) { @@ -82,7 +82,7 @@ class SocialIssueFilter implements FilterInterface return null; } - public function alterQuery(QueryBuilder $qb, $data) + public function alterQuery(QueryBuilder $qb, $data): QueryBuilder { $qb->join('acp.socialIssues', 'si'); @@ -97,7 +97,7 @@ class SocialIssueFilter implements FilterInterface $qb->add('where', $where); $qb->setParameter('socialissues', - $this->addParentIssues($data['accepted_socialissue']) + $this->addParentIssues($data['accepted_socialissues']) ); } @@ -110,7 +110,7 @@ class SocialIssueFilter implements FilterInterface * @param $accepted_issues * @return array */ - private function addParentIssues($accepted_issues) + private function addParentIssues($accepted_issues): array { $array = []; foreach ($accepted_issues as $i) diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/StepFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/StepFilter.php index ac47be949..e3fbc19d5 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/StepFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/StepFilter.php @@ -37,7 +37,7 @@ class StepFilter implements FilterInterface public function buildForm(FormBuilderInterface $builder) { - $builder->add('accepted_step', ChoiceType::class, [ + $builder->add('accepted_steps', ChoiceType::class, [ 'choices' => self::STEPS, 'multiple' => false, 'expanded' => true, @@ -53,7 +53,7 @@ class StepFilter implements FilterInterface public function describeAction($data, $format = 'string') { - $step = array_flip(self::STEPS)[$data['accepted_step']]; + $step = array_flip(self::STEPS)[$data['accepted_steps']]; return ["Filtered by steps: only %step%", [ '%step%' => $this->translator->trans($step) @@ -77,7 +77,7 @@ class StepFilter implements FilterInterface } $qb->add('where', $where); - $qb->setParameter('step', $data['accepted_step']); + $qb->setParameter('step', $data['accepted_steps']); } public function applyOn() diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index ed82fdae6..8e532dd35 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -383,11 +383,11 @@ Filter by user job: Filtrer par métier du référent "Filtered by user job: only %job%": "Filtré par métier du référent: uniquement %job%" Filter by social issue: Filtrer par problématiques sociales -Accepted socialissue: Problématiques sociales +Accepted socialissues: Problématiques sociales "Filtered by socialissues: only %socialissues%": "Filtré par problématique sociale: uniquement %socialissues%" Filter by step: Filtrer par statut du parcours -Accepted step: Statuts +Accepted steps: Statuts "Filtered by steps: only %step%": "Filtré par statut du parcours: uniquement %step%" ## aggregators From e56520f4b1297a0fc37728625750728d15aac185 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 25 Jul 2022 12:36:22 +0200 Subject: [PATCH 10/17] exports: create origin filter --- .../Export/Filter/OriginFilter.php | 95 +++++++++++++++++++ .../config/services/exports.yaml | 7 ++ .../translations/messages.fr.yml | 4 + 3 files changed, 106 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/Export/Filter/OriginFilter.php diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/OriginFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/OriginFilter.php new file mode 100644 index 000000000..01cbdfb89 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Filter/OriginFilter.php @@ -0,0 +1,95 @@ +translatableStringHelper = $translatableStringHelper; + } + + /** + * @inheritDoc + */ + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('accepted_origins', EntityType::class, [ + 'class' => Origin::class, + 'choice_label' => function (Origin $o) { + return $this->translatableStringHelper->localize($o->getLabel()); + }, + 'multiple' => false, + 'expanded' => true + ]); + } + + /** + * @inheritDoc + */ + public function getTitle(): string + { + return 'Filter by origin'; + } + + /** + * @inheritDoc + */ + public function describeAction($data, $format = 'string'): array + { + return ['Filtered by origins: only %origin%', [ + '%origin%' => $this->translatableStringHelper->localize( + $data['accepted_origins']->getLabel()) + ]]; + } + + /** + * @inheritDoc + */ + public function addRole() + { + return null; + } + + /** + * @inheritDoc + */ + public function alterQuery(QueryBuilder $qb, $data) + { + $where = $qb->getDQLPart('where'); + $clause = $qb->expr()->eq('acp.origin', ':origin'); + + if ($where instanceof Andx) { + $where->add($clause); + } else { + $where = $qb->expr()->andX($clause); + } + + $qb->add('where', $where); + $qb->setParameter('origin', $data['accepted_origins']); + } + + /** + * @inheritDoc + */ + public function applyOn(): string + { + return Declarations::ACP_TYPE; + } +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/config/services/exports.yaml b/src/Bundle/ChillPersonBundle/config/services/exports.yaml index 2a02707ed..093b7315b 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports.yaml @@ -86,6 +86,13 @@ services: autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_step_filter } + + chill.person.export.filter_origin: + class: Chill\PersonBundle\Export\Filter\OriginFilter + autowire: true + autoconfigure: true + tags: + - { name: chill.export_filter, alias: accompanyingcourse_origin_filter } chill.person.export.aggregator_nationality: class: Chill\PersonBundle\Export\Aggregator\NationalityAggregator diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 8e532dd35..54fe34d1b 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -390,6 +390,10 @@ Filter by step: Filtrer par statut du parcours Accepted steps: Statuts "Filtered by steps: only %step%": "Filtré par statut du parcours: uniquement %step%" +Filter by origin: Filtrer par origine du parcours +Accepted origins: Origines +"Filtered by origins: only %origin%": "Filtré par origine du parcours: uniquement %origin%" + ## aggregators Group people by nationality: Aggréger les personnes par nationalités Group by level: Grouper par niveau From 057617c1cbf145f3a6ffdc904c5e77e04875617f Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 25 Jul 2022 14:04:12 +0200 Subject: [PATCH 11/17] separate accompanying_period exports in yaml service definition --- .../ChillPersonExtension.php | 1 + .../config/services/exports.yaml | 50 +--------------- .../services/exports_accompanying_period.yaml | 57 ++++++++++++++++++- 3 files changed, 58 insertions(+), 50 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php index d7037c1d2..e2e2fbc97 100644 --- a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php +++ b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php @@ -95,6 +95,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac $loader->load('services/doctrineEventListener.yaml'); $loader->load('services/accompanyingPeriodConsistency.yaml'); + // if ($container->getParameter('chill_person.accompanying_period') !== 'hidden') { $loader->load('services/exports_accompanying_period.yaml'); } diff --git a/src/Bundle/ChillPersonBundle/config/services/exports.yaml b/src/Bundle/ChillPersonBundle/config/services/exports.yaml index 093b7315b..f50674e19 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports.yaml @@ -1,4 +1,5 @@ services: + chill.person.export.count_person: class: Chill\PersonBundle\Export\Export\CountPerson arguments: @@ -26,20 +27,6 @@ services: tags: - { name: chill.export, alias: list_person_duplicate } - chill.person.export.count_accompanyingcourse: - class: Chill\PersonBundle\Export\Export\CountAccompanyingCourse - arguments: - - "@doctrine.orm.entity_manager" - tags: - - { name: chill.export, alias: count_accompanyingcourse } - - chill.person.export.avg_accompanyingcourse_duration: - class: Chill\PersonBundle\Export\Export\StatAccompanyingCourseDuration - arguments: - - '@Chill\PersonBundle\Repository\AccompanyingPeriodRepository' - tags: - - { name: chill.export, alias: avg_accompanyingcourse_duration } - chill.person.export.filter_gender: class: Chill\PersonBundle\Export\Filter\GenderFilter arguments: @@ -58,41 +45,6 @@ services: autoconfigure: true tags: - { name: chill.export_filter, alias: person_nationality_filter } - - chill.person.export.filter_userscope: - class: Chill\PersonBundle\Export\Filter\UserScopeFilter - autowire: true - autoconfigure: true - tags: - - { name: chill.export_filter, alias: accompanyingcourse_userscope_filter } - - chill.person.export.filter_userjob: - class: Chill\PersonBundle\Export\Filter\UserJobFilter - autowire: true - autoconfigure: true - tags: - - { name: chill.export_filter, alias: accompanyingcourse_userjob_filter } - - chill.person.export.filter_socialissue: - class: Chill\PersonBundle\Export\Filter\SocialIssueFilter - autowire: true - autoconfigure: true - tags: - - { name: chill.export_filter, alias: accompanyingcourse_socialissue_filter } - - chill.person.export.filter_step: - class: Chill\PersonBundle\Export\Filter\StepFilter - autowire: true - autoconfigure: true - tags: - - { name: chill.export_filter, alias: accompanyingcourse_step_filter } - - chill.person.export.filter_origin: - class: Chill\PersonBundle\Export\Filter\OriginFilter - autowire: true - autoconfigure: true - tags: - - { name: chill.export_filter, alias: accompanyingcourse_origin_filter } chill.person.export.aggregator_nationality: class: Chill\PersonBundle\Export\Aggregator\NationalityAggregator diff --git a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_period.yaml b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_period.yaml index 6126af6d6..36544abde 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_period.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_period.yaml @@ -1,4 +1,6 @@ -services: +services: + + ## chill.person.export.filter_accompanying_period: class: Chill\PersonBundle\Export\Filter\AccompanyingPeriodFilter tags: @@ -13,3 +15,56 @@ services: class: Chill\PersonBundle\Export\Filter\AccompanyingPeriodClosingFilter tags: - { name: chill.export_filter, alias: person_acc_pe_cl_filter } + + ## Indicators + chill.person.export.count_accompanyingcourse: + class: Chill\PersonBundle\Export\Export\CountAccompanyingCourse + autowire: true + autoconfigure: true + tags: + - { name: chill.export, alias: count_accompanyingcourse } + + chill.person.export.avg_accompanyingcourse_duration: + class: Chill\PersonBundle\Export\Export\StatAccompanyingCourseDuration + autowire: true + autoconfigure: true + tags: + - { name: chill.export, alias: avg_accompanyingcourse_duration } + + ## Filters + chill.person.export.filter_userscope: + class: Chill\PersonBundle\Export\Filter\UserScopeFilter + autowire: true + autoconfigure: true + tags: + - { name: chill.export_filter, alias: accompanyingcourse_userscope_filter } + + chill.person.export.filter_userjob: + class: Chill\PersonBundle\Export\Filter\UserJobFilter + autowire: true + autoconfigure: true + tags: + - { name: chill.export_filter, alias: accompanyingcourse_userjob_filter } + + chill.person.export.filter_socialissue: + class: Chill\PersonBundle\Export\Filter\SocialIssueFilter + autowire: true + autoconfigure: true + tags: + - { name: chill.export_filter, alias: accompanyingcourse_socialissue_filter } + + chill.person.export.filter_step: + class: Chill\PersonBundle\Export\Filter\StepFilter + autowire: true + autoconfigure: true + tags: + - { name: chill.export_filter, alias: accompanyingcourse_step_filter } + + chill.person.export.filter_origin: + class: Chill\PersonBundle\Export\Filter\OriginFilter + autowire: true + autoconfigure: true + tags: + - { name: chill.export_filter, alias: accompanyingcourse_origin_filter } + + ## Aggregators \ No newline at end of file From ef5b3b24e4db9ab9e082b12eb660b85352d4e5e8 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 25 Jul 2022 14:44:03 +0200 Subject: [PATCH 12/17] exports: create closingmotive filter --- .../Export/Filter/ClosingMotiveFilter.php | 95 +++++++++++++++++++ .../Export/Filter/SocialIssueFilter.php | 2 +- .../services/exports_accompanying_period.yaml | 7 ++ .../translations/messages.fr.yml | 4 + 4 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 src/Bundle/ChillPersonBundle/Export/Filter/ClosingMotiveFilter.php diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/ClosingMotiveFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/ClosingMotiveFilter.php new file mode 100644 index 000000000..b4fc3f94d --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Filter/ClosingMotiveFilter.php @@ -0,0 +1,95 @@ +translatableStringHelper = $translatableStringHelper; + } + + /** + * @inheritDoc + */ + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('accepted_closingmotives', EntityType::class, [ + 'class' => ClosingMotive::class, + 'choice_label' => function (ClosingMotive $cm) { + return $this->translatableStringHelper->localize($cm->getName()); + }, + 'multiple' => false, + 'expanded' => false + ]); + } + + /** + * @inheritDoc + */ + public function getTitle(): string + { + return 'Filter by closing motive'; + } + + /** + * @inheritDoc + */ + public function describeAction($data, $format = 'string'): array + { + return [ + 'Filtered by closingmotive: only %closingmotive%', [ + '%closingmotive%' => $this->translatableStringHelper->localize( + $data['accepted_closingmotives']->getName()) + ]]; + } + + /** + * @inheritDoc + */ + public function addRole() + { + return null; + } + + /** + * @inheritDoc + */ + public function alterQuery(QueryBuilder $qb, $data) + { + $where = $qb->getDQLPart('where'); + $clause = $qb->expr()->eq('acp.closingMotive', ':closingmotive'); + + if ($where instanceof Andx) { + $where->add($clause); + } else { + $where = $qb->expr()->andX($clause); + } + + $qb->add('where', $where); + $qb->setParameter('closingmotive', $data['accepted_closingmotives']); + } + + /** + * @inheritDoc + */ + public function applyOn(): string + { + return Declarations::ACP_TYPE; + } +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialIssueFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialIssueFilter.php index 27f01cb86..092982d41 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialIssueFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialIssueFilter.php @@ -82,7 +82,7 @@ class SocialIssueFilter implements FilterInterface return null; } - public function alterQuery(QueryBuilder $qb, $data): QueryBuilder + public function alterQuery(QueryBuilder $qb, $data) { $qb->join('acp.socialIssues', 'si'); diff --git a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_period.yaml b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_period.yaml index 36544abde..d34512220 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_period.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_period.yaml @@ -67,4 +67,11 @@ services: tags: - { name: chill.export_filter, alias: accompanyingcourse_origin_filter } + chill.person.export.filter_closingmotive: + class: Chill\PersonBundle\Export\Filter\ClosingMotiveFilter + autowire: true + autoconfigure: true + tags: + - { name: chill.export_filter, alias: accompanyingcourse_closingmotive_filter } + ## Aggregators \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 54fe34d1b..51ca82ce6 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -394,6 +394,10 @@ Filter by origin: Filtrer par origine du parcours Accepted origins: Origines "Filtered by origins: only %origin%": "Filtré par origine du parcours: uniquement %origin%" +Filter by closing motive: Filtrer par motif de fermeture +Accepted closingmotives: Motifs de clôture +"Filtered by closingmotive: only %closingmotive%": "Filtré par motif de clôture: uniquement %closingmotive%" + ## aggregators Group people by nationality: Aggréger les personnes par nationalités Group by level: Grouper par niveau From 43bedc41a7cd228032a81de12faa2806c33c1f74 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 25 Jul 2022 15:42:51 +0200 Subject: [PATCH 13/17] exports: create confidential filter --- .../Export/Filter/ConfidentialFilter.php | 87 +++++++++++++++++++ .../services/exports_accompanying_period.yaml | 7 ++ .../translations/messages.fr.yml | 6 ++ 3 files changed, 100 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/Export/Filter/ConfidentialFilter.php diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/ConfidentialFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/ConfidentialFilter.php new file mode 100644 index 000000000..f33ce9c1e --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Filter/ConfidentialFilter.php @@ -0,0 +1,87 @@ + false, + 'is confidential' => true, + ]; + + private CONST DEFAULT_CHOICE = false; + + private TranslatorInterface $translator; + + public function __construct(TranslatorInterface $translator) + { + $this->translator = $translator; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('accepted_confidentials', ChoiceType::class, [ + 'choices' => self::CHOICES, + 'multiple' => false, + 'expanded' => true, + 'empty_data' => self::DEFAULT_CHOICE, + 'data' => self::DEFAULT_CHOICE, + ]); + } + + public function getTitle(): string + { + return 'Filter by confidential'; + } + + public function describeAction($data, $format = 'string'): array + { + dump($data, self::CHOICES); + //$choice = //array_flip(self::CHOICES)[$data['accepted_confidentials']]; + foreach (self::CHOICES as $k => $v) { + if ($v === $data['accepted_confidentials']) { + $choice = $k; + } + } + + return [ + 'Filtered by confidential: only %confidential%', [ + '%confidential%' => $this->translator->trans($choice) + ] + ]; + } + + public function addRole() + { + return null; + } + + public function alterQuery(QueryBuilder $qb, $data) + { + $where = $qb->getDQLPart('where'); + $clause = $qb->expr()->eq('acp.confidential', ':confidential'); + + if ($where instanceof Andx) { + $where->add($clause); + } else { + $where = $qb->expr()->andX($clause); + } + + $qb->add('where', $where); + $qb->setParameter('confidential', $data['accepted_confidentials']); + } + + public function applyOn(): string + { + return Declarations::ACP_TYPE; + } + +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_period.yaml b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_period.yaml index d34512220..abaeffd8a 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_period.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_period.yaml @@ -74,4 +74,11 @@ services: tags: - { name: chill.export_filter, alias: accompanyingcourse_closingmotive_filter } + chill.person.export.filter_confidential: + class: Chill\PersonBundle\Export\Filter\ConfidentialFilter + autowire: true + autoconfigure: true + tags: + - { name: chill.export_filter, alias: accompanyingcourse_confidential_filter } + ## Aggregators \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 51ca82ce6..75da040d0 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -398,6 +398,12 @@ Filter by closing motive: Filtrer par motif de fermeture Accepted closingmotives: Motifs de clôture "Filtered by closingmotive: only %closingmotive%": "Filtré par motif de clôture: uniquement %closingmotive%" +Filter by confidential: Filtrer par confidentialité +Accepted confidentials: Choix possibles +is confidential: le parcours est confidentiel +is not confidential: le parcours n'est pas confidentiel +"Filtered by confidential: only %confidential%": "Filtré par confidentialité: uniquement si %confidential%" + ## aggregators Group people by nationality: Aggréger les personnes par nationalités Group by level: Grouper par niveau From ddac410b2e5be2db7542dc92f89c5d0d4baf3ce7 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 25 Jul 2022 16:19:54 +0200 Subject: [PATCH 14/17] exports: fix choice forms builder with multiple selections --- .../Export/Filter/ClosingMotiveFilter.php | 17 +++++++++++------ .../Export/Filter/OriginFilter.php | 15 ++++++++++----- .../Export/Filter/StepFilter.php | 18 +++++++++++------- .../translations/messages.fr.yml | 6 +++--- 4 files changed, 35 insertions(+), 21 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/ClosingMotiveFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/ClosingMotiveFilter.php index b4fc3f94d..7ff78d41b 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/ClosingMotiveFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/ClosingMotiveFilter.php @@ -34,8 +34,8 @@ class ClosingMotiveFilter implements FilterInterface 'choice_label' => function (ClosingMotive $cm) { return $this->translatableStringHelper->localize($cm->getName()); }, - 'multiple' => false, - 'expanded' => false + 'multiple' => true, + 'expanded' => true, ]); } @@ -52,10 +52,15 @@ class ClosingMotiveFilter implements FilterInterface */ public function describeAction($data, $format = 'string'): array { + $motives = []; + + foreach ($data['accepted_closingmotives'] as $k => $v) { + $motives[] = $this->translatableStringHelper->localize($v->getName()); + } + return [ - 'Filtered by closingmotive: only %closingmotive%', [ - '%closingmotive%' => $this->translatableStringHelper->localize( - $data['accepted_closingmotives']->getName()) + 'Filtered by closingmotive: only %closingmotives%', [ + '%closingmotives%' => implode(', ou ', $motives) ]]; } @@ -73,7 +78,7 @@ class ClosingMotiveFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { $where = $qb->getDQLPart('where'); - $clause = $qb->expr()->eq('acp.closingMotive', ':closingmotive'); + $clause = $qb->expr()->in('acp.closingMotive', ':closingmotive'); if ($where instanceof Andx) { $where->add($clause); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/OriginFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/OriginFilter.php index 01cbdfb89..936767009 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/OriginFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/OriginFilter.php @@ -35,7 +35,7 @@ class OriginFilter implements FilterInterface 'choice_label' => function (Origin $o) { return $this->translatableStringHelper->localize($o->getLabel()); }, - 'multiple' => false, + 'multiple' => true, 'expanded' => true ]); } @@ -53,9 +53,14 @@ class OriginFilter implements FilterInterface */ public function describeAction($data, $format = 'string'): array { - return ['Filtered by origins: only %origin%', [ - '%origin%' => $this->translatableStringHelper->localize( - $data['accepted_origins']->getLabel()) + $origins = []; + + foreach ($data['accepted_origins'] as $v) { + $origins[] = $this->translatableStringHelper->localize($v->getLabel()); + } + + return ['Filtered by origins: only %origins%', [ + '%origins%' => implode(', ou ', $origins) ]]; } @@ -73,7 +78,7 @@ class OriginFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { $where = $qb->getDQLPart('where'); - $clause = $qb->expr()->eq('acp.origin', ':origin'); + $clause = $qb->expr()->in('acp.origin', ':origin'); if ($where instanceof Andx) { $where->add($clause); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/StepFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/StepFilter.php index e3fbc19d5..98d496714 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/StepFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/StepFilter.php @@ -39,10 +39,8 @@ class StepFilter implements FilterInterface { $builder->add('accepted_steps', ChoiceType::class, [ 'choices' => self::STEPS, - 'multiple' => false, + 'multiple' => true, 'expanded' => true, - 'empty_data' => self::DEFAULT_CHOICE, - 'data' => self::DEFAULT_CHOICE, ]); } @@ -53,10 +51,16 @@ class StepFilter implements FilterInterface public function describeAction($data, $format = 'string') { - $step = array_flip(self::STEPS)[$data['accepted_steps']]; + $steps = []; - return ["Filtered by steps: only %step%", [ - '%step%' => $this->translator->trans($step) + foreach ($data['accepted_steps'] as $v) { + $steps[] = $this->translator->trans( + array_flip(self::STEPS)[$v] + ); + } + + return ["Filtered by steps: only %steps%", [ + '%steps%' => implode(', ou ', $steps) ]]; } @@ -68,7 +72,7 @@ class StepFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { $where = $qb->getDQLPart('where'); - $clause = $qb->expr()->eq('acp.step', ':step'); + $clause = $qb->expr()->in('acp.step', ':step'); if ($where instanceof Andx) { $where->add($clause); diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 75da040d0..c755126de 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -388,15 +388,15 @@ Accepted socialissues: Problématiques sociales Filter by step: Filtrer par statut du parcours Accepted steps: Statuts -"Filtered by steps: only %step%": "Filtré par statut du parcours: uniquement %step%" +"Filtered by steps: only %steps%": "Filtré par statut du parcours: uniquement %steps%" Filter by origin: Filtrer par origine du parcours Accepted origins: Origines -"Filtered by origins: only %origin%": "Filtré par origine du parcours: uniquement %origin%" +"Filtered by origins: only %origins%": "Filtré par origine du parcours: uniquement %origins%" Filter by closing motive: Filtrer par motif de fermeture Accepted closingmotives: Motifs de clôture -"Filtered by closingmotive: only %closingmotive%": "Filtré par motif de clôture: uniquement %closingmotive%" +"Filtered by closingmotive: only %closingmotives%": "Filtré par motif de clôture: uniquement %closingmotives%" Filter by confidential: Filtrer par confidentialité Accepted confidentials: Choix possibles From da224ea4bc7f20e21d003b16cc232997edd277ca Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 25 Jul 2022 16:35:11 +0200 Subject: [PATCH 15/17] exports: create emergency filter --- .../Export/Filter/ConfidentialFilter.php | 2 +- .../Export/Filter/EmergencyFilter.php | 87 +++++++++++++++++++ .../services/exports_accompanying_period.yaml | 7 ++ .../translations/messages.fr.yml | 8 +- 4 files changed, 102 insertions(+), 2 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Export/Filter/EmergencyFilter.php diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/ConfidentialFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/ConfidentialFilter.php index f33ce9c1e..7e043c131 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/ConfidentialFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/ConfidentialFilter.php @@ -45,7 +45,7 @@ class ConfidentialFilter implements FilterInterface public function describeAction($data, $format = 'string'): array { dump($data, self::CHOICES); - //$choice = //array_flip(self::CHOICES)[$data['accepted_confidentials']]; + foreach (self::CHOICES as $k => $v) { if ($v === $data['accepted_confidentials']) { $choice = $k; diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EmergencyFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EmergencyFilter.php new file mode 100644 index 000000000..4e292977a --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EmergencyFilter.php @@ -0,0 +1,87 @@ + false, + 'is emergency' => true, + ]; + + private CONST DEFAULT_CHOICE = false; + + private TranslatorInterface $translator; + + public function __construct(TranslatorInterface $translator) + { + $this->translator = $translator; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('accepted_emergencies', ChoiceType::class, [ + 'choices' => self::CHOICES, + 'multiple' => false, + 'expanded' => true, + 'empty_data' => self::DEFAULT_CHOICE, + 'data' => self::DEFAULT_CHOICE, + ]); + } + + public function getTitle(): string + { + return 'Filter by emergency'; + } + + public function describeAction($data, $format = 'string'): array + { + dump($data, self::CHOICES); + + foreach (self::CHOICES as $k => $v) { + if ($v === $data['accepted_emergencies']) { + $choice = $k; + } + } + + return [ + 'Filtered by emergency: only %emergency%', [ + '%emergency%' => $this->translator->trans($choice) + ] + ]; + } + + public function addRole() + { + return null; + } + + public function alterQuery(QueryBuilder $qb, $data) + { + $where = $qb->getDQLPart('where'); + $clause = $qb->expr()->eq('acp.emergency', ':emergency'); + + if ($where instanceof Andx) { + $where->add($clause); + } else { + $where = $qb->expr()->andX($clause); + } + + $qb->add('where', $where); + $qb->setParameter('emergency', $data['accepted_emergencies']); + } + + public function applyOn(): string + { + return Declarations::ACP_TYPE; + } + +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_period.yaml b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_period.yaml index abaeffd8a..ff79a1617 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_period.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_period.yaml @@ -81,4 +81,11 @@ services: tags: - { name: chill.export_filter, alias: accompanyingcourse_confidential_filter } + chill.person.export.filter_emergency: + class: Chill\PersonBundle\Export\Filter\EmergencyFilter + autowire: true + autoconfigure: true + tags: + - { name: chill.export_filter, alias: accompanyingcourse_emergency_filter } + ## Aggregators \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index c755126de..1b6f96a9a 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -399,11 +399,17 @@ Accepted closingmotives: Motifs de clôture "Filtered by closingmotive: only %closingmotives%": "Filtré par motif de clôture: uniquement %closingmotives%" Filter by confidential: Filtrer par confidentialité -Accepted confidentials: Choix possibles +Accepted confidentials: '' is confidential: le parcours est confidentiel is not confidential: le parcours n'est pas confidentiel "Filtered by confidential: only %confidential%": "Filtré par confidentialité: uniquement si %confidential%" +Filter by emergency: Filtrer par urgence +Accepted emergencies: '' +is emergency: le parcours est urgent +is not emergency: le parcours n'est pas urgent +"Filtered by emergency: only %emergency%": "Filtré par urgence: uniquement si %emergency%" + ## aggregators Group people by nationality: Aggréger les personnes par nationalités Group by level: Grouper par niveau From e728c00671140d889eca0a3e290a8243d56131e6 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 25 Jul 2022 16:49:57 +0200 Subject: [PATCH 16/17] exports: create intensity filter --- .../Export/Filter/EmergencyFilter.php | 2 - .../Export/Filter/IntensityFilter.php | 85 +++++++++++++++++++ .../services/exports_accompanying_period.yaml | 7 ++ .../translations/messages.fr.yml | 9 ++ 4 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Export/Filter/IntensityFilter.php diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EmergencyFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EmergencyFilter.php index 4e292977a..f09d117f4 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/EmergencyFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EmergencyFilter.php @@ -44,8 +44,6 @@ class EmergencyFilter implements FilterInterface public function describeAction($data, $format = 'string'): array { - dump($data, self::CHOICES); - foreach (self::CHOICES as $k => $v) { if ($v === $data['accepted_emergencies']) { $choice = $k; diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/IntensityFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/IntensityFilter.php new file mode 100644 index 000000000..b55e7f399 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Filter/IntensityFilter.php @@ -0,0 +1,85 @@ + 'occasional', + 'is regular' => 'regular', + ]; + + private CONST DEFAULT_CHOICE = 'occasional'; + + private TranslatorInterface $translator; + + public function __construct(TranslatorInterface $translator) + { + $this->translator = $translator; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('accepted_intensities', ChoiceType::class, [ + 'choices' => self::CHOICES, + 'multiple' => false, + 'expanded' => true, + 'empty_data' => self::DEFAULT_CHOICE, + 'data' => self::DEFAULT_CHOICE, + ]); + } + + public function getTitle(): string + { + return 'Filter by intensity'; + } + + public function describeAction($data, $format = 'string'): array + { + foreach (self::CHOICES as $k => $v) { + if ($v === $data['accepted_intensities']) { + $choice = $k; + } + } + + return [ + 'Filtered by intensity: only %intensity%', [ + '%intensity%' => $this->translator->trans($choice) + ] + ]; + } + + public function addRole() + { + return null; + } + + public function alterQuery(QueryBuilder $qb, $data) + { + $where = $qb->getDQLPart('where'); + $clause = $qb->expr()->eq('acp.intensity', ':intensity'); + + if ($where instanceof Andx) { + $where->add($clause); + } else { + $where = $qb->expr()->andX($clause); + } + + $qb->add('where', $where); + $qb->setParameter('intensity', $data['accepted_intensities']); + } + + public function applyOn(): string + { + return Declarations::ACP_TYPE; + } + +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_period.yaml b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_period.yaml index ff79a1617..72fa1ad80 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_period.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_period.yaml @@ -88,4 +88,11 @@ services: tags: - { name: chill.export_filter, alias: accompanyingcourse_emergency_filter } + chill.person.export.filter_intensity: + class: Chill\PersonBundle\Export\Filter\IntensityFilter + autowire: true + autoconfigure: true + tags: + - { name: chill.export_filter, alias: accompanyingcourse_intensity_filter } + ## Aggregators \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 1b6f96a9a..288793af0 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -410,6 +410,15 @@ is emergency: le parcours est urgent is not emergency: le parcours n'est pas urgent "Filtered by emergency: only %emergency%": "Filtré par urgence: uniquement si %emergency%" +Filter by intensity: Filtrer par intensité +Accepted intensities: '' +is occasional: le parcours est ponctuel +is regular: le parcours est régulier +"Filtered by intensity: only %intensity%": "Filtré par intensité: uniquement si %intensity%" + + + + ## aggregators Group people by nationality: Aggréger les personnes par nationalités Group by level: Grouper par niveau From ef827a132254ac889e8e9330d77256669dd1bb42 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 25 Jul 2022 18:24:24 +0200 Subject: [PATCH 17/17] revert stepFilter to uniq selection (cfr ddac410b2e5be2db7542dc92f89c5d0d4baf3ce7) --- .../Export/Filter/StepFilter.php | 18 +++++++----------- .../translations/messages.fr.yml | 2 +- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/StepFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/StepFilter.php index 98d496714..e3fbc19d5 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/StepFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/StepFilter.php @@ -39,8 +39,10 @@ class StepFilter implements FilterInterface { $builder->add('accepted_steps', ChoiceType::class, [ 'choices' => self::STEPS, - 'multiple' => true, + 'multiple' => false, 'expanded' => true, + 'empty_data' => self::DEFAULT_CHOICE, + 'data' => self::DEFAULT_CHOICE, ]); } @@ -51,16 +53,10 @@ class StepFilter implements FilterInterface public function describeAction($data, $format = 'string') { - $steps = []; + $step = array_flip(self::STEPS)[$data['accepted_steps']]; - foreach ($data['accepted_steps'] as $v) { - $steps[] = $this->translator->trans( - array_flip(self::STEPS)[$v] - ); - } - - return ["Filtered by steps: only %steps%", [ - '%steps%' => implode(', ou ', $steps) + return ["Filtered by steps: only %step%", [ + '%step%' => $this->translator->trans($step) ]]; } @@ -72,7 +68,7 @@ class StepFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { $where = $qb->getDQLPart('where'); - $clause = $qb->expr()->in('acp.step', ':step'); + $clause = $qb->expr()->eq('acp.step', ':step'); if ($where instanceof Andx) { $where->add($clause); diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 288793af0..4c5ca1dcf 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -388,7 +388,7 @@ Accepted socialissues: Problématiques sociales Filter by step: Filtrer par statut du parcours Accepted steps: Statuts -"Filtered by steps: only %steps%": "Filtré par statut du parcours: uniquement %steps%" +"Filtered by steps: only %step%": "Filtré par statut du parcours: uniquement %step%" Filter by origin: Filtrer par origine du parcours Accepted origins: Origines