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