WIP: Rama-Melina #4 y #5 #13

Closed
melina.gutierrez wants to merge 3 commits from Rama-Melina into main
Showing only changes of commit 3825d79479 - Show all commits

View File

@ -53,14 +53,12 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
private H3 fs = null; private H3 fs = null;
private H3 ss = 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) { public EmployeeView(final EmployeeService employeeService) {
super(Employee.class); super(Employee.class);
this.employeeService = employeeService; this.employeeService = employeeService;
configureButtons();
mt = new H2("Información General del Empleado"); mt = new H2("Información General del Empleado");
fs = new H3("Información Personal"); fs = new H3("Información Personal");
@ -139,6 +137,8 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
setSavedHandler((SavedHandler<Employee>) employee -> { setSavedHandler((SavedHandler<Employee>) employee -> {
final Employee saved = employeeService.createOrUpdate(employee); final Employee saved = employeeService.createOrUpdate(employee);
Review

parece que los campos de emergency contact no estan definidos en la clase model Employee. Se deberian crear esos campos para que puedan ser guardados en al DB.

podrias ir viendo de agregar campo por campo y ver si se guardan en la db cuando se hace el save.

parece que los campos de emergency contact no estan definidos en la clase model Employee. Se deberian crear esos campos para que puedan ser guardados en al DB. podrias ir viendo de agregar campo por campo y ver si se guardan en la db cuando se hace el save.
Notification.show("Empleado guardado exitosamente.");
getUI().ifPresent(ui -> ui.navigate(EmployeesListView.class));
setEntityWithEnabledSave(saved); setEntityWithEnabledSave(saved);
}); });
@ -147,23 +147,6 @@ public class EmployeeView extends BeanValidationForm<Employee> 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() { private VerticalLayout createSidebar() {
VerticalLayout sidebar = new VerticalLayout(); VerticalLayout sidebar = new VerticalLayout();
sidebar.setWidth("250px"); sidebar.setWidth("250px");
@ -187,10 +170,8 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
if (StringUtils.isNotBlank(s) && !"new".equals(s)) { if (StringUtils.isNotBlank(s) && !"new".equals(s)) {
var employee = employeeService.getEmployee(UUID.fromString(s)); var employee = employeeService.getEmployee(UUID.fromString(s));
setEntityWithEnabledSave(employee); setEntityWithEnabledSave(employee);
editButton.setEnabled(true);
} else { } else {
setEntityWithEnabledSave(new Employee()); setEntityWithEnabledSave(new Employee());
editButton.setEnabled(false);
} }
} }
@ -211,11 +192,8 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
emergencyCName, emergencyCName,
emergencyCAddress, emergencyCAddress,
emergencyCPhone, emergencyCPhone,
emergencyCEmail, emergencyCEmail
saveButton,
editButton
); );
} }
} }