diff --git a/src/Bundle/ChillMainBundle/Controller/LocationController.php b/src/Bundle/ChillMainBundle/Controller/LocationController.php new file mode 100644 index 000000000..75bc01262 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Controller/LocationController.php @@ -0,0 +1,19 @@ +where('e.availableForUsers', "'TRUE'"); + } + + // public function createEntity(string $action, Request $request): object + // { + + // } +} diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php index 501faaf92..5574556f2 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php @@ -20,6 +20,7 @@ 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; @@ -45,8 +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\LocationType as LocationFormType; use Symfony\Component\HttpFoundation\Request; /** @@ -319,6 +322,28 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface, ] ] ], + [ + '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', diff --git a/src/Bundle/ChillMainBundle/Form/LocationType.php b/src/Bundle/ChillMainBundle/Form/LocationType.php new file mode 100644 index 000000000..5bf71734c --- /dev/null +++ b/src/Bundle/ChillMainBundle/Form/LocationType.php @@ -0,0 +1,47 @@ +translatableStringHelper = $translatableStringHelper; + // } + + public function buildForm(FormBuilderInterface $builder, array $options) + { + + $builder + ->add('name', TextType::class) + ->add('phonenumber1', TextType::class, ['required' => false]) + ->add('phonenumber2', TextType::class, ['required' => false]) + ->add('email', TextType::class, ['required' => false]) + ->add('locationType', EntityType::class, [ + 'class' => EntityLocationType::class, + 'choice_label' => function (EntityLocationType $entity) { + //return $this->translatableStringHelper->localize($entity->getTitle()); + return $entity->getTitle()['fr']; + }, + ]) + ->add('address', PickAddressType::class, [ + 'label' => 'Address', + 'use_valid_from' => false, + 'use_valid_to' => false, + 'mapped' => false, + ]); + } +} 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..0b6a0f8a1 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/Location/edit.html.twig @@ -0,0 +1,22 @@ +{% 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 %} + +{% block js %} + {{ encore_entry_script_tags('mod_input_address') }} +{% 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..a99311a9c --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/Location/index.html.twig @@ -0,0 +1,48 @@ +{% extends "@ChillAsideActivity/Admin/layout_asideactivity.html.twig" %} + +{% block admin_content %} +
{{ 'Name'|trans }} | +{{ 'phonenumber1'|trans }} | +{{ 'phonenumber2'|trans }} | +{{ 'email'|trans }} | +{{ 'address'|trans }} | +|
---|---|---|---|---|---|
{{ entity.name }} | +{{ entity.phonenumber1 }} | +{{ entity.phonenumber2 }} | +{{ entity.email }} | ++ {% if entity.address is not null %} + {{ entity.address.street}}, {{ entity.address.streetnumber }} + {% endif %} + | ++ + | +