From 92843677f9d3abc2f0785fa169d6ae72eb3eb58f Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 21 Oct 2021 16:30:37 +0200 Subject: [PATCH] location admin: add admin crud for location type --- .../Controller/LocationTypeController.php | 10 ++++ .../ChillMainExtension.php | 27 ++++++++++- .../ChillMainBundle/Form/LocationTypeType.php | 46 ++++++++++++++++++ .../views/LocationType/edit.html.twig | 14 ++++++ .../views/LocationType/index.html.twig | 47 +++++++++++++++++++ .../views/LocationType/new.html.twig | 11 +++++ .../translations/messages.fr.yml | 13 +++++ 7 files changed, 167 insertions(+), 1 deletion(-) create mode 100644 src/Bundle/ChillMainBundle/Controller/LocationTypeController.php create mode 100644 src/Bundle/ChillMainBundle/Form/LocationTypeType.php create mode 100644 src/Bundle/ChillMainBundle/Resources/views/LocationType/edit.html.twig create mode 100644 src/Bundle/ChillMainBundle/Resources/views/LocationType/index.html.twig create mode 100644 src/Bundle/ChillMainBundle/Resources/views/LocationType/new.html.twig 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 @@ + '@ChillMain/User/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/Form/LocationTypeType.php b/src/Bundle/ChillMainBundle/Form/LocationTypeType.php new file mode 100644 index 000000000..a720c6f8d --- /dev/null +++ b/src/Bundle/ChillMainBundle/Form/LocationTypeType.php @@ -0,0 +1,46 @@ +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 + ]); + } +} 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..16d264097 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/LocationType/index.html.twig @@ -0,0 +1,47 @@ +{% extends "@ChillAsideActivity/Admin/layout_asideactivity.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 }}
{{ entity.title | localize_translatable_string }} + {%- if entity.availableForUsers -%} + + {%- else -%} + + {%- endif -%} + {{ entity.addressRequired|trans }}{{ entity.contactData|trans }} +
    +
  • + +
  • +
+
+ + +{% 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/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index c026571d1..e2be1734f 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -180,6 +180,16 @@ 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 type list: Liste des types de localisation +Create a new location type: Créer un nouveau type de lieu +Available for users: Disponible aux utilisateurs +Address required: Adresse requise? +Contact data: Données de contact? +optional: optionnel +required: requis +never: jamais + # circles / scopes Choose the circle: Choisir le cercle @@ -294,6 +304,9 @@ 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 No entities: Aucun élément