diff --git a/CHANGELOG.md b/CHANGELOG.md index 6182b4d0e..936a5317d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,10 @@ and this project adheres to * [person]: accompanying course work: remove creation date display the list of work + handle case when end date is null +* [main]: Add new pages with a menu for managing location and location type in the admin +* [main]: Add some fixtures for location type +* [calendar]: Pass the location when transforming a calendar item (rdv) into an activity +* [calendar]: Add a user menu for "my calendar" ## Test releases diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index 8a4a228eb..9529d40c0 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -242,6 +242,11 @@ class ActivityController extends AbstractController } } + if (array_key_exists('location', $activityData)) { + $location = $em->getRepository(\Chill\MainBundle\Entity\Location::class)->find($activityData['location']); + $entity->setLocation($location); + } + if (array_key_exists('comment', $activityData)) { $comment = new CommentEmbeddable(); $comment->setComment($activityData['comment']); diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php index 71e461464..a62963e07 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php @@ -234,6 +234,7 @@ class CalendarController extends AbstractController 'professionalsId' => $professionalsId, 'date' => $entity->getStartDate()->format('Y-m-d'), 'durationTime' => $durationTimeInMinutes, + 'location' => $entity->getLocation()->getId(), 'comment' => $entity->getComment()->getComment(), ]; diff --git a/src/Bundle/ChillCalendarBundle/Menu/UserMenuBuilder.php b/src/Bundle/ChillCalendarBundle/Menu/UserMenuBuilder.php new file mode 100644 index 000000000..14e775234 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Menu/UserMenuBuilder.php @@ -0,0 +1,94 @@ + + * + * 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\CalendarBundle\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 Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; + + +/** + * + * @author Champs-Libres + */ +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) + { + $user = $this->tokenStorage->getToken()->getUser(); + + if ($this->authorizationChecker->isGranted('ROLE_USER')){ + $menu->addChild("My calendar list", [ + 'route' => 'chill_calendar_calendar_list', + 'routeParameters' => [ + 'user_id' => $user->getId(), + ] + ]) + ->setExtras([ + 'order' => 9, + 'icon' => 'tasks' + ]); + } + } + + public static function getMenuIds(): array + { + return [ 'user' ]; + } + +} diff --git a/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php b/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php index 9c657ae46..d3112fd97 100644 --- a/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php +++ b/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php @@ -342,13 +342,19 @@ class CRUDController extends AbstractController */ protected function buildQueryEntities(string $action, Request $request) { - return $this->getDoctrine()->getManager() + $query = $this->getDoctrine()->getManager() ->createQueryBuilder() ->select('e') ->from($this->getEntityClass(), 'e') ; + + $this->customizeQuery($action, $request, $query); + + return $query; } + protected function customizeQuery(string $action, Request $request, $query): void {} + /** * Query the entity. * diff --git a/src/Bundle/ChillMainBundle/Controller/AdminController.php b/src/Bundle/ChillMainBundle/Controller/AdminController.php index 1c6569eea..1fe10ef08 100644 --- a/src/Bundle/ChillMainBundle/Controller/AdminController.php +++ b/src/Bundle/ChillMainBundle/Controller/AdminController.php @@ -41,4 +41,9 @@ class AdminController extends AbstractController return $this->render('@ChillMain/Admin/layout_permissions.html.twig'); } + public function indexLocationsAction() + { + return $this->render('@ChillMain/Admin/layout_location.html.twig'); + } + } diff --git a/src/Bundle/ChillMainBundle/Controller/LocationApiController.php b/src/Bundle/ChillMainBundle/Controller/LocationApiController.php index 4e0e9d2d2..5c0301959 100644 --- a/src/Bundle/ChillMainBundle/Controller/LocationApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/LocationApiController.php @@ -20,7 +20,10 @@ class LocationApiController extends ApiController $query->expr()->eq('e.createdBy', ':user'), $query->expr()->gte('e.createdAt', ':dateBefore') ), - $query->expr()->eq('e.availableForUsers', "'TRUE'") + $query->expr()->andX( + $query->expr()->eq('e.availableForUsers', "'TRUE'"), + $query->expr()->eq('e.active', "'TRUE'") + ) )) ->setParameters([ 'user' => $this->getUser(), diff --git a/src/Bundle/ChillMainBundle/Controller/LocationController.php b/src/Bundle/ChillMainBundle/Controller/LocationController.php new file mode 100644 index 000000000..fb1c1c61a --- /dev/null +++ b/src/Bundle/ChillMainBundle/Controller/LocationController.php @@ -0,0 +1,23 @@ +where('e.availableForUsers = true'); //TODO not working + } + + protected function createEntity(string $action, Request $request): object + { + $entity = parent::createEntity($action, $request); + + $entity->setAvailableForUsers(true); + + return $entity; + } +} diff --git a/src/Bundle/ChillMainBundle/Controller/LocationTypeController.php b/src/Bundle/ChillMainBundle/Controller/LocationTypeController.php new file mode 100644 index 000000000..4f87cc300 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Controller/LocationTypeController.php @@ -0,0 +1,10 @@ +container = $container; + } + + public function getOrder() { + return 52; + } + + public function load(ObjectManager $manager): void { + + echo "loading some location type... \n"; + + $arr = [ + [ + 'name' => ['fr' => 'Mairie'], + 'address_required' => LocationType::STATUS_OPTIONAL + ], + [ + 'name' => ['fr' => 'Guichet d\'accueil'], + 'address_required' => LocationType::STATUS_OPTIONAL + ], + [ + 'name' => ['fr' => 'Domicile de l\'usager'], + 'address_required' => LocationType::STATUS_REQUIRED + ], + [ + 'name' => ['fr' => 'Centre d\'aide sociale'], + 'address_required' => LocationType::STATUS_OPTIONAL + ], + ]; + + foreach ($arr as $a) { + $locationType = (new LocationType()) + ->setTitle($a['name']) + ->setAvailableForUsers(true) + ->setActive(true) + ->setAddressRequired($a['address_required']); + $manager->persist($locationType); + } + + $manager->flush(); + } +} \ No newline at end of file diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php index 7ec8d3585..c90638893 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php @@ -20,6 +20,8 @@ namespace Chill\MainBundle\DependencyInjection; use Chill\MainBundle\Controller\AddressApiController; +use Chill\MainBundle\Controller\LocationController; +use Chill\MainBundle\Controller\LocationTypeController; use Chill\MainBundle\Controller\UserController; use Chill\MainBundle\Doctrine\DQL\STContains; use Chill\MainBundle\Doctrine\DQL\StrictWordSimilarityOPS; @@ -44,6 +46,10 @@ use Chill\MainBundle\Doctrine\DQL\Replace; use Chill\MainBundle\Doctrine\ORM\Hydration\FlatHierarchyEntityHydrator; use Chill\MainBundle\Doctrine\Type\NativeDateIntervalType; use Chill\MainBundle\Doctrine\Type\PointType; +use Chill\MainBundle\Entity\Location; +use Chill\MainBundle\Entity\LocationType; +use Chill\MainBundle\Form\LocationTypeType; +use Chill\MainBundle\Form\LocationFormType; use Symfony\Component\HttpFoundation\Request; /** @@ -319,7 +325,51 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface, 'template' => '@ChillMain/User/edit.html.twig' ] ] - ] + ], + [ + 'class' => Location::class, + 'name' => 'main_location', + 'base_path' => '/admin/main/location', + 'base_role' => 'ROLE_ADMIN', + 'form_class' => LocationFormType::class, + 'controller' => LocationController::class, + 'actions' => [ + 'index' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillMain/Location/index.html.twig', + ], + 'new' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillMain/Location/new.html.twig', + ], + 'edit' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillMain/Location/edit.html.twig', + ] + ] + ], + [ + 'class' => LocationType::class, + 'name' => 'main_location_type', + 'base_path' => '/admin/main/location-type', + 'base_role' => 'ROLE_ADMIN', + 'form_class' => LocationTypeType::class, + 'controller' => LocationTypeController::class, + 'actions' => [ + 'index' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillMain/LocationType/index.html.twig', + ], + 'new' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillMain/LocationType/new.html.twig', + ], + 'edit' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillMain/LocationType/edit.html.twig', + ] + ] + ], ], 'apis' => [ [ diff --git a/src/Bundle/ChillMainBundle/Entity/Location.php b/src/Bundle/ChillMainBundle/Entity/Location.php index be97a4373..06e5ccca5 100644 --- a/src/Bundle/ChillMainBundle/Entity/Location.php +++ b/src/Bundle/ChillMainBundle/Entity/Location.php @@ -76,6 +76,12 @@ class Location implements TrackCreationInterface, TrackUpdateInterface */ private bool $availableForUsers = false; + /** + * @ORM\Column(type="boolean", nullable=true) + * @Serializer\Groups({"read"}) + */ + private bool $active = true; + /** * @ORM\ManyToOne(targetEntity=User::class) * @Serializer\Groups({"read"}) @@ -192,6 +198,18 @@ class Location implements TrackCreationInterface, TrackUpdateInterface return $this; } + public function getActive(): ?bool + { + return $this->active; + } + + public function setActive(bool $active): self + { + $this->active = $active; + + return $this; + } + public function getCreatedBy(): ?User { return $this->createdBy; diff --git a/src/Bundle/ChillMainBundle/Entity/LocationType.php b/src/Bundle/ChillMainBundle/Entity/LocationType.php index 6510d5c22..026fc727d 100644 --- a/src/Bundle/ChillMainBundle/Entity/LocationType.php +++ b/src/Bundle/ChillMainBundle/Entity/LocationType.php @@ -40,6 +40,12 @@ class LocationType */ private bool $availableForUsers = true; + /** + * @ORM\Column(type="boolean", nullable=true) + * @Serializer\Groups({"read"}) + */ + private bool $active = true; + /** * @ORM\Column(type="string", length=32, options={"default"="optional"}) * @Serializer\Groups({"read"}) @@ -70,6 +76,18 @@ class LocationType return $this; } + public function getActive(): ?bool + { + return $this->active; + } + + public function setActive(bool $active): self + { + $this->active = $active; + + return $this; + } + public function getAvailableForUsers(): ?bool { return $this->availableForUsers; diff --git a/src/Bundle/ChillMainBundle/Form/LocationFormType.php b/src/Bundle/ChillMainBundle/Form/LocationFormType.php new file mode 100644 index 000000000..83d1c4242 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Form/LocationFormType.php @@ -0,0 +1,85 @@ +translatableStringHelper = $translatableStringHelper; + // } + + public function buildForm(FormBuilderInterface $builder, array $options) + { + + $builder + ->add('locationType', EntityType::class, [ + 'class' => EntityLocationType::class, + 'choice_attr' => function (EntityLocationType $entity) { + return [ + 'data-address' => $entity->getAddressRequired(), + 'data-contact' => $entity->getContactData(), + ]; + }, + 'choice_label' => function (EntityLocationType $entity) { + //return $this->translatableStringHelper->localize($entity->getTitle()); //TODO not working. Cannot pass smthg in the constructor + return $entity->getTitle()['fr']; + }, + ]) + ->add('name', TextType::class) + ->add('phonenumber1', TextType::class, ['required' => false]) + ->add('phonenumber2', TextType::class, ['required' => false]) + ->add('email', TextType::class, ['required' => false]) + ->add('address', PickAddressType::class, [ + 'required' => false, + 'label' => 'Address', + 'use_valid_from' => false, + 'use_valid_to' => false, + 'mapped' => false, + ]) + ->add('active', ChoiceType::class, + [ + 'choices' => [ + 'Yes' => true, + 'No' => false + ], + 'expanded' => true + ]); + } + + + /** + * @param OptionsResolverInterface $resolver + */ + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults(array( + 'data_class' => 'Chill\MainBundle\Entity\Location' + )); + } + + /** + * @return string + */ + public function getBlockPrefix() + { + return 'chill_mainbundle_location'; + } + +} diff --git a/src/Bundle/ChillMainBundle/Form/LocationTypeType.php b/src/Bundle/ChillMainBundle/Form/LocationTypeType.php new file mode 100644 index 000000000..dded13327 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Form/LocationTypeType.php @@ -0,0 +1,54 @@ +add('title', TranslatableStringFormType::class, + [ + 'label' => 'Name', + ]) + ->add('availableForUsers', ChoiceType::class, + [ + 'choices' => [ + 'Yes' => true, + 'No' => false + ], + 'expanded' => true + ]) + ->add('addressRequired', ChoiceType::class, + [ + 'choices' => [ + 'optional' => LocationType::STATUS_OPTIONAL, + 'required' => LocationType::STATUS_REQUIRED, + 'never' => LocationType::STATUS_NEVER, + ], + 'expanded' => true + ]) + ->add('contactData', ChoiceType::class, + [ + 'choices' => [ + 'optional' => LocationType::STATUS_OPTIONAL, + 'required' => LocationType::STATUS_REQUIRED, + 'never' => LocationType::STATUS_NEVER, + ], + 'expanded' => true + ]) + ->add('active', ChoiceType::class, + [ + 'choices' => [ + 'Yes' => true, + 'No' => false + ], + 'expanded' => true + ]); + } +} diff --git a/src/Bundle/ChillMainBundle/Resources/public/page/location/index.js b/src/Bundle/ChillMainBundle/Resources/public/page/location/index.js new file mode 100644 index 000000000..25bac1af5 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/public/page/location/index.js @@ -0,0 +1,66 @@ +const contactDataBlock = document.querySelector('div.location-form-contact'); +const addressBlock = document.querySelector('div.location-form-address'); +const locationType = document.getElementById('chill_mainbundle_location_locationType'); + +const getSelectedAttributes = + (select, attr) => select.selectedOptions[0].getAttribute(attr) + + +const removeRequired = (formBlock) => { + formBlock.querySelectorAll('label').forEach( + l => l.classList.remove('required') + ); + formBlock.querySelectorAll('input').forEach( + i => i.removeAttribute('required') + ); +} + +const addRequired = (formBlock) => { + formBlock.querySelectorAll('label').forEach( + l => l.classList.add('required') + ); + formBlock.querySelectorAll('input').forEach( + i => i.setAttribute('required', '') + ); +} + + +const onLocationTypeChange = () => { + console.log(getSelectedAttributes(locationType, 'data-address')) + console.log(getSelectedAttributes(locationType, 'data-contact')) + switch (getSelectedAttributes(locationType, 'data-address')) { + case 'optional': + default: + removeRequired(addressBlock); + addressBlock.classList.remove('d-none'); + break; + case 'required': + addRequired(addressBlock); + addressBlock.classList.remove('d-none'); + break; + case 'never': + removeRequired(addressBlock); + addressBlock.classList.add('d-none'); + break; + } + switch (getSelectedAttributes(locationType, 'data-contact')) { + case 'optional': + default: + removeRequired(contactDataBlock); + contactDataBlock.classList.remove('d-none'); + break; + case 'required': + addRequired(contactDataBlock); + contactDataBlock.classList.remove('d-none'); + break; + case 'never': + removeRequired(contactDataBlock); + contactDataBlock.classList.add('d-none'); + break; + } +}; + +document.addEventListener('DOMContentLoaded', _e => { + onLocationTypeChange(); + locationType.addEventListener('change', onLocationTypeChange); +}); diff --git a/src/Bundle/ChillMainBundle/Resources/views/Admin/layout_location.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/layout_location.html.twig new file mode 100644 index 000000000..fc0708af9 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/Admin/layout_location.html.twig @@ -0,0 +1,33 @@ +{# + * Copyright (C) 2014-2015, 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 . +#} + +{% extends "@ChillMain/Admin/layoutWithVerticalMenu.html.twig" %} + +{% block vertical_menu_content %} + {{ chill_menu('admin_location', { + 'layout': '@ChillMain/Admin/menu_admin_location.html.twig', + }) }} +{% endblock %} + + + +{% block layout_wvm_content %} + {% block admin_content %} +

