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