From 37291b27562be57cc121172d627b934a20e1c940 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 7 Oct 2025 16:26:30 +0200 Subject: [PATCH] Create admin interface for the Motive entity with relevant templates + translations --- .../unreleased/Feature-20251007-155945.yaml | 6 ++ .../src/Controller/Admin/MotiveController.php | 29 +++++++ .../ChillTicketExtension.php | 36 +++++++++ .../ChillTicketBundle/src/Form/MotiveType.php | 67 ++++++++++++++++ .../views/Admin/Motive/edit.html.twig | 15 ++++ .../views/Admin/Motive/index.html.twig | 64 +++++++++++++++ .../views/Admin/Motive/new.html.twig | 15 ++++ .../views/Admin/Motive/view.html.twig | 78 +++++++++++++++++++ .../src/config/services.yaml | 3 + .../src/translations/messages+intl-icu.fr.yml | 25 ++++++ 10 files changed, 338 insertions(+) create mode 100644 .changes/unreleased/Feature-20251007-155945.yaml create mode 100644 src/Bundle/ChillTicketBundle/src/Controller/Admin/MotiveController.php create mode 100644 src/Bundle/ChillTicketBundle/src/Form/MotiveType.php create mode 100644 src/Bundle/ChillTicketBundle/src/Resources/views/Admin/Motive/edit.html.twig create mode 100644 src/Bundle/ChillTicketBundle/src/Resources/views/Admin/Motive/index.html.twig create mode 100644 src/Bundle/ChillTicketBundle/src/Resources/views/Admin/Motive/new.html.twig create mode 100644 src/Bundle/ChillTicketBundle/src/Resources/views/Admin/Motive/view.html.twig 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 %} + +

{{ 'ticket.admin.title.Motive list'|trans }}

+ + + + + + + + + + + + + {% for entity in entities %} + + + + + + + + {% endfor %} + +
{{ '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 }} + +
    +
  • + +
  • +
  • + +
  • +
+
+ + {{ chill_pagination(paginator) }} + + +{% endblock %} diff --git a/src/Bundle/ChillTicketBundle/src/Resources/views/Admin/Motive/new.html.twig b/src/Bundle/ChillTicketBundle/src/Resources/views/Admin/Motive/new.html.twig new file mode 100644 index 000000000..428c3fa75 --- /dev/null +++ b/src/Bundle/ChillTicketBundle/src/Resources/views/Admin/Motive/new.html.twig @@ -0,0 +1,15 @@ +{% extends '@ChillMain/CRUD/Admin/index.html.twig' %} + +{% block title %} + {% include('@ChillMain/CRUD/_new_title.html.twig') %} +{% endblock %} + +{% block js %} +{{ parent() }} +{% endblock %} + +{% block admin_content %} + {% embed '@ChillMain/CRUD/_new_content.html.twig' %} + {% block content_form_actions_save_and_show %}{% endblock %} + {% endembed %} +{% endblock %} diff --git a/src/Bundle/ChillTicketBundle/src/Resources/views/Admin/Motive/view.html.twig b/src/Bundle/ChillTicketBundle/src/Resources/views/Admin/Motive/view.html.twig new file mode 100644 index 000000000..4a4f52097 --- /dev/null +++ b/src/Bundle/ChillTicketBundle/src/Resources/views/Admin/Motive/view.html.twig @@ -0,0 +1,78 @@ +{% extends '@ChillMain/Admin/layoutWithVerticalMenu.html.twig' %} + +{% block title %}{{ 'ticket.admin.title.Motive view'|trans }}{% endblock title %} + +{% block admin_content %} + +

{{ 'ticket.admin.title.Motive view'|trans }}

+ + + + + + + + + + + + + + + + + + + + +
{{ '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 -%} +
+ + {% if entity.supplementaryComments is not empty %} +

{{ 'Supplementary comments'|trans }}

+
+ {% for comment in entity.supplementaryComments %} +
+
+
+ {{ comment.comment|raw }} +
+ {% if comment.date %} +
+ + {{ 'Date'|trans }}: {{ comment.date|date('d/m/Y H:i') }} + {% if comment.userId %} + - {{ 'User'|trans }}: {{ comment.userId }} + {% endif %} + +
+ {% endif %} +
+
+ {% endfor %} +
+ {% else %} +

{{ 'Supplementary comments'|trans }}

+

{{ '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"