diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d693b287..8c61af1b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,19 @@ and this project adheres to ## Unreleased +* add 3 new fields to PostalCode and adapt postal code command and fixtures + +* [Aside activity] Fixes for aside activity + + * categories with child + * fast creation buttons + * add ordering for types + + +## Test releases + +### test release 2021-10-04 + * [Household editor][UI] Update how household suggestion and addresses are picked; * [AddAddress] Handle address suggestion; * [CenterType][Create a person] when overriding the ACL rules, allow to show a PickCenterType diff --git a/src/Bundle/ChillAsideActivityBundle/src/Controller/AdminController.php b/src/Bundle/ChillAsideActivityBundle/src/Controller/AdminController.php deleted file mode 100644 index ae04b2110..000000000 --- a/src/Bundle/ChillAsideActivityBundle/src/Controller/AdminController.php +++ /dev/null @@ -1,20 +0,0 @@ - - * @author Champs Libres - */ -class AdminController extends AbstractController -{ - - public function redirectToAdminIndexAction() - { - return $this->redirectToRoute('chill_main_admin_central'); - } -} \ No newline at end of file diff --git a/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityCategoryController.php b/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityCategoryController.php index 37f10c343..bf062b50d 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityCategoryController.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityCategoryController.php @@ -3,6 +3,9 @@ namespace Chill\AsideActivityBundle\Controller; use Chill\MainBundle\CRUD\Controller\CRUDController; +use Chill\MainBundle\Pagination\PaginatorInterface; +use Doctrine\ORM\QueryBuilder; +use Symfony\Component\HttpFoundation\Request; /** @@ -10,5 +13,12 @@ use Chill\MainBundle\CRUD\Controller\CRUDController; */ class AsideActivityCategoryController extends CRUDController { + protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator) + { + /** @var QueryBuilder $query */ + $query->addOrderBy('e.ordering', 'ASC'); -} \ No newline at end of file + return $query; + } + +} diff --git a/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php b/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php index 88e53c8d2..a0362ec12 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php @@ -4,6 +4,8 @@ declare(strict_types=1); namespace Chill\AsideActivityBundle\Controller; +use Chill\AsideActivityBundle\Entity\AsideActivity; +use Chill\AsideActivityBundle\Repository\AsideActivityCategoryRepository; use Chill\MainBundle\CRUD\Controller\CRUDController; use Doctrine\ORM\QueryBuilder; use Symfony\Component\HttpFoundation\Request; @@ -12,12 +14,21 @@ use Doctrine\Common\Collections\Criteria; final class AsideActivityController extends CRUDController { + + private $categoryRepository; + + public function __construct(AsideActivityCategoryRepository $categoryRepository) + { + $this->categoryRepository = $categoryRepository; + } + protected function buildQueryEntities(string $action, Request $request) { $qb = parent::buildQueryEntities($action, $request); if ('index' === $action) { - $qb->andWhere($qb->expr()->eq('e.agent', ':user')); + $qb->where($qb->expr()->eq('e.agent', ':user')); + $qb->orWhere($qb->expr()->eq('e.createdBy', ':user')); $qb->setParameter('user', $this->getUser()); } @@ -37,5 +48,24 @@ final class AsideActivityController extends CRUDController return parent::orderQuery($action, $query, $request, $paginator); } + public function createEntity(string $action, Request $request): object + { + $asideActivity = new AsideActivity(); + $duration = $request->query->get('duration', '300'); + $duration = \DateTime::createFromFormat('U', $duration); + $asideActivity->setDuration($duration); + + $categoryId = $request->query->get('type', 7); + if($categoryId === null){ + return $this->createNotFoundException('You must give a valid category id'); + } + $category = $this->categoryRepository->find($categoryId); + $asideActivity->setType($category); + + $note = $request->query->get('note', null); + $asideActivity->setNote($note); + + return $asideActivity; + } } diff --git a/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/ChillAsideActivityExtension.php b/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/ChillAsideActivityExtension.php index 712649653..59e77c3e9 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/ChillAsideActivityExtension.php +++ b/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/ChillAsideActivityExtension.php @@ -24,6 +24,12 @@ final class ChillAsideActivityExtension extends Extension implements PrependExte */ public function load(array $configs, ContainerBuilder $container): void { + + $configuration = $this->getConfiguration($configs, $container); + $config = $this->processConfiguration($configuration, $configs); + + $container->setParameter('chill_aside_activity.form.time_duration', $config['form']['time_duration']); + $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../config')); $loader->load('services.yaml'); $loader->load('services/form.yaml'); @@ -81,7 +87,7 @@ final class ChillAsideActivityExtension extends Extension implements PrependExte 'controller' => \Chill\AsideActivityBundle\Controller\AsideActivityController::class, 'actions' => [ 'index' => [ - 'template' => '@ChillAsideActivity/asideActivity/list.html.twig', + 'template' => '@ChillAsideActivity/asideActivity/index.html.twig', 'role' => 'ROLE_USER' ], 'new' => [ diff --git a/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/Configuration.php b/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/Configuration.php new file mode 100644 index 000000000..7268b92ae --- /dev/null +++ b/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/Configuration.php @@ -0,0 +1,138 @@ +getRootNode('chill_aside_activity') + ->children() + ->arrayNode('form') + ->canBeEnabled() + ->children() + ->arrayNode('time_duration') + ->isRequired() + ->defaultValue( + [ + [ 'label' => '5 minutes', 'seconds' => 300], + [ 'label' => '10 minutes', 'seconds' => 600], + [ 'label' => '15 minutes', 'seconds' => 900], + [ 'label' => '20 minutes', 'seconds' => 1200], + [ 'label' => '25 minutes', 'seconds' => 1500], + [ 'label' => '30 minutes', 'seconds' => 1800], + [ 'label' => '45 minutes', 'seconds' => 2700], + [ 'label' => '1 hour', 'seconds' => 3600], + [ 'label' => '1 hour 15', 'seconds' => 4500], + [ 'label' => '1 hour 30', 'seconds' => 5400], + [ 'label' => '1 hour 45', 'seconds' => 6300], + [ 'label' => '2 hours', 'seconds' => 7200], + [ 'label' => '2 hours 30', 'seconds' => 9000], + [ 'label' => '3 hours', 'seconds' => 10800], + [ 'label' => '3 hours 30', 'seconds' => 12600], + [ 'label' => '4 hours', 'seconds' => 14400], + [ 'label' => '4 hours 30', 'seconds' => 16200], + [ 'label' => '5 hours', 'seconds' => 18000], + [ 'label' => '5 hours 30', 'seconds' => 19800], + [ 'label' => '6 hours', 'seconds' => 21600], + [ 'label' => '6 hours 30', 'seconds' => 23400], + [ 'label' => '7 hours', 'seconds' => 25200], + [ 'label' => '7 hours 30', 'seconds' => 27000], + [ 'label' => '8 hours', 'seconds' => 28800], + [ 'label' => '8 hours 30', 'seconds' => 30600], + [ 'label' => '9 hours', 'seconds' => 32400], + [ 'label' => '9 hours 30', 'seconds' => 34200], + [ 'label' => '10 hours', 'seconds' => 36000], + [ 'label' => '1/2 day', 'seconds' => 14040], + [ 'label' => '1 day', 'seconds' => 28080], + [ 'label' => '1 1/2 days', 'seconds' => 42120], + [ 'label' => '2 days', 'seconds' => 56160], + [ 'label' => '2 1/2 days', 'seconds' => 70200], + [ 'label' => '3 days', 'seconds' => 84240], + [ 'label' => '3 1/2 days', 'seconds' => 98280], + [ 'label' => '4 days', 'seconds' => 112320], + [ 'label' => '4 1/2 days', 'seconds' => 126360], + [ 'label' => '5 days', 'seconds' => 140400], + [ 'label' => '5 1/2 days', 'seconds' => 154440], + [ 'label' => '6 days', 'seconds' => 168480], + [ 'label' => '6 1/2 days', 'seconds' => 182520], + [ 'label' => '7 days', 'seconds' => 196560], + [ 'label' => '7 1/2 days', 'seconds' => 210600], + [ 'label' => '8 days', 'seconds' => 224640], + [ 'label' => '8 1/2 days', 'seconds' => 238680], + [ 'label' => '9 days', 'seconds' => 252720], + [ 'label' => '9 1/2 days', 'seconds' => 266760], + [ 'label' => '10 days', 'seconds' => 280800], + [ 'label' => '10 1/2days', 'seconds' => 294840], + [ 'label' => '11 days', 'seconds' => 308880], + [ 'label' => '11 1/2 days', 'seconds' => 322920], + [ 'label' => '12 days', 'seconds' => 336960], + [ 'label' => '12 1/2 days', 'seconds' => 351000], + [ 'label' => '13 days', 'seconds' => 365040], + [ 'label' => '13 1/2 days', 'seconds' => 379080], + [ 'label' => '14 days', 'seconds' => 393120], + [ 'label' => '14 1/2 days', 'seconds' => 407160], + [ 'label' => '15 days', 'seconds' => 421200], + [ 'label' => '15 1/2 days', 'seconds' => 435240], + [ 'label' => '16 days', 'seconds' => 449280], + [ 'label' => '16 1/2 days', 'seconds' => 463320], + [ 'label' => '17 days', 'seconds' => 477360], + [ 'label' => '17 1/2 days', 'seconds' => 491400], + [ 'label' => '18 days', 'seconds' => 505440], + [ 'label' => '18 1/2 days', 'seconds' => 519480], + [ 'label' => '19 days', 'seconds' => 533520], + [ 'label' => '19 1/2 days', 'seconds' => 547560], + [ 'label' => '20 days', 'seconds' => 561600], + [ 'label' => '20 1/2 days', 'seconds' => 575640], + [ 'label' => '21 days', 'seconds' => 580680], + [ 'label' => '21 1/2 days', 'seconds' => 603720], + [ 'label' => '22 days', 'seconds' => 617760], + [ 'label' => '22 1/2 days', 'seconds' => 631800], + [ 'label' => '23 days', 'seconds' => 645840], + [ 'label' => '23 1/2 days', 'seconds' => 659880], + [ 'label' => '24 days', 'seconds' => 673920], + [ 'label' => '24 1/2 days', 'seconds' => 687960], + [ 'label' => '25 days', 'seconds' => 702000], + [ 'label' => '25 1/2 days', 'seconds' => 716040], + [ 'label' => '26 days', 'seconds' => 730080], + [ 'label' => '26 1/2 days', 'seconds' => 744120], + [ 'label' => '27 days', 'seconds' => 758160], + [ 'label' => '27 1/2 days', 'seconds' => 772200], + [ 'label' => '28 days', 'seconds' => 786240], + [ 'label' => '28 1/2 days', 'seconds' => 800280], + [ 'label' => '29 days', 'seconds' => 814320], + [ 'label' => '29 1/2 days', 'seconds' => 828360], + [ 'label' => '30 days', 'seconds' => 842400], + ] + ) + ->info('The intervals of time to show in activity form') + + ->prototype('array') + ->children() + ->scalarNode('seconds') + ->info("The number of seconds of this duration. Must be an integer.") + ->cannotBeEmpty() + ->validate() + ->ifTrue(function($data) { + return !is_int($data); + })->thenInvalid("The value %s is not a valid integer") + ->end() + ->end() + ->scalarNode('label') + ->cannotBeEmpty() + ->info("The label to show into fields") + ->end() + ->end() + ->end() + ->end() + ->end() + ->end(); + + return $treeBuilder; + } +} \ No newline at end of file diff --git a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php index 6c580394b..09087226c 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php @@ -7,6 +7,8 @@ namespace Chill\AsideActivityBundle\Entity; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Validator\Constraints as Assert; +use Symfony\Component\Validator\Context\ExecutionContextInterface; /** * @ORM\Entity @@ -27,10 +29,33 @@ class AsideActivityCategory private array $title; /** + * @ORM\OneToMany(targetEntity=AsideActivityCategory::class, mappedBy="parent") * @ORM\Column(type="boolean") */ private bool $isActive = true; + /** + * @var float + * @ORM\Column(type="float", options={"default": 0.00}) + */ + private float $ordering = 0.00; + + /** + * @ORM\ManyToOne(targetEntity=AsideActivityCategory::class, inversedBy="children") + * @ORM\JoinColumn(nullable=true) + */ + private $parent; + + /** + * @ORM\OneToMany(targetEntity=AsideActivityCategory::class, mappedBy="parent") + */ + private $children; + + public function __construct() + { + $this->children = new ArrayCollection(); + } + public function getId(): ?int { return $this->id; @@ -59,4 +84,85 @@ class AsideActivityCategory return $this; } + + public function getParent(): ?self + { + return $this->parent; + } + + /** + * + * @Assert\Callback() + */ + public function preventRecursiveParent(ExecutionContextInterface $context, $payload) + { + if (!$this->hasParent()) { + return; + } + + if ($this->getParent() === $this) { + // replace parent with old parent. This prevent recursive loop + // when displaying form + $this->parent = $this->oldParent; + $context->buildViolation('You must not add twice the same category in the parent tree (previous result returned)') + ->atPath('parent') + ->addViolation() + ; + } + } + + public function hasParent(): bool + { + return $this->parent !== null; + } + + public function setParent(?self $parent): self + { + // cache the old result for changing it during validaiton + $this->oldParent = $this->parent; + $this->parent = $parent; + + return $this; + } + + /** + * @return Collection|self[] + */ + public function getChildren(): Collection + { + return $this->children; + } + + public function addChild(self $child): self + { + if (!$this->children->contains($child)) { + $this->children[] = $child; + $child->setParent($this); + } + + return $this; + } + + public function removeChild(self $child): self + { + if ($this->children->removeElement($child)) { + // set the owning side to null (unless already changed) + if ($child->getParent() === $this) { + $child->setParent(null); + } + } + + return $this; + } + + public function getOrdering(): float + { + return $this->ordering; + } + + public function setOrdering(float $ordering): AsideActivityCategory + { + $this->ordering = $ordering; + return $this; + } } diff --git a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityCategoryType.php b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityCategoryType.php index 1bfc6ed37..0060ab1b9 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityCategoryType.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityCategoryType.php @@ -3,21 +3,43 @@ namespace Chill\AsideActivityBundle\Form; use Chill\AsideActivityBundle\Entity\AsideActivityCategory; +use Chill\AsideActivityBundle\Templating\Entity\CategoryRender; use Chill\MainBundle\Form\Type\TranslatableStringFormType; +use Chill\MainBundle\Templating\TranslatableStringHelper; +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\NumberType; use Symfony\Component\Form\FormBuilderInterface; final class AsideActivityCategoryType extends AbstractType { + + protected $translatableStringHelper; + + public function __construct(TranslatableStringHelper $translatableStringHelper, CategoryRender $categoryRender) + { + $this->translatableStringHelper = $translatableStringHelper; + $this->categoryRender = $categoryRender; + } + public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('title', TranslatableStringFormType::class, [ 'label' => 'Nom', ]) - ->add('isActive', ChoiceType::class, + ->add('parent', EntityType::class, [ + 'class' => AsideActivityCategory::class, + 'required' => false, + 'label' => 'Parent', + 'choice_label' => function (AsideActivityCategory $category){ + $options = []; + return $this->categoryRender->renderString($category, $options); + } + ]) + ->add('ordering', NumberType::class) + ->add('isActive', ChoiceType::class, [ 'choices' => [ 'Yes' => true, diff --git a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php index 4bf5bbfdc..7c7803816 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php @@ -4,11 +4,13 @@ namespace Chill\AsideActivityBundle\Form; use Chill\AsideActivityBundle\Entity\AsideActivity; use Chill\AsideActivityBundle\Entity\AsideActivityCategory; +use Chill\AsideActivityBundle\Templating\Entity\CategoryRender; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Form\Type\ChillDateType; use Chill\MainBundle\Form\Type\ChillTextareaType; use Chill\MainBundle\Templating\TranslatableStringHelper; use Doctrine\ORM\EntityRepository; +use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Form\AbstractType; @@ -16,26 +18,27 @@ use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTra use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; -use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvents; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; -use Symfony\Component\Security\Core\Security; +use Symfony\Component\Templating\EngineInterface; final class AsideActivityFormType extends AbstractType { protected array $timeChoices; - private TranslatableStringHelper $translatableStringHelper; private TokenStorageInterface $storage; + private CategoryRender $categoryRender; public function __construct ( TranslatableStringHelper $translatableStringHelper, ParameterBagInterface $parameterBag, - TokenStorageInterface $storage + TokenStorageInterface $storage, + CategoryRender $categoryRender ){ - $this->timeChoices = $parameterBag->get('chill_activity.form.time_duration'); + $this->timeChoices = $parameterBag->get('chill_aside_activity.form.time_duration'); $this->translatableStringHelper = $translatableStringHelper; $this->storage = $storage; + $this->categoryRender = $categoryRender; } public function buildForm(FormBuilderInterface $builder, array $options) @@ -70,11 +73,6 @@ final class AsideActivityFormType extends AbstractType [ 'label' => 'date', 'data' => new \DateTime(), - //SETTING RANGE ONLY POSSIBLE WITH WIDGET 'CHOICE' AND NOT 'SINGLE_TEXT'? - // 'widget' => 'choice', - // 'years' => range(2020, date('Y')), - // 'months' => range(1, date('m')), - // 'days' => range(1, date('d')), 'required' => true ]) ->add('type', EntityType::class, @@ -83,9 +81,17 @@ final class AsideActivityFormType extends AbstractType 'required' => true, 'class' => AsideActivityCategory::class, 'placeholder' => 'Choose the activity category', - // 'choice_label' => 'title[""]' + 'query_builder' => function(EntityRepository $er) { + $qb = $er->createQueryBuilder('ac'); + $qb->where($qb->expr()->eq('ac.isActive', 'TRUE')) + ->addOrderBy('ac.ordering', 'ASC') + ; + + return $qb; + }, 'choice_label' => function (AsideActivityCategory $asideActivityCategory) { - return $this->translatableStringHelper->localize($asideActivityCategory->getTitle()); + $options = []; + return $this->categoryRender->renderString($asideActivityCategory, $options); }, ]) ->add('duration', ChoiceType::class, $durationTimeOptions) diff --git a/src/Bundle/ChillAsideActivityBundle/src/Menu/AdminMenuBuilder.php b/src/Bundle/ChillAsideActivityBundle/src/Menu/AdminMenuBuilder.php new file mode 100644 index 000000000..ecc1a1f90 --- /dev/null +++ b/src/Bundle/ChillAsideActivityBundle/src/Menu/AdminMenuBuilder.php @@ -0,0 +1,48 @@ +security = $security; + } + + public static function getMenuIds(): array + { + return ['admin_index', 'admin_section', 'admin_aside_activity']; + } + + public function buildMenu($menuId, MenuItem $menu, array $parameters) + { + // all the entries below must have ROLE_ADMIN permissions + if (!$this->security->isGranted('ROLE_ADMIN')) { + return; + } + + if (in_array($menuId, ['admin_index', 'admin_section'])) { + $menu->addChild('Aside activities', [ + 'route' => 'chill_crud_aside_activity_category_index' + ]) + ->setExtras([ + 'order' => 900, + 'explain' => "Configure aside activities categories" + ]); + } else { + $menu + ->addChild('Aside activity categories', [ + 'route' => 'chill_crud_aside_activity_category_index' + ]) + ->setExtras([ + 'order' => '50' + ]); + } + + } +} diff --git a/src/Bundle/ChillAsideActivityBundle/src/Menu/SectionMenuBuilder.php b/src/Bundle/ChillAsideActivityBundle/src/Menu/SectionMenuBuilder.php index b9776b92b..8a8d65156 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Menu/SectionMenuBuilder.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Menu/SectionMenuBuilder.php @@ -4,6 +4,8 @@ namespace Chill\AsideActivityBundle\Menu; use Chill\MainBundle\Routing\LocalMenuBuilderInterface; use Knp\Menu\MenuItem; +use Symfony\Component\Security\Core\Authorization\AuthorizationChecker; +use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Contracts\Translation\TranslatorInterface; /** @@ -14,10 +16,12 @@ use Symfony\Contracts\Translation\TranslatorInterface; class SectionMenuBuilder implements LocalMenuBuilderInterface { protected TranslatorInterface $translator; + public AuthorizationCheckerInterface $authorizationChecker; - public function __construct(TranslatorInterface $translator) + public function __construct(TranslatorInterface $translator, AuthorizationCheckerInterface $authorizationChecker) { $this->translator = $translator; + $this->authorizationChecker = $authorizationChecker; } /** @@ -27,13 +31,26 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface */ public function buildMenu($menuId, MenuItem $menu, array $parameters) { - $menu->addChild($this->translator->trans('Create an aside activity'), [ - 'route' => 'chill_crud_aside_activity_new' + if ($this->authorizationChecker->isGranted('ROLE_USER')){ + $menu->addChild($this->translator->trans('Create an aside activity'), [ + 'route' => 'chill_crud_aside_activity_new' + ]) + ->setExtras([ + 'order' => 11, + 'icons' => [ 'plus' ] + ]); + $menu->addChild($this->translator->trans('Phonecall'), [ + 'route' => 'chill_crud_aside_activity_new', + 'routeParameters' => [ + 'type' => 1, + 'duration' => 900, + ] ]) ->setExtras([ - 'order' => 11, - 'icons' => [ 'plus' ] + 'order' => 12, + 'icons' => ['plus'] ]); + } } /** diff --git a/src/Bundle/ChillAsideActivityBundle/src/Menu/UserMenuBuilder.php b/src/Bundle/ChillAsideActivityBundle/src/Menu/UserMenuBuilder.php new file mode 100644 index 000000000..4858e6ee7 --- /dev/null +++ b/src/Bundle/ChillAsideActivityBundle/src/Menu/UserMenuBuilder.php @@ -0,0 +1,92 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +namespace Chill\AsideActivityBundle\Menu; + +use Chill\MainBundle\Routing\LocalMenuBuilderInterface; +use Knp\Menu\MenuItem; +use Chill\TaskBundle\Templating\UI\CountNotificationTask; +use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; +use Symfony\Component\Translation\TranslatorInterface; +use Chill\MainBundle\Entity\User; +use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; + + +/** + * + * + * @author Julien Fastré + */ +class UserMenuBuilder implements LocalMenuBuilderInterface +{ + + /** + * + * @var CountNotificationTask + */ + public $counter; + + /* + * @var TokenStorageInterface + */ + public $tokenStorage; + + /** + * + * @var TranslatorInterface + */ + public $translator; + + /** + * + * @var AuthorizationCheckerInterface + */ + public $authorizationChecker; + + public function __construct( + CountNotificationTask $counter, + TokenStorageInterface $tokenStorage, + TranslatorInterface $translator, + AuthorizationCheckerInterface $authorizationChecker + ) { + $this->counter = $counter; + $this->tokenStorage = $tokenStorage; + $this->translator = $translator; + $this->authorizationChecker = $authorizationChecker; + } + + + public function buildMenu($menuId, MenuItem $menu, array $parameters) + { + if ($this->authorizationChecker->isGranted('ROLE_USER')){ + $menu->addChild("My aside activities", [ + 'route' => 'chill_crud_aside_activity_index' + ]) + ->setExtras([ + 'order' => 10, + 'icon' => 'tasks' + ]); + } + + } + + public static function getMenuIds(): array + { + return [ 'user' ]; + } + +} diff --git a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/Admin/layout_asideactivity.html.twig b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/Admin/layout_asideactivity.html.twig index f0242c085..3f44e432d 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/Admin/layout_asideactivity.html.twig +++ b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/Admin/layout_asideactivity.html.twig @@ -1,14 +1,12 @@ {% extends "@ChillMain/Admin/layoutWithVerticalMenu.html.twig" %} {% block vertical_menu_content %} - {{ chill_menu('admin_aside_activity', { - 'layout': '@ChillAsideActivity/Admin/menu_asideactivity.html.twig', - }) }} + {{ chill_menu('admin_aside_activity') }} {% endblock %} {% block layout_wvm_content %} {% block admin_content %} -