{{ 'Management of location' |trans }}

+ {% endblock %} +{% endblock %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Admin/menu_admin_location.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/menu_admin_location.html.twig new file mode 100644 index 000000000..b4112ff60 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/Admin/menu_admin_location.html.twig @@ -0,0 +1,20 @@ +{# + * Copyright (C) 2014-2015, 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 . +#} + +{% extends "@ChillMain/Menu/verticalMenu.html.twig" %} +{% block v_menu_title %}{{ 'Location Menu'|trans }}{% endblock %} \ No newline at end of file diff --git a/src/Bundle/ChillMainBundle/Resources/views/Location/edit.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Location/edit.html.twig new file mode 100644 index 000000000..d34d6968f --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/Location/edit.html.twig @@ -0,0 +1,39 @@ +{% extends '@ChillMain/Admin/layout.html.twig' %} + +{% block title %} +{% include('@ChillMain/CRUD/_edit_title.html.twig') %} +{% endblock %} + +{% block admin_content %} +{% embed '@ChillMain/CRUD/_edit_content.html.twig' %} + + {% block crud_content_form_rows %} + + {{ form_row(form.locationType) }} + +
+ {{ form_row(form.address) }} +
+ + {{ form_row(form.name) }} + +
+ {{ form_row(form.phonenumber1) }} + {{ form_row(form.phonenumber2) }} + {{ form_row(form.email) }} +
+ + {% endblock crud_content_form_rows %} + + {% block content_form_actions_save_and_show %}{% endblock %} +{% endembed %} +{% endblock %} + +{% block js %} + {{ encore_entry_script_tags('mod_input_address') }} + {{ encore_entry_script_tags('page_location') }} +{% endblock %} + +{% block css %} + {{ encore_entry_link_tags('mod_input_address') }} +{% endblock %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Location/index.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Location/index.html.twig new file mode 100644 index 000000000..cc35be33a --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/Location/index.html.twig @@ -0,0 +1,56 @@ +{% extends "@ChillMain/Admin/layout_location.html.twig" %} + +{% block admin_content %} +

{{ 'Location list'|trans }}

+ + + + + + + + + + + + + + {% for entity in entities %} + + + + + + + + + + {% endfor %} + +
{{ 'Name'|trans }}{{ 'Phonenumber1'|trans }}{{ 'Phonenumber2'|trans }}{{ 'Email'|trans }}{{ 'Address'|trans }}{{ 'Active'|trans }}
{{ entity.name }}{{ entity.phonenumber1 }}{{ entity.phonenumber2 }}{{ entity.email }} + {% if entity.address is not null %} + {{ entity.address.street}}, {{ entity.address.streetnumber }} + {% endif %} + + {%- if entity.active -%} + + {%- else -%} + + {%- endif -%} + +
    +
  • + +
  • +
+
+ + +{% endblock %} + diff --git a/src/Bundle/ChillMainBundle/Resources/views/Location/new.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Location/new.html.twig new file mode 100644 index 000000000..ba25a05e0 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/Location/new.html.twig @@ -0,0 +1,39 @@ +{% extends '@ChillMain/Admin/layout.html.twig' %} + +{% block title %} +{% include('@ChillMain/CRUD/_new_title.html.twig') %} +{% endblock %} + +{% block admin_content %} +{% embed '@ChillMain/CRUD/_new_content.html.twig' %} + + {% block crud_content_form_rows %} + + {{ form_row(form.locationType) }} + +
+ {{ form_row(form.address) }} +
+ + {{ form_row(form.name) }} + +
+ {{ form_row(form.phonenumber1) }} + {{ form_row(form.phonenumber2) }} + {{ form_row(form.email) }} +
+ + {% endblock crud_content_form_rows %} + + {% block content_form_actions_save_and_show %}{% endblock %} +{% endembed %} +{% endblock %} + +{% block js %} + {{ encore_entry_script_tags('mod_input_address') }} + {{ encore_entry_script_tags('page_location') }} +{% endblock %} + +{% block css %} + {{ encore_entry_link_tags('mod_input_address') }} +{% endblock %} \ No newline at end of file diff --git a/src/Bundle/ChillMainBundle/Resources/views/LocationType/edit.html.twig b/src/Bundle/ChillMainBundle/Resources/views/LocationType/edit.html.twig new file mode 100644 index 000000000..ad0a38f73 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/LocationType/edit.html.twig @@ -0,0 +1,14 @@ +{% extends '@ChillMain/Admin/layout.html.twig' %} + +{% block title %} +{% include('@ChillMain/CRUD/_edit_title.html.twig') %} +{% endblock %} + +{% block admin_content %} +{# {% as we are in the admin layout, we override the admin content with the CRUD content %} #} +{% embed '@ChillMain/CRUD/_edit_content.html.twig' %} + {# we do not have "view" page. We empty the corresponding block #} + {% block content_form_actions_view %}{% endblock %} + {% block content_form_actions_save_and_show %}{% endblock %} +{% endembed %} +{% endblock %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/LocationType/index.html.twig b/src/Bundle/ChillMainBundle/Resources/views/LocationType/index.html.twig new file mode 100644 index 000000000..ec617c6c0 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/LocationType/index.html.twig @@ -0,0 +1,55 @@ +{% extends "@ChillMain/Admin/layout_location.html.twig" %} + +{% block admin_content %} +

{{ 'Location type list'|trans }}

+ + + + + + + + + + + + + {% for entity in entities %} + + + + + + + + + {% endfor %} + +
{{ 'Title'|trans }}{{ 'Available for users'|trans }}{{ 'Address required'|trans }}{{ 'Contact data'|trans }}{{ 'Active'|trans }}
{{ entity.title | localize_translatable_string }} + {%- if entity.availableForUsers -%} + + {%- else -%} + + {%- endif -%} + {{ entity.addressRequired|trans }}{{ entity.contactData|trans }} + {%- if entity.active -%} + + {%- else -%} + + {%- endif -%} + +
    +
  • + +
  • +
+
+ + +{% endblock %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/LocationType/new.html.twig b/src/Bundle/ChillMainBundle/Resources/views/LocationType/new.html.twig new file mode 100644 index 000000000..0781272a1 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/LocationType/new.html.twig @@ -0,0 +1,11 @@ +{% extends '@ChillMain/Admin/layout.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 %} \ No newline at end of file diff --git a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/AdminSectionMenuBuilder.php b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/AdminSectionMenuBuilder.php index b943ce8da..7f41dbf67 100644 --- a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/AdminSectionMenuBuilder.php +++ b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/AdminSectionMenuBuilder.php @@ -54,6 +54,15 @@ class AdminSectionMenuBuilder implements LocalMenuBuilderInterface 'order' => 200, 'explain' => "Configure permissions for users" ]); + + $menu->addChild('Location and location type', [ + 'route' => 'chill_main_admin_locations' + ]) + ->setExtras([ + 'icons' => ['key'], + 'order' => 205, + 'explain' => "Configure location and location type" + ]); } public static function getMenuIds(): array diff --git a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/LocationMenuBuilder.php b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/LocationMenuBuilder.php new file mode 100644 index 000000000..890c1b2ef --- /dev/null +++ b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/LocationMenuBuilder.php @@ -0,0 +1,28 @@ +addChild('Location type list', [ + 'route' => 'chill_crud_main_location_type_index' + ])->setExtras(['order' => 205]); + + $menu->addChild('Location list', [ + 'route' => 'chill_crud_main_location_index' + ])->setExtras(['order' => 206]); + } +} diff --git a/src/Bundle/ChillMainBundle/chill.webpack.config.js b/src/Bundle/ChillMainBundle/chill.webpack.config.js index 733899c19..68e704d9c 100644 --- a/src/Bundle/ChillMainBundle/chill.webpack.config.js +++ b/src/Bundle/ChillMainBundle/chill.webpack.config.js @@ -51,6 +51,7 @@ module.exports = function(encore, entries) // Page entrypoints encore.addEntry('page_login', __dirname + '/Resources/public/page/login/index.js'); + encore.addEntry('page_location', __dirname + '/Resources/public/page/location/index.js'); buildCKEditor(encore); diff --git a/src/Bundle/ChillMainBundle/config/routes.yaml b/src/Bundle/ChillMainBundle/config/routes.yaml index 9a155f6e6..bebdf8f52 100644 --- a/src/Bundle/ChillMainBundle/config/routes.yaml +++ b/src/Bundle/ChillMainBundle/config/routes.yaml @@ -66,6 +66,10 @@ chill_main_admin_permissions: path: /{_locale}/admin/permissions controller: Chill\MainBundle\Controller\AdminController::indexPermissionsAction +chill_main_admin_locations: + path: /{_locale}/admin/locations + controller: Chill\MainBundle\Controller\AdminController::indexLocationsAction + chill_main_search: path: /{_locale}/search.{_format} controller: Chill\MainBundle\Controller\SearchController::searchAction diff --git a/src/Bundle/ChillMainBundle/config/services/form.yaml b/src/Bundle/ChillMainBundle/config/services/form.yaml index f2e5b1fc4..b3eb0ca98 100644 --- a/src/Bundle/ChillMainBundle/config/services/form.yaml +++ b/src/Bundle/ChillMainBundle/config/services/form.yaml @@ -137,3 +137,7 @@ services: Chill\MainBundle\Form\DataTransform\AddressToIdDataTransformer: autoconfigure: true autowire: true + + Chill\MainBundle\Form\Type\LocationFormType: + autowire: true + autoconfigure: true \ No newline at end of file diff --git a/src/Bundle/ChillMainBundle/migrations/Version20211022094429.php b/src/Bundle/ChillMainBundle/migrations/Version20211022094429.php new file mode 100644 index 000000000..1bc4f68d0 --- /dev/null +++ b/src/Bundle/ChillMainBundle/migrations/Version20211022094429.php @@ -0,0 +1,31 @@ +addSql('ALTER TABLE chill_main_location ADD active BOOLEAN DEFAULT TRUE;'); + $this->addSql('ALTER TABLE chill_main_location_type ADD active BOOLEAN DEFAULT TRUE;'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_main_location_type DROP active'); + $this->addSql('ALTER TABLE chill_main_location DROP active'); + } +} diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index c026571d1..7737e1d04 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -110,11 +110,16 @@ edit: modifier Main admin menu: Menu d'administration principal Actions: Actions Users and permissions: Utilisateurs et permissions +Location and location type: Localisations et types de localisation #permissions Permissions Menu: Gestion des droits Permissions management of your chill installation: Gestion des permissions de votre instance +#location +Location Menu: Localisations et types de localisation +Management of location: Gestion des localisations et types de localisation + #admin section "Administration interface": Interface d'administration Welcome to the admin section !: > @@ -180,6 +185,24 @@ Circle edit: Modification du cercle Circle creation: Création d'un cercle Create a new circle: Créer un nouveau cercle +#admin section for location +Location: Localisation +Location type list: Liste des types de localisation +Create a new location type: Créer un nouveau type de localisation +Available for users: Disponible aux utilisateurs +Address required: Adresse requise? +Contact data: Données de contact? +optional: optionnel +required: requis +never: jamais +Create a new location: Créer une nouvelle localisation +Location list: Liste des localisations +Location type: Type de localisation +Phonenumber1: Numéro de téléphone +Phonenumber2: Autre numéro de téléphone +Configure location: Configuration des localisations +Configure location type: Configuration des types de localisations + # circles / scopes Choose the circle: Choisir le cercle @@ -294,6 +317,12 @@ crud: add_new: Créer title_new: Nouveau métier title_edit: Modifier un métier + main_location_type: + title_new: Nouveau type de localisation + title_edit: Modifier un type de localisation + main_location: + title_new: Nouvelle localisation + title_edit: Modifier une localisation No entities: Aucun élément diff --git a/src/Bundle/ChillTaskBundle/Menu/UserMenuBuilder.php b/src/Bundle/ChillTaskBundle/Menu/UserMenuBuilder.php index 0330699ad..e5841c849 100644 --- a/src/Bundle/ChillTaskBundle/Menu/UserMenuBuilder.php +++ b/src/Bundle/ChillTaskBundle/Menu/UserMenuBuilder.php @@ -115,26 +115,6 @@ 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 aside activities", [ - 'route' => 'chill_crud_aside_activity_index' - ]) - ->setExtras([ - 'order' => -10, - 'icon' => 'tasks' - ]); - */ } protected function addItemInMenu(MenuItem $menu, User $u, $message, $title, $status, $number, $order)