From 4c99abd6d3d15d8cfc63a98c711e9c2805d3e611 Mon Sep 17 00:00:00 2001 From: nobohan Date: Mon, 2 May 2022 16:51:41 +0200 Subject: [PATCH] Admin: Add country and languages to the admin --- .../Controller/AdminController.php | 5 ++ .../Controller/CountryController.php | 27 ++++++++ .../Controller/LanguageController.php | 27 ++++++++ .../ChillMainExtension.php | 61 +++++++++++++++++-- .../ChillMainBundle/Form/CountryType.php | 32 ++++++++++ .../ChillMainBundle/Form/LanguageType.php | 32 ++++++++++ .../views/Admin/Country/edit.html.twig | 7 +++ .../views/Admin/Country/index.html.twig | 28 +++++++++ .../views/Admin/Language/edit.html.twig | 7 +++ .../views/Admin/Language/index.html.twig | 27 ++++++++ .../views/{ => Admin}/Location/edit.html.twig | 0 .../{ => Admin}/Location/index.html.twig | 0 .../views/{ => Admin}/Location/new.html.twig | 0 .../{ => Admin}/LocationType/edit.html.twig | 0 .../{ => Admin}/LocationType/index.html.twig | 0 .../{ => Admin}/LocationType/new.html.twig | 0 .../Admin/layout_language_country.html.twig | 33 ++++++++++ .../menu_admin_language_country.html.twig | 20 ++++++ .../translations/messages.fr.yml | 18 ++++++ 19 files changed, 318 insertions(+), 6 deletions(-) create mode 100644 src/Bundle/ChillMainBundle/Controller/CountryController.php create mode 100644 src/Bundle/ChillMainBundle/Controller/LanguageController.php create mode 100644 src/Bundle/ChillMainBundle/Form/CountryType.php create mode 100644 src/Bundle/ChillMainBundle/Form/LanguageType.php create mode 100644 src/Bundle/ChillMainBundle/Resources/views/Admin/Country/edit.html.twig create mode 100644 src/Bundle/ChillMainBundle/Resources/views/Admin/Country/index.html.twig create mode 100644 src/Bundle/ChillMainBundle/Resources/views/Admin/Language/edit.html.twig create mode 100644 src/Bundle/ChillMainBundle/Resources/views/Admin/Language/index.html.twig rename src/Bundle/ChillMainBundle/Resources/views/{ => Admin}/Location/edit.html.twig (100%) rename src/Bundle/ChillMainBundle/Resources/views/{ => Admin}/Location/index.html.twig (100%) rename src/Bundle/ChillMainBundle/Resources/views/{ => Admin}/Location/new.html.twig (100%) rename src/Bundle/ChillMainBundle/Resources/views/{ => Admin}/LocationType/edit.html.twig (100%) rename src/Bundle/ChillMainBundle/Resources/views/{ => Admin}/LocationType/index.html.twig (100%) rename src/Bundle/ChillMainBundle/Resources/views/{ => Admin}/LocationType/new.html.twig (100%) create mode 100644 src/Bundle/ChillMainBundle/Resources/views/Admin/layout_language_country.html.twig create mode 100644 src/Bundle/ChillMainBundle/Resources/views/Admin/menu_admin_language_country.html.twig diff --git a/src/Bundle/ChillMainBundle/Controller/AdminController.php b/src/Bundle/ChillMainBundle/Controller/AdminController.php index efde1ae20..2055f0f22 100644 --- a/src/Bundle/ChillMainBundle/Controller/AdminController.php +++ b/src/Bundle/ChillMainBundle/Controller/AdminController.php @@ -24,6 +24,11 @@ class AdminController extends AbstractController return $this->render('@ChillMain/Admin/index.html.twig'); } + public function indexLanguageCountryAction() + { + return $this->render('@ChillMain/Admin/layout_language_country.html.twig'); + } + public function indexLocationsAction() { return $this->render('@ChillMain/Admin/layout_location.html.twig'); diff --git a/src/Bundle/ChillMainBundle/Controller/CountryController.php b/src/Bundle/ChillMainBundle/Controller/CountryController.php new file mode 100644 index 000000000..351a8d4c3 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Controller/CountryController.php @@ -0,0 +1,27 @@ +addOrderBy('e.countryCode', 'ASC'); + + return parent::orderQuery($action, $query, $request, $paginator); + } + +} diff --git a/src/Bundle/ChillMainBundle/Controller/LanguageController.php b/src/Bundle/ChillMainBundle/Controller/LanguageController.php new file mode 100644 index 000000000..33d88ab0e --- /dev/null +++ b/src/Bundle/ChillMainBundle/Controller/LanguageController.php @@ -0,0 +1,27 @@ +addOrderBy('e.id', 'ASC'); + + return parent::orderQuery($action, $query, $request, $paginator); + } + +} diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php index 62a3d80d8..02c8589c8 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php @@ -13,6 +13,7 @@ namespace Chill\MainBundle\DependencyInjection; use Chill\MainBundle\Controller\AddressApiController; use Chill\MainBundle\Controller\CivilityApiController; +use Chill\MainBundle\Controller\CountryController; use Chill\MainBundle\Controller\LocationController; use Chill\MainBundle\Controller\LocationTypeController; use Chill\MainBundle\Controller\UserController; @@ -30,10 +31,14 @@ use Chill\MainBundle\Doctrine\DQL\Unaccent; use Chill\MainBundle\Doctrine\ORM\Hydration\FlatHierarchyEntityHydrator; use Chill\MainBundle\Doctrine\Type\NativeDateIntervalType; use Chill\MainBundle\Doctrine\Type\PointType; +use Chill\MainBundle\Entity\Country; +use Chill\MainBundle\Entity\Language; use Chill\MainBundle\Entity\Location; use Chill\MainBundle\Entity\LocationType; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\UserJob; +use Chill\MainBundle\Form\CountryType; +use Chill\MainBundle\Form\LanguageType; use Chill\MainBundle\Form\LocationFormType; use Chill\MainBundle\Form\LocationTypeType; use Chill\MainBundle\Form\UserJobType; @@ -348,15 +353,15 @@ class ChillMainExtension extends Extension implements 'actions' => [ 'index' => [ 'role' => 'ROLE_ADMIN', - 'template' => '@ChillMain/Location/index.html.twig', + 'template' => '@ChillMain/Admin/Location/index.html.twig', ], 'new' => [ 'role' => 'ROLE_ADMIN', - 'template' => '@ChillMain/Location/new.html.twig', + 'template' => '@ChillMain/Admin/Location/new.html.twig', ], 'edit' => [ 'role' => 'ROLE_ADMIN', - 'template' => '@ChillMain/Location/edit.html.twig', + 'template' => '@ChillMain/Admin/Location/edit.html.twig', ], ], ], @@ -370,15 +375,59 @@ class ChillMainExtension extends Extension implements 'actions' => [ 'index' => [ 'role' => 'ROLE_ADMIN', - 'template' => '@ChillMain/LocationType/index.html.twig', + 'template' => '@ChillMain/Admin/LocationType/index.html.twig', ], 'new' => [ 'role' => 'ROLE_ADMIN', - 'template' => '@ChillMain/LocationType/new.html.twig', + 'template' => '@ChillMain/Admin/LocationType/new.html.twig', ], 'edit' => [ 'role' => 'ROLE_ADMIN', - 'template' => '@ChillMain/LocationType/edit.html.twig', + 'template' => '@ChillMain/Admin/LocationType/edit.html.twig', + ], + ], + ], + [ + 'class' => Country::class, + 'name' => 'main_country', + 'base_path' => '/admin/main/country', + 'base_role' => 'ROLE_ADMIN', + 'form_class' => CountryType::class, + 'controller' => CountryController::class, + 'actions' => [ + 'index' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillMain/Admin/Country/index.html.twig', + ], + 'new' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillMain/Admin/Country/edit.html.twig', + ], + 'edit' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillMain/Admin/Country/edit.html.twig', + ], + ], + ], + [ + 'class' => Language::class, + 'name' => 'main_language', + 'base_path' => '/admin/main/language', + 'base_role' => 'ROLE_ADMIN', + 'form_class' => LanguageType::class, + 'controller' => LanguageController::class, + 'actions' => [ + 'index' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillMain/Admin/Language/index.html.twig', + ], + 'new' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillMain/Admin/Language/edit.html.twig', + ], + 'edit' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillMain/Admin/Language/edit.html.twig', ], ], ], diff --git a/src/Bundle/ChillMainBundle/Form/CountryType.php b/src/Bundle/ChillMainBundle/Form/CountryType.php new file mode 100644 index 000000000..2eb979d85 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Form/CountryType.php @@ -0,0 +1,32 @@ +add('name', TranslatableStringFormType::class, [ + 'label' => 'Name', + 'required' => true, + ]) + ->add('countryCode', TextType::class, [ + 'label' => 'Country code', + 'required' => true, + ]); + } +} diff --git a/src/Bundle/ChillMainBundle/Form/LanguageType.php b/src/Bundle/ChillMainBundle/Form/LanguageType.php new file mode 100644 index 000000000..cb48d15ca --- /dev/null +++ b/src/Bundle/ChillMainBundle/Form/LanguageType.php @@ -0,0 +1,32 @@ +add('id', TextType::class, [ + 'label' => 'Id', + 'required' => true, + ]) + ->add('name', TranslatableStringFormType::class, [ + 'label' => 'Name', + 'required' => true, + ]); + } +} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Admin/Country/edit.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/Country/edit.html.twig new file mode 100644 index 000000000..1160220a3 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/Admin/Country/edit.html.twig @@ -0,0 +1,7 @@ +{% extends '@ChillMain/CRUD/Admin/index.html.twig' %} + +{% block content -%} + {% embed '@ChillMain/CRUD/_edit_content.html.twig' %} + {% block content_form_actions_save_and_show %}{% endblock %} + {% endembed %} +{% endblock content %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Admin/Country/index.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/Country/index.html.twig new file mode 100644 index 000000000..6e1279701 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/Admin/Country/index.html.twig @@ -0,0 +1,28 @@ +{% extends '@ChillMain/CRUD/Admin/index.html.twig' %} + +{% block content %} + {% embed '@ChillMain/CRUD/_index.html.twig' %} + {% block table_entities_thead_tr %} + id + name + countryCode + {% endblock %} + {% block table_entities_tbody %} + {% for entity in entities %} + + {{ entity.id }} + {{ entity.name|localize_translatable_string }} + {{ entity.countrycode }} + + + + + {% endfor %} + {% endblock %} + {% endembed %} +{% endblock content %} + diff --git a/src/Bundle/ChillMainBundle/Resources/views/Admin/Language/edit.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/Language/edit.html.twig new file mode 100644 index 000000000..1160220a3 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/Admin/Language/edit.html.twig @@ -0,0 +1,7 @@ +{% extends '@ChillMain/CRUD/Admin/index.html.twig' %} + +{% block content -%} + {% embed '@ChillMain/CRUD/_edit_content.html.twig' %} + {% block content_form_actions_save_and_show %}{% endblock %} + {% endembed %} +{% endblock content %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Admin/Language/index.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/Language/index.html.twig new file mode 100644 index 000000000..92e9ce8f5 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/Admin/Language/index.html.twig @@ -0,0 +1,27 @@ +{% extends '@ChillMain/CRUD/Admin/index.html.twig' %} + +{% block content %} + {% embed '@ChillMain/CRUD/_index.html.twig' %} + {% block table_entities_thead_tr %} + id + name +   + {% endblock %} + {% block table_entities_tbody %} + {% for entity in entities %} + + {{ entity.id }} + {{ entity.name|localize_translatable_string }} + + + + + {% endfor %} + {% endblock %} + {% endembed %} +{% endblock content %} + diff --git a/src/Bundle/ChillMainBundle/Resources/views/Location/edit.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/Location/edit.html.twig similarity index 100% rename from src/Bundle/ChillMainBundle/Resources/views/Location/edit.html.twig rename to src/Bundle/ChillMainBundle/Resources/views/Admin/Location/edit.html.twig diff --git a/src/Bundle/ChillMainBundle/Resources/views/Location/index.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/Location/index.html.twig similarity index 100% rename from src/Bundle/ChillMainBundle/Resources/views/Location/index.html.twig rename to src/Bundle/ChillMainBundle/Resources/views/Admin/Location/index.html.twig diff --git a/src/Bundle/ChillMainBundle/Resources/views/Location/new.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/Location/new.html.twig similarity index 100% rename from src/Bundle/ChillMainBundle/Resources/views/Location/new.html.twig rename to src/Bundle/ChillMainBundle/Resources/views/Admin/Location/new.html.twig diff --git a/src/Bundle/ChillMainBundle/Resources/views/LocationType/edit.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/LocationType/edit.html.twig similarity index 100% rename from src/Bundle/ChillMainBundle/Resources/views/LocationType/edit.html.twig rename to src/Bundle/ChillMainBundle/Resources/views/Admin/LocationType/edit.html.twig diff --git a/src/Bundle/ChillMainBundle/Resources/views/LocationType/index.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/LocationType/index.html.twig similarity index 100% rename from src/Bundle/ChillMainBundle/Resources/views/LocationType/index.html.twig rename to src/Bundle/ChillMainBundle/Resources/views/Admin/LocationType/index.html.twig diff --git a/src/Bundle/ChillMainBundle/Resources/views/LocationType/new.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/LocationType/new.html.twig similarity index 100% rename from src/Bundle/ChillMainBundle/Resources/views/LocationType/new.html.twig rename to src/Bundle/ChillMainBundle/Resources/views/Admin/LocationType/new.html.twig diff --git a/src/Bundle/ChillMainBundle/Resources/views/Admin/layout_language_country.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/layout_language_country.html.twig new file mode 100644 index 000000000..b76e60861 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/Admin/layout_language_country.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_language_country', { + 'layout': '@ChillMain/Admin/menu_admin_language_country.html.twig', + }) }} +{% endblock %} + + + +{% block layout_wvm_content %} + {% block admin_content %} +

{{ 'Management of languages and countries' |trans }}

+ {% endblock %} +{% endblock %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Admin/menu_admin_language_country.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/menu_admin_language_country.html.twig new file mode 100644 index 000000000..e6b4fa5fe --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/Admin/menu_admin_language_country.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 %}{{ 'Language and countries menu'|trans }}{% 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 452ad306c..0d164075b 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -223,6 +223,12 @@ none: aucun person: usager thirdparty: tiers + +#admin section for language and country +Language and countries menu: Menu Langues & Pays +Management of languages and countries: Gestion des langues & Pays + + # circles / scopes Choose the circle: Choisir le cercle Scopes: Services @@ -344,6 +350,18 @@ crud: main_location: title_new: Nouvelle localisation title_edit: Modifier une localisation + main_language: + index: + title: Liste des langues + add_new: Ajouter une langue + title_new: Nouvelle langue + title_edit: Modifier une langue + main_country: + index: + title: Liste des pays + add_new: Ajouter un pays + title_new: Nouveau pays + title_edit: Modifier un pays No entities: Aucun élément