From 229af2e4f98a48cbaa25cb1e9ea8b790d1bd92c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 24 Apr 2023 15:40:20 +0200 Subject: [PATCH] Feature: Adapt filters and aggregators with new steps --- .../translations/messages.fr.yml | 1 + .../Entity/AccompanyingPeriod.php | 5 ++-- .../StepAggregator.php | 12 ++++++-- .../Export/Export/ListAccompanyingPeriod.php | 30 +++++++++++++++++++ .../AccompanyingCourseFilters/StepFilter.php | 10 ++++--- .../StepFilterTest.php | 2 ++ .../translations/messages.fr.yml | 17 +++++++++-- 7 files changed, 64 insertions(+), 13 deletions(-) diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index b8349ce2e..14de6dbf0 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -564,6 +564,7 @@ export: _as_string: Adresse formattée confidential: Adresse confidentielle ? isNoAddress: Adresse incomplète ? + steps: Escaliers _lat: Latitude _lon: Longitude diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php index a724596a9..a8e191df3 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php @@ -358,6 +358,7 @@ class AccompanyingPeriod implements /** * @ORM\Column(type="string", length=32, nullable=true) * @Groups({"read"}) + * @var AccompanyingPeriod::STEP_* */ private string $step = self::STEP_DRAFT; @@ -730,11 +731,9 @@ class AccompanyingPeriod implements if ($this->getStep() === self::STEP_DRAFT) { return [[self::STEP_DRAFT]]; } - - if ($this->getStep() === self::STEP_CONFIRMED) { + if (str_starts_with($this->getStep(), 'CONFIRM')) { return [[self::STEP_DRAFT, self::STEP_CONFIRMED]]; } - if ($this->getStep() === self::STEP_CLOSED) { return [[self::STEP_DRAFT, self::STEP_CONFIRMED, self::STEP_CLOSED]]; } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php index 84dbd4e69..85cfc3190 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php @@ -86,13 +86,19 @@ final class StepAggregator implements AggregatorInterface return function ($value): string { switch ($value) { case AccompanyingPeriod::STEP_DRAFT: - return $this->translator->trans('Draft'); + return $this->translator->trans('course.draft'); case AccompanyingPeriod::STEP_CONFIRMED: - return $this->translator->trans('Confirmed'); + return $this->translator->trans('course.confirmed'); case AccompanyingPeriod::STEP_CLOSED: - return $this->translator->trans('Closed'); + return $this->translator->trans('course.closed'); + + case AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT: + return $this->translator->trans('course.inactive_short'); + + case AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG: + return $this->translator->trans('course.inactive_long'); case '_header': return 'Step'; diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php index 045039930..3fd7ee01a 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php @@ -41,6 +41,7 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Query\Expr\Join; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Contracts\Translation\TranslatorInterface; use function strlen; class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface @@ -100,6 +101,8 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface private TranslatableStringHelperInterface $translatableStringHelper; + private TranslatorInterface $translator; + private UserHelper $userHelper; public function __construct( @@ -113,6 +116,7 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface SocialIssueRepository $socialIssueRepository, SocialIssueRender $socialIssueRender, TranslatableStringHelperInterface $translatableStringHelper, + TranslatorInterface $translator, RollingDateConverterInterface $rollingDateConverter, UserHelper $userHelper ) { @@ -126,6 +130,7 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface $this->thirdPartyRender = $thirdPartyRender; $this->thirdPartyRepository = $thirdPartyRepository; $this->translatableStringHelper = $translatableStringHelper; + $this->translator = $translator; $this->rollingDateConverter = $rollingDateConverter; $this->userHelper = $userHelper; } @@ -250,6 +255,31 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface ); }; + case 'step': + return function ($value) { + return match ($value) { + '_header' => 'export.list.acp.step', + null => '', + AccompanyingPeriod::STEP_DRAFT => $this->translator->trans('course.draft'), + AccompanyingPeriod::STEP_CONFIRMED => $this->translator->trans('course.confirmed'), + AccompanyingPeriod::STEP_CLOSED => $this->translator->trans('course.closed'), + AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT => $this->translator->trans('course.inactive_short'), + AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG => $this->translator->trans('course.inactive_long'), + default => $value, + }; + }; + + case 'intensity': + return function ($value) { + return match ($value) { + '_header' => 'export.list.acp.intensity', + null => '', + AccompanyingPeriod::INTENSITY_OCCASIONAL => $this->translator->trans('occasional'), + AccompanyingPeriod::INTENSITY_REGULAR => $this->translator->trans('regular'), + default => $value, + }; + }; + default: return static function ($value) use ($key) { if ('_header' === $value) { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php index 240b093b5..8ee798c07 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilter.php @@ -32,9 +32,11 @@ class StepFilter implements FilterInterface private const P = 'acp_step_filter_date'; private const STEPS = [ - 'Draft' => AccompanyingPeriod::STEP_DRAFT, - 'Confirmed' => AccompanyingPeriod::STEP_CONFIRMED, - 'Closed' => AccompanyingPeriod::STEP_CLOSED, + 'course.draft' => AccompanyingPeriod::STEP_DRAFT, + 'course.confirmed' => AccompanyingPeriod::STEP_CONFIRMED, + 'course.closed' => AccompanyingPeriod::STEP_CLOSED, + 'course.inactive_short' => AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT, + 'course.inactive_long' => AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG, ]; private RollingDateConverterInterface $rollingDateConverter; @@ -96,7 +98,7 @@ class StepFilter implements FilterInterface 'data' => self::DEFAULT_CHOICE, ]) ->add('calc_date', PickRollingDateType::class, [ - 'label' => 'export.acp.filter.by_step.date_calc', + 'label' => 'export.filter.course.by_step.date_calc', 'data' => new RollingDate(RollingDate::T_TODAY), ]); } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/StepFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/StepFilterTest.php index 9388aa8ae..42eec5823 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/StepFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/StepFilterTest.php @@ -40,6 +40,8 @@ final class StepFilterTest extends AbstractFilterTest return [ ['accepted_steps' => AccompanyingPeriod::STEP_DRAFT], ['accepted_steps' => AccompanyingPeriod::STEP_CONFIRMED], + ['accepted_steps' => AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG], + ['accepted_steps' => AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT], ['accepted_steps' => AccompanyingPeriod::STEP_CLOSED], ]; } diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index d33957ea7..0cdc9e601 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -57,7 +57,7 @@ Add new phone: Ajouter un numéro de téléphone Remove phone: Supprimer 'Notes on contact information': 'Remarques sur les informations de contact' 'Remarks': 'Remarques' -'Spoken languages': 'Langues parlées' +Spoken languages': 'Langues parlées' 'Unknown spoken languages': 'Langues parlées inconnues' Male: Homme Female: Femme @@ -237,8 +237,12 @@ No referrer: Pas d'agent traitant Some peoples does not belong to any household currently. Add them to an household soon: Certains usagers n'appartiennent à aucun ménage actuellement. Renseignez leur ménage dès que possible. Add to household now: Ajouter à un ménage Any resource for this accompanying course: Aucun interlocuteur privilégié pour ce parcours -course.draft: Brouillon -course.closed: Clôturé +course: + draft: Brouillon + closed: Clôturé + inactive_short: Hors file active + inactive_long: Pré-archivé + confirmed: Confirmé Origin: Origine de la demande Delete accompanying period: Supprimer le parcours d'accompagnement Are you sure you want to remove the accompanying period "%id%" ?: Êtes-vous sûr de vouloir supprimer le parcours d'accompagnement %id% ? @@ -1072,6 +1076,8 @@ export: Status: Statut course: + by_step: + date_calc: Date de prise en compte du statut by_user_scope: Computation date for referrer: Date à laquelle le référent était actif by_referrer: @@ -1095,12 +1101,15 @@ export: id: Identifiant du parcours openingDate: Date d'ouverture du parcours closingDate: Date de fermeture du parcours + closingMotive: Motif de cloture + job: Métier confidential: Confidentiel emergency: Urgent intensity: Intensité createdAt: Créé le updatedAt: Dernière mise à jour le acpOrigin: Origine du parcours + origin: Origine du parcourse acpClosingMotive: Motif de fermeture acpJob: Métier du parcours createdBy: Créé par @@ -1120,6 +1129,8 @@ export: acprequestorPerson: Nom du demandeur usager scopes: Services socialIssues: Problématiques sociales + requestorPerson: Demandeur (personne) + requestorThirdParty: Demandeur (tiers) eval: List of evaluations: Liste des évaluations Generate a list of evaluations, filtered on different parameters: Génère une liste des évaluations, filtrée sur différents paramètres.