From 3825d79479ae192bcbcb89a24ac43048c855545b Mon Sep 17 00:00:00 2001 From: Melina Gutierrez Date: Tue, 27 Aug 2024 20:39:40 -0400 Subject: [PATCH] =?UTF-8?q?#5=20Perfil=20de=20Empleado=20-=20A=C3=B1adir?= =?UTF-8?q?=20la=20funcion=20de=20guardado=20de=20Informaci=C3=B3n=20Perso?= =?UTF-8?q?nal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/EmployeeView.java | 32 +++---------------- 1 file changed, 5 insertions(+), 27 deletions(-) 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