This commit is contained in:
parent
fc77443317
commit
b57f5a7f2c
Binary file not shown.
@ -1,5 +1,6 @@
|
||||
package com.primefactorsolutions.views;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.primefactorsolutions.model.Document;
|
||||
import com.primefactorsolutions.model.DocumentType;
|
||||
import com.primefactorsolutions.model.Employee;
|
||||
@ -132,8 +133,20 @@ public class DocumentsListView extends BaseView {
|
||||
employeeFilter = new ComboBox<>("Empleado");
|
||||
employeeFilter.setPlaceholder("Seleccionar ...");
|
||||
employeeFilter.setClearButtonVisible(true);
|
||||
List<Employee> employees = employeeService.findAllEmployees();
|
||||
employeeFilter.setItems(employees);
|
||||
|
||||
final List<Employee> employees;
|
||||
|
||||
if (isRoleAdmin()) {
|
||||
employees = employeeService.findAllEmployees();
|
||||
employeeFilter.setItems(employees);
|
||||
} else {
|
||||
Employee employee = employeeService.getEmployee(getEmployeeId().get());
|
||||
employees = Lists.newArrayList(employee);
|
||||
employeeFilter.setItems(employees);
|
||||
employeeFilter.setValue(employees.getFirst());
|
||||
employeeFilter.setReadOnly(true);
|
||||
}
|
||||
|
||||
employeeFilter.setItemLabelGenerator(this::getEmployeeLabel);
|
||||
employeeFilter.addValueChangeListener(event -> {
|
||||
updateDocumentGrid(documentTypeFilter.getValue(), event.getValue());
|
||||
|
@ -32,11 +32,11 @@ import com.vaadin.flow.data.value.ValueChangeMode;
|
||||
import com.vaadin.flow.router.*;
|
||||
import com.vaadin.flow.server.StreamResource;
|
||||
import com.vaadin.flow.spring.annotation.SpringComponent;
|
||||
import com.vaadin.flow.spring.security.AuthenticationContext;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.vaadin.firitin.components.datepicker.VDatePicker;
|
||||
import org.vaadin.firitin.form.BeanValidationForm;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@ -54,7 +54,7 @@ import java.util.UUID;
|
||||
@PageTitle("Employee")
|
||||
@Route(value = "/employees/:employeeId?/:action?", layout = MainLayout.class)
|
||||
@Slf4j
|
||||
public class EmployeeView extends BeanValidationForm<Employee> implements HasUrlParameter<String> {
|
||||
public class EmployeeView extends BaseEntityForm<Employee> implements HasUrlParameter<String> {
|
||||
private final EmployeeService employeeService;
|
||||
private final ReportService reportService;
|
||||
private final TimeOffRequestService requestService;
|
||||
@ -123,13 +123,9 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
||||
private final TextField sss = createTextField("Matricula de Asegurado (SSS)", 30, false);
|
||||
private final TextField beneficiarie1 = createTextField("Derechohabiente 1", 30, false);
|
||||
private final TextField beneficiarie2 = createTextField("Derechohabiente 2", 30, false);
|
||||
private static final String SAVE_BUTTON_TEXT = "Save";
|
||||
private static final String EDIT_BUTTON_TEXT = "Edit";
|
||||
private static final String NOTIFICATION_SAVE_SUCCESS = "Employee saved successfully.";
|
||||
private static final String NOTIFICATION_VALIDATE_ERROR = "Please complete the required fields correctly.";
|
||||
private static final String PHONE_NUMBER_ERROR_MESSAGE = "El teléfono debe contener solo números.";
|
||||
private final Button saveButton = new Button(SAVE_BUTTON_TEXT, e -> saveEmployee());
|
||||
private final Button editButton = new Button(EDIT_BUTTON_TEXT, e -> enableEditMode());
|
||||
private final Button reportButton = new Button("Generar Ficha de Contratación");
|
||||
private final Dialog dialog = new Dialog();
|
||||
private final PdfViewer pdfViewer = new PdfViewer();
|
||||
@ -149,16 +145,16 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
||||
private final H3 datBanc = new H3("Datos Bancarios");
|
||||
private final H3 datGest = new H3("Datos Gestora Pública y Seguro Social");
|
||||
|
||||
public EmployeeView(final EmployeeService employeeService,
|
||||
public EmployeeView(final AuthenticationContext authenticationContext,
|
||||
final EmployeeService employeeService,
|
||||
final ReportService reportService,
|
||||
final TeamService teamService,
|
||||
final TimeOffRequestService requestService) {
|
||||
super(Employee.class);
|
||||
super(authenticationContext, Employee.class);
|
||||
this.employeeService = employeeService;
|
||||
this.reportService = reportService;
|
||||
this.requestService = requestService;
|
||||
this.teamService = teamService;
|
||||
saveButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
||||
excelReportButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
||||
configureComponents();
|
||||
addClassName("main-layout");
|
||||
@ -167,6 +163,7 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
||||
ui.navigate(EmployeeReportView.class, getEntity().getId().toString())
|
||||
)
|
||||
);
|
||||
setSavedHandler(e -> saveEmployee(e));
|
||||
}
|
||||
|
||||
private void makeUpperCase(final TextField textField) {
|
||||
@ -189,8 +186,6 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
||||
lastName.addValueChangeListener(e -> validateNameField(lastName, e.getValue()));
|
||||
createTeamComboBox();
|
||||
configureUpload();
|
||||
saveButton.setVisible(true);
|
||||
editButton.setVisible(true);
|
||||
reportButton.setVisible(true);
|
||||
birthday.addValueChangeListener(event -> calculateAge());
|
||||
birthday.setMin(LocalDate.now().minusYears(100));
|
||||
@ -456,14 +451,6 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
||||
team.setWidthFull();
|
||||
}
|
||||
|
||||
private <T> ComboBox<T> createComboBox(final String label, final T[] items) {
|
||||
ComboBox<T> comboBox = new ComboBox<>(label);
|
||||
comboBox.setItems(items);
|
||||
comboBox.setItemLabelGenerator(Object::toString);
|
||||
comboBox.setWidthFull();
|
||||
return comboBox;
|
||||
}
|
||||
|
||||
private ComboBox<Employee.Gender> createGenderComboBox() {
|
||||
ComboBox<Employee.Gender> comboBox = new ComboBox<>("Genero");
|
||||
comboBox.setItems(Employee.Gender.values());
|
||||
@ -496,9 +483,8 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
||||
}
|
||||
}
|
||||
|
||||
private void saveEmployee() {
|
||||
private void saveEmployee(final Employee employee) {
|
||||
if (validateForm()) {
|
||||
Employee employee = getEntity();
|
||||
employee.setStatus(status.getValue());
|
||||
employee.setAge(age.getValue());
|
||||
employee.setSalaryBasic(salaryBasic.getValue());
|
||||
@ -521,39 +507,39 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
||||
|
||||
private void enableEditMode() {
|
||||
setFieldsEditable();
|
||||
saveButton.setVisible(true);
|
||||
editButton.setVisible(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParameter(final BeforeEvent beforeEvent, final String action) {
|
||||
final RouteParameters params = beforeEvent.getRouteParameters();
|
||||
final String s = params.get("employeeId").orElse(null);
|
||||
|
||||
if ("new".equals(action)) {
|
||||
setEntityWithEnabledSave(new Employee());
|
||||
saveButton.setVisible(true);
|
||||
editButton.setVisible(false);
|
||||
setFieldsEditable();
|
||||
upload.setVisible(true);
|
||||
profileImagePreview.setVisible(true);
|
||||
salaryTotal.setValue(BigDecimal.valueOf(0.0));
|
||||
} else {
|
||||
UUID employeeId = UUID.fromString(s);
|
||||
var employee = employeeService.getEmployee(employeeId);
|
||||
setEntityWithEnabledSave(employee);
|
||||
if ("edit".equals(action) && !s.isEmpty()) {
|
||||
saveButton.setVisible(true);
|
||||
editButton.setVisible(false);
|
||||
Employee employee = null;
|
||||
|
||||
if (s != null) {
|
||||
final UUID employeeId = UUID.fromString(s);
|
||||
employee = employeeService.getEmployee(employeeId);
|
||||
} else {
|
||||
employee = employeeService.getEmployee(getEmployeeId().get());
|
||||
}
|
||||
|
||||
if ("edit".equals(action)) {
|
||||
setEntityWithEnabledSave(employee);
|
||||
status.setValue(employee.getStatus());
|
||||
setFieldsEditable();
|
||||
upload.setVisible(true);
|
||||
displayProfileImage(employee);
|
||||
profileImagePreview.setVisible(true);
|
||||
salaryTotal.setValue(employee.getSalaryTotal());
|
||||
} else if ("view".equals(action) && !s.isEmpty()) {
|
||||
setFieldsReadOnly();
|
||||
saveButton.setVisible(false);
|
||||
editButton.setVisible(true);
|
||||
} else if ("view".equals(action) || "me".equals(action)) {
|
||||
setEntity(employee);
|
||||
setFieldsReadOnly();
|
||||
displayProfileImage(employee);
|
||||
salaryTotal.setValue(employee.getSalaryTotal());
|
||||
@ -701,6 +687,7 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
||||
@Override
|
||||
protected List<Component> getFormComponents() {
|
||||
return List.of(
|
||||
new HorizontalLayout(reportButton, excelReportButton),
|
||||
username,
|
||||
infoPer,
|
||||
infoGenr,
|
||||
@ -724,7 +711,7 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
||||
salaryBasic, professionalBonus, tenureBonus, salaryTotal,
|
||||
datBanc, bankName, accountNumber,
|
||||
datGest, gpss, sss, beneficiarie1, beneficiarie2,
|
||||
saveButton, editButton, reportButton, excelReportButton, dialog
|
||||
dialog
|
||||
);
|
||||
}
|
||||
}
|
@ -175,7 +175,13 @@ public class MainLayout extends AppLayout {
|
||||
|
||||
final SideNavItem profile = new SideNavItem("Employee");
|
||||
profile.setPrefixComponent(LineAwesomeIcon.USER_TIE_SOLID.create());
|
||||
profile.addItem(new SideNavItem("Profiles", EmployeesListView.class,
|
||||
|
||||
if (isAdmin(authContext)) {
|
||||
profile.addItem(new SideNavItem("Profiles", EmployeesListView.class,
|
||||
LineAwesomeIcon.USER_FRIENDS_SOLID.create()));
|
||||
}
|
||||
|
||||
profile.addItem(new SideNavItem("My Profile", "/employees/me",
|
||||
LineAwesomeIcon.USER_EDIT_SOLID.create()));
|
||||
profile.addItem(new SideNavItem("Documents", DocumentsListView.class,
|
||||
LineAwesomeIcon.FILE_ALT_SOLID.create()));
|
||||
|
@ -3,29 +3,29 @@ package com.primefactorsolutions.views.admin;
|
||||
import com.primefactorsolutions.model.TimeOff;
|
||||
import com.primefactorsolutions.model.TimeOffRequestType;
|
||||
import com.primefactorsolutions.service.TimeOffService;
|
||||
import com.primefactorsolutions.views.BaseEntityForm;
|
||||
import com.primefactorsolutions.views.MainLayout;
|
||||
import com.vaadin.flow.component.Component;
|
||||
import com.vaadin.flow.component.combobox.ComboBox;
|
||||
import com.vaadin.flow.component.textfield.NumberField;
|
||||
import com.vaadin.flow.router.*;
|
||||
import com.vaadin.flow.spring.annotation.SpringComponent;
|
||||
import com.vaadin.flow.spring.security.AuthenticationContext;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.vaadin.firitin.components.datepicker.VDatePicker;
|
||||
import org.vaadin.firitin.form.BeanValidationForm;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.YearMonth;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@SpringComponent
|
||||
@PermitAll
|
||||
@Scope("prototype")
|
||||
@PageTitle("Vacaciones")
|
||||
@Route(value = "/time-off/:hours-workedId?/:action?", layout = MainLayout.class)
|
||||
public class TimeOffView extends BeanValidationForm<TimeOff> implements HasUrlParameter<String> {
|
||||
public class TimeOffView extends BaseEntityForm<TimeOff> implements HasUrlParameter<String> {
|
||||
private final ComboBox<TimeOffRequestType> category = new ComboBox<>("Categoria");
|
||||
private final ComboBox<TimeOff.Type> type = new ComboBox<>("Tipo");
|
||||
private final VDatePicker date = new VDatePicker("Fecha");
|
||||
@ -34,8 +34,9 @@ public class TimeOffView extends BeanValidationForm<TimeOff> implements HasUrlPa
|
||||
|
||||
private final TimeOffService timeOffService;
|
||||
|
||||
public TimeOffView(final TimeOffService timeOffService) {
|
||||
super(TimeOff.class);
|
||||
public TimeOffView(final AuthenticationContext authenticationContext,
|
||||
final TimeOffService timeOffService) {
|
||||
super(authenticationContext, TimeOff.class);
|
||||
this.timeOffService = timeOffService;
|
||||
|
||||
initializeDateField();
|
||||
@ -60,11 +61,11 @@ public class TimeOffView extends BeanValidationForm<TimeOff> implements HasUrlPa
|
||||
setEntityWithEnabledSave(timeOff);
|
||||
} else if ("view".equals(action) && !s.isEmpty()) {
|
||||
setEntity(timeOff);
|
||||
duration.setEnabled(false);
|
||||
expiration.setEnabled(false);
|
||||
category.setEnabled(false);
|
||||
type.setEnabled(false);
|
||||
date.setEnabled(false);
|
||||
duration.setReadOnly(true);
|
||||
expiration.setReadOnly(true);
|
||||
category.setReadOnly(true);
|
||||
type.setReadOnly(true);
|
||||
date.setReadOnly(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.primefactorsolutions.views.assessment;
|
||||
|
||||
import com.primefactorsolutions.model.Candidate;
|
||||
import com.primefactorsolutions.service.CandidateService;
|
||||
import com.primefactorsolutions.views.BaseEntityForm;
|
||||
import com.primefactorsolutions.views.MainLayout;
|
||||
import com.vaadin.flow.component.Component;
|
||||
import com.vaadin.flow.component.textfield.EmailField;
|
||||
@ -10,10 +11,10 @@ import com.vaadin.flow.router.HasUrlParameter;
|
||||
import com.vaadin.flow.router.PageTitle;
|
||||
import com.vaadin.flow.router.Route;
|
||||
import com.vaadin.flow.spring.annotation.SpringComponent;
|
||||
import com.vaadin.flow.spring.security.AuthenticationContext;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.vaadin.firitin.form.BeanValidationForm;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@ -23,13 +24,14 @@ import java.util.UUID;
|
||||
@PageTitle("Assessments")
|
||||
@Route(value = "/candidates", layout = MainLayout.class)
|
||||
@PermitAll
|
||||
public class CandidateView extends BeanValidationForm<Candidate> implements HasUrlParameter<String> {
|
||||
public class CandidateView extends BaseEntityForm<Candidate> implements HasUrlParameter<String> {
|
||||
private final CandidateService candidateService;
|
||||
|
||||
private EmailField email = null;
|
||||
|
||||
public CandidateView(final CandidateService candidateService) {
|
||||
super(Candidate.class);
|
||||
public CandidateView(final AuthenticationContext authenticationContext,
|
||||
final CandidateService candidateService) {
|
||||
super(authenticationContext, Candidate.class);
|
||||
this.candidateService = candidateService;
|
||||
email = new EmailField();
|
||||
email.setWidthFull();
|
||||
|
@ -2,6 +2,7 @@ package com.primefactorsolutions.views.assessment;
|
||||
|
||||
import com.primefactorsolutions.model.Question;
|
||||
import com.primefactorsolutions.service.QuestionService;
|
||||
import com.primefactorsolutions.views.BaseEntityForm;
|
||||
import com.primefactorsolutions.views.MainLayout;
|
||||
import com.vaadin.flow.component.Component;
|
||||
import com.vaadin.flow.component.textfield.IntegerField;
|
||||
@ -9,10 +10,10 @@ import com.vaadin.flow.component.textfield.TextArea;
|
||||
import com.vaadin.flow.component.textfield.TextField;
|
||||
import com.vaadin.flow.router.*;
|
||||
import com.vaadin.flow.spring.annotation.SpringComponent;
|
||||
import com.vaadin.flow.spring.security.AuthenticationContext;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.vaadin.firitin.form.BeanValidationForm;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@ -22,7 +23,7 @@ import java.util.UUID;
|
||||
@PageTitle("Assessments")
|
||||
@Route(value = "/questions", layout = MainLayout.class)
|
||||
@PermitAll
|
||||
public class QuestionView extends BeanValidationForm<Question> implements HasUrlParameter<String> {
|
||||
public class QuestionView extends BaseEntityForm<Question> implements HasUrlParameter<String> {
|
||||
private final QuestionService questionService;
|
||||
|
||||
private TextField title = null;
|
||||
@ -30,8 +31,9 @@ public class QuestionView extends BeanValidationForm<Question> implements HasUrl
|
||||
private TextArea content = null;
|
||||
private IntegerField timeMinutes = null;
|
||||
|
||||
public QuestionView(final QuestionService questionService) {
|
||||
super(Question.class);
|
||||
public QuestionView(final AuthenticationContext authenticationContext,
|
||||
final QuestionService questionService) {
|
||||
super(authenticationContext, Question.class);
|
||||
this.questionService = questionService;
|
||||
title = new TextField();
|
||||
title.setWidthFull();
|
||||
|
@ -166,11 +166,11 @@ public class TimeOffRequestView extends BaseEntityForm<TimeOffRequest> implement
|
||||
private void onCategoryChange(final TimeOffRequestType selectedCategory) {
|
||||
if (selectedCategory == TimeOffRequestType.VACACION_GESTION_ACTUAL
|
||||
|| selectedCategory == TimeOffRequestType.VACACION_GESTION_ANTERIOR) {
|
||||
startDate.setEnabled(true);
|
||||
endDate.setEnabled(true);
|
||||
startDate.setReadOnly(false);
|
||||
endDate.setReadOnly(false);
|
||||
} else {
|
||||
startDate.setEnabled(true);
|
||||
endDate.setEnabled(false);
|
||||
startDate.setReadOnly(false);
|
||||
endDate.setReadOnly(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,9 +56,9 @@ public class TimeOffRequestsListView extends BaseView {
|
||||
private final EmployeeService employeeService;
|
||||
private final TeamService teamService;
|
||||
private final PagingGrid<TimeOffRequest> requestsGrid = new PagingGrid<>();
|
||||
private ComboBox<Employee> employeeFilter;
|
||||
private ComboBox<Team> teamFilter;
|
||||
private ComboBox<TimeOffRequestType> categoryFilter;
|
||||
private final ComboBox<Employee> employeeFilter = new ComboBox<>("Empleado");
|
||||
private final ComboBox<Team> teamFilter = new ComboBox<>("Equipo");
|
||||
private final ComboBox<TimeOffRequestType> categoryFilter = new ComboBox<>("Categoría");
|
||||
|
||||
public TimeOffRequestsListView(final AuthenticationContext authenticationContext,
|
||||
final TimeOffRequestService requestService,
|
||||
@ -69,14 +69,20 @@ public class TimeOffRequestsListView extends BaseView {
|
||||
this.employeeService = employeeService;
|
||||
this.teamService = teamService;
|
||||
initializeView();
|
||||
refreshGeneralRequestsGrid(null, null, null);
|
||||
refreshGeneralRequestsGrid(employeeFilter.getValue(), teamFilter.getValue(), categoryFilter.getValue());
|
||||
}
|
||||
|
||||
private void initializeView() {
|
||||
final Button newRequestButton = new Button("Crear nueva peticion", event -> navigateToAddNew());
|
||||
newRequestButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
||||
final Button downloadReportButton = new Button("Descargar reporte de rechazos", event -> downloadReport());
|
||||
final HorizontalLayout hl = new HorizontalLayout(newRequestButton, downloadReportButton);
|
||||
|
||||
final HorizontalLayout hl = new HorizontalLayout(newRequestButton);
|
||||
|
||||
if (isRoleAdmin()) {
|
||||
final Button downloadReportButton = new Button("Descargar reporte de rechazos", event -> downloadReport());
|
||||
hl.add(downloadReportButton);
|
||||
}
|
||||
|
||||
getCurrentPageLayout().add(hl);
|
||||
setupFilters();
|
||||
setupRequestsGrid();
|
||||
@ -188,12 +194,19 @@ public class TimeOffRequestsListView extends BaseView {
|
||||
}
|
||||
|
||||
private ComboBox<Employee> createEmployeeFilter() {
|
||||
employeeFilter = new ComboBox<>("Empleado");
|
||||
employeeFilter.setClearButtonVisible(true);
|
||||
employeeFilter.setPlaceholder("Seleccionar ...");
|
||||
final List<Employee> employees = new ArrayList<>(employeeService.findAllEmployees());
|
||||
|
||||
employeeFilter.setItems(employees);
|
||||
if (isRoleAdmin()) {
|
||||
final List<Employee> employees = employeeService.findAllEmployees();
|
||||
employeeFilter.setItems(employees);
|
||||
} else {
|
||||
final Employee employee = employeeService.getEmployee(getEmployeeId().get());
|
||||
employeeFilter.setItems(List.of(employee));
|
||||
employeeFilter.setValue(employee);
|
||||
employeeFilter.setReadOnly(true);
|
||||
}
|
||||
|
||||
employeeFilter.setItemLabelGenerator(this::getEmployeeFullNameLabel);
|
||||
employeeFilter.addValueChangeListener(event ->
|
||||
refreshGeneralRequestsGrid(
|
||||
@ -206,7 +219,6 @@ public class TimeOffRequestsListView extends BaseView {
|
||||
}
|
||||
|
||||
private ComboBox<Team> createTeamFilter() {
|
||||
teamFilter = new ComboBox<>("Equipo");
|
||||
teamFilter.setClearButtonVisible(true);
|
||||
teamFilter.setPlaceholder("Seleccionar ...");
|
||||
final List<Team> teams = new ArrayList<>(teamService.findAllTeams());
|
||||
@ -223,7 +235,6 @@ public class TimeOffRequestsListView extends BaseView {
|
||||
}
|
||||
|
||||
private ComboBox<TimeOffRequestType> createCategoryFilter() {
|
||||
categoryFilter = new ComboBox<>("Categoría");
|
||||
categoryFilter.setPlaceholder("Seleccionar ...");
|
||||
categoryFilter.setClearButtonVisible(true);
|
||||
categoryFilter.setItems(TimeOffRequestType.values());
|
||||
|
@ -52,8 +52,8 @@ public class TimeOffSummaryListView extends BaseView {
|
||||
private final TeamService teamService;
|
||||
private final TimeOffService timeOffService;
|
||||
private final PagingGrid<Employee> requestGrid = new PagingGrid<>();
|
||||
private ComboBox<Employee> employeeFilter;
|
||||
private ComboBox<Team> teamFilter;
|
||||
private final ComboBox<Employee> employeeFilter = new ComboBox<>("Empleado");;
|
||||
private final ComboBox<Team> teamFilter = new ComboBox<>("Equipo");
|
||||
|
||||
public TimeOffSummaryListView(
|
||||
final AuthenticationContext authenticationContext,
|
||||
@ -67,7 +67,7 @@ public class TimeOffSummaryListView extends BaseView {
|
||||
this.teamService = teamService;
|
||||
this.timeOffService = timeOffService;
|
||||
initializeView();
|
||||
refreshGeneralRequestGrid(null, null);
|
||||
refreshGeneralRequestGrid(employeeFilter.getValue(), teamFilter.getValue());
|
||||
}
|
||||
|
||||
private void initializeView() {
|
||||
@ -334,12 +334,19 @@ public class TimeOffSummaryListView extends BaseView {
|
||||
}
|
||||
|
||||
private ComboBox<Employee> createEmployeeFilter() {
|
||||
employeeFilter = new ComboBox<>("Empleado");
|
||||
|
||||
final List<Employee> employees = new ArrayList<>(employeeService.findAllEmployees());
|
||||
employeeFilter.setPlaceholder("Seleccionar ...");
|
||||
employeeFilter.setClearButtonVisible(true);
|
||||
employeeFilter.setItems(employees);
|
||||
|
||||
if (isRoleAdmin()) {
|
||||
final List<Employee> employees = new ArrayList<>(employeeService.findAllEmployees());
|
||||
employeeFilter.setItems(employees);
|
||||
} else {
|
||||
final Employee employee = employeeService.getEmployee(getEmployeeId().get());
|
||||
employeeFilter.setItems(List.of(employee));
|
||||
employeeFilter.setValue(employee);
|
||||
employeeFilter.setReadOnly(true);
|
||||
}
|
||||
|
||||
employeeFilter.setItemLabelGenerator(this::getEmployeeFullName);
|
||||
employeeFilter.addValueChangeListener(event ->
|
||||
refreshGeneralRequestGrid(
|
||||
@ -352,7 +359,6 @@ public class TimeOffSummaryListView extends BaseView {
|
||||
}
|
||||
|
||||
private ComboBox<Team> createTeamFilter() {
|
||||
teamFilter = new ComboBox<>("Equipo");
|
||||
teamFilter.setPlaceholder("Seleccionar ...");
|
||||
teamFilter.setClearButtonVisible(true);
|
||||
final List<Team> teams = new ArrayList<>(teamService.findAllTeams());
|
||||
|
@ -79,12 +79,12 @@ public class TimesheetEntryView extends BaseEntityForm<TimesheetEntry> implement
|
||||
setEntityWithEnabledSave(timesheetEntry);
|
||||
} else if ("view".equals(action) && !s.isEmpty()) {
|
||||
setEntity(timesheetEntry);
|
||||
employee.setEnabled(false);
|
||||
team.setEnabled(false);
|
||||
task.setEnabled(false);
|
||||
details.setEnabled(false);
|
||||
date.setEnabled(false);
|
||||
hours.setEnabled(false);
|
||||
employee.setReadOnly(true);
|
||||
team.setReadOnly(true);
|
||||
task.setReadOnly(true);
|
||||
details.setReadOnly(true);
|
||||
date.setReadOnly(true);
|
||||
hours.setReadOnly(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ public class TimesheetListView extends BaseView {
|
||||
List<Employee> employees = new ArrayList<>(employeeService.findAllEmployees());
|
||||
|
||||
if (!isRoleAdmin()) {
|
||||
employeeFilter.setEnabled(false);
|
||||
employeeFilter.setReadOnly(true);
|
||||
employees = employees.stream()
|
||||
.filter(e -> getEmployeeId().equals(Optional.ofNullable(e.getId())))
|
||||
.toList();
|
||||
|
Loading…
x
Reference in New Issue
Block a user