diff --git a/src/main/java/com/primefactorsolutions/views/EmployeeView.java b/src/main/java/com/primefactorsolutions/views/EmployeeView.java index 5bb14d8..6dab5d1 100644 --- a/src/main/java/com/primefactorsolutions/views/EmployeeView.java +++ b/src/main/java/com/primefactorsolutions/views/EmployeeView.java @@ -53,14 +53,12 @@ public class EmployeeView extends BeanValidationForm implements HasUrl private H3 fs = null; private H3 ss = null; - private final Button saveButton = new Button("Save"); - private final Button editButton = new Button("Edit"); + //private final Button editButton = new Button("Edit"); public EmployeeView(final EmployeeService employeeService) { super(Employee.class); this.employeeService = employeeService; - configureButtons(); mt = new H2("Información General del Empleado"); fs = new H3("Información Personal"); @@ -139,6 +137,8 @@ public class EmployeeView extends BeanValidationForm implements HasUrl setSavedHandler((SavedHandler) employee -> { final Employee saved = employeeService.createOrUpdate(employee); + Notification.show("Empleado guardado exitosamente."); + getUI().ifPresent(ui -> ui.navigate(EmployeesListView.class)); setEntityWithEnabledSave(saved); }); @@ -147,23 +147,6 @@ public class EmployeeView extends BeanValidationForm implements HasUrl } - private void configureButtons() { - editButton.setEnabled(false); // Desactivar el botón de editar inicialmente - - saveButton.addClickListener(e -> { - if (isValid()) { - saveButton.setEnabled(false); - } else { - Notification.show("Por favor, complete todos los campos obligatorios."); - } - }); - - editButton.addClickListener(e -> { - Notification.show("Modo de edición activado."); - setHasChanges(false); - }); - } - private VerticalLayout createSidebar() { VerticalLayout sidebar = new VerticalLayout(); sidebar.setWidth("250px"); @@ -187,10 +170,8 @@ public class EmployeeView extends BeanValidationForm implements HasUrl if (StringUtils.isNotBlank(s) && !"new".equals(s)) { var employee = employeeService.getEmployee(UUID.fromString(s)); setEntityWithEnabledSave(employee); - editButton.setEnabled(true); } else { setEntityWithEnabledSave(new Employee()); - editButton.setEnabled(false); } } @@ -211,11 +192,8 @@ public class EmployeeView extends BeanValidationForm implements HasUrl emergencyCName, emergencyCAddress, emergencyCPhone, - emergencyCEmail, - saveButton, - editButton + emergencyCEmail ); } -} - +} \ No newline at end of file