diff --git a/public/assets/css/app.css b/public/assets/css/app.css index 1499952d0d36a7f5acb9e5a1ff01ab8b9f523bbf..ca04b22bf6aa0e109091576de25875bca7d13194 100644 --- a/public/assets/css/app.css +++ b/public/assets/css/app.css @@ -148,13 +148,13 @@ table.label-table > tbody > tr > td { .text-grey { color:lightgrey; } -p:hover .fa.text-grey { +p:hover .fa.text-grey, h4:hover .fa.text-grey, h1:hover .fa.text-grey { color: dimgrey; } .text-light-green { - color: #b6e8b6; + color: #c3eec3; } -p:hover .fa.text-light-green { +p:hover .fa.text-light-green, h4:hover .fa.text-light-green, h1:hover .fa.text-light-green { color: limegreen; } diff --git a/src/Controller/EntryController.php b/src/Controller/EntryController.php index f62e5324e9bd40bd8854ad2af998501ceb029b3f..46589cd1c55a79d5b49d1236b8bbe32063440a8f 100644 --- a/src/Controller/EntryController.php +++ b/src/Controller/EntryController.php @@ -227,14 +227,12 @@ class EntryController extends AppBaseController 'id' => $entry->getId(), 'blockId' => $blockId, 'blockCategory' => $blockCategory, - ]) + ]), + 'blockCategory' => $blockCategory, ]); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { -// if ($blockCategory && !isset($block[$blockCategory])) { -// -// } $parentBlock[$blockCategory][] = $form->get('block')->getData(); $propertyAccessor->setValue($attributes, $blockId, $parentBlock); $entry->setAttributes($attributes); @@ -243,8 +241,8 @@ class EntryController extends AppBaseController return $this->render('closeModalAndReload.html.twig'); } - return $this->render('genericModalForm.html.twig', [ - 'title' => "Ajouter un bloc « " . $blockCategory . " »", + return $this->render('entry/addBlock.html.twig', [ + 'category' => $blockCategory, 'form' => $form->createView(), ]); } diff --git a/src/Entity/Entry.php b/src/Entity/Entry.php index 28052982a726c5c9bd8125191c4390925e147662..d982fb4c2934cbc554a23084f6e8d1930f664c7a 100644 --- a/src/Entity/Entry.php +++ b/src/Entity/Entry.php @@ -21,6 +21,10 @@ use OpenApi\Annotations as OA; */ class Entry { + const ATTR_PRONUNCIATION = 'Pronunciations'; + const ATTR_PART_OF_SPEECH = 'PartOfSpeech'; + const ATTR_DEFINITION = 'Definitions'; + use LoggableTrait; /** diff --git a/src/Form/BlockType.php b/src/Form/BlockType.php index 9353f080f02169a07b15059d2ed8b5aac6d43edf..d8a4751210d54f0afbfb58e060ea1ddacc165ba8 100644 --- a/src/Form/BlockType.php +++ b/src/Form/BlockType.php @@ -2,6 +2,7 @@ namespace App\Form; +use App\Entity\Entry; use App\Entity\Label; use App\Entity\User; use App\Languages\LanguagesIso; @@ -21,11 +22,34 @@ class BlockType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options): void { - $builder - ->add('block', TextType::class, [ - 'label' => false, - ]) - ; + $blockCategory = $options['blockCategory']; + + if ($blockCategory === Entry::ATTR_PRONUNCIATION) { + $builder + ->add('block', PronunciationType::class, [ + 'label' => false, + ]) + ; + } elseif ($blockCategory === Entry::ATTR_DEFINITION) { + $builder + ->add('block', DefinitionType::class, [ + 'label' => false, + ]) + ; + } elseif ($blockCategory === Entry::ATTR_PART_OF_SPEECH) { + $builder + ->add('block', PartOfSpeechType::class, [ + 'label' => false, + ]) + ; + } else { + $builder + ->add('block', TextareaType::class, [ + 'label' => false, + ]) + ; + } + $builder ->add('submit', SubmitType::class, [ @@ -36,12 +60,12 @@ class BlockType extends AbstractType public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults([ - 'user' => null, 'attr' => [ 'data-ajax-form' => '', 'data-ajax-form-target' => '#bootstrap-modal .modal-content', 'novalidate' => 'novalidate', ], + 'blockCategory' => null, ]); } } diff --git a/src/Form/DefinitionType.php b/src/Form/DefinitionType.php new file mode 100644 index 0000000000000000000000000000000000000000..2286a80c52988a4e919d80384654b2e648bd2012 --- /dev/null +++ b/src/Form/DefinitionType.php @@ -0,0 +1,37 @@ +<?php + +namespace App\Form; + +use App\Entity\Entry; +use App\Entity\Label; +use App\Entity\User; +use App\Languages\LanguagesIso; +use App\Repository\GroupRepository; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; +use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\ChoiceType; +use Symfony\Component\Form\Extension\Core\Type\DateTimeType; +use Symfony\Component\Form\Extension\Core\Type\DateType; +use Symfony\Component\Form\Extension\Core\Type\SubmitType; +use Symfony\Component\Form\Extension\Core\Type\TextareaType; +use Symfony\Component\Form\Extension\Core\Type\TextType; +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; + +class DefinitionType extends AbstractType +{ + public function buildForm(FormBuilderInterface $builder, array $options): void + { + $builder + ->add('Def', TextareaType::class, [ + 'label' => "Définition", + ]) + ; + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + ]); + } +} diff --git a/src/Form/PartOfSpeechType.php b/src/Form/PartOfSpeechType.php new file mode 100644 index 0000000000000000000000000000000000000000..c65927df1851def8823812d71d849a1a43014e47 --- /dev/null +++ b/src/Form/PartOfSpeechType.php @@ -0,0 +1,42 @@ +<?php + +namespace App\Form; + +use App\Entity\Entry; +use App\Entity\Label; +use App\Entity\User; +use App\Languages\LanguagesIso; +use App\Repository\GroupRepository; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; +use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\ChoiceType; +use Symfony\Component\Form\Extension\Core\Type\DateTimeType; +use Symfony\Component\Form\Extension\Core\Type\DateType; +use Symfony\Component\Form\Extension\Core\Type\HiddenType; +use Symfony\Component\Form\Extension\Core\Type\SubmitType; +use Symfony\Component\Form\Extension\Core\Type\TextareaType; +use Symfony\Component\Form\Extension\Core\Type\TextType; +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; + +class PartOfSpeechType extends AbstractType +{ + public function buildForm(FormBuilderInterface $builder, array $options): void + { + $builder + ->add('PartOfSpeech', TextType::class, [ + 'label' => "Nature", + ]) + ->add('Sense', HiddenType::class, [ + 'required' => false, + 'label' => false, + ]) + ; + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + ]); + } +} diff --git a/src/Form/PronunciationType.php b/src/Form/PronunciationType.php new file mode 100644 index 0000000000000000000000000000000000000000..747741549611290d1bc75fbd7d233717a377f1bc --- /dev/null +++ b/src/Form/PronunciationType.php @@ -0,0 +1,41 @@ +<?php + +namespace App\Form; + +use App\Entity\Entry; +use App\Entity\Label; +use App\Entity\User; +use App\Languages\LanguagesIso; +use App\Repository\GroupRepository; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; +use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\ChoiceType; +use Symfony\Component\Form\Extension\Core\Type\DateTimeType; +use Symfony\Component\Form\Extension\Core\Type\DateType; +use Symfony\Component\Form\Extension\Core\Type\SubmitType; +use Symfony\Component\Form\Extension\Core\Type\TextareaType; +use Symfony\Component\Form\Extension\Core\Type\TextType; +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; + +class PronunciationType extends AbstractType +{ + public function buildForm(FormBuilderInterface $builder, array $options): void + { + $builder + ->add('api', TextType::class, [ + 'label' => "Api", + ]) + ->add('accent', TextType::class, [ + 'required' => false, + 'label' => "Accent", + ]) + ; + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + ]); + } +} diff --git a/templates/entry/_entryAttributes.html.twig b/templates/entry/_entryAttributes.html.twig index 219c9d1918d34de798b092b6bf9fa857dcb5efa5..a93098e89319d50c8ad209d1115f17e662936468 100644 --- a/templates/entry/_entryAttributes.html.twig +++ b/templates/entry/_entryAttributes.html.twig @@ -1,9 +1,15 @@ <div id="entryAttributes" class="ps-5"> {# {{ dump(entry.attributes) }}#} - <h1>{{ entry }}</h1> - - <h4>{{ "Pronunciations"|trans }}</h4> + <h1> + {{ entry }} + {{ _self.actions(entry, '', ['add'], "Ajouter une nature", 'Items') }} + </h1> + + <h4> + {{ "Pronunciations"|trans }} + {{ _self.actions(entry, '[Items][0][Sense]', ['add'], "Ajouter une prononciation", 'Pronunciations') }} + </h4> <div class="ms-1 ps-4 mb-2"> {% for pronunciation in entry_manager.pronunciations(entry) %} {% if pronunciation.accent is defined %}{{ pronunciation.accent }} :{% endif %} @@ -17,7 +23,10 @@ {######### SET KEY ##########} {% set itemKey = '[Items]['~key~']' %} - <h4>{{ entry_manager.partOfSpeechFromItem(item)|trans }}</h4> + <h4> + {{ entry_manager.partOfSpeechFromItem(item)|trans }} + {{ _self.actions(entry, itemKey~'[Sense]', ['add'], "Ajouter une définition", 'Definitions') }} + </h4> <div class="ms-1 ps-4 left-border-blue bg-light-grey"> @@ -29,7 +38,7 @@ <p class="fw-bold"> {{ loop.index }}. {{ definition.Def }} - {{ _self.actions(entry, definitionKey, ['add'], 'Examples') }} + {{ _self.actions(entry, definitionKey, ['add'], "Ajouter un exemple", 'Examples') }} </p> {% for key, example in definition.Examples|default([]) %} @@ -50,9 +59,9 @@ </div> -{% macro actions(entry, key, operations, category) %} +{% macro actions(entry, key, operations, title, category) %} {% if 'add' in operations %} - <a href="#" data-url="{{ path('app_entry_add_block', {id: entry.id, blockId: key, blockCategory: category}) }}" class="modal-form"><i class="fa fa-plus-circle fa-lg text-light-green" title="{{ category|trans }} {{ key }}"></i></a> + <a href="#" data-url="{{ path('app_entry_add_block', {id: entry.id, blockId: key, blockCategory: category}) }}" class="modal-form"><i class="fa fa-plus-circle fa-lg text-light-green" title="{{ title ? title|trans : category|trans }} {{ key }}"></i></a> {% endif %} {% if 'edit' in operations %} <a href="#" data-url="{{ path('app_entry_edit_block', {id: entry.id, blockId: key}) }}" class="modal-form"><i class="fa fa-pencil-square fa-lg text-grey" title="{{ key }}"></i></a> diff --git a/templates/entry/addBlock.html.twig b/templates/entry/addBlock.html.twig new file mode 100644 index 0000000000000000000000000000000000000000..e8f1058969f68f381ef02a11150a8eaea24505cb --- /dev/null +++ b/templates/entry/addBlock.html.twig @@ -0,0 +1,30 @@ +{% extends 'modal.html.twig' %} + +{% block modal_title %} + {{ "Ajouter un bloc"|trans }} {{ category|trans }} +{% endblock %} + +{% block modal_body %} + <div class="row"> + <div class="col-md-12"> + + {% include "flashes.html.twig" %} + + {{ form_start(form) }} + {{ form_errors(form) }} + {% for child in form %} + {% if child.vars.name != 'submit' %} + {{ form_row(child) }} + {% endif %} + {% endfor %} + <div class="row pt-3"> + <div class="col-sm-4"></div> + <div class="col-sm-8"> + {{ form_widget(form.submit) }} + <button type="button" class="btn btn-light" data-bs-dismiss="modal">{{ 'Annuler'|trans }}</button> + </div> + </div> + {{ form_end(form) }} + </div> + </div> +{% endblock %} \ No newline at end of file diff --git a/translations/messages.fr.yaml b/translations/messages.fr.yaml index d0f20a3c66238173de6bade8c7caa5f8232f4fd8..ddd0c16155cc4c9bc58d942530a9664cdc712bb2 100644 --- a/translations/messages.fr.yaml +++ b/translations/messages.fr.yaml @@ -13,4 +13,8 @@ "Prep": "Préposition" "general": "général" "institutional": "institutionnel" -"milestone": "échéance" \ No newline at end of file +"milestone": "échéance" +"Definitions": "Définition" +"Pronunciations": "Prononciation" +"Examples": "Exemple" +"PartOfSpeech": "Nature"