#4-Registrar-empleado #15
@ -38,10 +38,10 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
||||
|
||||
private final TextField firstName;
|
||||
private final TextField lastName;
|
||||
private final ComboBox<String> status;
|
||||
private final ComboBox<Employee.Status> status;
|
||||
private final VDatePicker birthday;
|
||||
private final TextField birthCity;
|
||||
private final ComboBox<String> maritalStatus;
|
||||
private final ComboBox<Employee.MaritalStatus> maritalStatus;
|
||||
private final TextField residenceAddress;
|
||||
private final TextField phoneNumber;
|
||||
private final EmailField personalEmail;
|
||||
@ -79,9 +79,9 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
||||
lastName.setRequired(true);
|
||||
|
||||
status = new ComboBox<>("Estado");
|
||||
status.setItems(List.of("ACTIVE", "INACTIVE"));
|
||||
lastName.setWidthFull();
|
||||
lastName.setMaxLength(30);
|
||||
status.setItems(Employee.Status.values());
|
||||
status.setItemLabelGenerator(Employee.Status::name);
|
||||
status.setWidthFull();
|
||||
status.setRequired(true);
|
||||
|
||||
birthday = new VDatePicker("Fecha de Nacimiento");
|
||||
@ -92,7 +92,8 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
||||
birthCity.setMaxLength(20);
|
||||
|
||||
maritalStatus = new ComboBox<>("Estado Civil");
|
||||
maritalStatus.setItems(List.of("Soltero", "Casado", "Viudo", "Divorciado"));
|
||||
maritalStatus.setItems(Employee.MaritalStatus.values());
|
||||
maritalStatus.setItemLabelGenerator(Employee.MaritalStatus::name);
|
||||
maritalStatus.setWidthFull();
|
||||
|
||||
residenceAddress = new TextField("Dirección de Residencia");
|
||||
@ -144,6 +145,7 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
||||
|
||||
setSavedHandler((SavedHandler<Employee>) employee -> {
|
||||
if (validateForm()) {
|
||||
employee.setStatus(status.getValue()); // Actualiza el estado del empleado antes de guardar
|
||||
final Employee saved = employeeService.createOrUpdate(employee);
|
||||
Notification.show("Employee saved successfully.");
|
||||
getUI().ifPresent(ui -> ui.navigate(EmployeesListView.class));
|
||||
@ -184,6 +186,7 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
||||
if (StringUtils.isNotBlank(s) && !"new".equals(s)) {
|
||||
var employee = employeeService.getEmployee(UUID.fromString(s));
|
||||
setEntityWithEnabledSave(employee);
|
||||
status.setValue(employee.getStatus()); // Asegúrate de que el ComboBox esté sincronizado con el estado del empleado
|
||||
} else {
|
||||
setEntityWithEnabledSave(new Employee());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user