Skip to content

Commit

Permalink
Merge pull request #21 from gerMdz/20-wizard-entrada
Browse files Browse the repository at this point in the history
20-wizard-entrada, wizard de solo 2 pasos, aunque eso sigie
  • Loading branch information
gerMdz authored Jun 1, 2021
2 parents 2468b2e + a852e55 commit ec16917
Show file tree
Hide file tree
Showing 13 changed files with 568 additions and 125 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,5 @@ yarn-error.log
/public/images/base.jpg
/public/images/logo-mail.png
/public/images/logo.png
/migrations/
/migrations/Version20210515203711.php
2 changes: 1 addition & 1 deletion assets/js/select2.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'select2/dist/css/select2.css'; // optional if you have css loader

$(function () {
$('.select2-enable').select2({
placeholder: 'Seleccione la página en donde se insertará la sección',
placeholder: 'Seleccione item de la lista',
allowClear: true
});

Expand Down
62 changes: 62 additions & 0 deletions src/Controller/AdminEntradaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
namespace App\Controller;

use App\Entity\Entrada;
use App\Entity\Section;
use App\Form\EntradaComplexType;
use App\Form\EntradaType;
use App\Form\Step\Entrada\StepOneType;
use App\Form\Step\Entrada\StepTwoType;
use App\Repository\EntradaRepository;
use App\Service\BoleanToDateHelper;
use App\Service\LoggerClient;
Expand Down Expand Up @@ -219,6 +222,65 @@ public function new(EntityManagerInterface $em, Request $request, UploaderHelper
'entrada' => $entrada,
]);
}
/**
* @Route("/admin/new/step1", name="admin_entrada_new_step1", methods={"GET","POST"})
* @param Request $request
* @return Response
* @throws Exception
* @IsGranted("ROLE_ADMIN")
*/
public function newStepOne(Request $request): Response
{
$entrada = new Entrada();
$form = $this->createForm(StepOneType::class, $entrada);
$form->handleRequest($request);

if ($form->isSubmitted() && $form->isValid()) {
$section = $form['section']->getData();
$entrada->addSection($section);
$entityManager = $this->getDoctrine()->getManager();
$entityManager->persist($entrada);
$entityManager->flush();

return $this->redirectToRoute('admin_entrada_new_step2', [
'id' => $entrada->getId()
]);
}

return $this->render('admin_entrada/new_step.html.twig', [
'entrada' => $entrada,
'entradaForm' => $form->createView(),
]);
}

/**
* @Route("/admin/new/step2/{id}", name="admin_entrada_new_step2", methods={"GET","POST"})
* @param Request $request
* @param Entrada $entrada
* @return Response
* @IsGranted("ROLE_ADMIN")
*/
public function newStepTwo(Request $request, Entrada $entrada): Response
{

$form = $this->createForm(StepTwoType::class, $entrada);
$form->handleRequest($request);

if ($form->isSubmitted() && $form->isValid()) {

$this->getDoctrine()->getManager()->flush();

return $this->redirectToRoute('admin_entrada_new_step3', [
'id' => $entrada->getId()
]);
}

return $this->render('admin_entrada/new_step2.html.twig', [
'entrada' => $entrada,
'entradaForm' => $form->createView(),
]);
}


/**
* @Route("/admin/entrada/{linkRoute}", name="entrada_admin_link")
Expand Down
20 changes: 20 additions & 0 deletions src/Entity/Entrada.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ class Entrada
*/
private $button;

/**
* @ORM\Column(type="string", length=150, nullable=true, unique=true)
*/
private $identificador;

public function __construct()
{
$this->entradaReferences = new ArrayCollection();
Expand Down Expand Up @@ -519,4 +524,19 @@ public function removeButton(ButtonLink $button): self
return $this;
}

public function getIdentificador(): ?string
{
return $this->identificador;
}

public function setIdentificador(?string $identificador): self
{
if(null === $identificador){
$identificador = str_replace(' ', '-',strip_tags($this->titulo));
}
$this->identificador = $identificador;

return $this;
}

}
Loading

0 comments on commit ec16917

Please sign in to comment.