diff --git a/src/main/java/com/primefactorsolutions/views/EmployeeView.java b/src/main/java/com/primefactorsolutions/views/EmployeeView.java index 9e49fe4..054ae7d 100644 --- a/src/main/java/com/primefactorsolutions/views/EmployeeView.java +++ b/src/main/java/com/primefactorsolutions/views/EmployeeView.java @@ -38,10 +38,10 @@ public class EmployeeView extends BeanValidationForm implements HasUrl private final TextField firstName; private final TextField lastName; - private final ComboBox status; + private final ComboBox status; private final VDatePicker birthday; private final TextField birthCity; - private final ComboBox maritalStatus; + private final ComboBox maritalStatus; private final TextField residenceAddress; private final TextField phoneNumber; private final EmailField personalEmail; @@ -79,9 +79,9 @@ public class EmployeeView extends BeanValidationForm 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 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 implements HasUrl setSavedHandler((SavedHandler) 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 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()); }