Add Categoria and Departamento services and repositories; refactor UserService to implement GenericEntityService
This commit is contained in:
parent
ebbb373cf6
commit
8b14a236a2
|
|
@ -2,6 +2,7 @@
|
|||
package com.ieslamar.GestionInventario;
|
||||
import com.ieslamar.GestionInventario.dto.BotonDTO;
|
||||
import com.ieslamar.GestionInventario.entities.Role;
|
||||
import com.ieslamar.GestionInventario.services.CategoriaService;
|
||||
import com.ieslamar.GestionInventario.services.DepartamentoService;
|
||||
import com.ieslamar.GestionInventario.services.UserService;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
|
|
@ -11,14 +12,14 @@ import org.springframework.context.annotation.Configuration;
|
|||
@Configuration
|
||||
public class DataInitializer {
|
||||
|
||||
@Bean
|
||||
public CommandLineRunner initData(UserService userService,DepartamentoService departamentoService) {
|
||||
return args -> {
|
||||
// @Bean
|
||||
// public CommandLineRunner initData(UserService userService,DepartamentoService departamentoService) {
|
||||
// return args -> {
|
||||
// userService.registerUser("Test","test123",Role.USER.name(),"test4@gmail.com",departamentoService.getDepartamentoById(1));
|
||||
// userService.registerUser("admin", "admin123", Role.ADMIN.name(), "admin123@ejemplo.com",null);
|
||||
// userService.registerUser("user", "user123", Role.USER.name(), "user123@ejemplo.com",null);
|
||||
};
|
||||
}
|
||||
// };
|
||||
// }
|
||||
|
||||
// @Bean
|
||||
// public CommandLineRunner initData(DepartamentoService departamentoService) {
|
||||
|
|
@ -27,6 +28,12 @@ public class DataInitializer {
|
|||
// departamentoService.registerDepartamento("Ciencias");
|
||||
// };
|
||||
// }
|
||||
// @Bean
|
||||
// public CommandLineRunner initData(CategoriaService categoriaService) {
|
||||
// return args -> {
|
||||
// categoriaService.registerCategoria("Mueble");
|
||||
// };
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,46 +1,50 @@
|
|||
package com.ieslamar.GestionInventario.controllers;
|
||||
|
||||
|
||||
import com.ieslamar.GestionInventario.dto.BotonDTO;
|
||||
import com.ieslamar.GestionInventario.entities.Departamento;
|
||||
import com.ieslamar.GestionInventario.entities.User;
|
||||
import com.ieslamar.GestionInventario.entities.*;
|
||||
import com.ieslamar.GestionInventario.repos.GenericEntityService;
|
||||
import com.ieslamar.GestionInventario.services.CategoriaService;
|
||||
import com.ieslamar.GestionInventario.services.DepartamentoService;
|
||||
import com.ieslamar.GestionInventario.services.UserService;
|
||||
import jakarta.persistence.Entity;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
public class UserController {
|
||||
@Autowired
|
||||
private ApplicationContext context;
|
||||
|
||||
private final UserService userService;
|
||||
private final DepartamentoService departamentoService;
|
||||
private final CategoriaService categoriaService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(UserController.class);
|
||||
|
||||
public UserController(UserService userService, DepartamentoService departamentoService) {
|
||||
public UserController(UserService userService, DepartamentoService departamentoService, CategoriaService categoriaService) {
|
||||
this.userService = userService;
|
||||
this.departamentoService = departamentoService;
|
||||
this.categoriaService = categoriaService;
|
||||
}
|
||||
|
||||
private final BotonDTO gestionUsuarios = new BotonDTO("Gestión de usuarios", "/user_list", true, null);
|
||||
// private final BotonDTO gestionDepartamentosTest = new BotonDTO("Gestión de departamentos generica", "/list/" + Categoria.class.getSimpleName(), true, null);
|
||||
private final BotonDTO gestionProductos = new BotonDTO("Gestión de Productos", "/user_management", true, null);
|
||||
private final BotonDTO gestionDepartamentos = new BotonDTO("Gestión de Departamentos", "/departamento_list", true, null);
|
||||
private final BotonDTO gestionCategorias = new BotonDTO("Gestión de Categorías", "/user_management", true, null);
|
||||
private final BotonDTO gestionUbicaciones = new BotonDTO("Gestión de Ubicaciones", "/user_management", true, null);
|
||||
private final BotonDTO gestionInventario = new BotonDTO("Gestión de Inventario", "/user_management", true, null);
|
||||
private final BotonDTO gestionInventario = new BotonDTO("Gestión de Inventario", "/inventario", true, null);
|
||||
private final BotonDTO gestionTiposDatos = new BotonDTO("Gestión de Tipos de dato", "/user_management", true, null);
|
||||
|
||||
private final BotonDTO inventario = new BotonDTO("Inventario", "/management", false, null);
|
||||
|
|
@ -93,6 +97,7 @@ public class UserController {
|
|||
gestionInventario,
|
||||
gestionCategorias,
|
||||
gestionTiposDatos,
|
||||
// gestionDepartamentosTest,
|
||||
home
|
||||
)));
|
||||
model.addAttribute("buttons", botones);
|
||||
|
|
@ -100,40 +105,50 @@ public class UserController {
|
|||
}
|
||||
|
||||
|
||||
//USERS--------------------------------------------------------------------------------------------------------
|
||||
|
||||
@GetMapping("/userPage")
|
||||
public String userPage(Model model) {
|
||||
model.addAttribute("departamentos", departamentoService.getAllDepartamentos());
|
||||
return "userPage"; // Retorna la vista register.html
|
||||
}
|
||||
|
||||
@PostMapping("/userPage")
|
||||
public String userPage(@RequestParam String username,
|
||||
public String userPage(@RequestParam(required = false) Long id,
|
||||
@RequestParam String username,
|
||||
@RequestParam String password,
|
||||
@RequestParam String role,
|
||||
@RequestParam String mail,
|
||||
@RequestParam(required = false) Integer iddepartamento
|
||||
) {
|
||||
Departamento departamento = null;
|
||||
if(iddepartamento != null)
|
||||
departamento = departamentoService.getDepartamentoById(iddepartamento);
|
||||
userService.registerUser(username, password, role, mail, departamento);
|
||||
return "redirect:/user_list"; // Redirige al login tras registrarse
|
||||
@RequestParam(required = false) Integer iddepartamento) {
|
||||
Departamento departamento = iddepartamento != null ? departamentoService.getDepartamentoById(iddepartamento) : null;
|
||||
if (id != null) {
|
||||
// Editar usuario existente
|
||||
User user = userService.getUserById(id);
|
||||
if (user != null) {
|
||||
user.setNombre(username);
|
||||
if (!password.isEmpty()) {
|
||||
user.setPassword(password);
|
||||
}
|
||||
user.setRole(Role.valueOf(role));
|
||||
user.setMail(mail);
|
||||
user.setDepartamento(departamento);
|
||||
userService.saveUser(user);
|
||||
}
|
||||
} else {
|
||||
// Crear nuevo usuario
|
||||
userService.registerUser(username, password, role, mail, departamento);
|
||||
}
|
||||
return "redirect:/user_list";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("/delete_user")
|
||||
public String deleteUser(@RequestParam("id") Long id) {
|
||||
User user = userService.getUserById(id);
|
||||
userService.deleteUser(user); // Llama al servicio para eliminar el usuario
|
||||
return "redirect:/user_list"; // Redirige a la página de gestión de usuarios
|
||||
}
|
||||
|
||||
@GetMapping("/user_list")
|
||||
public String userList(Model model) {
|
||||
return buildUserList(model, userService.getAllUsers());
|
||||
}
|
||||
|
||||
private String buildUserList(Model model, List<User> users) {
|
||||
model.addAttribute("title", "Gestión de usuarios");
|
||||
model.addAttribute("headers", List.of("ID", "Nombre", "Rol", "Email", "Departamento"));
|
||||
|
|
@ -150,7 +165,7 @@ public class UserController {
|
|||
))
|
||||
.toList());
|
||||
model.addAttribute("actionsUrl", Map.of(
|
||||
"edit", "",
|
||||
"edit", "/edit_user",
|
||||
"delete", "/delete_user"
|
||||
));
|
||||
model.addAttribute("backUrl", "/Inventario/home");
|
||||
|
|
@ -158,11 +173,18 @@ public class UserController {
|
|||
|
||||
return "list";
|
||||
}
|
||||
@GetMapping("/edit_user/{id}")
|
||||
public String editUser(@PathVariable Long id, Model model) {
|
||||
User user = userService.getUserById(id);
|
||||
if (user != null) {
|
||||
model.addAttribute("user", user);
|
||||
model.addAttribute("departamentos", departamentoService.getAllDepartamentos());
|
||||
}
|
||||
return "userPage"; // Redirige a la página de registro
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//DEPARTAMENTOS--------------------------------------------------------------------------------------------------------
|
||||
|
||||
@GetMapping("/departamento_list")
|
||||
public String genericPageDepartamento(Model model) {
|
||||
|
|
@ -182,5 +204,101 @@ public class UserController {
|
|||
return "list";
|
||||
}
|
||||
|
||||
//CATEGORIAS--------------------------------------------------------------------------------------------------------
|
||||
|
||||
private String buildCategoriaList(Model model, List<Categoria> categorias) {
|
||||
model.addAttribute("title", "Gestión de categorías");
|
||||
model.addAttribute("headers", List.of("ID", "Nombre"));
|
||||
model.addAttribute("items", categorias.stream()
|
||||
.map(categoria -> Map.of(
|
||||
"id", categoria.getId(),
|
||||
"values", List.of(
|
||||
categoria.getId(),
|
||||
categoria.getNombre()
|
||||
)
|
||||
))
|
||||
.toList());
|
||||
model.addAttribute("actionsUrl", Map.of(
|
||||
"edit", "",
|
||||
"delete", "/delete_user"
|
||||
));
|
||||
model.addAttribute("backUrl", "/Inventario/home");
|
||||
model.addAttribute("addUrl", "/Inventario/userPage");
|
||||
|
||||
return "list";
|
||||
}
|
||||
|
||||
|
||||
//GENERICO--------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
@GetMapping("/list/{tabla}")
|
||||
public String tablaList(Model model, @PathVariable String entity) {
|
||||
String serviceName = entity.toLowerCase() + "Service";
|
||||
Object serviceBean = context.getBean(serviceName);
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/list/{entity}")
|
||||
public String entityList(Model model, @PathVariable String entity) {
|
||||
//construye el nombre del servicio de la entidad
|
||||
String serviceName = entity.toLowerCase() + "Service";
|
||||
try {
|
||||
//busca el servicio de la entidad
|
||||
Object serviceBean = context.getBean(serviceName);
|
||||
//si el Bean es una instancia de GenericEntityService
|
||||
if (serviceBean instanceof GenericEntityService<?> genericService) {
|
||||
//genericService es un Servicio de los que hay, eso trae todas las instancias, entities sería por ejemplo user,categoria,etc
|
||||
List<?> entities = genericService.findAll();
|
||||
|
||||
List<Map<String, Object>> items = entities.stream().map(e ->
|
||||
Map.of(
|
||||
"id", getId(e),
|
||||
"values", genericService.getRowValues(e)
|
||||
)
|
||||
).toList();
|
||||
|
||||
model.addAttribute("title", "Gestión de " + entity);
|
||||
model.addAttribute("headers", genericService.getHeaders());
|
||||
model.addAttribute("items", items);
|
||||
model.addAttribute("actionsUrl", Map.of(
|
||||
"edit", "",
|
||||
"delete", "" // puedes personalizar por entidad
|
||||
));
|
||||
model.addAttribute("backUrl", "/Inventario/home");
|
||||
model.addAttribute("addUrl", "/Inventario/");
|
||||
|
||||
return "list";
|
||||
} else {
|
||||
throw new IllegalArgumentException("No es un GenericEntityService válido");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
model.addAttribute("error", "No se pudo cargar la entidad: " + entity);
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
|
||||
private Object getId(Object entity) {
|
||||
try {
|
||||
Method method = entity.getClass().getMethod("getId");
|
||||
return method.invoke(entity);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
**/
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,14 @@
|
|||
package com.ieslamar.GestionInventario.entities;
|
||||
|
||||
import com.ieslamar.GestionInventario.controllers.UserController;
|
||||
import com.ieslamar.GestionInventario.services.DepartamentoService;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.springframework.orm.hibernate5.SpringSessionContext;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -28,4 +32,5 @@ public class Departamento {
|
|||
|
||||
@OneToMany(mappedBy = "departamento")
|
||||
private List<User> usuarios;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
package com.ieslamar.GestionInventario.entities;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class Entidad {
|
||||
|
||||
public abstract String getEntityName();
|
||||
public abstract List<String> getEntityAttributes();
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.ieslamar.GestionInventario.repos;
|
||||
|
||||
import com.ieslamar.GestionInventario.entities.Categoria;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface CategoriaRepository extends JpaRepository<Categoria, Integer> {
|
||||
Categoria findByNombre(String nombre);
|
||||
}
|
||||
|
|
@ -1,8 +1,11 @@
|
|||
package com.ieslamar.GestionInventario.repos;
|
||||
|
||||
import com.ieslamar.GestionInventario.entities.Departamento;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface DepartamentoRepository extends JpaRepository<Departamento, Integer> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.ieslamar.GestionInventario.repos;
|
||||
|
||||
import com.ieslamar.GestionInventario.entities.User;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface GenericEntityService<T> {
|
||||
List<T> findAll();
|
||||
List<String> getHeaders();
|
||||
List<Object> getRowValues(T entity);
|
||||
}
|
||||
|
|
@ -1,9 +1,12 @@
|
|||
package com.ieslamar.GestionInventario.repos;
|
||||
|
||||
import com.ieslamar.GestionInventario.entities.User;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import java.util.Optional;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Optional;
|
||||
@Repository
|
||||
public interface UserRepository extends JpaRepository<User, Long> {
|
||||
Optional<User> findByNombre(String username);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
package com.ieslamar.GestionInventario.services;
|
||||
|
||||
import com.ieslamar.GestionInventario.entities.Categoria;
|
||||
import com.ieslamar.GestionInventario.repos.CategoriaRepository;
|
||||
import com.ieslamar.GestionInventario.repos.GenericEntityService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CategoriaService implements GenericEntityService<Categoria> {
|
||||
private final CategoriaRepository categoriaRepository;
|
||||
|
||||
public CategoriaService(CategoriaRepository categoriaRepository) {
|
||||
this.categoriaRepository = categoriaRepository;
|
||||
}
|
||||
public List<Categoria> getAllCategorias() {
|
||||
return categoriaRepository.findAll();
|
||||
}
|
||||
public Categoria getCategoriaById(Integer id) {
|
||||
return categoriaRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
public void registerCategoria(String nombre) {
|
||||
Categoria categoria = new Categoria();
|
||||
categoria.setNombre(nombre);
|
||||
categoriaRepository.save(categoria);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Categoria> findAll() {
|
||||
return categoriaRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getHeaders() {
|
||||
return List.of("ID","Nombre");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Object> getRowValues(Categoria categoria) {
|
||||
return List.of(
|
||||
categoria.getId(),
|
||||
categoria.getNombre()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -3,12 +3,12 @@ package com.ieslamar.GestionInventario.services;
|
|||
import com.ieslamar.GestionInventario.entities.Departamento;
|
||||
import com.ieslamar.GestionInventario.entities.User;
|
||||
import com.ieslamar.GestionInventario.repos.DepartamentoRepository;
|
||||
import com.ieslamar.GestionInventario.repos.UserRepository;
|
||||
import com.ieslamar.GestionInventario.repos.GenericEntityService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class DepartamentoService {
|
||||
public class DepartamentoService implements GenericEntityService<Departamento> {
|
||||
private final DepartamentoRepository departamentoRepository;
|
||||
|
||||
public DepartamentoService(DepartamentoRepository departamentoRepository) {
|
||||
|
|
@ -26,4 +26,22 @@ public class DepartamentoService {
|
|||
departamento.setNombre(nombre);
|
||||
departamentoRepository.save(departamento);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List findAll() {
|
||||
return departamentoRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getHeaders() {
|
||||
return List.of("ID", "Nombre");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Object> getRowValues(Departamento departamento) {
|
||||
return List.of(
|
||||
departamento.getId(),
|
||||
departamento.getNombre()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,19 +3,22 @@ package com.ieslamar.GestionInventario.services;
|
|||
import com.ieslamar.GestionInventario.entities.Departamento;
|
||||
import com.ieslamar.GestionInventario.entities.Role;
|
||||
import com.ieslamar.GestionInventario.entities.User;
|
||||
import com.ieslamar.GestionInventario.repos.GenericEntityService;
|
||||
import com.ieslamar.GestionInventario.repos.UserRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class UserService {
|
||||
private final UserRepository userRepository;
|
||||
public class UserService implements GenericEntityService<User> {
|
||||
@Autowired
|
||||
public UserRepository userRepository;
|
||||
private final PasswordEncoder passwordEncoder;
|
||||
|
||||
public UserService(UserRepository userRepository, PasswordEncoder passwordEncoder) {
|
||||
this.userRepository = userRepository;
|
||||
this.passwordEncoder = passwordEncoder;
|
||||
}
|
||||
|
||||
|
|
@ -37,4 +40,32 @@ public class UserService {
|
|||
public User getUserById(Long id) {
|
||||
return userRepository.findById(id).orElse(null);
|
||||
}
|
||||
public List<User> getAll() {
|
||||
return userRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<User> findAll() {
|
||||
return userRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getHeaders() {
|
||||
return List.of("ID", "Nombre", "Rol", "Email", "Departamento");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Object> getRowValues(User user) {
|
||||
return List.of(
|
||||
user.getId(),
|
||||
user.getNombre(),
|
||||
user.getRole(),
|
||||
user.getMail(),
|
||||
user.getDepartamento() != null ? user.getDepartamento().getNombre() : " "
|
||||
);
|
||||
}
|
||||
|
||||
public void saveUser(User user) {
|
||||
userRepository.save(user);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ body {
|
|||
align-items: center;
|
||||
}
|
||||
tr{
|
||||
text-align: left;
|
||||
text-align: center;
|
||||
}
|
||||
tbody tr:hover {
|
||||
background-color: rgba(255, 255, 255, 0.3);
|
||||
|
|
|
|||
|
|
@ -12,21 +12,17 @@
|
|||
|
||||
<div class="input-group">
|
||||
<label>Usuario:</label>
|
||||
<input type="text" name="username" required>
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<label>Contraseña:</label>
|
||||
<input type="password" name="password" required>
|
||||
<input type="text" name="username" th:value="${user != null ? user.nombre : ''}" required>
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<label>Mail:</label>
|
||||
<input type="text" name="mail" required>
|
||||
<input type="text" name="mail" th:value="${user != null ? user.mail : ''}" required>
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<label>Rol:</label>
|
||||
<select name="role">
|
||||
<option value="USER">Usuario</option>
|
||||
<option value="ADMIN">Administrador</option>
|
||||
<option value="USER" th:selected="${user != null and user.role.name() == 'USER'}">Usuario</option>
|
||||
<option value="ADMIN" th:selected="${user != null and user.role.name() == 'ADMIN'}">Administrador</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="input-group">
|
||||
|
|
@ -35,7 +31,8 @@
|
|||
<option value="">-- Sin departamento --</option>
|
||||
<option th:each="departamento : ${departamentos}"
|
||||
th:value="${departamento.id}"
|
||||
th:text="${departamento.nombre}">
|
||||
th:text="${departamento.nombre}"
|
||||
th:selected="${user != null and user.departamento != null and user.departamento.id == departamento.id}">
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue