From f1446638775aa0c2c8ee916c15f364b67fa6b206 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 15 Nov 2022 11:46:32 +0000 Subject: [PATCH 01/15] Fixed: Fix typo in message for activity --- src/Bundle/ChillActivityBundle/translations/validators.fr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/translations/validators.fr.yml b/src/Bundle/ChillActivityBundle/translations/validators.fr.yml index 1f4f97a63..f2c104828 100644 --- a/src/Bundle/ChillActivityBundle/translations/validators.fr.yml +++ b/src/Bundle/ChillActivityBundle/translations/validators.fr.yml @@ -16,8 +16,8 @@ For this type of activity, document is required: Pour ce type d'activité, un do For this type of activity, emergency is required: Pour ce type d'activité, le champ "Urgent" est requis For this type of activity, accompanying period is required: Pour ce type d'activité, le parcours d'accompagnement est requis For this type of activity, you must add at least one social issue: Pour ce type d'activité, vous devez ajouter au moins une problématique sociale -For this type of activity, you must add at least one social action: Pour ce type d'activité, vous devez indiquez au moins une action sociale +For this type of activity, you must add at least one social action: Pour ce type d'activité, vous devez indiquer au moins une action sociale # admin This parameter must be equal to social issue parameter: Ce paramètre doit être égal au paramètre "Visibilité du champs Problématiques sociales" -The socialActionsVisible value is not compatible with the socialIssuesVisible value: Cette valeur du paramètre "Visibilité du champs Actions sociales" n'est pas compatible avec la valeur du paramètre "Visibilité du champs Problématiques sociales" \ No newline at end of file +The socialActionsVisible value is not compatible with the socialIssuesVisible value: Cette valeur du paramètre "Visibilité du champs Actions sociales" n'est pas compatible avec la valeur du paramètre "Visibilité du champs Problématiques sociales" From 9ad3bbc1b41fdfefde727b946a1ebc096dfb2282 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 15 Nov 2022 11:58:26 +0000 Subject: [PATCH 02/15] Fixed: fix typo in workflows --- src/Bundle/ChillMainBundle/translations/messages.fr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index 36f793817..28896ff85 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -465,8 +465,8 @@ workflow: Previous workflow transitionned help: Workflows où vous avez exécuté une action. For: Pour You must select a next step, pick another decision if no next steps are available: Il faut une prochaine étape. Choissisez une autre décision si nécessaire. - An access key was also sent to those addresses: Un lien d'accès a été envoyé à ces addresses - Those users are also granted to apply a transition by using an access key: Ces utilisateurs ont obtennu l'accès grâce au lien reçu par email + An access key was also sent to those addresses: Un lien d'accès a été envoyé à ces adresses + Those users are also granted to apply a transition by using an access key: Ces utilisateurs ont obtenu l'accès grâce au lien reçu par email Access link copied: Lien d'accès copié This link grant any user to apply a transition: Le lien d'accès suivant permet d'appliquer une transition The workflow may be accssed through this link: Une transition peut être appliquée sur ce workflow grâce au lien d'accès suivant From fc607d6a0ec07a3921030e4646615c8356717d53 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 15 Nov 2022 16:16:52 +0100 Subject: [PATCH 03/15] DX: improve import command + help for address-ref-from-best-addresses --- .../Command/LoadAddressesBEFromBestAddressCommand.php | 5 +++-- .../Command/LoadAddressesFRFromBANOCommand.php | 2 +- .../Service/Import/PostalCodeBEFromBestAddress.php | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Command/LoadAddressesBEFromBestAddressCommand.php b/src/Bundle/ChillMainBundle/Command/LoadAddressesBEFromBestAddressCommand.php index 09bf85d0d..cc26b7687 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadAddressesBEFromBestAddressCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadAddressesBEFromBestAddressCommand.php @@ -37,8 +37,9 @@ class LoadAddressesBEFromBestAddressCommand extends Command { $this ->setName('chill:main:address-ref-from-best-addresses') - ->addArgument('lang', InputArgument::REQUIRED) - ->addArgument('list', InputArgument::IS_ARRAY, 'The list to add'); + ->addArgument('lang', InputArgument::REQUIRED, "Language code, for example 'fr'") + ->addArgument('list', InputArgument::IS_ARRAY, "The list to add, for example 'full', or 'extract' (dev) or '1xxx' (brussel CP)") + ->setDescription('Import BE addresses from BeST Address (see https://osoc19.github.io/best/)'); } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Bundle/ChillMainBundle/Command/LoadAddressesFRFromBANOCommand.php b/src/Bundle/ChillMainBundle/Command/LoadAddressesFRFromBANOCommand.php index 6d2737a66..40772d52b 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadAddressesFRFromBANOCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadAddressesFRFromBANOCommand.php @@ -31,7 +31,7 @@ class LoadAddressesFRFromBANOCommand extends Command { $this->setName('chill:main:address-ref-from-bano') ->addArgument('departementNo', InputArgument::REQUIRED | InputArgument::IS_ARRAY, 'a list of departement numbers') - ->setDescription('Import addresses from bano (see https://bano.openstreetmap.fr'); + ->setDescription('Import FR addresses from bano (see https://bano.openstreetmap.fr'); } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php index a78744a65..a6d9512c7 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php +++ b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeBEFromBestAddress.php @@ -97,8 +97,8 @@ class PostalCodeBEFromBestAddress trim($record['postal_info_objectid']), $record['municipality_objectid'], 'bestaddress', - $record['Y'], - $record['X'], + (float) $record['Y'], + (float) $record['X'], 3812 ); } From 999e9e85533d8f9e5616f26f38d24b38d50968a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 17 Nov 2022 19:16:23 +0100 Subject: [PATCH 04/15] Feature: [workflow] do not subscribe user on notification for each step automatically --- .../ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php index 8b3175408..d86770560 100644 --- a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php +++ b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php @@ -133,8 +133,7 @@ class EntityWorkflowStep if (!$this->destUser->contains($user)) { $this->destUser[] = $user; $this->getEntityWorkflow() - ->addSubscriberToFinal($user) - ->addSubscriberToStep($user); + ->addSubscriberToFinal($user); } return $this; @@ -145,8 +144,7 @@ class EntityWorkflowStep if (!$this->destUserByAccessKey->contains($user) && !$this->destUser->contains($user)) { $this->destUserByAccessKey[] = $user; $this->getEntityWorkflow() - ->addSubscriberToFinal($user) - ->addSubscriberToStep($user); + ->addSubscriberToFinal($user); } return $this; From 88fb48e2bedc0da7ea12e812889635b4e1b7dc69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 17 Nov 2022 19:01:06 +0100 Subject: [PATCH 05/15] Fixed: let the aggregator "Activity by type" be shown again --- .../Export/Aggregator/ActivityTypeAggregator.php | 2 +- .../ChillActivityBundle/config/services/export.yaml | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php index 8c98e1049..071ccd232 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php @@ -44,7 +44,7 @@ class ActivityTypeAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { if (!in_array('acttype', $qb->getAllAliases(), true)) { - $qb->join('activity.activityType', 'acttype'); + $qb->leftJoin('activity.activityType', 'acttype'); } $qb->addSelect(sprintf('IDENTITY(activity.activityType) AS %s', self::KEY)); diff --git a/src/Bundle/ChillActivityBundle/config/services/export.yaml b/src/Bundle/ChillActivityBundle/config/services/export.yaml index 57153a193..16addd2a3 100644 --- a/src/Bundle/ChillActivityBundle/config/services/export.yaml +++ b/src/Bundle/ChillActivityBundle/config/services/export.yaml @@ -41,6 +41,12 @@ services: tags: - { name: chill.export, alias: 'avg_activity_visit_duration_linked_to_acp' } + Chill\ActivityBundle\Export\Export\LinkedToACP\ListActivity: + tags: + - { name: chill.export, alias: 'list_activity_acp'} + + Chill\ActivityBundle\Export\Export\ListActivityHelper: ~ + ## Filters chill.activity.export.type_filter: class: Chill\ActivityBundle\Export\Filter\ActivityTypeFilter @@ -129,10 +135,9 @@ services: tags: - { name: chill.export_aggregator, alias: activity_reason_aggregator } - chill.activity.export.type_aggregator: - class: Chill\ActivityBundle\Export\Aggregator\ActivityTypeAggregator + Chill\ActivityBundle\Export\Aggregator\ActivityTypeAggregator: tags: - - { name: chill.export_aggregator, alias: activity_type_aggregator } + - { name: chill.export_aggregator, alias: activity_common_type_aggregator } chill.activity.export.user_aggregator: class: Chill\ActivityBundle\Export\Aggregator\ActivityUserAggregator From d080dfda9a6dbcef57e3614e35b8a470edea019e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 17 Nov 2022 19:01:54 +0100 Subject: [PATCH 06/15] DX: Fix CS --- .../ChillMainBundle/Form/Type/PickRollingDateType.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickRollingDateType.php b/src/Bundle/ChillMainBundle/Form/Type/PickRollingDateType.php index 5b5bff6b3..a4492526f 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickRollingDateType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickRollingDateType.php @@ -44,6 +44,11 @@ class PickRollingDateType extends AbstractType $builder->setDataMapper(new RollingDateDataMapper()); } + public function buildView(FormView $view, FormInterface $form, array $options) + { + $view->vars['uniqid'] = uniqid('rollingdate-'); + } + public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ @@ -65,9 +70,4 @@ class PickRollingDateType extends AbstractType ->addViolation(); } } - - public function buildView(FormView $view, FormInterface $form, array $options) - { - $view->vars['uniqid'] = uniqid('rollingdate-'); - } } From 368136ea575a6009c86226d296a233360efc03bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 5 Dec 2022 18:25:23 +0100 Subject: [PATCH 07/15] Feature: [activity][list] Fix list for activities and refactor list with an helper --- .../Export/LinkedToACP/ListActivity.php | 165 +++++++++++ .../Export/Export/ListActivityHelper.php | 269 ++++++++++++++++++ .../Repository/ActivityPresenceRepository.php | 51 ++++ .../ActivityPresenceRepositoryInterface.php | 33 +++ .../translations/messages.fr.yml | 23 ++ .../TranslatableStringExportLabelHelper.php | 70 +++++ .../Export/Helper/UserHelper.php | 41 +++ .../translations/messages.fr.yml | 6 + .../Export/Helper/LabelPersonHelper.php | 69 +++++ .../Export/Helper/LabelThirdPartyHelper.php | 69 +++++ .../config/services.yaml | 5 + 11 files changed, 801 insertions(+) create mode 100644 src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php create mode 100644 src/Bundle/ChillActivityBundle/Export/Export/ListActivityHelper.php create mode 100644 src/Bundle/ChillActivityBundle/Repository/ActivityPresenceRepository.php create mode 100644 src/Bundle/ChillActivityBundle/Repository/ActivityPresenceRepositoryInterface.php create mode 100644 src/Bundle/ChillMainBundle/Export/Helper/TranslatableStringExportLabelHelper.php create mode 100644 src/Bundle/ChillPersonBundle/Export/Helper/LabelPersonHelper.php create mode 100644 src/Bundle/ChillThirdPartyBundle/Export/Helper/LabelThirdPartyHelper.php diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php new file mode 100644 index 000000000..77444e414 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php @@ -0,0 +1,165 @@ +helper = $helper; + $this->entityManager = $entityManager; + $this->translatableStringExportLabelHelper = $translatableStringExportLabelHelper; + } + + public function buildForm(FormBuilderInterface $builder) + { + $this->helper->buildForm($builder); + } + + public function getAllowedFormattersTypes() + { + return $this->helper->getAllowedFormattersTypes(); + } + + public function getDescription() + { + return ListActivityHelper::MSG_KEY . 'List activities linked to an accompanying course'; + } + + public function getGroup(): string + { + return 'Exports of activities linked to an accompanying period'; + } + + public function getLabels($key, array $values, $data) + { + switch ($key) { + case 'acpId': + return static function ($value) { + if ('_header' === $value) { + return ListActivityHelper::MSG_KEY . 'accompanying course id'; + } + + return $value ?? ''; + }; + + case 'scopesNames': + return $this->translatableStringExportLabelHelper->getLabelMulti($key, $values, ListActivityHelper::MSG_KEY . 'course circles'); + + default: + return $this->helper->getLabels($key, $values, $data); + } + } + + public function getQueryKeys($data) + { + return + array_merge( + $this->helper->getQueryKeys($data), + [ + 'acpId', + 'scopesNames', + ] + ); + } + + public function getResult($query, $data) + { + return $this->helper->getResult($query, $data); + } + + public function getTitle() + { + return ListActivityHelper::MSG_KEY . 'List activity linked to a course'; + } + + public function getType() + { + return $this->helper->getType(); + } + + public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) + { + $centers = array_map(static function ($el) { + return $el['center']; + }, $acl); + + $qb = $this->entityManager->createQueryBuilder(); + + $qb + ->distinct() + ->from(Activity::class, 'activity') + ->join('activity.accompanyingPeriod', 'acp') + ->leftJoin('acp.participations', 'acppart') + ->leftJoin('acppart.person', 'person') + ->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL') + ->andWhere( + $qb->expr()->exists( + 'SELECT 1 + FROM ' . PersonCenterHistory::class . ' acl_count_person_history + WHERE acl_count_person_history.person = person + AND acl_count_person_history.center IN (:authorized_centers) + ' + ) + ) + // some grouping are necessary + ->addGroupBy('acp.id') + ->addOrderBy('activity.date') + ->addOrderBy('activity.id') + ->setParameter('authorized_centers', $centers); + + $this->helper->addSelect($qb); + + // add select for this step + $qb + ->addSelect('acp.id AS acpId') + ->addSelect('(SELECT AGGREGATE(acpScope.name) FROM ' . Scope::class . ' acpScope WHERE acpScope MEMBER OF acp.scopes) AS scopesNames') + ->addGroupBy('scopesNames'); + + return $qb; + } + + public function requiredRole(): string + { + return ActivityStatsVoter::LISTS; + } + + public function supportsModifiers() + { + return array_merge( + $this->helper->supportsModifiers(), + [ + \Chill\PersonBundle\Export\Declarations::ACP_TYPE, + ] + ); + } +} diff --git a/src/Bundle/ChillActivityBundle/Export/Export/ListActivityHelper.php b/src/Bundle/ChillActivityBundle/Export/Export/ListActivityHelper.php new file mode 100644 index 000000000..0e8b28ab4 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Export/Export/ListActivityHelper.php @@ -0,0 +1,269 @@ +activityPresenceRepository = $activityPresenceRepository; + $this->activityTypeRepository = $activityTypeRepository; + $this->dateTimeHelper = $dateTimeHelper; + $this->labelPersonHelper = $labelPersonHelper; + $this->labelThirdPartyHelper = $labelThirdPartyHelper; + $this->translator = $translator; + $this->translatableStringHelper = $translatableStringHelper; + $this->translatableStringLabelHelper = $translatableStringLabelHelper; + $this->userHelper = $userHelper; + } + + public function addSelect(QueryBuilder $qb): void + { + $qb + ->addSelect('activity.id AS id') + ->addSelect('activity.date') + ->addSelect('IDENTITY(activity.activityType) AS typeName') + ->leftJoin('activity.reasons', 'reasons') + ->addSelect('AGGREGATE(reasons.name) AS listReasons') + ->leftJoin('activity.persons', 'actPerson') + ->addSelect('AGGREGATE(actPerson.id) AS personsIds') + ->addSelect('AGGREGATE(actPerson.id) AS personsNames') + ->leftJoin('activity.users', 'users_u') + ->addSelect('AGGREGATE(users_u.id) AS usersIds') + ->addSelect('AGGREGATE(users_u.id) AS usersNames') + ->leftJoin('activity.thirdParties', 'thirdparty') + ->addSelect('AGGREGATE(thirdparty.id) AS thirdPartiesIds') + ->addSelect('AGGREGATE(thirdparty.id) AS thirdPartiesNames') + ->addSelect('IDENTITY(activity.attendee) AS attendeeName') + ->addSelect('activity.durationTime') + ->addSelect('activity.travelTime') + ->addSelect('activity.emergency') + ->leftJoin('activity.location', 'location') + ->addSelect('location.name AS locationName') + ->addSelect('activity.sentReceived') + ->addSelect('IDENTITY(activity.createdBy) AS createdBy') + ->addSelect('activity.createdAt') + ->addSelect('IDENTITY(activity.updatedBy) AS updatedBy') + ->addSelect('activity.updatedAt') + ->addGroupBy('activity.id') + ->addGroupBy('location.id'); + } + + public function buildForm(FormBuilderInterface $builder) + { + } + + public function getAllowedFormattersTypes() + { + return [FormatterInterface::TYPE_LIST]; + } + + public function getLabels($key, array $values, $data) + { + switch ($key) { + case 'createdAt': + case 'updatedAt': + return $this->dateTimeHelper->getLabel($key); + + case 'createdBy': + case 'updatedBy': + return $this->userHelper->getLabel($key, $values, $key); + + case 'date': + return $this->dateTimeHelper->getLabel(self::MSG_KEY . $key); + + case 'attendeeName': + return function ($value) { + if ('_header' === $value) { + return 'Attendee'; + } + + if (null === $value || null === $presence = $this->activityPresenceRepository->find($value)) { + return ''; + } + + return $this->translatableStringHelper->localize($presence->getName()); + }; + + case 'listReasons': + return $this->translatableStringLabelHelper->getLabelMulti($key, $values, 'Activity Reasons'); + + case 'typeName': + return function ($value) { + if ('_header' === $value) { + return 'Activity type'; + } + + if (null === $value || null === $type = $this->activityTypeRepository->find($value)) { + return ''; + } + + return $this->translatableStringHelper->localize($type->getName()); + }; + + case 'usersNames': + return $this->userHelper->getLabelMulti($key, $values, self::MSG_KEY . 'users name'); + + case 'usersIds': + case 'thirdPartiesIds': + case 'personsIds': + return static function ($value) use ($key) { + if ('_header' === $value) { + switch ($key) { + case 'usersIds': + return self::MSG_KEY . 'users ids'; + + case 'thirdPartiesIds': + return self::MSG_KEY . 'third parties ids'; + + case 'personsIds': + return self::MSG_KEY . 'persons ids'; + + default: + throw new LogicException('key not supported'); + } + } + + $decoded = json_decode($value); + + return implode( + '|', + array_unique( + array_filter($decoded, static fn (?int $id) => null !== $id), + SORT_NUMERIC + ) + ); + }; + + case 'personsNames': + return $this->labelPersonHelper->getLabelMulti($key, $values, self::MSG_KEY . 'persons name'); + + case 'thirdPartiesNames': + return $this->labelThirdPartyHelper->getLabelMulti($key, $values, self::MSG_KEY . 'thirds parties'); + + case 'sentReceived': + return function ($value) { + if ('_header' === $value) { + return self::MSG_KEY . 'sent received'; + } + + if (null === $value) { + return ''; + } + + return $this->translator->trans($value); + }; + + default: + return function ($value) use ($key) { + if ('_header' === $value) { + return self::MSG_KEY . $key; + } + + if (null === $value) { + return ''; + } + + return $this->translator->trans($value); + }; + } + } + + public function getQueryKeys($data) + { + return [ + 'id', + 'date', + 'typeName', + 'listReasons', + 'attendeeName', + 'durationTime', + 'travelTime', + 'emergency', + 'locationName', + 'sentReceived', + 'personsIds', + 'personsNames', + 'usersIds', + 'usersNames', + 'thirdPartiesIds', + 'thirdPartiesNames', + 'createdBy', + 'createdAt', + 'updatedBy', + 'updatedAt', + ]; + } + + public function getResult($query, $data) + { + return $query->getQuery()->getResult(AbstractQuery::HYDRATE_SCALAR); + } + + public function getType(): string + { + return Declarations::ACTIVITY; + } + + public function supportsModifiers() + { + return [ + Declarations::ACTIVITY, + ]; + } +} diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityPresenceRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityPresenceRepository.php new file mode 100644 index 000000000..2cf9f9470 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityPresenceRepository.php @@ -0,0 +1,51 @@ +repository = $entityManager->getRepository($this->getClassName()); + } + + public function find($id): ?ActivityPresence + { + return $this->repository->find($id); + } + + public function findAll(): array + { + return $this->repository->findAll(); + } + + public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array + { + return $this->findBy($criteria, $orderBy, $limit, $offset); + } + + public function findOneBy(array $criteria): ?ActivityPresence + { + return $this->findOneBy($criteria); + } + + public function getClassName(): string + { + return ActivityPresence::class; + } +} diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityPresenceRepositoryInterface.php b/src/Bundle/ChillActivityBundle/Repository/ActivityPresenceRepositoryInterface.php new file mode 100644 index 000000000..228d70856 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityPresenceRepositoryInterface.php @@ -0,0 +1,33 @@ +translatableStringHelper = $translatableStringHelper; + } + + public function getLabel(string $key, array $values, string $header) + { + return function ($value) use ($header) { + if ('_header' === $value) { + return $header; + } + + if (null === $value) { + return ''; + } + + return $this->translatableStringHelper->localize(json_decode($value, true)); + }; + } + + public function getLabelMulti(string $key, array $values, string $header) + { + return function ($value) use ($header) { + if ('_header' === $value) { + return $header; + } + + if (null === $value) { + return ''; + } + + $decoded = json_decode($value, true); + + return implode( + '|', + array_unique( + array_map( + fn (array $translatableString) => $this->translatableStringHelper->localize($translatableString), + array_filter($decoded, static fn ($elem) => null !== $elem) + ) + ) + ); + }; + } +} diff --git a/src/Bundle/ChillMainBundle/Export/Helper/UserHelper.php b/src/Bundle/ChillMainBundle/Export/Helper/UserHelper.php index 98c4c5579..d8eb7e9cc 100644 --- a/src/Bundle/ChillMainBundle/Export/Helper/UserHelper.php +++ b/src/Bundle/ChillMainBundle/Export/Helper/UserHelper.php @@ -13,6 +13,8 @@ namespace Chill\MainBundle\Export\Helper; use Chill\MainBundle\Repository\UserRepositoryInterface; use Chill\MainBundle\Templating\Entity\UserRender; +use function count; +use const SORT_NUMERIC; class UserHelper { @@ -40,4 +42,43 @@ class UserHelper return $this->userRender->renderString($user, []); }; } + + public function getLabelMulti($key, array $values, string $header): callable + { + return function ($value) { + if ('_header' === $value) { + return 'users name'; + } + + if (null === $value) { + return ''; + } + + $decoded = json_decode($value); + + if (0 === count($decoded)) { + return ''; + } + + return + implode( + '|', + array_map( + function (int $userId) { + $user = $this->userRepository->find($userId); + + if (null === $user) { + return ''; + } + + return $this->userRender->renderString($user, []); + }, + array_unique( + array_filter($decoded, static fn (?int $userId) => null !== $userId), + SORT_NUMERIC + ) + ) + ); + }; + } } diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index fbd8da3a7..f41b8d36d 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -56,6 +56,12 @@ Until %date%: Jusqu'au %date% until %date%: jusqu'au %date% Since: Depuis le Until: Jusqu'au + +updatedAt: Mise à jour le +updatedBy: Mise à jour par +createdAt: Créé le +createdBy: Créé par + #elements used in software centers: centres Centers: Centres diff --git a/src/Bundle/ChillPersonBundle/Export/Helper/LabelPersonHelper.php b/src/Bundle/ChillPersonBundle/Export/Helper/LabelPersonHelper.php new file mode 100644 index 000000000..2cfc8d3cf --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Helper/LabelPersonHelper.php @@ -0,0 +1,69 @@ +personRepository = $personRepository; + $this->personRender = $personRender; + } + + public function getLabelMulti(string $key, array $values, string $header): callable + { + return function ($value) use ($header) { + if ('_header' === $value) { + return $header; + } + + if (null === $value) { + return ''; + } + + $decoded = json_decode($value); + + if (0 === count($decoded)) { + return ''; + } + + return + implode( + '|', + array_map( + function (int $personId) { + $person = $this->personRepository->find($personId); + + if (null === $person) { + return ''; + } + + return $this->personRender->renderString($person, []); + }, + array_unique( + array_filter($decoded, static fn (?int $id) => null !== $id), + SORT_NUMERIC + ) + ) + ); + }; + } +} diff --git a/src/Bundle/ChillThirdPartyBundle/Export/Helper/LabelThirdPartyHelper.php b/src/Bundle/ChillThirdPartyBundle/Export/Helper/LabelThirdPartyHelper.php new file mode 100644 index 000000000..dc5f8ddc6 --- /dev/null +++ b/src/Bundle/ChillThirdPartyBundle/Export/Helper/LabelThirdPartyHelper.php @@ -0,0 +1,69 @@ +thirdPartyRender = $thirdPartyRender; + $this->thirdPartyRepository = $thirdPartyRepository; + } + + public function getLabelMulti(string $key, array $values, string $header): callable + { + return function ($value) use ($header) { + if ('_header' === $value) { + return $header; + } + + if (null === $value) { + return ''; + } + + $decoded = json_decode($value); + + if (0 === count($decoded)) { + return ''; + } + + return + implode( + '|', + array_map( + function (int $tpId) { + $tp = $this->thirdPartyRepository->find($tpId); + + if (null === $tp) { + return ''; + } + + return $this->thirdPartyRender->renderString($tp, []); + }, + array_unique( + array_filter($decoded, static fn (?int $id) => null !== $id), + SORT_NUMERIC + ) + ) + ); + }; + } +} diff --git a/src/Bundle/ChillThirdPartyBundle/config/services.yaml b/src/Bundle/ChillThirdPartyBundle/config/services.yaml index 8f9420a67..0024556f6 100644 --- a/src/Bundle/ChillThirdPartyBundle/config/services.yaml +++ b/src/Bundle/ChillThirdPartyBundle/config/services.yaml @@ -6,3 +6,8 @@ services: tags: - { name: 'serializer.normalizer', priority: 64 } + Chill\ThirdPartyBundle\Export\: + autowire: true + autoconfigure: true + resource: '../Export/' + From 5328bee2627514fa67833f236f941972fa2272a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 6 Dec 2022 10:17:49 +0100 Subject: [PATCH 08/15] Fixed: [SocialAction] Fix the loading of evaluations associated to a SocialActions --- .../ChillPersonBundle/Entity/SocialWork/SocialAction.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php index bc439c083..a8c68c8ce 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php @@ -46,7 +46,7 @@ class SocialAction private $desactivationDate; /** - * @ORM\ManyToMany(targetEntity=Evaluation::class, mappedBy="socialActions") + * @ORM\ManyToMany(targetEntity=Evaluation::class, inversedBy="socialActions") * @ORM\JoinTable(name="chill_person_social_work_evaluation_action") */ private Collection $evaluations; @@ -62,7 +62,7 @@ class SocialAction * @ORM\GeneratedValue * @ORM\Column(type="integer") */ - private $id; + private ?int $id = null; /** * @ORM\ManyToOne(targetEntity=SocialIssue::class, inversedBy="socialActions") From 516e4e5f47b3ca3c74628cab0a9732ca8c099f96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 6 Dec 2022 21:25:35 +0100 Subject: [PATCH 09/15] Fixed: fix the loading of bootstrap See https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/690 --- .../Resources/public/module/bootstrap/_shared.scss | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Bundle/ChillMainBundle/Resources/public/module/bootstrap/_shared.scss b/src/Bundle/ChillMainBundle/Resources/public/module/bootstrap/_shared.scss index c216c5cf8..96da20779 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/module/bootstrap/_shared.scss +++ b/src/Bundle/ChillMainBundle/Resources/public/module/bootstrap/_shared.scss @@ -14,9 +14,11 @@ // 4. Include any default map overrides here @import "custom/_maps"; +@import "bootstrap/scss/maps"; // 5. Include remainder of required parts @import "bootstrap/scss/mixins"; +@import "bootstrap/scss/utilities"; @import "bootstrap/scss/root"; From a10aae21008b88e7fb815d1a00018b4a51167cc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 6 Dec 2022 22:27:27 +0100 Subject: [PATCH 10/15] Deploy: update webpack config for postcss loader and ckeditor --- src/Bundle/ChillMainBundle/chill.webpack.config.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillMainBundle/chill.webpack.config.js b/src/Bundle/ChillMainBundle/chill.webpack.config.js index 0e4924b03..727964779 100644 --- a/src/Bundle/ChillMainBundle/chill.webpack.config.js +++ b/src/Bundle/ChillMainBundle/chill.webpack.config.js @@ -26,12 +26,15 @@ buildCKEditor = function(encore) .addLoader({ test: /ckeditor5-[^/\\]+[/\\]theme[/\\].+\.css$/, loader: 'postcss-loader', - options: styles.getPostCssConfig( { - themeImporter: { + options: + { + postcssOptions: styles.getPostCssConfig( { + themeImporter: { themePath: require.resolve('@ckeditor/ckeditor5-theme-lark') - }, - minify: true - } ) + }, + minify: true + } ) + } } ) ; }; From 34c97769a6ff27a40fcc956f73e1640e763636d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 7 Dec 2022 12:00:14 +0100 Subject: [PATCH 11/15] Fixed: Fix modal layout with bootstrap upgrade --- .../public/vuejs/_components/Modal.vue | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Modal.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Modal.vue index 39815de3e..11bb9db2f 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Modal.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Modal.vue @@ -2,25 +2,27 @@ @@ -33,7 +35,7 @@ import {defineComponent} from "vue"; * [+] with 'v-if:showModal' directive:parameter, html scope is added/removed not just shown/hidden * [+] with slot we can pass content from parent component * [+] some classes are passed from parent component - * and Bootstrap 4.6 _modal.scss module + * and Bootstrap 5 _modal.scss module * [+] using bootstrap css classes, the modal have a responsive behaviour, * [+] modal design can be configured using css classes (size, scroll) */ @@ -56,6 +58,9 @@ export default defineComponent({