diff --git a/src/Bundle/ChillThirdPartyBundle/Controller/ThirdPartyCategoryController.php b/src/Bundle/ChillThirdPartyBundle/Controller/ThirdPartyCategoryController.php new file mode 100644 index 000000000..1e0bcc508 --- /dev/null +++ b/src/Bundle/ChillThirdPartyBundle/Controller/ThirdPartyCategoryController.php @@ -0,0 +1,26 @@ +addOrderBy('e.id', 'ASC'); + + return parent::orderQuery($action, $query, $request, $paginator); + } +} diff --git a/src/Bundle/ChillThirdPartyBundle/DependencyInjection/ChillThirdPartyExtension.php b/src/Bundle/ChillThirdPartyBundle/DependencyInjection/ChillThirdPartyExtension.php index d2023fae5..03a3daf5f 100644 --- a/src/Bundle/ChillThirdPartyBundle/DependencyInjection/ChillThirdPartyExtension.php +++ b/src/Bundle/ChillThirdPartyBundle/DependencyInjection/ChillThirdPartyExtension.php @@ -11,8 +11,11 @@ declare(strict_types=1); namespace Chill\ThirdPartyBundle\DependencyInjection; +use Chill\ThirdPartyBundle\Controller\ThirdPartyCategoryController; use Chill\ThirdPartyBundle\Controller\ThirdPartyController; use Chill\ThirdPartyBundle\Entity\ThirdParty; +use Chill\ThirdPartyBundle\Entity\ThirdPartyCategory; +use Chill\ThirdPartyBundle\Form\ThirdPartyCategoryType; use Chill\ThirdPartyBundle\Form\ThirdPartyType; use Chill\ThirdPartyBundle\Security\Voter\ThirdPartyVoter; use Symfony\Component\Config\FileLocator; @@ -100,6 +103,27 @@ class ChillThirdPartyExtension extends Extension implements PrependExtensionInte ], ], ], + [ + 'class' => ThirdPartyCategory::class, + 'name' => 'thirdparty_thirdparty-category', + 'base_path' => '/admin/thirdparty/thirdparty-category', + 'form_class' => ThirdPartyCategoryType::class, + 'controller' => ThirdPartyCategoryController::class, + 'actions' => [ + 'index' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillThirdParty/ThirdPartyCategory/index.html.twig', + ], + 'new' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillThirdParty/ThirdPartyCategory/new.html.twig', + ], + 'edit' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillThirdParty/ThirdPartyCategory/edit.html.twig', + ], + ], + ], ], 'apis' => [ [ diff --git a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyCategoryType.php b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyCategoryType.php new file mode 100644 index 000000000..ec1152710 --- /dev/null +++ b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyCategoryType.php @@ -0,0 +1,37 @@ +add('name', TranslatableStringFormType::class) + ->add('active', CheckboxType::class, [ + 'required' => false, + ]); + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver + ->setDefault('class', ThirdPartyCategory::class); + } +} diff --git a/src/Bundle/ChillThirdPartyBundle/Menu/AdminMenuBuilder.php b/src/Bundle/ChillThirdPartyBundle/Menu/AdminMenuBuilder.php new file mode 100644 index 000000000..ec44d8339 --- /dev/null +++ b/src/Bundle/ChillThirdPartyBundle/Menu/AdminMenuBuilder.php @@ -0,0 +1,49 @@ +authorizationChecker = $authorizationChecker; + } + + public function buildMenu($menuId, MenuItem $menu, array $parameters) + { + if (!$this->authorizationChecker->isGranted('ROLE_ADMIN')) { + return; + } + + $menu->addChild('Third party') + ->setAttribute('class', 'list-group-item-header') + ->setExtras(['order' => 3000, 'header' => true]); + + $menu->addChild('Third party category', [ + 'route' => 'chill_crud_thirdparty_thirdparty-category_index', + ])->setExtras(['order' => 3010]); + } + + public static function getMenuIds(): array + { + return ['admin_section']; + } +} diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdPartyCategory/edit.html.twig b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdPartyCategory/edit.html.twig new file mode 100644 index 000000000..28678bf6d --- /dev/null +++ b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdPartyCategory/edit.html.twig @@ -0,0 +1,11 @@ +{% extends '@ChillMain/CRUD/Admin/index.html.twig' %} + +{% block title %} + {% include('@ChillMain/CRUD/_edit_title.html.twig') %} +{% endblock %} + +{% block admin_content %} + {% embed '@ChillMain/CRUD/_edit_content.html.twig' %} + {% block content_form_actions_save_and_show %}{% endblock %} + {% endembed %} +{% endblock admin_content %} \ No newline at end of file diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdPartyCategory/index.html.twig b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdPartyCategory/index.html.twig new file mode 100644 index 000000000..c70688404 --- /dev/null +++ b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdPartyCategory/index.html.twig @@ -0,0 +1,41 @@ +{% extends '@ChillMain/CRUD/Admin/index.html.twig' %} + +{% block admin_content %} + {% embed '@ChillMain/CRUD/_index.html.twig' %} + {% block table_entities_thead_tr %} + {{ 'Id'|trans }} + {{ 'Name'|trans }} + {{ 'active'|trans }} +   + {% endblock %} + + {% block table_entities_tbody %} + {% for entity in entities %} + + {{ entity.id }} + {{ entity.name|localize_translatable_string }} + + {%- if entity.active -%} + + {%- else -%} + + {%- endif -%} + + + + + + {% endfor %} + {% endblock %} + + {% block actions_before %} +
  • + {{'Back to the admin'|trans}} +
  • + {% endblock %} + {% endembed %} +{% endblock %} \ No newline at end of file diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdPartyCategory/new.html.twig b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdPartyCategory/new.html.twig new file mode 100644 index 000000000..3a28dd85f --- /dev/null +++ b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdPartyCategory/new.html.twig @@ -0,0 +1,12 @@ +{% extends '@ChillMain/CRUD/Admin/index.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 admin_content %} + diff --git a/src/Bundle/ChillThirdPartyBundle/config/services/menu.yaml b/src/Bundle/ChillThirdPartyBundle/config/services/menu.yaml index 4b6ffd83f..cacd1124b 100644 --- a/src/Bundle/ChillThirdPartyBundle/config/services/menu.yaml +++ b/src/Bundle/ChillThirdPartyBundle/config/services/menu.yaml @@ -1,4 +1,10 @@ services: + Chill\ThirdPartyBundle\Menu\: + autowire: true + autoconfigure: true + resource: '../../Menu/' + tags: ['chill.menu_builder'] + Chill\ThirdPartyBundle\Menu\MenuBuilder: arguments: $translator: '@Symfony\Contracts\Translation\TranslatorInterface' diff --git a/src/Bundle/ChillThirdPartyBundle/translations/messages.fr.yml b/src/Bundle/ChillThirdPartyBundle/translations/messages.fr.yml index e1962b94a..8c2a9d856 100644 --- a/src/Bundle/ChillThirdPartyBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillThirdPartyBundle/translations/messages.fr.yml @@ -76,6 +76,10 @@ The party is visible in those centers: Le tiers est visible dans ces centres The party is not visible in any center: Le tiers n'est associé à aucun centre No third parties: Aucun tiers +Thirdparty handling: Tiers traitant +Thirdparty workers: Tiers intervenants +Third party category: Catégories de tiers + # ROLES CHILL_3PARTY_3PARTY_CREATE: Ajouter un Tiers CHILL_3PARTY_3PARTY_SHOW: Voir un Tiers @@ -86,6 +90,10 @@ crud: 3party_3party: index: add_new: Créer + thirdparty_thirdparty-category: + index: + title: Liste des catégories de tiers + add_new: Ajouter une nouvelle + title_new: Nouvelle catégorie de tiers + title_edit: Modifier la catégorie de tiers -Thirdparty handling: Tiers traitant -Thirdparty workers: Tiers intervenants