{{ 'Aside activity configuration' |trans }}

+

{{ 'Aside activity configuration'|trans }}

{% endblock %} {% endblock %} diff --git a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/Admin/menu_asideactivity.html.twig b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/Admin/menu_asideactivity.html.twig deleted file mode 100644 index 34ea309e5..000000000 --- a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/Admin/menu_asideactivity.html.twig +++ /dev/null @@ -1,4 +0,0 @@ -{% extends "@ChillMain/Menu/verticalMenu.html.twig" %} -{% block v_menu_title %} - {{ 'Aside activity configuration menu'|trans }} -{% endblock %} diff --git a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/Entity/asideActivityCategory.html.twig b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/Entity/asideActivityCategory.html.twig new file mode 100644 index 000000000..1b31cc765 --- /dev/null +++ b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/Entity/asideActivityCategory.html.twig @@ -0,0 +1,12 @@ +{% set reversed_parents = parents|reverse %} + + {%- for p in reversed_parents %} + + {{ p.title|localize_translatable_string }}{{ options['default.separator'] }} + + {%- endfor -%} + + {{ asideActivityCategory.title|localize_translatable_string }} + + diff --git a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/_index.html.twig b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/_index.html.twig deleted file mode 100644 index e69de29bb..000000000 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 0e8ea0506..6cc45aeaf 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/index.html.twig +++ b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/index.html.twig @@ -1,8 +1,91 @@ -{% extends '@ChillMain/layout.html.twig' %} +{% extends "@ChillMain/layout.html.twig" %} -{% block title %}{{ ('crud.' ~ crud_name ~ '.index.title')|trans({'%crud_name%': crud_name}) }}{% endblock %} +{% block title %} + {{ 'Aside activity list'|trans }} +{% endblock title %} {% block content %} - {% embed '@ChillAsideActivity/AsideActivity/_index.html.twig' %} - {% endembed %} -{% endblock content %} \ No newline at end of file +
+

