Commit 547acb07 authored by Mat's avatar Mat

init OffreLegume/ajaxMainDisplay, elle s'affiche

parent 0e9f1553
......@@ -87,6 +87,7 @@ fos_js_routing:
routes_to_expose:
- api_legume_*
- api_offre_*
- potage_offre_legumes_ajax_display
# VichUploaderBundle Configuration
vich_uploader:
......
<?php
namespace APIBundle\Form;
use PotageBundle\Form\Offre\OffreLegumesType;
use Symfony\Component\OptionsResolver\OptionsResolver;
class OffreLegumesAPIType extends OffreLegumesType
{
/**
* @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));
}
}
......@@ -3,6 +3,7 @@
namespace PotageBundle\Controller;
use APIBundle\Form\OffreAPIType;
use APIBundle\Form\OffreLegumesAPIType;
class OffreController extends MasterController
{
......@@ -17,4 +18,26 @@ class OffreController extends MasterController
'formOffre' => $form->createView()
));
}
/**
* @param $id
* @return \Symfony\Component\HttpFoundation\Response|\Symfony\Component\HttpKernel\Exception\NotFoundHttpException
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function readOneAction($id)
{
$offre = $this->getDoctrine()->getManager()
->getRepository('PotageBundle:Offre')->findOneForAPIRead($id);
if ($offre === null) {
return $this->createNotFoundException('Non trouvé');
}
$form = $this->createForm(OffreLegumesAPIType::class);
return $this->render('@Potage/OffreLegumes/ajaxDisplay.html.twig', array(
'id' => $id,
'offre' => $offre,
'formOffreLegumes' => $form->createView()
));
}
}
<?php
namespace PotageBundle\Controller;
use APIBundle\Form\OffreLegumesAPIType;
class OffreLegumesController extends MasterController
{
/**
* @param $id
* @return \Symfony\Component\HttpFoundation\Response|\Symfony\Component\HttpKernel\Exception\NotFoundHttpException
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function ajaxDisplayAction($id)
{
$offre = $this->getDoctrine()->getManager()
->getRepository('PotageBundle:Offre')->findOneForAPIRead($id);
if ($offre === null) {
return $this->createNotFoundException('Non trouvé');
}
$form = $this->createForm(OffreLegumesAPIType::class);
return $this->render('@Potage/OffreLegumes/ajaxDisplay.html.twig', array(
'id' => $id,
'offre' => $offre,
'formOffreLegumes' => $form->createView()
));
}
}
<?php
namespace PotageBundle\Form\Offre;
use PotageBundle\Entity\OffreLegumes;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Vich\UploaderBundle\Form\Type\VichImageType;
class OffreLegumesType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
parent::buildForm($builder, $options);
$builder->add('fruit', ChoiceType::class, array(
'label' => "Fruit ou légume ?",
'choices' => array(
'Fruit' => true,
'Légume' => false,
),
'label_attr' => array('class' => 'col-form-label'),
'attr' => array(
'class' => 'form-control form-control-sm',
'autofocus' => true,
),
));
$builder->add('nom', TextType::class, array(
'label' => "Nom",
'label_attr' => array('class' => 'col-form-label'),
'attr' => array(
'class' => 'form-control form-control-sm',
),
));
$builder->add('description', TextareaType::class, array(
'label' => "Description",
'label_attr' => array('class' => 'col-form-label'),
'attr' => array(
'class' => 'form-control form-control-sm',
),
));
$builder->add('revente', CheckboxType::class, array(
'label' => "C'est un produit de revente",
'required' => false,
));
$builder->add('origine', TextType::class, array(
'required' => false,
'label' => "Origine",
'label_attr' => array('class' => 'col-form-label'),
'attr' => array(
'class' => 'form-control form-control-sm',
),
));
$builder->add('unite', ChoiceType::class, array(
'label' => "Unité",
'choices' => array(
'le kilo' => 'kg',
'la pièce' => 'pièce',
'la botte' => 'botte',
),
'label_attr' => array('class' => 'col-form-label'),
'attr' => array(
'class' => 'form-control form-control-sm',
),
));
$builder->add('quantiteMin', NumberType::class, array(
'label' => "Quantité minimale",
'label_attr' => array('class' => 'col-form-label'),
'attr' => array(
'class' => 'form-control form-control-sm',
),
));
$builder->add('quantiteMax', NumberType::class, array(
'label' => "Quantité maximale",
'label_attr' => array('class' => 'col-form-label'),
'attr' => array(
'class' => 'form-control form-control-sm',
),
));
$builder->add('quantiteStep', NumberType::class, array(
'label' => "Écart (step)",
'label_attr' => array('class' => 'col-form-label'),
'attr' => array(
'class' => 'form-control form-control-sm',
),
));
$builder->add('prixUnitaire', MoneyType::class, array(
'label' => "Prix unitaire",
'label_attr' => array('class' => 'col-form-label'),
'attr' => array(
'class' => 'form-control form-control-sm',
'placeholder' => '€',
),
));
$builder->add('imageFile', VichImageType::class, array(
'label' => "Téléverser une image",
'label_attr' => array('class' => 'col-form-label'),
'attr' => array(
'class' => 'form-control-sm',
),
));
/* TODO les champs en plus
*/
$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', OffreLegumes::class);
$resolver->setDefault('attr', array(
'class' => 'formulaire formulaire_offre_legumes',
));
}
public function getBlockPrefix()
{
return 'offre_legumes';
}
}
......@@ -76,4 +76,17 @@ class OffreRepository extends \Doctrine\ORM\EntityRepository
));
return $qb->getQuery()->getOneOrNullResult();
}
/**
* @param $id
* @return mixed
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function findOneForAPIRead($id)
{
$qb = $this->createQueryBuilder('o')
->where('o.id = :id')
->setParameter(':id', $id);
return $qb->getQuery()->getOneOrNullResult();
}
}
......@@ -45,3 +45,11 @@ potage_offre_ajax_display:
_controller: PotageBundle:Offre:ajaxDisplay
methods: [ GET ]
potage_offre_legumes_ajax_display:
path: /admin/offre/{id}
requirements:
id: \d+
defaults:
_controller: PotageBundle:Offre:readOne
methods: [ GET ]
......@@ -254,9 +254,14 @@
let td6 = document.createElement('td');
let referenceBtn = document.createElement('a');
referenceBtn.setAttribute('href', '#');
let href = Routing.generate('potage_offre_legumes_ajax_display', {'id': jsonRow.id });
referenceBtn.setAttribute('href', href);
<<<<<<< Updated upstream
referenceBtn.setAttribute('title', 'Éditer');
referenceBtn.classList.add('btn', 'btn-outline-dark', 'btn-sm', 'mb-2', 'mr-2');
=======
referenceBtn.classList.add('btn', 'btn-outline-dark', 'btn-sm');
>>>>>>> Stashed changes
referenceBtn.textContent = jsonRow.reference;
td6.appendChild(referenceBtn);
if (jsonRow.status === 'draft')
......
{% extends '@Potage/layout.html.twig' %}
{% block title %}
Offre # {{ id }}
{% endblock %}
{% block searchbar %}
<nav class="navbar navbar-expand-lg navbar-light bg-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>
</form>
<b>
<a href="{{ path('potage_offre_ajax_display') }}" class="nav-laterale left text-secondary"><i class="fas fa-long-arrow-alt-up fa-fw"></i> Toutes les offres</a>
</b>
</nav>
{% endblock %}
{% block headerContent %}
<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-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-offre-modal">
<i class="fas fa-plus"></i>
Créer une nouvelle offre
</a>
</div>
</div>
</div>
{% endblock %}
{% block sidebarContent %}
<div class="row">
<aside class="col-3">
<div class="card">
<ul class="list-group list-group-flush">
<div class="card-body">
<h3>
{{ offre.reference }}
</h3>
</div>
<li class="list-group-item d-flex justify-content-between align-items-center">
<dt>Créée le </dt><dd>{{ offre.createdAt.format('d/m/Y H:i') }}</dd>
</li>
{#
<li class="list-group-item d-flex justify-content-between align-items-center">
<dt>Dernière modification: </dt><dd>{{ offre.updatedAt.format('d/m/Y H:i') }}</dd>
</li>
#}
<li class="list-group-item list-group-item-action {#list-group-item-warning#}">
<dt>Statut: </dt><dd>{{ offre.status }}</dd>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
<dt>Date d'expiration: </dt><dd>{{ offre.endedAt.format('d/m/Y H:i') }}</dd>
</li>
<li class="list-group-item d-flex">
<button class="btn btn-dark btn-sm mr-2 mb-2">
Modifier
</button>
<button class="btn btn-danger btn-sm mb-2">
Supprimer
</button>
</li>
</ul>
</div>
</aside>
{% endblock %}
{% block sectionContent %}
<section class="col-9">
{#
{% include '@Potage/OffreLegumes/ajaxForm.html.twig' %}
{{ dump() }}
#}
</section>
</div>
{% 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 %}
......@@ -41,7 +41,7 @@ nav.navbar-search {
right: 0.3em;
}
/**/
/*
footer#footer:before,
nav.navbar-search:before {
content: ' ';
......@@ -51,9 +51,10 @@ nav.navbar-search:before {
background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHdpZHRoPScxMDAlJyBoZWlnaHQ9JzEwMCUnPgoJPGRlZnM+CgkJPHBhdHRlcm4gaWQ9J3RpbGUnIHBhdHRlcm5Vbml0cz0ndXNlclNwYWNlT25Vc2UnIHdpZHRoPSc3NScgaGVpZ2h0PSc3NScgdmlld0JveD0nMCAwIDUwIDUwJz4KCQkJPGxpbmUgeDE9JzEnIHkxPScwJyB4Mj0nNTEnIHkyPSc1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bGUpJyB3aWR0aD0nMTAwJScgaGVpZ2h0PScxMDAlJy8+Cgk8cmVjdCB3aWR0aD0nMTAwJScgaGVpZ2h0PScxMDAlJyBmaWxsPSd1cmwoI2wpJy8+Cjwvc3ZnPg==);
opacity: 0.4;
}
*/
footer#footer,
nav.navbar-search {
background-image: url("img/legume_background.nb.3.png");
background-image: url("img/legume_background.nb.4.png");
/*
background-color: #9adbfb; */
background-repeat: repeat;
......@@ -61,7 +62,7 @@ nav.navbar-search {
}
#offre_ajax_display footer#footer,
#offre_ajax_display .navbar-search {
background-image: url("img/offre_background.3.png");
background-image: url("img/offre_background.4.png");
background-size: 270px;
}
......
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