Skip to content
Snippets Groups Projects
Commit faac46c3 authored by Pierre Fleutot's avatar Pierre Fleutot
Browse files

Edition entrée : ajout de blocs sépcifiques

parent 560b419b
No related branches found
No related tags found
No related merge requests found
...@@ -148,13 +148,13 @@ table.label-table > tbody > tr > td { ...@@ -148,13 +148,13 @@ table.label-table > tbody > tr > td {
.text-grey { .text-grey {
color:lightgrey; color:lightgrey;
} }
p:hover .fa.text-grey { p:hover .fa.text-grey, h4:hover .fa.text-grey, h1:hover .fa.text-grey {
color: dimgrey; color: dimgrey;
} }
.text-light-green { .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; color: limegreen;
} }
......
...@@ -227,14 +227,12 @@ class EntryController extends AppBaseController ...@@ -227,14 +227,12 @@ class EntryController extends AppBaseController
'id' => $entry->getId(), 'id' => $entry->getId(),
'blockId' => $blockId, 'blockId' => $blockId,
'blockCategory' => $blockCategory, 'blockCategory' => $blockCategory,
]) ]),
'blockCategory' => $blockCategory,
]); ]);
$form->handleRequest($request); $form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
// if ($blockCategory && !isset($block[$blockCategory])) {
//
// }
$parentBlock[$blockCategory][] = $form->get('block')->getData(); $parentBlock[$blockCategory][] = $form->get('block')->getData();
$propertyAccessor->setValue($attributes, $blockId, $parentBlock); $propertyAccessor->setValue($attributes, $blockId, $parentBlock);
$entry->setAttributes($attributes); $entry->setAttributes($attributes);
...@@ -243,8 +241,8 @@ class EntryController extends AppBaseController ...@@ -243,8 +241,8 @@ class EntryController extends AppBaseController
return $this->render('closeModalAndReload.html.twig'); return $this->render('closeModalAndReload.html.twig');
} }
return $this->render('genericModalForm.html.twig', [ return $this->render('entry/addBlock.html.twig', [
'title' => "Ajouter un bloc « " . $blockCategory . " »", 'category' => $blockCategory,
'form' => $form->createView(), 'form' => $form->createView(),
]); ]);
} }
......
...@@ -21,6 +21,10 @@ use OpenApi\Annotations as OA; ...@@ -21,6 +21,10 @@ use OpenApi\Annotations as OA;
*/ */
class Entry class Entry
{ {
const ATTR_PRONUNCIATION = 'Pronunciations';
const ATTR_PART_OF_SPEECH = 'PartOfSpeech';
const ATTR_DEFINITION = 'Definitions';
use LoggableTrait; use LoggableTrait;
/** /**
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace App\Form; namespace App\Form;
use App\Entity\Entry;
use App\Entity\Label; use App\Entity\Label;
use App\Entity\User; use App\Entity\User;
use App\Languages\LanguagesIso; use App\Languages\LanguagesIso;
...@@ -21,11 +22,34 @@ class BlockType extends AbstractType ...@@ -21,11 +22,34 @@ class BlockType extends AbstractType
{ {
public function buildForm(FormBuilderInterface $builder, array $options): void public function buildForm(FormBuilderInterface $builder, array $options): void
{ {
$builder $blockCategory = $options['blockCategory'];
->add('block', TextType::class, [
'label' => false, 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 $builder
->add('submit', SubmitType::class, [ ->add('submit', SubmitType::class, [
...@@ -36,12 +60,12 @@ class BlockType extends AbstractType ...@@ -36,12 +60,12 @@ class BlockType extends AbstractType
public function configureOptions(OptionsResolver $resolver): void public function configureOptions(OptionsResolver $resolver): void
{ {
$resolver->setDefaults([ $resolver->setDefaults([
'user' => null,
'attr' => [ 'attr' => [
'data-ajax-form' => '', 'data-ajax-form' => '',
'data-ajax-form-target' => '#bootstrap-modal .modal-content', 'data-ajax-form-target' => '#bootstrap-modal .modal-content',
'novalidate' => 'novalidate', 'novalidate' => 'novalidate',
], ],
'blockCategory' => null,
]); ]);
} }
} }
<?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([
]);
}
}
<?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([
]);
}
}
<?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([
]);
}
}
<div id="entryAttributes" class="ps-5"> <div id="entryAttributes" class="ps-5">
{# {{ dump(entry.attributes) }}#} {# {{ dump(entry.attributes) }}#}
<h1>{{ entry }}</h1> <h1>
{{ entry }}
<h4>{{ "Pronunciations"|trans }}</h4> {{ _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"> <div class="ms-1 ps-4 mb-2">
{% for pronunciation in entry_manager.pronunciations(entry) %} {% for pronunciation in entry_manager.pronunciations(entry) %}
{% if pronunciation.accent is defined %}{{ pronunciation.accent }} :{% endif %} {% if pronunciation.accent is defined %}{{ pronunciation.accent }} :{% endif %}
...@@ -17,7 +23,10 @@ ...@@ -17,7 +23,10 @@
{######### SET KEY ##########} {######### SET KEY ##########}
{% set itemKey = '[Items]['~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"> <div class="ms-1 ps-4 left-border-blue bg-light-grey">
...@@ -29,7 +38,7 @@ ...@@ -29,7 +38,7 @@
<p class="fw-bold"> <p class="fw-bold">
{{ loop.index }}. {{ definition.Def }} {{ loop.index }}. {{ definition.Def }}
{{ _self.actions(entry, definitionKey, ['add'], 'Examples') }} {{ _self.actions(entry, definitionKey, ['add'], "Ajouter un exemple", 'Examples') }}
</p> </p>
{% for key, example in definition.Examples|default([]) %} {% for key, example in definition.Examples|default([]) %}
...@@ -50,9 +59,9 @@ ...@@ -50,9 +59,9 @@
</div> </div>
{% macro actions(entry, key, operations, category) %} {% macro actions(entry, key, operations, title, category) %}
{% if 'add' in operations %} {% 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 %} {% endif %}
{% if 'edit' in operations %} {% 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> <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>
......
{% 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
...@@ -13,4 +13,8 @@ ...@@ -13,4 +13,8 @@
"Prep": "Préposition" "Prep": "Préposition"
"general": "général" "general": "général"
"institutional": "institutionnel" "institutional": "institutionnel"
"milestone": "échéance" "milestone": "échéance"
\ No newline at end of file "Definitions": "Définition"
"Pronunciations": "Prononciation"
"Examples": "Exemple"
"PartOfSpeech": "Nature"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment