Terminando las busquedas basicas para el segundo dropdown, falta a implementar que peuden acceptar ams de una palabara y la barra de busqueda de lista como ahora me hace la busqueda sobre la tabla de entidad de nuevo de todas entidades

master
vicsash 6 months ago
parent c92885fac7
commit 48ee5e61e5

@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpSession;
import java.util.*;
@Controller
@ -58,35 +59,18 @@ public class BuscadorController {
@RequestParam(defaultValue = "nombre") String sortField,
@RequestParam(defaultValue = "asc") String sortDir,
@RequestParam String secondaryOption,
Model model){
System.out.println("Selected option TEST: " + secondaryOption);
Model model){
Page<Empresa> page = empresaService.getPage(pageNum, size, sortField, sortDir, query, secondaryOption);
List<Integer> itemsPage = Arrays.asList(5, 10, 15, 20, 25, 50);
if(page!=null){
List<Empresa> empresas = page.getContent();
model.addAttribute("currentPage", pageNum);
model.addAttribute("totalPages", page.getTotalPages());
model.addAttribute("totalItems", page.getTotalElements());
addPaginationAttributes(model, pageNum, page, sortField, sortDir, query, itemsPage, size);
model.addAttribute("empresas", empresas);
model.addAttribute("sortField", sortField);
model.addAttribute("sortDir", sortDir);
model.addAttribute("reverseSortDir", sortDir.equals("asc") ? "desc" : "asc");
model.addAttribute("query", query);
model.addAttribute("secondaryOption", secondaryOption);
model.addAttribute("itemsPage", itemsPage);
model.addAttribute("currentSize", size);
}else{
System.out.println("No se encontraron empresas");
// System.out.println("No se encontraron empresas");
}
// List<Object> models = model.asMap().values().stream().toList();
// for(Object m : models){
// System.out.println(m);
// }
return "/list/empresas";
}
@ -101,15 +85,11 @@ public class BuscadorController {
String[] word = query.split("\\b(y|o)\\b|[,/]");
List<Integer> itemsPage = Arrays.asList(5, 10, 15, 20, 25, 50);
Map<String, Object> attributes = new HashMap<>();
if (secondaryOption.equalsIgnoreCase("Todo")) {
sortField = "nombre";
sortDir = "asc";
attributes = getPaginatedAttributes(pageNum, query, size, sortField, sortDir, alumnoService, itemsPage);
}
attributes = getPaginatedAttributes(pageNum, query, size, sortField, sortDir, sectorService, itemsPage);
for (Map.Entry<String, Object> entry : attributes.entrySet()) {
model.addAttribute(entry.getKey(), entry.getValue());
}
model.addAttribute("secondaryOption",secondaryOption);
return "/list/sectores";
}
@ -122,17 +102,16 @@ public class BuscadorController {
@RequestParam(defaultValue = "asc") String sortDir,
@RequestParam(defaultValue = "") String secondaryOption,
Model model) {
String[] word = query.split("\\b(y|o)\\b|[,/]");
Page<Contacto> page = contactosService.getPage(pageNum, size, sortField, sortDir, query, secondaryOption);
List<Integer> itemsPage = Arrays.asList(5, 10, 15, 20, 25, 50);
Map<String, Object> attributes =new HashMap<>();
if (secondaryOption.equalsIgnoreCase("Todo")) {
sortField = "nombre";
sortDir = "asc";
attributes = getPaginatedAttributes(pageNum, query, size, sortField, sortDir, alumnoService, itemsPage);
}
for (Map.Entry<String, Object> entry : attributes.entrySet()) {
model.addAttribute(entry.getKey(), entry.getValue());
if(page!=null){
List<Contacto> contactos = page.getContent();
addPaginationAttributes(model, pageNum, page, sortField, sortDir, query, itemsPage, size);
model.addAttribute("contactos", contactos);
model.addAttribute("query", query);
model.addAttribute("secondaryOption", secondaryOption);
}else{
//System.out.println("No se encontraron Contactos");
}
return "/list/contactos";
}
@ -145,16 +124,16 @@ public class BuscadorController {
@RequestParam(defaultValue = "asc") String sortDir,
@RequestParam(defaultValue = "") String secondaryOption,
Model model){
String[] word = query.split("\\b(y|o)\\b|[,/]");
Page<Sucursal> page = sucursalService.getPage(pageNum, size, sortField, sortDir, query, secondaryOption);
List<Integer> itemsPage = Arrays.asList(5, 10, 15, 20, 25, 50);
Map<String, Object> attributes = new HashMap<>();
if (secondaryOption.equalsIgnoreCase("Todo")) {
sortField = "nombre";
sortDir = "asc";
attributes = getPaginatedAttributes(pageNum, query, size, sortField, sortDir, alumnoService, itemsPage);
}
for (Map.Entry<String, Object> entry : attributes.entrySet()) {
model.addAttribute(entry.getKey(), entry.getValue());
if(page!=null){
List<Sucursal> sucursals = page.getContent();
addPaginationAttributes(model, pageNum, page, sortField, sortDir, query, itemsPage, size);
model.addAttribute("sucursals",sucursals);
model.addAttribute("query", query);
model.addAttribute("secondaryOption", secondaryOption);
}else{
// System.out.println("No se encontraron sucursales");
}
return "/list/sucursales";
}
@ -167,16 +146,16 @@ public class BuscadorController {
@RequestParam(defaultValue = "asc") String sortDir,
@RequestParam(defaultValue = "") String secondaryOption,
Model model){
String[] word = query.split("\\b(y|o)\\b|[,/]");
Page<Oferta> page = ofertasService.getPage(pageNum, size, sortField, sortDir, query, secondaryOption);
List<Integer> itemsPage = Arrays.asList(5, 10, 15, 20, 25, 50);
Map<String, Object> attributes = new HashMap<>();
if (secondaryOption.equalsIgnoreCase("Todo")) {
sortField = "nombre";
sortDir = "asc";
attributes = getPaginatedAttributes(pageNum, query, size, sortField, sortDir, alumnoService, itemsPage);
}
for (Map.Entry<String, Object> entry : attributes.entrySet()) {
model.addAttribute(entry.getKey(), entry.getValue());
if(page!=null){
List<Oferta> ofertas = page.getContent();
addPaginationAttributes(model, pageNum, page, sortField, sortDir, query, itemsPage, size);
model.addAttribute("ofertas", ofertas);
model.addAttribute("query", query);
model.addAttribute("secondaryOption", secondaryOption);
}else{
// System.out.println("No se encontraron ofertas");
}
return "/list/ofertas";
}
@ -195,11 +174,12 @@ public class BuscadorController {
if (secondaryOption.equalsIgnoreCase("Todo")) {
sortField = "nombre";
sortDir = "asc";
attributes = getPaginatedAttributes(pageNum, query, size, sortField, sortDir, alumnoService, itemsPage);
attributes = getPaginatedAttributes(pageNum, query, size, sortField, sortDir, familiaService, itemsPage);
}
for (Map.Entry<String, Object> entry : attributes.entrySet()) {
model.addAttribute(entry.getKey(), entry.getValue());
}
model.addAttribute("secondaryOption",secondaryOption);
return "/list/familias";
}
@ -211,16 +191,16 @@ public class BuscadorController {
@RequestParam(defaultValue = "asc") String sortDir,
@RequestParam(defaultValue = "") String secondaryOption,
Model model) {
String[] word = query.split("\\b(y|o)\\b|[,/]");
Page<Ciclo> page =cicloService.getPage(pageNum, size, sortField, sortDir, query, secondaryOption);
List<Integer> itemsPage = Arrays.asList(5, 10, 15, 20, 25, 50);
Map<String, Object> attributes = new HashMap<>();
if (secondaryOption.equalsIgnoreCase("Todo")) {
sortField = "nombre";
sortDir = "asc";
attributes = getPaginatedAttributes(pageNum, query, size, sortField, sortDir, alumnoService, itemsPage);
}
for (Map.Entry<String, Object> entry : attributes.entrySet()) {
model.addAttribute(entry.getKey(), entry.getValue());
if(page!=null){
List<Ciclo> ciclos = page.getContent();
addPaginationAttributes(model, pageNum, page, sortField, sortDir, query, itemsPage, size);
model.addAttribute("ciclos", ciclos);
model.addAttribute("query", query);
model.addAttribute("secondaryOption", secondaryOption);
}else{
// System.out.println("No se encontraron ofertas");
}
return "/list/ciclos";
}
@ -234,16 +214,16 @@ public class BuscadorController {
@RequestParam(defaultValue = "") String secondaryOption,
Model model) {
String[] word = query.split("\\b(y|o)\\b|[,/]");
Page<Alumno> page = alumnoService.getPage(pageNum, size, sortField, sortDir, query, secondaryOption);
List<Integer> itemsPage = Arrays.asList(5, 10, 15, 20, 25, 50);
Map<String, Object> attributes = new HashMap<>();
if (secondaryOption.equalsIgnoreCase("Todo")) {
sortField = "nombre";
sortDir = "asc";
attributes = getPaginatedAttributes(pageNum, query, size, sortField, sortDir, alumnoService, itemsPage);
}
for (Map.Entry<String, Object> entry : attributes.entrySet()) {
model.addAttribute(entry.getKey(), entry.getValue());
if(page!=null){
List<Alumno> alumnos = page.getContent();
addPaginationAttributes(model, pageNum, page, sortField, sortDir, query, itemsPage, size);
model.addAttribute("alumnos", alumnos);
model.addAttribute("query", query);
model.addAttribute("secondaryOption", secondaryOption);
}else{
// System.out.println("No se encontraron alumnos");
}
return "/list/alumnos";
}
@ -268,6 +248,7 @@ public class BuscadorController {
for (Map.Entry<String, Object> entry : attributes.entrySet()) {
model.addAttribute(entry.getKey(), entry.getValue());
}
model.addAttribute("secondaryOption",secondaryOption);
return "/list/skills";
}
public <T> Map<String, Object> getPaginatedAttributes(int pageNum, String query, int size, String sortField, String sortDir, IPagination<T> service, List<Integer> itemsPage) {
@ -287,11 +268,24 @@ public class BuscadorController {
return attributes;
}
public void addPaginationAttributes(Model model, int pageNum, Page<?> page, String sortField, String sortDir, String query, List<Integer> itemsPage, int size) {
model.addAttribute("currentPage", pageNum);
model.addAttribute("totalPages", page.getTotalPages());
model.addAttribute("totalItems", page.getTotalElements());
model.addAttribute("sortField", sortField);
model.addAttribute("sortDir", sortDir);
model.addAttribute("reverseSortDir", sortDir.equals("asc") ? "desc" : "asc");
model.addAttribute("itemsPage", itemsPage);
model.addAttribute("currentSize", size);
}
@GetMapping("/empresas/search")
public ResponseEntity<List<Empresa>> searchEmpresas(@RequestParam String query) {
List<Empresa> empresas = empresaService.search(query);
return ResponseEntity.ok(empresas);
public ResponseEntity<List<Empresa>> searchEmpresas(@RequestParam String query, @RequestParam String secondaryQuery) {
List<Empresa> searchResult = empresaService.search(query);
return ResponseEntity.ok(searchResult);
}
@GetMapping("/sectores/search")

@ -1,43 +0,0 @@
package com.example.proyectofinal.controllers;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/editMain")
public class EditController {
@GetMapping
public String editMain(){
return "admin/editMain";
}
@GetMapping("/{text}")
public String editMain(@PathVariable String text, Model model){
model.addAttribute("text", text);
return "admin/editMenu/edit_menu";
}
@GetMapping("/{text}/{action}")
public String operationSwitch(@PathVariable String text, @PathVariable String action, Model model){
model.addAttribute("text", text);
switch(action) {
case "crear":
if(text.equalsIgnoreCase("familia")){
return "admin/editMenu/familia/familia_crear";
}
break;
case "editar":
System.out.println("editar "+text);
break;
case "borrar":
System.out.println("borrar "+ text);
break;
}
return "admin/editMenu/edit_menu";
}
}

@ -1,8 +0,0 @@
package com.example.proyectofinal.interfaces;
import org.springframework.data.domain.Page;
public interface IPaginationStrategy<T> {
Page<T> getPage(int pageNum, int size, String sortField, String sortDir, String query, IPagination<T> service);
}

@ -1,13 +0,0 @@
package com.example.proyectofinal.interfaces.specific;
import com.example.proyectofinal.interfaces.IPagination;
import com.example.proyectofinal.models.empresas.Empresa;
import org.springframework.data.domain.Page;
import java.util.List;
public interface IEmpresaSpecificPagination extends IPagination<Empresa> {
Page<Empresa> findEmpresasBySectorPaginated(Long sectorId, int pageNum, int size, String sortField, String sortDir);
}

@ -2,6 +2,8 @@ package com.example.proyectofinal.repositories.empresas;
import com.example.proyectofinal.models.empresas.Alumno;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
@ -37,7 +39,26 @@ public interface AlumnoRepository extends JpaRepository<Alumno, Long> {
@Query("SELECT a FROM Alumno a WHERE a.nia = ?1")
Alumno findByNia(String nia);
@Query("SELECT a FROM Alumno a WHERE a.apellido like ?1 or a.apellido2 like ?1")
Page<Alumno> findAlumnoByApellido(String query, PageRequest of);
@Query("SELECT a FROM Alumno a WHERE a.nombre like ?1")
Page<Alumno> findAlumnoByNombre(String query, PageRequest of);
@Query(value = "SELECT * FROM alumnos a WHERE FIND_IN_SET(?1, a.keywords)", nativeQuery = true)
Page<Alumno> findAlumnoByKeywords(String query, PageRequest of);
@Query("SELECT a FROM Alumno a WHERE a.nia like ?1")
Page<Alumno> findAlumnoByNia(String query, PageRequest of);
@Query("SELECT a FROM Alumno a WHERE a.dni like ?1")
Page<Alumno> findAlumnoByDni(String query, PageRequest of);
@Query("SELECT a FROM Alumno a WHERE a.ciclo.nombre like ?1")
Page<Alumno> findAlumnoByCiclo(String query, PageRequest of);
// @Query(value = "SELECT * FROM alumnos u WHERE MATCH(u.nombre, u.keywords, " +
// "u.apellido, u.apellido2, u.correo, u.correo2, u.nacionalidad, u.genero, u.dni, u.nia ) AGAINST(?1 IN BOOLEAN MODE)", nativeQuery = true)
// public ArrayList<Alumno> getAlumnoByKeywordsOrName(String keyword1);
}

@ -1,6 +1,8 @@
package com.example.proyectofinal.repositories.empresas;
import com.example.proyectofinal.models.empresas.Ciclo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
@ -18,4 +20,10 @@ public interface CicloRepository extends JpaRepository<Ciclo, Long> {
@Query("SELECT c FROM Ciclo c WHERE c.nombre LIKE %?1% or c.familia.nombre LIKE %?1% or c.codigo LIKE %?1%")
List<Ciclo> search(String query);
@Query("SELECT c FROM Ciclo c WHERE c.familia.nombre LIKE %?1%")
Page<Ciclo> findCicloByFamilia(String query, PageRequest of);
@Query("SELECT c FROM Ciclo c WHERE c.codigo LIKE %?1%")
Page<Ciclo> findCicloByCodigo(String query, PageRequest of);
}

@ -1,6 +1,8 @@
package com.example.proyectofinal.repositories.empresas;
import com.example.proyectofinal.models.empresas.Contacto;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
@ -13,9 +15,6 @@ public interface ContactoRepository extends JpaRepository<Contacto, Long> {
@Query("SELECT c FROM Contacto c WHERE c.empresa.id = ?1")
ArrayList<Contacto> findBySector(Long id);
// @Query(value = "SELECT * FROM contactos u WHERE MATCH(u.nombre, u.apellido,u.apellido2, u.correo, u.telefono) AGAINST(?1 IN BOOLEAN MODE)", nativeQuery = true)
// public ArrayList<Contacto> getContactoFullTextSeach(String keyword1);
@Query(value="Delete from contactos where fk_empressa =?1", nativeQuery = true)
public void deleteByEmpresaId(Long id);
@ -31,4 +30,10 @@ public interface ContactoRepository extends JpaRepository<Contacto, Long> {
@Modifying
@Query(value = "INSERT INTO contactos (nombre, apellido, apellido2, correo, telefono, fk_empressa) VALUES (:nombre, :apellido, :apellido2, :correo, :telefono, :fk_empressa)", nativeQuery = true)
void insertContacto(@Param("nombre") String nombre, @Param("apellido") String apellido, @Param("apellido2") String apellido2, @Param("correo") String correo, @Param("telefono") String telefono, @Param("fk_empressa") Long fk_empressa);
@Query("SELECT c FROM Contacto c WHERE c.nombre like %:query%")
Page<Contacto> findContactoByNombre(String query, PageRequest of);
@Query("SELECT c FROM Contacto c WHERE c.empresa.nombre LIKE %:query%")
Page<Contacto> findContactoByEmpresa(String query, PageRequest of);
}

@ -1,12 +1,16 @@
package com.example.proyectofinal.repositories.empresas;
import com.example.proyectofinal.models.empresas.Contacto;
import com.example.proyectofinal.models.empresas.Empresa;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.ArrayList;
import java.util.List;
@ -37,4 +41,15 @@ public interface EmpressaRepository extends JpaRepository<Empresa, Long>, JpaSpe
@Query("SELECT e FROM Empresa e WHERE e.sector.nombre = :sectorName")
Page<Empresa> findEmpresasBySectorName(@Param("sectorName") String sectorName, Pageable pageable);
@Query("SELECT e FROM Empresa e WHERE e.nombre LIKE %:query%")
Page<Empresa> findEmpresasByEmpresaName(String query, PageRequest of);
@Query("SELECT e FROM Empresa e WHERE e.keywords LIKE %:query%")
Page<Empresa> findEmpresasByKeywords(String query, PageRequest of);
// @Query()
// List<Empresa> findByQueryAndSecondaryOption(String query, String secondaryQuery);
}

@ -1,6 +1,9 @@
package com.example.proyectofinal.repositories.empresas;
import com.example.proyectofinal.models.empresas.Oferta;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
@ -41,4 +44,16 @@ public interface OfertaRepository extends JpaRepository<Oferta, Long> {
Oferta findByNombre(String name);
@Query(value = "SELECT o FROM Oferta o JOIN o.skills s WHERE s.nombre = ?1", nativeQuery = false)
Page<Oferta> findOfertaBySkill(String skillName, Pageable pageable);
@Query("SELECT o FROM Oferta o WHERE o.nombre LIKE %:query%")
Page<Oferta> findOfertaByNombre(String query, PageRequest of);
@Query("SELECT o FROM Oferta o WHERE o.fecha LIKE %:query%")
Page<Oferta> findOfertaByFecha(String query, PageRequest of);
@Query("SELECT o FROM Oferta o WHERE o.sucursal.nombre LIKE %:query%")
Page<Oferta> findOfertaByEmpresa(String query, PageRequest of);
}

@ -1,6 +1,8 @@
package com.example.proyectofinal.repositories.empresas;
import com.example.proyectofinal.models.empresas.Sucursal;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
@ -22,4 +24,13 @@ public interface SucursalRepository extends JpaRepository<Sucursal, Long> {
@Query("SELECT s FROM Sucursal s WHERE s.nombre = :nombre")
Sucursal findByName(String nombre);
@Query("SELECT s FROM Sucursal s WHERE s.empresa.nombre LIKE %:query%")
Page<Sucursal> findSucursalByEmpresa(String query, PageRequest of);
@Query("SELECT s FROM Sucursal s WHERE s.nombre LIKE %:query%")
Page<Sucursal> findSucursalaByNombre(String query, PageRequest of);
@Query("SELECT s FROM Sucursal s WHERE s.localidad LIKE %:query%")
Page<Sucursal> findSucursalByLocalidad(String query, PageRequest of);
}

@ -17,6 +17,29 @@ import java.util.List;
public class AlumnoService implements IAlumno{
@Autowired
private AlumnoRepository alumnoRepository;
@Override
public Page<Alumno> getPage(int pageNum, int size, String sortField, String sortDir, String query, String secondaryOption) {
if(secondaryOption.equalsIgnoreCase("Todo")){
return findAllPaginated(pageNum, size, sortField, sortDir);
}else if (secondaryOption.equals("Apellido")) {
return alumnoRepository.findAlumnoByApellido(query, PageRequest.of(pageNum - 1, size, Sort.by(sortField).ascending()));
} else if(secondaryOption.equals("Nombre")) {
return alumnoRepository.findAlumnoByNombre(query, PageRequest.of(pageNum - 1, size, Sort.by(sortField).ascending()));
}else if(secondaryOption.equals("Keywords")) {
return alumnoRepository.findAlumnoByKeywords(query, PageRequest.of(pageNum - 1, size, Sort.by(sortField).ascending()));
}else if(secondaryOption.equals("Nia")) {
return alumnoRepository.findAlumnoByNia(query, PageRequest.of(pageNum - 1, size, Sort.by(sortField).ascending()));
}else if(secondaryOption.equals("Dni")) {
return alumnoRepository.findAlumnoByDni(query, PageRequest.of(pageNum - 1, size, Sort.by(sortField).ascending()));
}else if(secondaryOption.equals("Ciclo")) {
return alumnoRepository.findAlumnoByCiclo(query, PageRequest.of(pageNum - 1, size, Sort.by(sortField).ascending()));
} else {
return null;
}
}
@Override
public List<Alumno> findAll() {
return alumnoRepository.findAll();
@ -77,4 +100,6 @@ public class AlumnoService implements IAlumno{
}
}
}

@ -92,5 +92,18 @@ public class CicloService implements ICiclos {
}
}
@Override
public Page<Ciclo> getPage(int pageNum, int size, String sortField, String sortDir, String query, String secondaryOption) {
if(secondaryOption.equalsIgnoreCase("Todo")){
return findAllPaginated(pageNum, size, sortField, sortDir);
}else if(secondaryOption.equals("Familia")) {
return cicloRepository.findCicloByFamilia(query, PageRequest.of(pageNum - 1, size, Sort.by(sortField).ascending()));
} else if(secondaryOption.equals("Codigo")) {
return cicloRepository.findCicloByCodigo(query, PageRequest.of(pageNum - 1, size, Sort.by(sortField).ascending()));
} else {
return null;
}
}
}

@ -2,6 +2,7 @@ package com.example.proyectofinal.servicios;
import com.example.proyectofinal.models.empresas.Contacto;
import com.example.proyectofinal.models.empresas.Empresa;
import com.example.proyectofinal.repositories.empresas.EmpressaRepository;
import com.example.proyectofinal.servicios.implemetations.IContactos;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
@ -91,5 +92,18 @@ public class ContactosService implements IContactos {
return contactoRepository.existsByNombreApe(contacto.getNombre(),contacto.getApellido(),contacto.getApellido2());
}
@Override
public Page<Contacto> getPage(int pageNum, int size, String sortField, String sortDir, String query, String secondaryOption) {
if(secondaryOption.equalsIgnoreCase("Todo")){
return findAllPaginated(pageNum, size, sortField, sortDir);
} else if(secondaryOption.equals("Nombre")) {
return contactoRepository.findContactoByNombre(query, PageRequest.of(pageNum - 1, size, Sort.by(sortField).ascending()));
}else if(secondaryOption.equals("Empresa")) {
return contactoRepository.findContactoByEmpresa(query, PageRequest.of(pageNum - 1, size, Sort.by(sortField).ascending()));
} else {
return null;
}
}
}

@ -1,9 +1,6 @@
package com.example.proyectofinal.servicios;
import com.example.proyectofinal.interfaces.specific.IEmpresaSpecificPagination;
import com.example.proyectofinal.models.empresas.Empresa;
import com.example.proyectofinal.models.empresas.Oferta;
import com.example.proyectofinal.models.empresas.Sector;
import com.example.proyectofinal.models.empresas.Sucursal;
import com.example.proyectofinal.repositories.empresas.EmpressaRepository;
import com.example.proyectofinal.repositories.empresas.OfertaRepository;
@ -18,7 +15,7 @@ import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class EmpresaService implements IEmpresa, IEmpresaSpecificPagination {
public class EmpresaService implements IEmpresa {
@Autowired
private EmpressaRepository empresaRepository;
@ -31,16 +28,23 @@ public class EmpresaService implements IEmpresa, IEmpresaSpecificPagination {
@Autowired
private OfertaRepository ofertaRepository;
@Override
public Page<Empresa> getPage(int pageNum, int size, String sortField, String sortDir, String query, String secondaryOption) {
if(secondaryOption.equalsIgnoreCase("Todo")){
return findAllPaginated(pageNum, size, sortField, sortDir);
}else if (secondaryOption.equals("Sector")) {
return empresaRepository.findEmpresasBySectorName(query, PageRequest.of(pageNum - 1, size, Sort.by(sortField).ascending()));
} else if(secondaryOption.equals("Nombre")) {
return empresaRepository.findEmpresasByEmpresaName(query, PageRequest.of(pageNum - 1, size, Sort.by(sortField).ascending()));
}else if(secondaryOption.equals("Keywords")) {
return empresaRepository.findEmpresasByKeywords(query, PageRequest.of(pageNum - 1, size, Sort.by(sortField).ascending()));
} else {
return null;
}
}
@Override
public List<Empresa> findAll() {
return empresaRepository.findAll();
@ -53,13 +57,7 @@ public class EmpresaService implements IEmpresa, IEmpresaSpecificPagination {
Page<Empresa> result = empresaRepository.findAll(pageRequest);
return result;
}
@Override
public Page<Empresa> findEmpresasBySectorPaginated(Long sectorId, int pageNum, int pageSize, String sortField, String sortDir) {
Sort sort = sortDir.equalsIgnoreCase(Sort.Direction.ASC.name()) ? Sort.by(sortField).ascending() : Sort.by(sortField).descending();
PageRequest pageRequest = PageRequest.of(pageNum - 1, pageSize, sort);
Page<Empresa> result = empresaRepository.empresaBySector(sectorId, pageRequest);
return result;
}
@Override
public Empresa findById(Long id) {
@ -106,5 +104,10 @@ public class EmpresaService implements IEmpresa, IEmpresaSpecificPagination {
return empresaRepository.findBySector(id);
}
// @Override
// public List<Empresa> getEmpresasByQueryAndSecondaryOption(String query, String secondaryQuery) {
// return empresaRepository.findByQueryAndSecondaryOption(query, secondaryQuery);
// }
}

@ -26,6 +26,23 @@ public class OfertaService implements IOferta {
@Autowired
private OfertaRepository ofertaRepository;
@Override
public Page<Oferta> getPage(int pageNum, int size, String sortField, String sortDir, String query, String secondaryOption) {
if(secondaryOption.equalsIgnoreCase("Todo")){
return findAllPaginated(pageNum, size, sortField, sortDir);
}else if (secondaryOption.equals("Skill")) {
return ofertaRepository.findOfertaBySkill(query, PageRequest.of(pageNum - 1, size, Sort.by(sortField).ascending()));
} else if(secondaryOption.equals("Nombre")) {
return ofertaRepository.findOfertaByNombre(query, PageRequest.of(pageNum - 1, size, Sort.by(sortField).ascending()));
}else if(secondaryOption.equals("Fecha")) {
return ofertaRepository.findOfertaByFecha(query, PageRequest.of(pageNum - 1, size, Sort.by(sortField).ascending()));
}else if(secondaryOption.equals("Empresa")) {
return ofertaRepository.findOfertaByEmpresa(query, PageRequest.of(pageNum - 1, size, Sort.by(sortField).ascending()));
} else {
return null;
}
}
@Override
public List<Oferta> findAll() {
return ofertaRepository.findAll();
@ -102,4 +119,6 @@ public class OfertaService implements IOferta {
}
}
}
}

@ -80,5 +80,20 @@ public class SucursalService implements ISucursal {
return sucursalRepository.findByName(sucursal.getNombre());
}
@Override
public Page<Sucursal> getPage(int pageNum, int size, String sortField, String sortDir, String query, String secondaryOption) {
if(secondaryOption.equalsIgnoreCase("Todo")){
return findAllPaginated(pageNum, size, sortField, sortDir);
}else if (secondaryOption.equals("Empressa")) {
return sucursalRepository.findSucursalByEmpresa(query, PageRequest.of(pageNum - 1, size, Sort.by(sortField).ascending()));
} else if(secondaryOption.equals("Nombre")) {
return sucursalRepository.findSucursalaByNombre(query, PageRequest.of(pageNum - 1, size, Sort.by(sortField).ascending()));
}else if(secondaryOption.equals("Localidad")) {
return sucursalRepository.findSucursalByLocalidad(query, PageRequest.of(pageNum - 1, size, Sort.by(sortField).ascending()));
} else {
return null;
}
}
}

@ -2,6 +2,7 @@ package com.example.proyectofinal.servicios.implemetations;
import com.example.proyectofinal.interfaces.IPagination;
import com.example.proyectofinal.models.empresas.Alumno;
import org.springframework.data.domain.Page;
import java.util.List;
@ -21,4 +22,7 @@ public interface IAlumno extends IPagination<Alumno> {
Alumno exists(Alumno alumno);
void deleteByCiclo(Long id);
Page<Alumno> getPage(int pageNum, int size, String sortField, String sortDir, String query, String secondaryOption);
}

@ -3,6 +3,7 @@ package com.example.proyectofinal.servicios.implemetations;
import com.example.proyectofinal.interfaces.IPagination;
import com.example.proyectofinal.models.empresas.Ciclo;
import com.example.proyectofinal.models.empresas.Familia;
import org.springframework.data.domain.Page;
import java.util.List;
@ -24,5 +25,7 @@ public interface ICiclos extends IPagination<Ciclo> {
Ciclo exists(Ciclo ciclo);
void deleteByFamiliaId(Long id);
Page<Ciclo> getPage(int pageNum, int size, String sortField, String sortDir, String query, String secondaryOption);
}

@ -3,6 +3,7 @@ package com.example.proyectofinal.servicios.implemetations;
import com.example.proyectofinal.interfaces.IPagination;
import com.example.proyectofinal.models.empresas.Contacto;
import com.example.proyectofinal.models.empresas.Empresa;
import org.springframework.data.domain.Page;
import java.util.List;
@ -22,4 +23,6 @@ public interface IContactos extends IPagination<Contacto> {
void deleteByEmpresa(Empresa empresa);
Contacto exists(Contacto contacto);
Page<Contacto> getPage(int pageNum, int size, String sortField, String sortDir, String query, String secondaryOption);
}

@ -1,8 +1,8 @@
package com.example.proyectofinal.servicios.implemetations;
import com.example.proyectofinal.interfaces.IPagination;
import com.example.proyectofinal.interfaces.specific.IEmpresaSpecificPagination;
import com.example.proyectofinal.models.empresas.Empresa;
import org.springframework.data.domain.Page;
import java.util.List;
@ -22,4 +22,7 @@ public interface IEmpresa extends IPagination<Empresa> {
List<Empresa> findBySector(Long id);
Page<Empresa> getPage(int pageNum, int size, String sortField, String sortDir, String query, String secondaryOption);
// List<Empresa> getEmpresasByQueryAndSecondaryOption(String query, String secondaryQuery);
}

@ -3,6 +3,7 @@ package com.example.proyectofinal.servicios.implemetations;
import com.example.proyectofinal.interfaces.IPagination;
import com.example.proyectofinal.models.empresas.Oferta;
import com.example.proyectofinal.models.empresas.Sucursal;
import org.springframework.data.domain.Page;
import java.util.List;
@ -22,4 +23,6 @@ public interface IOferta extends IPagination<Oferta> {
List<Oferta> findBySucursal(Sucursal sucursal);
void deleteByCicloId(Long id);
Page<Oferta> getPage(int pageNum, int size, String sortField, String sortDir, String query, String secondaryOption);
}

@ -3,6 +3,7 @@ package com.example.proyectofinal.servicios.implemetations;
import com.example.proyectofinal.interfaces.IPagination;
import com.example.proyectofinal.models.empresas.Empresa;
import com.example.proyectofinal.models.empresas.Sucursal;
import org.springframework.data.domain.Page;
import java.util.List;
@ -22,4 +23,6 @@ public interface ISucursal extends IPagination<Sucursal> {
List<Sucursal> findByEmpresa(Empresa empresa);
Sucursal exists(Sucursal sucursal);
Page<Sucursal> getPage(int pageNum, int size, String sortField, String sortDir, String query, String secondaryOption);
}

@ -1,7 +1,7 @@
spring.datasource.url=jdbc:mysql://localhost:3306/projfin
spring.datasource.username=projfin
spring.h2.console.enabled=true
spring.datasource.password=1234
spring.datasource.password=1234S
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

@ -1,17 +0,0 @@
.back-button {
display: flex;
position: fixed;
bottom: 0;
left: 0;
width: 200px !important;
height: 50px !important;
font-size: 25px !important;
margin-top: 100px;
background-color: #007BFF;
color: white;
font-weight: bolder;
border-radius: 5px;
justify-content: center;
align-items: center;
font-family: Verdana, Geneva, Tahoma, sans-serif;
}

@ -165,7 +165,7 @@
options = ['Todo', 'Nombre', 'Empresa'];
break;
case'ofertas':
options = ['Todo', 'Nombre', 'Empresa','Fecha'];
options = ['Todo', 'Nombre', 'Empresa','Fecha','Skill'];
break;
case'sucursales':
options = ['Todo', 'Nombre', 'Empresa','Localidad'];
@ -177,10 +177,10 @@
options = ['Todo'];
break;
case'ciclos':
options = ['Todo','Familia'];
options = ['Todo','Familia','Codigo'];
break;
case'alumnos':
options = ['Todo', 'Nombre', 'Apellidos','Ciclo','Keywords'];
options = ['Todo', 'Nombre', 'Apellido','Ciclo','Keywords','Nia' ,'Dni'];
break;
default:
options = [];

@ -92,7 +92,7 @@
</tr>
</thead>
<tbody>
<tr class="cell" th:each="alumno :${items}" th:data-id="${alumno.id}">
<tr class="cell" th:each="alumno :${alumnos}" th:data-id="${alumno.id}">
<td>
[[${alumno.nombre}]]
<i class="edit-icon fas fa-pen-square"></i>
@ -120,24 +120,21 @@
<div class="page">
<nav aria-label="Page navigation" id="paginationControls">
<ul class="pagination">
<input type="hidden" name="secondaryOption" id="hiddenSecondaryOption" th:value="${secondaryOption}">
<li class="page-item" th:classappend="${currentPage == 1 ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/alumnos/page/' + ${1} + '?query=' + ${query} + '&size=' + ${currentSize}}">Prim</a>
<a class="page-link" th:href="@{'/buscador/alumnos/page/' + ${1} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Prim</a>
</li>
<li class="page-item" th:classappend="${currentPage == 1 ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/alumnos/page/' + ${currentPage - 1} + '?query=' + ${query} + '&size=' + ${currentSize}}">Ant</a>
<a class="page-link" th:href="@{'/buscador/alumnos/page/' + ${currentPage - 1} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Ant</a>
</li>
<li class="page-item" th:each="pageNum : ${#numbers.sequence(1, totalPages)}" th:classappend="${pageNum eq currentPage ? 'active' : ''}">
<th:block th:if="${pageNum lt 3 or pageNum gt totalPages - 2 or pageNum eq currentPage - 2 or pageNum eq currentPage - 1 or pageNum eq currentPage or pageNum eq currentPage + 1 or pageNum eq currentPage + 2}">
<a class="page-link" th:href="@{'/buscador/alumnos/page/' + ${pageNum} + '?query=' + ${query} + '&size=' + ${currentSize}}">[[${pageNum}]]</a>
</th:block>
<th:block th:if="${pageNum eq 3 and currentPage gt 5}">...</th:block>
<th:block th:if="${pageNum eq totalPages - 2 and currentPage lt totalPages - 4}">...</th:block>
<a class="page-link" th:href="@{'/buscador/alumnos/page/' + ${pageNum} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">[[${pageNum}]]</a>
</li>
<li class="page-item" th:classappend="${currentPage == totalPages ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/alumnos/page/' + ${currentPage + 1} + '?query=' + ${query} + '&size=' + ${currentSize}}">Sig</a>
<a class="page-link" th:href="@{'/buscador/alumnos/page/' + ${currentPage + 1} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Sig</a>
</li>
<li class="page-item" th:classappend="${currentPage == totalPages ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/alumnos/page/' + ${totalPages} + '?query=' + ${query} + '&size=' + ${currentSize}}">Ult</a>
<a class="page-link" th:href="@{'/buscador/alumnos/page/' + ${totalPages} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Ult</a>
</li>
</ul>
</nav>

@ -42,7 +42,7 @@
</th>
</thead>
<tbody>
<tr class="cell" th:each="ciclo :${items}" th:data-id="${ciclo.id}">
<tr class="cell" th:each="ciclo :${ciclos}" th:data-id="${ciclo.id}">
<td>
[[${ciclo.nombre}]]
<i class="edit-icon fas fa-pen-square"></i>
@ -57,24 +57,21 @@
<div class="page">
<nav aria-label="Page navigation" id="paginationControls">
<ul class="pagination">
<input type="hidden" name="secondaryOption" id="hiddenSecondaryOption" th:value="${secondaryOption}">
<li class="page-item" th:classappend="${currentPage == 1 ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/ciclos/page/' + ${1} + '?query=' + ${query} + '&size=' + ${currentSize}}">Prim</a>
<a class="page-link" th:href="@{'/buscador/ciclos/page/' + ${1} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Prim</a>
</li>
<li class="page-item" th:classappend="${currentPage == 1 ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/ciclos/page/' + ${currentPage - 1} + '?query=' + ${query} + '&size=' + ${currentSize}}">Ant</a>
<a class="page-link" th:href="@{'/buscador/ciclos/page/' + ${currentPage - 1} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Ant</a>
</li>
<li class="page-item" th:each="pageNum : ${#numbers.sequence(1, totalPages)}" th:classappend="${pageNum eq currentPage ? 'active' : ''}">
<th:block th:if="${pageNum lt 3 or pageNum gt totalPages - 2 or pageNum eq currentPage - 2 or pageNum eq currentPage - 1 or pageNum eq currentPage or pageNum eq currentPage + 1 or pageNum eq currentPage + 2}">
<a class="page-link" th:href="@{'/buscador/ciclos/page/' + ${pageNum} + '?query=' + ${query} + '&size=' + ${currentSize}}">[[${pageNum}]]</a>
</th:block>
<th:block th:if="${pageNum eq 3 and currentPage gt 5}">...</th:block>
<th:block th:if="${pageNum eq totalPages - 2 and currentPage lt totalPages - 4}">...</th:block>
<a class="page-link" th:href="@{'/buscador/ciclos/page/' + ${pageNum} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">[[${pageNum}]]</a>
</li>
<li class="page-item" th:classappend="${currentPage == totalPages ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/ciclos/page/' + ${currentPage + 1} + '?query=' + ${query} + '&size=' + ${currentSize}}">Sig</a>
<a class="page-link" th:href="@{'/buscador/ciclos/page/' + ${currentPage + 1} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Sig</a>
</li>
<li class="page-item" th:classappend="${currentPage == totalPages ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/ciclos/page/' + ${totalPages} + '?query=' + ${query} + '&size=' + ${currentSize}}">Ult</a>
<a class="page-link" th:href="@{'/buscador/ciclos/page/' + ${totalPages} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Ult</a>
</li>
</ul>
</nav>

@ -58,7 +58,7 @@
</tr>
</thead>
<tbody>
<tr class="cell" th:each="contacto :${items}" th:data-id="${contacto.id}">
<tr class="cell" th:each="contacto :${contactos}" th:data-id="${contacto.id}">
<td>
[[${contacto.nombre}]]
<i class="edit-icon fas fa-pen-square"></i>
@ -73,27 +73,25 @@
</tbody>
</table>
</div>
<div class="page">
<nav aria-label="Page navigation" id="paginationControls">
<ul class="pagination">
<input type="hidden" name="secondaryOption" id="hiddenSecondaryOption" th:value="${secondaryOption}">
<li class="page-item" th:classappend="${currentPage == 1 ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/contactos/page/' + ${1} + '?query=' + ${query} + '&size=' + ${currentSize}}">Prim</a>
<a class="page-link" th:href="@{'/buscador/contactos/page/' + ${1} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Prim</a>
</li>
<li class="page-item" th:classappend="${currentPage == 1 ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/contactos/page/' + ${currentPage - 1} + '?query=' + ${query} + '&size=' + ${currentSize}}">Ant</a>
<a class="page-link" th:href="@{'/buscador/contactos/page/' + ${currentPage - 1} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Ant</a>
</li>
<li class="page-item" th:each="pageNum : ${#numbers.sequence(1, totalPages)}" th:classappend="${pageNum eq currentPage ? 'active' : ''}">
<th:block th:if="${pageNum lt 3 or pageNum gt totalPages - 2 or pageNum eq currentPage - 2 or pageNum eq currentPage - 1 or pageNum eq currentPage or pageNum eq currentPage + 1 or pageNum eq currentPage + 2}">
<a class="page-link" th:href="@{'/buscador/contactos/page/' + ${pageNum} + '?query=' + ${query} + '&size=' + ${currentSize}}">[[${pageNum}]]</a>
</th:block>
<th:block th:if="${pageNum eq 3 and currentPage gt 5}">...</th:block>
<th:block th:if="${pageNum eq totalPages - 2 and currentPage lt totalPages - 4}">...</th:block>
<a class="page-link" th:href="@{'/buscador/contactos/page/' + ${pageNum} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">[[${pageNum}]]</a>
</li>
<li class="page-item" th:classappend="${currentPage == totalPages ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/contactos/page/' + ${currentPage + 1} + '?query=' + ${query} + '&size=' + ${currentSize}}">Sig</a>
<a class="page-link" th:href="@{'/buscador/contactos/page/' + ${currentPage + 1} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Sig</a>
</li>
<li class="page-item" th:classappend="${currentPage == totalPages ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/contactos/page/' + ${totalPages} + '?query=' + ${query} + '&size=' + ${currentSize}}">Ult</a>
<a class="page-link" th:href="@{'/buscador/contactos/page/' + ${totalPages} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Ult</a>
</li>
</ul>
</nav>

@ -59,6 +59,7 @@
</thead>
<tbody>
<tr class="cell" th:each="empresa :${empresas}" th:data-id="${empresa.id}">
<td>
<a th:href="@{/templates/admin/empresa/{id}(id=${empresa.id})}">[[${empresa.nombre}]]</a>
<i class="edit-icon fas fa-pen-square"></i>
@ -76,24 +77,21 @@
<div class="page">
<nav aria-label="Page navigation" id="paginationControls">
<ul class="pagination">
<input type="hidden" name="secondaryOption" id="hiddenSecondaryOption" th:value="${secondaryOption}">
<li class="page-item" th:classappend="${currentPage == 1 ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/empresas/page/' + ${1} + '?query=' + ${query} + '&size=' + ${currentSize}}">Prim</a>
<a class="page-link" th:href="@{'/buscador/empresas/page/' + ${1} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Prim</a>
</li>
<li class="page-item" th:classappend="${currentPage == 1 ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/empresas/page/' + ${currentPage - 1} + '?query=' + ${query} + '&size=' + ${currentSize}}">Ant</a>
<a class="page-link" th:href="@{'/buscador/empresas/page/' + ${currentPage - 1} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Ant</a>
</li>
<li class="page-item" th:each="pageNum : ${#numbers.sequence(1, totalPages)}" th:classappend="${pageNum eq currentPage ? 'active' : ''}">
<th:block th:if="${pageNum lt 3 or pageNum gt totalPages - 2 or pageNum eq currentPage - 2 or pageNum eq currentPage - 1 or pageNum eq currentPage or pageNum eq currentPage + 1 or pageNum eq currentPage + 2}">
<a class="page-link" th:href="@{'/buscador/empresas/page/' + ${pageNum} + '?query=' + ${query} + '&size=' + ${currentSize}}">[[${pageNum}]]</a>
</th:block>
<th:block th:if="${pageNum eq 3 and currentPage gt 5}">...</th:block>
<th:block th:if="${pageNum eq totalPages - 2 and currentPage lt totalPages - 4}">...</th:block>
<a class="page-link" th:href="@{'/buscador/empresas/page/' + ${pageNum} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">[[${pageNum}]]</a>
</li>
<li class="page-item" th:classappend="${currentPage == totalPages ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/empresas/page/' + ${currentPage + 1} + '?query=' + ${query} + '&size=' + ${currentSize}}">Sig</a>
<a class="page-link" th:href="@{'/buscador/empresas/page/' + ${currentPage + 1} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Sig</a>
</li>
<li class="page-item" th:classappend="${currentPage == totalPages ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/empresas/page/' + ${totalPages} + '?query=' + ${query} + '&size=' + ${currentSize}}">Ult</a>
<a class="page-link" th:href="@{'/buscador/empresas/page/' + ${totalPages} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Ult</a>
</li>
</ul>
</nav>
@ -116,18 +114,19 @@
function goBack() {
window.history.back();
}
var $table = $('#table');
var $modalDelete = $('#modalDelete');
var $myInput = $('#myInput');
var $createIcon = $('#create-icon');
var isSearchBarUsed = false;
$table.on('click', '.edit-icon', function(event) {
$table.on('click', '.edit-icon', function (event) {
console.log("Edit icon clicked");
handleEdit(event);
});
$table.on('click', '.delete-icon', function(event) {
$table.on('click', '.delete-icon', function (event) {
console.log("Delete icon clicked");
handleDelete(event);
});
@ -152,16 +151,16 @@
document.body.style.pointerEvents = 'none';
modal.style.pointerEvents = 'auto';
closeSpan.onclick = function() {
closeSpan.onclick = function () {
modal.style.display = "none";
document.body.style.pointerEvents = 'auto';
}
deleteSpan.onclick = function() {
deleteSpan.onclick = function () {
$.ajax({
url: '/empresa/delete/' + rowId,
type: 'GET',
success: function(response) {
success: function (response) {
if (response === "La empresa ha sido eliminada") {
alert("Empresa borrada con exito");
window.location.reload();
@ -173,10 +172,12 @@
}
}
$myInput.on('input', function() {
$myInput.on('input', function () {
var query = document.querySelector('#myInput').value;
var paginationControls = document.querySelector('#paginationControls');
var entriesCountDropdown = document.querySelector('#entriesCount');
var empresasData = document.querySelector('#empresasData').value; // Retrieve the serialized empresas
if (query == '') {
isSearchBarUsed = false;
@ -213,12 +214,12 @@
tableBody.appendChild(row);
});
document.querySelectorAll('.edit-icon').forEach(function(icon) {
document.querySelectorAll('.edit-icon').forEach(function (icon) {
icon.removeEventListener('click', handleEdit);
icon.addEventListener('click', handleEdit);
console.log("Edit icon event listener attached");
});
document.querySelectorAll('.delete-icon').forEach(function(icon) {
document.querySelectorAll('.delete-icon').forEach(function (icon) {
icon.removeEventListener('click', handleDelete);
icon.addEventListener('click', handleDelete);
console.log("Delete icon event listener attached");
@ -229,7 +230,7 @@
}
});
document.querySelector('#table').addEventListener('click', function(event) {
document.querySelector('#table').addEventListener('click', function (event) {
if (event.target.matches('.edit-icon')) {
handleEdit(event);
} else if (event.target.matches('.delete-icon')) {
@ -237,24 +238,24 @@
}
});
const observer = new MutationObserver(function() {
document.querySelectorAll('.edit-icon').forEach(function(icon) {
const observer = new MutationObserver(function () {
document.querySelectorAll('.edit-icon').forEach(function (icon) {
icon.addEventListener('click', handleEdit);
});
document.querySelectorAll('.delete-icon').forEach(function(icon) {
document.querySelectorAll('.delete-icon').forEach(function (icon) {
icon.addEventListener('click', handleDelete);
});
});
observer.observe(document.querySelector('#table tbody'), { childList: true });
observer.observe(document.querySelector('#table tbody'), {childList: true});
document.getElementById('create-icon').addEventListener('click', function() {
document.getElementById('create-icon').addEventListener('click', function () {
console.log("Create button clicked : TEST");
window.location = "/admin/empresa/create";
});
var tableHeaders = document.querySelectorAll('.table-header');
tableHeaders.forEach(function(header) {
header.addEventListener('click', function(event) {
tableHeaders.forEach(function (header) {
header.addEventListener('click', function (event) {
if (isSearchBarUsed) {
event.preventDefault();
}

@ -46,24 +46,21 @@
<div class="page">
<nav aria-label="Page navigation" id="paginationControls">
<ul class="pagination">
<input type="hidden" name="secondaryOption" id="hiddenSecondaryOption" th:value="${secondaryOption}">
<li class="page-item" th:classappend="${currentPage == 1 ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/familia/page/' + ${1} + '?query=' + ${query} + '&size=' + ${currentSize}}">Prim</a>
<a class="page-link" th:href="@{'/buscador/familias/page/' + ${1} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Prim</a>
</li>
<li class="page-item" th:classappend="${currentPage == 1 ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/familia/page/' + ${currentPage - 1} + '?query=' + ${query} + '&size=' + ${currentSize}}">Ant</a>
<a class="page-link" th:href="@{'/buscador/familias/page/' + ${currentPage - 1} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Ant</a>
</li>
<li class="page-item" th:each="pageNum : ${#numbers.sequence(1, totalPages)}" th:classappend="${pageNum eq currentPage ? 'active' : ''}">
<th:block th:if="${pageNum lt 3 or pageNum gt totalPages - 2 or pageNum eq currentPage - 2 or pageNum eq currentPage - 1 or pageNum eq currentPage or pageNum eq currentPage + 1 or pageNum eq currentPage + 2}">
<a class="page-link" th:href="@{'/buscador/familia/page/' + ${pageNum} + '?query=' + ${query} + '&size=' + ${currentSize}}">[[${pageNum}]]</a>
</th:block>
<th:block th:if="${pageNum eq 3 and currentPage gt 5}">...</th:block>
<th:block th:if="${pageNum eq totalPages - 2 and currentPage lt totalPages - 4}">...</th:block>
<a class="page-link" th:href="@{'/buscador/familias/page/' + ${pageNum} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">[[${pageNum}]]</a>
</li>
<li class="page-item" th:classappend="${currentPage == totalPages ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/familia/page/' + ${currentPage + 1} + '?query=' + ${query} + '&size=' + ${currentSize}}">Sig</a>
<a class="page-link" th:href="@{'/buscador/familias/page/' + ${currentPage + 1} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Sig</a>
</li>
<li class="page-item" th:classappend="${currentPage == totalPages ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/familia/page/' + ${totalPages} + '?query=' + ${query} + '&size=' + ${currentSize}}">Ult</a>
<a class="page-link" th:href="@{'/buscador/familias/page/' + ${totalPages} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Ult</a>
</li>
</ul>
</nav>

@ -56,8 +56,7 @@
</tr>
</thead>
<tbody>
<tr class="cell" th:each="oferta :${items}" th:data-id="${oferta.id}">
<td>[[${oferta.id}]]</td>
<tr class="cell" th:each="oferta :${ofertas}" th:data-id="${oferta.id}">
<td>
[[${oferta.nombre}]]
<i class="edit-icon fas fa-pen-square"></i>
@ -77,24 +76,21 @@
<div class="page">
<nav aria-label="Page navigation" id="paginationControls">
<ul class="pagination">
<input type="hidden" name="secondaryOption" id="hiddenSecondaryOption" th:value="${secondaryOption}">
<li class="page-item" th:classappend="${currentPage == 1 ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/ofertas/page/' + ${1} + '?query=' + ${query} + '&size=' + ${currentSize}}">Prim</a>
<a class="page-link" th:href="@{'/buscador/ofertas/page/' + ${1} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Prim</a>
</li>
<li class="page-item" th:classappend="${currentPage == 1 ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/ofertas/page/' + ${currentPage - 1} + '?query=' + ${query} + '&size=' + ${currentSize}}">Ant</a>
<a class="page-link" th:href="@{'/buscador/ofertas/page/' + ${currentPage - 1} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Ant</a>
</li>
<li class="page-item" th:each="pageNum : ${#numbers.sequence(1, totalPages)}" th:classappend="${pageNum eq currentPage ? 'active' : ''}">
<th:block th:if="${pageNum lt 3 or pageNum gt totalPages - 2 or pageNum eq currentPage - 2 or pageNum eq currentPage - 1 or pageNum eq currentPage or pageNum eq currentPage + 1 or pageNum eq currentPage + 2}">
<a class="page-link" th:href="@{'/buscador/ofertas/page/' + ${pageNum} + '?query=' + ${query} + '&size=' + ${currentSize}}">[[${pageNum}]]</a>
</th:block>
<th:block th:if="${pageNum eq 3 and currentPage gt 5}">...</th:block>
<th:block th:if="${pageNum eq totalPages - 2 and currentPage lt totalPages - 4}">...</th:block>
<a class="page-link" th:href="@{'/buscador/ofertas/page/' + ${pageNum} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">[[${pageNum}]]</a>
</li>
<li class="page-item" th:classappend="${currentPage == totalPages ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/ofertas/page/' + ${currentPage + 1} + '?query=' + ${query} + '&size=' + ${currentSize}}">Sig</a>
<a class="page-link" th:href="@{'/buscador/ofertas/page/' + ${currentPage + 1} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Sig</a>
</li>
<li class="page-item" th:classappend="${currentPage == totalPages ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/ofertas/page/' + ${totalPages} + '?query=' + ${query} + '&size=' + ${currentSize}}">Ult</a>
<a class="page-link" th:href="@{'/buscador/ofertas/page/' + ${totalPages} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Ult</a>
</li>
</ul>
</nav>

@ -45,24 +45,21 @@
<div class="page">
<nav aria-label="Page navigation" id="paginationControls">
<ul class="pagination">
<input type="hidden" name="secondaryOption" id="hiddenSecondaryOption" th:value="${secondaryOption}">
<li class="page-item" th:classappend="${currentPage == 1 ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/sectores/page/' + ${1} + '?query=' + ${query} + '&size=' + ${currentSize}}">Prim</a>
<a class="page-link" th:href="@{'/buscador/sectores/page/' + ${1} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Prim</a>
</li>
<li class="page-item" th:classappend="${currentPage == 1 ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/sectores/page/' + ${currentPage - 1} + '?query=' + ${query} + '&size=' + ${currentSize}}">Ant</a>
<a class="page-link" th:href="@{'/buscador/sectores/page/' + ${currentPage - 1} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Ant</a>
</li>
<li class="page-item" th:each="pageNum : ${#numbers.sequence(1, totalPages)}" th:classappend="${pageNum eq currentPage ? 'active' : ''}">
<th:block th:if="${pageNum lt 3 or pageNum gt totalPages - 2 or pageNum eq currentPage - 2 or pageNum eq currentPage - 1 or pageNum eq currentPage or pageNum eq currentPage + 1 or pageNum eq currentPage + 2}">
<a class="page-link" th:href="@{'/buscador/sectores/page/' + ${pageNum} + '?query=' + ${query} + '&size=' + ${currentSize}}">[[${pageNum}]]</a>
</th:block>
<th:block th:if="${pageNum eq 3 and currentPage gt 5}">...</th:block>
<th:block th:if="${pageNum eq totalPages - 2 and currentPage lt totalPages - 4}">...</th:block>
<a class="page-link" th:href="@{'/buscador/sectores/page/' + ${pageNum} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">[[${pageNum}]]</a>
</li>
<li class="page-item" th:classappend="${currentPage == totalPages ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/sectores/page/' + ${currentPage + 1} + '?query=' + ${query} + '&size=' + ${currentSize}}">Sig</a>
<a class="page-link" th:href="@{'/buscador/sectores/page/' + ${currentPage + 1} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Sig</a>
</li>
<li class="page-item" th:classappend="${currentPage == totalPages ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/sectores/page/' + ${totalPages} + '?query=' + ${query} + '&size=' + ${currentSize}}">Ult</a>
<a class="page-link" th:href="@{'/buscador/sectores/page/' + ${totalPages} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Ult</a>
</li>
</ul>
</nav>

@ -45,24 +45,21 @@
<div class="page">
<nav aria-label="Page navigation" id="paginationControls">
<ul class="pagination">
<input type="hidden" name="secondaryOption" id="hiddenSecondaryOption" th:value="${secondaryOption}">
<li class="page-item" th:classappend="${currentPage == 1 ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/skills/page/' + ${1} + '?query=' + ${query} + '&size=' + ${currentSize}}">Prim</a>
<a class="page-link" th:href="@{'/buscador/skills/page/' + ${1} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Prim</a>
</li>
<li class="page-item" th:classappend="${currentPage == 1 ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/skills/page/' + ${currentPage - 1} + '?query=' + ${query} + '&size=' + ${currentSize}}">Ant</a>
<a class="page-link" th:href="@{'/buscador/skills/page/' + ${currentPage - 1} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Ant</a>
</li>
<li class="page-item" th:each="pageNum : ${#numbers.sequence(1, totalPages)}" th:classappend="${pageNum eq currentPage ? 'active' : ''}">
<th:block th:if="${pageNum lt 3 or pageNum gt totalPages - 2 or pageNum eq currentPage - 2 or pageNum eq currentPage - 1 or pageNum eq currentPage or pageNum eq currentPage + 1 or pageNum eq currentPage + 2}">
<a class="page-link" th:href="@{'/buscador/skills/page/' + ${pageNum} + '?query=' + ${query} + '&size=' + ${currentSize}}">[[${pageNum}]]</a>
</th:block>
<th:block th:if="${pageNum eq 3 and currentPage gt 5}">...</th:block>
<th:block th:if="${pageNum eq totalPages - 2 and currentPage lt totalPages - 4}">...</th:block>
<a class="page-link" th:href="@{'/buscador/skills/page/' + ${pageNum} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">[[${pageNum}]]</a>
</li>
<li class="page-item" th:classappend="${currentPage == totalPages ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/skills/page/' + ${currentPage + 1} + '?query=' + ${query} + '&size=' + ${currentSize}}">Sig</a>
<a class="page-link" th:href="@{'/buscador/skills/page/' + ${currentPage + 1} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Sig</a>
</li>
<li class="page-item" th:classappend="${currentPage == totalPages ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/skills/page/' + ${totalPages} + '?query=' + ${query} + '&size=' + ${currentSize}}">Ult</a>
<a class="page-link" th:href="@{'/buscador/skills/page/' + ${totalPages} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Ult</a>
</li>
</ul>
</nav>

@ -53,7 +53,7 @@
</tr>
</thead>
<tbody>
<tr class="cell" th:each="sucursal :${items}" th:data-id="${sucursal.id}">
<tr class="cell" th:each="sucursal :${sucursals}" th:data-id="${sucursal.id}">
<td>
[[${sucursal.nombre}]]
<i class="edit-icon fas fa-pen-square"></i>
@ -70,24 +70,21 @@
<div class="page">
<nav aria-label="Page navigation" id="paginationControls">
<ul class="pagination">
<input type="hidden" name="secondaryOption" id="hiddenSecondaryOption" th:value="${secondaryOption}">
<li class="page-item" th:classappend="${currentPage == 1 ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/sucursales/page/' + ${1} + '?query=' + ${query} + '&size=' + ${currentSize}}">Prim</a>
<a class="page-link" th:href="@{'/buscador/sucursales/page/' + ${1} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Prim</a>
</li>
<li class="page-item" th:classappend="${currentPage == 1 ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/sucursales/page/' + ${currentPage - 1} + '?query=' + ${query} + '&size=' + ${currentSize}}">Ant</a>
<a class="page-link" th:href="@{'/buscador/sucursales/page/' + ${currentPage - 1} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Ant</a>
</li>
<li class="page-item" th:each="pageNum : ${#numbers.sequence(1, totalPages)}" th:classappend="${pageNum eq currentPage ? 'active' : ''}">
<th:block th:if="${pageNum lt 3 or pageNum gt totalPages - 2 or pageNum eq currentPage - 2 or pageNum eq currentPage - 1 or pageNum eq currentPage or pageNum eq currentPage + 1 or pageNum eq currentPage + 2}">
<a class="page-link" th:href="@{'/buscador/sucursales/page/' + ${pageNum} + '?query=' + ${query} + '&size=' + ${currentSize}}">[[${pageNum}]]</a>
</th:block>
<th:block th:if="${pageNum eq 3 and currentPage gt 5}">...</th:block>
<th:block th:if="${pageNum eq totalPages - 2 and currentPage lt totalPages - 4}">...</th:block>
<a class="page-link" th:href="@{'/buscador/sucursales/page/' + ${pageNum} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">[[${pageNum}]]</a>
</li>
<li class="page-item" th:classappend="${currentPage == totalPages ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/sucursales/page/' + ${currentPage + 1} + '?query=' + ${query} + '&size=' + ${currentSize}}">Sig</a>
<a class="page-link" th:href="@{'/buscador/sucursales/page/' + ${currentPage + 1} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Sig</a>
</li>
<li class="page-item" th:classappend="${currentPage == totalPages ? 'disabled' : ''}">
<a class="page-link" th:href="@{'/buscador/sucursales/page/' + ${totalPages} + '?query=' + ${query} + '&size=' + ${currentSize}}">Ult</a>
<a class="page-link" th:href="@{'/buscador/sucursales/page/' + ${totalPages} + '?query=' + ${query} + '&size=' + ${currentSize} + '&secondaryOption=' + ${secondaryOption}}">Ult</a>
</li>
</ul>
</nav>

Loading…
Cancel
Save

Powered by INFORMATICA.FP.EDU.ES.