#5 Perfil de Empleado - Añadir la funcion de guardado de Información Personal
This commit is contained in:
parent
29ebc2e4e6
commit
3825d79479
@ -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);
|
||||||
|
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
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user