Improve user experience for creation of document categories with select field for document class

This commit is contained in:
Julie Lenaerts 2024-11-05 15:28:11 +01:00
parent 8cb2bb1ef4
commit 456d29e605
3 changed files with 18 additions and 3 deletions

View File

@ -17,15 +17,25 @@ use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Contracts\Translation\TranslatorInterface;
class DocumentCategoryType extends AbstractType class DocumentCategoryType extends AbstractType
{ {
public function __construct(private readonly TranslatorInterface $translator)
{
}
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
{ {
$bundles = [ $bundles = [
'chill-doc-store' => 'chill-doc-store', 'chill-doc-store' => 'chill-doc-store',
]; ];
$documentClasses = [
$this->translator->trans('Accompanying period document') => "Chill\DocStoreBundle\Entity\AccompanyingCourseDocument",
$this->translator->trans('Person document') => "Chill\DocStoreBundle\Entity\PersonDocument",
];
$builder $builder
->add('bundleId', ChoiceType::class, [ ->add('bundleId', ChoiceType::class, [
'choices' => $bundles, 'choices' => $bundles,
@ -34,7 +44,10 @@ class DocumentCategoryType extends AbstractType
->add('idInsideBundle', null, [ ->add('idInsideBundle', null, [
'disabled' => true, 'disabled' => true,
]) ])
->add('documentClass', null, [ ->add('documentClass', ChoiceType::class, [
'choices' => $documentClasses,
'expanded' => false,
'required' => true,
'disabled' => false, 'disabled' => false,
]) ])
->add('name', TranslatableStringFormType::class); ->add('name', TranslatableStringFormType::class);

View File

@ -8,7 +8,7 @@
<table class="table table-bordered border-dark align-middle"> <table class="table table-bordered border-dark align-middle">
<thead> <thead>
<tr> <tr>
<th>{{ 'Creator bundle id' | trans }}</th> {# <th>{{ 'Creator bundle id' | trans }}</th>#}
<th>{{ 'Internal id inside creator bundle' | trans }}</th> <th>{{ 'Internal id inside creator bundle' | trans }}</th>
<th>{{ 'Document class' | trans }}</th> <th>{{ 'Document class' | trans }}</th>
<th>{{ 'Name' | trans }}</th> <th>{{ 'Name' | trans }}</th>
@ -18,7 +18,7 @@
<tbody> <tbody>
{% for document_category in document_categories %} {% for document_category in document_categories %}
<tr> <tr>
<td>{{ document_category.bundleId }}</td> {# <td>{{ document_category.bundleId }}</td>#}
<td>{{ document_category.idInsideBundle }}</td> <td>{{ document_category.idInsideBundle }}</td>
<td>{{ document_category.documentClass }}</td> <td>{{ document_category.documentClass }}</td>
<td>{{ document_category.name | localize_translatable_string}}</td> <td>{{ document_category.name | localize_translatable_string}}</td>

View File

@ -74,6 +74,8 @@ no records found:
Create new category: Créer une nouvelle catégorie Create new category: Créer une nouvelle catégorie
Back to the category list: Retour à la liste Back to the category list: Retour à la liste
Create new DocumentCategory: Créer une nouvelle catégorie de document Create new DocumentCategory: Créer une nouvelle catégorie de document
Accompanying period document: Document de parcours d'accompagnement
Person document: Document de personne
# WOPI EDIT # WOPI EDIT
online_edit_document: Éditer en ligne online_edit_document: Éditer en ligne