Vacaciones #79

Merged
jesus.pelaez merged 36 commits from Vacaciones into En-desarrollo 2024-11-24 01:19:42 +00:00
10 changed files with 37 additions and 38 deletions
Showing only changes of commit 2a561a925c - Show all commits

View File

@ -37,7 +37,7 @@ public class AssessmentsListView extends Main {
final HorizontalLayout hl = new HorizontalLayout(); final HorizontalLayout hl = new HorizontalLayout();
final Button addAssessment = new Button("Add Assessment"); final Button addAssessment = new Button("Add Assessment");
addAssessment.addClickListener((ComponentEventListener<ClickEvent<Button>>) buttonClickEvent -> { addAssessment.addClickListener((ComponentEventListener<ClickEvent<Button>>) buttonClickEvent -> {
this.getUI().get().navigate(AssessmentView.class, "new"); this.getUI().flatMap(ui -> ui.navigate(AssessmentView.class, "new"));
}); });
hl.add(addAssessment); hl.add(addAssessment);
@ -51,7 +51,7 @@ public class AssessmentsListView extends Main {
grid.addComponentColumn((ValueProvider<Assessment, Component>) assessment -> { grid.addComponentColumn((ValueProvider<Assessment, Component>) assessment -> {
var result = new Button("Result", event -> var result = new Button("Result", event ->
this.getUI().get().navigate(SubmissionView.class, assessment.getId().toString()) this.getUI().flatMap(ui -> ui.navigate(SubmissionView.class, assessment.getId().toString()))
); );
result.setEnabled(assessment.isCompleted()); result.setEnabled(assessment.isCompleted());
@ -95,6 +95,7 @@ public class AssessmentsListView extends Main {
return assessmentService.getAssessments().size(); return assessmentService.getAssessments().size();
} }
@SuppressWarnings("unused")
@Override @Override
public Stream<Assessment> fetch(final Query<Assessment, Object> query) { public Stream<Assessment> fetch(final Query<Assessment, Object> query) {
int limit = query.getLimit(); int limit = query.getLimit();

View File

@ -28,15 +28,13 @@ import java.util.stream.Stream;
@Route(value = "/candidates", layout = MainLayout.class) @Route(value = "/candidates", layout = MainLayout.class)
@PermitAll @PermitAll
public class CandidatesListView extends Main { public class CandidatesListView extends Main {
private final CandidateService candidateService;
public CandidatesListView(final CandidateService candidateService) { public CandidatesListView(final CandidateService candidateService) {
this.candidateService = candidateService;
final HorizontalLayout hl = new HorizontalLayout(); final HorizontalLayout hl = new HorizontalLayout();
final Button addCandidate = new Button("Add Candidate"); final Button addCandidate = new Button("Add Candidate");
addCandidate.addClickListener((ComponentEventListener<ClickEvent<Button>>) buttonClickEvent -> { addCandidate.addClickListener((ComponentEventListener<ClickEvent<Button>>) buttonClickEvent -> {
this.getUI().get().navigate(CandidateView.class, "new"); this.getUI().flatMap(ui -> ui.navigate(CandidateView.class, "new"));
}); });
hl.add(addCandidate); hl.add(addCandidate);
@ -46,7 +44,7 @@ public class CandidatesListView extends Main {
grid.addComponentColumn((ValueProvider<Candidate, Component>) candidate -> { grid.addComponentColumn((ValueProvider<Candidate, Component>) candidate -> {
final Button edit = new Button("Edit"); final Button edit = new Button("Edit");
edit.addClickListener((ComponentEventListener<ClickEvent<Button>>) buttonClickEvent -> edit.addClickListener((ComponentEventListener<ClickEvent<Button>>) buttonClickEvent ->
this.getUI().get().navigate(CandidateView.class, candidate.getId().toString())); this.getUI().flatMap(ui -> ui.navigate(CandidateView.class, candidate.getId().toString())));
return edit; return edit;
}); });
@ -61,6 +59,7 @@ public class CandidatesListView extends Main {
return candidateService.getCandidates().size(); return candidateService.getCandidates().size();
} }
@SuppressWarnings("unused")
@Override @Override
public Stream<Candidate> fetch(final Query<Candidate, Object> query) { public Stream<Candidate> fetch(final Query<Candidate, Object> query) {
int limit = query.getLimit(); int limit = query.getLimit();

View File

@ -0,0 +1,5 @@
package com.primefactorsolutions.views;
public class Constants {
public static final int PAGE_SIZE = 10;
}

View File

@ -24,6 +24,8 @@ import org.vaadin.firitin.components.grid.PagingGrid;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.util.List; import java.util.List;
import static com.primefactorsolutions.views.Constants.PAGE_SIZE;
@SpringComponent @SpringComponent
@Scope("prototype") @Scope("prototype")
@ -133,7 +135,7 @@ public class DocumentsListView extends Main {
private void configurePagination() { private void configurePagination() {
documentGrid.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM); documentGrid.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM);
documentGrid.setPageSize(5); documentGrid.setPageSize(PAGE_SIZE);
} }
private void updateDocumentGrid(final DocumentType documentType, final Employee employee) { private void updateDocumentGrid(final DocumentType documentType, final Employee employee) {

View File

@ -75,7 +75,7 @@ public class EmployeesListView extends Main {
private void setupPagingGrid() { private void setupPagingGrid() {
table.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM); table.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM);
table.setPageSize(5); table.setPageSize(Constants.PAGE_SIZE);
} }
private void refreshGrid() { private void refreshGrid() {

View File

@ -23,6 +23,8 @@ import java.time.temporal.IsoFields;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.primefactorsolutions.views.Constants.PAGE_SIZE;
@SpringComponent @SpringComponent
@PermitAll @PermitAll
@Scope("prototype") @Scope("prototype")
@ -34,7 +36,6 @@ public class HoursWorkedListView extends Main {
private final EmployeeService employeeService; private final EmployeeService employeeService;
private final TeamService teamService; private final TeamService teamService;
private final PagingGrid<HoursWorked> hoursWorkedGrid = new PagingGrid<>(); private final PagingGrid<HoursWorked> hoursWorkedGrid = new PagingGrid<>();
private List<Employee> employees = Collections.emptyList();
private ComboBox<Employee> employeeFilter; private ComboBox<Employee> employeeFilter;
private ComboBox<Team> teamFilter; private ComboBox<Team> teamFilter;
private UUID selectedEmployeeId; private UUID selectedEmployeeId;
@ -46,7 +47,6 @@ public class HoursWorkedListView extends Main {
this.hoursWorkedService = hoursWorkedService; this.hoursWorkedService = hoursWorkedService;
this.employeeService = employeeService; this.employeeService = employeeService;
this.teamService = teamService; this.teamService = teamService;
this.employees = employeeService.findAllEmployees();
initializeView(); initializeView();
refreshGridListHoursWorked(null, null); refreshGridListHoursWorked(null, null);
@ -127,7 +127,7 @@ public class HoursWorkedListView extends Main {
hoursWorkedGrid.addColumn(hw -> hw.getDate() != null ? hw.getDate().toString() : "") hoursWorkedGrid.addColumn(hw -> hw.getDate() != null ? hw.getDate().toString() : "")
.setHeader("Fecha") .setHeader("Fecha")
.setSortable(true); .setSortable(true);
hoursWorkedGrid.addColumn(hw -> hw.getWeekNumber()) hoursWorkedGrid.addColumn(HoursWorked::getWeekNumber)
.setHeader("Semana") .setHeader("Semana")
.setSortable(true); .setSortable(true);
hoursWorkedGrid.addColumn(hw -> hw.getEmployee().getFirstName() + " " + hw.getEmployee().getLastName()) hoursWorkedGrid.addColumn(hw -> hw.getEmployee().getFirstName() + " " + hw.getEmployee().getLastName())
@ -136,12 +136,12 @@ public class HoursWorkedListView extends Main {
.getName() : "Sin asignar") .getName() : "Sin asignar")
.setHeader("Equipo"); .setHeader("Equipo");
hoursWorkedGrid.addColumn(HoursWorked::getActividad).setHeader("Actividad"); hoursWorkedGrid.addColumn(HoursWorked::getActividad).setHeader("Actividad");
hoursWorkedGrid.addColumn(hw -> hw.getHours()).setHeader("Total Horas").setSortable(true); hoursWorkedGrid.addColumn(HoursWorked::getHours).setHeader("Total Horas").setSortable(true);
hoursWorkedGrid.addColumn(hw -> hw.getHoraspendientes() - calcularTotal(hw)).setHeader("Horas Pendientes") hoursWorkedGrid.addColumn(hw -> hw.getHoraspendientes() - calcularTotal(hw)).setHeader("Horas Pendientes")
.setSortable(true); .setSortable(true);
hoursWorkedGrid.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM); hoursWorkedGrid.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM);
hoursWorkedGrid.setPageSize(5); hoursWorkedGrid.setPageSize(PAGE_SIZE);
hoursWorkedGrid.asSingleSelect().addValueChangeListener(event -> { hoursWorkedGrid.asSingleSelect().addValueChangeListener(event -> {
HoursWorked selectedHoursWorked = event.getValue(); HoursWorked selectedHoursWorked = event.getValue();
if (selectedHoursWorked != null) { if (selectedHoursWorked != null) {
@ -159,7 +159,7 @@ public class HoursWorkedListView extends Main {
private double calculateTotalUtilized(final List<HoursWorked> employeeRequests) { private double calculateTotalUtilized(final List<HoursWorked> employeeRequests) {
return employeeRequests.stream() return employeeRequests.stream()
.filter(Objects::nonNull) .filter(Objects::nonNull)
.mapToDouble(hoursworked -> hoursworked.getHours()) .mapToDouble(HoursWorked::getHours)
.sum(); .sum();
} }
@ -223,7 +223,7 @@ public class HoursWorkedListView extends Main {
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);
teamFilter.setItemLabelGenerator(team -> getTeamLabel(team)); teamFilter.setItemLabelGenerator(this::getTeamLabel);
teamFilter.setValue(teams.getFirst()); teamFilter.setValue(teams.getFirst());
teamFilter.addValueChangeListener(event -> teamFilter.addValueChangeListener(event ->
refreshGridListHoursWorked( refreshGridListHoursWorked(

View File

@ -19,6 +19,8 @@ import org.vaadin.firitin.components.grid.PagingGrid;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.primefactorsolutions.views.Constants.PAGE_SIZE;
@SpringComponent @SpringComponent
@Scope("prototype") @Scope("prototype")
@PageTitle("PendingRequests") @PageTitle("PendingRequests")
@ -31,7 +33,6 @@ public class PendingRequestsListView extends Main {
private final TeamService teamService; private final TeamService teamService;
private final PagingGrid<TimeOffRequest> pendingRequestsGrid = new PagingGrid<>(); private final PagingGrid<TimeOffRequest> pendingRequestsGrid = new PagingGrid<>();
private List<Employee> employees = Collections.emptyList();
private ComboBox<Employee> employeeFilter; private ComboBox<Employee> employeeFilter;
private ComboBox<Team> teamFilter; private ComboBox<Team> teamFilter;
private ComboBox<TimeOffRequestType> categoryFilter; private ComboBox<TimeOffRequestType> categoryFilter;
@ -44,7 +45,6 @@ public class PendingRequestsListView extends Main {
this.requestService = requestService; this.requestService = requestService;
this.employeeService = employeeService; this.employeeService = employeeService;
this.teamService = teamService; this.teamService = teamService;
this.employees = employeeService.findAllEmployees();
initializeView(); initializeView();
refreshGeneralPendingRequestsGrid(null, null, null); refreshGeneralPendingRequestsGrid(null, null, null);
} }
@ -68,7 +68,7 @@ public class PendingRequestsListView extends Main {
pendingRequestsGrid.addColumn(this::getCategory).setHeader("Categoría"); pendingRequestsGrid.addColumn(this::getCategory).setHeader("Categoría");
pendingRequestsGrid.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM); pendingRequestsGrid.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM);
pendingRequestsGrid.setPageSize(5); pendingRequestsGrid.setPageSize(PAGE_SIZE);
pendingRequestsGrid.asSingleSelect().addValueChangeListener(event -> { pendingRequestsGrid.asSingleSelect().addValueChangeListener(event -> {
TimeOffRequest selectedRequest = event.getValue(); TimeOffRequest selectedRequest = event.getValue();
if (selectedRequest != null) { if (selectedRequest != null) {

View File

@ -28,16 +28,13 @@ import java.util.stream.Stream;
@Route(value = "/questions", layout = MainLayout.class) @Route(value = "/questions", layout = MainLayout.class)
@PermitAll @PermitAll
public class QuestionsListView extends Main { public class QuestionsListView extends Main {
private final QuestionService questionService;
public QuestionsListView(final QuestionService questionService) { public QuestionsListView(final QuestionService questionService) {
this.questionService = questionService;
final HorizontalLayout hl = new HorizontalLayout(); final HorizontalLayout hl = new HorizontalLayout();
final Button addQuestion = new Button("Add Question"); final Button addQuestion = new Button("Add Question");
addQuestion.addClickListener((ComponentEventListener<ClickEvent<Button>>) buttonClickEvent -> { addQuestion.addClickListener((ComponentEventListener<ClickEvent<Button>>) buttonClickEvent ->
this.getUI().get().navigate(QuestionView.class, "new"); this.getUI().flatMap(ui -> ui.navigate(QuestionView.class, "new")));
});
hl.add(addQuestion); hl.add(addQuestion);
final VGrid<Question> grid = new VGrid<>(Question.class); final VGrid<Question> grid = new VGrid<>(Question.class);
@ -45,7 +42,7 @@ public class QuestionsListView extends Main {
grid.addComponentColumn((ValueProvider<Question, Component>) question -> { grid.addComponentColumn((ValueProvider<Question, Component>) question -> {
final Button edit = new Button("Edit"); final Button edit = new Button("Edit");
edit.addClickListener((ComponentEventListener<ClickEvent<Button>>) buttonClickEvent -> edit.addClickListener((ComponentEventListener<ClickEvent<Button>>) buttonClickEvent ->
this.getUI().get().navigate(QuestionView.class, question.getId().toString())); this.getUI().flatMap(ui -> ui.navigate(QuestionView.class, question.getId().toString())));
return edit; return edit;
}); });
grid.setDataProvider(new DataProvider<>() { grid.setDataProvider(new DataProvider<>() {
@ -59,6 +56,7 @@ public class QuestionsListView extends Main {
return questionService.getQuestions().size(); return questionService.getQuestions().size();
} }
@SuppressWarnings("unused")
@Override @Override
public Stream<Question> fetch(final Query<Question, Object> query) { public Stream<Question> fetch(final Query<Question, Object> query) {
int limit = query.getLimit(); int limit = query.getLimit();

View File

@ -26,6 +26,8 @@ import java.time.Period;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.primefactorsolutions.views.Constants.PAGE_SIZE;
@SpringComponent @SpringComponent
@PermitAll @PermitAll
@Scope("prototype") @Scope("prototype")
@ -96,7 +98,7 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
requestGrid.getColumnByKey("daysToBeTake").setHeader("Días a Tomar"); requestGrid.getColumnByKey("daysToBeTake").setHeader("Días a Tomar");
requestGrid.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM); requestGrid.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM);
requestGrid.setPageSize(5); requestGrid.setPageSize(PAGE_SIZE);
requestGrid.asSingleSelect().addValueChangeListener(event -> { requestGrid.asSingleSelect().addValueChangeListener(event -> {
TimeOffRequest selectedRequest = event.getValue(); TimeOffRequest selectedRequest = event.getValue();
if (selectedRequest != null) { if (selectedRequest != null) {
@ -244,9 +246,6 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
private double calculateHolidayUtilizedDays(final int year) { private double calculateHolidayUtilizedDays(final int year) {
return requests.stream() return requests.stream()
.filter(this::verificationIsHoliday) .filter(this::verificationIsHoliday)
.filter(this::verificationIsHoliday)
.filter(req -> req.getState() == TimeOffRequestStatus.APROBADO)
.filter(req -> req.getState() == TimeOffRequestStatus.EN_USO)
.filter(req -> req.getState() == TimeOffRequestStatus.TOMADO) .filter(req -> req.getState() == TimeOffRequestStatus.TOMADO)
.filter(req -> getStartDateYear(req) == year) .filter(req -> getStartDateYear(req) == year)
.mapToDouble(TimeOffRequest::getDaysToBeTake) .mapToDouble(TimeOffRequest::getDaysToBeTake)
@ -256,8 +255,6 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
private double calculatePersonalDaysUtilized(final boolean isMale, final int year) { private double calculatePersonalDaysUtilized(final boolean isMale, final int year) {
return requests.stream() return requests.stream()
.filter(req -> !verificationIsHoliday(req)) .filter(req -> !verificationIsHoliday(req))
.filter(req -> req.getState() == TimeOffRequestStatus.APROBADO)
.filter(req -> req.getState() == TimeOffRequestStatus.EN_USO)
.filter(req -> req.getState() == TimeOffRequestStatus.TOMADO) .filter(req -> req.getState() == TimeOffRequestStatus.TOMADO)
.filter(req -> !getStandardExclusions().contains(req.getCategory())) .filter(req -> !getStandardExclusions().contains(req.getCategory()))
.filter(req -> !(isMale && getMaleSpecificExclusions().contains(req.getCategory()))) .filter(req -> !(isMale && getMaleSpecificExclusions().contains(req.getCategory())))

View File

@ -22,6 +22,8 @@ import java.time.Period;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.primefactorsolutions.views.Constants.PAGE_SIZE;
@SpringComponent @SpringComponent
@Scope("prototype") @Scope("prototype")
@PageTitle("Requests") @PageTitle("Requests")
@ -35,10 +37,8 @@ public class RequestsListView extends Main {
private final VacationService vacationService; private final VacationService vacationService;
private final PagingGrid<Employee> requestGrid = new PagingGrid<>(); private final PagingGrid<Employee> requestGrid = new PagingGrid<>();
private List<Employee> employees = Collections.emptyList();
private ComboBox<Employee> employeeFilter; private ComboBox<Employee> employeeFilter;
private ComboBox<Team> teamFilter; private ComboBox<Team> teamFilter;
private ComboBox<TimeOffRequestType> categoryFilter;
private ComboBox<Status> stateFilter; private ComboBox<Status> stateFilter;
private UUID selectedEmployeeId; private UUID selectedEmployeeId;
@ -51,7 +51,6 @@ public class RequestsListView extends Main {
this.employeeService = employeeService; this.employeeService = employeeService;
this.teamService = teamService; this.teamService = teamService;
this.vacationService = vacationService; this.vacationService = vacationService;
this.employees = employeeService.findAllEmployees();
initializeView(); initializeView();
refreshGeneralRequestGrid(null, null, null); refreshGeneralRequestGrid(null, null, null);
} }
@ -77,7 +76,7 @@ public class RequestsListView extends Main {
requestGrid.addColumn(this::getGeneralTotal).setHeader("Total general"); requestGrid.addColumn(this::getGeneralTotal).setHeader("Total general");
requestGrid.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM); requestGrid.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM);
requestGrid.setPageSize(5); requestGrid.setPageSize(PAGE_SIZE);
requestGrid.asSingleSelect().addValueChangeListener(event -> { requestGrid.asSingleSelect().addValueChangeListener(event -> {
Employee selectedRequest = event.getValue(); Employee selectedRequest = event.getValue();
if (selectedRequest != null) { if (selectedRequest != null) {
@ -328,10 +327,8 @@ public class RequestsListView extends Main {
&& !employeeRequestCategories.contains(vacation.getCategory())) { && !employeeRequestCategories.contains(vacation.getCategory())) {
return false; return false;
} }
if (!isFemale(employee) && genderSpecificExclusions.contains(vacation.getCategory())) {
return false; return isFemale(employee) || !genderSpecificExclusions.contains(vacation.getCategory());
}
return true;
} }
private boolean isFemale(final Employee employee) { private boolean isFemale(final Employee employee) {