Skip to content

Commit

Permalink
Merge pull request #102 from gerMdz/101-entrada-desde-sección
Browse files Browse the repository at this point in the history
Creando entrada desde section
  • Loading branch information
gerMdz authored Sep 10, 2022
2 parents 4d69f85 + c4c9431 commit b00622d
Show file tree
Hide file tree
Showing 14 changed files with 100 additions and 23 deletions.
2 changes: 1 addition & 1 deletion notas/rama.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### GraceCMS
##### branch
- 98-asegurar-la-busqueda-de-entradas
- git checkout 101-entrada-desde-sección

### Elyon
##### branch
Expand Down
4 changes: 4 additions & 0 deletions src/Controller/AdminEntradaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Entity\Entrada;
use App\Entity\Principal;
use App\Entity\Section;
use App\Form\EntradaComplexType;
use App\Form\EntradaType;
use App\Form\Step\Entrada\StepOneType;
Expand Down Expand Up @@ -203,6 +204,9 @@ public function new(EntityManagerInterface $em, Request $request, UploaderHelper
$entrada = new Entrada();
$user = $this->getUser();
$entrada->setAutor($user);
if($request->get('section')){
$entrada->addSection($this->container->get('doctrine')->getRepository(Section::class)->find($request->get('section')));
}

$form = $this->createForm(EntradaType::class, $entrada);

Expand Down
2 changes: 1 addition & 1 deletion src/Controller/EntradaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function agregarSeccion(Request $request, Entrada $entrada, SectionReposi
return $this->redirectToRoute('admin_entrada_index');
}

return $this->render('admin_entrada/vistaAgregaSection.html.twig', [
return $this->render('admin/entrada/vistaAgregaSection.html.twig', [
'index' => $entrada,
'form' => $form->createView(),
]);
Expand Down
32 changes: 32 additions & 0 deletions src/Controller/SectionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use App\Entity\Principal;
use App\Entity\Section;
use App\Entity\SourceApi;
use App\Form\EntradaSectionType;
use App\Form\SectionFormType;
use App\Form\Step\Section\StepOneType;
use App\Form\Step\Section\StepThreeType;
Expand All @@ -24,6 +25,7 @@
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
Expand Down Expand Up @@ -383,4 +385,34 @@ public function getDataSourceApi(SourceApi $api)
{
return new JsonResponse($this->api->fetchSourceApi($api));
}

/**
* @Route("/agregarEntrada/{id}", name="section_agregar_entrada", methods={"GET", "POST"})
* @param Request $request
* @param Entrada $entrada
* @param SectionRepository $sectionRepository
* @return RedirectResponse|Response
*/
public function agregarSeccion(Request $request, Section $section, EntradaRepository $entradaRepository)
{
$form = $this->createForm(EntradaSectionType::class, $entrada);
$form->handleRequest($request);

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

$id_section = $form->get('section')->getData();
$seccion = $sectionRepository->find($id_section);
$entrada->addSection($seccion);
$entityManager = $this->getDoctrine()->getManager();
$entityManager->persist($entrada);
$entityManager->flush();

return $this->redirectToRoute('admin_entrada_index');
}

return $this->render('admin_entrada/vistaAgregaSection.html.twig', [
'index' => $entrada,
'form' => $form->createView(),
]);
}
}
6 changes: 3 additions & 3 deletions templates/admin/_nav.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="navbar-wrapper">
<a class="navbar-brand" href="javascript:">{{ marca_label|default('Inicio') }}</a>
</div>
<button class="navbar-toggler" type="button" data-toggle="collapse" aria-controls="navigation-index" aria-expanded="false" aria-label="Toggle navigation">
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" aria-controls="navigation-index" aria-expanded="false" aria-label="Toggle navigation">
<span class="sr-only">Toggle navigation</span>
<span class="navbar-toggler-icon icon-bar"></span>
<span class="navbar-toggler-icon icon-bar"></span>
Expand All @@ -30,7 +30,7 @@
{# </a>#}
{# </li>#}
<li class="nav-item dropdown">
<a class="nav-link" href="https://iglesialameda.com" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<a class="nav-link" href="https://iglesialameda.com" id="navbarDropdownMenuLink" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{# <i class="material-icons">notifications</i>#}
{# <span class="notification">5</span>#}
<p class="d-lg-none d-md-block">
Expand All @@ -46,7 +46,7 @@
</div>
</li>
<li class="nav-item dropdown">
<a class="nav-link" href="javascript:;" id="navbarDropdownProfile" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<a class="nav-link" href="javascript:;" id="navbarDropdownProfile" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="material-icons">person</i>
<p class="d-lg-none d-md-block">
Perfil
Expand Down
4 changes: 2 additions & 2 deletions templates/admin/_nav_board.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
{# </a> #}
{# </li> #}
<li class="nav-item dropdown">
<a class="nav-link" href="https://iglesialameda.com" id="navbarDropdownMenuLink" data-toggle="dropdown"
<a class="nav-link" href="https://iglesialameda.com" id="navbarDropdownMenuLink" data-bs-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
{# <i class="material-icons">notifications</i> #}
{# <span class="notification">5</span> #}
Expand All @@ -42,7 +42,7 @@
</div>
</li>
<li class="nav-item dropdown">
<a class="nav-link" href="javascript:;" id="navbarDropdownProfile" data-toggle="dropdown"
<a class="nav-link" href="javascript:;" id="navbarDropdownProfile" data-bs-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
<i class="material-icons">person</i>
<p class="d-lg-none d-md-block">
Expand Down
2 changes: 1 addition & 1 deletion templates/admin/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<script>
$('#admin').addClass('active');
$(function () {
$('[data-toggle="tooltip"]').tooltip()
$('[data-bs-toggle="tooltip"]').tooltip()
})
</script>

Expand Down
2 changes: 1 addition & 1 deletion templates/admin/list_principal.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<p class="text-muted">
{% if principal.principal.linkRoute is defined %}
<small>
<a class="text-info" data-toggle="tooltip"
<a class="text-info" data-bs-toggle="tooltip"
title="Ver linkRoute principal"
href="{{ path('principal_show', {'id': principal.principal.id}) }}">
{{ include('bases/_ver.html.twig', {'button_label': principal.principal.linkRoute }) }}
Expand Down
2 changes: 1 addition & 1 deletion templates/base.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@

<script>
$(document).ready(function () {
$('[data-toggle="tooltip"]').tooltip({html: true, placement: "bottom"});
$('[data-bs-toggle="tooltip"]').tooltip({html: true, placement: "bottom"});
});
</script>

Expand Down
2 changes: 1 addition & 1 deletion templates/base_admin_board.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
{% for message in app.flashes('success') %}
<div class="alert alert-success mt-5 pt-5 mb-0 pb-0 alert-dismissible fade show" role="alert">
{{ message }}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<button type="button" class="close" data-bs-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
Expand Down
22 changes: 11 additions & 11 deletions templates/base_beta.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@
<div class="row justify-content-center">
<div class="col-lg-10">
<div id="carouselAlamedaIndicators" class="carousel slide bg-light u-box-shadow-lg"
data-ride="carousel">
data-bs-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselAlamedaIndicators" data-slide-to="0" class="rounded active"></li>
<li data-target="#carouselAlamedaIndicators" data-slide-to="1" class="rounded"></li>
<li data-target="#carouselAlamedaIndicators" data-slide-to="2" class="rounded"></li>
<li data-bs-target="#carouselAlamedaIndicators" data-bs-slide-to="0" class="rounded active"></li>
<li data-bs-target="#carouselAlamedaIndicators" data-bs-slide-to="1" class="rounded"></li>
<li data-bs-target="#carouselAlamedaIndicators" data-bs-slide-to="2" class="rounded"></li>
</ol>

<div class="carousel-inner">
Expand Down Expand Up @@ -190,13 +190,13 @@
</div>
</div>
</div>
<a class="carousel-control-prev" href="#carouselAlamedaIndicators" role="button" data-slide="prev">
<a class="carousel-control-prev" href="#carouselAlamedaIndicators" role="button" data-bs-slide="prev">
<span aria-hidden="true">
<i class="fas fa-angle-left carousel-control-size"></i>
</span>
<span class="sr-only">Previa</span>
</a>
<a class="carousel-control-next" href="#carouselAlamedaIndicators" role="button" data-slide="next">
<a class="carousel-control-next" href="#carouselAlamedaIndicators" role="button" data-bs-slide="next">
<span aria-hidden="true">
<i class="fas fa-angle-right carousel-control-size"></i>
</span>
Expand All @@ -217,7 +217,7 @@
<div class="container">
<div class="text-center w-md-50 mx-auto py-5">
<a class="display-4 d-inline-block mb-3 text-dark" target="_blank" href="{{ path('avanza') }}"
data-toggle="tooltip" data-placement="top" title="" data-original-title="Avanza">
data-bs-toggle="tooltip" data-bs-placement="top" title="" data-bs-original-title="Avanza">
<i class="fas fa-hand-holding-heart fa-2x mb-1"></i>

</a>
Expand Down Expand Up @@ -600,7 +600,7 @@
</div>
<div class="col-sm-12">
<a href="{{ path('notas') }}" class="text-light-blue"
data-toggle="tooltip"
data-bs-toggle="tooltip"
title="<h5 class='bg-light-blue'><strong>Mas detallles aquí</strong> "><i
class="material-icons btn-sm text-point-sec">local_library</i> Empieza aquí</a>
</div>
Expand Down Expand Up @@ -628,9 +628,9 @@
</div>
<div class="col-sm-9 pull-right ">

<a title="Reviví los mensajes" data-placement="bottom" style="text-decoration-line: none"
<a title="Reviví los mensajes" data-bs-placement="bottom" style="text-decoration-line: none"
href="https://youtube.com/user/IglesiaAlameda" target="_blank"
data-original-title="Reviví los mensajes"
data-bs-original-title="Reviví los mensajes"
>
<blockquote class="bg-danger text-tan blockquote rounded d-flex align-items-center">
<i class="fab fa-youtube-square fa-4x" style="color: #FFF"></i>
Expand Down Expand Up @@ -752,7 +752,7 @@

<script>
$(document).ready(function () {
$('[data-toggle="tooltip"]').tooltip({html: true, placement: "bottom"});
$('[data-bs-toggle="tooltip"]').tooltip({html: true, placement: "bottom"});
});
</script>
<script type="text/javascript">
Expand Down
2 changes: 1 addition & 1 deletion templates/models/entradas/default.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="position-relative">
<img src="{{ entrada.imagePath|imagine_filter('squared_thumbnail_medium') }}"
class="card-img-top img-modal"
data-toggle="modal" data-target="#modal-02"
data-bs-toggle="modal" data-bs-target="#modal-02"
alt="{{ base.lema }}">
</div>
<div class="card-body position-relative mt-n6 mx-2 bg-white text-center rounded border border-light u-box-shadow-lg">
Expand Down
4 changes: 4 additions & 0 deletions templates/section_admin/show.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@
<br/>
{% else %}
No posee
<br/>
{% endfor %}
<a href="{{ path('admin_entrada_new', {'section': section.id }) }}">
Crear entrada
</a>
</td>
</tr>
<tr>
Expand Down
37 changes: 37 additions & 0 deletions templates/section_admin/vistaAgregaEntrada.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<button type="button" class="btn-close" data-bs-dismiss="modal" data-bs-target="#modalPlantillaWeb" aria-label="Close"></button>

{{ form_start(form, {'action' : path('entrada_agregar_seccion', { 'id': index.id })}) }}
<div class="modal-header panel-info">
<h5 class="modal-title" id="exampleModalLabel">Agregar Sección </h5>
</div>

{{ form_start(form, {'action' : path('entrada_agregar_seccion', { 'id': index.id })}) }}
<div id="section-modal" class="modal-body">

{#<div class="modal-body">#}
<div class="card">
<div class="card-header card-header-primary">
<h4 class="card-title "> Secciones </h4>
</div>
<div class="card-body">

<div class="col-sm-12 p-0">
<label for="{{ form.section.vars.id}}" class="label text-dark">
<i class="fa fa-list"> </i> Sección
</label>
{{ form_widget(form.section) }}
</div>

<div class="col-sm-12 p-0 text-center">
{{ form_row(form.save) }}
</div>
{{ form_widget(form._token) }}
</div>
</div>
</div>

{{ form_end(form, {'render_rest': false}) }}
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cerrar</button>

</div>

0 comments on commit b00622d

Please sign in to comment.