diff --git a/.gitignore b/.gitignore index 38d06d315..ebdc16e56 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ composer composer.phar composer.lock docs/build/ +node_modules/* .php_cs.cache ###> symfony/framework-bundle ### 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 e67e0f3c2..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); } @@ -473,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/Export/Filter/PersonFilters/ActivityReasonFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/ActivityReasonFilter.php index 5634358c7..c55d579e4 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/ActivityReasonFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/ActivityReasonFilter.php @@ -50,7 +50,7 @@ class ActivityReasonFilter implements ExportElementValidatedInterface, FilterInt { $where = $qb->getDQLPart('where'); $join = $qb->getDQLPart('join'); - $clause = $qb->expr()->in('reasons', ':selected_activity_reasons'); + $clause = $qb->expr()->in('actreasons', ':selected_activity_reasons'); if (!in_array('actreasons', $qb->getAllAliases(), true)) { $qb->join('activity.reasons', 'actreasons'); @@ -77,6 +77,7 @@ class ActivityReasonFilter implements ExportElementValidatedInterface, FilterInt 'class' => ActivityReason::class, 'choice_label' => fn (ActivityReason $reason) => $this->translatableStringHelper->localize($reason->getName()), 'group_by' => fn (ActivityReason $reason) => $this->translatableStringHelper->localize($reason->getCategory()->getName()), + 'attr' => ['class' => 'select2 '], 'multiple' => true, 'expanded' => false, ]); 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/Menu/AdminMenuBuilder.php b/src/Bundle/ChillActivityBundle/Menu/AdminMenuBuilder.php index 5e10c9a14..71a9e3c2a 100644 --- a/src/Bundle/ChillActivityBundle/Menu/AdminMenuBuilder.php +++ b/src/Bundle/ChillActivityBundle/Menu/AdminMenuBuilder.php @@ -36,7 +36,6 @@ final class AdminMenuBuilder implements LocalMenuBuilderInterface ->setAttribute('class', 'list-group-item-header') ->setExtras([ 'order' => 5000, - 'icons' => ['exchange'], ]); $menu->addChild('Activity Reasons', [ 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/views/Activity/show.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig index 49e71bfad..53bd3e8a7 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig @@ -156,7 +156,7 @@
- {{ entity.privateComment.comments[userId] }} + {{ entity.privateComment.comments[userId]|chill_markdown_to_html }}
@@ -172,7 +172,7 @@ {% endfor %} {% else %} - {{ 'Any document found'|trans }} + {{ 'No document found'|trans }} {% endif %} {% endif %} 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(form) }} - + diff --git a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/index.html.twig b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/index.html.twig index 4dd12e042..5ffc73684 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/index.html.twig +++ b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/index.html.twig @@ -87,5 +87,5 @@ {% endif %} - + {% endblock %} diff --git a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/new.html.twig b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/new.html.twig index 09acf9859..99ff217b1 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/new.html.twig +++ b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/new.html.twig @@ -1,4 +1,4 @@ -{% extends '@ChillMain/Admin/layout.html.twig' %} +{% extends '@ChillMain/layout.html.twig' %} {% block js %} {{ parent() }} @@ -14,7 +14,7 @@ {% include('@ChillMain/CRUD/_new_title.html.twig') %} {% endblock %} -{% block admin_content %} +{% block content %} {% embed '@ChillMain/CRUD/_new_content.html.twig' %} {% block content_form_actions_save_and_show %}{% endblock %} {% endembed %} diff --git a/src/Bundle/ChillAsideActivityBundle/src/translations/messages.fr.yml b/src/Bundle/ChillAsideActivityBundle/src/translations/messages.fr.yml index 35a4d6a22..2b4b6788a 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/translations/messages.fr.yml +++ b/src/Bundle/ChillAsideActivityBundle/src/translations/messages.fr.yml @@ -183,4 +183,5 @@ export: Group by aside activity type: Grouper les activités annexes par type d'activité Aside activity type: Type d'activité annexe - +# ROLES +CHILL_ASIDE_ACTIVITY_STATS: Statistiques pour les activités annexes diff --git a/src/Bundle/ChillBudgetBundle/Controller/Admin/AdminController.php b/src/Bundle/ChillBudgetBundle/Controller/Admin/AdminController.php new file mode 100644 index 000000000..998775fbe --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Controller/Admin/AdminController.php @@ -0,0 +1,26 @@ +render('@ChillBudget/Admin/index.html.twig'); + } +} diff --git a/src/Bundle/ChillBudgetBundle/Controller/Admin/ChargeKindController.php b/src/Bundle/ChillBudgetBundle/Controller/Admin/ChargeKindController.php new file mode 100644 index 000000000..e1989176d --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Controller/Admin/ChargeKindController.php @@ -0,0 +1,28 @@ +addOrderBy('e.ordering', 'ASC'); + + return $query; + } +} diff --git a/src/Bundle/ChillBudgetBundle/Controller/Admin/ResourceKindController.php b/src/Bundle/ChillBudgetBundle/Controller/Admin/ResourceKindController.php new file mode 100644 index 000000000..90b8e750a --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Controller/Admin/ResourceKindController.php @@ -0,0 +1,28 @@ +addOrderBy('e.ordering', 'ASC'); + + return $query; + } +} diff --git a/src/Bundle/ChillBudgetBundle/DependencyInjection/ChillBudgetExtension.php b/src/Bundle/ChillBudgetBundle/DependencyInjection/ChillBudgetExtension.php index b5cb3a9c1..ed7fd1ae9 100644 --- a/src/Bundle/ChillBudgetBundle/DependencyInjection/ChillBudgetExtension.php +++ b/src/Bundle/ChillBudgetBundle/DependencyInjection/ChillBudgetExtension.php @@ -11,6 +11,10 @@ declare(strict_types=1); namespace Chill\BudgetBundle\DependencyInjection; +use Chill\BudgetBundle\Controller\Admin\ChargeKindController; +use Chill\BudgetBundle\Controller\Admin\ResourceKindController; +use Chill\BudgetBundle\Entity\ChargeKind; +use Chill\BudgetBundle\Entity\ResourceKind; use Chill\BudgetBundle\Security\Authorization\BudgetElementVoter; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -33,6 +37,7 @@ class ChillBudgetExtension extends Extension implements PrependExtensionInterfac $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../config')); $loader->load('services/config.yaml'); $loader->load('services/form.yaml'); + $loader->load('services/repository.yaml'); $loader->load('services/security.yaml'); $loader->load('services/controller.yaml'); $loader->load('services/templating.yaml'); @@ -48,6 +53,7 @@ class ChillBudgetExtension extends Extension implements PrependExtensionInterfac { $this->prependAuthorization($container); $this->prependRoutes($container); + $this->prependCruds($container); } /** (non-PHPdoc). @@ -75,6 +81,56 @@ class ChillBudgetExtension extends Extension implements PrependExtensionInterfac ]); } + protected function prependCruds(ContainerBuilder $container) + { + $container->prependExtensionConfig('chill_main', [ + 'cruds' => [ + [ + 'class' => ChargeKind::class, + 'name' => 'charge_kind', + 'base_path' => '/admin/budget/charge-kind', + 'form_class' => \Chill\BudgetBundle\Form\Admin\ChargeKindType::class, + 'controller' => ChargeKindController::class, + 'actions' => [ + 'index' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillBudget/Admin/Charge/index.html.twig', + ], + 'new' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillBudget/Admin/Charge/new.html.twig', + ], + 'edit' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillBudget/Admin/Charge/edit.html.twig', + ], + ], + ], + [ + 'class' => ResourceKind::class, + 'name' => 'resource_kind', + 'base_path' => '/admin/budget/resource-kind', + 'form_class' => \Chill\BudgetBundle\Form\Admin\ResourceKindType::class, + 'controller' => ResourceKindController::class, + 'actions' => [ + 'index' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillBudget/Admin/Resource/index.html.twig', + ], + 'new' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillBudget/Admin/Resource/new.html.twig', + ], + 'edit' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillBudget/Admin/Resource/edit.html.twig', + ], + ], + ], + ], + ]); + } + protected function storeConfig($position, array $config, ContainerBuilder $container) { $container diff --git a/src/Bundle/ChillBudgetBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillBudgetBundle/DependencyInjection/Configuration.php index cf8f72a16..8856df22b 100644 --- a/src/Bundle/ChillBudgetBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillBudgetBundle/DependencyInjection/Configuration.php @@ -26,6 +26,7 @@ class Configuration implements ConfigurationInterface // ressources ->arrayNode('resources')->defaultValue([]) + ->setDeprecated('Chill', '2.0', 'Since the introduction of budget admin entities, config is no longer used') ->arrayPrototype() ->children() ->scalarNode('key')->isRequired()->cannotBeEmpty() @@ -49,6 +50,7 @@ class Configuration implements ConfigurationInterface ->end() ->end() ->arrayNode('charges')->defaultValue([]) + ->setDeprecated('Chill', '2.0', 'Since the introduction of budget admin entities, config is no longer used') ->arrayPrototype() ->children() ->scalarNode('key')->isRequired()->cannotBeEmpty() diff --git a/src/Bundle/ChillBudgetBundle/Entity/Charge.php b/src/Bundle/ChillBudgetBundle/Entity/Charge.php index eab153b2e..056e4abff 100644 --- a/src/Bundle/ChillBudgetBundle/Entity/Charge.php +++ b/src/Bundle/ChillBudgetBundle/Entity/Charge.php @@ -39,6 +39,12 @@ class Charge extends AbstractElement implements HasCentersInterface self::HELP_NOT_RELEVANT, ]; + /** + * @ORM\ManyToOne(targetEntity=ChargeKind::class, inversedBy="AbstractElement") + * @ORM\JoinColumn + */ + private ?ChargeKind $charge = null; + /** * @var string * @ORM\Column(name="help", type="string", nullable=true) @@ -66,6 +72,11 @@ class Charge extends AbstractElement implements HasCentersInterface return $this->getHousehold()->getCurrentPersons()->map(static fn (Person $p) => $p->getCenter())->toArray(); } + public function getCharge(): ?ChargeKind + { + return $this->charge; + } + public function getHelp() { return $this->help; @@ -91,6 +102,13 @@ class Charge extends AbstractElement implements HasCentersInterface return false; } + public function setCharge(?ChargeKind $charge): self + { + $this->charge = $charge; + + return $this; + } + public function setHelp($help) { $this->help = $help; diff --git a/src/Bundle/ChillBudgetBundle/Entity/ChargeKind.php b/src/Bundle/ChillBudgetBundle/Entity/ChargeKind.php new file mode 100644 index 000000000..d1393eafb --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Entity/ChargeKind.php @@ -0,0 +1,108 @@ +id; + } + + public function getIsActive(): bool + { + return $this->isActive; + } + + public function getKind(): ?string + { + return $this->kind; + } + + public function getName(): ?array + { + return $this->name; + } + + public function getOrdering(): float + { + return $this->ordering; + } + + public function setIsActive(bool $isActive): self + { + $this->isActive = $isActive; + + return $this; + } + + public function setKind(?string $kind): self + { + $this->kind = $kind; + + return $this; + } + + public function setName(array $name): self + { + $this->name = $name; + + return $this; + } + + public function setOrdering(float $ordering): ChargeKind + { + $this->ordering = $ordering; + + return $this; + } +} diff --git a/src/Bundle/ChillBudgetBundle/Entity/Resource.php b/src/Bundle/ChillBudgetBundle/Entity/Resource.php index bed9f23c3..28b8645e0 100644 --- a/src/Bundle/ChillBudgetBundle/Entity/Resource.php +++ b/src/Bundle/ChillBudgetBundle/Entity/Resource.php @@ -31,6 +31,12 @@ class Resource extends AbstractElement implements HasCentersInterface */ private ?int $id = null; + /** + * @ORM\ManyToOne(targetEntity=ResourceKind::class, inversedBy="AbstractElement") + * @ORM\JoinColumn + */ + private ?ResourceKind $resource = null; + public function __construct() { $this->setStartDate(new DateTimeImmutable('today')); @@ -55,6 +61,11 @@ class Resource extends AbstractElement implements HasCentersInterface return $this->id; } + public function getResource(): ?ResourceKind + { + return $this->resource; + } + public function isCharge(): bool { return false; @@ -64,4 +75,11 @@ class Resource extends AbstractElement implements HasCentersInterface { return true; } + + public function setResource(?ResourceKind $resource): self + { + $this->resource = $resource; + + return $this; + } } diff --git a/src/Bundle/ChillBudgetBundle/Entity/ResourceKind.php b/src/Bundle/ChillBudgetBundle/Entity/ResourceKind.php new file mode 100644 index 000000000..5d88af298 --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Entity/ResourceKind.php @@ -0,0 +1,108 @@ +id; + } + + public function getIsActive(): bool + { + return $this->isActive; + } + + public function getKind(): ?string + { + return $this->kind; + } + + public function getName(): ?array + { + return $this->name; + } + + public function getOrdering(): float + { + return $this->ordering; + } + + public function setIsActive(bool $isActive): self + { + $this->isActive = $isActive; + + return $this; + } + + public function setKind(?string $kind): self + { + $this->kind = $kind; + + return $this; + } + + public function setName(array $name): self + { + $this->name = $name; + + return $this; + } + + public function setOrdering(float $ordering): self + { + $this->ordering = $ordering; + + return $this; + } +} diff --git a/src/Bundle/ChillBudgetBundle/Form/Admin/ChargeKindType.php b/src/Bundle/ChillBudgetBundle/Form/Admin/ChargeKindType.php new file mode 100644 index 000000000..661199aec --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Form/Admin/ChargeKindType.php @@ -0,0 +1,42 @@ +add('name', TranslatableStringFormType::class, [ + 'label' => 'Nom', + ]) + ->add('ordering', NumberType::class) + ->add('isActive', CheckboxType::class, [ + 'label' => 'Actif ?', + 'required' => false, + ]); + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver + ->setDefault('class', ChargeKind::class); + } +} diff --git a/src/Bundle/ChillBudgetBundle/Form/Admin/ResourceKindType.php b/src/Bundle/ChillBudgetBundle/Form/Admin/ResourceKindType.php new file mode 100644 index 000000000..7b2622c5d --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Form/Admin/ResourceKindType.php @@ -0,0 +1,42 @@ +add('name', TranslatableStringFormType::class, [ + 'label' => 'Nom', + ]) + ->add('ordering', NumberType::class) + ->add('isActive', CheckboxType::class, [ + 'label' => 'Actif ?', + 'required' => false, + ]); + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver + ->setDefault('class', ResourceKind::class); + } +} diff --git a/src/Bundle/ChillBudgetBundle/Form/ChargeType.php b/src/Bundle/ChillBudgetBundle/Form/ChargeType.php index 387c1e424..3dc2e230c 100644 --- a/src/Bundle/ChillBudgetBundle/Form/ChargeType.php +++ b/src/Bundle/ChillBudgetBundle/Form/ChargeType.php @@ -13,15 +13,18 @@ namespace Chill\BudgetBundle\Form; use Chill\BudgetBundle\Config\ConfigRepository; use Chill\BudgetBundle\Entity\Charge; +use Chill\BudgetBundle\Entity\ChargeKind; +use Chill\BudgetBundle\Repository\ChargeKindRepository; use Chill\MainBundle\Form\Type\ChillDateType; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\MoneyType; use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; - +use Symfony\Contracts\Translation\TranslatorInterface; use function array_flip; use function asort; @@ -31,21 +34,35 @@ class ChargeType extends AbstractType protected TranslatableStringHelperInterface $translatableStringHelper; + private ChargeKindRepository $repository; + + private TranslatorInterface $translator; + public function __construct( ConfigRepository $configRepository, - TranslatableStringHelperInterface $translatableStringHelper + TranslatableStringHelperInterface $translatableStringHelper, + ChargeKindRepository $repository, + TranslatorInterface $translator ) { $this->configRepository = $configRepository; $this->translatableStringHelper = $translatableStringHelper; + $this->repository = $repository; + $this->translator = $translator; } public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('type', ChoiceType::class, [ - 'choices' => $this->getTypes(), - 'placeholder' => 'Choose a charge type', - 'attr' => ['class' => ' select2 '], + ->add('charge', EntityType::class, [ + 'class' => ChargeKind::class, + 'choices' => $this->repository->findAllActive(), + 'label' => 'Charge type', + 'required' => true, + 'placeholder' => $this->translator->trans('admin.form.Choose the type of charge'), + 'choice_label' => function (ChargeKind $resource) { + return $this->translatableStringHelper->localize($resource->getName()); + }, + 'attr' => ['class' => 'select2'], ]) ->add('amount', MoneyType::class) ->add('comment', TextareaType::class, [ diff --git a/src/Bundle/ChillBudgetBundle/Form/ResourceType.php b/src/Bundle/ChillBudgetBundle/Form/ResourceType.php index 6239dace8..106f50ad1 100644 --- a/src/Bundle/ChillBudgetBundle/Form/ResourceType.php +++ b/src/Bundle/ChillBudgetBundle/Form/ResourceType.php @@ -13,15 +13,17 @@ namespace Chill\BudgetBundle\Form; use Chill\BudgetBundle\Config\ConfigRepository; use Chill\BudgetBundle\Entity\Resource; +use Chill\BudgetBundle\Entity\ResourceKind; +use Chill\BudgetBundle\Repository\ResourceKindRepository; use Chill\MainBundle\Form\Type\ChillDateType; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\MoneyType; use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; - +use Symfony\Contracts\Translation\TranslatorInterface; use function array_flip; class ResourceType extends AbstractType @@ -30,22 +32,35 @@ class ResourceType extends AbstractType protected TranslatableStringHelperInterface $translatableStringHelper; + private ResourceKindRepository $repository; + + private TranslatorInterface $translator; + public function __construct( ConfigRepository $configRepository, - TranslatableStringHelperInterface $translatableStringHelper + TranslatableStringHelperInterface $translatableStringHelper, + ResourceKindRepository $repository, + TranslatorInterface $translator ) { $this->configRepository = $configRepository; $this->translatableStringHelper = $translatableStringHelper; + $this->repository = $repository; + $this->translator = $translator; } public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('type', ChoiceType::class, [ - 'choices' => $this->getTypes(), - 'placeholder' => 'Choose a resource type', - 'label' => 'Resource element type', - 'attr' => ['class' => ' select2 '], + ->add('resource', EntityType::class, [ + 'class' => ResourceKind::class, + 'choices' => $this->repository->findAllActive(), + 'label' => 'Resource type', + 'required' => true, + 'placeholder' => $this->translator->trans('admin.form.Choose the type of resource'), + 'choice_label' => function (ResourceKind $resource) { + return $this->translatableStringHelper->localize($resource->getName()); + }, + 'attr' => ['class' => 'select2'], ]) ->add('amount', MoneyType::class) ->add('comment', TextareaType::class, [ diff --git a/src/Bundle/ChillBudgetBundle/Menu/AdminMenuBuilder.php b/src/Bundle/ChillBudgetBundle/Menu/AdminMenuBuilder.php new file mode 100644 index 000000000..894230ad9 --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Menu/AdminMenuBuilder.php @@ -0,0 +1,62 @@ +security = $security; + } + + public function buildMenu($menuId, MenuItem $menu, array $parameters) + { + // all the entries below must have ROLE_ADMIN permissions + if (!$this->security->isGranted('ROLE_ADMIN')) { + return; + } + + $menu->addChild('Budget', [ + 'route' => 'chill_admin_budget', + ]) + ->setAttribute('class', 'list-group-item-header') + ->setExtras([ + 'order' => 7050, + 'explain' => 'Budget resource and charge type configuration', + ]); + $menu + ->addChild('admin.menu.Resource types', [ + 'route' => 'chill_crud_resource_kind_index', + ]) + ->setExtras([ + 'order' => 7060, + ]); + $menu + ->addChild('admin.menu.Charge types', [ + 'route' => 'chill_crud_charge_kind_index', + ]) + ->setExtras([ + 'order' => 7070, + ]); + } + + public static function getMenuIds(): array + { + return ['admin_section', 'admin_budget']; + } +} diff --git a/src/Bundle/ChillBudgetBundle/Repository/ChargeKindRepository.php b/src/Bundle/ChillBudgetBundle/Repository/ChargeKindRepository.php new file mode 100644 index 000000000..e170a362a --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Repository/ChargeKindRepository.php @@ -0,0 +1,84 @@ +repository = $entityManager->getRepository(ChargeKind::class); + } + + public function find($id): ?ChargeKind + { + return $this->repository->find($id); + } + + /** + * @return ChargeType[] + */ + public function findAll(): array + { + return $this->repository->findAll(); + } + + /** + * @return ChargeType[] + */ + public function findAllActive(): array + { + $qb = $this->repository->createQueryBuilder('c'); + + return $qb + ->select('c') + ->where($qb->expr()->eq('c.isActive', 'true')) + ->orderBy('c.ordering', 'ASC') + ->getQuery() + ->getResult(); + } + + /** + * @return ChargeType[] + */ + public function findAllByType(string $type): array + { + return $this->findBy(['elementType' => $type]); + } + + /** + * @param mixed|null $limit + * @param mixed|null $offset + * + * @return ChargeType[] + */ + public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array + { + return $this->repository->findBy($criteria, $orderBy, $limit, $offset); + } + + public function findOneBy(array $criteria): ?ChargeKind + { + return $this->repository->findOneBy($criteria); + } + + public function getClassName(): string + { + return ChargeKind::class; + } +} diff --git a/src/Bundle/ChillBudgetBundle/Repository/ResourceKindRepository.php b/src/Bundle/ChillBudgetBundle/Repository/ResourceKindRepository.php new file mode 100644 index 000000000..03af9e083 --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Repository/ResourceKindRepository.php @@ -0,0 +1,84 @@ +repository = $entityManager->getRepository(ResourceKind::class); + } + + public function find($id): ?ResourceKind + { + return $this->repository->find($id); + } + + /** + * @return ResourceType[] + */ + public function findAll(): array + { + return $this->repository->findAll(); + } + + /** + * @return ResourceType[] + */ + public function findAllActive(): array + { + $qb = $this->repository->createQueryBuilder('r'); + + return $qb + ->select('r') + ->where($qb->expr()->eq('r.isActive', 'true')) + ->orderBy('r.ordering', 'ASC') + ->getQuery() + ->getResult(); + } + + /** + * @return ResourceType[] + */ + public function findAllByType(string $type): array + { + return $this->findBy(['elementType' => $type]); + } + + /** + * @param mixed|null $limit + * @param mixed|null $offset + * + * @return ResourceType[] + */ + public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array + { + return $this->repository->findBy($criteria, $orderBy, $limit, $offset); + } + + public function findOneBy(array $criteria): ?ResourceKind + { + return $this->repository->findOneBy($criteria); + } + + public function getClassName(): string + { + return ResourceKind::class; + } +} diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Charge/edit.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Charge/edit.html.twig new file mode 100644 index 000000000..3a60d3e9c --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Charge/edit.html.twig @@ -0,0 +1,12 @@ +{% 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_view %}{% endblock %} + {% block content_form_actions_save_and_show %}{% endblock %} + {% endembed %} +{% endblock %} diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Charge/index.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Charge/index.html.twig new file mode 100644 index 000000000..2486aaecf --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Charge/index.html.twig @@ -0,0 +1,49 @@ +{% extends '@ChillMain/Admin/layoutWithVerticalMenu.html.twig' %} + +{% block title %}{{ 'admin.title.Charge Type List'|trans }}{% endblock title %} + +{% block admin_content %} + +

{{ 'admin.title.Charge Type List'|trans }}

+ + + + + + + + + + + + {% for entity in entities %} + + + + + + + {% endfor %} + +
{{ 'Ordering'|trans }}{{ 'Name'|trans }}{{ 'Active'|trans }} 
{{ entity.ordering }}{{ entity|chill_entity_render_box }} + {%- if entity.isActive -%} + + {%- else -%} + + {%- endif -%} + +
    +
  • + +
  • +
+
+ + +{% endblock %} diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Charge/new.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Charge/new.html.twig new file mode 100644 index 000000000..00ebd2938 --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Charge/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 %} diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Resource/edit.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Resource/edit.html.twig new file mode 100644 index 000000000..3a60d3e9c --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Resource/edit.html.twig @@ -0,0 +1,12 @@ +{% 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_view %}{% endblock %} + {% block content_form_actions_save_and_show %}{% endblock %} + {% endembed %} +{% endblock %} diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Resource/index.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Resource/index.html.twig new file mode 100644 index 000000000..35bf88609 --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Resource/index.html.twig @@ -0,0 +1,49 @@ +{% extends '@ChillMain/Admin/layoutWithVerticalMenu.html.twig' %} + +{% block title %}{{ 'admin.title.Resource Type List'|trans }}{% endblock title %} + +{% block admin_content %} + +

{{ 'admin.title.Resource Type List'|trans }}

+ + + + + + + + + + + + {% for entity in entities %} + + + + + + + {% endfor %} + +
{{ 'Ordering'|trans }}{{ 'Name'|trans }}{{ 'Active'|trans }} 
{{ entity.ordering }}{{ entity|chill_entity_render_box }} + {%- if entity.isActive -%} + + {%- else -%} + + {%- endif -%} + +
    +
  • + +
  • +
+
+ + +{% endblock %} diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Resource/new.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Resource/new.html.twig new file mode 100644 index 000000000..00ebd2938 --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Admin/Resource/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 %} diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Admin/index.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Admin/index.html.twig new file mode 100644 index 000000000..0e3beca04 --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Admin/index.html.twig @@ -0,0 +1,14 @@ +{% extends "@ChillMain/Admin/layoutWithVerticalMenu.html.twig" %} + +{% block vertical_menu_content %} + {{ chill_menu('admin_budget', { + 'layout': '@ChillMain/Admin/menu_admin_section.html.twig', + }) }} +{% endblock %} + +{% block layout_wvm_content %} + {% block admin_content %} + +

{{ 'admin.title.Budget configuration'|trans }}

+ {% endblock %} +{% endblock %} diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_macros.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_macros.html.twig index 41b6f36df..e8d10578b 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_macros.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Budget/_macros.html.twig @@ -16,7 +16,11 @@ - {{ f.type|budget_element_type_display(family) }} + {% if f.isResource %} + {{ f.resource.name|localize_translatable_string }} + {% else %} + {{ f.charge.name|localize_translatable_string }} + {% endif %} {{ f.amount|format_currency('EUR') }} diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Charge/confirm_delete.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Charge/confirm_delete.html.twig index f64184d6f..7a97731da 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Charge/confirm_delete.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Charge/confirm_delete.html.twig @@ -3,13 +3,13 @@ {% set indexPage = 'chill_budget_elements_index' %} {% set activeRouteKey = '' %} {% set person = element.person %} - {% set confirm_question = 'Are you sure you want to remove the charge "%type%" associated to "%name%" ?'|trans({ '%name%' : person.firstname ~ ' ' ~ person.lastname, '%type%': element.type|budget_element_type_display('charge') } ) %} + {% set confirm_question = 'Are you sure you want to remove the charge "%type%" associated to "%name%" ?'|trans({ '%name%' : person.firstname ~ ' ' ~ person.lastname, '%type%': element.charge.getName | localize_translatable_string } ) %} {% else %} {% set template = '@ChillPerson/Household/layout.html.twig' %} {% set indexPage = 'chill_budget_elements_household_index' %} {% set activeRouteKey = '' %} {% set household = element.household %} - {% set confirm_question = 'Are you sure you want to remove the charge "%type%" associated to household "%household%" ?'|trans({ '%household%' : household.id, '%type%': element.type|budget_element_type_display('charge') } ) %} + {% set confirm_question = 'Are you sure you want to remove the charge "%type%" associated to household "%household%" ?'|trans({ '%household%' : household.id, '%type%': element.charge.getName | localize_translatable_string } ) %} {% endif %} {% extends template %} diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Charge/edit.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Charge/edit.html.twig index fed80a5c0..ab68314d6 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Charge/edit.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Charge/edit.html.twig @@ -21,7 +21,7 @@ {{ form_start(form) }} -{{ form_row(form.type) }} +{{ form_row(form.charge) }} {{ form_row(form.amount) }} {{ form_row(form.help) }} {{ form_row(form.comment) }} diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Charge/new.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Charge/new.html.twig index 817d501ca..bdd7334bb 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Charge/new.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Charge/new.html.twig @@ -20,7 +20,7 @@ {{ form_start(form) }} -{{ form_row(form.type) }} +{{ form_row(form.charge) }} {{ form_row(form.amount) }} {{ form_row(form.help) }} {{ form_row(form.comment) }} diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Charge/view.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Charge/view.html.twig index d3b9ef71b..509c421b0 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Charge/view.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Charge/view.html.twig @@ -25,7 +25,7 @@

- {{ element.type|budget_element_type_display('charge') }} + {{ element.charge.getName | localize_translatable_string }}

diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Entity/budget_element_type.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Entity/budget_element_type.html.twig new file mode 100644 index 000000000..f2187a8b8 --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Entity/budget_element_type.html.twig @@ -0,0 +1 @@ +{{ entity.name|localize_translatable_string }} \ No newline at end of file diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Resource/confirm_delete.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Resource/confirm_delete.html.twig index 73ae173ff..f60c3b6de 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Resource/confirm_delete.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Resource/confirm_delete.html.twig @@ -3,13 +3,13 @@ {% set indexPage = 'chill_budget_elements_index' %} {% set activeRouteKey = '' %} {% set person = element.person %} - {% set confirm_question = 'Are you sure you want to remove the ressource "%type%" associated to "%name%" ?'|trans({ '%name%' : person.firstname ~ ' ' ~ person.lastname, '%type%': element.type|budget_element_type_display('resource') } ) %} + {% set confirm_question = 'Are you sure you want to remove the ressource "%type%" associated to "%name%" ?'|trans({ '%name%' : person.firstname ~ ' ' ~ person.lastname, '%type%': element.resource.getName | localize_translatable_string } ) %} {% else %} {% set template = '@ChillPerson/Household/layout.html.twig' %} {% set indexPage = 'chill_budget_elements_household_index' %} {% set activeRouteKey = '' %} {% set household = element.household %} - {% set confirm_question = 'Are you sure you want to remove the ressource "%type%" associated to household "%household%" ?'|trans({ '%household%' : household.id, '%type%': element.type|budget_element_type_display('resource') } ) %} + {% set confirm_question = 'Are you sure you want to remove the ressource "%type%" associated to household "%household%" ?'|trans({ '%household%' : household.id, '%type%': element.resource.getName | localize_translatable_string} ) %} {% endif %} {% extends template %} diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Resource/edit.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Resource/edit.html.twig index 8b051eeaf..85cf7e8e4 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Resource/edit.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Resource/edit.html.twig @@ -23,7 +23,7 @@ {{ form_start(form) }} -{{ form_row(form.type) }} +{{ form_row(form.resource) }} {{ form_row(form.amount) }} {{ form_row(form.comment) }} {{ form_row(form.startDate) }} diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Resource/new.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Resource/new.html.twig index 4ea71f4de..5c1b63d12 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Resource/new.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Resource/new.html.twig @@ -22,8 +22,7 @@

{{ title }}

{{ form_start(form) }} - -{{ form_row(form.type) }} +{{ form_row(form.resource) }} {{ form_row(form.amount) }} {{ form_row(form.comment) }} {{ form_row(form.startDate) }} diff --git a/src/Bundle/ChillBudgetBundle/Resources/views/Resource/view.html.twig b/src/Bundle/ChillBudgetBundle/Resources/views/Resource/view.html.twig index 110aed9fe..c3618b498 100644 --- a/src/Bundle/ChillBudgetBundle/Resources/views/Resource/view.html.twig +++ b/src/Bundle/ChillBudgetBundle/Resources/views/Resource/view.html.twig @@ -25,7 +25,7 @@

- {{ element.type|budget_element_type_display('resource') }} + {{ element.resource.getName | localize_translatable_string }}

diff --git a/src/Bundle/ChillBudgetBundle/Templating/BudgetElementTypeRender.php b/src/Bundle/ChillBudgetBundle/Templating/BudgetElementTypeRender.php new file mode 100644 index 000000000..9cc89e2bf --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/Templating/BudgetElementTypeRender.php @@ -0,0 +1,55 @@ +translatableStringHelper = $translatableStringHelper; + $this->engine = $engine; + } + + public function renderBox($entity, array $options): string + { + return $this->engine->render('@ChillBudget/Entity/budget_element_type.html.twig', [ + 'entity' => $entity, + 'options' => $options, + ]); + } + + public function renderString($entity, array $options): string + { + $title = ''; + + if (null !== $entity->getName()) { + return $this->translatableStringHelper->localize($entity->getName()); + } + + return $title; + } + + public function supports($entity, array $options): bool + { + return $entity instanceof ChargeKind || $entity instanceof ResourceKind; + } +} diff --git a/src/Bundle/ChillBudgetBundle/config/services/controller.yaml b/src/Bundle/ChillBudgetBundle/config/services/controller.yaml index 82c683536..ae6fb84d6 100644 --- a/src/Bundle/ChillBudgetBundle/config/services/controller.yaml +++ b/src/Bundle/ChillBudgetBundle/config/services/controller.yaml @@ -3,3 +3,7 @@ services: autowire: true resource: '../../Controller' tags: ['controller.service_arguments'] + Chill\BudgetBundle\Controller\Admin\: + autowire: true + autoconfigure: true + resource: '../../Controller/Admin' diff --git a/src/Bundle/ChillBudgetBundle/config/services/form.yaml b/src/Bundle/ChillBudgetBundle/config/services/form.yaml index 63862ce94..a033413d0 100644 --- a/src/Bundle/ChillBudgetBundle/config/services/form.yaml +++ b/src/Bundle/ChillBudgetBundle/config/services/form.yaml @@ -1,14 +1,9 @@ services: - Chill\BudgetBundle\Form\ResourceType: - arguments: - $configRepository: '@Chill\BudgetBundle\Config\ConfigRepository' - $translatableStringHelper: '@Chill\MainBundle\Templating\TranslatableStringHelper' - tags: - - { name: 'form.type' } - - Chill\BudgetBundle\Form\ChargeType: - arguments: - $configRepository: '@Chill\BudgetBundle\Config\ConfigRepository' - $translatableStringHelper: '@Chill\MainBundle\Templating\TranslatableStringHelper' + Chill\BudgetBundle\Form\: + autowire: true + resource: '../../Form' tags: - { name: 'form.type' } +# Chill\BudgetBundle\Form\Admin\: +# autowire: true +# resource: '../../Form/Admin' diff --git a/src/Bundle/ChillBudgetBundle/config/services/menu.yaml b/src/Bundle/ChillBudgetBundle/config/services/menu.yaml index 34128519b..ba8b301d5 100644 --- a/src/Bundle/ChillBudgetBundle/config/services/menu.yaml +++ b/src/Bundle/ChillBudgetBundle/config/services/menu.yaml @@ -1,8 +1,5 @@ services: - Chill\BudgetBundle\Menu\PersonMenuBuilder: - autowire: true - autoconfigure: true - - Chill\BudgetBundle\Menu\HouseholdMenuBuilder: + Chill\BudgetBundle\Menu\: autowire: true autoconfigure: true + resource: './../../Menu' diff --git a/src/Bundle/ChillBudgetBundle/config/services/repository.yaml b/src/Bundle/ChillBudgetBundle/config/services/repository.yaml new file mode 100644 index 000000000..7205a8378 --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/config/services/repository.yaml @@ -0,0 +1,5 @@ +services: + Chill\BudgetBundle\Repository\: + autowire: true + autoconfigure: true + resource: './../../Repository' \ No newline at end of file diff --git a/src/Bundle/ChillBudgetBundle/config/services/templating.yaml b/src/Bundle/ChillBudgetBundle/config/services/templating.yaml index 903db5d67..2646f3892 100644 --- a/src/Bundle/ChillBudgetBundle/config/services/templating.yaml +++ b/src/Bundle/ChillBudgetBundle/config/services/templating.yaml @@ -1,7 +1,5 @@ services: - Chill\BudgetBundle\Templating\Twig: - arguments: - $configRepository: '@Chill\BudgetBundle\Config\ConfigRepository' - $translatableStringHelper: '@Chill\MainBundle\Templating\TranslatableStringHelper' - tags: - - { name: 'twig.extension' } \ No newline at end of file + Chill\BudgetBundle\Templating\: + autowire: true + autoconfigure: true + resource: '../../Templating' diff --git a/src/Bundle/ChillBudgetBundle/migrations/Version20221116163445.php b/src/Bundle/ChillBudgetBundle/migrations/Version20221116163445.php new file mode 100644 index 000000000..118b7c30d --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/migrations/Version20221116163445.php @@ -0,0 +1,39 @@ +addSql('DROP SEQUENCE chill_budget.charge_type_id_seq CASCADE'); + $this->addSql('DROP SEQUENCE chill_budget.resource_type_id_seq CASCADE'); + $this->addSql('DROP TABLE chill_budget.charge_type'); + $this->addSql('DROP TABLE chill_budget.resource_type'); + } + + public function getDescription(): string + { + return 'Create resource type and charge type'; + } + + public function up(Schema $schema): void + { + $this->addSql('CREATE SEQUENCE chill_budget.charge_type_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE SEQUENCE chill_budget.resource_type_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE TABLE chill_budget.charge_type (id INT NOT NULL, isActive BOOLEAN DEFAULT TRUE NOT NULL, name JSONB DEFAULT \'{}\'::jsonb NOT NULL, ordering DOUBLE PRECISION DEFAULT \'0\' NOT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE TABLE chill_budget.resource_type (id INT NOT NULL, isActive BOOLEAN DEFAULT TRUE NOT NULL, name JSONB DEFAULT \'{}\'::jsonb NOT NULL, ordering DOUBLE PRECISION DEFAULT \'0\' NOT NULL, PRIMARY KEY(id))'); + } +} diff --git a/src/Bundle/ChillBudgetBundle/migrations/Version20221130101659.php b/src/Bundle/ChillBudgetBundle/migrations/Version20221130101659.php new file mode 100644 index 000000000..98d67b341 --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/migrations/Version20221130101659.php @@ -0,0 +1,41 @@ +addSql('ALTER TABLE chill_budget.resource_type DROP kind'); + $this->addSql('ALTER TABLE chill_budget.resource_type DROP tags'); + $this->addSql('ALTER TABLE chill_budget.charge_type DROP kind'); + $this->addSql('ALTER TABLE chill_budget.charge_type DROP tags'); + } + + public function getDescription(): string + { + return 'Add kind and tags property to charge and resource types'; + } + + public function up(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_budget.charge_type ADD kind VARCHAR(255) DEFAULT \'\' NOT NULL'); + $this->addSql('ALTER TABLE chill_budget.charge_type ADD tags JSONB DEFAULT \'{}\'::jsonb NOT NULL'); + $this->addSql('COMMENT ON COLUMN chill_budget.charge_type.tags IS \'(DC2Type:jsonb)\''); + $this->addSql('ALTER TABLE chill_budget.resource_type ADD kind VARCHAR(255) DEFAULT \'\' NOT NULL'); + $this->addSql('ALTER TABLE chill_budget.resource_type ADD tags JSONB DEFAULT \'{}\'::jsonb NOT NULL'); + $this->addSql('COMMENT ON COLUMN chill_budget.resource_type.tags IS \'(DC2Type:jsonb)\''); + } +} diff --git a/src/Bundle/ChillBudgetBundle/migrations/Version20221202165608.php b/src/Bundle/ChillBudgetBundle/migrations/Version20221202165608.php new file mode 100644 index 000000000..c2152100b --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/migrations/Version20221202165608.php @@ -0,0 +1,41 @@ +addSql('ALTER TABLE chill_budget.charge DROP CONSTRAINT FK_5C99D2C355284914'); + $this->addSql('ALTER TABLE chill_budget.charge DROP charge_id'); + $this->addSql('ALTER TABLE chill_budget.resource DROP CONSTRAINT FK_5E0A5E9789329D25'); + $this->addSql('ALTER TABLE chill_budget.resource DROP resource_id'); + } + + public function getDescription(): string + { + return 'Integrate budget admin entity'; + } + + public function up(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_budget.charge ADD charge_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_budget.charge ADD CONSTRAINT FK_5C99D2C355284914 FOREIGN KEY (charge_id) REFERENCES chill_budget.charge_type (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE INDEX IDX_5C99D2C355284914 ON chill_budget.charge (charge_id)'); + $this->addSql('ALTER TABLE chill_budget.resource ADD resource_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_budget.resource ADD CONSTRAINT FK_5E0A5E9789329D25 FOREIGN KEY (resource_id) REFERENCES chill_budget.resource_type (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE INDEX IDX_5E0A5E9789329D25 ON chill_budget.resource (resource_id)'); + } +} diff --git a/src/Bundle/ChillBudgetBundle/migrations/Version20221207105407.php b/src/Bundle/ChillBudgetBundle/migrations/Version20221207105407.php new file mode 100644 index 000000000..cfe3a0089 --- /dev/null +++ b/src/Bundle/ChillBudgetBundle/migrations/Version20221207105407.php @@ -0,0 +1,81 @@ +addSql('DELETE FROM chill_budget.resource_type;'); + $this->addSql('DELETE FROM chill_budget.charge_type;'); + } + + public function getDescription(): string + { + return 'Use new budget admin entities'; + } + + public function setContainer(?ContainerInterface $container = null) + { + $this->container = $container; + } + + public function up(Schema $schema): void + { + $resources = $this->container->getParameter('chill_budget.resources'); + $charges = $this->container->getParameter('chill_budget.charges'); + + foreach ($resources as $value) { + $lang = $value['labels'][0]['lang']; + $label = $value['labels'][0]['label']; + $kind = $value['key']; + $this->addSql( + 'INSERT INTO chill_budget.resource_type (id, isActive, name, ordering, kind) VALUES ( + nextval(\'chill_budget.resource_type_id_seq\'), true, jsonb_build_object(:lang::text, :label::text), 0, :kind::text)', + ['lang' => $lang, 'label' => $label, 'kind' => $kind], + ['lang' => Types::STRING, 'label' => Types::STRING, 'kind' => Types::STRING] + ); + $this->addSql( + 'UPDATE chill_budget.resource SET resource_id = resource_type.id + FROM chill_budget.resource_type WHERE resource.type = :kind AND resource_type.kind = resource.type;', + ['kind' => $kind], + ['kind' => Types::STRING] + ); + } + + foreach ($charges as $value) { + $lang = $value['labels'][0]['lang']; + $label = $value['labels'][0]['label']; + $kind = $value['key']; + $this->addSql( + 'INSERT INTO chill_budget.charge_type VALUES (nextval(\'chill_budget.charge_type_id_seq\'), true, + jsonb_build_object(:lang::text, :label::text), 0, :kind::text);', + ['lang' => $lang, 'label' => $label, 'kind' => $kind], + ['lang' => Types::STRING, 'label' => Types::STRING, 'kind' => Types::STRING] + ); + $this->addSql( + 'UPDATE chill_budget.charge SET charge_id = charge_type.id + FROM chill_budget.charge_type WHERE charge.type = :kind AND charge_type.kind = charge.type;', + ['kind' => $kind], + ['kind' => Types::STRING] + ); + } + } +} diff --git a/src/Bundle/ChillBudgetBundle/translations/messages.fr.yml b/src/Bundle/ChillBudgetBundle/translations/messages.fr.yml index 299fa295e..8337dff87 100644 --- a/src/Bundle/ChillBudgetBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillBudgetBundle/translations/messages.fr.yml @@ -58,6 +58,8 @@ Charge updated: charge mise à jour Choose a resource type: Choisissez un type de ressource Choose a charge type: Choisissez un type de charge +Resource type: Type de ressource +Charge type: Type de charge Amount: Montant Comment: Commentaire @@ -74,3 +76,35 @@ The balance: Différence entre ressources et charges Valid since %startDate% until %endDate%: Valide depuis le %startDate% jusqu'au %endDate% Valid since %startDate%: Valide depuis le %startDate% + +# ROLES +Budget elements: Budget +CHILL_BUDGET_ELEMENT_CREATE: Créer une ressource/charge +CHILL_BUDGET_ELEMENT_DELETE: Supprimer une ressource/charge +CHILL_BUDGET_ELEMENT_SEE: Voir les ressources/charges +CHILL_BUDGET_ELEMENT_UPDATE: Modifier une ressource/charge + +## admin + +crud: + resource_kind: + title_new: Nouveau type de ressource + title_edit: Modifier le type de ressource + charge_kind: + title_new: Nouveau type de charge + title_edit: Modifier le type de charge + +admin: + menu: + Resource types: Types de ressource + Charge types: Types de charge + title: + Charge Type List: Liste des types de charge + Resource Type List: Liste des types de ressource + Budget configuration: Configuration des éléments de budget + new: + Create a new charge type: Créér un nouveau type de charge + Create a new resource type: Créér un nouveau type de ressource + form: + Choose the type of resource: Choisissez une type de ressource + Choose the type of charge: Choisissez une type de charge diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php index db5f2ec16..550c6e984 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php @@ -45,6 +45,7 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Serializer\SerializerInterface; +use Symfony\Contracts\Translation\TranslatorInterface; class CalendarController extends AbstractController { @@ -68,6 +69,8 @@ class CalendarController extends AbstractController private TranslatableStringHelperInterface $translatableStringHelper; + private TranslatorInterface $translator; + private UserRepositoryInterface $userRepository; public function __construct( @@ -81,7 +84,8 @@ class CalendarController extends AbstractController TranslatableStringHelperInterface $translatableStringHelper, PersonRepository $personRepository, AccompanyingPeriodRepository $accompanyingPeriodRepository, - UserRepositoryInterface $userRepository + UserRepositoryInterface $userRepository, + TranslatorInterface $translator ) { $this->calendarACLAwareRepository = $calendarACLAwareRepository; $this->docGeneratorTemplateRepository = $docGeneratorTemplateRepository; @@ -94,6 +98,7 @@ class CalendarController extends AbstractController $this->personRepository = $personRepository; $this->accompanyingPeriodRepository = $accompanyingPeriodRepository; $this->userRepository = $userRepository; + $this->translator = $translator; } /** @@ -131,7 +136,7 @@ class CalendarController extends AbstractController $em->remove($entity); $em->flush(); - $this->addFlash('success', $this->get('translator') + $this->addFlash('success', $this->translator ->trans('The calendar item has been successfully removed.')); return new RedirectResponse($redirectRoute); @@ -190,7 +195,7 @@ class CalendarController extends AbstractController if ($form->isSubmitted() && $form->isValid()) { $em->flush(); - $this->addFlash('success', $this->get('translator')->trans('Success : calendar item updated!')); + $this->addFlash('success', $this->translator->trans('Success : calendar item updated!')); if ($form->get('save_and_upload_doc')->isClicked()) { return $this->redirectToRoute('chill_calendar_calendardoc_new', ['id' => $entity->getId()]); @@ -210,7 +215,7 @@ class CalendarController extends AbstractController } if ($form->isSubmitted() && !$form->isValid()) { - $this->addFlash('error', $this->get('translator')->trans('This form contains errors')); + $this->addFlash('error', $this->translator->trans('This form contains errors')); } $entity_array = $this->serializer->normalize($entity, 'json', ['groups' => 'read']); @@ -369,7 +374,7 @@ class CalendarController extends AbstractController $em->persist($entity); $em->flush(); - $this->addFlash('success', $this->get('translator')->trans('Success : calendar item created!')); + $this->addFlash('success', $this->translator->trans('Success : calendar item created!')); if ($form->get('save_and_upload_doc')->isClicked()) { return $this->redirectToRoute('chill_calendar_calendardoc_new', ['id' => $entity->getId()]); @@ -393,7 +398,7 @@ class CalendarController extends AbstractController } if ($form->isSubmitted() && !$form->isValid()) { - $this->addFlash('error', $this->get('translator')->trans('This form contains errors')); + $this->addFlash('error', $this->translator->trans('This form contains errors')); } if (null === $view) { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php index 9b0ad9057..e1de9f399 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php @@ -66,6 +66,10 @@ final class AgentAggregator implements AggregatorInterface return 'Agent'; } + if (null === $value || '' === $value) { + return ''; + } + $r = $this->userRepository->find($value); return $this->userRender->renderString($r, []); diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php index 329e2e50e..611cb6d79 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php @@ -67,6 +67,10 @@ class CancelReasonAggregator implements AggregatorInterface return 'Cancel reason'; } + if (null === $value || '' === $value) { + return ''; + } + $j = $this->cancelReasonRepository->find($value); return $this->translatableStringHelper->localize( diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php index 2a6f3b63e..23292a5b0 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php @@ -66,6 +66,10 @@ final class JobAggregator implements AggregatorInterface return 'Job'; } + if (null === $value || '' === $value) { + return ''; + } + $j = $this->jobRepository->find($value); return $this->translatableStringHelper->localize( diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php index 687dc9096..940000f47 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php @@ -60,6 +60,10 @@ final class LocationAggregator implements AggregatorInterface return 'Location'; } + if (null === $value || '' === $value) { + return ''; + } + $l = $this->locationRepository->find($value); return $l->getName(); diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php index b23b304f6..6574e3934 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php @@ -66,7 +66,13 @@ final class LocationTypeAggregator implements AggregatorInterface return 'Location type'; } - $j = $this->locationTypeRepository->find($value); + if (null === $value || '' === $value) { + return ''; + } + + if (null === $j = $this->locationTypeRepository->find($value)) { + return ''; + } return $this->translatableStringHelper->localize( $j->getTitle() diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php index b16b06d84..3aff3e0d8 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php @@ -66,6 +66,10 @@ final class ScopeAggregator implements AggregatorInterface return 'Scope'; } + if (null === $value || '' === $value) { + return ''; + } + $s = $this->scopeRepository->find($value); return $this->translatableStringHelper->localize( diff --git a/src/Bundle/ChillCalendarBundle/Menu/AdminMenuBuilder.php b/src/Bundle/ChillCalendarBundle/Menu/AdminMenuBuilder.php index ad00609e2..1658029a7 100644 --- a/src/Bundle/ChillCalendarBundle/Menu/AdminMenuBuilder.php +++ b/src/Bundle/ChillCalendarBundle/Menu/AdminMenuBuilder.php @@ -39,7 +39,6 @@ class AdminMenuBuilder implements LocalMenuBuilderInterface ->setAttribute('class', 'list-group-item-header') ->setExtras([ 'order' => 6000, - 'icons' => ['calendar'], ]); $menu->addChild('Cancel reason', [ diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_documents.twig.html b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_documents.twig.html index a568ec009..499fb0a83 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_documents.twig.html +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_documents.twig.html @@ -3,7 +3,7 @@ {% import "@ChillDocStore/Macro/macro.html.twig" as m %} {% import "@ChillDocStore/Macro/macro_mimeicon.html.twig" as mm %} -
+
diff --git a/src/Bundle/ChillCustomFieldsBundle/Menu/AdminMenuBuilder.php b/src/Bundle/ChillCustomFieldsBundle/Menu/AdminMenuBuilder.php index 7ac745b12..db63ad6ac 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Menu/AdminMenuBuilder.php +++ b/src/Bundle/ChillCustomFieldsBundle/Menu/AdminMenuBuilder.php @@ -39,7 +39,6 @@ class AdminMenuBuilder implements LocalMenuBuilderInterface ->setAttribute('class', 'list-group-item-header') ->setExtras([ 'order' => 4500, - 'icons' => ['plus'], ]); $menu->addChild('Custom fields group', [ diff --git a/src/Bundle/ChillDocStoreBundle/Menu/AdminMenuBuilder.php b/src/Bundle/ChillDocStoreBundle/Menu/AdminMenuBuilder.php index 6848ed65a..466c3bace 100644 --- a/src/Bundle/ChillDocStoreBundle/Menu/AdminMenuBuilder.php +++ b/src/Bundle/ChillDocStoreBundle/Menu/AdminMenuBuilder.php @@ -39,7 +39,6 @@ class AdminMenuBuilder implements LocalMenuBuilderInterface ->setAttribute('class', 'list-group-item-header') ->setExtras([ 'order' => 4000, - 'icons' => ['file-pdf-o'], ]); $menu->addChild('Document category list', [ diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/_workflow.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/_workflow.html.twig index 299183cca..f914bd7f5 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/_workflow.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/_workflow.html.twig @@ -6,7 +6,7 @@ {{ 'workflow.Document deleted'|trans }} {% else %} -
+
@@ -22,7 +22,6 @@ {{ document.description }} {% endif %} -
diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/Macro/macro.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/Macro/macro.html.twig index 886544b1e..0e739d94b 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/Macro/macro.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/Macro/macro.html.twig @@ -13,3 +13,19 @@ {{ 'Download'|trans }} {% endif %} {% endmacro %} + +{% macro download_button_small(storedObject, filename = null) %} + {% if storedObject is null %} + + {% else %} + + {{ 'Download'|trans }} + {% endif %} +{% endmacro %} \ No newline at end of file diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/Macro/macro_mimeicon.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/Macro/macro_mimeicon.html.twig index a9bc07e2f..7079a0d94 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/Macro/macro_mimeicon.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/Macro/macro_mimeicon.html.twig @@ -48,8 +48,8 @@ {% endif %} {% endfor %} - + {% endmacro %} \ No newline at end of file diff --git a/src/Bundle/ChillDocStoreBundle/Service/StoredObjectManager.php b/src/Bundle/ChillDocStoreBundle/Service/StoredObjectManager.php index daed12b84..a1ef42ff1 100644 --- a/src/Bundle/ChillDocStoreBundle/Service/StoredObjectManager.php +++ b/src/Bundle/ChillDocStoreBundle/Service/StoredObjectManager.php @@ -60,7 +60,7 @@ final class StoredObjectManager implements StoredObjectManagerInterface $this ->tempUrlGenerator ->generate( - Request::METHOD_PUT, + Request::METHOD_HEAD, $document->getFilename() ) ->url diff --git a/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml b/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml index 400e37236..b658dbbee 100644 --- a/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml @@ -14,7 +14,7 @@ Edit attributes: Modifier les propriétés du document Existing document: Document existant No document to download: Aucun document à télécharger 'Choose a document category': Choisissez une catégorie de document -Any document found: Aucun document trouvé +No document found: Aucun document trouvé The document is successfully registered: Le document est enregistré The document is successfully updated: Le document est mis à jour Any description: Aucune description @@ -66,3 +66,11 @@ online_edit_document: Éditer en ligne workflow: Document deleted: Document supprimé + +# ROLES +accompanyingCourseDocument: Documents dans les parcours d'accompagnement +CHILL_ACCOMPANYING_COURSE_DOCUMENT_CREATE: Créer un document +CHILL_ACCOMPANYING_COURSE_DOCUMENT_DELETE: Supprimer un document +CHILL_ACCOMPANYING_COURSE_DOCUMENT_SEE: Voir les documents +CHILL_ACCOMPANYING_COURSE_DOCUMENT_SEE_DETAILS: Voir les détails d'un document +CHILL_ACCOMPANYING_COURSE_DOCUMENT_UPDATE: Modifier un document \ No newline at end of file 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/ScopeApiController.php b/src/Bundle/ChillMainBundle/Controller/ScopeApiController.php new file mode 100644 index 000000000..85041f0f3 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Controller/ScopeApiController.php @@ -0,0 +1,25 @@ +andWhere($query->expr()->eq('e.active', "'TRUE'")); + } + } +} diff --git a/src/Bundle/ChillMainBundle/Controller/UserApiController.php b/src/Bundle/ChillMainBundle/Controller/UserApiController.php index b29fe7c8e..da873e118 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserApiController.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\MainBundle\Controller; use Chill\MainBundle\CRUD\Controller\ApiController; +use Chill\MainBundle\Pagination\PaginatorInterface; use Doctrine\ORM\QueryBuilder; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; @@ -70,4 +71,13 @@ class UserApiController extends ApiController $query->andWhere($query->expr()->eq('e.enabled', "'TRUE'")); } } + + /** + * @param mixed $query + * @param mixed $_format + */ + protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator, $_format) + { + return $query->orderBy('e.label', 'ASC'); + } } 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/DependencyInjection/ChillMainExtension.php b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php index 9c2148a14..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; @@ -499,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' => [ [ @@ -631,6 +655,7 @@ class ChillMainExtension extends Extension implements ], [ 'class' => \Chill\MainBundle\Entity\Scope::class, + 'controller' => \Chill\MainBundle\Controller\ScopeApiController::class, 'name' => 'scope', 'base_path' => '/api/1.0/main/scope', 'base_role' => 'ROLE_USER', 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 c38dd97c6..43a63c52d 100644 --- a/src/Bundle/ChillMainBundle/Entity/User.php +++ b/src/Bundle/ChillMainBundle/Entity/User.php @@ -16,7 +16,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; @@ -32,7 +32,7 @@ use function in_array; * "user": User::class * }) */ -class User implements AdvancedUserInterface +class User implements UserInterface { /** * @ORM\Id @@ -64,8 +64,6 @@ class User implements AdvancedUserInterface private ?Location $currentLocation = null; /** - * @var string - * * @ORM\Column(type="string", length=150, nullable=true) */ private ?string $email = null; @@ -227,7 +225,7 @@ class User implements AdvancedUserInterface } /** - * @return GroupCenter + * @return Collection */ public function getGroupCenters() { @@ -236,10 +234,8 @@ class User implements AdvancedUserInterface /** * Get id. - * - * @return int */ - public function getId() + public function getId(): ?int { return $this->id; } @@ -508,7 +504,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/Export/Helper/AggregateStringHelper.php b/src/Bundle/ChillMainBundle/Export/Helper/AggregateStringHelper.php new file mode 100644 index 000000000..6266ce86f --- /dev/null +++ b/src/Bundle/ChillMainBundle/Export/Helper/AggregateStringHelper.php @@ -0,0 +1,36 @@ +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/ScopeType.php b/src/Bundle/ChillMainBundle/Form/ScopeType.php index 691328500..86335c554 100644 --- a/src/Bundle/ChillMainBundle/Form/ScopeType.php +++ b/src/Bundle/ChillMainBundle/Form/ScopeType.php @@ -13,6 +13,7 @@ namespace Chill\MainBundle\Form; use Chill\MainBundle\Form\Type\TranslatableStringFormType; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -21,7 +22,12 @@ class ScopeType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('name', TranslatableStringFormType::class); + ->add('name', TranslatableStringFormType::class) + ->add('active', ChoiceType::class, [ + 'choices' => [ + 'Active' => true, + 'Inactive' => false, + ], ]); } /** diff --git a/src/Bundle/ChillMainBundle/Resources/public/chill/chillmain.scss b/src/Bundle/ChillMainBundle/Resources/public/chill/chillmain.scss index aa1d24844..3c9fc8601 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/chill/chillmain.scss +++ b/src/Bundle/ChillMainBundle/Resources/public/chill/chillmain.scss @@ -221,12 +221,8 @@ footer.footer { */ div.admin { - flex-direction: row-reverse; div.vertical-menu { - font-size: 0.9em; - .list-group-item { - padding: 0.3rem 0.7rem; - } + .list-group-item {} } } @@ -307,12 +303,12 @@ table.table-bordered { /// meta-data div.createdBy, div.updatedBy, -div.metadata { +.metadata { span.user, span.date { text-decoration: underline dotted; } } -div.metadata { +.metadata { font-size: smaller; color: $gray-600; span.user, span.date { @@ -368,6 +364,19 @@ div#flashMessages { } } +/// unbullet lists +ul.unbullet { + list-style-type: none; + padding-left: 0; +} +/// libellé +span.dt { + font-size: 90%; + font-weight: bolder; + background-color: var(--bs-chill-light-gray); +} + + /* * SPECIFIC RULES */ diff --git a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/render_box.scss b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/render_box.scss index 92becc089..19da5aed3 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/render_box.scss +++ b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/render_box.scss @@ -106,18 +106,5 @@ section.chill-entity { // used for comment-embeddable &.entity-comment-embeddable { width: 100%; - - /* already defined !! - div.metadata { - font-size: smaller; - color: $gray-600; - span.user, span.date { - text-decoration: underline dotted; - &:hover { - color: $gray-700; - } - } - } - */ } } 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 30a240938..21ab5e3d0 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue @@ -48,33 +48,35 @@ -
- - - - - - -
+ @@ -118,40 +120,42 @@ -
- - - - - - -
+ @@ -192,32 +196,34 @@ -
- - - - diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressSelection.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressSelection.vue index 2c8e17687..f1cac5254 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressSelection.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressSelection.vue @@ -98,6 +98,11 @@ export default { } }, }, + mounted() { + if (typeof this.value.point !== 'undefined') { + this.updateMapCenter(this.value.point); + } + }, methods: { transName(value) { return value.streetNumber === undefined ? value.street : `${value.streetNumber}, ${value.street}` 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 4ab117395..c0e42a7b1 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/EditPane.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/EditPane.vue @@ -187,6 +187,7 @@ div.address-form { div#address_map { height: 400px; width: 100%; + z-index: 1; } } 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 bc246d542..5048815e2 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/ShowPane.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/ShowPane.vue @@ -1,6 +1,6 @@