{{ 'My aside activities'|trans }}

+ + {% if entities|length == 0 %} +

+ {{ "There aren't any aside activities."|trans }} + +

+ {% else %} + +
+ + {% for entity in entities %} + +
+
+ +
+

+ {{ entity.type|chill_entity_render_box }} +

+
+ {% if entity.date %} + {{ entity.date|format_date('long') }} + {% endif %} + {% if entity.date %} + + + + {{ entity.duration|date('H:i') }} + + + {% endif %} +
+
+
+
+
    +
  • + + {{ 'By'|trans }}: + {{ entity.createdBy|chill_entity_render_box }} + +
  • +
  • + + {{ 'For'|trans }}: + {{ entity.agent|chill_entity_render_box }} + + +
  • +
+
+
    +
  • + +
  • +
  • + +
  • +
  • + +
  • +
+
+
+
+
+
+ {% endfor %} +
+ + {{ chill_pagination(paginator) }} + + + {% endif %} + + {% endblock %} diff --git a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/list.html.twig b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/list.html.twig deleted file mode 100644 index d0e02e3d2..000000000 --- a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/list.html.twig +++ /dev/null @@ -1,97 +0,0 @@ -{% extends "@ChillMain/layout.html.twig" %} - -{% block title %} - {{ 'Aside activity list' |trans }} -{% endblock title %} - -{% block content %} -
-

