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