Vacaciones #64

Merged
jesus.pelaez merged 11 commits from Vacaciones into En-desarrollo 2024-11-04 04:25:22 +00:00
Showing only changes of commit ca630ef5c6 - Show all commits

View File

@ -70,10 +70,10 @@ public class RequestsListView extends Main {
}
private void setupRequestGrid() {
requestGrid.addColumn(this::getEmployeeFullName).setHeader("Employee");
requestGrid.addColumn(this::getTeamName).setHeader("Team");
requestGrid.addColumn(this::getEmployeeStatus).setHeader("Employee State");
requestGrid.addColumn(this::getGeneralTotal).setHeader("General Total");
requestGrid.addColumn(this::getEmployeeFullName).setHeader("Empleado");
requestGrid.addColumn(this::getTeamName).setHeader("Equipo");
requestGrid.addColumn(this::getEmployeeStatus).setHeader("Estado del empleado");
requestGrid.addColumn(this::getGeneralTotal).setHeader("Total general");
requestGrid.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM);
requestGrid.setPageSize(5);
@ -86,14 +86,14 @@ public class RequestsListView extends Main {
}
private HorizontalLayout createActionButtons() {
Button viewButton = new Button("View", event -> {
Button viewButton = new Button("Ver", event -> {
if (selectedEmployeeId != null) {
navigateToTimeOffRequestView(selectedEmployeeId);
} else {
Notification.show("Please select a request to view.", 3000, Notification.Position.MIDDLE);
Notification.show("Seleccione una solicitud para verla.", 3000, Notification.Position.MIDDLE);
}
});
Button closeButton = new Button("Close", event -> navigateToMainView());
Button closeButton = new Button("Salir", event -> navigateToMainView());
return new HorizontalLayout(viewButton, closeButton);
}
@ -114,24 +114,24 @@ public class RequestsListView extends Main {
final Status state) {
List<Employee> filteredEmployees = employeeService.findAllEmployees();
if (employee != null && !"ALL".equals(employee.getFirstName())) {
if (employee != null && !"TODOS".equals(employee.getFirstName())) {
filteredEmployees = filteredEmployees.stream()
.filter(emp -> emp.getId().equals(employee.getId()))
.collect(Collectors.toList());
}
if (team != null && !"ALL".equals(team.getName())) {
if (team != null && !"TODOS".equals(team.getName())) {
filteredEmployees = filteredEmployees.stream()
.filter(emp -> emp.getTeam() != null && emp.getTeam().getId().equals(team.getId()))
.collect(Collectors.toList());
}
if (state != null && state != Status.ALL) {
if (state != null && state != Status.TODOS) {
filteredEmployees = filteredEmployees.stream()
.filter(emp -> {
Optional<TimeOffRequest> request = requestService
.findByEmployeeAndState(emp.getId(), TimeOffRequestStatus.TAKEN);
return state == Status.IDLE ? request.isPresent() : request.isEmpty();
.findByEmployeeAndState(emp.getId(), TimeOffRequestStatus.IN_USE);
return state == Status.EN_DESCANSO ? request.isPresent() : request.isEmpty();
})
.collect(Collectors.toList());
}
@ -141,22 +141,22 @@ public class RequestsListView extends Main {
}
private String getEmployeeFullName(final Employee employee) {
return "ALL".equals(employee.getFirstName()) ? "ALL" : employee.getFirstName() + " " + employee.getLastName();
return "TODOS".equals(employee.getFirstName()) ? "TODOS" : employee.getFirstName() + " " + employee.getLastName();
}
private String getTeamName(final Employee employee) {
Team team = employee.getTeam();
return team != null ? team.getName() : "Unassigned";
return team != null ? team.getName() : "Sin asignar";
}
private String getTeamLabel(final Team team) {
return "ALL".equals(team.getName()) ? "ALL" : team.getName();
return "TODOS".equals(team.getName()) ? "TODOS" : team.getName();
}
private String getEmployeeStatus(final Employee employee) {
Optional<TimeOffRequest> activeRequest = requestService
.findByEmployeeAndState(employee.getId(), TimeOffRequestStatus.IN_USE);
return activeRequest.isPresent() ? "IDLE" : "ACTIVE";
return activeRequest.isPresent() ? "EN_DESCANSO" : "ACTIVO";
}
private String getGeneralTotal(final Employee employee) {
@ -249,7 +249,7 @@ public class RequestsListView extends Main {
}
private ComboBox<Employee> createEmployeeFilter() {
employeeFilter = new ComboBox<>("Employee");
employeeFilter = new ComboBox<>("Empleado");
List<Employee> employees = new ArrayList<>(employeeService.findAllEmployees());
employees.addFirst(createAllEmployeesOption());
employeeFilter.setItems(employees);
@ -266,7 +266,7 @@ public class RequestsListView extends Main {
}
private ComboBox<Team> createTeamFilter() {
teamFilter = new ComboBox<>("Team");
teamFilter = new ComboBox<>("Equipo");
List<Team> teams = new ArrayList<>(teamService.findAllTeams());
teams.addFirst(createAllTeamsOption());
teamFilter.setItems(teams);
@ -283,7 +283,7 @@ public class RequestsListView extends Main {
}
private ComboBox<Status> createStateFilter() {
stateFilter = new ComboBox<>("Employee State");
stateFilter = new ComboBox<>("Estado del empleado");
stateFilter.setItems(Status.values());
stateFilter.setValue(Status.values()[0]);
stateFilter.addValueChangeListener(event ->
@ -297,20 +297,20 @@ public class RequestsListView extends Main {
}
private enum Status {
ALL,
IDLE,
ACTIVE
TODOS,
EN_DESCANSO,
ACTIVO
}
private Employee createAllEmployeesOption() {
Employee allEmployeesOption = new Employee();
allEmployeesOption.setFirstName("ALL");
allEmployeesOption.setFirstName("TODOS");
return allEmployeesOption;
}
private Team createAllTeamsOption() {
Team allTeamsOption = new Team();
allTeamsOption.setName("ALL");
allTeamsOption.setName("TODOS");
return allTeamsOption;
}