Acabando con oepracion de borar,edit y crear en todas las entidades. Refactorizacion del codigo de metodos de paginacion a un metodo y un interfaz de paginacion. Refactorizacion de los scripts y cambios a css de una tablas. Quitando el id de las tabla que el usuario no necesita a verlos.
parent
dffe0bdbf0
commit
ea6c8a7d63
@ -0,0 +1,92 @@
|
||||
package com.example.proyectofinal.controllers.modelControllers;
|
||||
|
||||
import com.example.proyectofinal.models.empresas.*;
|
||||
import com.example.proyectofinal.servicios.AlumnoService;
|
||||
import com.example.proyectofinal.servicios.CicloService;
|
||||
import com.example.proyectofinal.servicios.SkillService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Controller
|
||||
@RequestMapping()
|
||||
public class AlumnoController {
|
||||
@Autowired
|
||||
private AlumnoService alumnoService;
|
||||
|
||||
@Autowired
|
||||
private SkillService skillService;
|
||||
|
||||
@Autowired
|
||||
private CicloService cicloService;
|
||||
|
||||
@GetMapping("/admin/alumno/create")
|
||||
public String showCreateForm(Model model) {
|
||||
Alumno alumno = new Alumno();
|
||||
List<Ciclo> ciclos = cicloService.findAll();
|
||||
List<Skill> skills = skillService.findAll();
|
||||
model.addAttribute("skills", skills);
|
||||
model.addAttribute("alumno", alumno);
|
||||
model.addAttribute("ciclos", ciclos);
|
||||
return "admin/alumno/create";
|
||||
}
|
||||
|
||||
@PostMapping("/alumno/save")
|
||||
public ResponseEntity<String> saveAlumno(Alumno alumno, @RequestParam("ciclo") Long ciclo, @RequestParam("skills") List<Long> skills){
|
||||
try{
|
||||
Ciclo cicloEntity = cicloService.findById(ciclo);
|
||||
Set<Skill> skillEntities = skillService.findAllByIds(skills);
|
||||
alumno.setCiclo(cicloEntity);
|
||||
alumno.setSkills(skillEntities);
|
||||
Alumno testIfExist = alumnoService.exists(alumno);
|
||||
if(testIfExist != null){
|
||||
return new ResponseEntity<>("El alumno ya existe", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
alumnoService.save(alumno);
|
||||
return new ResponseEntity<>("El alumno fue guardado con exito", HttpStatus.OK);
|
||||
}catch (Exception e) {
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/admin/alumno/update/{id}")
|
||||
public String showUpdateForm(Model model, @PathVariable Long id) {
|
||||
Alumno alumno = alumnoService.findById(id);
|
||||
List<Ciclo> ciclos = cicloService.findAll();
|
||||
List<Skill> skills = skillService.findAll();
|
||||
model.addAttribute("skills", skills);
|
||||
model.addAttribute("alumno", alumno);
|
||||
model.addAttribute("ciclos", ciclos);
|
||||
return "admin/alumno/update";
|
||||
}
|
||||
|
||||
@PostMapping("/alumno/update")
|
||||
public ResponseEntity<String> updateAlumno(Alumno alumno, @RequestParam("ciclo") Long ciclo, @RequestParam("skills") List<Long> skills){
|
||||
try{
|
||||
Ciclo cicloEntity = cicloService.findById(ciclo);
|
||||
Set<Skill> skillEntities = skillService.findAllByIds(skills);
|
||||
alumno.setCiclo(cicloEntity);
|
||||
alumno.setSkills(skillEntities);
|
||||
alumnoService.save(alumno);
|
||||
return new ResponseEntity<>("El alumno fue actualizado con exito", HttpStatus.OK);
|
||||
}catch (Exception e) {
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/alumno/delete/{id}")
|
||||
public ResponseEntity<String> deleteAlumno(@PathVariable Long id){
|
||||
try{
|
||||
alumnoService.deleteById(id);
|
||||
return new ResponseEntity<>("El alumno ha sido eliminado", HttpStatus.OK);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package com.example.proyectofinal.controllers.modelControllers;
|
||||
|
||||
import com.example.proyectofinal.models.empresas.Ciclo;
|
||||
import com.example.proyectofinal.models.empresas.Familia;
|
||||
import com.example.proyectofinal.servicios.CicloService;
|
||||
import com.example.proyectofinal.servicios.FamiliaService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@RequestMapping()
|
||||
public class CicloController {
|
||||
|
||||
@Autowired
|
||||
private CicloService cicloService;
|
||||
|
||||
@Autowired
|
||||
private FamiliaService familiaService;
|
||||
|
||||
@GetMapping("/admin/ciclo/create")
|
||||
public String showCreateForm(Model model) {
|
||||
Ciclo ciclo = new Ciclo();
|
||||
List<Familia> familias = familiaService.findAll();
|
||||
Familia familia = new Familia();
|
||||
model.addAttribute("ciclo", ciclo);
|
||||
model.addAttribute("familias", familias);
|
||||
model.addAttribute("familia", familia);
|
||||
return "admin/ciclo/create";
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/ciclo/save")
|
||||
public ResponseEntity<String> saveCiclo(Ciclo ciclo, @RequestParam("familia") Long familiaId){
|
||||
try{
|
||||
Familia familia = familiaService.findById(familiaId);
|
||||
ciclo.setFamilia(familia);
|
||||
if(cicloService.exists(ciclo) != null){
|
||||
return new ResponseEntity<>("Este ciclo ya existe en la base de datos", HttpStatus.BAD_REQUEST);
|
||||
}else{
|
||||
cicloService.save(ciclo);
|
||||
return new ResponseEntity<>("El ciclo fue guardado con exito", HttpStatus.OK);
|
||||
}
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/admin/ciclo/update/{id}")
|
||||
public String showUpdateForm(Model model, @PathVariable Long id) {
|
||||
Ciclo ciclo = cicloService.findById(id);
|
||||
List<Familia> familias = familiaService.findAll();
|
||||
Familia familia = new Familia();
|
||||
model.addAttribute("ciclo", ciclo);
|
||||
model.addAttribute("familias", familias);
|
||||
model.addAttribute("familia", familia);
|
||||
return "admin/ciclo/update";
|
||||
}
|
||||
|
||||
@PostMapping("/ciclo/update")
|
||||
public ResponseEntity<String> updateCiclo(Ciclo ciclo, @RequestParam("familia.id") Long familiaId){
|
||||
try{
|
||||
Familia familia = familiaService.findById(familiaId);
|
||||
ciclo.setFamilia(familia);
|
||||
cicloService.save(ciclo);
|
||||
return new ResponseEntity<>("Los datos del ciclo fue renovados con exito", HttpStatus.OK);
|
||||
}catch (Exception e) {
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/ciclo/delete/{id}")
|
||||
public ResponseEntity<String> deleteCiclo(@PathVariable Long id){
|
||||
try{
|
||||
cicloService.deleteById(id);
|
||||
return new ResponseEntity<>("El ciclo ha sido eliminado", HttpStatus.OK);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,44 +1,65 @@
|
||||
package com.example.proyectofinal.controllers.modelControllers;
|
||||
|
||||
import com.example.proyectofinal.models.empresas.Ciclo;
|
||||
import com.example.proyectofinal.repositories.empresas.CicloRepository;
|
||||
import com.example.proyectofinal.models.empresas.Familia;
|
||||
import com.example.proyectofinal.servicios.FamiliaService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/familia")
|
||||
@RequestMapping()
|
||||
public class FamiliaController {
|
||||
@Autowired
|
||||
private CicloRepository cicloRepository;
|
||||
|
||||
@Autowired
|
||||
private FamiliaService familiaService;
|
||||
|
||||
@PostMapping("/crearFamilia")
|
||||
@ResponseBody
|
||||
public String editFamilia(@RequestParam String name) {
|
||||
String result = familiaService.createFamilia(name);
|
||||
System.out.println(name);
|
||||
if (result.equals("Familia creada")) {
|
||||
return "redirect:/editMain";
|
||||
}else if (result.equals("Familia ya existe")){
|
||||
return result;
|
||||
@GetMapping("/admin/familia/create")
|
||||
public String showCreateForm(Model model) {
|
||||
Familia familia = new Familia();
|
||||
model.addAttribute("familia", familia);
|
||||
return "admin/familia/create";
|
||||
}
|
||||
|
||||
@PostMapping("/familia/save")
|
||||
public ResponseEntity<String> saveFamilia(Familia familia){
|
||||
try{
|
||||
if(familiaService.findByName(familia.getNombre()) != null){
|
||||
System.out.println("Este familia ya existe en la base de datos");
|
||||
return new ResponseEntity<>("Este familia ya existe en la base de datos", HttpStatus.BAD_REQUEST);
|
||||
}else {
|
||||
return "redirect:/error";
|
||||
familiaService.save(familia);
|
||||
return new ResponseEntity<>("La familia fue guardado con exito", HttpStatus.OK);
|
||||
}
|
||||
}catch (Exception e) {
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
@GetMapping("/admin/familia/update/{id}")
|
||||
public String showUpdateForm(Model model, @PathVariable Long id) {
|
||||
Familia familia = familiaService.findById(id);
|
||||
model.addAttribute("familia", familia);
|
||||
return "admin/familia/update";
|
||||
}
|
||||
|
||||
@PostMapping("/familia/update")
|
||||
public ResponseEntity<String> updateFamilia(Familia familia){
|
||||
try{
|
||||
familiaService.save(familia);
|
||||
return new ResponseEntity<>("La familia ha sido actualizado con exito", HttpStatus.OK);
|
||||
}catch (Exception e) {
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public String getFamiliaById(@PathVariable Long id, Model model) {
|
||||
Set<Ciclo> cicloSet = new HashSet<>(cicloRepository.findCicloByFamiliaId(id));
|
||||
model.addAttribute("ciclos", cicloSet);
|
||||
return "ciclo";
|
||||
@GetMapping("/familia/delete/{id}")
|
||||
public ResponseEntity<String> deleteFamilia(@PathVariable Long id){
|
||||
try{
|
||||
familiaService.deleteById(id);
|
||||
return new ResponseEntity<>("La familia ha sido eliminado", HttpStatus.OK);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,107 @@
|
||||
package com.example.proyectofinal.controllers.modelControllers;
|
||||
|
||||
import com.example.proyectofinal.models.empresas.*;
|
||||
import com.example.proyectofinal.servicios.CicloService;
|
||||
import com.example.proyectofinal.servicios.OfertaService;
|
||||
import com.example.proyectofinal.servicios.SkillService;
|
||||
import com.example.proyectofinal.servicios.SucursalService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Controller
|
||||
@RequestMapping()
|
||||
public class OfertaController {
|
||||
@Autowired
|
||||
private OfertaService ofertaService;
|
||||
|
||||
@Autowired
|
||||
private SkillService skillService;
|
||||
|
||||
@Autowired
|
||||
private SucursalService sucursalService;
|
||||
|
||||
@Autowired
|
||||
private CicloService cicloService;
|
||||
|
||||
@GetMapping("/admin/oferta/create")
|
||||
public String showCreateForm(Model model) {
|
||||
Oferta oferta = new Oferta();
|
||||
List<Ciclo> ciclos = cicloService.findAll();
|
||||
List<Skill> skills = skillService.findAll();
|
||||
List<Sucursal> sucursals = sucursalService.findAll();
|
||||
model.addAttribute("sucursals", sucursals);
|
||||
model.addAttribute("skills", skills);
|
||||
model.addAttribute("oferta", oferta);
|
||||
model.addAttribute("ciclos", ciclos);
|
||||
return "admin/oferta/create";
|
||||
}
|
||||
|
||||
@PostMapping("/oferta/save")
|
||||
public ResponseEntity<String> saveOferta(Oferta oferta, @RequestParam("ciclo") Long ciclo, @RequestParam("sucursal") Long sucursal, @RequestParam("skills") List<Long> skills){
|
||||
try{
|
||||
Ciclo cicloEntity = cicloService.findById(ciclo);
|
||||
Sucursal sucursalEntity = sucursalService.findById(sucursal);
|
||||
Set<Skill> skillEntities = skillService.findAllByIds(skills);
|
||||
oferta.setCiclo(cicloEntity);
|
||||
oferta.setSucursal(sucursalEntity);
|
||||
oferta.setSkills(skillEntities);
|
||||
Oferta testIfExist = ofertaService.findByName(oferta.getNombre());
|
||||
if(testIfExist != null){
|
||||
return new ResponseEntity<>("Esta oferta ya existe en la base de datos", HttpStatus.BAD_REQUEST);
|
||||
}else {
|
||||
ofertaService.save(oferta);
|
||||
return new ResponseEntity<>("La oferta fue guadada con exito", HttpStatus.OK);
|
||||
}
|
||||
}catch (Exception e) {
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
@GetMapping("/admin/oferta/update/{id}")
|
||||
public String showUpdateForm(Model model, @PathVariable Long id) {
|
||||
Oferta oferta = ofertaService.findById(id);
|
||||
List<Ciclo> ciclos = cicloService.findAll();
|
||||
List<Skill> skills = skillService.findAll();
|
||||
List<Sucursal> sucursals = sucursalService.findAll();
|
||||
model.addAttribute("sucursals", sucursals);
|
||||
model.addAttribute("skills", skills);
|
||||
model.addAttribute("oferta", oferta);
|
||||
model.addAttribute("ciclos", ciclos);
|
||||
return "admin/oferta/update";
|
||||
}
|
||||
|
||||
@PostMapping("/oferta/update")
|
||||
public ResponseEntity<String> updateOferta(Oferta oferta, @RequestParam("ciclo") Long ciclo, @RequestParam("sucursal") Long sucursal, @RequestParam("skills") List<Long> skills){
|
||||
System.out.println("UPDATE TEST");
|
||||
try{
|
||||
Ciclo cicloEntity = cicloService.findById(ciclo);
|
||||
Sucursal sucursalEntity = sucursalService.findById(sucursal);
|
||||
Set<Skill> skillEntities = skillService.findAllByIds(skills);
|
||||
oferta.setCiclo(cicloEntity);
|
||||
oferta.setSucursal(sucursalEntity);
|
||||
oferta.setSkills(skillEntities);
|
||||
ofertaService.save(oferta);
|
||||
return new ResponseEntity<>("La oferta fue guadada con exito", HttpStatus.OK);
|
||||
}catch (Exception e) {
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/oferta/delete/{id}")
|
||||
public ResponseEntity<String> deleteOferta(@PathVariable Long id){
|
||||
try{
|
||||
ofertaService.deleteById(id);
|
||||
return new ResponseEntity<>("La oferta ha sido eliminado", HttpStatus.OK);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package com.example.proyectofinal.controllers.modelControllers;
|
||||
|
||||
import com.example.proyectofinal.models.empresas.Skill;
|
||||
import com.example.proyectofinal.servicios.SkillService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@Controller
|
||||
@RequestMapping()
|
||||
public class SkillController {
|
||||
@Autowired
|
||||
private SkillService skillService;
|
||||
|
||||
@GetMapping("/admin/skill/create")
|
||||
public String showCreateForm(Model model) {
|
||||
Skill skill = new Skill();
|
||||
model.addAttribute("skill", skill);
|
||||
return "admin/skill/create";
|
||||
}
|
||||
|
||||
@PostMapping("/skill/save")
|
||||
public ResponseEntity<String> saveSkill(Skill skill){
|
||||
try{
|
||||
if(skillService.findByName(skill.getNombre()) != null){
|
||||
return new ResponseEntity<>("Este skill ya existe en la base de datos", HttpStatus.BAD_REQUEST);
|
||||
}else {
|
||||
skillService.save(skill);
|
||||
return new ResponseEntity<>("El skill fue guardado con exito", HttpStatus.OK);
|
||||
}
|
||||
}catch (Exception e) {
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/admin/skill/update/{id}")
|
||||
public String showUpdateForm(Model model, @PathVariable Long id) {
|
||||
Skill skill = skillService.findById(id);
|
||||
model.addAttribute("skill", skill);
|
||||
return "admin/skill/update";
|
||||
}
|
||||
|
||||
@PostMapping("/skill/update")
|
||||
public ResponseEntity<String> updateSkill(Skill skill){
|
||||
try{
|
||||
skillService.save(skill);
|
||||
return new ResponseEntity<>("El skill fue renovado", HttpStatus.OK);
|
||||
}catch (Exception e) {
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/skill/delete/{id}")
|
||||
public ResponseEntity<String> deleteSkill(@PathVariable Long id){
|
||||
try{
|
||||
skillService.deleteById(id);
|
||||
return new ResponseEntity<>("Skill ha sido eliminada", HttpStatus.OK);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package com.example.proyectofinal.servicios;
|
||||
|
||||
import com.example.proyectofinal.models.empresas.Alumno;
|
||||
import com.example.proyectofinal.repositories.empresas.AlumnoRepository;
|
||||
import com.example.proyectofinal.servicios.implemetations.IAlumno;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class AlumnoService implements IAlumno{
|
||||
@Autowired
|
||||
private AlumnoRepository alumnoRepository;
|
||||
@Override
|
||||
public List<Alumno> findAll() {
|
||||
return alumnoRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Alumno> findAllPaginated(int pageNum, int pageSize, String sortField, String sortDir) {
|
||||
Sort sort = sortDir.equalsIgnoreCase(Sort.Direction.ASC.name())
|
||||
? Sort.by(sortField).ascending() :
|
||||
Sort.by(sortField).descending();
|
||||
Pageable pageable = PageRequest.of(pageNum - 1,pageSize,sort);
|
||||
return this.alumnoRepository.findAll(pageable);
|
||||
}
|
||||
@Override
|
||||
public Alumno findById(Long id) {
|
||||
return alumnoRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Alumno findByName(String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Alumno save(Alumno alumno) {
|
||||
return alumnoRepository.save(alumno);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void deleteById(Long id) {
|
||||
Alumno alumno = alumnoRepository.findById(id).orElse(null);
|
||||
if(alumno != null){
|
||||
alumnoRepository.deleteSkillByAlumnoId(alumno.getId());
|
||||
alumnoRepository.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Alumno> search(String query) {
|
||||
return alumnoRepository.search(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Alumno exists(Alumno alumno) {
|
||||
return alumnoRepository.findByNia(alumno.getNia());
|
||||
}
|
||||
@Transactional
|
||||
@Override
|
||||
public void deleteByCiclo(Long id) {
|
||||
List<Alumno> alumnos = alumnoRepository.findByCiclo(id);
|
||||
if(!alumnos.isEmpty()){
|
||||
for(Alumno alumno : alumnos){
|
||||
System.out.println("Deleting alumno with id: " + alumno.getId());
|
||||
alumnoRepository.deleteSkillByAlumnoId(alumno.getId()); // delete associated skills
|
||||
alumnoRepository.deleteById(alumno.getId()); // then delete the alumno
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package com.example.proyectofinal.servicios;
|
||||
|
||||
import com.example.proyectofinal.models.empresas.Ciclo;
|
||||
import com.example.proyectofinal.models.empresas.Familia;
|
||||
import com.example.proyectofinal.repositories.empresas.CicloRepository;
|
||||
import com.example.proyectofinal.servicios.implemetations.ICiclos;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CicloService implements ICiclos {
|
||||
@Autowired
|
||||
private CicloRepository cicloRepository;
|
||||
@Autowired
|
||||
private AlumnoService alumnoService;
|
||||
@Autowired
|
||||
private OfertaService ofertaService;
|
||||
|
||||
@Override
|
||||
public Page<Ciclo> findAllPaginated(int pageNum, int pageSize, String sortField, String sortDir) {
|
||||
Sort sort = sortDir.equalsIgnoreCase(Sort.Direction.ASC.name())
|
||||
? Sort.by(sortField).ascending() :
|
||||
Sort.by(sortField).descending();
|
||||
Pageable pageable = PageRequest.of(pageNum - 1,pageSize,sort);
|
||||
return this.cicloRepository.findAll(pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Ciclo> findAll() {
|
||||
return cicloRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Ciclo findById(Long id) {
|
||||
return cicloRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Ciclo findByName(String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Ciclo save(Ciclo ciclo) {
|
||||
return cicloRepository.save(ciclo);
|
||||
}
|
||||
@Transactional
|
||||
@Override
|
||||
public void deleteById(Long id) {
|
||||
Ciclo ciclo = cicloRepository.findById(id).orElse(null);
|
||||
if(ciclo != null){
|
||||
alumnoService.deleteByCiclo(ciclo.getId());
|
||||
ofertaService.deleteByCicloId(ciclo.getId());
|
||||
cicloRepository.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Ciclo> search(String query) {
|
||||
return cicloRepository.search(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByFamilia(Familia familia) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Ciclo exists(Ciclo ciclo) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void deleteByFamiliaId(Long id) {
|
||||
List<Ciclo> ciclos = cicloRepository.findCicloByFamiliaId(id);
|
||||
if(ciclos != null){
|
||||
for (Ciclo ciclo : ciclos) {
|
||||
System.out.println("Deleting ciclo with id: " + ciclo.getId());
|
||||
alumnoService.deleteByCiclo(ciclo.getId());
|
||||
ofertaService.deleteByCicloId(ciclo.getId());
|
||||
cicloRepository.deleteById(ciclo.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,34 +1,65 @@
|
||||
package com.example.proyectofinal.servicios;
|
||||
|
||||
import com.example.proyectofinal.models.empresas.Empresa;
|
||||
import com.example.proyectofinal.models.empresas.Familia;
|
||||
import com.example.proyectofinal.models.empresas.Oferta;
|
||||
import com.example.proyectofinal.repositories.empresas.FamiliaRepository;
|
||||
import com.example.proyectofinal.servicios.implemetations.IFamilia;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class FamiliaService {
|
||||
public class FamiliaService implements IFamilia {
|
||||
@Autowired
|
||||
private FamiliaRepository familiaRepository;
|
||||
@Autowired
|
||||
private CicloService cicloService;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<Familia> findAll() {
|
||||
return familiaRepository.findAll();
|
||||
}
|
||||
|
||||
public String createFamilia(String name) {
|
||||
if (familiaRepository.findByName(name).isPresent()) {
|
||||
return "Familia ya existe";
|
||||
} else {
|
||||
Familia newFamilia = new Familia();
|
||||
newFamilia.setNombre(name);
|
||||
familiaRepository.save(newFamilia);
|
||||
return "Familia creada";
|
||||
@Override
|
||||
public Page<Familia> findAllPaginated(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<Familia> result = familiaRepository.findAll(pageRequest);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Familia findById(Long id) {
|
||||
return familiaRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Familia findByName(String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String updateFamilia(Long id, String name) {
|
||||
if (familiaRepository.findById(id).isPresent()) {
|
||||
Familia familia = familiaRepository.findById(id).get();
|
||||
familia.setNombre(name);
|
||||
familiaRepository.save(familia);
|
||||
return "Familia actualizada";
|
||||
} else {
|
||||
return "Familia no encontrada";
|
||||
@Override
|
||||
public Familia save(Familia familia) {
|
||||
return familiaRepository.save(familia);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteById(Long id) {
|
||||
System.out.println("Deleting familia with id: " + id);
|
||||
cicloService.deleteByFamiliaId(id);
|
||||
familiaRepository.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Familia> search(String query) {
|
||||
return familiaRepository.search(query);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
package com.example.proyectofinal.servicios.implemetations;
|
||||
|
||||
import com.example.proyectofinal.models.empresas.Alumno;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IAlumno extends IPagination<Alumno> {
|
||||
List<Alumno> findAll();
|
||||
|
||||
Alumno findById(Long id);
|
||||
|
||||
Alumno findByName(String name);
|
||||
|
||||
Alumno save(Alumno ciclo);
|
||||
|
||||
void deleteById(Long id);
|
||||
|
||||
List<Alumno> search(String query);
|
||||
|
||||
Alumno exists(Alumno alumno);
|
||||
|
||||
void deleteByCiclo(Long id);
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.example.proyectofinal.servicios.implemetations;
|
||||
|
||||
import com.example.proyectofinal.models.empresas.Ciclo;
|
||||
import com.example.proyectofinal.models.empresas.Familia;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ICiclos extends IPagination<Ciclo> {
|
||||
List<Ciclo> findAll();
|
||||
|
||||
Ciclo findById(Long id);
|
||||
|
||||
Ciclo findByName(String name);
|
||||
|
||||
Ciclo save(Ciclo ciclo);
|
||||
|
||||
void deleteById(Long id);
|
||||
|
||||
List<Ciclo> search(String query);
|
||||
|
||||
void deleteByFamilia(Familia familia);
|
||||
|
||||
Ciclo exists(Ciclo ciclo);
|
||||
|
||||
void deleteByFamiliaId(Long id);
|
||||
}
|
||||
|
@ -0,0 +1,20 @@
|
||||
package com.example.proyectofinal.servicios.implemetations;
|
||||
|
||||
import com.example.proyectofinal.models.empresas.Familia;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IFamilia extends IPagination<Familia> {
|
||||
List<Familia> findAll();
|
||||
|
||||
Familia findById(Long id);
|
||||
|
||||
Familia findByName(String name);
|
||||
|
||||
Familia save(Familia familia);
|
||||
|
||||
void deleteById(Long id);
|
||||
|
||||
List<Familia> search(String query);
|
||||
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.example.proyectofinal.servicios.implemetations;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
|
||||
public interface IPagination<T> {
|
||||
|
||||
Page<T> findAllPaginated(int pageNum, int size, String sortField, String sortDir);
|
||||
}
|
@ -0,0 +1,205 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Creacion: Alumno</title>
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||
<link rel="stylesheet" type="text/css" th:href="@{/top.css}">
|
||||
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/css/select2.min.css" rel="stylesheet" />
|
||||
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/js/select2.min.js"></script>
|
||||
<style>
|
||||
form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
max-width: none;
|
||||
margin: auto;
|
||||
padding: 25px;
|
||||
margin-top: 100px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
margin-top: 25px;
|
||||
margin-right: 5px;
|
||||
width: 120px;
|
||||
height: 40px;
|
||||
font-family: Verdana;
|
||||
}
|
||||
form input[type="submit"], form input[type="button"] {
|
||||
width: 100px;
|
||||
}
|
||||
form input[type="text"]{
|
||||
width: 75%;
|
||||
}
|
||||
form label{
|
||||
font-size: 20px;
|
||||
margin-bottom: 10px;
|
||||
font-family: Verdana, Geneva, Tahoma, sans-serif;
|
||||
}
|
||||
|
||||
body, h1 {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Añadir Alumno<a href="/logout" class="logout-button"><i class="fas fa-door-open"></i></a></h1>
|
||||
|
||||
<form th:action="@{/contacto/save}" method="post" enctype="multipart/form-data" th:object="${alumno}">
|
||||
<div class="p-3">
|
||||
<div class ="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="nombre">Nombre</label>
|
||||
<div class = "col-sm-9">
|
||||
<input type="text" th:field="*{nombre}" required minlength="2" maxlength="75" class="form-control" id="nombre">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="cif">Apellido</label>
|
||||
<div class = "col-sm-9">
|
||||
<input type="text" th:field="*{apellido}" required minlength="2" maxlength="75" title="Entra un nombre" class="form-control" id="cif">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="apellido2">Apellido2</label>
|
||||
<div class = "col-sm-9">
|
||||
<input type="text" th:field="*{apellido2}" minlength="2" maxlength="75" class="form-control" id="apellido2">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="fechaNacimiento">Fecha de Nacimiento</label>
|
||||
<div class = "col-sm-9">
|
||||
<input type="date" th:field="*{fechaNacimiento}" required class="form-control" id="fechaNacimiento" title="Introduce fecha">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="genero">Genero</label>
|
||||
<div class="col-sm-9">
|
||||
<select th:field="*{genero}" class="form-control" id="genero" required>
|
||||
<option value="">Selecciona un genero</option>
|
||||
<option value="Mujer">Mujer</option>
|
||||
<option value="Varon">Varon</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="nia">Nia</label>
|
||||
<div class = "col-sm-9">
|
||||
<!--TODO: Añadir validacion de nia-->
|
||||
<input type="text" th:field="*{nia}" title="Entra un nia correcto" class="form-control" id="nia">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="dni">DNI/NIE</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" th:field="*{dni}" required class="form-control" id="dni" title="Introduce DNI/NIE">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="correo">Correo</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="email" th:field="*{correo}" required class="form-control" id="correo" title="Introduce correo">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="correo2">Correo2</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="email" th:field="*{correo2}" class="form-control" id="correo2" title="Introduce correo alternativo">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="nacionalidad">Nacionalidad</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" th:field="*{nacionalidad}" class="form-control" id="nacionalidad" title="Introduce nacionalidad">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="keywords">Keywords</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" th:field="*{keywords}" class="form-control" id="keywords" title="Introduce keywords">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Ciclos -->
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="ciclo">Ciclo</label>
|
||||
<div class="col-sm-9">
|
||||
<select th:field="*{ciclo.id}" class="form-control" id="ciclo">
|
||||
<option th:each="ciclo : ${ciclos}" th:value="${ciclo.id}" th:text="${ciclo.nombre}"></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="skills-container">
|
||||
<h2>Select Skills</h2>
|
||||
<select id="skills" multiple>
|
||||
<option th:each="skill : ${skills}" th:value="${skill.id}" th:text="${skill.nombre}"></option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
<input type="submit" value="Guardar" class="btn"/>
|
||||
<input type="button" value="Cancelar" id="btnCancelar" class="btn" onclick="goBack()"/>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#skills').select2();
|
||||
});
|
||||
|
||||
function goBack() {
|
||||
window.history.back();
|
||||
}
|
||||
$(document).ready(function () {
|
||||
$("form").on("submit", function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
var formDataArray = $(this).serializeArray();
|
||||
formDataArray.push({name: 'ciclo', value: $('#ciclo').val()});
|
||||
formDataArray.push({name: 'skills', value: $('#skills').val()});
|
||||
|
||||
$.ajax({
|
||||
url: '/alumno/save',
|
||||
type: 'post',
|
||||
data: $.param(formDataArray),
|
||||
success: function (message) {
|
||||
if(message === "El alumno fue guardado con exito") {
|
||||
alert("El alumno fue guardado con exito")
|
||||
window.history.go(-1);
|
||||
} else if(message === "El alumno ya existe"){
|
||||
alert("El alumno ya existe");
|
||||
window.history.go(-1);
|
||||
}else{
|
||||
alert("Error, consulte a los informaticos")
|
||||
window.history.go(-1)
|
||||
}
|
||||
},
|
||||
error: function (jqXHR) {
|
||||
alert(jqXHR.responseText);
|
||||
window.history.back();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,203 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Update: Alumno</title>
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||
<link rel="stylesheet" type="text/css" th:href="@{/top.css}">
|
||||
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/css/select2.min.css" rel="stylesheet" />
|
||||
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/js/select2.min.js"></script>
|
||||
<style>
|
||||
form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
max-width: none;
|
||||
margin: auto;
|
||||
padding: 25px;
|
||||
margin-top: 100px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
margin-top: 25px;
|
||||
margin-right: 5px;
|
||||
width: 120px;
|
||||
height: 40px;
|
||||
font-family: Verdana;
|
||||
}
|
||||
form input[type="submit"], form input[type="button"] {
|
||||
width: 100px;
|
||||
}
|
||||
form input[type="text"]{
|
||||
width: 75%;
|
||||
}
|
||||
form label{
|
||||
font-size: 20px;
|
||||
margin-bottom: 10px;
|
||||
font-family: Verdana, Geneva, Tahoma, sans-serif;
|
||||
}
|
||||
|
||||
body, h1 {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Editar datos de Alumno<a href="/logout" class="logout-button"><i class="fas fa-door-open"></i></a></h1>
|
||||
|
||||
<form th:action="@{/alumno/update}" method="post" enctype="multipart/form-data" th:object="${alumno}">
|
||||
<input type="hidden" th:field="*{id}"/>
|
||||
<div class="p-3">
|
||||
<div class ="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="nombre">Nombre</label>
|
||||
<div class = "col-sm-9">
|
||||
<input type="text" th:field="*{nombre}" required minlength="2" maxlength="75" class="form-control" id="nombre">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="cif">Apellido</label>
|
||||
<div class = "col-sm-9">
|
||||
<input type="text" th:field="*{apellido}" required minlength="2" maxlength="75" title="Entra un nombre" class="form-control" id="cif">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="apellido2">Apellido2</label>
|
||||
<div class = "col-sm-9">
|
||||
<input type="text" th:field="*{apellido2}" minlength="2" maxlength="75" class="form-control" id="apellido2">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="fechaNacimiento">Fecha de Nacimiento</label>
|
||||
<div class = "col-sm-9">
|
||||
<input type="date" th:field="*{fechaNacimiento}" required class="form-control" id="fechaNacimiento" title="Introduce fecha">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="genero">Genero</label>
|
||||
<div class="col-sm-9">
|
||||
<select th:field="*{genero}" class="form-control" id="genero" required>
|
||||
<option value="">Selecciona un genero</option>
|
||||
<option value="Mujer">Mujer</option>
|
||||
<option value="Varon">Varon</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="nia">Nia</label>
|
||||
<div class = "col-sm-9">
|
||||
<!--TODO: Añadir validacion de nia-->
|
||||
<input type="text" th:field="*{nia}" title="Entra un nia correcto" class="form-control" id="nia">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="dni">DNI/NIE</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" th:field="*{dni}" required class="form-control" id="dni" title="Introduce DNI/NIE">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="correo">Correo</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="email" th:field="*{correo}" required class="form-control" id="correo" title="Introduce correo">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="correo2">Correo2</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="email" th:field="*{correo2}" class="form-control" id="correo2" title="Introduce correo alternativo">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="nacionalidad">Nacionalidad</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" th:field="*{nacionalidad}" class="form-control" id="nacionalidad" title="Introduce nacionalidad">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="keywords">Keywords</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" th:field="*{keywords}" class="form-control" id="keywords" title="Introduce keywords">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Ciclos -->
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="ciclo">Ciclo</label>
|
||||
<div class="col-sm-9">
|
||||
<select th:field="*{ciclo.id}" class="form-control" id="ciclo">
|
||||
<option th:each="ciclo : ${ciclos}" th:value="${ciclo.id}" th:text="${ciclo.nombre}"></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="skills-container">
|
||||
<h2>Select Skills</h2>
|
||||
<select id="skills" multiple>
|
||||
<option th:each="skill : ${skills}" th:value="${skill.id}" th:text="${skill.nombre}" th:selected="${alumno.skills.contains(skill)}"></option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
<input type="submit" value="Guardar" class="btn"/>
|
||||
<input type="button" value="Cancelar" id="btnCancelar" class="btn" onclick="goBack()"/>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#skills').select2();
|
||||
});
|
||||
|
||||
function goBack() {
|
||||
window.history.back();
|
||||
}
|
||||
$(document).ready(function () {
|
||||
$("form").on("submit", function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
var formDataArray = $(this).serializeArray();
|
||||
formDataArray.push({name: 'ciclo', value: $('#ciclo').val()});
|
||||
formDataArray.push({name: 'skills', value: $('#skills').val()});
|
||||
|
||||
$.ajax({
|
||||
url: '/alumno/update',
|
||||
type: 'post',
|
||||
data: $.param(formDataArray),
|
||||
success: function (message) {
|
||||
if(message === "El alumno fue actualizado con exito") {
|
||||
alert("El alumno fue actualizado con exito")
|
||||
window.history.go(-1);
|
||||
} else {
|
||||
alert("Error, consulte a los informaticos")
|
||||
window.history.go(-1)
|
||||
}
|
||||
},
|
||||
error: function (jqXHR) {
|
||||
alert(jqXHR.responseText);
|
||||
window.history.back();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,123 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Creacion: Ciclo</title>
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||
<link rel="stylesheet" type="text/css" th:href="@{/top.css}">
|
||||
<style>
|
||||
form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
max-width: none;
|
||||
margin: auto;
|
||||
padding: 25px;
|
||||
margin-top: 100px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
margin-top: 25px;
|
||||
margin-right: 5px;
|
||||
width: 120px;
|
||||
height: 40px;
|
||||
font-family: Verdana;
|
||||
}
|
||||
form input[type="submit"], form input[type="button"] {
|
||||
width: 100px;
|
||||
}
|
||||
form input[type="text"]{
|
||||
width: 75%;
|
||||
}
|
||||
form label{
|
||||
font-size: 20px;
|
||||
margin-bottom: 10px;
|
||||
font-family: Verdana, Geneva, Tahoma, sans-serif;
|
||||
}
|
||||
|
||||
body, h1 {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Añadir Ciclo<a href="/logout" class="logout-button"><i class="fas fa-door-open"></i></a></h1>
|
||||
|
||||
<form th:action="@{/ciclo/save}" method="post" enctype="multipart/form-data" th:object="${ciclo}">
|
||||
<div class="p-3">
|
||||
<div class ="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="nombre">Nombre</label>
|
||||
<div class = "col-sm-9">
|
||||
<input type="text" th:field="*{nombre}" required minlength="2" maxlength="125" title="Entra un Nombre" class="form-control" id="nombre">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="codigo">Codigo</label>
|
||||
<div class = "col-sm-9">
|
||||
<input type="text" th:field="*{codigo}" required minlength="2" maxlength="15" title="Entra un codigo" class="form-control" id="codigo">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="familia">Familia</label>
|
||||
<div class = "col-sm-9">
|
||||
<select th:field="*{familia.id}" class="form-control" id="familia">
|
||||
<option th:each="familia : ${familias}" th:value="${familia.id}" th:text="${familia.nombre}"></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
<input type="submit" value="Guardar" class="btn"/>
|
||||
<input type="button" value="Cancelar" id="btnCancelar" class="btn" onclick="goBack()"/>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
function goBack() {
|
||||
window.history.back();
|
||||
}
|
||||
$(document).ready(function () {
|
||||
$("form").on("submit", function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
var formDataArray = $(this).serializeArray();
|
||||
formDataArray.push({name: 'familia', value: $('#familia').val()});
|
||||
$.ajax({
|
||||
url: '/ciclo/save',
|
||||
type: 'post',
|
||||
data: $.param(formDataArray),
|
||||
success: function (message) {
|
||||
if(message === "El ciclo fue guardado con exito") {
|
||||
alert("El ciclo fue guardado con exito")
|
||||
window.history.go(-1); // Go back two pages
|
||||
} else if(message === "Este ciclo ya existe en la base de datos"){
|
||||
alert("Este ciclo ya existe en la base de datos");
|
||||
window.history.go(-1);
|
||||
}else{
|
||||
alert("Error, consulata a los informaticos")
|
||||
window.history.go(-1)
|
||||
}
|
||||
},
|
||||
error: function (jqXHR) {
|
||||
alert(jqXHR.responseText);
|
||||
window.history.back();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,121 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Update: Ciclo</title>
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||
<link rel="stylesheet" type="text/css" th:href="@{/top.css}">
|
||||
<style>
|
||||
form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
max-width: none;
|
||||
margin: auto;
|
||||
padding: 25px;
|
||||
margin-top: 100px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
margin-top: 25px;
|
||||
margin-right: 5px;
|
||||
width: 120px;
|
||||
height: 40px;
|
||||
font-family: Verdana;
|
||||
}
|
||||
form input[type="submit"], form input[type="button"] {
|
||||
width: 100px;
|
||||
}
|
||||
form input[type="text"]{
|
||||
width: 75%;
|
||||
}
|
||||
form label{
|
||||
font-size: 20px;
|
||||
margin-bottom: 10px;
|
||||
font-family: Verdana, Geneva, Tahoma, sans-serif;
|
||||
}
|
||||
|
||||
body, h1 {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Editar datos de Ciclo<a href="/logout" class="logout-button"><i class="fas fa-door-open"></i></a></h1>
|
||||
|
||||
<form th:action="@{/ciclo/update}" method="post" enctype="multipart/form-data" th:object="${ciclo}">
|
||||
<input type="hidden" th:field="*{id}"/>
|
||||
<div class="p-3">
|
||||
<div class ="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="nombre">Nombre</label>
|
||||
<div class = "col-sm-9">
|
||||
<input type="text" th:field="*{nombre}" required minlength="2" maxlength="125" title="Entra un Nombre" class="form-control" id="nombre">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="codigo">Codigo</label>
|
||||
<div class = "col-sm-9">
|
||||
<input type="text" th:field="*{codigo}" required minlength="2" maxlength="15" title="Entra un codigo" class="form-control" id="codigo">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="familia">Familia</label>
|
||||
<div class = "col-sm-9">
|
||||
<select th:field="*{familia.id}" class="form-control" id="familia">
|
||||
<option th:each="familia : ${familias}" th:value="${familia.id}" th:text="${familia.nombre}"></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
<input type="submit" value="Guardar" class="btn"/>
|
||||
<input type="button" value="Cancelar" id="btnCancelar" class="btn" onclick="goBack()"/>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
function goBack() {
|
||||
console.log("goBack function called");
|
||||
window.history.back();
|
||||
}
|
||||
$(document).ready(function () {
|
||||
$("form").on("submit", function (event) {
|
||||
event.preventDefault();
|
||||
var formDataArray = $(this).serializeArray();
|
||||
formDataArray.push({name: 'familia', value: $('#familia').val()});
|
||||
$.ajax({
|
||||
url: '/ciclo/update',
|
||||
type: 'post',
|
||||
data: $.param(formDataArray),
|
||||
success: function (message) {
|
||||
if(message === "Los datos del ciclo fue renovados con exito") {
|
||||
alert("Los datos del ciclo fue renovados con exito")
|
||||
window.history.go(-1); // Go back two pages
|
||||
}else{
|
||||
alert("Error, consulata a los informaticos")
|
||||
window.history.go(-1)
|
||||
}
|
||||
},
|
||||
error: function (jqXHR) {
|
||||
alert(jqXHR.responseText);
|
||||
window.history.back();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,10 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,10 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,101 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Update: Familia</title>
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||
<link rel="stylesheet" type="text/css" th:href="@{/top.css}">
|
||||
<style>
|
||||
form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
max-width: none;
|
||||
margin: auto;
|
||||
padding: 25px;
|
||||
margin-top: 100px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
margin-top: 25px;
|
||||
margin-right: 5px;
|
||||
width: 120px;
|
||||
height: 40px;
|
||||
font-family: Verdana;
|
||||
}
|
||||
form input[type="submit"], form input[type="button"] {
|
||||
width: 100px;
|
||||
}
|
||||
form input[type="text"]{
|
||||
width: 75%;
|
||||
}
|
||||
form label{
|
||||
font-size: 20px;
|
||||
margin-bottom: 10px;
|
||||
font-family: Verdana, Geneva, Tahoma, sans-serif;
|
||||
}
|
||||
|
||||
body, h1 {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Editar datos de Familia<a href="/logout" class="logout-button"><i class="fas fa-door-open"></i></a></h1>
|
||||
|
||||
<form th:action="@{/familia/update}" method="post" enctype="multipart/form-data" th:object="${familia}">
|
||||
<input type="hidden" th:field="*{id}"/>
|
||||
<div class="p-3">
|
||||
<div class ="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="nombre">Nombre</label>
|
||||
<div class = "col-sm-9">
|
||||
<input type="text" th:field="*{nombre}" required minlength="2" maxlength="75" class="form-control" id="nombre">
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<input type="submit" value="Guardar" class="btn"/>
|
||||
<input type="button" value="Cancelar" id="btnCancelar" class="btn" onclick="goBack()"/>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
function goBack() {
|
||||
console.log("goBack function called");
|
||||
window.history.back();
|
||||
}
|
||||
$(document).ready(function () {
|
||||
$("form").on("submit", function (event) {
|
||||
event.preventDefault();
|
||||
var formData = $(this).serialize();
|
||||
formData += '&familia=';
|
||||
$.ajax({
|
||||
url: '/familia/update',
|
||||
type: 'post',
|
||||
data: formData,
|
||||
success: function (message) {
|
||||
if(message === "La familia ha sido actualizado con exito") {
|
||||
alert("Los datos del familia fue renovada con exito")
|
||||
window.history.go(-1); // Go back two pages
|
||||
}
|
||||
},
|
||||
error: function (jqXHR) {
|
||||
alert(jqXHR.responseText);
|
||||
window.history.back();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,156 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Creacion: Oferta</title>
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||
<link rel="stylesheet" type="text/css" th:href="@{/top.css}">
|
||||
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/css/select2.min.css" rel="stylesheet" />
|
||||
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/js/select2.min.js"></script>
|
||||
<style>
|
||||
form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
max-width: none;
|
||||
margin: auto;
|
||||
padding: 25px;
|
||||
margin-top: 100px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
margin-top: 25px;
|
||||
margin-right: 5px;
|
||||
width: 120px;
|
||||
height: 40px;
|
||||
font-family: Verdana;
|
||||
}
|
||||
form input[type="submit"], form input[type="button"] {
|
||||
width: 100px;
|
||||
}
|
||||
form input[type="text"]{
|
||||
width: 75%;
|
||||
}
|
||||
form label{
|
||||
font-size: 20px;
|
||||
margin-bottom: 10px;
|
||||
font-family: Verdana, Geneva, Tahoma, sans-serif;
|
||||
}
|
||||
|
||||
body, h1 {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Añadir Oferta<a href="/logout" class="logout-button"><i class="fas fa-door-open"></i></a></h1>
|
||||
|
||||
<form th:action="@{/oferta/save}" method="post" enctype="multipart/form-data" th:object="${oferta}">
|
||||
<div class="p-3">
|
||||
<div class ="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="nombre">Nombre</label>
|
||||
<div class = "col-sm-9">
|
||||
<input type="text" th:field="*{nombre}" required minlength="2" maxlength="128" class="form-control" id="nombre">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="fecha">Fecha</label>
|
||||
<div class = "col-sm-9">
|
||||
<input type="date" th:field="*{fecha}" required class="form-control" id="fecha" title="Introduce fecha">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="descripcion">Descripcion</label>
|
||||
<div class = "col-sm-9">
|
||||
<input type="text" th:field="*{descripcion}" class="form-control" id="descripcion">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Ciclos -->
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="ciclo">Ciclo</label>
|
||||
<div class="col-sm-9">
|
||||
<select th:field="*{ciclo.id}" class="form-control" id="ciclo">
|
||||
<option th:each="ciclo : ${ciclos}" th:value="${ciclo.id}" th:text="${ciclo.nombre}"></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Sucursals-->
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="sucursal">Sucursal</label>
|
||||
<div class="col-sm-9">
|
||||
<select th:field="*{sucursal.id}" class="form-control" id="sucursal">
|
||||
<option th:each="sucursal : ${sucursals}" th:value="${sucursal.id}" th:text="${sucursal.nombre}"></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="skills-container">
|
||||
<h2>Select Skills</h2>
|
||||
<select id="skills" multiple>
|
||||
<option th:each="skill : ${skills}" th:value="${skill.id}" th:text="${skill.nombre}"></option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
<input type="submit" value="Guardar" class="btn"/>
|
||||
<input type="button" value="Cancelar" id="btnCancelar" class="btn" onclick="goBack()"/>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#skills').select2();
|
||||
});
|
||||
|
||||
function goBack() {
|
||||
//console.log("goBack function called");
|
||||
window.history.back();
|
||||
}
|
||||
$(document).ready(function () {
|
||||
$("form").on("submit", function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
var formDataArray = $(this).serializeArray();
|
||||
formDataArray.push({name: 'ciclo', value: $('#ciclo').val()});
|
||||
formDataArray.push({name: 'sucursal', value: $('#sucursal').val()});
|
||||
formDataArray.push({name: 'skills', value: $('#skills').val()});
|
||||
|
||||
$.ajax({
|
||||
url: '/oferta/save',
|
||||
type: 'post',
|
||||
data: $.param(formDataArray), // use $.param(formDataArray) instead of formData
|
||||
success: function (message) {
|
||||
if(message === "La oferta fue guadada con exito") {
|
||||
alert("La oferta fue guadada con exito")
|
||||
window.history.go(-1); // Go back two pages
|
||||
} else if(message === "Esta oferta ya existe en la base de datos"){
|
||||
alert("Esta oferta ya existe en la base de datos");
|
||||
window.history.go(-1);
|
||||
}else{
|
||||
alert("Error, consulata a los informaticos")
|
||||
window.history.go(-1)
|
||||
}
|
||||
},
|
||||
error: function (jqXHR) {
|
||||
alert(jqXHR.responseText);
|
||||
window.history.back();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,152 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Update: Oferta</title>
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||
<link rel="stylesheet" type="text/css" th:href="@{/top.css}">
|
||||
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/css/select2.min.css" rel="stylesheet" />
|
||||
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/js/select2.min.js"></script>
|
||||
<style>
|
||||
form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
max-width: none;
|
||||
margin: auto;
|
||||
padding: 25px;
|
||||
margin-top: 100px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
margin-top: 25px;
|
||||
margin-right: 5px;
|
||||
width: 120px;
|
||||
height: 40px;
|
||||
font-family: Verdana;
|
||||
}
|
||||
form input[type="submit"], form input[type="button"] {
|
||||
width: 100px;
|
||||
}
|
||||
form input[type="text"]{
|
||||
width: 75%;
|
||||
}
|
||||
form label{
|
||||
font-size: 20px;
|
||||
margin-bottom: 10px;
|
||||
font-family: Verdana, Geneva, Tahoma, sans-serif;
|
||||
}
|
||||
|
||||
body, h1 {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Editar datos de Oferta<a href="/logout" class="logout-button"><i class="fas fa-door-open"></i></a></h1>
|
||||
|
||||
<form th:action="@{/oferta/update}" method="post" enctype="multipart/form-data" th:object="${oferta}">
|
||||
<input type="hidden" th:field="*{id}"/>
|
||||
<div class="p-3">
|
||||
<div class ="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="nombre">Nombre</label>
|
||||
<div class = "col-sm-9">
|
||||
<input type="text" th:field="*{nombre}" required minlength="2" maxlength="128" class="form-control" id="nombre">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="fecha">Fecha</label>
|
||||
<div class = "col-sm-9">
|
||||
<input type="date" th:field="*{fecha}" required class="form-control" id="fecha" title="Introduce fecha en formato aaaa-mm-dd como 2022-05-05">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="descripcion">Descripcion</label>
|
||||
<div class = "col-sm-9">
|
||||
<input type="text" th:field="*{descripcion}" class="form-control" id="descripcion">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Ciclos -->
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="ciclo">Ciclo</label>
|
||||
<div class="col-sm-9">
|
||||
<select th:field="*{ciclo.id}" class="form-control" id="ciclo">
|
||||
<option th:each="ciclo : ${ciclos}" th:value="${ciclo.id}" th:text="${ciclo.nombre}"></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Sucursals-->
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="sucursal">Sucursal</label>
|
||||
<div class="col-sm-9">
|
||||
<select th:field="*{sucursal.id}" class="form-control" id="sucursal">
|
||||
<option th:each="sucursal : ${sucursals}" th:value="${sucursal.id}" th:text="${sucursal.nombre}"></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="skills-container">
|
||||
<h2>Select Skills</h2>
|
||||
<select id="skills" multiple>
|
||||
<option th:each="skill : ${skills}" th:value="${skill.id}" th:text="${skill.nombre}" th:selected="${oferta.skills.contains(skill)}"></option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
<input type="submit" value="Guardar" class="btn"/>
|
||||
<input type="button" value="Cancelar" id="btnCancelar" class="btn" onclick="goBack()"/>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#skills').select2();
|
||||
});
|
||||
|
||||
function goBack() {
|
||||
window.history.back();
|
||||
}
|
||||
$(document).ready(function () {
|
||||
$("form").on("submit", function (event) {
|
||||
event.preventDefault();
|
||||
var formDataArray = $(this).serializeArray();
|
||||
formDataArray.push({name: 'ciclo', value: $('#ciclo').val()});
|
||||
formDataArray.push({name: 'sucursal', value: $('#sucursal').val()});
|
||||
formDataArray.push({name: 'skills', value: $('#skills').val()});
|
||||
$.ajax({
|
||||
url: '/oferta/update',
|
||||
type: 'post',
|
||||
data: $.param(formDataArray),
|
||||
success: function (message) {
|
||||
if(message === "La oferta fue guadada con exito") {
|
||||
alert("La oferta fue renovada con exito")
|
||||
window.history.go(-1);
|
||||
}else{
|
||||
alert("Error, consulata a los informaticos")
|
||||
window.history.go(-1)
|
||||
}
|
||||
},
|
||||
error: function (jqXHR) {
|
||||
alert(jqXHR.responseText);
|
||||
window.history.back();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,105 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Creacion: Skill</title>
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||
<link rel="stylesheet" type="text/css" th:href="@{/top.css}">
|
||||
<style>
|
||||
form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
max-width: none;
|
||||
margin: auto;
|
||||
padding: 25px;
|
||||
margin-top: 100px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
margin-top: 25px;
|
||||
margin-right: 5px;
|
||||
width: 120px;
|
||||
height: 40px;
|
||||
font-family: Verdana;
|
||||
}
|
||||
form input[type="submit"], form input[type="button"] {
|
||||
width: 100px;
|
||||
}
|
||||
form input[type="text"]{
|
||||
width: 75%;
|
||||
}
|
||||
form label{
|
||||
font-size: 20px;
|
||||
margin-bottom: 10px;
|
||||
font-family: Verdana, Geneva, Tahoma, sans-serif;
|
||||
}
|
||||
|
||||
body, h1 {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Añadir Skill<a href="/logout" class="logout-button"><i class="fas fa-door-open"></i></a></h1>
|
||||
|
||||
<form th:action="@{/skill/save}" method="post" enctype="multipart/form-data" th:object="${skill}">
|
||||
<div class="p-3">
|
||||
<div class ="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="nombre">Nombre</label>
|
||||
<div class = "col-sm-9">
|
||||
<input type="text" th:field="*{nombre}" required minlength="2" maxlength="128" class="form-control" id="nombre">
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<input type="submit" value="Guardar" class="btn"/>
|
||||
<input type="button" value="Cancelar" id="btnCancelar" class="btn" onclick="goBack()"/>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
function goBack() {
|
||||
console.log("goBack function called");
|
||||
window.history.back();
|
||||
}
|
||||
$(document).ready(function () {
|
||||
$("form").on("submit", function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
var formData = $(this).serialize();
|
||||
formData += '&skill=';
|
||||
$.ajax({
|
||||
url: '/skill/save',
|
||||
type: 'post',
|
||||
data: formData,
|
||||
success: function (message) {
|
||||
if(message === "El skill fue guardado con exito") {
|
||||
alert("El skill fue guardado con exito")
|
||||
window.history.go(-1); // Go back two pages
|
||||
} else if(message === "Este skill ya existe en la base de datos"){
|
||||
alert("Este skill ya existe en la base de datos");
|
||||
window.history.go(-1);
|
||||
}else{
|
||||
alert("Error, consulata a los informaticos")
|
||||
window.history.go(-1)
|
||||
}
|
||||
},
|
||||
error: function (jqXHR) {
|
||||
alert(jqXHR.responseText);
|
||||
window.history.back();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,107 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Update: Skill</title>
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||
<link rel="stylesheet" type="text/css" th:href="@{/top.css}">
|
||||
<style>
|
||||
form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
max-width: none;
|
||||
margin: auto;
|
||||
padding: 25px;
|
||||
margin-top: 100px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
margin-top: 25px;
|
||||
margin-right: 5px;
|
||||
width: 120px;
|
||||
height: 40px;
|
||||
font-family: Verdana;
|
||||
}
|
||||
form input[type="submit"], form input[type="button"] {
|
||||
width: 100px;
|
||||
}
|
||||
form input[type="text"]{
|
||||
width: 75%;
|
||||
}
|
||||
form label{
|
||||
font-size: 20px;
|
||||
margin-bottom: 10px;
|
||||
font-family: Verdana, Geneva, Tahoma, sans-serif;
|
||||
}
|
||||
|
||||
body, h1 {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Editar Skill<a href="/logout" class="logout-button"><i class="fas fa-door-open"></i></a></h1>
|
||||
|
||||
<form th:action="@{/skill/update}" method="post" enctype="multipart/form-data" th:object="${skill}">
|
||||
<input type="hidden" th:field="*{id}"/>
|
||||
<div class="p-3">
|
||||
|
||||
<div class ="form-group row">
|
||||
<label class="col-sm-3 col-form-label" for="nombre">Nombre</label>
|
||||
<div class = "col-sm-9">
|
||||
<input type="text" th:field="*{nombre}" required minlength="2" maxlength="128" class="form-control" id="nombre">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
<input type="submit" value="Guardar" class="btn"/>
|
||||
<input type="button" value="Cancelar" id="btnCancelar" class="btn" onclick="goBack()"/>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
function goBack() {
|
||||
console.log("goBack function called");
|
||||
window.history.back();
|
||||
}
|
||||
$(document).ready(function () {
|
||||
$("form").on("submit", function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
var formData = $(this).serialize();
|
||||
formData += '&skill=';
|
||||
$.ajax({
|
||||
url: '/skill/update',
|
||||
type: 'post',
|
||||
data: formData,
|
||||
success: function (message) {
|
||||
if(message === "El skill fue renovado") {
|
||||
alert("El skill fue renovado")
|
||||
window.history.go(-1);
|
||||
}else{
|
||||
alert("Error, consulata a los informaticos")
|
||||
window.history.go(-1)
|
||||
}
|
||||
},
|
||||
error: function (jqXHR) {
|
||||
alert(jqXHR.responseText);
|
||||
window.history.back();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,43 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css">
|
||||
<link rel="stylesheet" type="text/css" th:href="@{/style.css}">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
<style>
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-Fy6S3B9q64WdZWQUiU+q4/2Lc9npb8tCaSX9FK7E8HnRr0Jz8D6OP9dO5Vg3Q9ct" crossorigin="anonymous"></script>
|
||||
<h1>Listado de Ciclos<a href="/logout" class="logout-button"><i class="fas fa-door-open"></i></a></h1>
|
||||
<div class="table">
|
||||
<table class ="table table-hover table-responsive-xl">
|
||||
<thead class="thread-light">
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<th>Nombre</th>
|
||||
<th>Familia</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="cell" th:each="ciclo :${ciclos}">
|
||||
<td>[[${ciclo.id}]]</td>
|
||||
<td>[[${ciclo.nombre}]]</td>
|
||||
<td>[[${ciclo.familia.nombre}]]</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<button onclick="goBack()">Atras</button>
|
||||
|
||||
<script>
|
||||
function goBack() {
|
||||
window.history.back();
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,251 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css">
|
||||
<link rel="stylesheet" type="text/css" th:href="@{/style.css}">
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
|
||||
<meta charset="UTF-8">
|
||||
<title>Lista: Cilos</title>
|
||||
<style>
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="header">
|
||||
<button onclick="goBack()">Atras</button>
|
||||
<h1>Listado de Ciclos</h1>
|
||||
<a href="/logout" class="logout-button"><i class="fas fa-door-open"></i></a>
|
||||
</div>
|
||||
|
||||
|
||||
<input type="text" id="myInput" placeholder="Buscar por...."> <i class="fas fa-plus" id="create-icon"></i>
|
||||
|
||||
<div class="table-container">
|
||||
<table class="table" id="table">
|
||||
<thead class="thread-light">
|
||||
<tr>
|
||||
<th class="table-header">
|
||||
<a th:href="@{'/buscador/ciclos/page/' + ${currentPage} + '?sortField=nombre&sortDir=' + ${reverseSortDir}}">
|
||||
Nombre
|
||||
</a>
|
||||
</th>
|
||||
<th class="table-header">
|
||||
<a th:href="@{'/buscador/ciclos/page/' + ${currentPage} + '?sortField=codigo&sortDir=' + ${reverseSortDir}}">
|
||||
Codigo
|
||||
</a>
|
||||
</th>
|
||||
<th class="table-header">
|
||||
<a th:href="@{'/buscador/ciclos/page/' + ${currentPage} + '?sortField=familia.nombre&sortDir=' + ${reverseSortDir}}">
|
||||
Familia
|
||||
</a>
|
||||
</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="cell" th:each="ciclo :${items}" th:data-id="${ciclo.id}">
|
||||
<td>
|
||||
[[${ciclo.nombre}]]
|
||||
<i class="edit-icon fas fa-pen-square"></i>
|
||||
<i class="delete-icon fas fa-ban"></i>
|
||||
</td>
|
||||
<td>[[${ciclo.codigo}]]</td>
|
||||
<td>[[${ciclo.familia.nombre}]]</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="page">
|
||||
<nav aria-label="Page navigation" id="paginationControls">
|
||||
<ul class="pagination">
|
||||
<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>
|
||||
</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>
|
||||
</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>
|
||||
</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>
|
||||
</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>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
<select id="entriesCount">
|
||||
<option th:each="item : ${itemsPage}" th:value="${item}" th:text="${item}" th:selected="${item == currentSize}"></option>
|
||||
</select>
|
||||
|
||||
<div id="modalDelete" class ="modal">
|
||||
<div class="modal-content">
|
||||
<p>¿Estas seguro que quires borar este elemnto?</p>
|
||||
<span class="delete">Borar</span>
|
||||
<span class="close">Cancelar</span>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/orderTable.js"></script>
|
||||
<script>
|
||||
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) {
|
||||
console.log("Edit icon clicked");
|
||||
handleEdit(event);
|
||||
});
|
||||
|
||||
$table.on('click', '.delete-icon', function(event) {
|
||||
console.log("Delete icon clicked");
|
||||
handleDelete(event);
|
||||
});
|
||||
|
||||
function handleEdit(event) {
|
||||
console.log("handleEdit function called");
|
||||
const row = event.target.closest('tr');
|
||||
const rowId = row.dataset.id;
|
||||
console.log("Row ID: " + rowId);
|
||||
window.location = "/admin/ciclo/update/" + rowId;
|
||||
}
|
||||
|
||||
function handleDelete(event) {
|
||||
console.log("handleDelete function called");
|
||||
console.log("Delete icon clicked");
|
||||
const row = event.target.closest('tr');
|
||||
const rowId = row.dataset.id;
|
||||
var modal = document.getElementById("modalDelete");
|
||||
var closeSpan = document.getElementsByClassName("close")[0];
|
||||
var deleteSpan = document.getElementsByClassName("delete")[0];
|
||||
modal.style.display = "block";
|
||||
document.body.style.pointerEvents = 'none';
|
||||
modal.style.pointerEvents = 'auto';
|
||||
|
||||
closeSpan.onclick = function() {
|
||||
modal.style.display = "none";
|
||||
document.body.style.pointerEvents = 'auto';
|
||||
}
|
||||
|
||||
deleteSpan.onclick = function() {
|
||||
$.ajax({
|
||||
url: '/ciclo/delete/' + rowId,
|
||||
type: 'GET',
|
||||
success: function(response) {
|
||||
if (response === "El ciclo ha sido eliminado") {
|
||||
alert("Cilco borrado con exito");
|
||||
window.location.reload();
|
||||
} else {
|
||||
alert("Error al borrar el ciclo");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$myInput.on('input', function() {
|
||||
var query = document.querySelector('#myInput').value;
|
||||
var paginationControls = document.querySelector('#paginationControls');
|
||||
var entriesCountDropdown = document.querySelector('#entriesCount');
|
||||
|
||||
if (query == '') {
|
||||
isSearchBarUsed = false;
|
||||
paginationControls.style.display = '';
|
||||
entriesCountDropdown.style.display = '';
|
||||
table.style.pointerEvents = '';
|
||||
location.reload();
|
||||
} else {
|
||||
isSearchBarUsed = true;
|
||||
paginationControls.style.display = 'none';
|
||||
entriesCountDropdown.style.display = 'none';
|
||||
table.style.pointerEvents = 'none';
|
||||
|
||||
fetch('/buscador/ciclos/search?query=' + query)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
var tableBody = document.querySelector('#table tbody');
|
||||
tableBody.innerHTML = '';
|
||||
data.forEach(ciclo => {
|
||||
var row = document.createElement('tr');
|
||||
row.dataset.id = ciclo.id;
|
||||
row.innerHTML = `
|
||||
<td>
|
||||
${ciclo.nombre}
|
||||
<i class="edit-icon fas fa-pen-square"></i>
|
||||
<i class="delete-icon fas fa-ban"></i>
|
||||
</td>
|
||||
<td>${ciclo.codigo}</td>
|
||||
<td>${ciclo.familia.nombre}</td>
|
||||
`;
|
||||
tableBody.appendChild(row);
|
||||
});
|
||||
|
||||
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) {
|
||||
icon.removeEventListener('click', handleDelete);
|
||||
icon.addEventListener('click', handleDelete);
|
||||
console.log("Delete icon event listener attached");
|
||||
});
|
||||
|
||||
table.style.pointerEvents = 'auto';
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
document.querySelector('#table').addEventListener('click', function(event) {
|
||||
if (event.target.matches('.edit-icon')) {
|
||||
handleEdit(event);
|
||||
} else if (event.target.matches('.delete-icon')) {
|
||||
handleDelete(event);
|
||||
}
|
||||
});
|
||||
|
||||
// Create a new observer
|
||||
const observer = new MutationObserver(function() {
|
||||
// Attach the event listeners to the edit and delete icons
|
||||
document.querySelectorAll('.edit-icon').forEach(function(icon) {
|
||||
icon.addEventListener('click', handleEdit);
|
||||
});
|
||||
document.querySelectorAll('.delete-icon').forEach(function(icon) {
|
||||
icon.addEventListener('click', handleDelete);
|
||||
});
|
||||
});
|
||||
|
||||
// Start observing the document with the configured parameters
|
||||
observer.observe(document.querySelector('#table tbody'), { childList: true });
|
||||
|
||||
document.getElementById('create-icon').addEventListener('click', function() {
|
||||
console.log("Create button clicked : TEST");
|
||||
window.location = "/admin/ciclo/create";
|
||||
});
|
||||
|
||||
var tableHeaders = document.querySelectorAll('.table-header');
|
||||
tableHeaders.forEach(function(header) {
|
||||
header.addEventListener('click', function(event) {
|
||||
// If the search bar is currently being used, prevent the default action of the click event
|
||||
if (isSearchBarUsed) {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in new issue