diff --git a/.changes/unreleased/Feature-20251007-155945.yaml b/.changes/unreleased/Feature-20251007-155945.yaml new file mode 100644 index 000000000..9b59e7ea5 --- /dev/null +++ b/.changes/unreleased/Feature-20251007-155945.yaml @@ -0,0 +1,6 @@ +kind: Feature +body: Admin interface for Motive entity +time: 2025-10-07T15:59:45.597029709+02:00 +custom: + Issue: "" + SchemaChange: No schema change diff --git a/src/Bundle/ChillTicketBundle/src/Controller/Admin/MotiveController.php b/src/Bundle/ChillTicketBundle/src/Controller/Admin/MotiveController.php new file mode 100644 index 000000000..fe9f62a0a --- /dev/null +++ b/src/Bundle/ChillTicketBundle/src/Controller/Admin/MotiveController.php @@ -0,0 +1,29 @@ +addOrderBy('e.id', 'ASC'); + + return parent::orderQuery($action, $query, $request, $paginator); + } +} diff --git a/src/Bundle/ChillTicketBundle/src/DependencyInjection/ChillTicketExtension.php b/src/Bundle/ChillTicketBundle/src/DependencyInjection/ChillTicketExtension.php index 596cb655a..a990cfa16 100644 --- a/src/Bundle/ChillTicketBundle/src/DependencyInjection/ChillTicketExtension.php +++ b/src/Bundle/ChillTicketBundle/src/DependencyInjection/ChillTicketExtension.php @@ -11,8 +11,10 @@ declare(strict_types=1); namespace Chill\TicketBundle\DependencyInjection; +use Chill\TicketBundle\Controller\Admin\MotiveController; use Chill\TicketBundle\Controller\MotiveApiController; use Chill\TicketBundle\Entity\Motive; +use Chill\TicketBundle\Form\MotiveType; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; @@ -36,6 +38,7 @@ class ChillTicketExtension extends Extension implements PrependExtensionInterfac public function prepend(ContainerBuilder $container) { $this->prependApi($container); + $this->prependCruds($container); } private function prependApi(ContainerBuilder $container): void @@ -66,4 +69,37 @@ class ChillTicketExtension extends Extension implements PrependExtensionInterfac ], ]); } + + protected function prependCruds(ContainerBuilder $container): void + { + $container->prependExtensionConfig('chill_main', [ + 'cruds' => [ + [ + 'class' => Motive::class, + 'name' => 'motive', + 'base_path' => '/admin/ticket/motive', + 'form_class' => MotiveType::class, + 'controller' => MotiveController::class, + 'actions' => [ + 'index' => [ + 'template' => '@ChillTicket/Admin/Motive/index.html.twig', + 'role' => 'ROLE_ADMIN', + ], + 'new' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillTicket/Admin/Motive/new.html.twig', + ], + 'view' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillTicket/Admin/Motive/view.html.twig', + ], + 'edit' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillTicket/Admin/Motive/edit.html.twig', + ], + ], + ], + ], + ]); + } } diff --git a/src/Bundle/ChillTicketBundle/src/Form/MotiveType.php b/src/Bundle/ChillTicketBundle/src/Form/MotiveType.php new file mode 100644 index 000000000..e7dae2784 --- /dev/null +++ b/src/Bundle/ChillTicketBundle/src/Form/MotiveType.php @@ -0,0 +1,67 @@ +add('label', TranslatableStringFormType::class, [ + 'label' => 'Label', + 'required' => true, + ]) + ->add('active', CheckboxType::class, [ + 'label' => 'Active', + 'required' => false, + ]) + ->add('makeTicketEmergency', EnumType::class, [ + 'class' => EmergencyStatusEnum::class, + 'label' => 'emergency?', + 'required' => false, + 'placeholder' => 'Choose an option...', + ]) + ->add('supplementaryComments', ChillCollectionType::class, [ + 'entry_type' => TextareaType::class, + 'allow_add' => true, + 'allow_delete' => true, + 'by_reference' => true, + 'label' => 'Supplementary comments', + 'required' => false, + ]); + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + 'data_class' => Motive::class, + ]); + } + + public function getBlockPrefix(): string + { + return 'chill_ticketbundle_motive'; + } +} diff --git a/src/Bundle/ChillTicketBundle/src/Resources/views/Admin/Motive/edit.html.twig b/src/Bundle/ChillTicketBundle/src/Resources/views/Admin/Motive/edit.html.twig new file mode 100644 index 000000000..73c005374 --- /dev/null +++ b/src/Bundle/ChillTicketBundle/src/Resources/views/Admin/Motive/edit.html.twig @@ -0,0 +1,15 @@ +{% extends '@ChillMain/CRUD/Admin/index.html.twig' %} + +{% block title %} + {% include('@ChillMain/CRUD/_edit_title.html.twig') %} +{% endblock %} + +{% block js %} +{{ parent() }} +{% endblock %} + +{% block admin_content %} + {% embed '@ChillMain/CRUD/_edit_content.html.twig' %} + {% block content_form_actions_save_and_view %}{% endblock %} + {% endembed %} +{% endblock %} diff --git a/src/Bundle/ChillTicketBundle/src/Resources/views/Admin/Motive/index.html.twig b/src/Bundle/ChillTicketBundle/src/Resources/views/Admin/Motive/index.html.twig new file mode 100644 index 000000000..74d4de75a --- /dev/null +++ b/src/Bundle/ChillTicketBundle/src/Resources/views/Admin/Motive/index.html.twig @@ -0,0 +1,64 @@ +{% extends '@ChillMain/Admin/layoutWithVerticalMenu.html.twig' %} + +{% block title %}{{ 'ticket.admin.title.Motive list'|trans }}{% endblock title %} + +{% block admin_content %} + +
{{ 'Label'|trans }} | +{{ 'Active'|trans }} | +{{ 'emergency?'|trans }} | +{{ 'Supplementary comments'|trans }} | ++ |
---|---|---|---|---|
{{ entity.label|localize_translatable_string }} | ++ {%- if entity.isActive -%} + + {%- else -%} + + {%- endif -%} + | ++ {%- if entity.makeTicketEmergency -%} + {{ entity.makeTicketEmergency.value|trans }} + {%- else -%} + - + {%- endif -%} + | ++ {{ entity.supplementaryComments|length }} + | ++ + | +
{{ 'Id'|trans }} | +{{ entity.id }} | +
---|---|
{{ 'Label'|trans }} | +{{ entity.label|localize_translatable_string }} | +
{{ 'Active'|trans }} | ++ {%- if entity.isActive -%} + {{ 'Yes'|trans }} + {%- else -%} + {{ 'No'|trans }} + {%- endif -%} + | +
{{ 'emergency?'|trans }} | ++ {%- if entity.makeTicketEmergency -%} + {{ entity.makeTicketEmergency.value|trans }} + {%- else -%} + - + {%- endif -%} + | +
{{ 'No supplementary comments'|trans }}
+ {% endif %} + + +{% endblock %} diff --git a/src/Bundle/ChillTicketBundle/src/config/services.yaml b/src/Bundle/ChillTicketBundle/src/config/services.yaml index 1089b574e..3be7cb65f 100644 --- a/src/Bundle/ChillTicketBundle/src/config/services.yaml +++ b/src/Bundle/ChillTicketBundle/src/config/services.yaml @@ -40,3 +40,6 @@ services: Chill\TicketBundle\DataFixtures\: resource: '../DataFixtures/' + + Chill\TicketBundle\Form\: + resource: '../Form/' diff --git a/src/Bundle/ChillTicketBundle/src/translations/messages+intl-icu.fr.yml b/src/Bundle/ChillTicketBundle/src/translations/messages+intl-icu.fr.yml index b47eaa035..dad2bc603 100644 --- a/src/Bundle/ChillTicketBundle/src/translations/messages+intl-icu.fr.yml +++ b/src/Bundle/ChillTicketBundle/src/translations/messages+intl-icu.fr.yml @@ -148,3 +148,28 @@ chill_ticket: open_new_tab: "Ouvrir dans un nouvel onglet" iframe_not_supported: "Votre navigateur ne supporte pas les iframes." click_to_open_pdf: "Cliquez ici pour ouvrir le PDF" + +ticket: + admin: + title: + "Motive list": "Liste des motifs" + "Motive view": "Détails du motif" + new: + "Create a new motive": "Créer un nouveau motif" + motive: + label: "Motifs" + +"Label": "Libellé" +"Active": "Actif" +"emergency?": "Urgent ?" +"Supplementary comments": "Commentaires supplémentaires" +"edit": "modifier" +"show": "voir" +"Yes": "Oui" +"No": "Non" +"Id": "ID" +"Date": "Date" +"User": "Utilisateur" +"No supplementary comments": "Aucun commentaire supplémentaire" +"Back to the list": "Retour à la liste" +"Edit": "Modifier"