Skip to content

Commit

Permalink
Merge pull request #204 from gerMdz/add-gentella-admin
Browse files Browse the repository at this point in the history
Add gentella admin
  • Loading branch information
gerMdz authored Oct 29, 2023
2 parents 0d4e820 + f36d250 commit d135816
Show file tree
Hide file tree
Showing 25 changed files with 652 additions and 580 deletions.
41 changes: 22 additions & 19 deletions src/Controller/SectionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,16 @@ public function __construct(SessionInterface $session, HandlerSourceApi $api)
*/
public function list(SectionRepository $repository, PaginatorInterface $paginator, Request $request): Response
{
$seccion = $repository->getSections();
$bus = $request->get('busq');

$seccion = $repository->getSections($bus);
$secciones = $paginator->paginate(
$seccion, /* query NOT result */
$request->query->getInt('page', 1)/*page number*/,
20/*limit per page*/
);

return $this->render('section_admin/list.html.twig', [
return $this->render('admin/section_admin/list.html.twig', [
'sections' => $secciones,
]);
}
Expand Down Expand Up @@ -122,7 +124,7 @@ public function new(EntityManagerInterface $em, Request $request, UploaderHelper
return $this->redirectToRoute('admin_section_list');
}

return $this->render('section_admin/new.html.twig', [
return $this->render('admin/section_admin/new.html.twig', [
'sectionForm' => $form->createView(),
]);
}
Expand All @@ -149,12 +151,12 @@ public function edit(Request $request, Section $section, UploaderHelper $uploade
$newFilename = $uploaderHelper->uploadEntradaImage($uploadedFile, $section->getImageFilename());
$section->setImageFilename($newFilename);
}
$this->getDoctrine()->getManager()->flush();
$this->container->get('doctrine')->getManager()->flush();

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

return $this->render('section_admin/edit.html.twig', [
return $this->render('admin/section_admin/edit.html.twig', [
'section' => $section,
'sectionForm' => $form->createView(),
]);
Expand Down Expand Up @@ -272,7 +274,7 @@ public function mostrarSection(Section $section, EntradaRepository $entradaRepos
*/
public function show(Section $section): Response
{
return $this->render('section_admin/show.html.twig', [
return $this->render('admin/section_admin/show.html.twig', [
'section' => $section,
]);
}
Expand All @@ -282,7 +284,7 @@ public function show(Section $section): Response
* @param Request $request
* @return Response
* @throws Exception
* @IsGranted("ROLE_ADMIN")
* @IsGranted("ROLE_ESCRITOR")
*/
public function newStepOne(Request $request): Response
{
Expand All @@ -294,7 +296,7 @@ public function newStepOne(Request $request): Response

$principal = $form['principal']->getData();
$section->addPrincipale($principal);
$entityManager = $this->getDoctrine()->getManager();
$entityManager = $this->container->get('doctrine')->getManager();
$entityManager->persist($section);
$entityManager->flush();

Expand All @@ -303,7 +305,7 @@ public function newStepOne(Request $request): Response
]);
}

return $this->render('section_admin/new_step1.html.twig', [
return $this->render('admin/section_admin/new_step1.html.twig', [
'section' => $section,
'sectionForm' => $form->createView(),
]);
Expand All @@ -315,7 +317,7 @@ public function newStepOne(Request $request): Response
* @param Section $section
* @param ModelTemplateRepository $modelTemplateRepository
* @return Response
* @IsGranted("ROLE_ADMIN")
* @IsGranted("ROLE_ESCRITOR")
*/
public function newStepTwo(
Request $request,
Expand All @@ -336,14 +338,14 @@ public function newStepTwo(
}
$this->session->remove('model_template_id');
}
$this->getDoctrine()->getManager()->flush();
$this->container->get('doctrine')->getManager()->flush();

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

return $this->render('section_admin/new_step2.html.twig', [
return $this->render('admin/section_admin/new_step2.html.twig', [
'section' => $section,
'sectionForm' => $form->createView(),
]);
Expand All @@ -354,7 +356,7 @@ public function newStepTwo(
* @param Request $request
* @param Section $section
* @return Response
* @IsGranted("ROLE_ADMIN")
* @IsGranted("ROLE_ESCRITOR")
*/
public function newStepThree(Request $request, Section $section): Response
{
Expand All @@ -364,14 +366,14 @@ public function newStepThree(Request $request, Section $section): Response

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

$this->getDoctrine()->getManager()->flush();
$this->container->get('doctrine')->getManager()->flush();

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

return $this->render('section_admin/new_step3.html.twig', [
return $this->render('admin/section_admin/new_step3.html.twig', [
'section' => $section,
'sectionForm' => $form->createView(),
]);
Expand All @@ -387,30 +389,31 @@ public function getDataSourceApi(SourceApi $api)
}

/**
* La idea es agregar una entrada ya creada a una sección, falta el modal que selecciona la entrada
* @Route("/agregarEntrada/{id}", name="section_agregar_entrada", methods={"GET", "POST"})
* @param Request $request
* @param Entrada $entrada
* @param Entrada $section
* @param SectionRepository $sectionRepository
* @return RedirectResponse|Response
*/
public function agregarSeccion(Request $request, Section $section, EntradaRepository $entradaRepository)
{
$form = $this->createForm(EntradaSectionType::class, $entrada);
$form = $this->createForm(EntradaSectionType::class, $section);
$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 = $this->container->get('doctrine')->getManager();
$entityManager->persist($entrada);
$entityManager->flush();

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
9 changes: 7 additions & 2 deletions src/Form/SectionFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,17 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'attr' => [
'class' => 'form-check-input ',
],
'help' => 'Se mostrará la sección'
])
->add('disponibleAt', null, [
'widget' => 'single_text',
'label'=>'Inicia',
'html5' => true,
'required' => false,
// 'format' => 'yyyy-MM-dd HH:mm',
'attr' => ['class' => 'datetimepicker']
// 'attr' => ['class' => 'datetimepicker']
'attr' => ['class' => 'form-control '],
'input' => 'datetime',
])
->add('columns', IntegerType::class, [
'label' => 'Cantidad de columnas',
Expand All @@ -64,7 +67,9 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'html5' => true,
'required' => false,
// 'format' => 'yyyy-MM-dd HH:mm',
'attr' => ['class' => 'datetimepicker']
// 'attr' => ['class' => 'datetimepicker']
'attr' => ['class' => 'form-control '],
'input' => 'datetime',
))
->add('orden', IntegerType::class, [
'label' => 'Orden en la página',
Expand Down
3 changes: 2 additions & 1 deletion src/Form/Step/Section/StepOneType.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
namespace App\Form\Step\Section;

use App\Entity\Section;
use Doctrine\Common\Persistence\ManagerRegistry;

use Doctrine\Persistence\ManagerRegistry;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
Expand Down
6 changes: 1 addition & 5 deletions src/Form/Step/Section/StepThreeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@


use App\Entity\Section;
use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\Persistence\ManagerRegistry;
use FOS\CKEditorBundle\Form\Type\CKEditorType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
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;

Expand Down
13 changes: 1 addition & 12 deletions src/Form/Step/Section/StepTwoType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,18 @@


use App\Entity\Section;
use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\Persistence\ManagerRegistry;
use FOS\CKEditorBundle\Form\Type\CKEditorType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
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;

class StepTwoType extends AbstractType
{

private $registry;

/**
* SectionFormType constructor.
* @param ManagerRegistry $registry
*/
public function __construct(ManagerRegistry $registry)
{
$this->registry = $registry;
}


public function buildForm(FormBuilderInterface $builder, array $options)
Expand Down
25 changes: 20 additions & 5 deletions src/Repository/SectionRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,25 @@ private function getQueryBuilderOrderByUpdate(QueryBuilder $qb = null): QueryBui
}


public function getSections(): QueryBuilder
public function getSections(?string $qSearch): QueryBuilder
{
return $this->createQueryBuilder('s')
$qb = $this->createQueryBuilder('s')
->orderBy('s.updatedAt', 'DESC')
->addOrderBy('s.name', 'ASC');
if ($qSearch) {
$qb->leftJoin('s.autor', 'a')
->addSelect('a');
$qb->leftJoin('s.entradas', 'e')
->addSelect('e');
$qb->leftJoin('s.principales', 'p')
->addSelect('p');
$qb->andWhere(
'UPPER(s.contenido) LIKE :qsearch OR upper(a.primerNombre) LIKE :qsearch OR upper(s.title) LIKE :qsearch OR upper(p.titulo) LIKE :qsearch OR upper(e.titulo) LIKE :qsearch'
)
->setParameter('qsearch', '%' . mb_strtoupper($qSearch) . '%');
}

return $qb;
}


Expand Down Expand Up @@ -120,10 +134,11 @@ public function queryFindSectionsByPrincipal(string $id): QueryBuilder
}

public function sectionByDateAndActiveAndModification(
$fecha_inicial ,
$fecha_final ,
$fecha_inicial,
$fecha_final,
?array $notSection
): QueryBuilder {
): QueryBuilder
{

$qb = $this->createQueryBuilder('s')
->select()
Expand Down
47 changes: 19 additions & 28 deletions templates/admin/bars.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -41,37 +41,33 @@
<ul class="nav side-menu">
<li>
<a href="{{ path('app_admin_main') }}">
<i class="fa-solid fa-house"></i> {{ "backend.menu.home"|trans }}
<i class="fa-solid fa-house"></i>
{{ "backend.menu.home"|trans }}
</a>
</li>


<li>
<a>
<i class="fa-regular fa-clipboard"></i>
<a href="{{ path('admin_entrada_index') }}">
<i class="fa fa-clipboard" aria-hidden="true"></i>
{{ "backend.menu.posts"|trans }}
<span class="fa-solid fa-chevron-down">
</span>
</a>
<ul class="nav child_menu">
<li>
<a href="{{ path('admin_entrada_index') }}">
{{ "backend.menu.manage"|trans }}
</a>
</li>
</ul>
</li>
<li><a><i class="fa-regular fa-clipboard"></i> {{ "backend.menu.blog"|trans }} <span
class="fa-solid fa-chevron-down"></span></a>
<ul class="nav child_menu">
<li>
<a href="{{ path('admin_section_list') }}">
<i class="fa fa-puzzle-piece" aria-hidden="true"></i>
{{ "backend.menu.section"|trans }}
</a>
</li>
{# <li><a><i class="fa-regular fa-clipboard"></i> {{ "backend.menu.blog"|trans }} <span #}
{# class="fa-solid fa-chevron-down"></span></a> #}
{# <ul class="nav child_menu"> #}


<li>
<a href="{{ path('admin_section_list') }}">{{ "backend.menu.history"|trans }}</a>
</li>
{# <li> #}
{# <a href="{{ path('admin_section_list') }}">{{ "backend.menu.history"|trans }}</a> #}
{# </li> #}

</ul>
</li>
{# </ul> #}
{# </li> #}
<li>
<a href="{{ path('principal_index') }}">
<i class="fa fa-laptop" aria-hidden="true"></i>
Expand Down Expand Up @@ -209,12 +205,7 @@

</ul>
</li>
<li>
<a href="{{ path('admin_section_list') }}">
<i class="fa fa-puzzle-piece" aria-hidden="true"></i>
{{ "backend.menu.section"|trans }}
</a>
</li>

<li>
<a href="{{ path('app_source_api_index') }}">
<i class="fa fa-cloud" aria-hidden="true"></i>
Expand Down
Loading

0 comments on commit d135816

Please sign in to comment.