{{ 'My aside activities' |trans }}

- - {% if entities|length == 0 %} -

- {{ "There aren't any aside activities."|trans }} - -

- {% else %} - -
- {# Sort activities according to date in descending order #} - {% for entity in entities %} - {% set t = entity.type %} - -
-
-
- -

- {{ entity.type.title | localize_translatable_string }} -

- - {% if entity.date %} -

{{ entity.date|format_date('long') }}

- {% endif %} - -
-

- - {{ entity.duration|date('H:i') }} -

-
- -
-
-
    - {% if entity.createdBy %} -
  • - {{ 'Created by: '|trans }}{{ entity.createdBy.usernameCanonical }} -
  • - {% endif %} -
-
-
- - {# {% - if entity.note is not empty - or entity.createdBy|length > 0 - %} -
- {% if entity.note is not empty %} -
- {{ entity.note|chill_markdown_to_html }} -
- {% endif %} - -
- {% endif %} #} -
-
    -
      -
    • - -
    • -
    • - -
    • -
    -
-
-
- - {% endfor %} -
- - {{ chill_pagination(paginator) }} - - -
- {% endif %} - -{% endblock %} diff --git a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/view.html.twig b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/view.html.twig index 4553e1c6f..75da9a444 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/view.html.twig +++ b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivity/view.html.twig @@ -3,13 +3,50 @@ {% set activeRouteKey = '' %} {% block title %} -{% include('@ChillMain/CRUD/_view_title.html.twig') %} + {% include('@ChillMain/CRUD/_view_title.html.twig') %} {% endblock %} {% block content %} -{% embed '@ChillMain/CRUD/_view_content.html.twig' %} - {% block crud_content_header %} -

{{ ('crud.' ~ crud_name ~ '.title_view')|trans }}

- {% endblock crud_content_header %} -{% endembed %} -{% endblock %} \ No newline at end of file + {% embed '@ChillMain/CRUD/_view_content.html.twig' %} + {% block crud_content_header %} +

{{ ('crud.' ~ crud_name ~ '.title_view')|trans }}

+ {% endblock crud_content_header %} + {% block crud_content_view_details %} +
+ +
{{ 'Type'|trans }}
+
{{ entity.type|chill_entity_render_box }}
+ +
{{ 'Created by'|trans }}
+
{{ entity.createdBy }}
+ +
{{ 'Created for'|trans }}
+
{{ entity.agent }}
+ +

{{ 'Activity data'|trans }}

+ +
{{ 'Date'|trans }}
+
{{ entity.date|format_date('long') }}
+ +
{{ 'Duration'|trans }}
+
{{ entity.duration|date('H:i') }}
+ +
{{ 'Remark'|trans }}
+ {%- if entity.note is empty -%} +
+ {{ 'No comments'|trans }} +
+ {%- else -%} +
+
+
+

{{ entity.note }}

+
+
+
+ {%- endif -%} +
+ + {% endblock %} + {% endembed %} +{% endblock %} diff --git a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivityCategory/edit.html.twig b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivityCategory/edit.html.twig index dacee767c..3fb6fb612 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivityCategory/edit.html.twig +++ b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivityCategory/edit.html.twig @@ -1,4 +1,4 @@ -{% extends "@ChillActivity/Admin/layout_activity.html.twig" %} +{% extends "@ChillAsideActivity/Admin/layout_asideactivity.html.twig" %} {% block title %} {% include('@ChillMain/CRUD/_edit_title.html.twig') %} diff --git a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivityCategory/index.html.twig b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivityCategory/index.html.twig index d8cb67716..2c8373daf 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivityCategory/index.html.twig +++ b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivityCategory/index.html.twig @@ -1,11 +1,12 @@ {% extends "@ChillAsideActivity/Admin/layout_asideactivity.html.twig" %} {% block admin_content %} -

{{ 'ActivityType list'|trans }}

+

{{ 'Aside Activity Type list'|trans }}

+ @@ -14,7 +15,8 @@ {% for entity in entities %} - + +
{{ 'Ordering'|trans }} {{ 'Name'|trans }} {{ 'Active'|trans }} {{ 'Actions'|trans }}
{{ entity.title|localize_translatable_string }}{{ entity.ordering }}{{ entity|chill_entity_render_box }} {%- if entity.isActive -%} diff --git a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivityCategory/new.html.twig b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivityCategory/new.html.twig index d7ac89752..3c8ded234 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivityCategory/new.html.twig +++ b/src/Bundle/ChillAsideActivityBundle/src/Resources/views/asideActivityCategory/new.html.twig @@ -1,4 +1,4 @@ -{% extends "@ChillActivity/Admin/layout_activity.html.twig" %} +{% extends "@ChillAsideActivity/Admin/layout_asideactivity.html.twig" %} {% block title %} {% include('@ChillMain/CRUD/_new_title.html.twig') %} diff --git a/src/Bundle/ChillAsideActivityBundle/src/Templating/Entity/CategoryRender.php b/src/Bundle/ChillAsideActivityBundle/src/Templating/Entity/CategoryRender.php new file mode 100644 index 000000000..902ed7a68 --- /dev/null +++ b/src/Bundle/ChillAsideActivityBundle/src/Templating/Entity/CategoryRender.php @@ -0,0 +1,80 @@ + ' > ' + ]; + + public function __construct(TranslatableStringHelper $translatableStringHelper, EngineInterface $engine) + { + $this->translatableStringHelper = $translatableStringHelper; + $this->engine = $engine; + } + + /** + * @param AsideActivityCategory $asideActivityCategory + */ + public function renderString($asideActivityCategory, array $options): string + { + $options = array_merge(self::DEFAULT_ARGS, $options); + + $titles[] = $this->translatableStringHelper->localize($asideActivityCategory->getTitle()); + + while ($asideActivityCategory->hasParent()) { + $asideActivityCategory = $asideActivityCategory->getParent(); + $titles[] = $this->translatableStringHelper->localize($asideActivityCategory->getTitle()); + } + + $titles = array_reverse($titles); + + return implode($options[self::SEPERATOR_KEY], $titles); + + } + + /** + * @param AsideActivityCategory $asideActivityCategory + */ + public function supports($asideActivityCategory, array $options): bool + { + return $asideActivityCategory instanceof AsideActivityCategory; + } + + public function buildParents(AsideActivityCategory $asideActivityCategory) + { + $parents = []; + + while($asideActivityCategory->hasParent()) { + $asideActivityCategory = $parents[] = $asideActivityCategory->getParent(); + } + + return $parents; + } + + /** + * @param AsideActivityCategory $asideActivityCategory + */ + public function renderBox($asideActivityCategory, array $options): string + { + $options = array_merge(self::DEFAULT_ARGS, $options); + $parents = $this->buildParents($asideActivityCategory); + + return $this->engine->render('@ChillAsideActivity/Entity/asideActivityCategory.html.twig', + [ + 'asideActivityCategory' => $asideActivityCategory, + 'parents' => $parents, + 'options' => $options + ]); + } +} diff --git a/src/Bundle/ChillAsideActivityBundle/src/config/services.yaml b/src/Bundle/ChillAsideActivityBundle/src/config/services.yaml index 8ff656fdc..34bb6da33 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/config/services.yaml +++ b/src/Bundle/ChillAsideActivityBundle/src/config/services.yaml @@ -1,5 +1,22 @@ services: - Chill\AsideActivityBundle\DataFixtures\: - resource: './../DataFixtures' - autowire: true - autoconfigure: true + Chill\AsideActivityBundle\DataFixtures\: + resource: "./../DataFixtures" + autowire: true + autoconfigure: true + + Chill\AsideActivityBundle\Templating\Entity\: + autowire: true + autoconfigure: true + resource: "../Templating/Entity" + tags: + - "chill.render_entity" + + Chill\AsideActivityBundle\Repository\: + resource: "../Repository" + autowire: true + autoconfigure: true + + Chill\AsideActivityBundle\Controller\: + resource: "../Controller" + autowire: true + autoconfigure: true diff --git a/src/Bundle/ChillAsideActivityBundle/src/config/services/menu.yaml b/src/Bundle/ChillAsideActivityBundle/src/config/services/menu.yaml index 614391a0e..909f82381 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/config/services/menu.yaml +++ b/src/Bundle/ChillAsideActivityBundle/src/config/services/menu.yaml @@ -1,5 +1,5 @@ services: Chill\AsideActivityBundle\Menu\: - resource: './../../Menu' + resource: "./../../Menu" autowire: true autoconfigure: true diff --git a/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210706124644.php b/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210706124644.php index 59fa35be4..13bee6404 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210706124644.php +++ b/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210706124644.php @@ -7,14 +7,11 @@ namespace Chill\Migrations\AsideActivity; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; -/** - * Auto-generated Migration: Please modify to your needs! - */ final class Version20210706124644 extends AbstractMigration { public function getDescription(): string { - return ''; + return 'Aside activity category entity created'; } public function up(Schema $schema): void diff --git a/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210804082249.php b/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210804082249.php index 4135bb4a2..85b99c572 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210804082249.php +++ b/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210804082249.php @@ -7,14 +7,11 @@ namespace Chill\Migrations\AsideActivity; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; -/** - * Auto-generated Migration: Please modify to your needs! - */ final class Version20210804082249 extends AbstractMigration { public function getDescription(): string { - return ''; + return 'Aside activity entity created'; } public function up(Schema $schema): void @@ -59,12 +56,12 @@ final class Version20210804082249 extends AbstractMigration $this->addSql('CREATE INDEX idx_e9fa219165ff1aec ON asideactivity (updatedby_id)'); $this->addSql('CREATE INDEX idx_e9fa21913414710b ON asideactivity (agent_id)'); $this->addSql('COMMENT ON COLUMN asideactivity.updatedat IS \'(DC2Type:datetime_immutable)\''); - $this->addSql('CREATE TABLE chill_main_address_legacy (id INT DEFAULT NULL, postcode_id INT DEFAULT NULL, street VARCHAR(255) DEFAULT NULL, streetnumber VARCHAR(255) DEFAULT NULL, validfrom DATE DEFAULT NULL, isnoaddress BOOLEAN DEFAULT NULL, customs JSONB DEFAULT NULL, floor VARCHAR(16) DEFAULT NULL, corridor VARCHAR(16) DEFAULT NULL, steps VARCHAR(16) DEFAULT NULL, buildingname VARCHAR(255) DEFAULT NULL, flat VARCHAR(16) DEFAULT NULL, distribution VARCHAR(255) DEFAULT NULL, extra VARCHAR(255) DEFAULT NULL, validto DATE DEFAULT NULL, point VARCHAR(255) DEFAULT NULL, linkedtothirdparty_id INT DEFAULT NULL)'); $this->addSql('ALTER TABLE asideactivity ADD CONSTRAINT fk_e9fa2191c54c8c93 FOREIGN KEY (type_id) REFERENCES asideactivitytype (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('ALTER TABLE asideactivity ADD CONSTRAINT fk_e9fa21913174800f FOREIGN KEY (createdby_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('ALTER TABLE asideactivity ADD CONSTRAINT fk_e9fa219165ff1aec FOREIGN KEY (updatedby_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('ALTER TABLE asideactivity ADD CONSTRAINT fk_e9fa21913414710b FOREIGN KEY (agent_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('DROP TABLE chill_asideactivity.AsideActivity'); $this->addSql('DROP TABLE chill_asideactivity.AsideActivityCategory'); + $this->addSql('DROP SCHEMA chill_asideactivity'); } } diff --git a/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210806140343.php b/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210806140343.php index 62b568407..75c7b81b2 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210806140343.php +++ b/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210806140343.php @@ -7,14 +7,11 @@ namespace Chill\Migrations\AsideActivity; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; -/** - * Auto-generated Migration: Please modify to your needs! - */ final class Version20210806140343 extends AbstractMigration { public function getDescription(): string { - return ''; + return 'Duration changed to type integer'; } public function up(Schema $schema): void diff --git a/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210806140710.php b/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210806140710.php index 92320e639..5c572e650 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210806140710.php +++ b/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210806140710.php @@ -7,14 +7,11 @@ namespace Chill\Migrations\AsideActivity; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; -/** - * Auto-generated Migration: Please modify to your needs! - */ final class Version20210806140710 extends AbstractMigration { public function getDescription(): string { - return ''; + return 'Duration changed back to timestamp'; } public function up(Schema $schema): void diff --git a/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210810084456.php b/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210810084456.php index 29d6be7f3..2984108c2 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210810084456.php +++ b/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210810084456.php @@ -7,14 +7,11 @@ namespace Chill\Migrations\AsideActivity; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; -/** - * Auto-generated Migration: Please modify to your needs! - */ final class Version20210810084456 extends AbstractMigration { public function getDescription(): string { - return ''; + return 'createdat, updatedat and date given a type timestamp'; } public function up(Schema $schema): void diff --git a/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210922182907.php b/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210922182907.php new file mode 100644 index 000000000..13ba8749c --- /dev/null +++ b/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20210922182907.php @@ -0,0 +1,28 @@ +addSql('ALTER TABLE chill_asideactivity.asideactivitycategory ADD parent_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_asideactivity.asideactivitycategory ADD CONSTRAINT FK_7BF90DBE727ACA70 FOREIGN KEY (parent_id) REFERENCES chill_asideactivity.AsideActivityCategory (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE INDEX IDX_7BF90DBE727ACA70 ON chill_asideactivity.asideactivitycategory (parent_id)'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_asideactivity.AsideActivityCategory DROP parent'); + } +} diff --git a/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20211004134012.php b/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20211004134012.php new file mode 100644 index 000000000..42763638e --- /dev/null +++ b/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20211004134012.php @@ -0,0 +1,29 @@ +addSql('ALTER TABLE chill_asideactivity.asideactivitycategory ADD ordering DOUBLE PRECISION NOT NULL DEFAULT 0.00'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_asideactivity.asideactivitycategory DROP ordering'); + } +} diff --git a/src/Bundle/ChillAsideActivityBundle/src/translations/messages.fr.yml b/src/Bundle/ChillAsideActivityBundle/src/translations/messages.fr.yml index fa62befea..c16f6af6a 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/translations/messages.fr.yml +++ b/src/Bundle/ChillAsideActivityBundle/src/translations/messages.fr.yml @@ -14,11 +14,8 @@ present: présent not present: absent Delete: Supprimer Update: Mettre à jour -Update activity: Modifier l'activité Aside activity data: Données de l'activité annexe -No reason associated: Aucun sujet There aren't any aside activities.: Aucune activité annexe enregistrée. -type_name: type de l'activité Type: Type Invisible: Invisible Optional: Optionnel @@ -43,14 +40,8 @@ crud: title_edit: Edition d'une catégorie de type d'activité #forms -Activity creation: Nouvelle activité annexe -Create a new aside activity type: Nouvelle catégorie d'activité annexe -Create: Créer +Create a new aside activity type: Nouvelle categorie d'activité annexe Back to the list: Retour à la liste -Save activity: Sauver l'activité -Reset form: Remise à zéro du formulaire -Choose the agent for whom this activity is created: Choisissez l'utilisateur pour qui l'activité est créée. -Choose the activity category: Choisissez le type d'activité Choose the duration: Choisir la durée Choose a category: Choisir une catégorie Is active: Actif @@ -58,12 +49,106 @@ Agent: Utilisateur date: Date Duration: Durée Note: Note +Choose the agent for whom this activity is created: Choisissez l'agent pour qui l'activité est créée +Choose the activity category: Choisir la catégorie + +#Duration +minutes: minutes +hour: heure +hours: heures +day: jour +days: jours +5 minutes: 5 minutes +10 minutes: 10 minutes +15 minutes: 15 minutes +20 minutes: 20 minutes +25 minutes: 25 minutes +30 minutes: 30 minutes +45 minutes: 45 minutes +1 hour: 1 heure +1 hour 15: 1 heure 15 +1 hour 30: 1 heure 30 +1 hour 45: 1 heure 45 +2 hours: 2 heures +2 hours 30: 2 heure 30 +3 hours: 3 heures +3 hours 30: 3 heure 30 +4 hours: 4 heures +4 hours 30: 4 heure 30 +5 hours: 5 heures +5 hours 30: 5 heure 30 +6 hours: 6 heures +6 hours 30: 6 heure 30 +7 hours: 7 heures +7 hours 30: 7 heure 30 +8 hours: 8 heures +8 hours 30: 8 heure 30 +9 hours: 9 heures +9 hours 30: 9 heure 30 +10 hours: 10 heures +1/2 day: 1/2 jour +1 day: 1 jour +1 1/2 days: 1 1/2 jours +2 days: 2 jours +2 1/2 days: 2 1/2 jours +3 days: 3 jours +3 1/2 days: 3 1/2 jours +4 days: 4 jours +4 1/2 days: 4 1/2 jours +5 days: 5 jours +5 1/2 days: 5 1/2 jours +6 days: 6 jours +6 1/2 days: 6 1/2 jours +7 days: 7 jours +7 1/2 days: 7 1/2 jours +8 days: 8 jours +8 1/2 days: 8 1/2 jours +9 days: 9 jours +9 1/2 days: 9 1/2 jours +10 days: 10 jours +10 1/2 days: 10 1/2 jours +11 days: 11 jours +11 1/2 days: 11 1/2 jours +12 days: 12 jours +12 1/2 days: 12 1/2 jours +13 days: 13 jours +13 1/2 days: 13 1/2 jours +14 days: 14 jours +14 1/2 days: 14 1/2 jours +15 days: 15 jours +15 1/2 days: 15 1/2 jours +16 days: 16 jours +16 1/2 days: 16 1/2 jours +17 days: 17 jours +17 1/2 days: 17 1/2 jours +18 days: 18 jours +18 1/2 days: 18 1/2 jours +19 days: 19 jours +19 1/2 days: 19 1/2 jours +20 days: 20 jours +20 1/2 days: 20 1/2 jours +21 days: 21 jours +21 1/2 days: 21 1/2 jours +22 days: 22 jours +22 1/2 days: 22 1/2 jours +23 days: 23 jours +23 1/2 days: 23 1/2 jours +24 days: 24 jours +24 1/2 days: 24 1/2 jours +25 days: 25 jours +25 1/2 days: 25 1/2 jours +26 days: 26 jours +26 1/2 days: 26 1/2 jours +27 days: 27 jours +27 1/2 days: 27 1/2 jours +28 days: 28 jours +28 1/2 days: 28 1/2 jours +29 days: 29 jours +29 1/2 days: 29 1/2 jours +30 days: 30 jours #list My aside activities: Mes activités annexes -Date: Date -Created by: Créée par - #Aside activity delete Delete aside activity: Supprimer une activité annexe Are you sure you want to remove the aside activity concerning "%name%" ?: Êtes-vous sûr de vouloir supprimer une activité annexe qui concerne "%name%" ? @@ -73,3 +158,4 @@ The activity has been successfully removed.: L'activité a été supprimée. Create an aside activity: "Créer une activité annexe" Aside activity configuration menu: "Menu de configuration des activités annexes" Aside activity configuration: "Configuration des activités annexes" +Phonecall: "Appel téléphonique" diff --git a/src/Bundle/ChillAsideActivityBundle/src/translations/validators.fr.yaml b/src/Bundle/ChillAsideActivityBundle/src/translations/validators.fr.yaml new file mode 100644 index 000000000..28883568c --- /dev/null +++ b/src/Bundle/ChillAsideActivityBundle/src/translations/validators.fr.yaml @@ -0,0 +1 @@ +You must not add twice the same category in the parent tree (previous result returned): Il est interdit d'indiquer la même entité dans l'arbre des parents. Le résultat précédent a été rétabli diff --git a/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php b/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php index ba51db779..21090a61f 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php @@ -19,6 +19,8 @@ namespace Chill\MainBundle\Command; +use Chill\MainBundle\Doctrine\Model\Point; +use Chill\MainBundle\Entity\Country; use Doctrine\ORM\EntityManager; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; @@ -69,6 +71,9 @@ class LoadPostalCodesCommand extends Command . "using the postal code and name. \n" . "The CSV file must have the following columns: " . "postal code, label, country code." + . "Optionally, the csv file can have the following " + . "columns after the country code: reference code, latitude, longitude, source. " + . "The latitude and longitude columns are supposed to be in WGS84 and expressed in decimal degrees. " . "The CSV file should not have any header row.") ->addArgument('csv_file', InputArgument::REQUIRED, "the path to " . "the csv file. See the help for specifications.") @@ -163,7 +168,7 @@ class LoadPostalCodesCommand extends Command } $em = $this->entityManager; $country = $em - ->getRepository('ChillMainBundle:Country') + ->getRepository(Country::class) ->findOneBy(array('countryCode' => $row[2])); if ($country === NULL) { @@ -173,7 +178,7 @@ class LoadPostalCodesCommand extends Command // try to find an existing postal code $existingPC = $em - ->getRepository('ChillMainBundle:PostalCode') + ->getRepository(PostalCode::class) ->findBy(array('code' => $row[0], 'name' => $row[1])); if (count($existingPC) > 0) { @@ -187,6 +192,18 @@ class LoadPostalCodesCommand extends Command ->setCountry($country) ; + if (NULL != $row[3]){ + $postalCode->setRefPostalCodeId($row[3]); + } + + if (NULL != $row[4] & NULL != $row[5]){ + $postalCode->setCenter(Point::fromLonLat((float) $row[5], (float) $row[4])); + } + + if (NULL != $row[6]){ + $postalCode->setPostalCodeSource($row[6]); + } + $errors = $this->validator->validate($postalCode); if ($errors->count() == 0) { diff --git a/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadPostalCodes.php b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadPostalCodes.php index 6e3d1781b..26ce7415e 100644 --- a/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadPostalCodes.php +++ b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadPostalCodes.php @@ -22,6 +22,8 @@ namespace Chill\MainBundle\DataFixtures\ORM; +use Chill\MainBundle\Doctrine\Model\Point; +use Chill\MainBundle\Entity\Country; use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Persistence\ObjectManager; @@ -40,21 +42,41 @@ class LoadPostalCodes extends AbstractFixture implements OrderedFixtureInterface return 50; } - public static $refs = array(); + public static $refs = []; public function load(ObjectManager $manager) { - $lines = str_getcsv(self::$codes, "\n"); - $belgium = $manager->getRepository('ChillMainBundle:Country') - ->findOneBy(array('countryCode' => 'BE')); + echo "loading postal codes... \n"; + $this->loadPostalCodeCSV($manager, self::$postalCodeBelgium, 'BE'); + $this->loadPostalCodeCSV($manager, self::$postalCodeFrance, 'FR'); + } + + private function loadPostalCodeCSV(ObjectManager $manager, string $csv, string $countryCode) { + + $lines = str_getcsv($csv, "\n"); + $country = $manager->getRepository(Country::class) + ->findOneBy(['countryCode' => $countryCode]); foreach($lines as $line) { $code = str_getcsv($line); $c = new PostalCode(); - $c->setCountry($belgium) + $c->setCountry($country) ->setCode($code[0]) - ->setName(\ucwords(\strtolower($code[2]))) + ->setName(\ucwords(\strtolower($code[1]))) ; + + if (NULL != $code[3]){ + $c->setRefPostalCodeId($code[3]); + } + + if (NULL != $code[4] & NULL != $code[5]){ + $c->setCenter(Point::fromLonLat((float) $code[5], (float) $code[4])); + } + + if (NULL != $code[6]){ + $c->setPostalCodeSource($code[6]); + } + $manager->persist($c); $ref = 'postal_code_'.$code[0]; @@ -66,40 +88,342 @@ class LoadPostalCodes extends AbstractFixture implements OrderedFixtureInterface $manager->flush(); } - - private static $codes = <<country; } + + public function getRefPostalCodeId(): ?string + { + return $this->refPostalCodeId; + } + + public function setRefPostalCodeId(?string $refPostalCodeId): self + { + $this->refPostalCodeId = $refPostalCodeId; + + return $this; + } + + public function getPostalCodeSource(): ?string + { + return $this->postalCodeSource; + } + + public function setPostalCodeSource(?string $postalCodeSource): self + { + $this->postalCodeSource = $postalCodeSource; + + return $this; + } + + public function getCenter(): ?Point + { + return $this->center; + } + + public function setCenter(?Point $center): self + { + $this->center = $center; + + return $this; + } } diff --git a/src/Bundle/ChillMainBundle/Resources/views/Menu/defaultMenu.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Menu/defaultMenu.html.twig index 67a32b98b..6eada4dd6 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Menu/defaultMenu.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Menu/defaultMenu.html.twig @@ -1,5 +1,5 @@ {# - * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, + * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, / * * This program is free software: you can redistribute it and/or modify @@ -17,7 +17,7 @@ #} \ No newline at end of file + diff --git a/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig b/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig index 27fc4430b..8bee2983e 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig @@ -70,6 +70,9 @@ + {{ chill_widget('homepage', {} ) }} {% endblock %} diff --git a/src/Bundle/ChillMainBundle/Tests/Services/ChillMenuTwigFunctionTest.php b/src/Bundle/ChillMainBundle/Tests/Services/ChillMenuTwigFunctionTest.php deleted file mode 100644 index a85ff9710..000000000 --- a/src/Bundle/ChillMainBundle/Tests/Services/ChillMenuTwigFunctionTest.php +++ /dev/null @@ -1,54 +0,0 @@ - - * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -namespace Chill\MainBundle\Tests\Services; - -use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; -use Symfony\Component\DomCrawler\Crawler; - -/** - * Test the Twig function 'chill_menu' - * - * @author Julien Fastré - */ -class ChillMenuTwigFunctionTest extends KernelTestCase -{ - - private static $templating; - - public static function setUpBeforeClass() - { - self::bootKernel(array('environment' => 'test')); - static::$templating = static::$container - ->get('templating'); - $pathToBundle = static::$container->getParameter('kernel.bundles_metadata')['ChillMainBundle']['path']; - //load templates in Tests/Resources/views - static::$container->get('twig.loader') - ->addPath($pathToBundle.'/Resources/test/views/', $namespace = 'tests'); - } - - public function testNormalMenu() - { - $content = static::$templating->render('@tests/menus/normalMenu.html.twig'); - $this->assertContains('ul', $content, - "test that the file contains an ul tag" - ); - } -} diff --git a/src/Bundle/ChillMainBundle/migrations/Version20211006151653.php b/src/Bundle/ChillMainBundle/migrations/Version20211006151653.php new file mode 100644 index 000000000..9f4508ba8 --- /dev/null +++ b/src/Bundle/ChillMainBundle/migrations/Version20211006151653.php @@ -0,0 +1,33 @@ +addSql('ALTER TABLE chill_main_postal_code ADD refPostalCodeId VARCHAR(255) DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_main_postal_code ADD postalCodeSource VARCHAR(255) DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_main_postal_code ADD center geometry(POINT,4326) DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_main_postal_code DROP refPostalCodeId'); + $this->addSql('ALTER TABLE chill_main_postal_code DROP postalCodeSource'); + $this->addSql('ALTER TABLE chill_main_postal_code DROP center'); + } +} diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index d99a565c1..d2add7737 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -1,7 +1,7 @@ "This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License": "Ce programme est un logiciel libre: vous pouvez le redistribuer et/ou le modifier selon les termes de la licence GNU Affero GPL" User manual: Manuel d'utilisation Search: Rechercher -'Search persons, ...': 'Recherche des personnes, ...' +"Search persons, ...": "Recherche des personnes, ..." Person name: Nom / Prénom de la personne Login: Connexion Logout: Se déconnecter @@ -33,7 +33,7 @@ Cancel: Annuler Save: Enregistrer This form contains errors: Ce formulaire contient des erreurs Choose an user: Choisir un utilisateur -'You are going to leave a page with unsubmitted data. Are you sure you want to leave ?': "Vous allez quitter la page alors que des données n'ont pas été enregistrées. Êtes vous sûr de vouloir partir ?" +"You are going to leave a page with unsubmitted data. Are you sure you want to leave ?": "Vous allez quitter la page alors que des données n'ont pas été enregistrées. Êtes vous sûr de vouloir partir ?" No value: Aucune information Last updated by: Dernière mise à jour par Last updated on: Dernière mise à jour le @@ -71,24 +71,24 @@ Postal code: Code postal Valid from: Valide à partir du Choose a postal code: Choisir un code postal address: - address_homeless: L'adresse est-elle celle d'un domicile fixe ? - real address: Adresse d'un domicile - consider homeless: N'est pas l'adresse d'un domicile (SDF) + address_homeless: L'adresse est-elle celle d'un domicile fixe ? + real address: Adresse d'un domicile + consider homeless: N'est pas l'adresse d'un domicile (SDF) address more: - floor: ét - corridor: coul - steps: esc - flat: appart - buildingName: résidence - extra: '' - distribution: cedex + floor: ét + corridor: coul + steps: esc + flat: appart + buildingName: résidence + extra: "" + distribution: cedex Create a new address: Créer une nouvelle adresse #serach Your search is empty. Please provide search terms.: La recherche est vide. Merci de fournir des termes de recherche. The domain %domain% is unknow. Please check your search.: Le domaine de recherche "%domain%" est inconnu. Merci de vérifier votre recherche. -Invalid terms : Recherche invalide -You should not have more than one domain. : Vous ne devriez pas avoir plus d'un domaine de recherche. +Invalid terms: Recherche invalide +You should not have more than one domain.: Vous ne devriez pas avoir plus d'un domaine de recherche. #used for page title Search %pattern%: Recherche de "%pattern%" Results %start%-%end% of %total%: Résultats %start%-%end% sur %total% @@ -113,9 +113,9 @@ Permissions Menu: Gestion des droits Permissions management of your chill installation: Gestion des permissions de votre instance #admin section -'Administration interface': Interface d'administration +"Administration interface": Interface d'administration Welcome to the admin section !: > - Bienvenue dans l'interface d'administration ! + Bienvenue dans l'interface d'administration ! #admin section for center's administration Create a new center: Créer un nouveau centre @@ -210,7 +210,6 @@ Problem during download: Problème durant le téléchargement # sans valeur without data: sans valeur - #CSV List Formatter Add a number on first column: La première colonne est un numéro Number: Numéro @@ -228,9 +227,9 @@ Comma separated values (CSV): Valeurs séparées par des virgules (CSV - tableur Choose the format: Choisir le format # select2 -'select2.no_results': Aucun résultat -'select2.error_loading': Erreur de chargement des résultats -'select2.searching': Recherche en cours... +"select2.no_results": Aucun résultat +"select2.error_loading": Erreur de chargement des résultats +"select2.searching": Recherche en cours... # change password Change my password: Modification du mot de passe @@ -258,38 +257,35 @@ Impersonate: Incarner l'utilisateur Impersonate mode: Mode fantôme crud: - # general items - new: - button_action_form: Créer - link_edit: Modifier - save_and_close: Créer & fermer - save_and_show: Créer & voir - save_and_new: Créer & nouveau - success: Les données ont été créées - edit: - button_action_form: Enregistrer - back_to_view: Voir - save_and_close: Enregistrer & fermer - save_and_show: Enregistrer & voir - success: Les données ont été modifiées - delete: - success: Les données ont été supprimées - link_to_form: Supprimer - default: - success: Les données ont été enregistrées - view: - link_duplicate: Dupliquer - ## admin for users - admin_user: - index: - title: Utilisateurs - add_new: "Créer" - is_active: "Actif ?" - usernames: "Identifiants" - mains: "Champs principaux" - title_new: "Nouvel utilisateur" - title_edit: Modifier un utilisateur + # general items + new: + button_action_form: Créer + link_edit: Modifier + save_and_close: Créer & fermer + save_and_show: Créer & voir + save_and_new: Créer & nouveau + success: Les données ont été créées + edit: + button_action_form: Enregistrer + back_to_view: Voir + save_and_close: Enregistrer & fermer + save_and_show: Enregistrer & voir + success: Les données ont été modifiées + delete: + success: Les données ont été supprimées + link_to_form: Supprimer + default: + success: Les données ont été enregistrées + view: + link_duplicate: Dupliquer No entities: Aucun élément CHILL_FOO_SEE: Voir un élément CHILL_FOO_EDIT: Modifier un élément + +#Show templates +Date: Date +By: Par +For: Pour +Created for: Créé pour +Created by: Créé par diff --git a/src/Bundle/ChillTaskBundle/Menu/UserMenuBuilder.php b/src/Bundle/ChillTaskBundle/Menu/UserMenuBuilder.php index 632961953..0330699ad 100644 --- a/src/Bundle/ChillTaskBundle/Menu/UserMenuBuilder.php +++ b/src/Bundle/ChillTaskBundle/Menu/UserMenuBuilder.php @@ -115,16 +115,16 @@ class UserMenuBuilder implements LocalMenuBuilderInterface 'icon' => 'tasks' ]); - $menu->addChild("My calendar list", [ - 'route' => 'chill_calendar_calendar_list', - 'routeParameters' => [ - 'user_id' => $user->getId(), - ] - ]) - ->setExtras([ - 'order' => -9, - 'icon' => 'tasks' - ]); + // $menu->addChild("My calendar list", [ + // 'route' => 'chill_calendar_calendar_list', + // 'routeParameters' => [ + // 'user_id' => $user->getId(), + // ] + // ]) + // ->setExtras([ + // 'order' => -9, + // 'icon' => 'tasks' + // ]); /* $menu->addChild("My aside activities", [