Commit 7d414bf1 authored by Mat's avatar Mat
Browse files

Formate et affiche le form create des 2 entités Info et Lettre

parent 909ccc1d
......@@ -4,6 +4,11 @@ namespace PotageBundle\Form\Info;
use PotageBundle\Entity\Info;
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\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;
......@@ -11,6 +16,74 @@ class InfoType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
// title varchar(150) not null,
$builder->add('title', TextType::class, array(
'label' => "Titre",
'label_attr' => array('class' => 'col-form-label'),
'attr' => array('class' => 'form-control form-control-sm'),
));
// subtitle varchar(150) not null,
$builder->add('subtitle', TextType::class, array(
'label' => "Soustitre",
'label_attr' => array('class' => 'col-form-label'),
'attr' => array('class' => 'form-control form-control-sm'),
));
// text longtext not null,
$builder->add('text', TextareaType::class, array(
'label' => "Texte",
'label_attr' => array('class' => 'col-form-label'),
'attr' => array('class' => 'form-control form-control-sm'),
));
// isPost tinyint(1) not null,
$builder->add('isPost', ChoiceType::class, array(
'label' => "is_post",
'choices' => array(
'Daté' => true,
'Non daté' => false,
),
'label_attr' => array('class' => 'col-form-label'),
'attr' => array('class' => 'form-control form-control-sm'),
));
// postedAt
$builder->add('postedAt', DateTimeType::class, array(
'label' => "Date de publication",
'data' => new \DateTime('now'),
'date_widget' => 'single_text',
'time_widget' => 'single_text',
'label_attr' => array('class' => 'col-form-label'),
'attr' => array('class' => 'form-control form-control-sm'),
));
// status enum ('draft', 'posted', 'trash') null,
$builder->add('status', ChoiceType::class, array(
'label' => "status",
'choices' => array(
"Brouillon" => 'draft',
"Publié" => 'posted',
// TODO doit setter la date dans postedAt
"Poubelle" => 'trash'
),
'label_attr' => array('class' => 'col-form-label'),
'attr' => array('class' => 'form-control form-control-sm'),
));
// color varchar(10) not null,
$builder->add('color', TextType::class, array(
'label' => "color",
'label_attr' => array('class' => 'col-form-label'),
'attr' => array('class' => 'form-control form-control-sm'),
));
$builder->add('sauver', SubmitType::class, array(
'label' => 'Enregistrer',
'attr' => array('class' => 'btn btn-dark mb-2')
));
}
......
......@@ -2,7 +2,10 @@
namespace PotageBundle\Form\Lettre;
use PotageBundle\Entity\Info;
use PotageBundle\Entity\Lettre;
use PotageBundle\Entity\Offre;
use PotageBundle\Repository\OffreRepository;
use Symfony\Component\Form\AbstractType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
......@@ -10,6 +13,8 @@ use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
class LettreType extends AbstractType
......@@ -17,57 +22,92 @@ class LettreType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('offre', EntityType::class, array(
'label' => "Offre",
'label_attr' => array('class' => 'col-form-label'),
'attr' => array('class' => 'form-control form-control-sm'),
));
// offre
$builder->addEventListener(
FormEvents::PRE_SET_DATA,
function (FormEvent $event)
{
$form = $event->getForm();
$offre = $event->getData();
$form->add('offre', EntityType::class, array(
'class' => Offre::class,
'query_builder' => function (OffreRepository $er) use ($offre) {
return $er->createQueryBuilder('o')
->where('o.status = :draft')
->orWhere('o.status = :current')
->setParameters(array(
':draft' => 'draft',
':current' => 'current'))
->orderBy('o.reference', 'DESC');
},
'choice_label' => 'getReference',
'label' => "À laquelle on joint une offre",
'label_attr' => array('class' => 'col-form-label'),
'attr' => array('class' => 'form-control form-control-sm'),
));
}
);
// infos
$builder->add('infos', EntityType::class, array(
'label' => "Infos",
'class' => Info::class,
'label' => "Dans laquelle on glisse des infos",
'label_attr' => array('class' => 'col-form-label'),
'attr' => array('class' => 'form-control form-control-sm'),
));
// groupe
$builder->add('groupe', ChoiceType::class, array(
'label' => "Groupe",
'label_attr' => array('class' => 'col-form-label'),
'attr' => array('class' => 'form-control form-control-sm'),
));
$builder->add('reference', TextType::class, array(
'label' => "Référence",
'label' => "À destination d'un groupe",
'label_attr' => array('class' => 'col-form-label'),
'attr' => array('class' => 'form-control form-control-sm'),
));
// subject
$builder->add('subject', TextType::class, array(
'label' => "Sujet",
'label' => "Sujet ",
'label_attr' => array('class' => 'col-form-label'),
'attr' => array('class' => 'form-control form-control-sm'),
));
$builder->add('started_at', DateType::class, array(
'label' => "Début",
// startedAt
$builder->add('startedAt', DateType::class, array(
'label' => "Début de la période",
'widget' => 'single_text',
'data' => new \DateTime('now'),
'label_attr' => array('class' => 'col-form-label'),
'attr' => array('class' => 'form-control form-control-sm'),
));
$builder->add('ended_at', DateType::class, array(
'label' => "Fin",
// endedAt
$builder->add('endedAt', DateType::class, array(
'label' => "Fin de la période",
'widget' => 'single_text',
'data' => new \DateTime('now'),
'label_attr' => array('class' => 'col-form-label'),
'attr' => array('class' => 'form-control form-control-sm'),
));
// status enum ('draft', 'current', 'sent', 'closed', 'trash')
$builder->add('status', ChoiceType::class, array(
'label' => 'Statut',
'label' => "Statut de l'infolettre",
'label_attr' => array('class' => 'col-form-label'),
'attr' => array('class' => 'form-control form-control-sm'),
'choices' => array(
'En préparation' => 'draft',
'Envoyer' => 'current',
), // enum ('draft', 'current', 'sent', 'closed', 'trash')
'Pour Relecture' => 'current',
'Envoyer' => 'sent',
),
));
$builder->add('sauver', SubmitType::class, array(
'label' => 'Enregistrer',
'attr' => array('class' => 'btn btn-dark mb-2')
));
}
public function configureOptions(OptionsResolver $resolver)
{
parent::configureOptions($resolver);
......
......@@ -12,13 +12,106 @@
{% endblock %}
{% block sidebarContent %}
<div class="row">
<div class="row">
<aside class="col-3">
<div class="card text-white bg-dark" id="card-button-ajouter">
<div class="card-header">
<a href="javascript: void(0);" class="btn btn-dark btn-block btn-create"
data-toggle="modal" data-target=".form-info-modal">
<i class="fas fa-plus"></i>
Écrire une nouvelle info
</a>
</div>
</div>
<div style="margin: 1em 0;">
<div class="nav flex-column nav-pills" id="v-pills-tab" role="tablist" aria-orientation="vertical">
<a class="nav-link active" id="v-pills-actuel-tab" data-toggle="pill" href="#v-pills-actuel" role="tab"
aria-controls="v-pills-actuel" aria-selected="true">
<i class="fas fa-caret-right fa-fw"></i> En ce moment</a>
<a class="nav-link" id="v-pills-archives-tab" data-toggle="pill" href="#v-pills-archives" role="tab"
aria-controls="v-pills-archives" aria-selected="false">
<i class="fas fa-caret-right fa-fw"></i> Archives</a>
</div>
</div>
</aside>
{% endblock %}
{% block sectionContent %}
<section class="col-9">
</div>
{% include '@Potage/Info/ajaxForm.html.twig' %}
<div class="row">
<div class="col left hd-1">
<h1>{{ block('title') }}</h1>
</div>
<div class="col right hd-1">
<div style="margin-top: 0.65em;">
{#
<a href="javascript: void(0);" class="btn btn-outline-dark mb-2 btn-sm btn-reload">
<i class="fas fa-sync-alt"></i>
Rafraîchir la liste
</a>
#}
</div>
</div>
</div>
<div class="tab-content" id="v-pills-tabContent">
<div class="tab-pane fade show active" id="v-pills-actuel" role="tabpanel" aria-labelledby="v-pills-actuel-tab">
<h2><i class="fas fa-angle-down fa-fw"></i> En préparation</h2>
<table id="maintab-draft" class="table offres table-striped">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Offre</th>
<th scope="col">Contenu</th>
<th scope="col">Créée le</th>
<th scope="col">Date de clôture</th>
<th scope="col">Référence</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<h2><i class="fas fa-angle-down fa-fw"></i> En cours</h2>
<table id="maintab-current" class="table offres table-striped">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Offre</th>
<th scope="col">Contenu</th>
<th scope="col">Créée le</th>
<th scope="col">Date de clôture</th>
<th scope="col">Référence</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<div class="tab-pane fade" id="v-pills-archives" role="tabpanel" aria-labelledby="v-pills-archives-tab">
<h2><i class="fas fa-angle-down fa-fw"></i> Archives</h2>
<table id="maintab-closed" class="table offres table-striped">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Offre</th>
<th scope="col">Contenu</th>
<th scope="col">Créée le</th>
<th scope="col">Date de clôture</th>
<th scope="col">Référence</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</section>
</div>
{% endblock %}
{% block customJS %}
......
<div class="modal fade form-info-modal" tabindex="-1" role="dialog" aria-labelledby="FormInfoModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h2 class="modal-title" id="form-info">Écrire une nouvelle info</h2>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
{{ form_start(formInfo) }}
<div class="modal-body">
{{ form_errors(formInfo) }}
<div class="form-group row">
<div class="col-sm-4">
{{ form_label(formInfo.title) }}
</div>
<div class="col-sm-8">
{{ form_widget(formInfo.title) }}
{{ form_errors(formInfo.title) }}
</div>
</div>
<div class="form-group row">
<div class="col-sm-4">
{{ form_label(formInfo.subtitle) }}
</div>
<div class="col-sm-8">
{{ form_widget(formInfo.subtitle) }}
{{ form_errors(formInfo.subtitle) }}
</div>
</div>
<div class="form-group row">
<div class="col-sm-4">
{{ form_label(formInfo.text) }}
</div>
<div class="col-sm-8">
{{ form_widget(formInfo.text) }}
{{ form_errors(formInfo.text) }}
</div>
</div>
<div class="form-group row">
<div class="col-sm-4">
{{ form_label(formInfo.isPost) }}
</div>
<div class="col-sm-8">
{{ form_widget(formInfo.isPost) }}
{{ form_errors(formInfo.isPost) }}
</div>
</div>
<div class="form-group row">
<div class="col-sm-4">
{{ form_label(formInfo.postedAt) }}
</div>
<div class="col-sm-8">
{{ form_widget(formInfo.postedAt) }}
{{ form_errors(formInfo.postedAt) }}
</div>
</div>
<div class="form-group row">
<div class="col-sm-4">
{{ form_label(formInfo.status) }}
</div>
<div class="col-sm-8">
{{ form_widget(formInfo.status) }}
{{ form_errors(formInfo.status) }}
</div>
</div>
<div class="form-group row">
<div class="col-sm-4">
{{ form_label(formInfo.color) }}
</div>
<div class="col-sm-8">
{{ form_widget(formInfo.color) }}
{{ form_errors(formInfo.color) }}
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-secondary mb-2" data-dismiss="modal">Fermer</button>
{{ form_label(formInfo.sauver) }}
{{ form_widget(formInfo.sauver) }}
</div>
{{ form_rest(formInfo) }}
{{ form_end(formInfo) }}
</div>
</div>
</div>
......@@ -3,7 +3,7 @@
<div class="modal-content">
<div class="modal-header">
<h2 class="modal-title" id="form-lettre"></h2>
<h2 class="modal-title" id="form-lettre">Écrire une nouvelle infolettre</h2>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
......@@ -16,15 +16,73 @@
<div class="form-group row">
<div class="col-sm-4">
{{ form_label(formLettre.groupe) }}
</div>
<div class="col-sm-8">
{{ form_widget(formLettre.groupe) }}
{{ form_errors(formLettre.groupe) }}
</div>
</div>
<div class="form-group row">
<div class="col-sm-4">
{{ form_label(formLettre.subject) }}
</div>
<div class="col-sm-8">
{{ form_widget(formLettre.subject) }}
{{ form_errors(formLettre.subject) }}
</div>
</div>
<div class="form-group row">
<div class="col-sm-4">
{{ form_label(formLettre.infos) }}
</div>
<div class="col-sm-8">
{{ form_widget(formLettre.infos) }}
{{ form_errors(formLettre.infos) }}
</div>
</div>
<div class="form-group row">
<div class="col-sm-4">
{{ form_label(formLettre.offre) }}
</div>
<div class="col-sm-8">
{{ form_widget(formLettre.offre) }}
{{ form_errors(formLettre.offre) }}
</div>
</div>
<div class="form-group row">
<div class="col-sm-4">
{{ form_label(formLettre.startedAt) }}
</div>
<div class="col-sm-8">
{{ form_widget(formLettre.startedAt) }}
{{ form_errors(formLettre.startedAt) }}
</div>
</div>
<div class="form-group row">
<div class="col-sm-4">
{{ form_label(formLettre.endedAt) }}
</div>
<div class="col-sm-8">
{{ form_widget(formLettre.endedAt) }}
{{ form_errors(formLettre.endedAt) }}
</div>
</div>
<div class="form-group row">
<div class="col-sm-4">
{{ form_label(formLettre.status) }}
</div>
<div class="col-sm-8">
{{ form_widget(formLettre.status) }}
{{ form_errors(formLettre.status) }}
</div>
</div>
</div>
<div class="modal-footer">
......
......@@ -131,7 +131,7 @@ span#rebours {
margin: 0.5em 0;
}
.form-legume-modal .modal-body {
.modal-body {
padding: 3rem;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment