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 %} +

{{ 'Location list'|trans }}

+ + + + + + + + + + + + + {% for entity in entities %} + + + + + + + + + {% endfor %} + +
{{ '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 %} + +
    +
  • + +
  • +
+
+ + +{% 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..1177169a1 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/Location/new.html.twig @@ -0,0 +1,19 @@ +{% 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 %} + +{% block js %} + {{ encore_entry_script_tags('mod_input_address') }} +{% endblock %} + +{% block css %} + {{ encore_entry_link_tags('mod_input_address') }} +{% endblock %} \ No newline at end of file diff --git a/src/Bundle/ChillMainBundle/config/services/form.yaml b/src/Bundle/ChillMainBundle/config/services/form.yaml index f2e5b1fc4..f7c65b234 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\LocationType: + autowire: true + autoconfigure: true \ No newline at end of file diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index e2be1734f..24249053e 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -182,13 +182,15 @@ Create a new circle: Créer un nouveau cercle #admin section for location Location type list: Liste des types de localisation -Create a new location type: Créer un nouveau type de lieu +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 # circles / scopes Choose the circle: Choisir le cercle @@ -307,6 +309,9 @@ crud: 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