Commit 1429897e authored by Mat's avatar Mat
Browse files

Prépare le template complet de la page Utilisateur/ajaxDisplay

parent 0ea749c1
<?php
namespace APIBundle\Form;
use PotageBundle\Form\Utilisateur\UtilisateurType;
use Symfony\Component\OptionsResolver\OptionsResolver;
class UtilisateurAPIType extends UtilisateurType
{
/**
* @param OptionsResolver $resolver
*/
public function configureOptions(OptionsResolver $resolver)
{
parent::configureOptions($resolver);
$resolver->setDefault('csrf_protection', false);
// TODO temporaire, le temps de régler les validations au niveau des Asserts et des FormType
$resolver->setDefault('attr', array('novalidate' => true));
}
}
<?php
namespace PotageBundle\Controller;
use APIBundle\Form\UtilisateurAPIType;
class UtilisateurController extends MasterController
{
/**
* @return \Symfony\Component\HttpFoundation\Response
*/
public function ajaxDisplayAction()
{
$form = $this->createForm(UtilisateurAPIType::class);
return $this->render('@Potage/Utilisateur/ajaxDisplay.html.twig', array(
'formUtilisateur' => $form->createView()
));
}
}
......@@ -72,4 +72,14 @@ class User extends BaseUser
{
return $this->utilisateur;
}
/**
*
* @return string
*/
public function getUsernameEmail()
{
return parent::getUsername() . ' ( ' . parent::getEmail() . ' )';
}
}
<?php
namespace PotageBundle\Form\Utilisateur;
use PotageBundle\Entity\Depot;
use PotageBundle\Entity\Groupe;
use PotageBundle\Entity\User;
use PotageBundle\Entity\Utilisateur;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class UtilisateurType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('nom', TextType::class, array(
'label' => 'Nom',
'label_attr' => array('class' => 'label-common'),
'attr' => array(
'class' => 'form-control form-control-sm',
'min' => "5",
'max' => "255",
),
));
$builder->add('prenom', TextType::class, array(
'label' => 'Prénom', // peut prendre 'false'
'label_attr' => array('class' => 'super-label label-common'),
'attr' => array(
'class' => 'form-control form-control-sm',
'autofocus' => true,
'min' => "5",
'max' => "255",
),
));
$builder->add('email', EmailType::class, array(
'required' => false,
'label' => 'Adresse email',
'label_attr' => array('class' => 'label-common'),
'attr' => array(
'placeholder' => "@",
'class' => 'form-control form-control-sm',
),
));
$builder->add('groupes', EntityType::class, array(
'class' => Groupe::class,
'label' => "Groupes de mangeurs",
'placeholder' => "Fait partie du/des groupe/s",
'choice_label' => 'getNom',
'expanded' => true,
'multiple' => true,
'label_attr' => array('class' => 'col-form-label'),
'attr' => array('class' => ''),
));
$builder->add('user', EntityType::class, array(
'class' => User::class,
'label' => "Compte utilisateur",
'placeholder' => "< choisissez dans la liste >",
'choice_label' => 'getUsernameEmail',
'label_attr' => array('class' => 'col-form-label'),
'attr' => array('class' => 'form-control form-control-sm'),
));
/*
$builder->add('depot', EntityType::class, array(
'class' => Depot::class,
'label' => "Responsable d'un dépôt",
'placeholder' => '',
'choice_label' => 'getLocalisation',
'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')
));
}
public function configureOptions(OptionsResolver $resolver)
{
parent::configureOptions($resolver);
$resolver->setDefault('data_class', Utilisateur::class);
$resolver->setDefault('attr', array(
'class' => 'formulaire formulaire_utilisateur',
));
}
public function getBlockPrefix()
{
return 'utilisateur';
}
}
......@@ -43,8 +43,8 @@ potage_groupe_ajax_display:
_controller: PotageBundle:Groupe:ajaxDisplay
methods: [ GET ]
potage_depot_ajax_display:
path: /admin/depots
potage_utilisateur_ajax_display:
path: /admin/utilisateurs
defaults:
_controller: PotageBundle:Depot:ajaxDisplay
_controller: PotageBundle:Utilisateur:ajaxDisplay
methods: [ GET ]
......@@ -45,9 +45,9 @@
<a class="dropdown-item disabled" href="#">Les commandes</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item disabled" href="#">Les utilisateurs</a>
<a class="dropdown-item" href="{{ path('potage_utilisateur_ajax_display') }}">Les utilisateurs</a>
<a class="dropdown-item" href="{{ path('potage_groupe_ajax_display') }}">Les groupes</a>
<a class="dropdown-item" href="{{ path('potage_depot_ajax_display') }}">Les points de dépôt</a>
</div>
</li>
......
......@@ -7,7 +7,7 @@
{% block searchbar %}
<nav class="navbar navbar-expand-lg navbar-light navbar-search">
<a href="{{ path('potage_lettre_ajax_display') }}" class="nav-laterale left text-secondary"><i class="fas fa-long-arrow-alt-left fa-fw"></i> Les infolettres</a>
<a href="#" class="nav-laterale right text-secondary">Les utilisateurs <i class="fas fa-long-arrow-alt-right fa-fw"></i></a>
<a href="{{ path('potage_utilisateur_ajax_display') }}" class="nav-laterale right text-secondary">Les utilisateurs <i class="fas fa-long-arrow-alt-right fa-fw"></i></a>
</nav>
{% endblock %}
......
{% extends '@Potage/layout.html.twig' %}
{% block title %}
Les utilisateurs
{% endblock %}
{% block searchbar %}
<nav class="navbar navbar-expand-lg navbar-light navbar-search">
<form class="form-inline my-2 my-lg-0" style="margin: auto;">
<div class="input-group input-group-lg">
<div class="input-group-prepend">
<span class="input-group-text" id="inputGroup-sizing-lg"><i class="fas fa-search"></i></span>
</div>
<input id="search" type="search" class="form-control" placeholder="Rechercher"
aria-label="LargeSearch" aria-describedby="inputGroup-sizing-sm">
</div>
<span id="rebours"></span>
</form>
<a href="{{ path('potage_groupe_ajax_display') }}" class="nav-laterale left text-secondary"><i class="fas fa-long-arrow-alt-left fa-fw"></i> Les groupes et les dépôts</a>
<a href="#" class="nav-laterale right text-secondary">Les commandes <i class="fas fa-long-arrow-alt-right fa-fw"></i></a>
</nav>
{% endblock %}
{% block headerContent %}
<div class="row">
<div class="col left hd-1">
<h1>{{ block('title') }}</h1>
<div>
<span id="totalRows"></span>
<span id="totalPages"></span>
</div>
<form id="pagination">
<select class="custom-select custom-select-sm" title="Pagination">
<option value="-1" selected>Pagination</option>
<option value="5">5</option>
<option value="10">10</option>
<option value="20">20</option>
<option value="50">50</option>
<option value="100">100</option>
</select>
</form>
</div>
<div class="col right hd-1">
<div style="margin-top: 0.65em; margin-bottom: 1em;">
<a href="javascript: void(0);" class="btn btn-outline-dark mb-2 btn-reload">
<i class="fas fa-sync-alt"></i>
Rafraîchir la liste
</a>
<a href="javascript: void(0);" class="btn btn-dark mb-2 btn-create"
data-toggle="modal" data-target=".form-utilisateur-modal">
<i class="fas fa-plus"></i>
Ajouter un nouvel utilisateur
</a>
</div>
</div>
</div>
{% endblock %}
{% block sidebarContent %}
{% include '@Potage/Utilisateur/ajaxForm.html.twig' %}
{% endblock %}
{% block sectionContent %}
<section>
<nav id="pagenav" aria-label="page navigation legume">
<ul class="pagination justify-content-center">
</ul>
</nav>
<table id="maintab" class="table utilisateurs table-striped">
<thead>
<tr>
<th scope="col">
<a href="javascript: void(0);" id="id" class="btn-sort">#
</a>
</th>
<th scope="col">
<a href="javascript: void(0);" id="nom" class="btn-sort">Nom
</a>
</th>
<th scope="col">
<a href="javascript: void(0);" id="prenom" class="btn-sort">Prénom
</a>
</th>
<th scope="col">
<a href="javascript: void(0);" id="email" class="btn-sort">Email
</a>
</th>
<th scope="col">
<a href="javascript: void(0);" id="groupes" class="btn-sort">Groupes
</a>
</th>
<th scope="col">
<a href="javascript: void(0);" id="login" class="btn-sort">Compte FOSUser
</a>
</th>
<th scope="col">
<a id="action">Action
</a>
</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</section>
{% endblock %}
{% block customJS %}
<script type="text/javascript" src="{{ asset('js/functions.js') }}"></script>
<script type="text/javascript" src="{{ asset('js/ajax_functions.js') }}"></script>
<script type="text/javascript">
</script>
{% endblock %}
{#
#}
\ No newline at end of file
<div class="modal fade form-utilisateur-modal" tabindex="-1" role="dialog" aria-labelledby="FormUtilisateurModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h2 class="modal-title" id="form-utilisateur">Ajouter un nouvel utilisateur</h2>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
{{ form_start(formUtilisateur) }}
<div class="modal-body">
{{ form_errors(formUtilisateur) }}
<div class="form-group row">
<div class="col-sm-4">
{{ form_label(formUtilisateur.nom) }}
</div>
<div class="col-sm-8">
{{ form_widget(formUtilisateur.nom) }}
{{ form_errors(formUtilisateur.nom) }}
</div>
</div>
<div class="form-group row">
<div class="col-sm-4">
{{ form_label(formUtilisateur.prenom) }}
</div>
<div class="col-sm-8">
{{ form_widget(formUtilisateur.prenom) }}
{{ form_errors(formUtilisateur.prenom) }}
</div>
</div>
<div class="form-group row">
<div class="col-sm-4">
{{ form_label(formUtilisateur.email) }}
</div>
<div class="col-sm-8">
{{ form_widget(formUtilisateur.email) }}
{{ form_errors(formUtilisateur.email) }}
</div>
</div>
<div class="form-group row">
<div class="col-sm-4">
{{ form_label(formUtilisateur.groupes) }}
</div>
<div class="col-sm-8">
{{ form_widget(formUtilisateur.groupes) }}
{{ form_errors(formUtilisateur.groupes) }}
</div>
</div>
<div class="form-group row">
<div class="col-sm-4">
{{ form_label(formUtilisateur.user) }}
</div>
<div class="col-sm-8">
{{ form_widget(formUtilisateur.user) }}
{{ form_errors(formUtilisateur.user) }}
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-secondary mb-2" data-dismiss="modal">Fermer</button>
{{ form_label(formUtilisateur.sauver) }}
{{ form_widget(formUtilisateur.sauver) }}
</div>
{{ form_rest(formUtilisateur) }}
{{ form_end(formUtilisateur) }}
</div>
</div>
</div>
\ No newline at end of file
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