This commit is contained in:
parent
0695223c31
commit
2a561a925c
@ -37,7 +37,7 @@ public class AssessmentsListView extends Main {
|
||||
final HorizontalLayout hl = new HorizontalLayout();
|
||||
final Button addAssessment = new Button("Add Assessment");
|
||||
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);
|
||||
|
||||
@ -51,7 +51,7 @@ public class AssessmentsListView extends Main {
|
||||
|
||||
grid.addComponentColumn((ValueProvider<Assessment, Component>) assessment -> {
|
||||
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());
|
||||
|
||||
@ -95,6 +95,7 @@ public class AssessmentsListView extends Main {
|
||||
return assessmentService.getAssessments().size();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Override
|
||||
public Stream<Assessment> fetch(final Query<Assessment, Object> query) {
|
||||
int limit = query.getLimit();
|
||||
|
@ -28,15 +28,13 @@ import java.util.stream.Stream;
|
||||
@Route(value = "/candidates", layout = MainLayout.class)
|
||||
@PermitAll
|
||||
public class CandidatesListView extends Main {
|
||||
private final CandidateService candidateService;
|
||||
|
||||
public CandidatesListView(final CandidateService candidateService) {
|
||||
this.candidateService = candidateService;
|
||||
|
||||
final HorizontalLayout hl = new HorizontalLayout();
|
||||
final Button addCandidate = new Button("Add Candidate");
|
||||
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);
|
||||
|
||||
@ -46,7 +44,7 @@ public class CandidatesListView extends Main {
|
||||
grid.addComponentColumn((ValueProvider<Candidate, Component>) candidate -> {
|
||||
final Button edit = new Button("Edit");
|
||||
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;
|
||||
});
|
||||
|
||||
@ -61,6 +59,7 @@ public class CandidatesListView extends Main {
|
||||
return candidateService.getCandidates().size();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Override
|
||||
public Stream<Candidate> fetch(final Query<Candidate, Object> query) {
|
||||
int limit = query.getLimit();
|
||||
|
@ -0,0 +1,5 @@
|
||||
package com.primefactorsolutions.views;
|
||||
|
||||
public class Constants {
|
||||
public static final int PAGE_SIZE = 10;
|
||||
}
|
@ -24,6 +24,8 @@ import org.vaadin.firitin.components.grid.PagingGrid;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.util.List;
|
||||
|
||||
import static com.primefactorsolutions.views.Constants.PAGE_SIZE;
|
||||
|
||||
|
||||
@SpringComponent
|
||||
@Scope("prototype")
|
||||
@ -133,7 +135,7 @@ public class DocumentsListView extends Main {
|
||||
|
||||
private void configurePagination() {
|
||||
documentGrid.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM);
|
||||
documentGrid.setPageSize(5);
|
||||
documentGrid.setPageSize(PAGE_SIZE);
|
||||
}
|
||||
|
||||
private void updateDocumentGrid(final DocumentType documentType, final Employee employee) {
|
||||
|
@ -75,7 +75,7 @@ public class EmployeesListView extends Main {
|
||||
|
||||
private void setupPagingGrid() {
|
||||
table.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM);
|
||||
table.setPageSize(5);
|
||||
table.setPageSize(Constants.PAGE_SIZE);
|
||||
}
|
||||
|
||||
private void refreshGrid() {
|
||||
|
@ -23,6 +23,8 @@ import java.time.temporal.IsoFields;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.primefactorsolutions.views.Constants.PAGE_SIZE;
|
||||
|
||||
@SpringComponent
|
||||
@PermitAll
|
||||
@Scope("prototype")
|
||||
@ -34,7 +36,6 @@ public class HoursWorkedListView extends Main {
|
||||
private final EmployeeService employeeService;
|
||||
private final TeamService teamService;
|
||||
private final PagingGrid<HoursWorked> hoursWorkedGrid = new PagingGrid<>();
|
||||
private List<Employee> employees = Collections.emptyList();
|
||||
private ComboBox<Employee> employeeFilter;
|
||||
private ComboBox<Team> teamFilter;
|
||||
private UUID selectedEmployeeId;
|
||||
@ -46,7 +47,6 @@ public class HoursWorkedListView extends Main {
|
||||
this.hoursWorkedService = hoursWorkedService;
|
||||
this.employeeService = employeeService;
|
||||
this.teamService = teamService;
|
||||
this.employees = employeeService.findAllEmployees();
|
||||
|
||||
initializeView();
|
||||
refreshGridListHoursWorked(null, null);
|
||||
@ -127,7 +127,7 @@ public class HoursWorkedListView extends Main {
|
||||
hoursWorkedGrid.addColumn(hw -> hw.getDate() != null ? hw.getDate().toString() : "")
|
||||
.setHeader("Fecha")
|
||||
.setSortable(true);
|
||||
hoursWorkedGrid.addColumn(hw -> hw.getWeekNumber())
|
||||
hoursWorkedGrid.addColumn(HoursWorked::getWeekNumber)
|
||||
.setHeader("Semana")
|
||||
.setSortable(true);
|
||||
hoursWorkedGrid.addColumn(hw -> hw.getEmployee().getFirstName() + " " + hw.getEmployee().getLastName())
|
||||
@ -136,12 +136,12 @@ public class HoursWorkedListView extends Main {
|
||||
.getName() : "Sin asignar")
|
||||
.setHeader("Equipo");
|
||||
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")
|
||||
.setSortable(true);
|
||||
|
||||
hoursWorkedGrid.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM);
|
||||
hoursWorkedGrid.setPageSize(5);
|
||||
hoursWorkedGrid.setPageSize(PAGE_SIZE);
|
||||
hoursWorkedGrid.asSingleSelect().addValueChangeListener(event -> {
|
||||
HoursWorked selectedHoursWorked = event.getValue();
|
||||
if (selectedHoursWorked != null) {
|
||||
@ -159,7 +159,7 @@ public class HoursWorkedListView extends Main {
|
||||
private double calculateTotalUtilized(final List<HoursWorked> employeeRequests) {
|
||||
return employeeRequests.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.mapToDouble(hoursworked -> hoursworked.getHours())
|
||||
.mapToDouble(HoursWorked::getHours)
|
||||
.sum();
|
||||
}
|
||||
|
||||
@ -223,7 +223,7 @@ public class HoursWorkedListView extends Main {
|
||||
List<Team> teams = new ArrayList<>(teamService.findAllTeams());
|
||||
teams.addFirst(createAllTeamsOption());
|
||||
teamFilter.setItems(teams);
|
||||
teamFilter.setItemLabelGenerator(team -> getTeamLabel(team));
|
||||
teamFilter.setItemLabelGenerator(this::getTeamLabel);
|
||||
teamFilter.setValue(teams.getFirst());
|
||||
teamFilter.addValueChangeListener(event ->
|
||||
refreshGridListHoursWorked(
|
||||
|
@ -19,6 +19,8 @@ import org.vaadin.firitin.components.grid.PagingGrid;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.primefactorsolutions.views.Constants.PAGE_SIZE;
|
||||
|
||||
@SpringComponent
|
||||
@Scope("prototype")
|
||||
@PageTitle("PendingRequests")
|
||||
@ -31,7 +33,6 @@ public class PendingRequestsListView extends Main {
|
||||
private final TeamService teamService;
|
||||
private final PagingGrid<TimeOffRequest> pendingRequestsGrid = new PagingGrid<>();
|
||||
|
||||
private List<Employee> employees = Collections.emptyList();
|
||||
private ComboBox<Employee> employeeFilter;
|
||||
private ComboBox<Team> teamFilter;
|
||||
private ComboBox<TimeOffRequestType> categoryFilter;
|
||||
@ -44,7 +45,6 @@ public class PendingRequestsListView extends Main {
|
||||
this.requestService = requestService;
|
||||
this.employeeService = employeeService;
|
||||
this.teamService = teamService;
|
||||
this.employees = employeeService.findAllEmployees();
|
||||
initializeView();
|
||||
refreshGeneralPendingRequestsGrid(null, null, null);
|
||||
}
|
||||
@ -68,7 +68,7 @@ public class PendingRequestsListView extends Main {
|
||||
pendingRequestsGrid.addColumn(this::getCategory).setHeader("Categoría");
|
||||
|
||||
pendingRequestsGrid.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM);
|
||||
pendingRequestsGrid.setPageSize(5);
|
||||
pendingRequestsGrid.setPageSize(PAGE_SIZE);
|
||||
pendingRequestsGrid.asSingleSelect().addValueChangeListener(event -> {
|
||||
TimeOffRequest selectedRequest = event.getValue();
|
||||
if (selectedRequest != null) {
|
||||
|
@ -28,16 +28,13 @@ import java.util.stream.Stream;
|
||||
@Route(value = "/questions", layout = MainLayout.class)
|
||||
@PermitAll
|
||||
public class QuestionsListView extends Main {
|
||||
private final QuestionService questionService;
|
||||
|
||||
public QuestionsListView(final QuestionService questionService) {
|
||||
this.questionService = questionService;
|
||||
|
||||
final HorizontalLayout hl = new HorizontalLayout();
|
||||
final Button addQuestion = new Button("Add Question");
|
||||
addQuestion.addClickListener((ComponentEventListener<ClickEvent<Button>>) buttonClickEvent -> {
|
||||
this.getUI().get().navigate(QuestionView.class, "new");
|
||||
});
|
||||
addQuestion.addClickListener((ComponentEventListener<ClickEvent<Button>>) buttonClickEvent ->
|
||||
this.getUI().flatMap(ui -> ui.navigate(QuestionView.class, "new")));
|
||||
hl.add(addQuestion);
|
||||
|
||||
final VGrid<Question> grid = new VGrid<>(Question.class);
|
||||
@ -45,7 +42,7 @@ public class QuestionsListView extends Main {
|
||||
grid.addComponentColumn((ValueProvider<Question, Component>) question -> {
|
||||
final Button edit = new Button("Edit");
|
||||
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;
|
||||
});
|
||||
grid.setDataProvider(new DataProvider<>() {
|
||||
@ -59,6 +56,7 @@ public class QuestionsListView extends Main {
|
||||
return questionService.getQuestions().size();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Override
|
||||
public Stream<Question> fetch(final Query<Question, Object> query) {
|
||||
int limit = query.getLimit();
|
||||
|
@ -26,6 +26,8 @@ import java.time.Period;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.primefactorsolutions.views.Constants.PAGE_SIZE;
|
||||
|
||||
@SpringComponent
|
||||
@PermitAll
|
||||
@Scope("prototype")
|
||||
@ -96,7 +98,7 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
|
||||
requestGrid.getColumnByKey("daysToBeTake").setHeader("Días a Tomar");
|
||||
|
||||
requestGrid.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM);
|
||||
requestGrid.setPageSize(5);
|
||||
requestGrid.setPageSize(PAGE_SIZE);
|
||||
requestGrid.asSingleSelect().addValueChangeListener(event -> {
|
||||
TimeOffRequest selectedRequest = event.getValue();
|
||||
if (selectedRequest != null) {
|
||||
@ -244,9 +246,6 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
|
||||
private double calculateHolidayUtilizedDays(final int year) {
|
||||
return requests.stream()
|
||||
.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 -> getStartDateYear(req) == year)
|
||||
.mapToDouble(TimeOffRequest::getDaysToBeTake)
|
||||
@ -256,8 +255,6 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
|
||||
private double calculatePersonalDaysUtilized(final boolean isMale, final int year) {
|
||||
return requests.stream()
|
||||
.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 -> !getStandardExclusions().contains(req.getCategory()))
|
||||
.filter(req -> !(isMale && getMaleSpecificExclusions().contains(req.getCategory())))
|
||||
|
@ -22,6 +22,8 @@ import java.time.Period;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.primefactorsolutions.views.Constants.PAGE_SIZE;
|
||||
|
||||
@SpringComponent
|
||||
@Scope("prototype")
|
||||
@PageTitle("Requests")
|
||||
@ -35,10 +37,8 @@ public class RequestsListView extends Main {
|
||||
private final VacationService vacationService;
|
||||
private final PagingGrid<Employee> requestGrid = new PagingGrid<>();
|
||||
|
||||
private List<Employee> employees = Collections.emptyList();
|
||||
private ComboBox<Employee> employeeFilter;
|
||||
private ComboBox<Team> teamFilter;
|
||||
private ComboBox<TimeOffRequestType> categoryFilter;
|
||||
private ComboBox<Status> stateFilter;
|
||||
private UUID selectedEmployeeId;
|
||||
|
||||
@ -51,7 +51,6 @@ public class RequestsListView extends Main {
|
||||
this.employeeService = employeeService;
|
||||
this.teamService = teamService;
|
||||
this.vacationService = vacationService;
|
||||
this.employees = employeeService.findAllEmployees();
|
||||
initializeView();
|
||||
refreshGeneralRequestGrid(null, null, null);
|
||||
}
|
||||
@ -77,7 +76,7 @@ public class RequestsListView extends Main {
|
||||
requestGrid.addColumn(this::getGeneralTotal).setHeader("Total general");
|
||||
|
||||
requestGrid.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM);
|
||||
requestGrid.setPageSize(5);
|
||||
requestGrid.setPageSize(PAGE_SIZE);
|
||||
requestGrid.asSingleSelect().addValueChangeListener(event -> {
|
||||
Employee selectedRequest = event.getValue();
|
||||
if (selectedRequest != null) {
|
||||
@ -328,10 +327,8 @@ public class RequestsListView extends Main {
|
||||
&& !employeeRequestCategories.contains(vacation.getCategory())) {
|
||||
return false;
|
||||
}
|
||||
if (!isFemale(employee) && genderSpecificExclusions.contains(vacation.getCategory())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
return isFemale(employee) || !genderSpecificExclusions.contains(vacation.getCategory());
|
||||
}
|
||||
|
||||
private boolean isFemale(final Employee employee) {
|
||||
|
Loading…
Reference in New Issue
Block a user