diff --git a/composer.json b/composer.json index 45d7ca832..9447d6db5 100644 --- a/composer.json +++ b/composer.json @@ -9,18 +9,22 @@ ], "require": { "php": "^7.4", + "ext-json": "*", + "ext-openssl": "*", + "ext-redis": "*", "champs-libres/async-uploader-bundle": "dev-sf4#d57134aee8e504a83c902ff0cf9f8d36ac418290", - "champs-libres/wopi-bundle": "dev-master#6dd8e0a14e00131eb4b889ecc30270ee4a0e5224", - "champs-libres/wopi-lib": "dev-master#8615f4a45a39fc2b6a98765ea835fcfd39618787", + "champs-libres/wopi-bundle": "dev-master@dev", + "champs-libres/wopi-lib": "dev-master@dev", "doctrine/doctrine-bundle": "^2.1", "doctrine/doctrine-migrations-bundle": "^3.0", - "doctrine/orm": "^2.7", + "doctrine/orm": "^2.13.0", "erusev/parsedown": "^1.7", "graylog2/gelf-php": "^1.5", "knplabs/knp-menu-bundle": "^3.0", "knplabs/knp-time-bundle": "^1.12", "knpuniversity/oauth2-client-bundle": "^2.10", "league/csv": "^9.7.1", + "lexik/jwt-authentication-bundle": "^2.16", "nyholm/psr7": "^1.4", "ocramius/package-versions": "^1.10 || ^2", "odolbeau/phone-number-bundle": "^3.6", @@ -29,12 +33,12 @@ "ramsey/uuid-doctrine": "^1.7", "sensio/framework-extra-bundle": "^5.5", "spomky-labs/base64url": "^2.0", - "symfony/asset": "^4.4", "symfony/browser-kit": "^4.4", "symfony/css-selector": "^4.4", "symfony/expression-language": "^4.4", "symfony/form": "^4.4", "symfony/framework-bundle": "^4.4", + "symfony/http-client": "^4.4 || ^5", "symfony/http-foundation": "^4.4", "symfony/intl": "^4.4", "symfony/mailer": "^5.4", @@ -48,7 +52,6 @@ "symfony/translation": "^4.4", "symfony/twig-bundle": "^4.4", "symfony/validator": "^4.4", - "symfony/web-link": "*", "symfony/webpack-encore-bundle": "^1.11", "symfony/workflow": "^4.4", "symfony/yaml": "^4.4", @@ -72,8 +75,7 @@ "symfony/maker-bundle": "^1.20", "symfony/phpunit-bridge": "^4.4", "symfony/stopwatch": "^4.4", - "symfony/var-dumper": "^4.4", - "symfony/web-profiler-bundle": "^4.4" + "symfony/var-dumper": "^4.4" }, "conflict": { "symfony/symfony": "*" diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index 11db2dcb3..b7d5fcbd2 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -43,6 +43,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Serializer\SerializerInterface; +use Symfony\Contracts\Translation\TranslatorInterface; use function array_key_exists; final class ActivityController extends AbstractController @@ -73,6 +74,8 @@ final class ActivityController extends AbstractController private ThirdPartyRepository $thirdPartyRepository; + private TranslatorInterface $translator; + private UserRepositoryInterface $userRepository; public function __construct( @@ -89,7 +92,8 @@ final class ActivityController extends AbstractController LoggerInterface $logger, SerializerInterface $serializer, UserRepositoryInterface $userRepository, - CenterResolverManagerInterface $centerResolver + CenterResolverManagerInterface $centerResolver, + TranslatorInterface $translator ) { $this->activityACLAwareRepository = $activityACLAwareRepository; $this->activityTypeRepository = $activityTypeRepository; @@ -105,6 +109,7 @@ final class ActivityController extends AbstractController $this->serializer = $serializer; $this->userRepository = $userRepository; $this->centerResolver = $centerResolver; + $this->translator = $translator; } /** @@ -160,7 +165,7 @@ final class ActivityController extends AbstractController $this->entityManager->remove($activity); $this->entityManager->flush(); - $this->addFlash('success', $this->get('translator') + $this->addFlash('success', $this->translator ->trans('The activity has been successfully removed.')); $params = $this->buildParamsToUrl($person, $accompanyingPeriod); @@ -245,7 +250,7 @@ final class ActivityController extends AbstractController ); } - $this->addFlash('success', $this->get('translator')->trans('Success : activity updated!')); + $this->addFlash('success', $this->translator->trans('Success : activity updated!')); return $this->redirectToRoute('chill_activity_activity_show', $params); } @@ -363,6 +368,7 @@ final class ActivityController extends AbstractController if ($person instanceof Person) { $entity->setPerson($person); + $entity->getPersons()->add($person); } if ($accompanyingPeriod instanceof AccompanyingPeriod) { @@ -472,7 +478,7 @@ final class ActivityController extends AbstractController ); } - $this->addFlash('success', $this->get('translator')->trans('Success : activity created!')); + $this->addFlash('success', $this->translator->trans('Success : activity created!')); $params = $this->buildParamsToUrl($person, $accompanyingPeriod); diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityReasonController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityReasonController.php index 6af42a53c..95a49d0ba 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityReasonController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityReasonController.php @@ -13,15 +13,24 @@ namespace Chill\ActivityBundle\Controller; use Chill\ActivityBundle\Entity\ActivityReason; use Chill\ActivityBundle\Form\ActivityReasonType; +use Chill\ActivityBundle\Repository\ActivityReasonRepository; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * ActivityReason controller. */ class ActivityReasonController extends AbstractController { + private ActivityReasonRepository $activityReasonRepository; + + public function __construct(ActivityReasonRepository $activityReasonRepository) + { + $this->activityReasonRepository = $activityReasonRepository; + } + /** * Creates a new ActivityReason entity. */ @@ -56,8 +65,8 @@ class ActivityReasonController extends AbstractController $entity = $em->getRepository(\Chill\ActivityBundle\Entity\ActivityReason::class)->find($id); - if (!$entity) { - throw $this->createNotFoundException('Unable to find ActivityReason entity.'); + if (null === $entity) { + throw new NotFoundHttpException('Unable to find ActivityReason entity.'); } $editForm = $this->createEditForm($entity); @@ -75,7 +84,7 @@ class ActivityReasonController extends AbstractController { $em = $this->getDoctrine()->getManager(); - $entities = $em->getRepository(\Chill\ActivityBundle\Entity\ActivityReason::class)->findAll(); + $entities = $this->activityReasonRepository->findAll(); return $this->render('ChillActivityBundle:ActivityReason:index.html.twig', [ 'entities' => $entities, diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityReason.php b/src/Bundle/ChillActivityBundle/Entity/ActivityReason.php index c0cc21209..e6da6b7e0 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityReason.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityReason.php @@ -63,10 +63,8 @@ class ActivityReason /** * Get category. - * - * @return ActivityReasonCategory */ - public function getCategory() + public function getCategory(): ?ActivityReasonCategory { return $this->category; } @@ -107,6 +105,11 @@ class ActivityReason return $this->name; } + public function isActiveAndParentActive(): bool + { + return $this->active && null !== $this->getCategory() && $this->getCategory()->getActive(); + } + /** * Set active. * diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByCreatorAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByCreatorAggregator.php index c09685e4e..69149737b 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByCreatorAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByCreatorAggregator.php @@ -60,7 +60,7 @@ class ByCreatorAggregator implements AggregatorInterface return 'Created by'; } - if (null === $value) { + if (null === $value || '' === $value) { return ''; } diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php index 58c824adc..89732412d 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php @@ -65,7 +65,7 @@ class BySocialActionAggregator implements AggregatorInterface return 'Social action'; } - if (null === $value) { + if (null === $value || '' === $value) { return ''; } diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php index fe07fd23f..158e87664 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php @@ -65,7 +65,7 @@ class BySocialIssueAggregator implements AggregatorInterface return 'Social issues'; } - if (null === $value) { + if (null === $value || '' === $value) { return ''; } diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php index 5eab4cae3..c3ca6d59c 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByThirdpartyAggregator.php @@ -65,7 +65,7 @@ class ByThirdpartyAggregator implements AggregatorInterface return 'Accepted thirdparty'; } - if (null === $value) { + if (null === $value || '' === $value) { return ''; } diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/CreatorScopeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/CreatorScopeAggregator.php index 2041fcbb4..2c7ec1483 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/CreatorScopeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/CreatorScopeAggregator.php @@ -65,7 +65,7 @@ class CreatorScopeAggregator implements AggregatorInterface return 'Scope'; } - if (null === $value) { + if (null === $value || '' === $value) { return ''; } diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php index b648fcf83..ec4ce6315 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/LocationTypeAggregator.php @@ -65,11 +65,13 @@ class LocationTypeAggregator implements AggregatorInterface return 'Accepted locationtype'; } - if (null === $value) { + if (null === $value || '' === $value) { return ''; } - $lt = $this->locationTypeRepository->find($value); + if (null === $lt = $this->locationTypeRepository->find($value)) { + return ''; + } return $this->translatableStringHelper->localize( $lt->getTitle() diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php index 071ccd232..7cd16718e 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php @@ -71,7 +71,7 @@ class ActivityTypeAggregator implements AggregatorInterface return 'Activity type'; } - if (null === $value) { + if (null === $value || '' === $value) { return ''; } diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php index 2b1ac57b5..9bde692c6 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php @@ -66,7 +66,7 @@ class ActivityUserAggregator implements AggregatorInterface return 'Activity user'; } - if (null === $value) { + if (null === $value || '' === $value) { return ''; } diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersAggregator.php index ccccc48a0..139f2743e 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersAggregator.php @@ -64,7 +64,7 @@ class ActivityUsersAggregator implements AggregatorInterface return 'Activity users'; } - if (null === $value) { + if (null === $value || '' === $value) { return ''; } diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersJobAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersJobAggregator.php index a0a6a439b..5741a0e58 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersJobAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersJobAggregator.php @@ -63,7 +63,7 @@ class ActivityUsersJobAggregator implements \Chill\MainBundle\Export\AggregatorI return 'Users \'s job'; } - if (null === $value) { + if (null === $value || '' === $value) { return ''; } diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersScopeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersScopeAggregator.php index 975c5df27..15da300be 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersScopeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersScopeAggregator.php @@ -63,7 +63,7 @@ class ActivityUsersScopeAggregator implements \Chill\MainBundle\Export\Aggregato return 'Users \'s scope'; } - if (null === $value) { + if (null === $value || '' === $value) { return ''; } diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php index bfd785554..eaccf95cb 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php @@ -134,6 +134,10 @@ class ActivityReasonAggregator implements AggregatorInterface, ExportElementVali return 'reasons' === $data['level'] ? 'Group by reasons' : 'Group by categories of reason'; } + if (null === $value || '' === $value) { + return ''; + } + switch ($data['level']) { case 'reasons': $r = $this->activityReasonRepository->find($value); diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/SentReceivedAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/SentReceivedAggregator.php index 7d77a7c69..5f772e156 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/SentReceivedAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/SentReceivedAggregator.php @@ -57,6 +57,7 @@ class SentReceivedAggregator implements AggregatorInterface switch ($value) { case null: + case '': return ''; case 'sent': diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php index 575d11815..a793f21de 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php @@ -17,11 +17,9 @@ use Chill\ActivityBundle\Repository\ActivityTypeRepositoryInterface; use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Chill\PersonBundle\Export\Declarations; -use Doctrine\ORM\Query\Expr; use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormBuilderInterface; -use function in_array; class ActivityTypeFilter implements FilterInterface { @@ -44,14 +42,13 @@ class ActivityTypeFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('activity', $qb->getAllAliases(), true)) { - $qb->join(Activity::class, 'activity', Expr\Join::WITH, 'activity.accompanyingPeriod = acp'); - } - - $clause = $qb->expr()->in('activity.activityType', ':selected_activity_types'); - - $qb->andWhere($clause); - $qb->setParameter('selected_activity_types', $data['types']); + $qb->andWhere( + $qb->expr()->exists( + 'SELECT 1 FROM ' . Activity::class . ' act_type_filter_activity + WHERE act_type_filter_activity.activityType IN (:act_type_filter_activity_types) AND act_type_filter_activity.accompanyingPeriod = acp' + ) + ); + $qb->setParameter('act_type_filter_activity_types', $data['accepted_activitytypes']); } public function applyOn() diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityReasonType.php b/src/Bundle/ChillActivityBundle/Form/ActivityReasonType.php index 84a3e08ed..f47a101bd 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityReasonType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityReasonType.php @@ -11,7 +11,8 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Form; -use Chill\ActivityBundle\Form\Type\TranslatableActivityReasonCategory; +use Chill\ActivityBundle\Entity\ActivityReason; +use Chill\ActivityBundle\Form\Type\TranslatableActivityReasonCategoryType; use Chill\MainBundle\Form\Type\TranslatableStringFormType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\CheckboxType; @@ -25,13 +26,13 @@ class ActivityReasonType extends AbstractType $builder ->add('name', TranslatableStringFormType::class) ->add('active', CheckboxType::class, ['required' => false]) - ->add('category', TranslatableActivityReasonCategory::class); + ->add('category', TranslatableActivityReasonCategoryType::class); } public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ - 'data_class' => 'Chill\ActivityBundle\Entity\ActivityReason', + 'data_class' => ActivityReason::class, ]); } diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityType.php b/src/Bundle/ChillActivityBundle/Form/ActivityType.php index cabfc0e76..6d198c5fa 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityType.php @@ -13,7 +13,7 @@ namespace Chill\ActivityBundle\Form; use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Entity\ActivityPresence; -use Chill\ActivityBundle\Entity\ActivityReason; +use Chill\ActivityBundle\Form\Type\PickActivityReasonType; use Chill\ActivityBundle\Security\Authorization\ActivityVoter; use Chill\DocStoreBundle\Form\StoredObjectType; use Chill\MainBundle\Entity\Center; @@ -229,19 +229,10 @@ class ActivityType extends AbstractType } if ($activityType->isVisible('reasons')) { - $builder->add('reasons', EntityType::class, [ + $builder->add('reasons', PickActivityReasonType::class, [ 'label' => $activityType->getLabel('reasons'), 'required' => $activityType->isRequired('reasons'), - 'class' => ActivityReason::class, 'multiple' => true, - 'choice_label' => function (ActivityReason $activityReason) { - return $this->translatableStringHelper->localize($activityReason->getName()); - }, - 'attr' => ['class' => 'select2 '], - 'query_builder' => static function (EntityRepository $er) { - return $er->createQueryBuilder('a') - ->where('a.active = true'); - }, ]); } diff --git a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReason.php b/src/Bundle/ChillActivityBundle/Form/Type/PickActivityReasonType.php similarity index 68% rename from src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReason.php rename to src/Bundle/ChillActivityBundle/Form/Type/PickActivityReasonType.php index d8ac89963..a951ef940 100644 --- a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReason.php +++ b/src/Bundle/ChillActivityBundle/Form/Type/PickActivityReasonType.php @@ -12,9 +12,9 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Form\Type; use Chill\ActivityBundle\Entity\ActivityReason; +use Chill\ActivityBundle\Repository\ActivityReasonRepository; use Chill\ActivityBundle\Templating\Entity\ActivityReasonRender; -use Chill\MainBundle\Templating\TranslatableStringHelper; -use Doctrine\ORM\EntityRepository; +use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -22,31 +22,29 @@ use Symfony\Component\OptionsResolver\OptionsResolver; /** * FormType to choose amongst activity reasons. */ -class TranslatableActivityReason extends AbstractType +class PickActivityReasonType extends AbstractType { - /** - * @var ActivityReasonRender - */ - protected $reasonRender; + private ActivityReasonRepository $activityReasonRepository; - /** - * @var TranslatableStringHelper - */ - protected $translatableStringHelper; + private ActivityReasonRender $reasonRender; + + private TranslatableStringHelperInterface $translatableStringHelper; public function __construct( - TranslatableStringHelper $translatableStringHelper, - ActivityReasonRender $reasonRender + ActivityReasonRepository $activityReasonRepository, + ActivityReasonRender $reasonRender, + TranslatableStringHelperInterface $translatableStringHelper ) { - $this->translatableStringHelper = $translatableStringHelper; + $this->activityReasonRepository = $activityReasonRepository; $this->reasonRender = $reasonRender; + $this->translatableStringHelper = $translatableStringHelper; } public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults( [ - 'class' => 'ChillActivityBundle:ActivityReason', + 'class' => ActivityReason::class, 'choice_label' => function (ActivityReason $choice) { return $this->reasonRender->renderString($choice, []); }, @@ -57,10 +55,7 @@ class TranslatableActivityReason extends AbstractType return null; }, - 'query_builder' => static function (EntityRepository $er) { - return $er->createQueryBuilder('r') - ->where('r.active = true'); - }, + 'choices' => $this->activityReasonRepository->findAll(), 'attr' => ['class' => ' select2 '], ] ); diff --git a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategory.php b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategory.php deleted file mode 100644 index bac4822e6..000000000 --- a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategory.php +++ /dev/null @@ -1,59 +0,0 @@ -requestStack = $requestStack; - } - - public function configureOptions(OptionsResolver $resolver) - { - $locale = $this->requestStack->getCurrentRequest()->getLocale(); - $resolver->setDefaults( - [ - 'class' => 'ChillActivityBundle:ActivityReasonCategory', - 'choice_label' => 'name[' . $locale . ']', - 'query_builder' => static function (EntityRepository $er) { - return $er->createQueryBuilder('c') - ->where('c.active = true'); - }, - ] - ); - } - - public function getBlockPrefix() - { - return 'translatable_activity_reason_category'; - } - - public function getParent() - { - return EntityType::class; - } -} diff --git a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategoryType.php b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategoryType.php new file mode 100644 index 000000000..96dabe008 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategoryType.php @@ -0,0 +1,58 @@ +translatableStringHelper = $translatableStringHelper; + $this->translator = $translator; + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults( + [ + 'class' => ActivityReasonCategory::class, + 'choice_label' => function (ActivityReasonCategory $category) { + return $this->translatableStringHelper->localize($category->getName()) + . (!$category->getActive() ? ' (' . $this->translator->trans('inactive') . ')' : ''); + }, + ] + ); + } + + public function getBlockPrefix() + { + return 'translatable_activity_reason_category'; + } + + public function getParent() + { + return EntityType::class; + } +} diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityReasonRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityReasonRepository.php index 275c49b2c..c6b69319e 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityReasonRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityReasonRepository.php @@ -14,17 +14,38 @@ namespace Chill\ActivityBundle\Repository; use Chill\ActivityBundle\Entity\ActivityReason; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Persistence\ManagerRegistry; +use Symfony\Component\HttpFoundation\RequestStack; /** * @method ActivityReason|null find($id, $lockMode = null, $lockVersion = null) * @method ActivityReason|null findOneBy(array $criteria, array $orderBy = null) - * @method ActivityReason[] findAll() * @method ActivityReason[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) */ class ActivityReasonRepository extends ServiceEntityRepository { - public function __construct(ManagerRegistry $registry) - { + private RequestStack $requestStack; + + public function __construct( + ManagerRegistry $registry, + RequestStack $requestStack + ) { parent::__construct($registry, ActivityReason::class); + + $this->requestStack = $requestStack; + } + + /** + * @return ActivityReason[] + */ + public function findAll(): array + { + $qb = $this->createQueryBuilder('ar'); + $qb->select(['ar']) + ->leftJoin('ar.category', 'category') + ->addOrderBy('JSON_EXTRACT(category.name, :lang)') + ->addOrderBy('JSON_EXTRACT(ar.name, :lang)') + ->setParameter('lang', $this->requestStack->getCurrentRequest()->getLocale() ?? 'fr'); + + return $qb->getQuery()->getResult(); } } diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location/NewLocation.vue b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location/NewLocation.vue index 6a6289875..568c8747a 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location/NewLocation.vue +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location/NewLocation.vue @@ -117,7 +117,8 @@ export default { target: { //name, id }, edit: false, - addressId: null + addressId: null, + defaults: window.addaddress } } } diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js index ca56a5dae..9f710abeb 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js @@ -30,7 +30,7 @@ const store = createStore({ }, getters: { suggestedEntities(state) { - if (typeof state.activity.accompanyingPeriod === "undefined") { + if (typeof state.activity.accompanyingPeriod === "undefined" || state.activity.accompanyingPeriod === null) { return []; } const allEntities = [ diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.locations.js b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.locations.js index 056dc129d..7a216f628 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.locations.js +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.locations.js @@ -39,6 +39,9 @@ const makeConcernedThirdPartiesLocation = (locationType, store) => { return locations; }; const makeAccompanyingPeriodLocation = (locationType, store) => { + if (store.state.activity.accompanyingPeriod === null) { + return {}; + } const accPeriodLocation = store.state.activity.accompanyingPeriod.location; return { type: 'location', diff --git a/src/Bundle/ChillActivityBundle/Resources/views/ActivityReason/index.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/ActivityReason/index.html.twig index 7d9e5f71d..855c9386d 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/ActivityReason/index.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/ActivityReason/index.html.twig @@ -7,22 +7,34 @@ {{ 'Name'|trans }} + {{ 'Active'|trans }} {{ 'Actions'|trans }} {% for entity in entities %} - {{ entity.name|localize_translatable_string }} - + {% if entity.category is not null -%} + {{ entity.category.name|localize_translatable_string }} > + {% endif -%} + {{ entity.name|localize_translatable_string }} + + + + {% if entity.active and not entity.isActiveAndParentActive %} + {{ 'Associated activity reason category is inactive'|trans }} + {% endif %} + + + {% endfor %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/ActivityReasonCategory/index.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/ActivityReasonCategory/index.html.twig index 473059124..5f48180b3 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/ActivityReasonCategory/index.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/ActivityReasonCategory/index.html.twig @@ -7,6 +7,7 @@ {{ 'Name'|trans }} + {{ 'Active'|trans }} {{ 'Actions'|trans }} @@ -14,7 +15,11 @@ {% for entity in entities %} - {{ entity.name|localize_translatable_string }} + {{ entity.name|localize_translatable_string }} + + + + - + {{ form_end(edit_form) }} + + {% endblock %} diff --git a/src/Bundle/ChillEventBundle/Resources/views/Event/list.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Event/list.html.twig index 6e77b6df8..8d5f49da8 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Event/list.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Event/list.html.twig @@ -6,42 +6,42 @@

{{ 'Results %start%-%end% of %total%'|trans({ '%start%' : start, '%end%': start + events|length, '%total%' : total } ) }}

- +
- - - - - - + + + + + + - {% for event in events %} - - - - - + + + + - - {% endfor %} + {% endif %} + + + + + {% endfor %}
{{ 'Name'|trans }}{{ 'Date'|trans }}{{ 'Event type'|trans }} 
{{ 'Name'|trans }}{{ 'Date'|trans }}{{ 'Event type'|trans }} 
{{ event.name }}{{ event.date|format_date('long') }}{{ event.type.name|localize_translatable_string }} -
    -
  • - {# {% if is_granted('CHILL_EVENT_SEE_DETAILS', event) %} #} - - {{ 'See'|trans }} - - {# {% endif %} #} - {% if is_granted('CHILL_EVENT_UPDATE', event) %} + {% for event in events %} +
{{ event.name }}{{ event.date|format_date('long') }}{{ event.type.name|localize_translatable_string }} + -
- + {% endif %} {% if preview == false %} -{{ chill_pagination(paginator) }} + {{ chill_pagination(paginator) }} {% endif %} + diff --git a/src/Bundle/ChillEventBundle/Resources/views/Event/listByPerson.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Event/listByPerson.html.twig index 53e97c3c4..ef2dae85c 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Event/listByPerson.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Event/listByPerson.html.twig @@ -44,59 +44,59 @@ {{ participation.role.name|localize_translatable_string }} {{ participation.status.name|localize_translatable_string }} - + {% else %} -
  • {% if is_granted('CHILL_EVENT_UPDATE', participation.event) %} - - {{ 'Edit the event'|trans }} - + + {{ 'Edit the event'|trans }} + {% endif %} {% if is_granted('CHILL_EVENT_PARTICIPATION_UPDATE', participation) %} - - {{ 'Edit the participation'|trans }} - + + {{ 'Edit the participation'|trans }} + {% endif %} -
  • {% endif %} - + {% endfor %} @@ -108,31 +108,17 @@ {{ chill_pagination(paginator) }} {% endif %} -
    +
    {{ form_start(form_add_event_participation_by_person) }} - {# - - #} - {{ form_widget(form_add_event_participation_by_person.event_id, { 'attr' : { 'class' : 'form-control' } } ) }} -
    - {# - - #} - {{ form_widget(form_add_event_participation_by_person.submit, { 'attr' : { 'class' : 'btn btn-success' } } ) }} + {{ form_widget(form_add_event_participation_by_person.event_id, { 'attr' : { + 'class' : 'custom-select', + 'style': 'min-width: 15em; max-width: 18em; display: inline-block;' + }}) }} +
    + {{ form_widget(form_add_event_participation_by_person.submit, { 'attr' : { 'class' : 'btn btn-sm btn-save' } } ) }}
    {{ form_rest(form_add_event_participation_by_person) }} {{ form_end(form_add_event_participation_by_person) }}
    -{# -{{ form(form_add_event_participation_by_person) }} -#} - -
    - -
    - -
    -
    - {% endblock %} diff --git a/src/Bundle/ChillEventBundle/Resources/views/Event/new.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Event/new.html.twig index 44d24040b..f0d1b0ea2 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Event/new.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Event/new.html.twig @@ -3,6 +3,7 @@ {% block title 'Event creation'|trans %} {% block event_content -%} +

    {{ 'Event creation'|trans }}

    {{ form_start(form) }} @@ -26,4 +27,5 @@ {{ form_end(form) }} +
    {% endblock %} diff --git a/src/Bundle/ChillEventBundle/Resources/views/Event/newPickCenter.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Event/newPickCenter.html.twig index c4fb4aacd..a10d754e6 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Event/newPickCenter.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Event/newPickCenter.html.twig @@ -3,6 +3,7 @@ {% block title 'Event creation'|trans %} {% block event_content -%} +

    {{ 'Event creation'|trans }}

    {{ form_start(form) }} @@ -22,5 +23,5 @@ {{ form_end(form) }} - +
    {% endblock %} diff --git a/src/Bundle/ChillEventBundle/Resources/views/Event/show.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Event/show.html.twig index 6af5dd80a..4ce92a200 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Event/show.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Event/show.html.twig @@ -5,9 +5,10 @@ {% import 'ChillPersonBundle:Person:macro.html.twig' as person_macro %} {% block event_content -%} +

    {{ 'Details of an event'|trans }}

    - +
    @@ -69,7 +70,7 @@

    {% transchoice count %}%count% participations to this event{% endtranschoice %}

    {% if count > 0 %} -
    {{ 'Name'|trans }}
    +
    @@ -117,7 +118,7 @@ {% endif %} -
    +
    {{ form_start(form_add_participation_by_person) }}
    @@ -150,5 +151,5 @@
    {{ chill_delegated_block('block_footer_show', { 'event': event }) }}
    - +
    {% endblock %} diff --git a/src/Bundle/ChillEventBundle/Resources/views/Participation/confirm_delete.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Participation/confirm_delete.html.twig index 9b023a915..0d993b075 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Participation/confirm_delete.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Participation/confirm_delete.html.twig @@ -5,7 +5,7 @@ {% block title 'Remove participation'|trans %} {% block event_content %} - +
    {{ include('@ChillMain/Util/confirmation_template.html.twig', { 'title' : 'Remove participation'|trans, @@ -15,6 +15,6 @@ 'form' : delete_form } ) }} - +
    {% endblock %} diff --git a/src/Bundle/ChillEventBundle/Resources/views/Participation/edit-multiple.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Participation/edit-multiple.html.twig index a50615414..f0f522a3d 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Participation/edit-multiple.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Participation/edit-multiple.html.twig @@ -3,9 +3,10 @@ {% import 'ChillPersonBundle:Person:macro.html.twig' as person_macro %} {% block event_content -%} +

    {{ 'Participation Edit'|trans }}

    -
    {{ 'Person'|trans }}
    +
    @@ -18,11 +19,11 @@
    {{ 'Associated event'|trans }}
    -

    {{ 'Participations'|trans }}

    +

    {{ 'Participations'|trans }}

    {{ form_start(form) }} - +
    @@ -59,4 +60,5 @@ {{ form_end(form) }} + {% endblock %} diff --git a/src/Bundle/ChillEventBundle/Resources/views/Participation/edit.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Participation/edit.html.twig index 19592526e..db716b3dc 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Participation/edit.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Participation/edit.html.twig @@ -3,6 +3,7 @@ {% import 'ChillPersonBundle:Person:macro.html.twig' as person_macro %} {% block event_content -%} +

    {{ 'Participation Edit'|trans }}

    {{ 'Person'|trans }}
    @@ -42,4 +43,5 @@ {{ form_end(form) }} + {% endblock %} diff --git a/src/Bundle/ChillEventBundle/Resources/views/Participation/new-multiple.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Participation/new-multiple.html.twig index a0551ff1a..224b7265f 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Participation/new-multiple.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Participation/new-multiple.html.twig @@ -18,7 +18,7 @@ {% block event_content -%}

    {{ 'Participation creation'|trans }}

    -
    +
    @@ -30,7 +30,7 @@ {% include 'ChillEventBundle:Participation:_ignored_participations.html.twig' with ignored_participations %} {{ form_start(form) }} -
    {{ 'Associated event'|trans }}
    +
    diff --git a/src/Bundle/ChillEventBundle/Resources/views/Participation/new.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Participation/new.html.twig index 33f7bc213..3fbea8b68 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Participation/new.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Participation/new.html.twig @@ -5,6 +5,7 @@ {% block title 'Participation creation'|trans %} {% block event_content -%} +

    {{ 'Participation creation'|trans }}

    {{ 'Person'|trans }}
    @@ -43,5 +44,5 @@ {{ form_end(form) }} - + {% endblock %} diff --git a/src/Bundle/ChillEventBundle/Resources/views/layout.html.twig b/src/Bundle/ChillEventBundle/Resources/views/layout.html.twig index 45eb6e481..e34a10e18 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/layout.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/layout.html.twig @@ -16,9 +16,9 @@ * along with this program. If not, see . #} -{% extends "@ChillMain/layoutWithVerticalMenu.html.twig" %} +{% extends "@ChillMain/layout.html.twig" %} -{% block layout_wvm_content %} +{% block content %} {% block event_content %}

    {{ 'Event' |trans }}

    {% endblock %} diff --git a/src/Bundle/ChillMainBundle/Controller/RegroupmentController.php b/src/Bundle/ChillMainBundle/Controller/RegroupmentController.php new file mode 100644 index 000000000..c73b03027 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Controller/RegroupmentController.php @@ -0,0 +1,26 @@ +addOrderBy('e.id', 'ASC'); + + return parent::orderQuery($action, $query, $request, $paginator); + } +} diff --git a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php index 9be2f04fd..17b5db75e 100644 --- a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php +++ b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php @@ -85,7 +85,6 @@ class WorkflowController extends AbstractController ->setRelatedEntityClass($request->query->get('entityClass')) ->setRelatedEntityId($request->query->getInt('entityId')) ->setWorkflowName($request->query->get('workflow')) - ->addSubscriberToStep($this->getUser()) ->addSubscriberToFinal($this->getUser()); $errors = $this->validator->validate($entityWorkflow, null, ['creation']); diff --git a/src/Bundle/ChillMainBundle/Cron/CronManager.php b/src/Bundle/ChillMainBundle/Cron/CronManager.php index 52cba3d38..f69dcba76 100644 --- a/src/Bundle/ChillMainBundle/Cron/CronManager.php +++ b/src/Bundle/ChillMainBundle/Cron/CronManager.php @@ -44,7 +44,7 @@ class CronManager implements CronManagerInterface private const UPDATE_AFTER_EXEC = 'UPDATE ' . CronJobExecution::class . ' cr SET cr.lastEnd = :now, cr.lastStatus = :status WHERE cr.key = :key'; - private const UPDATE_BEFORE_EXEC = 'UPDATE ' . CronJobExecution::class . ' cr SET cr.lastExecution = :now WHERE cr.key = :key'; + private const UPDATE_BEFORE_EXEC = 'UPDATE ' . CronJobExecution::class . ' cr SET cr.lastStart = :now WHERE cr.key = :key'; private CronJobExecutionRepositoryInterface $cronJobExecutionRepository; @@ -90,7 +90,8 @@ class CronManager implements CronManagerInterface ->setParameters([ 'now' => new DateTimeImmutable('now'), 'key' => $job->getKey(), - ]); + ]) + ->execute(); } else { $execution = new CronJobExecution($job->getKey()); $this->entityManager->persist($execution); diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php index 378d90aa2..69546016a 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php @@ -18,6 +18,7 @@ use Chill\MainBundle\Controller\CountryController; use Chill\MainBundle\Controller\LanguageController; use Chill\MainBundle\Controller\LocationController; use Chill\MainBundle\Controller\LocationTypeController; +use Chill\MainBundle\Controller\RegroupmentController; use Chill\MainBundle\Controller\UserController; use Chill\MainBundle\Controller\UserJobApiController; use Chill\MainBundle\Controller\UserJobController; @@ -48,6 +49,7 @@ use Chill\MainBundle\Entity\Country; use Chill\MainBundle\Entity\Language; use Chill\MainBundle\Entity\Location; use Chill\MainBundle\Entity\LocationType; +use Chill\MainBundle\Entity\Regroupment; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\UserJob; use Chill\MainBundle\Form\CivilityType; @@ -55,6 +57,7 @@ use Chill\MainBundle\Form\CountryType; use Chill\MainBundle\Form\LanguageType; use Chill\MainBundle\Form\LocationFormType; use Chill\MainBundle\Form\LocationTypeType; +use Chill\MainBundle\Form\RegroupmentType; use Chill\MainBundle\Form\UserJobType; use Chill\MainBundle\Form\UserType; use Exception; @@ -148,6 +151,11 @@ class ChillMainExtension extends Extension implements $config['access_permissions_group_list'] ); + $container->setParameter( + 'chill_main.add_address', + $config['add_address'] + ); + $container->setParameter( 'chill_main.routing.resources', $config['routing']['resources'] @@ -223,6 +231,7 @@ class ChillMainExtension extends Extension implements 'installation' => [ 'name' => $config['installation_name'], ], 'available_languages' => $config['available_languages'], + 'add_address' => $config['add_address'], ], 'form_themes' => ['@ChillMain/Form/fields.html.twig'], ]; @@ -493,6 +502,27 @@ class ChillMainExtension extends Extension implements ], ], ], + [ + 'class' => Regroupment::class, + 'name' => 'regroupment', + 'base_path' => '/admin/regroupment', + 'form_class' => RegroupmentType::class, + 'controller' => RegroupmentController::class, + 'actions' => [ + 'index' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillMain/Admin/Regroupment/index.html.twig', + ], + 'new' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillMain/Admin/Regroupment/new.html.twig', + ], + 'edit' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillMain/Admin/Regroupment/edit.html.twig', + ], + ], + ], ], 'apis' => [ [ diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php index 3f09f8181..2f622878a 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php @@ -276,6 +276,16 @@ class Configuration implements ConfigurationInterface ->end() // end of root ; + $rootNode->children() + ->arrayNode('add_address')->addDefaultsIfNotSet()->children() + ->scalarNode('default_country')->cannotBeEmpty()->defaultValue('BE')->end() + ->arrayNode('map_center')->children() + ->scalarNode('x')->cannotBeEmpty()->defaultValue(50.8443)->end() + ->scalarNode('y')->cannotBeEmpty()->defaultValue(4.3523)->end() + ->scalarNode('z')->cannotBeEmpty()->defaultValue(15)->end() + ->end() + ->end(); + return $treeBuilder; } } diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AddWidgetConfigurationTrait.php b/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AddWidgetConfigurationTrait.php index 468314159..a6688fca2 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AddWidgetConfigurationTrait.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AddWidgetConfigurationTrait.php @@ -135,12 +135,8 @@ trait AddWidgetConfigurationTrait /** * add configuration nodes for the widget at the given place. - * - * @param type $place - * - * @return type */ - protected function addWidgetsConfiguration($place, ContainerBuilder $containerBuilder) + protected function addWidgetsConfiguration(string $place, ContainerBuilder $containerBuilder) { $treeBuilder = new TreeBuilder($place); $root = $treeBuilder->getRootNode($place) diff --git a/src/Bundle/ChillMainBundle/Entity/Regroupment.php b/src/Bundle/ChillMainBundle/Entity/Regroupment.php new file mode 100644 index 000000000..5faffd17c --- /dev/null +++ b/src/Bundle/ChillMainBundle/Entity/Regroupment.php @@ -0,0 +1,95 @@ +centers = new ArrayCollection(); + } + + public function getCenters(): ?Collection + { + return $this->centers; + } + + public function getId(): ?int + { + return $this->id; + } + + public function getIsActive(): bool + { + return $this->isActive; + } + + public function getName(): string + { + return $this->name; + } + + public function setCenters(?Collection $centers): self + { + $this->centers = $centers; + + return $this; + } + + public function setIsActive(bool $isActive): self + { + $this->isActive = $isActive; + + return $this; + } + + public function setName(string $name): self + { + $this->name = $name; + + return $this; + } +} diff --git a/src/Bundle/ChillMainBundle/Entity/User.php b/src/Bundle/ChillMainBundle/Entity/User.php index 80a0b5b2a..dda6b63e4 100644 --- a/src/Bundle/ChillMainBundle/Entity/User.php +++ b/src/Bundle/ChillMainBundle/Entity/User.php @@ -15,7 +15,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use RuntimeException; -use Symfony\Component\Security\Core\User\AdvancedUserInterface; +use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Serializer\Annotation as Serializer; use Symfony\Component\Validator\Context\ExecutionContextInterface; @@ -31,7 +31,7 @@ use function in_array; * "user": User::class * }) */ -class User implements AdvancedUserInterface +class User implements UserInterface { /** * @ORM\Id @@ -58,8 +58,6 @@ class User implements AdvancedUserInterface private ?Location $currentLocation = null; /** - * @var string - * * @ORM\Column(type="string", length=150, nullable=true) */ private ?string $email = null; @@ -216,7 +214,7 @@ class User implements AdvancedUserInterface } /** - * @return GroupCenter + * @return Collection */ public function getGroupCenters() { @@ -225,10 +223,8 @@ class User implements AdvancedUserInterface /** * Get id. - * - * @return int */ - public function getId() + public function getId(): ?int { return $this->id; } @@ -487,7 +483,7 @@ class User implements AdvancedUserInterface * * @param string $name * - * @return Agent + * @return User */ public function setUsername($name) { diff --git a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php index d86770560..4bff7a3f5 100644 --- a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php +++ b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php @@ -132,8 +132,6 @@ class EntityWorkflowStep { if (!$this->destUser->contains($user)) { $this->destUser[] = $user; - $this->getEntityWorkflow() - ->addSubscriberToFinal($user); } return $this; @@ -143,8 +141,6 @@ class EntityWorkflowStep { if (!$this->destUserByAccessKey->contains($user) && !$this->destUser->contains($user)) { $this->destUserByAccessKey[] = $user; - $this->getEntityWorkflow() - ->addSubscriberToFinal($user); } return $this; diff --git a/src/Bundle/ChillMainBundle/Form/RegroupmentType.php b/src/Bundle/ChillMainBundle/Form/RegroupmentType.php new file mode 100644 index 000000000..bc8e6684f --- /dev/null +++ b/src/Bundle/ChillMainBundle/Form/RegroupmentType.php @@ -0,0 +1,47 @@ +add('name', TextType::class, [ + 'label' => 'Nom', + ]) + ->add('centers', EntityType::class, [ + 'class' => Center::class, + 'multiple' => true, + 'attr' => ['class' => 'select2'], + ]) + ->add('isActive', CheckboxType::class, [ + 'label' => 'Actif ?', + 'required' => false, + ]); + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver + ->setDefault('class', Regroupment::class); + } +} diff --git a/src/Bundle/ChillMainBundle/Form/Type/ChillDateTimeType.php b/src/Bundle/ChillMainBundle/Form/Type/ChillDateTimeType.php index 639848d9a..0063ee7d9 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/ChillDateTimeType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/ChillDateTimeType.php @@ -27,7 +27,6 @@ class ChillDateTimeType extends AbstractType { $resolver ->setDefault('date_widget', 'single_text') - ->setDefault('date_format', 'dd-MM-yyyy') ->setDefault('time_widget', 'choice') ->setDefault('minutes', range(0, 59, 5)) ->setDefault('hours', range(8, 22)) diff --git a/src/Bundle/ChillMainBundle/Resources/public/lib/api/apiMethods.ts b/src/Bundle/ChillMainBundle/Resources/public/lib/api/apiMethods.ts index d12871bdd..0ef659128 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/lib/api/apiMethods.ts +++ b/src/Bundle/ChillMainBundle/Resources/public/lib/api/apiMethods.ts @@ -67,13 +67,18 @@ export const makeFetch = (method: 'POST'|'GET'|'PUT'|'PATCH'|'DEL }, }; - if (body !== null || typeof body !== 'undefined') { + console.log('for url '+url, body); + console.log('for url '+url, body !== null); + + if (body !== null && typeof body !== 'undefined') { Object.assign(opts, {body: JSON.stringify(body)}) } if (typeof options !== 'undefined') { opts = Object.assign(opts, options); } + console.log('will fetch', url); + console.log('content for ' + url, opts); return fetch(url, opts) .then(response => { diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue index 8cb871de6..21ab5e3d0 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue @@ -315,8 +315,11 @@ export default { addressMap: { // Note: LeafletJs demands [lat, lon] // cfr https://macwright.com/lonlat/ - center : [48.8589, 2.3469], - zoom: 12 + center : [ + this.context.defaults.map_center.x, + this.context.defaults.map_center.y, + ], + zoom: this.context.defaults.map_center.z }, }, errorMsg: [] diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressMap.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressMap.vue index aad821c0d..d3c04260f 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressMap.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressMap.vue @@ -8,8 +8,12 @@ import L from 'leaflet'; import markerIconPng from 'leaflet/dist/images/marker-icon.png' import 'leaflet/dist/leaflet.css'; +const lonLatForLeaflet = (coordinates) => { + return [coordinates[1], coordinates[0]]; +} + export default { - name: 'AddressMap', + name: 'AddressMap', props: ['entity'], data() { return { @@ -21,10 +25,47 @@ export default { center() { return this.entity.addressMap.center; }, + hasAddressPoint() { + if (Object.keys(this.entity.address).length === 0) { + return false; + } + if (null !== this.entity.address.addressReference) { + return true; + } + if (null !== this.entity.address.postcode && null !== this.entity.address.postcode.center) { + return true; + } + return false; + }, + /** + * + * @returns {coordinates: [float, float], type: "Point"} + */ + addressPoint() { + if (Object.keys(this.entity.address).length === 0) { + return null; + } + + if (null !== this.entity.address.addressReference) { + return this.entity.address.addressReference.point; + } + + if (null !== this.entity.address.postcode && null !== this.entity.address.postcode.center) { + return this.entity.address.postcode.center; + } + + return null; + }, }, methods:{ init() { - this.map = L.map('address_map').setView([46.67059, -1.42683], 12); + this.map = L.map('address_map'); + + if (!this.hasAddressPoint) { + this.map.setView(lonLatForLeaflet(this.entity.addressMap.center), this.entity.addressMap.zoom); + } else { + this.map.setView(lonLatForLeaflet(this.addressPoint.coordinates), 15); + } this.map.scrollWheelZoom.disable(); @@ -37,20 +78,22 @@ export default { iconAnchor: [12, 41], }); - this.marker = L.marker([48.8589, 2.3469], {icon: markerIcon}); + if (!this.hasAddressPoint) { + this.marker = L.marker(lonLatForLeaflet(this.entity.addressMap.center), {icon: markerIcon}); + } else { + this.marker = L.marker(lonLatForLeaflet(this.addressPoint.coordinates), {icon: markerIcon}); + } this.marker.addTo(this.map); }, update() { - console.log('update map with : ', this.center) - if (this.marker && this.center) { - this.marker.setLatLng(this.center); - this.map.setView(this.center, 15); + if (this.marker && this.entity.addressMap.center) { + this.marker.setLatLng(lonLatForLeaflet(this.entity.addressMap.center)); + this.map.panTo(lonLatForLeaflet(this.entity.addressMap.center)); } } }, - mounted(){ + mounted() { this.init(); - this.update(); - } + }, } diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CountrySelection.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CountrySelection.vue index 6e64b2985..1b220ff00 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CountrySelection.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CountrySelection.vue @@ -30,7 +30,7 @@ export default { data() { return { value: this.selectCountryByCode( - this.context.edit ? this.entity.selected.country.code : 'FR' + this.context.edit ? this.entity.selected.country.code : this.context.defaults.default_country ) } }, @@ -45,14 +45,12 @@ export default { }, }, mounted() { - this.init(); + console.log('country selection mounted', this.value); + if (this.value !== undefined) { + this.selectCountry(this.value); + } }, - methods: { - init() { - if (this.value !== undefined) { - this.selectCountry(this.value); - } - }, + methods: { selectCountryByCode(countryCode) { return this.entity.loaded.countries.filter(c => c.countryCode === countryCode)[0]; }, diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/EditPane.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/EditPane.vue index 9ae464e3e..c0e42a7b1 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/EditPane.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/EditPane.vue @@ -174,8 +174,8 @@ export default { }, updateMapCenter(point) { console.log('point', point); - this.addressMap.center[0] = point.coordinates[1]; // TODO use reverse() - this.addressMap.center[1] = point.coordinates[0]; + this.addressMap.center[0] = point.coordinates[0]; + this.addressMap.center[1] = point.coordinates[1]; this.$refs.addressMap.update(); // cast child methods } } diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/ShowPane.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/ShowPane.vue index f910e6422..5048815e2 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/ShowPane.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/ShowPane.vue @@ -93,7 +93,7 @@ export default { ], emits: ['openEditPane'], mounted() { - console.log('context', this.context) + //console.log('context', this.context) }, computed: { address() { diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/index.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/index.js index 9241aa29d..ab0fb0bd4 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/index.js +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/index.js @@ -20,7 +20,8 @@ containers.forEach((container) => { }, edit: container.dataset.mode === 'edit', //boolean addressId: parseInt(container.dataset.addressId) || null, - backUrl: container.dataset.backUrl || null + backUrl: container.dataset.backUrl || null, + defaults: JSON.parse(container.dataset.addressDefaults) }, options: { /// Options override default. diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/mod_input_address_index.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/mod_input_address_index.js index cb7da6e07..6e9fd917c 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/mod_input_address_index.js +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/mod_input_address_index.js @@ -19,7 +19,6 @@ const addAddressInput = (inputs) => { if (container === null) { throw Error("no container"); } - console.log('useValidFrom', el.dataset.useValidFrom === '1'); const app = createApp({ template: ``, @@ -34,6 +33,7 @@ const addAddressInput = (inputs) => { }, edit: isEdit, addressId: addressIdInt, + defaults: window.addaddress, }, options: { /// Options override default. diff --git a/src/Bundle/ChillMainBundle/Resources/views/Address/_insert_vue_address.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Address/_insert_vue_address.html.twig index 571f4257f..70780eb90 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Address/_insert_vue_address.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Address/_insert_vue_address.html.twig @@ -72,6 +72,8 @@ {% if onlyButton is defined and onlyButton == 1 %} data-hide-address="true" {% endif %} + + data-address-defaults="{{ add_address|json_encode|e('html') }}" > {{ encore_entry_script_tags('vue_address') }} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Admin/Regroupment/edit.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/Regroupment/edit.html.twig new file mode 100644 index 000000000..4d55c480c --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/Admin/Regroupment/edit.html.twig @@ -0,0 +1,11 @@ +{% extends '@ChillMain/CRUD/Admin/index.html.twig' %} + +{% block title %} + {% include('@ChillMain/CRUD/_edit_title.html.twig') %} +{% endblock %} + +{% block admin_content %} + {% embed '@ChillMain/CRUD/_edit_content.html.twig' %} + {% block content_form_actions_save_and_show %}{% endblock %} + {% endembed %} +{% endblock admin_content %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Admin/Regroupment/index.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/Regroupment/index.html.twig new file mode 100644 index 000000000..06e646083 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/Admin/Regroupment/index.html.twig @@ -0,0 +1,39 @@ +{% extends '@ChillMain/CRUD/Admin/index.html.twig' %} + +{% block admin_content %} + {% embed '@ChillMain/CRUD/_index.html.twig' %} + {% block table_entities_thead_tr %} +
    + + + {% endblock %} + + {% block table_entities_tbody %} + {% for entity in entities %} + + + + + + {% endfor %} + {% endblock %} + + {% block actions_before %} +
  • + {{'Back to the admin'|trans}} +
  • + {% endblock %} + {% endembed %} +{% endblock %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Admin/Regroupment/new.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/Regroupment/new.html.twig new file mode 100644 index 000000000..7c204dddd --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/Admin/Regroupment/new.html.twig @@ -0,0 +1,11 @@ +{% extends '@ChillMain/CRUD/Admin/index.html.twig' %} + +{% block title %} + {% include('@ChillMain/CRUD/_new_title.html.twig') %} +{% endblock %} + +{% block admin_content %} + {% embed '@ChillMain/CRUD/_new_content.html.twig' %} + {% block content_form_actions_save_and_show %}{% endblock %} + {% endembed %} +{% endblock admin_content %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig b/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig index 5543809fc..319adad81 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig @@ -9,6 +9,11 @@ {% block head_custom %}{% endblock %} + + {{ encore_entry_link_tags('mod_bootstrap') }} {{ encore_entry_link_tags('mod_forkawesome') }} {{ encore_entry_link_tags('mod_ckeditor5') }} diff --git a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/AdminUserMenuBuilder.php b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/AdminUserMenuBuilder.php index 96f2fb3bd..4b6583aab 100644 --- a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/AdminUserMenuBuilder.php +++ b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/AdminUserMenuBuilder.php @@ -53,6 +53,10 @@ class AdminUserMenuBuilder implements LocalMenuBuilderInterface 'route' => 'admin_center', ])->setExtras(['order' => 1010]); + $menu->addChild('Regroupements des centres', [ + 'route' => 'chill_crud_regroupment_index', + ])->setExtras(['order' => 1015]); + $menu->addChild('List circles', [ 'route' => 'admin_scope', ])->setExtras(['order' => 1020]); diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelperForCurrentUser.php b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelperForCurrentUser.php new file mode 100644 index 000000000..55005fe92 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelperForCurrentUser.php @@ -0,0 +1,47 @@ +authorizationHelper = $authorizationHelper; + $this->security = $security; + } + + public function getReachableCenters(string $role, ?Scope $scope = null): array + { + if (!$this->security->getUser() instanceof User) { + return []; + } + + return $this->authorizationHelper->getReachableCenters($this->security->getUser(), $role, $scope); + } + + public function getReachableScopes(string $role, $center): array + { + if (!$this->security->getUser() instanceof User) { + return []; + } + + return $this->authorizationHelper->getReachableScopes($this->security->getUser(), $role, $center); + } +} diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelperForCurrentUserInterface.php b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelperForCurrentUserInterface.php new file mode 100644 index 000000000..f0d3f9fba --- /dev/null +++ b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelperForCurrentUserInterface.php @@ -0,0 +1,31 @@ +getLastStart() < $now->sub(new DateInterval('P1D')) - && in_array($now->format('H'), self::ACCEPTED_HOURS, true) // introduce a random component to ensure a roll when multiple instances are hosted on same machines - && mt_rand(0, 5) === 0; + && mt_rand(0, 10) === 0; } public function getKey(): string diff --git a/src/Bundle/ChillMainBundle/Tests/Services/AddressGeographicalUnit/RefreshAddressToGeographicalUnitMaterializedViewCronJobTest.php b/src/Bundle/ChillMainBundle/Tests/Services/AddressGeographicalUnit/RefreshAddressToGeographicalUnitMaterializedViewCronJobTest.php index f4e4a586e..687d5df2b 100644 --- a/src/Bundle/ChillMainBundle/Tests/Services/AddressGeographicalUnit/RefreshAddressToGeographicalUnitMaterializedViewCronJobTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Services/AddressGeographicalUnit/RefreshAddressToGeographicalUnitMaterializedViewCronJobTest.php @@ -30,6 +30,56 @@ final class RefreshAddressToGeographicalUnitMaterializedViewCronJobTest extends $this->connection = self::$container->get(Connection::class); } + public function testCanRun(): void + { + // As the can run is executed one of ten, this should be executed at least one after + // 10 + 5 executions + $job = new \Chill\MainBundle\Service\AddressGeographicalUnit\RefreshAddressToGeographicalUnitMaterializedViewCronJob( + $this->connection + ); + + $lastExecution = new CronJobExecution($job->getKey()); + $lastExecution->setLastStart(new DateTimeImmutable('2 days ago')); + + $executedForFirstTime = 0; + $executedAfterPreviousExecution = 0; + + for ($round = 0; 20 > $round; ++$round) { + if ($job->canRun(null)) { + ++$executedForFirstTime; + } + + if ($job->canRun($lastExecution)) { + ++$executedAfterPreviousExecution; + } + } + + $this->assertGreaterThan(0, $executedForFirstTime); + $this->assertGreaterThan(0, $executedAfterPreviousExecution); + } + + public function testCanRunShouldReturnFalse(): void + { + // As the can run is executed one of ten, this should be executed at least one after + // 10 + 5 executions + $job = new \Chill\MainBundle\Service\AddressGeographicalUnit\RefreshAddressToGeographicalUnitMaterializedViewCronJob( + $this->connection + ); + + $lastExecution = new CronJobExecution($job->getKey()); + $lastExecution->setLastStart(new DateTimeImmutable('2 hours ago')); + + $executedAfterPreviousExecution = 0; + + for ($round = 0; 20 > $round; ++$round) { + if ($job->canRun($lastExecution)) { + ++$executedAfterPreviousExecution; + } + } + + $this->assertEquals(0, $executedAfterPreviousExecution); + } + public function testFullRun(): void { $job = new \Chill\MainBundle\Service\AddressGeographicalUnit\RefreshAddressToGeographicalUnitMaterializedViewCronJob( diff --git a/src/Bundle/ChillMainBundle/config/services/controller.yaml b/src/Bundle/ChillMainBundle/config/services/controller.yaml index 28abc94e8..16c545a81 100644 --- a/src/Bundle/ChillMainBundle/config/services/controller.yaml +++ b/src/Bundle/ChillMainBundle/config/services/controller.yaml @@ -33,3 +33,7 @@ services: arguments: $security: '@Symfony\Component\Security\Core\Security' tags: ['controller.service_arguments'] + + Chill\MainBundle\Controller\RegroupmentController: + autowire: true + autoconfigure: true diff --git a/src/Bundle/ChillMainBundle/config/services/form.yaml b/src/Bundle/ChillMainBundle/config/services/form.yaml index 58f01883f..8157c27e9 100644 --- a/src/Bundle/ChillMainBundle/config/services/form.yaml +++ b/src/Bundle/ChillMainBundle/config/services/form.yaml @@ -138,6 +138,10 @@ services: autowire: true autoconfigure: true + Chill\MainBundle\Form\RegroupmentType: + autowire: true + autoconfigure: true + Chill\MainBundle\Form\DataTransformer\IdToLocationDataTransformer: ~ Chill\MainBundle\Form\DataTransformer\IdToUserDataTransformer: ~ Chill\MainBundle\Form\DataTransformer\IdToUsersDataTransformer: ~ diff --git a/src/Bundle/ChillMainBundle/config/services/security.yaml b/src/Bundle/ChillMainBundle/config/services/security.yaml index 824144470..c0d9f98b9 100644 --- a/src/Bundle/ChillMainBundle/config/services/security.yaml +++ b/src/Bundle/ChillMainBundle/config/services/security.yaml @@ -3,6 +3,11 @@ services: autowire: true autoconfigure: true + Chill\MainBundle\Security\: + autoconfigure: true + autowire: true + resource: '../../Security' + Chill\MainBundle\Security\Resolver\CenterResolverDispatcher: arguments: - !tagged_iterator chill_main.center_resolver diff --git a/src/Bundle/ChillMainBundle/migrations/Version20230111104315.php b/src/Bundle/ChillMainBundle/migrations/Version20230111104315.php new file mode 100644 index 000000000..aa6e0f4c5 --- /dev/null +++ b/src/Bundle/ChillMainBundle/migrations/Version20230111104315.php @@ -0,0 +1,43 @@ +addSql('DROP SEQUENCE regroupment_id_seq CASCADE'); + $this->addSql('ALTER TABLE regroupment_center DROP CONSTRAINT FK_2BCCE2F9EC6D1029'); + $this->addSql('ALTER TABLE regroupment_center DROP CONSTRAINT FK_2BCCE2F95932F377'); + $this->addSql('DROP TABLE regroupment'); + $this->addSql('DROP TABLE regroupment_center'); + } + + public function getDescription(): string + { + return 'Add regroupment admin entity'; + } + + public function up(Schema $schema): void + { + $this->addSql('CREATE SEQUENCE regroupment_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE TABLE regroupment (id INT NOT NULL, name VARCHAR(15) DEFAULT \'\' NOT NULL, isActive BOOLEAN NOT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE TABLE regroupment_center (regroupment_id INT NOT NULL, center_id INT NOT NULL, PRIMARY KEY(regroupment_id, center_id))'); + $this->addSql('CREATE INDEX IDX_2BCCE2F9EC6D1029 ON regroupment_center (regroupment_id)'); + $this->addSql('CREATE INDEX IDX_2BCCE2F95932F377 ON regroupment_center (center_id)'); + $this->addSql('ALTER TABLE regroupment_center ADD CONSTRAINT FK_2BCCE2F9EC6D1029 FOREIGN KEY (regroupment_id) REFERENCES regroupment (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE regroupment_center ADD CONSTRAINT FK_2BCCE2F95932F377 FOREIGN KEY (center_id) REFERENCES centers (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + } +} diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index fc6d901d2..9ec0d5ec1 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -42,6 +42,8 @@ by_user: "par " lifecycleUpdate: Evenements de création et mise à jour address_fields: Données liées à l'adresse +inactive: inactif + Edit: Modifier Update: Mettre à jour Back to the list: Retour à la liste @@ -408,6 +410,12 @@ crud: add_new: Ajouter une civilité title_new: Nouvelle civilité title_edit: Modifier une civilité + regroupment: + index: + title: Liste des regroupements + add_new: Ajouter un regroupement + title_new: Nouveau regroupement + title_edit: Modifier un regroupement No entities: Aucun élément diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php index 745a64240..bf0d998ff 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php @@ -13,12 +13,13 @@ namespace Chill\PersonBundle\Controller; use Chill\MainBundle\CRUD\Controller\ApiController; use Chill\MainBundle\Entity\Address; -use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper; use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Security\Authorization\PersonVoter; +use Chill\PersonBundle\Security\AuthorizedCenterOnPersonCreationInterface; use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; @@ -26,16 +27,37 @@ use function in_array; class PersonApiController extends ApiController { - private AuthorizationHelper $authorizationHelper; + private AuthorizedCenterOnPersonCreationInterface $authorizedCenterOnPersonCreation; private ConfigPersonAltNamesHelper $configPersonAltNameHelper; + private bool $showCenters; + public function __construct( - AuthorizationHelper $authorizationHelper, - ConfigPersonAltNamesHelper $configPersonAltNameHelper + AuthorizedCenterOnPersonCreationInterface $authorizedCenterOnPersonCreation, + ConfigPersonAltNamesHelper $configPersonAltNameHelper, + ParameterBagInterface $parameterBag ) { - $this->authorizationHelper = $authorizationHelper; + $this->authorizedCenterOnPersonCreation = $authorizedCenterOnPersonCreation; $this->configPersonAltNameHelper = $configPersonAltNameHelper; + $this->showCenters = $parameterBag->get('chill_main')['acl']['form_show_centers']; + } + + /** + * @Route("/api/1.0/person/creation/authorized-centers", + * name="chill_person_person_creation_authorized_centers" + * ) + */ + public function authorizedCentersForCreation(): Response + { + $centers = $this->authorizedCenterOnPersonCreation->getCenters(); + + return $this->json( + ['showCenters' => $this->showCenters, 'centers' => $centers], + Response::HTTP_OK, + [], + ['gropus' => ['read']] + ); } /** diff --git a/src/Bundle/ChillPersonBundle/Controller/SocialWork/SocialIssueController.php b/src/Bundle/ChillPersonBundle/Controller/SocialWork/SocialIssueController.php index 97b85263c..769e90de7 100644 --- a/src/Bundle/ChillPersonBundle/Controller/SocialWork/SocialIssueController.php +++ b/src/Bundle/ChillPersonBundle/Controller/SocialWork/SocialIssueController.php @@ -13,10 +13,25 @@ namespace Chill\PersonBundle\Controller\SocialWork; use Chill\MainBundle\CRUD\Controller\CRUDController; use Chill\MainBundle\Pagination\PaginatorInterface; +use LogicException; +use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\Request; class SocialIssueController extends CRUDController { + protected function createFormFor(string $action, $entity, ?string $formClass = null, array $formOptions = []): FormInterface + { + if ('new' === $action) { + return parent::createFormFor($action, $entity, $formClass, ['step' => 'create']); + } + + if ('edit' === $action) { + return parent::createFormFor($action, $entity, $formClass, ['step' => 'edit']); + } + + throw new LogicException('action is not supported: ' . $action); + } + protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator) { $query->addOrderBy('e.ordering', 'ASC'); diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index a477f9adb..4e2bd4e89 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -1567,7 +1567,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * * @return $this */ - public function setCenter(Center $center): self + public function setCenter(?Center $center): self { $modification = new DateTimeImmutable('now'); @@ -1577,7 +1577,11 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI } } - $this->centerHistory[] = $new = new PersonCenterHistory($this, $center, $modification); + if (null === $center) { + return $this; + } + + $this->centerHistory[] = new PersonCenterHistory($this, $center, $modification); return $this; } diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php index 42c8442c1..675a1a923 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php @@ -356,7 +356,9 @@ class SocialIssue { $this->parent = $parent; - $parent->addChild($this); + if (null !== $parent) { + $parent->addChild($this); + } return $this; } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php index d9fb57e35..96deac574 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php @@ -65,7 +65,7 @@ class AdministrativeLocationAggregator implements AggregatorInterface return 'Administrative location'; } - if (null === $value) { + if (null === $value || '' === $value) { return ''; } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php index dfa94e842..342958361 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php @@ -60,7 +60,7 @@ class ClosingMotiveAggregator implements AggregatorInterface return 'Closing motive'; } - if (null === $value) { + if (null === $value || '' === $value) { return ''; } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/CreatorJobAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/CreatorJobAggregator.php index 6c958ca6c..c336a8887 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/CreatorJobAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/CreatorJobAggregator.php @@ -65,7 +65,7 @@ class CreatorJobAggregator implements AggregatorInterface return 'export.aggregator.course.by_creator_job.Creator\'s job'; } - if (null === $value || null === $j = $this->jobRepository->find($value)) { + if (null === $value || '' === $value || null === $j = $this->jobRepository->find($value)) { return ''; } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php index 94d8296ad..b6436efc0 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php @@ -69,7 +69,7 @@ final class EvaluationAggregator implements AggregatorInterface return 'Evaluation'; } - if (null === $value) { + if (null === $value || '' === $value) { return ''; } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php index e0606a959..80781b823 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php @@ -143,7 +143,7 @@ final class GeographicalUnitStatAggregator implements AggregatorInterface return 'acp_geog_agg_unitname'; } - if (null === $value) { + if (null === $value || '' === $value) { return ''; } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/JobAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/JobAggregator.php index d054a4a3f..5019d3a8b 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/JobAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/JobAggregator.php @@ -65,7 +65,7 @@ final class JobAggregator implements AggregatorInterface return 'Job'; } - if (null === $value) { + if (null === $value || '' === $value) { return ''; } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php index 3c96b6d06..37d0c7b20 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php @@ -67,7 +67,7 @@ final class OriginAggregator implements AggregatorInterface return 'Origin'; } - if (null === $value) { + if (null === $value || '' === $value) { return ''; } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php index 01bc3a459..a09097fd2 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php @@ -94,7 +94,7 @@ final class ReferrerAggregator implements AggregatorInterface return 'Referrer'; } - if (null === $value) { + if (null === $value || '' === $value) { return ''; } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregator.php index 62f8cdef2..4f8c6f0ef 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregator.php @@ -101,7 +101,7 @@ class ReferrerScopeAggregator implements AggregatorInterface return 'export.aggregator.course.by_user_scope.Referrer\'s scope'; } - if (null === $value) { + if (null === $value || '' === $value) { return ''; } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php index 47339143f..8f34661bb 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php @@ -65,11 +65,13 @@ final class ScopeAggregator implements AggregatorInterface return 'Scope'; } - if (null === $value) { + if (null === $value || '' === $value) { return ''; } - $s = $this->scopeRepository->find($value); + if (null === $s = $this->scopeRepository->find($value)) { + return ''; + } return $this->translatableStringHelper->localize( $s->getName() diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregator.php index feb80477a..3bdd6549e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregator.php @@ -66,11 +66,13 @@ final class SocialActionAggregator implements AggregatorInterface return 'Social action'; } - if (null === $value) { + if (null === $value || '' === $value) { return ''; } - $sa = $this->actionRepository->find($value); + if (null === $sa = $this->actionRepository->find($value)) { + return ''; + } return $this->actionRender->renderString($sa, []); }; diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php index bf0c9ba26..12fa5a454 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php @@ -66,6 +66,10 @@ final class SocialIssueAggregator implements AggregatorInterface return 'Social issues'; } + if (null === $value || '' === $value) { + return ''; + } + $i = $this->issueRepository->find($value); return $this->issueRender->renderString($i, []); diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php index e17e9f9a5..84dbd4e69 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php @@ -98,6 +98,7 @@ final class StepAggregator implements AggregatorInterface return 'Step'; case null: + case '': return ''; default: diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php index aec3503b2..0c13611cb 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php @@ -60,7 +60,7 @@ class EvaluationTypeAggregator implements AggregatorInterface return 'Evaluation type'; } - if (null === $value) { + if (null === $value || '' === $value) { return ''; } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php index 19884dd10..52bcd88e5 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php @@ -89,7 +89,7 @@ class CompositionAggregator implements AggregatorInterface return 'Composition'; } - if (null === $value) { + if (null === $value || '' === $value) { return ''; } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/ByHouseholdCompositionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/ByHouseholdCompositionAggregator.php index 03e5f17ce..80f0faa17 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/ByHouseholdCompositionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/ByHouseholdCompositionAggregator.php @@ -105,7 +105,7 @@ class ByHouseholdCompositionAggregator implements AggregatorInterface return 'export.aggregator.person.by_household_composition.Household composition'; } - if (null === $value) { + if (null === $value || '' === $value) { return ''; } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GenderAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GenderAggregator.php index 549992845..f76420047 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GenderAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GenderAggregator.php @@ -66,6 +66,7 @@ final class GenderAggregator implements AggregatorInterface return $this->translator->trans('unknown'); case null: + case '': return $this->translator->trans('Not given'); case '_header': diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php index ea516dbb0..107634803 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php @@ -101,7 +101,7 @@ final class HouseholdPositionAggregator implements AggregatorInterface, ExportEl return 'Household position'; } - if (null === $value) { + if (null === $value || '' === $value) { return $this->translator->trans('without data'); } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php index e20ecfb62..08bde4bda 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php @@ -63,6 +63,10 @@ final class MaritalStatusAggregator implements AggregatorInterface return 'Marital status'; } + if (null === $value || '' === $value) { + return ''; + } + $g = $this->maritalStatusRepository->find($value); return $this->translatableStringHelper->localize($g->getName()); diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php index 0a42fd928..c1fccb968 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php @@ -85,7 +85,7 @@ final class ActionTypeAggregator implements AggregatorInterface return 'Social Action Type'; } - if (null === $value || null === $sa = $this->socialActionRepository->find($value)) { + if (null === $value || '' === $value || null === $sa = $this->socialActionRepository->find($value)) { return ''; } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php index 41e0ad086..8cc6a25da 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php @@ -63,7 +63,7 @@ final class GoalAggregator implements AggregatorInterface return 'Goal Type'; } - if (null === $value) { + if (null === $value || '' === $value) { return ''; } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalResultAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalResultAggregator.php index e2934247a..17b263d7e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalResultAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalResultAggregator.php @@ -72,7 +72,7 @@ class GoalResultAggregator implements AggregatorInterface public function getLabels($key, array $values, $data) { return function ($value) use ($key): string { - if (null === $value) { + if (null === $value || '' === $value) { return ''; } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php index ea4184a8e..cbf07091f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php @@ -65,7 +65,7 @@ final class JobAggregator implements AggregatorInterface return 'Job'; } - if (null === $value) { + if (null === $value || '' === $value) { return ''; } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php index f8e2e5ca6..0fe53b707 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php @@ -65,7 +65,7 @@ final class ReferrerAggregator implements AggregatorInterface return 'Referrer'; } - if (null === $value) { + if (null === $value || '' === $value) { return ''; } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php index ecfa342d6..2e46673da 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php @@ -63,7 +63,7 @@ final class ResultAggregator implements AggregatorInterface return 'Result Type'; } - if (null === $value) { + if (null === $value || '' === $value) { return ''; } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php index 3ce36476d..243263b83 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php @@ -65,7 +65,7 @@ final class ScopeAggregator implements AggregatorInterface return 'Scope'; } - if (null === $value) { + if (null === $value || '' === $value) { return ''; } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php index d7625711c..5bbb22e53 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php @@ -70,11 +70,11 @@ class GeographicalUnitStatFilter implements FilterInterface LEFT JOIN acp_geog_filter_address.geographicalUnits acp_geog_filter_units WHERE (acp_geog_filter_location_history.startDate <= :acp_geog_filter_date AND ( - acp_geog_filter_location_history.endDate IS NULL OR acp_geog_filter_location_history.endDate < :acp_geog_filter_date + acp_geog_filter_location_history.endDate IS NULL OR acp_geog_filter_location_history.endDate > :acp_geog_filter_date )) AND (acp_geog_filter_address_person_location.validFrom < :acp_geog_filter_date AND ( - acp_geog_filter_address_person_location.validTo IS NULL OR acp_geog_filter_address_person_location.validTo < :acp_geog_filter_date + acp_geog_filter_address_person_location.validTo IS NULL OR acp_geog_filter_address_person_location.validTo > :acp_geog_filter_date )) AND acp_geog_filter_units IN (:acp_geog_filter_units) AND acp_geog_filter_location_history.period = acp.id diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php index 773325580..9bdb3f2d4 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php @@ -111,10 +111,10 @@ class GeographicalUnitFilter implements \Chill\MainBundle\Export\FilterInterface public function describeAction($data, $format = 'string') { return [ - 'exports.by_person.Filtered by person\'s geographical unit (based on address) computed at datecalc, only units', + 'export.filter.by_geog_unit.Filtered by person\'s geographical unit (based on address) computed at %datecalc%, only %units%', [ - 'datecalc' => $this->rollingDateConverter->convert($data['date_calc'])->format('Y-m-d'), - 'units' => implode( + '%datecalc%' => $this->rollingDateConverter->convert($data['date_calc'])->format('Y-m-d'), + '%units%' => implode( ', ', array_map( function (SimpleGeographicalUnitDTO $item) { diff --git a/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialIssueType.php b/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialIssueType.php index d8b9fdba9..0435b5573 100644 --- a/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialIssueType.php +++ b/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialIssueType.php @@ -36,12 +36,19 @@ class SocialIssueType extends AbstractType $builder ->add('title', TranslatableStringFormType::class, [ 'label' => 'Nom', - ]) - ->add('parent', EntityType::class, [ - 'class' => SocialIssue::class, - 'required' => false, - 'choice_label' => fn (SocialIssue $issue): ?string => $this->translatableStringHelper->localize($issue->getTitle()), - ]) + ]); + + if ('create' === $options['step']) { + $builder + ->add('parent', EntityType::class, [ + 'class' => SocialIssue::class, + 'required' => false, + 'choice_label' => fn (SocialIssue $issue): ?string => $this->translatableStringHelper->localize($issue->getTitle()), + 'mapped' => 'create' === $options['step'], + ]); + } + + $builder ->add('ordering', NumberType::class, [ 'required' => true, 'scale' => 6, @@ -55,5 +62,8 @@ class SocialIssueType extends AbstractType public function configureOptions(OptionsResolver $resolver) { $resolver->setDefault('class', SocialIssue::class); + + $resolver->setRequired('step') + ->setAllowedValues('step', ['create', 'edit']); } } diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php index 9e7938675..501af5b9d 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php @@ -144,7 +144,7 @@ class PickPersonType extends AbstractType }, $this->user->getGroupCenters()->toArray()); } else { $centers = $this->authorizationHelper - ->getReachableCenters($this->user, $options['role']); + ->getReachableCenters($this->user, $options['role']->getRole()); } if (null === $options['centers']) { diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php index 071f7b3eb..7de509f1f 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php @@ -326,7 +326,7 @@ final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodAC $or = $qb->expr()->orX(); foreach ($services as $key => $service) { - $or->add($qb->expr()->isMemberOf('ap.scopes', ':scope_' . $key)); + $or->add($qb->expr()->isMemberOf(':scope_' . $key, 'ap.scopes')); $qb->setParameter('scope_' . $key, $service); } $qb->andWhere($or); diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue index 42f974dd1..99e3519f4 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue @@ -164,7 +164,8 @@ export default { id: this.accompanyingCourse.id }, edit: false, - addressId: null + addressId: null, + defaults: window.addaddress } if (this.accompanyingCourse.location) { context['edit'] = true; diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue index e423838d1..66918ad71 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/FormEvaluation.vue @@ -360,7 +360,7 @@ export default { ; }, buildEditLink(storedObject) { - return `/wopi/edit/${storedObject.uuid}?returnPath=` + encodeURIComponent( + return `/chill/wopi/edit/${storedObject.uuid}?returnPath=` + encodeURIComponent( window.location.pathname + window.location.search + window.location.hash); }, submitBeforeGenerate({template}) { diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/index.js index c9f5bb111..d2b271e17 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/index.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/index.js @@ -2,6 +2,8 @@ import { createApp } from 'vue'; import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n'; import { appMessages } from './js/i18n'; import { store } from './store'; +import VueToast from 'vue-toast-notification'; +import 'vue-toast-notification/dist/theme-sugar.css'; import App from './App.vue'; @@ -12,5 +14,11 @@ const app = createApp({ }) .use(store) .use(i18n) +.use(VueToast, { + position: "bottom-right", + type: "error", + duration: 5000, + dismissible: true +}) .component('app', App) .mount('#household_members_editor'); diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/store/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/store/index.js index 63c2aba19..bfd684fce 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/store/index.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/store/index.js @@ -5,6 +5,7 @@ import { fetchHouseholdByAddressReference } from 'ChillPersonAssets/lib/househol import { datetimeToISO, dateToISO, ISOToDate } from 'ChillMainAssets/chill/js/date'; const debug = process.env.NODE_ENV !== 'production'; +//console.log('AJAJAJA', window.addaddress); const concerned = window.household_members_editor_data.persons.map(p => { return { @@ -115,6 +116,7 @@ const store = createStore({ name: state.household.type, id: state.household.id }, + defaults: window.addaddress, suggestions: state.addressesSuggestion }; } else { @@ -125,6 +127,7 @@ const store = createStore({ name: state.household.type, id: state.household.id }, + defaults: window.addaddress, }; } }, diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/OnTheFly.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/OnTheFly.js index 338094122..c9c77991f 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/OnTheFly.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/OnTheFly.js @@ -1,3 +1,5 @@ +import {makeFetch} from 'ChillMainAssets/lib/api/apiMethods'; + /* * GET a person by id */ @@ -22,6 +24,8 @@ const getCivilities = () => throw Error('Error with request resource response'); }); +const getCentersForPersonCreation = () => makeFetch('GET', '/api/1.0/person/creation/authorized-centers', null); + /* * POST a new person */ @@ -59,6 +63,7 @@ const patchPerson = (id, body) => { }; export { + getCentersForPersonCreation, getPerson, getPersonAltNames, getCivilities, diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue index 4f8909233..16a76c780 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue @@ -87,6 +87,18 @@ +
    + + +
    +
    {{ 'Label'|trans }}{{ 'Active'|trans }} 
    {{ entity.name }} + {% if entity.isActive %} + + {% else %} + + {% endif %} + +
      +
    • + +
    • +
    +