Compare commits
20 Commits
b19496ca15
...
e3d672c00b
Author | SHA1 | Date | |
---|---|---|---|
|
e3d672c00b | ||
|
6c1c0e5ea7 | ||
|
2aec8ff05a | ||
3b085e835b | |||
5a270d6795 | |||
22963adad9 | |||
7d3b63f6a8 | |||
696481a695 | |||
0d9e0755b0 | |||
81b3003d1b | |||
602ab686f5 | |||
62d678c407 | |||
3768a69cf4 | |||
2a47bb8d9a | |||
0fd278ac62 | |||
f8f71b187c | |||
334802e004 | |||
f7d0e9df23 | |||
e8e0f60c4e | |||
f90efef23c |
111
src/main/java/com/primefactorsolutions/model/Actividad.java
Normal file
111
src/main/java/com/primefactorsolutions/model/Actividad.java
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
package com.primefactorsolutions.model;
|
||||||
|
|
||||||
|
final public class Actividad {
|
||||||
|
private String nombre;
|
||||||
|
private double lunes;
|
||||||
|
private double martes;
|
||||||
|
private double miercoles;
|
||||||
|
private double jueves;
|
||||||
|
private double viernes;
|
||||||
|
private double sabado;
|
||||||
|
private double domingo;
|
||||||
|
|
||||||
|
public Actividad(final Builder builder) {
|
||||||
|
this.nombre = builder.nombre;
|
||||||
|
this.lunes = builder.lunes;
|
||||||
|
this.martes = builder.martes;
|
||||||
|
this.miercoles = builder.miercoles;
|
||||||
|
this.jueves = builder.jueves;
|
||||||
|
this.viernes = builder.viernes;
|
||||||
|
this.sabado = builder.sabado;
|
||||||
|
this.domingo = builder.domingo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNombre() {
|
||||||
|
return nombre;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getLunes() {
|
||||||
|
return lunes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getMartes() {
|
||||||
|
return martes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getMiercoles() {
|
||||||
|
return miercoles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getJueves() {
|
||||||
|
return jueves;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getViernes() {
|
||||||
|
return viernes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getSabado() {
|
||||||
|
return sabado;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getDomingo() {
|
||||||
|
return domingo;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Builder para crear instancias de Actividad
|
||||||
|
public static class Builder {
|
||||||
|
private String nombre;
|
||||||
|
private double lunes;
|
||||||
|
private double martes;
|
||||||
|
private double miercoles;
|
||||||
|
private double jueves;
|
||||||
|
private double viernes;
|
||||||
|
private double sabado;
|
||||||
|
private double domingo;
|
||||||
|
|
||||||
|
public Builder nombre(final String nombre) {
|
||||||
|
this.nombre = nombre;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder lunes(final double horas) {
|
||||||
|
this.lunes = horas;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder martes(final double horas) {
|
||||||
|
this.martes = horas;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder miercoles(final double horas) {
|
||||||
|
this.miercoles = horas;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder jueves(final double horas) {
|
||||||
|
this.jueves = horas;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder viernes(final double horas) {
|
||||||
|
this.viernes = horas;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder sabado(final double horas) {
|
||||||
|
this.sabado = horas;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder domingo(final double horas) {
|
||||||
|
this.domingo = horas;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Actividad build() {
|
||||||
|
return new Actividad(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -29,7 +29,9 @@
|
|||||||
private String phoneNumber;
|
private String phoneNumber;
|
||||||
private String personalEmail;
|
private String personalEmail;
|
||||||
private String position;
|
private String position;
|
||||||
private String team;
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "team_id", nullable = false)
|
||||||
|
private Team team;
|
||||||
private String emergencyCName;
|
private String emergencyCName;
|
||||||
private String emergencyCAddress;
|
private String emergencyCAddress;
|
||||||
private String emergencyCPhone;
|
private String emergencyCPhone;
|
||||||
|
@ -1,61 +1,50 @@
|
|||||||
package com.primefactorsolutions.model;
|
package com.primefactorsolutions.model;
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
import com.vaadin.flow.component.template.Id;
|
||||||
import jakarta.validation.constraints.AssertTrue;
|
import jakarta.persistence.Entity;
|
||||||
import lombok.AllArgsConstructor;
|
import jakarta.persistence.GeneratedValue;
|
||||||
import lombok.Data;
|
import jakarta.persistence.GenerationType;
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Data
|
|
||||||
@Entity
|
@Entity
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class HoursWorked extends BaseEntity {
|
public class HoursWorked extends BaseEntity {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
@JoinColumn(name = "employee_id", nullable = false)
|
|
||||||
private Employee employee;
|
private Employee employee;
|
||||||
|
|
||||||
private LocalDate workDate;
|
private int weekNumber;
|
||||||
|
private double totalHours;
|
||||||
|
|
||||||
private int regularHours;
|
public HoursWorked() {}
|
||||||
|
|
||||||
private int overtimeHours;
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
private int weekendHours;
|
|
||||||
|
|
||||||
private int holidayHours;
|
|
||||||
|
|
||||||
@Enumerated(EnumType.STRING)
|
|
||||||
private WorkType workType;
|
|
||||||
|
|
||||||
@Enumerated(EnumType.STRING)
|
|
||||||
private ApprovalStatus approvalStatus;
|
|
||||||
|
|
||||||
@Column(columnDefinition = "TEXT")
|
|
||||||
private String notes;
|
|
||||||
|
|
||||||
public enum WorkType {
|
|
||||||
ONSITE, REMOTE, HYBRID
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ApprovalStatus {
|
public Employee getEmployee() {
|
||||||
PENDING, APPROVED, REJECTED
|
return employee;
|
||||||
}
|
}
|
||||||
|
|
||||||
@AssertTrue(message = "Las horas no pueden ser negativas")
|
public void setEmployee(Employee value) {
|
||||||
public boolean areHoursValid() {
|
this.employee = value; // Asignar el objeto Employee al campo
|
||||||
return regularHours >= 0 && overtimeHours >= 0 &&
|
|
||||||
weekendHours >= 0 && holidayHours >= 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@AssertTrue(message = "La suma de horas no puede superar 24 en un día")
|
public int getWeekNumber() {
|
||||||
public boolean isTotalHoursValid() {
|
return weekNumber;
|
||||||
int totalHours = regularHours + overtimeHours + weekendHours + holidayHours;
|
}
|
||||||
return totalHours <= 24;
|
|
||||||
|
public void setWeekNumber(int weekNumber) {
|
||||||
|
this.weekNumber = weekNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getTotalHours() {
|
||||||
|
return totalHours;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalHours(double totalHours) {
|
||||||
|
this.totalHours = totalHours;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import lombok.Data;
|
|||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.time.LocalDate;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Entity
|
@Entity
|
||||||
@ -17,30 +17,14 @@ public class TimeOffRequest extends BaseEntity {
|
|||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "employee_id", nullable = false)
|
@JoinColumn(name = "employee_id", nullable = false)
|
||||||
private Employee employee;
|
private Employee employee;
|
||||||
@ManyToOne
|
|
||||||
@JoinColumn(name = "team_id", nullable = false)
|
|
||||||
private Team team;
|
|
||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
private TimeOffRequestType category;
|
private TimeOffRequestType category;
|
||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
private Status state;
|
private TimeOffRequestStatus state;
|
||||||
private Double availableDays;
|
private Double availableDays;
|
||||||
private Date expiration;
|
private LocalDate expiration;
|
||||||
private Date startDate;
|
private LocalDate startDate;
|
||||||
private Date endDate;
|
private LocalDate endDate;
|
||||||
private Double daysToBeTake;
|
private Double daysToBeTake;
|
||||||
private Double daysBalance;
|
private Double daysBalance;
|
||||||
public enum Status {
|
|
||||||
ALL,
|
|
||||||
TAKEN,
|
|
||||||
REQUESTED,
|
|
||||||
APPROVED,
|
|
||||||
IN_USE,
|
|
||||||
UNDER_REVIEW,
|
|
||||||
PENDING,
|
|
||||||
REJECTED,
|
|
||||||
COMPLETED,
|
|
||||||
CANCELLED,
|
|
||||||
EXPIRED,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.primefactorsolutions.model;
|
||||||
|
|
||||||
|
public enum TimeOffRequestStatus {
|
||||||
|
ALL,
|
||||||
|
TAKEN,
|
||||||
|
REQUESTED,
|
||||||
|
APPROVED,
|
||||||
|
IN_USE,
|
||||||
|
UNDER_REVIEW,
|
||||||
|
PENDING,
|
||||||
|
REJECTED,
|
||||||
|
COMPLETED,
|
||||||
|
CANCELLED,
|
||||||
|
EXPIRED
|
||||||
|
}
|
@ -1,9 +1,14 @@
|
|||||||
package com.primefactorsolutions.repositories;
|
package com.primefactorsolutions.repositories;
|
||||||
|
|
||||||
import com.primefactorsolutions.model.TimeOffRequest;
|
import com.primefactorsolutions.model.TimeOffRequest;
|
||||||
|
import com.primefactorsolutions.model.TimeOffRequestStatus;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public interface TimeOffRequestRepository extends JpaRepository<TimeOffRequest, UUID> {
|
public interface TimeOffRequestRepository extends JpaRepository<TimeOffRequest, UUID> {
|
||||||
|
List<TimeOffRequest> findByEmployeeId(UUID idEmployee);
|
||||||
|
Optional<TimeOffRequest> findByEmployeeIdAndState(UUID employeeId, TimeOffRequestStatus state);
|
||||||
}
|
}
|
||||||
|
@ -3,14 +3,11 @@ package com.primefactorsolutions.service;
|
|||||||
import com.primefactorsolutions.model.*;
|
import com.primefactorsolutions.model.*;
|
||||||
import com.primefactorsolutions.repositories.TimeOffRequestRepository;
|
import com.primefactorsolutions.repositories.TimeOffRequestRepository;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.apache.commons.beanutils.BeanComparator;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@ -25,64 +22,20 @@ public class TimeOffRequestService {
|
|||||||
timeOffRequestRepository.deleteById(id);
|
timeOffRequestRepository.deleteById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TimeOffRequest> getAllTimeOffRequests() {
|
public List<TimeOffRequest> findAllTimeOffRequests() {
|
||||||
return timeOffRequestRepository.findAll();
|
return timeOffRequestRepository.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimeOffRequest getTimeOffRequest(final UUID id) {
|
public TimeOffRequest findTimeOffRequest(final UUID id) {
|
||||||
Optional<TimeOffRequest> timeOffRequest = timeOffRequestRepository.findById(id);
|
Optional<TimeOffRequest> timeOffRequest = timeOffRequestRepository.findById(id);
|
||||||
return timeOffRequest.orElse(null);
|
return timeOffRequest.orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TimeOffRequest> findTimeOffRequests(
|
public List<TimeOffRequest> findRequestsByEmployeeId(final UUID idEmployee) {
|
||||||
final int start, final int pageSize, final String sortProperty, final boolean asc) {
|
return timeOffRequestRepository.findByEmployeeId(idEmployee);
|
||||||
List<TimeOffRequest> timeOffRequests = timeOffRequestRepository.findAll();
|
|
||||||
|
|
||||||
int end = Math.min(start + pageSize, timeOffRequests.size());
|
|
||||||
timeOffRequests.sort(new BeanComparator<>(sortProperty));
|
|
||||||
|
|
||||||
if (!asc) {
|
|
||||||
Collections.reverse(timeOffRequests);
|
|
||||||
}
|
|
||||||
|
|
||||||
return timeOffRequests.subList(start, end);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TimeOffRequest> findTimeOffRequests(final int start, final int pageSize) {
|
public Optional<TimeOffRequest> findByEmployeeAndState(final UUID employeeId, final TimeOffRequestStatus state) {
|
||||||
List<TimeOffRequest> timeOffRequests = timeOffRequestRepository.findAll();
|
return timeOffRequestRepository.findByEmployeeIdAndState(employeeId, state);
|
||||||
|
|
||||||
int end = Math.min(start + pageSize, timeOffRequests.size());
|
|
||||||
return timeOffRequests.subList(start, end);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<TimeOffRequest> findTimeOffRequestBy(final Employee employee,
|
|
||||||
final Team team,
|
|
||||||
final TimeOffRequestType category,
|
|
||||||
final TimeOffRequest.Status state,
|
|
||||||
final int start,
|
|
||||||
final int pageSize) {
|
|
||||||
List<TimeOffRequest> timeOffRequests = timeOffRequestRepository.findAll();
|
|
||||||
if (employee != null && !"ALL".equals(employee.getFirstName())) {
|
|
||||||
timeOffRequests = timeOffRequests.stream()
|
|
||||||
.filter(req -> req.getEmployee().equals(employee))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
if (team != null && !"ALL".equals(team.getName())) {
|
|
||||||
timeOffRequests = timeOffRequests.stream()
|
|
||||||
.filter(req -> req.getTeam().equals(team))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
if (category != null && !"ALL".equals(category.name())) {
|
|
||||||
timeOffRequests = timeOffRequests.stream()
|
|
||||||
.filter(req -> req.getCategory().equals(category))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
if (state != null && !"ALL".equals(state.name())) {
|
|
||||||
timeOffRequests = timeOffRequests.stream()
|
|
||||||
.filter(req -> req.getState().equals(state))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
int end = Math.min(start + pageSize, timeOffRequests.size());
|
|
||||||
return timeOffRequests.subList(start, end);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,19 +1,26 @@
|
|||||||
package com.primefactorsolutions.views;
|
package com.primefactorsolutions.views;
|
||||||
|
|
||||||
|
import com.primefactorsolutions.model.Employee;
|
||||||
|
import com.primefactorsolutions.model.Actividad;
|
||||||
|
import com.primefactorsolutions.service.EmployeeService;
|
||||||
import com.vaadin.flow.component.button.Button;
|
import com.vaadin.flow.component.button.Button;
|
||||||
import com.vaadin.flow.component.combobox.ComboBox;
|
import com.vaadin.flow.component.combobox.ComboBox;
|
||||||
|
import com.vaadin.flow.component.datepicker.DatePicker;
|
||||||
import com.vaadin.flow.component.grid.Grid;
|
import com.vaadin.flow.component.grid.Grid;
|
||||||
import com.vaadin.flow.component.html.H2;
|
|
||||||
import com.vaadin.flow.component.html.Label;
|
import com.vaadin.flow.component.html.Label;
|
||||||
|
import com.vaadin.flow.component.notification.Notification;
|
||||||
|
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
||||||
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
||||||
import com.vaadin.flow.component.textfield.TextField;
|
|
||||||
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 jakarta.annotation.security.PermitAll;
|
import jakarta.annotation.security.PermitAll;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.temporal.TemporalAdjusters;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@SpringComponent
|
@SpringComponent
|
||||||
@ -22,57 +29,135 @@ import java.util.List;
|
|||||||
@PageTitle("Hours Worked Month")
|
@PageTitle("Hours Worked Month")
|
||||||
@Route(value = "/hours-worked-month/me", layout = MainLayout.class)
|
@Route(value = "/hours-worked-month/me", layout = MainLayout.class)
|
||||||
public class HoursWorkedMonthView extends VerticalLayout {
|
public class HoursWorkedMonthView extends VerticalLayout {
|
||||||
|
private final EmployeeService employeeService;
|
||||||
|
private final ComboBox<Employee> employeeComboBox = new ComboBox<>("Empleado");
|
||||||
|
private final ComboBox<String> equipoDropdown = new ComboBox<>("Equipo");
|
||||||
|
private final Grid<Actividad> grid = new Grid<>(Actividad.class);
|
||||||
|
|
||||||
private final Grid<HoursWorkedView.Actividad> grid;
|
private final Label totalCompletadoLabel = new Label();
|
||||||
private final ComboBox<String> equipoComboBox;
|
private final Label horasPendientesLabel = new Label();
|
||||||
private final TextField empleadoSearch;
|
private final Label totalAcumuladasLabel = new Label();
|
||||||
private final Button actualizarButton;
|
private final Label horasAdeudadasLabel = new Label();
|
||||||
private final Button guardarButton;
|
private final Button actualizarButton = new Button("Actualizar");
|
||||||
private final Button cerrarButton;
|
private final Button guardarButton = new Button("Guardar");
|
||||||
|
private final Button cerrarButton = new Button("Cerrar");
|
||||||
|
|
||||||
public HoursWorkedMonthView() {
|
private LocalDate selectedMonth;
|
||||||
add(new H2("Registro de Horas Trabajadas"));
|
|
||||||
|
|
||||||
Label mesLabel = new Label("SEPTIEMBRE 2024, MES 9");
|
@Autowired
|
||||||
add(mesLabel);
|
public HoursWorkedMonthView(EmployeeService employeeService) {
|
||||||
|
this.employeeService = employeeService;
|
||||||
equipoComboBox = new ComboBox<>("Equipo");
|
configurarVista();
|
||||||
equipoComboBox.setItems(getEquipos());
|
|
||||||
add(equipoComboBox);
|
|
||||||
|
|
||||||
empleadoSearch = new TextField("Empleado (Search):");
|
|
||||||
add(empleadoSearch);
|
|
||||||
|
|
||||||
grid = new Grid<>(HoursWorkedView.Actividad.class);
|
|
||||||
grid.setItems(getActividades());
|
|
||||||
grid.setColumns("lunes", "martes", "miercoles", "jueves", "viernes", "sabado", "domingo", "totalSem");
|
|
||||||
add(grid);
|
|
||||||
|
|
||||||
actualizarButton = new Button("Actualizar", e -> actualizar());
|
|
||||||
guardarButton = new Button("Guardar", e -> guardar());
|
|
||||||
cerrarButton = new Button("Cerrar", e -> cerrar());
|
|
||||||
|
|
||||||
add(actualizarButton, guardarButton, cerrarButton);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> getEquipos() {
|
private void configurarVista() {
|
||||||
return List.of("Equipo A", "Equipo B", "Equipo C");
|
DatePicker monthPicker = new DatePicker("Selecciona un mes");
|
||||||
|
monthPicker.setValue(LocalDate.now());
|
||||||
|
monthPicker.addValueChangeListener(event -> {
|
||||||
|
selectedMonth = event.getValue().withDayOfMonth(1);
|
||||||
|
cargarDatosMes(selectedMonth);
|
||||||
|
});
|
||||||
|
|
||||||
|
equipoDropdown.setItems("Equipo 1", "Equipo 2", "Equipo 3");
|
||||||
|
equipoDropdown.setWidth("250px");
|
||||||
|
|
||||||
|
setEmployeeComboBoxProperties();
|
||||||
|
|
||||||
|
configurarGrid();
|
||||||
|
|
||||||
|
actualizarButton.addClickListener(event -> actualizarDatos());
|
||||||
|
guardarButton.addClickListener(event -> guardarActividades());
|
||||||
|
cerrarButton.addClickListener(event -> closeView());
|
||||||
|
|
||||||
|
HorizontalLayout headerLayout = new HorizontalLayout(monthPicker, equipoDropdown, employeeComboBox);
|
||||||
|
add(
|
||||||
|
headerLayout, grid, totalCompletadoLabel,
|
||||||
|
horasPendientesLabel, totalAcumuladasLabel,
|
||||||
|
horasAdeudadasLabel, actualizarButton,
|
||||||
|
guardarButton, cerrarButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<HoursWorkedView.Actividad> getActividades() {
|
private void setEmployeeComboBoxProperties() {
|
||||||
return List.of(
|
employeeComboBox.setWidth("250px");
|
||||||
new HoursWorkedView.Actividad(1, 7, 8, 8, 8, 8, 1, 40),
|
employeeComboBox.setPlaceholder("Buscar empleado...");
|
||||||
new HoursWorkedView.Actividad(2, 1, 7, 8, 8, 8, 1, 40)
|
employeeComboBox.setItems(employeeService.findAllEmployees());
|
||||||
);
|
employeeComboBox.setItemLabelGenerator(employee -> employee.getFirstName() + " " + employee.getLastName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void actualizar() {
|
private void configurarGrid() {
|
||||||
grid.setItems(getActividades());
|
grid.removeAllColumns();
|
||||||
|
grid.addColumn(Actividad::getLunes).setHeader("Lunes");
|
||||||
|
grid.addColumn(Actividad::getMartes).setHeader("Martes");
|
||||||
|
grid.addColumn(Actividad::getMiercoles).setHeader("Miércoles");
|
||||||
|
grid.addColumn(Actividad::getJueves).setHeader("Jueves");
|
||||||
|
grid.addColumn(Actividad::getViernes).setHeader("Viernes");
|
||||||
|
grid.addColumn(Actividad::getSabado).setHeader("Sábado");
|
||||||
|
grid.addColumn(Actividad::getDomingo).setHeader("Domingo");
|
||||||
|
grid.addColumn(this::calcularTotalPorDia).setHeader("Total Semanal").setKey("totalSemanal");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void guardar() {
|
private void cargarDatosMes(LocalDate month) {
|
||||||
|
List<Actividad> actividadesDelMes = obtenerActividadesDelMes(month);
|
||||||
|
grid.setItems(actividadesDelMes);
|
||||||
|
|
||||||
|
double totalCompletado = calcularTotalCompletado(actividadesDelMes);
|
||||||
|
double horasPendientes = calcularHorasPendientes(totalCompletado);
|
||||||
|
double totalAcumuladas = 166;
|
||||||
|
double horasAdeudadas = 2;
|
||||||
|
|
||||||
|
totalCompletadoLabel.setText("Prom. Hrs/Semana Completadas: " + totalCompletado);
|
||||||
|
horasPendientesLabel.setText("Prom. Hrs/Semana Pendientes: " + horasPendientes);
|
||||||
|
totalAcumuladasLabel.setText("Total Hrs./Mes Acumuladas: " + totalAcumuladas);
|
||||||
|
horasAdeudadasLabel.setText("Total Hrs./Mes Adeudadas: " + horasAdeudadas);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cerrar() {
|
private List<Actividad> obtenerActividadesDelMes(final LocalDate month) {
|
||||||
|
LocalDate startOfMonth = month.with(TemporalAdjusters.firstDayOfMonth());
|
||||||
|
LocalDate endOfMonth = month.with(TemporalAdjusters.lastDayOfMonth());
|
||||||
|
|
||||||
|
List<Actividad> actividadesDelMes = new ArrayList<>();
|
||||||
|
|
||||||
|
for (LocalDate date = startOfMonth; date.isBefore(endOfMonth.plusDays(1)); date = date.plusDays(1)) {
|
||||||
|
Actividad actividad = new Actividad.Builder()
|
||||||
|
.lunes(0)
|
||||||
|
.martes(0)
|
||||||
|
.miercoles(0)
|
||||||
|
.jueves(0)
|
||||||
|
.viernes(0)
|
||||||
|
.sabado(0)
|
||||||
|
.domingo(0)
|
||||||
|
.build();
|
||||||
|
actividadesDelMes.add(actividad);
|
||||||
|
}
|
||||||
|
|
||||||
|
return actividadesDelMes;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
private double calcularTotalCompletado(List<Actividad> actividades) {
|
||||||
|
return actividades.stream()
|
||||||
|
.mapToDouble(this::calcularTotalPorDia)
|
||||||
|
.sum();
|
||||||
|
}
|
||||||
|
|
||||||
|
private double calcularTotalPorDia(final Actividad actividad) {
|
||||||
|
return actividad.getLunes() + actividad.getMartes() + actividad.getMiercoles() +
|
||||||
|
actividad.getJueves() + actividad.getViernes() + actividad.getSabado() +
|
||||||
|
actividad.getDomingo();
|
||||||
|
}
|
||||||
|
|
||||||
|
private double calcularHorasPendientes(double totalCompletado) {
|
||||||
|
return 40 - totalCompletado;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void actualizarDatos() {
|
||||||
|
Notification.show("Datos actualizados.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void guardarActividades() {
|
||||||
|
Notification.show("Actividades guardadas correctamente.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void closeView() {
|
||||||
|
getUI().ifPresent(ui -> ui.navigate(""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.primefactorsolutions.views;
|
package com.primefactorsolutions.views;
|
||||||
|
import com.primefactorsolutions.model.Actividad;
|
||||||
import com.primefactorsolutions.model.Employee;
|
import com.primefactorsolutions.model.Employee;
|
||||||
|
import com.primefactorsolutions.model.HoursWorked;
|
||||||
import com.primefactorsolutions.service.EmployeeService;
|
import com.primefactorsolutions.service.EmployeeService;
|
||||||
import com.vaadin.flow.component.datepicker.DatePicker;
|
import com.vaadin.flow.component.datepicker.DatePicker;
|
||||||
import com.vaadin.flow.component.grid.Grid;
|
import com.vaadin.flow.component.grid.Grid;
|
||||||
@ -20,6 +22,7 @@ import com.vaadin.flow.component.html.Label;
|
|||||||
|
|
||||||
import java.time.DayOfWeek;
|
import java.time.DayOfWeek;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.time.temporal.IsoFields;
|
||||||
import java.time.temporal.WeekFields;
|
import java.time.temporal.WeekFields;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -33,19 +36,29 @@ import java.util.Locale;
|
|||||||
public class HoursWorkedView extends VerticalLayout {
|
public class HoursWorkedView extends VerticalLayout {
|
||||||
private final List<Actividad> actividades = new ArrayList<>();
|
private final List<Actividad> actividades = new ArrayList<>();
|
||||||
private final Grid<Actividad> grid = new Grid<>(Actividad.class);
|
private final Grid<Actividad> grid = new Grid<>(Actividad.class);
|
||||||
private final Grid<Actividad> totalsGrid = new Grid<>(Actividad.class);
|
|
||||||
private final ComboBox<Employee> employeeComboBox = new ComboBox<>("Employee");
|
private final ComboBox<Employee> employeeComboBox = new ComboBox<>("Employee");
|
||||||
private LocalDate selectedStartOfWeek;
|
private LocalDate selectedStartOfWeek;
|
||||||
|
private int weekNumber;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private final EmployeeService employeeService;
|
private final EmployeeService employeeService;
|
||||||
|
|
||||||
private final Label fechasLabel = new Label("Selecciona una semana para ver las fechas.");
|
private final Label fechasLabel = new Label("Selecciona una semana para ver las fechas.");
|
||||||
|
private final Label totalCompletadoLabel = new Label();
|
||||||
|
private final Label horasPendientesLabel = new Label();
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public HoursWorkedView(final EmployeeService employeeService) {
|
public HoursWorkedView(final EmployeeService employeeService) {
|
||||||
this.employeeService = employeeService;
|
this.employeeService = employeeService;
|
||||||
configurarVista();
|
configurarVista();
|
||||||
|
cargarDatos();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cargarDatos() {
|
||||||
|
List<HoursWorked> listaDeHorasTrabajadas = obtenerDatos(); // Obtenemos la lista aquí
|
||||||
|
grid.setItems(actividades);
|
||||||
|
|
||||||
|
double totalHoras = calcularTotalHoras(listaDeHorasTrabajadas); // Pasa la lista aquí
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setEmployeeComboBoxProperties() {
|
private void setEmployeeComboBoxProperties() {
|
||||||
@ -68,6 +81,10 @@ public class HoursWorkedView extends VerticalLayout {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getWeekOfYear(LocalDate date) {
|
||||||
|
return date.get(IsoFields.WEEK_OF_WEEK_BASED_YEAR);
|
||||||
|
}
|
||||||
|
|
||||||
private void configurarVista() {
|
private void configurarVista() {
|
||||||
DatePicker fechaPicker = new DatePicker("Selecciona una fecha");
|
DatePicker fechaPicker = new DatePicker("Selecciona una fecha");
|
||||||
fechaPicker.addValueChangeListener(event -> {
|
fechaPicker.addValueChangeListener(event -> {
|
||||||
@ -76,9 +93,14 @@ public class HoursWorkedView extends VerticalLayout {
|
|||||||
selectedStartOfWeek = getStartOfWeek(selectedDate);
|
selectedStartOfWeek = getStartOfWeek(selectedDate);
|
||||||
LocalDate endOfWeek = selectedStartOfWeek.plusDays(6);
|
LocalDate endOfWeek = selectedStartOfWeek.plusDays(6);
|
||||||
fechasLabel.setText("Semana del " + selectedStartOfWeek + " al " + endOfWeek);
|
fechasLabel.setText("Semana del " + selectedStartOfWeek + " al " + endOfWeek);
|
||||||
|
weekNumber = getWeekOfYear(selectedDate);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Button verMesButton = new Button("Ver Mes", event -> {
|
||||||
|
getUI().ifPresent(ui -> ui.navigate(HoursWorkedMonthView.class));
|
||||||
|
});
|
||||||
|
|
||||||
ComboBox<String> equipoDropdown = new ComboBox<>("Equipo");
|
ComboBox<String> equipoDropdown = new ComboBox<>("Equipo");
|
||||||
equipoDropdown.setItems("Equipo 1", "Equipo 2", "Equipo 3");
|
equipoDropdown.setItems("Equipo 1", "Equipo 2", "Equipo 3");
|
||||||
equipoDropdown.setWidth("250px");
|
equipoDropdown.setWidth("250px");
|
||||||
@ -92,13 +114,17 @@ public class HoursWorkedView extends VerticalLayout {
|
|||||||
HorizontalLayout actividadFormLayout = configurarFormularioActividades();
|
HorizontalLayout actividadFormLayout = configurarFormularioActividades();
|
||||||
|
|
||||||
Button actualizarButton = new Button("Actualizar Totales", event -> actualizarTotales());
|
Button actualizarButton = new Button("Actualizar Totales", event -> actualizarTotales());
|
||||||
Button guardarButton = new Button("Guardar");
|
Button guardarButton = new Button("Guardar", event -> guardarActividades());
|
||||||
Button cerrarButton = new Button("Cerrar");
|
Button cerrarButton = new Button("Cerrar", event -> this.closeView());
|
||||||
|
|
||||||
HorizontalLayout buttonsLayout = new HorizontalLayout(actualizarButton, guardarButton, cerrarButton);
|
HorizontalLayout buttonsLayout = new HorizontalLayout(actualizarButton, guardarButton, cerrarButton, verMesButton);
|
||||||
|
|
||||||
|
VerticalLayout totalesLayout = new VerticalLayout(totalCompletadoLabel, horasPendientesLabel);
|
||||||
|
totalesLayout.setSpacing(true);
|
||||||
|
totalesLayout.setPadding(true);
|
||||||
|
|
||||||
|
add(fechaPicker, fechasLabel, filtersLayout, grid, actividadFormLayout, buttonsLayout, totalesLayout);
|
||||||
|
|
||||||
add(fechaPicker, fechasLabel, filtersLayout, grid, actividadFormLayout, buttonsLayout, totalsGrid);
|
|
||||||
configurarTablaTotales();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void configurarGrid() {
|
private void configurarGrid() {
|
||||||
@ -117,25 +143,27 @@ public class HoursWorkedView extends VerticalLayout {
|
|||||||
|
|
||||||
private HorizontalLayout configurarFormularioActividades() {
|
private HorizontalLayout configurarFormularioActividades() {
|
||||||
TextField actividadNombre = new TextField("Actividad");
|
TextField actividadNombre = new TextField("Actividad");
|
||||||
TextField lunesHoras = new TextField("Lunes");
|
actividadNombre.setWidth("200px");
|
||||||
TextField martesHoras = new TextField("Martes");
|
|
||||||
TextField miercolesHoras = new TextField("Miércoles");
|
TextField lunesHoras = crearCampoHora("Lunes");
|
||||||
TextField juevesHoras = new TextField("Jueves");
|
TextField martesHoras = crearCampoHora("Martes");
|
||||||
TextField viernesHoras = new TextField("Viernes");
|
TextField miercolesHoras = crearCampoHora("Miércoles");
|
||||||
TextField sabadoHoras = new TextField("Sábado");
|
TextField juevesHoras = crearCampoHora("Jueves");
|
||||||
TextField domingoHoras = new TextField("Domingo");
|
TextField viernesHoras = crearCampoHora("Viernes");
|
||||||
|
TextField sabadoHoras = crearCampoHora("Sábado");
|
||||||
|
TextField domingoHoras = crearCampoHora("Domingo");
|
||||||
|
|
||||||
Button agregarActividadButton = new Button("Agregar Actividad", e -> {
|
Button agregarActividadButton = new Button("Agregar Actividad", e -> {
|
||||||
try {
|
try {
|
||||||
Actividad nuevaActividad = new Actividad.Builder()
|
Actividad nuevaActividad = new Actividad.Builder()
|
||||||
.nombre(actividadNombre.getValue())
|
.nombre(actividadNombre.getValue())
|
||||||
.lunes(Double.parseDouble(lunesHoras.getValue()))
|
.lunes(parseHoras(lunesHoras.getValue()))
|
||||||
.martes(Double.parseDouble(martesHoras.getValue()))
|
.martes(parseHoras(martesHoras.getValue()))
|
||||||
.miercoles(Double.parseDouble(miercolesHoras.getValue()))
|
.miercoles(parseHoras(miercolesHoras.getValue()))
|
||||||
.jueves(Double.parseDouble(juevesHoras.getValue()))
|
.jueves(parseHoras(juevesHoras.getValue()))
|
||||||
.viernes(Double.parseDouble(viernesHoras.getValue()))
|
.viernes(parseHoras(viernesHoras.getValue()))
|
||||||
.sabado(Double.parseDouble(sabadoHoras.getValue()))
|
.sabado(parseHoras(sabadoHoras.getValue()))
|
||||||
.domingo(Double.parseDouble(domingoHoras.getValue()))
|
.domingo(parseHoras(domingoHoras.getValue()))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
actividades.add(nuevaActividad);
|
actividades.add(nuevaActividad);
|
||||||
@ -152,6 +180,20 @@ public class HoursWorkedView extends VerticalLayout {
|
|||||||
juevesHoras, viernesHoras, sabadoHoras, domingoHoras, agregarActividadButton);
|
juevesHoras, viernesHoras, sabadoHoras, domingoHoras, agregarActividadButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private TextField crearCampoHora(String placeholder) {
|
||||||
|
TextField field = new TextField(placeholder);
|
||||||
|
field.setWidth("80px");
|
||||||
|
field.setPlaceholder("0.0");
|
||||||
|
return field;
|
||||||
|
}
|
||||||
|
|
||||||
|
private double parseHoras(String value) {
|
||||||
|
if (value == null || value.trim().isEmpty()) {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
return Double.parseDouble(value);
|
||||||
|
}
|
||||||
|
|
||||||
private LocalDate getStartOfWeek(final LocalDate date) {
|
private LocalDate getStartOfWeek(final LocalDate date) {
|
||||||
WeekFields weekFields = WeekFields.of(Locale.getDefault());
|
WeekFields weekFields = WeekFields.of(Locale.getDefault());
|
||||||
return date.with(weekFields.dayOfWeek(), DayOfWeek.MONDAY.getValue());
|
return date.with(weekFields.dayOfWeek(), DayOfWeek.MONDAY.getValue());
|
||||||
@ -162,174 +204,35 @@ public class HoursWorkedView extends VerticalLayout {
|
|||||||
+ actividad.getJueves() + actividad.getViernes() + actividad.getSabado() + actividad.getDomingo();
|
+ actividad.getJueves() + actividad.getViernes() + actividad.getSabado() + actividad.getDomingo();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void configurarTablaTotales() {
|
|
||||||
totalsGrid.removeAllColumns();
|
|
||||||
totalsGrid.addColumn(Actividad::getNombre).setHeader("Descripción");
|
|
||||||
totalsGrid.addColumn(Actividad::getLunes).setHeader("Lunes");
|
|
||||||
totalsGrid.addColumn(Actividad::getMartes).setHeader("Martes");
|
|
||||||
totalsGrid.addColumn(Actividad::getMiercoles).setHeader("Miércoles");
|
|
||||||
totalsGrid.addColumn(Actividad::getJueves).setHeader("Jueves");
|
|
||||||
totalsGrid.addColumn(Actividad::getViernes).setHeader("Viernes");
|
|
||||||
totalsGrid.addColumn(Actividad::getSabado).setHeader("Sábado");
|
|
||||||
totalsGrid.addColumn(Actividad::getDomingo).setHeader("Domingo");
|
|
||||||
totalsGrid.addColumn(this::calcularTotalPorSemana).setHeader("Total");
|
|
||||||
|
|
||||||
totalsGrid.setItems(calcularTotales());
|
|
||||||
}
|
|
||||||
private double calcularTotalPorSemana(final Actividad actividad) {
|
|
||||||
return actividad.getLunes() + actividad.getMartes() + actividad.getMiercoles()
|
|
||||||
+ actividad.getJueves() + actividad.getViernes() + actividad.getSabado()
|
|
||||||
+ actividad.getDomingo();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private List<Actividad> calcularTotales() {
|
|
||||||
Actividad totalActividad = new Actividad.Builder()
|
|
||||||
.nombre("Total Semanal")
|
|
||||||
.lunes(actividades.stream().mapToDouble(Actividad::getLunes).sum())
|
|
||||||
.martes(actividades.stream().mapToDouble(Actividad::getMartes).sum())
|
|
||||||
.miercoles(actividades.stream().mapToDouble(Actividad::getMiercoles).sum())
|
|
||||||
.jueves(actividades.stream().mapToDouble(Actividad::getJueves).sum())
|
|
||||||
.viernes(actividades.stream().mapToDouble(Actividad::getViernes).sum())
|
|
||||||
.sabado(actividades.stream().mapToDouble(Actividad::getSabado).sum())
|
|
||||||
.domingo(actividades.stream().mapToDouble(Actividad::getDomingo).sum())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
return List.of(totalActividad);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void actualizarTotales() {
|
private void actualizarTotales() {
|
||||||
double totalLunes = actividades.stream().mapToDouble(Actividad::getLunes).sum();
|
double totalSemanaCompletada = actividades.stream()
|
||||||
double totalMartes = actividades.stream().mapToDouble(Actividad::getMartes).sum();
|
.mapToDouble(this::calcularTotalPorDia)
|
||||||
double totalMiercoles = actividades.stream().mapToDouble(Actividad::getMiercoles).sum();
|
.sum();
|
||||||
double totalJueves = actividades.stream().mapToDouble(Actividad::getJueves).sum();
|
|
||||||
double totalViernes = actividades.stream().mapToDouble(Actividad::getViernes).sum();
|
|
||||||
double totalSabado = actividades.stream().mapToDouble(Actividad::getSabado).sum();
|
|
||||||
double totalDomingo = actividades.stream().mapToDouble(Actividad::getDomingo).sum();
|
|
||||||
|
|
||||||
double totalSemanaCompletada = totalLunes + totalMartes + totalMiercoles + totalJueves + totalViernes + totalSabado + totalDomingo;
|
|
||||||
double horasPendientes = 40 - totalSemanaCompletada;
|
double horasPendientes = 40 - totalSemanaCompletada;
|
||||||
|
|
||||||
List<Actividad> totales = new ArrayList<>();
|
totalCompletadoLabel.setText("Total Hrs/Semana Completadas: " + totalSemanaCompletada);
|
||||||
totales.add(new Actividad.Builder()
|
horasPendientesLabel.setText("Horas Pendientes: " + horasPendientes);
|
||||||
.nombre("Total Hrs/Semana Completadas")
|
|
||||||
.lunes(totalSemanaCompletada)
|
|
||||||
.build());
|
|
||||||
|
|
||||||
totales.add(new Actividad.Builder()
|
|
||||||
.nombre("Total Hrs/Semana Pendientes")
|
|
||||||
.lunes(horasPendientes)
|
|
||||||
.build());
|
|
||||||
|
|
||||||
totalsGrid.setItems(totales);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class Actividad {
|
private void guardarActividades() {
|
||||||
private final String nombre;
|
HoursWorked hoursWorked = new HoursWorked();
|
||||||
private final double lunes;
|
hoursWorked.setEmployee(employeeComboBox.getValue());
|
||||||
private final double martes;
|
hoursWorked.setWeekNumber(weekNumber);
|
||||||
private final double miercoles;
|
|
||||||
private final double jueves;
|
|
||||||
private final double viernes;
|
|
||||||
private final double sabado;
|
|
||||||
private final double domingo;
|
|
||||||
|
|
||||||
private Actividad(final Builder builder) {
|
Notification.show("Actividades guardadas correctamente.");
|
||||||
this.nombre = builder.nombre;
|
}
|
||||||
this.lunes = builder.lunes;
|
|
||||||
this.martes = builder.martes;
|
|
||||||
this.miercoles = builder.miercoles;
|
|
||||||
this.jueves = builder.jueves;
|
|
||||||
this.viernes = builder.viernes;
|
|
||||||
this.sabado = builder.sabado;
|
|
||||||
this.domingo = builder.domingo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder {
|
private double calcularTotalHoras(List<HoursWorked> listaDeHorasTrabajadas) {
|
||||||
private String nombre;
|
return listaDeHorasTrabajadas.stream()
|
||||||
private double lunes;
|
.mapToDouble(HoursWorked::getTotalHours)
|
||||||
private double martes;
|
.sum();
|
||||||
private double miercoles;
|
}
|
||||||
private double jueves;
|
|
||||||
private double viernes;
|
|
||||||
private double sabado;
|
|
||||||
private double domingo;
|
|
||||||
|
|
||||||
public Builder nombre(final String nombre) {
|
private List<HoursWorked> obtenerDatos() {
|
||||||
this.nombre = nombre;
|
return new ArrayList<>();
|
||||||
return this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Builder lunes(final double lunes) {
|
private void closeView() {
|
||||||
this.lunes = lunes;
|
getUI().ifPresent(ui -> ui.navigate(HoursWorkedView.class));
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder martes(final double martes) {
|
|
||||||
this.martes = martes;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder miercoles(final double miercoles) {
|
|
||||||
this.miercoles = miercoles;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder jueves(final double jueves) {
|
|
||||||
this.jueves = jueves;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder viernes(final double viernes) {
|
|
||||||
this.viernes = viernes;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder sabado(final double sabado) {
|
|
||||||
this.sabado = sabado;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder domingo(final double domingo) {
|
|
||||||
this.domingo = domingo;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Actividad build() {
|
|
||||||
return new Actividad(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNombre() {
|
|
||||||
return nombre;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getLunes() {
|
|
||||||
return lunes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getMartes() {
|
|
||||||
return martes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getMiercoles() {
|
|
||||||
return miercoles;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getJueves() {
|
|
||||||
return jueves;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getViernes() {
|
|
||||||
return viernes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getSabado() {
|
|
||||||
return sabado;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getDomingo() {
|
|
||||||
return domingo;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,13 +1,18 @@
|
|||||||
package com.primefactorsolutions.views;
|
package com.primefactorsolutions.views;
|
||||||
|
|
||||||
import com.primefactorsolutions.model.Employee;
|
import com.primefactorsolutions.model.Employee;
|
||||||
|
import com.vaadin.flow.component.Text;
|
||||||
import com.vaadin.flow.component.applayout.AppLayout;
|
import com.vaadin.flow.component.applayout.AppLayout;
|
||||||
import com.vaadin.flow.component.applayout.DrawerToggle;
|
import com.vaadin.flow.component.applayout.DrawerToggle;
|
||||||
import com.vaadin.flow.component.button.Button;
|
import com.vaadin.flow.component.avatar.Avatar;
|
||||||
import com.vaadin.flow.component.html.Footer;
|
import com.vaadin.flow.component.contextmenu.HasMenuItems;
|
||||||
import com.vaadin.flow.component.html.H1;
|
import com.vaadin.flow.component.contextmenu.MenuItem;
|
||||||
import com.vaadin.flow.component.html.Header;
|
import com.vaadin.flow.component.contextmenu.SubMenu;
|
||||||
import com.vaadin.flow.component.html.Span;
|
import com.vaadin.flow.component.html.*;
|
||||||
|
import com.vaadin.flow.component.icon.Icon;
|
||||||
|
import com.vaadin.flow.component.icon.VaadinIcon;
|
||||||
|
import com.vaadin.flow.component.menubar.MenuBar;
|
||||||
|
import com.vaadin.flow.component.menubar.MenuBarVariant;
|
||||||
import com.vaadin.flow.component.orderedlayout.FlexComponent;
|
import com.vaadin.flow.component.orderedlayout.FlexComponent;
|
||||||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
||||||
import com.vaadin.flow.component.orderedlayout.Scroller;
|
import com.vaadin.flow.component.orderedlayout.Scroller;
|
||||||
@ -38,55 +43,85 @@ public class MainLayout extends AppLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addHeaderContent() {
|
private void addHeaderContent() {
|
||||||
DrawerToggle toggle = new DrawerToggle();
|
final DrawerToggle toggle = new DrawerToggle();
|
||||||
toggle.setAriaLabel("Menu toggle");
|
toggle.setAriaLabel("Menu toggle");
|
||||||
|
|
||||||
viewTitle = new H1();
|
viewTitle = new H1();
|
||||||
viewTitle.addClassNames(LumoUtility.FontSize.LARGE, LumoUtility.Margin.NONE);
|
viewTitle.addClassNames(LumoUtility.FontSize.LARGE, LumoUtility.Margin.NONE);
|
||||||
|
|
||||||
HorizontalLayout
|
final HorizontalLayout header = authContext.getAuthenticatedUser(UserDetails.class)
|
||||||
header =
|
.map(user -> {
|
||||||
authContext.getAuthenticatedUser(UserDetails.class)
|
final Avatar loggedUser = new Avatar(user.getUsername());
|
||||||
.map(user -> {
|
loggedUser.getStyle().set("display", "block");
|
||||||
final Button logout = new Button("Logout", click -> this.authContext.logout());
|
loggedUser.getElement().setAttribute("tabindex", "-1");
|
||||||
final Span loggedUser = new Span("Welcome " + user.getUsername());
|
final MenuBar menuBar = new MenuBar();
|
||||||
String employeeId = "N/A";
|
menuBar.addThemeVariants(MenuBarVariant.LUMO_ICON);
|
||||||
|
final MenuItem actions = createIconItem(menuBar, VaadinIcon.ELLIPSIS_V, null, "",
|
||||||
|
false);
|
||||||
|
final SubMenu actionsSubMenu = actions.getSubMenu();
|
||||||
|
final MenuItem signOutMenuItem = createIconItem(actionsSubMenu, VaadinIcon.EXIT, "Sign-out",
|
||||||
|
null, true);
|
||||||
|
signOutMenuItem.addClickListener(c -> this.authContext.logout());
|
||||||
|
|
||||||
if (user instanceof Employee) {
|
String employeeId = "N/A";
|
||||||
final UUID uuid = ((Employee) user).getId();
|
|
||||||
|
|
||||||
if (uuid != null) {
|
if (user instanceof Employee) {
|
||||||
employeeId = uuid.toString();
|
final UUID uuid = ((Employee) user).getId();
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final Tooltip tooltip = Tooltip.forComponent(loggedUser)
|
if (uuid != null) {
|
||||||
.withText("Employee id: " + employeeId)
|
employeeId = uuid.toString();
|
||||||
.withPosition(Tooltip.TooltipPosition.TOP_START);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final HorizontalLayout hl = new HorizontalLayout(loggedUser, logout);
|
final Tooltip tooltip = Tooltip.forComponent(loggedUser)
|
||||||
hl.setJustifyContentMode(FlexComponent.JustifyContentMode.END);
|
.withText("Employee id: " + employeeId)
|
||||||
|
.withPosition(Tooltip.TooltipPosition.TOP_START);
|
||||||
|
|
||||||
return hl;
|
final HorizontalLayout hl = new HorizontalLayout(loggedUser, menuBar);
|
||||||
}).orElseGet(HorizontalLayout::new);
|
hl.setJustifyContentMode(FlexComponent.JustifyContentMode.END);
|
||||||
|
|
||||||
|
return hl;
|
||||||
|
}).orElseGet(HorizontalLayout::new);
|
||||||
header.setAlignItems(FlexComponent.Alignment.STRETCH);
|
header.setAlignItems(FlexComponent.Alignment.STRETCH);
|
||||||
header.setWidthFull();
|
header.setWidthFull();
|
||||||
|
|
||||||
addToNavbar(true, toggle, viewTitle, header);
|
addToNavbar(true, toggle, viewTitle, header);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private MenuItem createIconItem(final HasMenuItems menu, final VaadinIcon iconName,
|
||||||
|
final String label, final String ariaLabel, final boolean isChild) {
|
||||||
|
final Icon icon = new Icon(iconName);
|
||||||
|
|
||||||
|
if (isChild) {
|
||||||
|
icon.getStyle().set("width", "var(--lumo-icon-size-s)");
|
||||||
|
icon.getStyle().set("height", "var(--lumo-icon-size-s)");
|
||||||
|
icon.getStyle().set("marginRight", "var(--lumo-space-s)");
|
||||||
|
}
|
||||||
|
|
||||||
|
final MenuItem item = menu.addItem(icon, e -> {
|
||||||
|
});
|
||||||
|
|
||||||
|
if (ariaLabel != null) {
|
||||||
|
item.setAriaLabel(ariaLabel);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (label != null) {
|
||||||
|
item.add(new Text(label));
|
||||||
|
}
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
private void addDrawerContent() {
|
private void addDrawerContent() {
|
||||||
Span appName = new Span("pfs-intra");
|
final Span appName = new Span("pfs-intra");
|
||||||
appName.addClassNames(LumoUtility.FontWeight.SEMIBOLD, LumoUtility.FontSize.LARGE);
|
appName.addClassNames(LumoUtility.FontWeight.SEMIBOLD, LumoUtility.FontSize.LARGE);
|
||||||
Header header = new Header(appName);
|
final Header header = new Header(appName);
|
||||||
|
final Scroller scroller = new Scroller(createNavigation());
|
||||||
Scroller scroller = new Scroller(createNavigation());
|
|
||||||
|
|
||||||
addToDrawer(header, scroller, createFooter());
|
addToDrawer(header, scroller, createFooter());
|
||||||
}
|
}
|
||||||
|
|
||||||
private SideNav createNavigation() {
|
private SideNav createNavigation() {
|
||||||
SideNav nav = new SideNav();
|
final SideNav nav = new SideNav();
|
||||||
|
|
||||||
authContext.getAuthenticatedUser(UserDetails.class).ifPresent(u -> {
|
authContext.getAuthenticatedUser(UserDetails.class).ifPresent(u -> {
|
||||||
SideNavItem recruiting = new SideNavItem("Recruiting", MainView.class,
|
SideNavItem recruiting = new SideNavItem("Recruiting", MainView.class,
|
||||||
@ -99,7 +134,7 @@ public class MainLayout extends AppLayout {
|
|||||||
LineAwesomeIcon.QUESTION_SOLID.create()));
|
LineAwesomeIcon.QUESTION_SOLID.create()));
|
||||||
|
|
||||||
SideNavItem admin = new SideNavItem("Admin", MainView.class,
|
SideNavItem admin = new SideNavItem("Admin", MainView.class,
|
||||||
LineAwesomeIcon.SUPERSCRIPT_SOLID.create());
|
LineAwesomeIcon.BUILDING.create());
|
||||||
admin.addItem(new SideNavItem("Employees", EmployeesListView.class,
|
admin.addItem(new SideNavItem("Employees", EmployeesListView.class,
|
||||||
LineAwesomeIcon.USER_EDIT_SOLID.create()));
|
LineAwesomeIcon.USER_EDIT_SOLID.create()));
|
||||||
admin.addItem(new SideNavItem("Documents", DocumentsListView.class,
|
admin.addItem(new SideNavItem("Documents", DocumentsListView.class,
|
||||||
@ -129,9 +164,7 @@ public class MainLayout extends AppLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Footer createFooter() {
|
private Footer createFooter() {
|
||||||
Footer layout = new Footer();
|
return new Footer();
|
||||||
|
|
||||||
return layout;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,185 @@
|
|||||||
|
package com.primefactorsolutions.views;
|
||||||
|
|
||||||
|
import com.primefactorsolutions.model.*;
|
||||||
|
import com.primefactorsolutions.service.EmployeeService;
|
||||||
|
import com.primefactorsolutions.service.TimeOffRequestService;
|
||||||
|
import com.vaadin.flow.component.button.Button;
|
||||||
|
import com.vaadin.flow.component.combobox.ComboBox;
|
||||||
|
import com.vaadin.flow.component.grid.Grid;
|
||||||
|
import com.vaadin.flow.component.html.Div;
|
||||||
|
import com.vaadin.flow.component.html.H3;
|
||||||
|
import com.vaadin.flow.component.html.Span;
|
||||||
|
import com.vaadin.flow.component.notification.Notification;
|
||||||
|
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
||||||
|
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
||||||
|
import com.vaadin.flow.router.BeforeEvent;
|
||||||
|
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 jakarta.annotation.security.PermitAll;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@SpringComponent
|
||||||
|
@PermitAll
|
||||||
|
@Scope("prototype")
|
||||||
|
@PageTitle("RequestEmployee")
|
||||||
|
@Route(value = "/requests", layout = MainLayout.class)
|
||||||
|
public class RequestEmployeeView extends Div implements HasUrlParameter<String> {
|
||||||
|
|
||||||
|
private final TimeOffRequestService requestService;
|
||||||
|
private final EmployeeService employeeService;
|
||||||
|
private final Grid<TimeOffRequest> requestGrid = new Grid<>(TimeOffRequest.class);
|
||||||
|
private List<TimeOffRequest> requests = Collections.emptyList();
|
||||||
|
private ComboBox<TimeOffRequestType> categoryFilter;
|
||||||
|
private ComboBox<TimeOffRequestStatus> stateFilter;
|
||||||
|
private UUID employeeId;
|
||||||
|
private TimeOffRequest request;
|
||||||
|
|
||||||
|
public RequestEmployeeView(final TimeOffRequestService requestService, final EmployeeService employeeService) {
|
||||||
|
this.requestService = requestService;
|
||||||
|
this.employeeService = employeeService;
|
||||||
|
initializeView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeView() {
|
||||||
|
setupFilters();
|
||||||
|
setupGrid();
|
||||||
|
add(requestGrid, createSummaryLayout(), createActionButtons());
|
||||||
|
refreshRequestGrid(null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupFilters() {
|
||||||
|
categoryFilter = createCategoryFilter();
|
||||||
|
stateFilter = createStateFilter();
|
||||||
|
add(categoryFilter, stateFilter);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ComboBox<TimeOffRequestType> createCategoryFilter() {
|
||||||
|
categoryFilter = new ComboBox<>("Category");
|
||||||
|
categoryFilter.setItems(TimeOffRequestType.values());
|
||||||
|
categoryFilter.setValue(TimeOffRequestType.values()[0]);
|
||||||
|
categoryFilter.addValueChangeListener(event -> refreshRequestGrid(event.getValue(), stateFilter.getValue()));
|
||||||
|
return categoryFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ComboBox<TimeOffRequestStatus> createStateFilter() {
|
||||||
|
stateFilter = new ComboBox<>("State");
|
||||||
|
stateFilter.setItems(TimeOffRequestStatus.values());
|
||||||
|
stateFilter.setValue(TimeOffRequestStatus.values()[0]);
|
||||||
|
stateFilter.addValueChangeListener(event -> refreshRequestGrid(categoryFilter.getValue(), event.getValue()));
|
||||||
|
return stateFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupGrid() {
|
||||||
|
requestGrid.setColumns(
|
||||||
|
"category",
|
||||||
|
"state",
|
||||||
|
"availableDays",
|
||||||
|
"expiration",
|
||||||
|
"startDate",
|
||||||
|
"endDate",
|
||||||
|
"daysToBeTake",
|
||||||
|
"daysBalance"
|
||||||
|
);
|
||||||
|
requestGrid.setAllRowsVisible(true);
|
||||||
|
requestGrid.asSingleSelect().addValueChangeListener(event -> {
|
||||||
|
TimeOffRequest selectedRequest = event.getValue();
|
||||||
|
if (selectedRequest != null) {
|
||||||
|
request = selectedRequest;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private VerticalLayout createSummaryLayout() {
|
||||||
|
int totalVacations = 15;
|
||||||
|
int totalTimeOff = 2;
|
||||||
|
int totalAvailableDays = totalVacations + totalTimeOff;
|
||||||
|
return new VerticalLayout(
|
||||||
|
new Span("TOTAL HOLIDAYS: " + totalVacations),
|
||||||
|
new Span("TOTAL TIME OFF: " + totalTimeOff),
|
||||||
|
new Span("TOTAL AVAILABLE DAYS: " + totalAvailableDays)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private HorizontalLayout createActionButtons() {
|
||||||
|
Button viewButton = new Button("View", event -> {
|
||||||
|
if (request != null) {
|
||||||
|
navigateToViewRequest(request);
|
||||||
|
} else {
|
||||||
|
Notification.show("Please select a request to view.", 3000, Notification.Position.MIDDLE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Button editButton = new Button("Edit", event -> {
|
||||||
|
if (request != null) {
|
||||||
|
navigateToEditRequest(request);
|
||||||
|
} else {
|
||||||
|
Notification.show("Please select a request to view.", 3000, Notification.Position.MIDDLE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Button closeButton = new Button("Close", event -> navigateToRequestsListView());
|
||||||
|
return new HorizontalLayout(viewButton, editButton, closeButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void navigateToRequestsListView() {
|
||||||
|
getUI().ifPresent(ui -> ui.navigate(RequestsListView.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void navigateToEditRequest(final TimeOffRequest request) {
|
||||||
|
navigateToRequestView(request, "edit");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void navigateToViewRequest(final TimeOffRequest request) {
|
||||||
|
navigateToRequestView(request, "view");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void navigateToRequestView(final TimeOffRequest request, final String action) {
|
||||||
|
getUI().ifPresent(ui -> ui.navigate(RequestView.class, request.getId().toString() + "/" + action));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void refreshRequestGrid(final TimeOffRequestType category, final TimeOffRequestStatus state) {
|
||||||
|
List<TimeOffRequest> filteredRequests = allFiltersAreNull(category, state)
|
||||||
|
? requestService.findRequestsByEmployeeId(employeeId)
|
||||||
|
: fetchFilteredTimeOffRequests(category, state);
|
||||||
|
requestGrid.setItems(filteredRequests);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean allFiltersAreNull(final TimeOffRequestType category, final TimeOffRequestStatus state) {
|
||||||
|
return category == null && state == null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<TimeOffRequest> fetchFilteredTimeOffRequests(final TimeOffRequestType category,
|
||||||
|
final TimeOffRequestStatus state) {
|
||||||
|
requests = requestService.findRequestsByEmployeeId(employeeId);
|
||||||
|
if (category != null && !"ALL".equals(category.name())) {
|
||||||
|
requests = requests.stream()
|
||||||
|
.filter(req -> req.getCategory().equals(category))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
if (state != null && !"ALL".equals(state.name())) {
|
||||||
|
requests = requests.stream()
|
||||||
|
.filter(req -> req.getState().equals(state))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
return requests;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setParameter(final BeforeEvent event, final String parameter) {
|
||||||
|
employeeId = UUID.fromString(parameter);
|
||||||
|
Employee employee = employeeService.getEmployee(employeeId);
|
||||||
|
requests = requestService.findRequestsByEmployeeId(employeeId);
|
||||||
|
setViewTitle(employee.getFirstName() + " " + employee.getLastName(), employee.getTeam().getName());
|
||||||
|
requestGrid.setItems(requests);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setViewTitle(final String employeeName, final String employeeTeam) {
|
||||||
|
addComponentAsFirst(new H3("Name: " + employeeName));
|
||||||
|
addComponentAtIndex(1, new H3("Team: " + employeeTeam));
|
||||||
|
}
|
||||||
|
}
|
160
src/main/java/com/primefactorsolutions/views/RequestView.java
Normal file
160
src/main/java/com/primefactorsolutions/views/RequestView.java
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
package com.primefactorsolutions.views;
|
||||||
|
|
||||||
|
import com.primefactorsolutions.model.*;
|
||||||
|
import com.primefactorsolutions.service.EmployeeService;
|
||||||
|
import com.primefactorsolutions.service.TeamService;
|
||||||
|
import com.primefactorsolutions.service.TimeOffRequestService;
|
||||||
|
import com.vaadin.flow.component.Component;
|
||||||
|
import com.vaadin.flow.component.button.Button;
|
||||||
|
import com.vaadin.flow.component.combobox.ComboBox;
|
||||||
|
import com.vaadin.flow.component.datepicker.DatePicker;
|
||||||
|
import com.vaadin.flow.component.html.H3;
|
||||||
|
import com.vaadin.flow.component.notification.Notification;
|
||||||
|
import com.vaadin.flow.component.textfield.NumberField;
|
||||||
|
import com.vaadin.flow.router.*;
|
||||||
|
import com.vaadin.flow.spring.annotation.SpringComponent;
|
||||||
|
import jakarta.annotation.security.PermitAll;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.vaadin.firitin.form.BeanValidationForm;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@SpringComponent
|
||||||
|
@PermitAll
|
||||||
|
@Scope("prototype")
|
||||||
|
@PageTitle("Request")
|
||||||
|
@Route(value = "/requests/:requestId?/:action?", layout = MainLayout.class)
|
||||||
|
public class RequestView extends BeanValidationForm<TimeOffRequest> implements HasUrlParameter<String> {
|
||||||
|
|
||||||
|
private final ComboBox<TimeOffRequestStatus> state = new ComboBox<>("State");
|
||||||
|
private final DatePicker expiration = new DatePicker("Expiration");
|
||||||
|
private final DatePicker startDate = new DatePicker("Start Date");
|
||||||
|
private final DatePicker endDate = new DatePicker("End Date");
|
||||||
|
private final NumberField availableDays = new NumberField("Available Days");
|
||||||
|
private final NumberField daysToBeTake = new NumberField("Days To Be Take");
|
||||||
|
|
||||||
|
private final TimeOffRequestService requestService;
|
||||||
|
private final EmployeeService employeeService;
|
||||||
|
private TimeOffRequest request;
|
||||||
|
private Employee employee;
|
||||||
|
|
||||||
|
private Button saveButton;
|
||||||
|
|
||||||
|
public RequestView(final TimeOffRequestService requestService,
|
||||||
|
final EmployeeService employeeService,
|
||||||
|
final TeamService teamService) {
|
||||||
|
super(TimeOffRequest.class);
|
||||||
|
this.requestService = requestService;
|
||||||
|
this.employeeService = employeeService;
|
||||||
|
state.setItems(List.of(TimeOffRequestStatus.values()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setParameter(final BeforeEvent beforeEvent, final String action) {
|
||||||
|
final RouteParameters params = beforeEvent.getRouteParameters();
|
||||||
|
final String requestIdString = params.get("requestId").orElse(null);
|
||||||
|
|
||||||
|
if ("new".equals(action)) {
|
||||||
|
setEntityWithEnabledSave(new TimeOffRequest());
|
||||||
|
} else {
|
||||||
|
assert requestIdString != null;
|
||||||
|
UUID requestId = UUID.fromString(requestIdString);
|
||||||
|
request = requestService.findTimeOffRequest(requestId);
|
||||||
|
UUID employeeId = request.getEmployee().getId();
|
||||||
|
employee = employeeService.getEmployee(employeeId);
|
||||||
|
setEntity(request);
|
||||||
|
configureViewOrEditAction(action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<Component> getFormComponents() {
|
||||||
|
return List.of(
|
||||||
|
createEmployeeHeader(),
|
||||||
|
createTeamHeader(),
|
||||||
|
createCategoryHeader(),
|
||||||
|
state,
|
||||||
|
expiration,
|
||||||
|
startDate,
|
||||||
|
endDate,
|
||||||
|
availableDays,
|
||||||
|
daysToBeTake,
|
||||||
|
createCloseButton()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Button createSaveButton() {
|
||||||
|
saveButton = new Button("Save");
|
||||||
|
saveButton.addClickListener(event -> saveRequest());
|
||||||
|
return saveButton;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Button createCloseButton() {
|
||||||
|
Button closeButton = new Button("Close");
|
||||||
|
closeButton.addClickListener(event -> closeForm());
|
||||||
|
return closeButton;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setFieldsReadOnly(final boolean option) {
|
||||||
|
state.setReadOnly(option);
|
||||||
|
expiration.setReadOnly(option);
|
||||||
|
startDate.setReadOnly(option);
|
||||||
|
endDate.setReadOnly(option);
|
||||||
|
availableDays.setReadOnly(option);
|
||||||
|
daysToBeTake.setReadOnly(option);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveRequest() {
|
||||||
|
if (isFormValid()) {
|
||||||
|
TimeOffRequest request = getEntity();
|
||||||
|
setRequestFieldValues(request);
|
||||||
|
requestService.saveTimeOffRequest(request);
|
||||||
|
Notification.show("Request saved successfully.");
|
||||||
|
closeForm();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setRequestFieldValues(final TimeOffRequest request) {
|
||||||
|
request.setState(state.getValue());
|
||||||
|
request.setExpiration(expiration.getValue());
|
||||||
|
request.setStartDate(startDate.getValue());
|
||||||
|
request.setEndDate(endDate.getValue());
|
||||||
|
request.setAvailableDays(availableDays.getValue());
|
||||||
|
request.setDaysToBeTake(daysToBeTake.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void closeForm() {
|
||||||
|
getUI().ifPresent(ui -> ui.navigate("requests/" + employee.getId().toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isFormValid() {
|
||||||
|
return !state.isEmpty()
|
||||||
|
&& expiration.getValue() != null
|
||||||
|
&& startDate.getValue() != null
|
||||||
|
&& endDate.getValue() != null
|
||||||
|
&& availableDays.getValue() != null
|
||||||
|
&& daysToBeTake.getValue() != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void configureViewOrEditAction(final String action) {
|
||||||
|
if ("edit".equals(action) && !request.getId().toString().isEmpty()) {
|
||||||
|
setFieldsReadOnly(false);
|
||||||
|
} else if ("view".equals(action) && !request.getId().toString().isEmpty()) {
|
||||||
|
setFieldsReadOnly(true);
|
||||||
|
saveButton.setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private H3 createEmployeeHeader() {
|
||||||
|
return new H3("Employee: " + employee.getFirstName() + " " + employee.getLastName());
|
||||||
|
}
|
||||||
|
|
||||||
|
private H3 createTeamHeader() {
|
||||||
|
return new H3("Team: " + employee.getTeam().getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
private H3 createCategoryHeader() {
|
||||||
|
return new H3("Category: " + request.getCategory());
|
||||||
|
}
|
||||||
|
}
|
@ -6,11 +6,9 @@ import com.primefactorsolutions.service.TeamService;
|
|||||||
import com.primefactorsolutions.service.TimeOffRequestService;
|
import com.primefactorsolutions.service.TimeOffRequestService;
|
||||||
import com.vaadin.flow.component.button.Button;
|
import com.vaadin.flow.component.button.Button;
|
||||||
import com.vaadin.flow.component.combobox.ComboBox;
|
import com.vaadin.flow.component.combobox.ComboBox;
|
||||||
import com.vaadin.flow.component.grid.GridSortOrder;
|
|
||||||
import com.vaadin.flow.component.html.Main;
|
import com.vaadin.flow.component.html.Main;
|
||||||
import com.vaadin.flow.component.html.Span;
|
import com.vaadin.flow.component.notification.Notification;
|
||||||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
||||||
import com.vaadin.flow.data.provider.SortDirection;
|
|
||||||
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;
|
||||||
@ -18,7 +16,8 @@ import jakarta.annotation.security.PermitAll;
|
|||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.vaadin.firitin.components.grid.PagingGrid;
|
import org.vaadin.firitin.components.grid.PagingGrid;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@SpringComponent
|
@SpringComponent
|
||||||
@Scope("prototype")
|
@Scope("prototype")
|
||||||
@ -30,11 +29,15 @@ public class RequestsListView extends Main {
|
|||||||
private final TimeOffRequestService requestService;
|
private final TimeOffRequestService requestService;
|
||||||
private final EmployeeService employeeService;
|
private final EmployeeService employeeService;
|
||||||
private final TeamService teamService;
|
private final TeamService teamService;
|
||||||
private final PagingGrid<TimeOffRequest> requestGrid;
|
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<TimeOffRequestType> categoryFilter;
|
||||||
private ComboBox<TimeOffRequest.Status> stateFilter;
|
private ComboBox<Status> stateFilter;
|
||||||
|
private UUID selectedEmployeeId;
|
||||||
|
|
||||||
|
|
||||||
public RequestsListView(final TimeOffRequestService requestService,
|
public RequestsListView(final TimeOffRequestService requestService,
|
||||||
final EmployeeService employeeService,
|
final EmployeeService employeeService,
|
||||||
@ -42,9 +45,9 @@ public class RequestsListView extends Main {
|
|||||||
this.requestService = requestService;
|
this.requestService = requestService;
|
||||||
this.employeeService = employeeService;
|
this.employeeService = employeeService;
|
||||||
this.teamService = teamService;
|
this.teamService = teamService;
|
||||||
this.requestGrid = new PagingGrid<>(TimeOffRequest.class);
|
this.employees = employeeService.findAllEmployees();
|
||||||
initializeView();
|
initializeView();
|
||||||
refreshRequestGrid(null, null, null, null);
|
refreshGeneralRequestGrid(null, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeView() {
|
private void initializeView() {
|
||||||
@ -62,97 +65,144 @@ public class RequestsListView extends Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setupRequestGrid() {
|
private void setupRequestGrid() {
|
||||||
requestGrid.setColumns(
|
requestGrid.addColumn(this::getEmployeeFullName).setHeader("Employee");
|
||||||
"category",
|
requestGrid.addColumn(this::getTeamName).setHeader("Team");
|
||||||
"state",
|
requestGrid.addColumn(this::getEmployeeStatus).setHeader("State");
|
||||||
"availableDays",
|
requestGrid.addColumn(this::getCategory).setHeader("Category");
|
||||||
"expiration",
|
requestGrid.addColumn(this::getStartDate).setHeader("Start Date");
|
||||||
"startDate",
|
requestGrid.addColumn(this::getEndDate).setHeader("End Date");
|
||||||
"endDate",
|
requestGrid.addColumn(this::getDaysBalance).setHeader("Days Balance");
|
||||||
"daysToBeTake",
|
|
||||||
"daysBalance"
|
|
||||||
);
|
|
||||||
requestGrid.addComponentColumn(this::createEmployeeSpan).setHeader("Employee");
|
|
||||||
requestGrid.addComponentColumn(this::createTeamSpan).setHeader("Team");
|
|
||||||
requestGrid.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM);
|
requestGrid.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM);
|
||||||
requestGrid.setPageSize(5);
|
requestGrid.setPageSize(5);
|
||||||
|
requestGrid.asSingleSelect().addValueChangeListener(event -> {
|
||||||
|
Employee selectedRequest = event.getValue();
|
||||||
|
if (selectedRequest != null) {
|
||||||
|
selectedEmployeeId = selectedRequest.getId();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private HorizontalLayout createActionButtons() {
|
private HorizontalLayout createActionButtons() {
|
||||||
Button viewButton = new Button("View");
|
Button viewButton = new Button("View", event -> {
|
||||||
Button editButton = new Button("Edit");
|
if (selectedEmployeeId != null) {
|
||||||
Button saveButton = new Button("Save");
|
navigateToTimeOffRequestView(selectedEmployeeId);
|
||||||
Button closeButton = new Button("Close", event -> closeView());
|
} else {
|
||||||
return new HorizontalLayout(viewButton, editButton, saveButton, closeButton);
|
Notification.show("Please select a request to view.", 3000, Notification.Position.MIDDLE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Button closeButton = new Button("Close", event -> navigateToMainView());
|
||||||
|
return new HorizontalLayout(viewButton, closeButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshRequestGrid(final Employee employee,
|
private void refreshGeneralRequestGrid(final Employee employee,
|
||||||
final Team team,
|
final Team team,
|
||||||
final TimeOffRequestType category,
|
final TimeOffRequestType category,
|
||||||
final TimeOffRequest.Status state) {
|
final Status state) {
|
||||||
requestGrid.setPagingDataProvider((page, pageSize) -> {
|
requestGrid.setPagingDataProvider((page, pageSize) -> {
|
||||||
if (allFiltersAreNull(employee, team, category, state)) {
|
int start = (int) (page * requestGrid.getPageSize());
|
||||||
return fetchTimeOffRequests((int) page, pageSize);
|
return fetchFilteredEmployees(start, pageSize, employee, team, category, state);
|
||||||
} else {
|
|
||||||
return fetchFilteredTimeOffRequests((int) page, pageSize, employee, team, category, state);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
requestGrid.getDataProvider().refreshAll();
|
requestGrid.getDataProvider().refreshAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean allFiltersAreNull(final Employee employee,
|
private List<Employee> fetchFilteredEmployees(final int start,
|
||||||
final Team team,
|
final int pageSize,
|
||||||
final TimeOffRequestType category,
|
final Employee employee,
|
||||||
final TimeOffRequest.Status state) {
|
final Team team,
|
||||||
return employee == null && team == null && category == null && state == null;
|
final TimeOffRequestType category,
|
||||||
}
|
final Status state) {
|
||||||
|
List<Employee> filteredEmployees = employeeService.findAllEmployees();
|
||||||
|
|
||||||
private List<TimeOffRequest> fetchTimeOffRequests(final int page, final int pageSize) {
|
if (employee != null && !"ALL".equals(employee.getFirstName())) {
|
||||||
int start = page * pageSize;
|
filteredEmployees = filteredEmployees.stream()
|
||||||
if (requestGrid.getSortOrder().isEmpty()) {
|
.filter(emp -> emp.getId().equals(employee.getId()))
|
||||||
return requestService.findTimeOffRequests(start, pageSize);
|
.collect(Collectors.toList());
|
||||||
} else {
|
|
||||||
return fetchSortedTimeOffRequests(start, pageSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (team != null && !"ALL".equals(team.getName())) {
|
||||||
|
filteredEmployees = filteredEmployees.stream()
|
||||||
|
.filter(emp -> emp.getTeam() != null && emp.getTeam().getId().equals(team.getId()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (category != null && category != TimeOffRequestType.values()[0]) {
|
||||||
|
filteredEmployees = filteredEmployees.stream()
|
||||||
|
.filter(emp -> {
|
||||||
|
Optional<TimeOffRequest> request = requestService
|
||||||
|
.findByEmployeeAndState(emp.getId(), TimeOffRequestStatus.TAKEN);
|
||||||
|
return request.isPresent() && request.get().getCategory() == category;
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state != null && state != Status.ALL) {
|
||||||
|
filteredEmployees = filteredEmployees.stream()
|
||||||
|
.filter(emp -> {
|
||||||
|
Optional<TimeOffRequest> request = requestService
|
||||||
|
.findByEmployeeAndState(emp.getId(), TimeOffRequestStatus.TAKEN);
|
||||||
|
return state == Status.IDLE ? request.isPresent() : request.isEmpty();
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
int end = Math.min(start + pageSize, filteredEmployees.size());
|
||||||
|
return filteredEmployees.subList(start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<TimeOffRequest> fetchSortedTimeOffRequests(final int start, final int pageSize) {
|
private String getEmployeeFullName(final Employee employee) {
|
||||||
GridSortOrder<TimeOffRequest> sortOrder = requestGrid.getSortOrder().getFirst();
|
return "ALL".equals(employee.getFirstName()) ? "ALL" : employee.getFirstName() + " " + employee.getLastName();
|
||||||
return requestService.findTimeOffRequests(
|
|
||||||
start,
|
|
||||||
pageSize,
|
|
||||||
sortOrder.getSorted().getKey(),
|
|
||||||
sortOrder.getDirection() == SortDirection.ASCENDING
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<TimeOffRequest> fetchFilteredTimeOffRequests(final int page,
|
private String getTeamName(final Employee employee) {
|
||||||
final int pageSize,
|
Team team = employee.getTeam();
|
||||||
final Employee employee,
|
return team != null ? team.getName() : "Unassigned";
|
||||||
final Team team,
|
|
||||||
final TimeOffRequestType category,
|
|
||||||
final TimeOffRequest.Status state) {
|
|
||||||
return requestService.findTimeOffRequestBy(employee, team, category, state, page, pageSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Span createEmployeeSpan(final TimeOffRequest timeOffRequest) {
|
private String getTeamLabel(final Team team) {
|
||||||
Employee employee = timeOffRequest.getEmployee();
|
return "ALL".equals(team.getName()) ? "ALL" : team.getName();
|
||||||
return new Span(employee.getFirstName() + " " + employee.getLastName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Span createTeamSpan(final TimeOffRequest timeOffRequest) {
|
|
||||||
return new Span(timeOffRequest.getTeam().getName());
|
private String getEmployeeStatus(final Employee employee) {
|
||||||
|
Optional<TimeOffRequest> activeRequest = requestService
|
||||||
|
.findByEmployeeAndState(employee.getId(), TimeOffRequestStatus.TAKEN);
|
||||||
|
return activeRequest.isPresent() ? "IDLE" : "ACTIVE";
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getCategory(final Employee employee) {
|
||||||
|
Optional<TimeOffRequest> activeRequest = requestService
|
||||||
|
.findByEmployeeAndState(employee.getId(), TimeOffRequestStatus.TAKEN);
|
||||||
|
return activeRequest.map(request -> request.getCategory().toString()).orElse("");
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getStartDate(final Employee employee) {
|
||||||
|
Optional<TimeOffRequest> activeRequest = requestService
|
||||||
|
.findByEmployeeAndState(employee.getId(), TimeOffRequestStatus.TAKEN);
|
||||||
|
return activeRequest.map(request -> request.getStartDate().toString()).orElse("");
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getEndDate(final Employee employee) {
|
||||||
|
Optional<TimeOffRequest> activeRequest = requestService
|
||||||
|
.findByEmployeeAndState(employee.getId(), TimeOffRequestStatus.TAKEN);
|
||||||
|
return activeRequest.map(request -> request.getEndDate().toString()).orElse("");
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getDaysBalance(final Employee employee) {
|
||||||
|
Optional<TimeOffRequest> activeRequest = requestService
|
||||||
|
.findByEmployeeAndState(employee.getId(), TimeOffRequestStatus.TAKEN);
|
||||||
|
return activeRequest.map(request -> request.getDaysBalance().toString()).orElse("");
|
||||||
}
|
}
|
||||||
|
|
||||||
private ComboBox<Employee> createEmployeeFilter() {
|
private ComboBox<Employee> createEmployeeFilter() {
|
||||||
employeeFilter = new ComboBox<>("Employee");
|
employeeFilter = new ComboBox<>("Employee");
|
||||||
List<Employee> employees = employeeService.findAllEmployees();
|
List<Employee> employees = new ArrayList<>(employeeService.findAllEmployees());
|
||||||
employees.addFirst(createAllEmployeesOption());
|
employees.addFirst(createAllEmployeesOption());
|
||||||
employeeFilter.setItems(employees);
|
employeeFilter.setItems(employees);
|
||||||
employeeFilter.setItemLabelGenerator(this::getEmployeeLabel);
|
employeeFilter.setItemLabelGenerator(this::getEmployeeFullName);
|
||||||
employeeFilter.setValue(employees.getFirst());
|
employeeFilter.setValue(employees.getFirst());
|
||||||
employeeFilter.addValueChangeListener(event ->
|
employeeFilter.addValueChangeListener(event ->
|
||||||
refreshRequestGrid(
|
refreshGeneralRequestGrid(
|
||||||
event.getValue(),
|
event.getValue(),
|
||||||
teamFilter.getValue(),
|
teamFilter.getValue(),
|
||||||
categoryFilter.getValue(),
|
categoryFilter.getValue(),
|
||||||
@ -164,13 +214,13 @@ public class RequestsListView extends Main {
|
|||||||
|
|
||||||
private ComboBox<Team> createTeamFilter() {
|
private ComboBox<Team> createTeamFilter() {
|
||||||
teamFilter = new ComboBox<>("Team");
|
teamFilter = new ComboBox<>("Team");
|
||||||
List<Team> teams = teamService.findAllTeams();
|
List<Team> teams = new ArrayList<>(teamService.findAllTeams());
|
||||||
teams.addFirst(createAllTeamsOption());
|
teams.addFirst(createAllTeamsOption());
|
||||||
teamFilter.setItems(teams);
|
teamFilter.setItems(teams);
|
||||||
teamFilter.setItemLabelGenerator(this::getTeamLabel);
|
teamFilter.setItemLabelGenerator(this::getTeamLabel);
|
||||||
teamFilter.setValue(teams.getFirst());
|
teamFilter.setValue(teams.getFirst());
|
||||||
teamFilter.addValueChangeListener(event ->
|
teamFilter.addValueChangeListener(event ->
|
||||||
refreshRequestGrid(
|
refreshGeneralRequestGrid(
|
||||||
employeeFilter.getValue(),
|
employeeFilter.getValue(),
|
||||||
event.getValue(),
|
event.getValue(),
|
||||||
categoryFilter.getValue(),
|
categoryFilter.getValue(),
|
||||||
@ -185,7 +235,7 @@ public class RequestsListView extends Main {
|
|||||||
categoryFilter.setItems(TimeOffRequestType.values());
|
categoryFilter.setItems(TimeOffRequestType.values());
|
||||||
categoryFilter.setValue(TimeOffRequestType.values()[0]);
|
categoryFilter.setValue(TimeOffRequestType.values()[0]);
|
||||||
categoryFilter.addValueChangeListener(event ->
|
categoryFilter.addValueChangeListener(event ->
|
||||||
refreshRequestGrid(
|
refreshGeneralRequestGrid(
|
||||||
employeeFilter.getValue(),
|
employeeFilter.getValue(),
|
||||||
teamFilter.getValue(),
|
teamFilter.getValue(),
|
||||||
event.getValue(),
|
event.getValue(),
|
||||||
@ -195,12 +245,12 @@ public class RequestsListView extends Main {
|
|||||||
return categoryFilter;
|
return categoryFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ComboBox<TimeOffRequest.Status> createStateFilter() {
|
private ComboBox<Status> createStateFilter() {
|
||||||
stateFilter = new ComboBox<>("State");
|
stateFilter = new ComboBox<>("State");
|
||||||
stateFilter.setItems(TimeOffRequest.Status.values());
|
stateFilter.setItems(Status.values());
|
||||||
stateFilter.setValue(TimeOffRequest.Status.values()[0]);
|
stateFilter.setValue(Status.values()[0]);
|
||||||
stateFilter.addValueChangeListener(event ->
|
stateFilter.addValueChangeListener(event ->
|
||||||
refreshRequestGrid(
|
refreshGeneralRequestGrid(
|
||||||
employeeFilter.getValue(),
|
employeeFilter.getValue(),
|
||||||
teamFilter.getValue(),
|
teamFilter.getValue(),
|
||||||
categoryFilter.getValue(),
|
categoryFilter.getValue(),
|
||||||
@ -210,6 +260,12 @@ public class RequestsListView extends Main {
|
|||||||
return stateFilter;
|
return stateFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private enum Status {
|
||||||
|
ALL,
|
||||||
|
IDLE,
|
||||||
|
ACTIVE
|
||||||
|
}
|
||||||
|
|
||||||
private Employee createAllEmployeesOption() {
|
private Employee createAllEmployeesOption() {
|
||||||
Employee allEmployeesOption = new Employee();
|
Employee allEmployeesOption = new Employee();
|
||||||
allEmployeesOption.setFirstName("ALL");
|
allEmployeesOption.setFirstName("ALL");
|
||||||
@ -222,15 +278,11 @@ public class RequestsListView extends Main {
|
|||||||
return allTeamsOption;
|
return allTeamsOption;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getEmployeeLabel(final Employee employee) {
|
private void navigateToMainView() {
|
||||||
return "ALL".equals(employee.getFirstName()) ? "ALL" : employee.getFirstName() + " " + employee.getLastName();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getTeamLabel(final Team team) {
|
|
||||||
return "ALL".equals(team.getName()) ? "ALL" : team.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void closeView() {
|
|
||||||
getUI().ifPresent(ui -> ui.navigate(MainView.class));
|
getUI().ifPresent(ui -> ui.navigate(MainView.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void navigateToTimeOffRequestView(final UUID idEmployee) {
|
||||||
|
getUI().ifPresent(ui -> ui.navigate("requests/" + idEmployee.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
@ -9,25 +9,6 @@ insert into ASSESSMENT_QUESTIONS (assessment_id, question_id) values ('46b153f4-
|
|||||||
|
|
||||||
insert into ASSESSMENT_QUESTIONS (assessment_id, question_id) values ('46b153f4-23fd-462f-8430-fbe67b83caab', '8a4b213c-ca81-4c38-b56d-d7028c2dde88');
|
insert into ASSESSMENT_QUESTIONS (assessment_id, question_id) values ('46b153f4-23fd-462f-8430-fbe67b83caab', '8a4b213c-ca81-4c38-b56d-d7028c2dde88');
|
||||||
|
|
||||||
insert into employee (id, version, username, first_name, last_name, status) values ('5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 1, 'bob', 'Bob', 'Test', 'ACTIVE');
|
|
||||||
insert into employee (id, version, username, first_name, last_name, status) values ('cba3efb7-32bc-44be-9fdc-fc5e4f211254', 1, 'ben', 'Ben', 'Test', 'ACTIVE');
|
|
||||||
insert into employee (id, version, username, first_name, last_name, status) values ('e99b7af5-7d3a-4c0f-b8bc-e8d0388d8fc4', 1, 'jperez', 'Juan', 'Perez Condori', 'INACTIVE');
|
|
||||||
insert into employee (id, version, username, first_name, last_name, status) values ('f6ab3c6d-7078-45f6-9b22-4e37637bfec6', 1, 'agarcia', 'Ana', 'Garcia Rojas', 'ACTIVE');
|
|
||||||
insert into employee (id, version, username, first_name, last_name, status) values ('2e2293b1-3f9a-4f3d-abc8-32639b0a5e15', 1, 'clopez', 'Carlos', 'Lopez Mendoza', 'INACTIVE');
|
|
||||||
insert into employee (id, version, username, first_name, last_name, status) values ('4b1c6c35-4627-4b35-b6e9-dc75c68b2c31', 1, 'mfernandez', 'Maria', 'Fernandez Villca', 'ACTIVE');
|
|
||||||
insert into employee (id, version, username, first_name, last_name, status) values ('afc5c741-f70a-4394-853b-39d51b118927', 1, 'lgutierrez', 'Luis', 'Gutierrez Mamani', 'ACTIVE');
|
|
||||||
insert into employee (id, version, username, first_name, last_name, status) values ('b2436b82-7b9f-4f0d-9463-f2c3173a45c3', 1, 'lmartinez', 'Laura', 'Martinez Paredes', 'INACTIVE');
|
|
||||||
insert into employee (id, version, username, first_name, last_name, status) values ('6e6a8a4e-9f6b-44eb-8c69-40acfdc86756', 1, 'rsantos', 'Roberto', 'Santos Escobar', 'ACTIVE');
|
|
||||||
insert into employee (id, version, username, first_name, last_name, status) values ('36b0d1c6-bdc0-4d98-94bb-08b9bce3f0d5', 1, 'vmorales', 'Valeria', 'Morales Ochoa', 'INACTIVE');
|
|
||||||
insert into employee (id, version, username, first_name, last_name, status) values ('5a1c6d80-58b3-43e3-a5a5-24b4a2d1d54a', 1, 'jramirez', 'Jorge', 'Ramirez Tapia', 'ACTIVE');
|
|
||||||
insert into employee (id, version, username, first_name, last_name, status) values ('9d6a5b2e-6d0b-4b89-8d6a-d3f3d1bfc047', 1, 'storres', 'Sandra', 'Torres Huanca', 'ACTIVE');
|
|
||||||
insert into employee (id, version, username, first_name, last_name, status) values ('f8b3e0c0-0d5a-4e5c-bf9d-207b9b5e8279', 1, 'fquispe', 'Felipe', 'Quispe Huanca', 'INACTIVE');
|
|
||||||
insert into employee (id, version, username, first_name, last_name, status) values ('cd80e1d0-9a08-44a6-bd63-2c63eaa003d4', 1, 'grivas', 'Gabriela', 'Rivas Arana', 'ACTIVE');
|
|
||||||
insert into employee (id, version, username, first_name, last_name, status) values ('62d3c1b7-815e-4e96-8d7e-f8c4236bca55', 1, 'oflores', 'Oscar', 'Flores Quiroga', 'INACTIVE');
|
|
||||||
insert into employee (id, version, username, first_name, last_name, status) values ('f20b7c5a-5a67-44f0-9ec1-4c1b8e80de05', 1, 'mvargas', 'Marta', 'Vargas Soria', 'ACTIVE');
|
|
||||||
insert into employee (id, version, username, first_name, last_name, status) values ('19b5a76e-d7b1-4b76-8b02-4d0748e85809', 1, 'aespinoza', 'Andres', 'Espinoza Chura', 'INACTIVE');
|
|
||||||
insert into employee (id, version, username, first_name, last_name, status) values ('5c1a7b82-832d-4f24-8377-54b77b91b6a8', 1, 'cvillanueva', 'Carla', 'Villanueva Arce', 'ACTIVE');
|
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO team (id, version, name) VALUES ('b0e8f394-78c1-4d8a-9c57-dc6e8b36a5fa', 1, 'ABC');
|
INSERT INTO team (id, version, name) VALUES ('b0e8f394-78c1-4d8a-9c57-dc6e8b36a5fa', 1, 'ABC');
|
||||||
INSERT INTO team (id, version, name) VALUES ('6d63bc15-3f8b-46f7-9cf1-7e9b0b9a2b28', 1, 'XYZ');
|
INSERT INTO team (id, version, name) VALUES ('6d63bc15-3f8b-46f7-9cf1-7e9b0b9a2b28', 1, 'XYZ');
|
||||||
@ -35,33 +16,53 @@ INSERT INTO team (id, version, name) VALUES ('c3a8a7b1-f2d9-48c0-86ea-f215c2e6b3
|
|||||||
INSERT INTO team (id, version, name) VALUES ('8f6b61e7-efb2-4de7-b8ed-7438c9d8babe', 1, 'GHI');
|
INSERT INTO team (id, version, name) VALUES ('8f6b61e7-efb2-4de7-b8ed-7438c9d8babe', 1, 'GHI');
|
||||||
|
|
||||||
|
|
||||||
insert into time_off_request (id, version, employee_id, team_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
|
insert into employee (id, version, username, first_name, last_name, status, team_id) values ('5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 1, 'bob', 'Bob', 'Test', 'ACTIVE','b0e8f394-78c1-4d8a-9c57-dc6e8b36a5fa');
|
||||||
values ('9d6f12ba-e341-4e7a-b8a6-cab0982bd8c1', 1, '5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 'b0e8f394-78c1-4d8a-9c57-dc6e8b36a5fa', 'VACATION', 'TAKEN', 15, '2025-12-31', '2024-10-01', '2024-10-10', 5, 10);
|
insert into employee (id, version, username, first_name, last_name, status, team_id) values ('cba3efb7-32bc-44be-9fdc-fc5e4f211254', 1, 'ben', 'Ben', 'Test', 'ACTIVE', '6d63bc15-3f8b-46f7-9cf1-7e9b0b9a2b28');
|
||||||
insert into time_off_request (id, version, employee_id, team_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
|
insert into employee (id, version, username, first_name, last_name, status, team_id) values ('e99b7af5-7d3a-4c0f-b8bc-e8d0388d8fc4', 1, 'jperez', 'Juan', 'Perez Condori', 'INACTIVE', 'c3a8a7b1-f2d9-48c0-86ea-f215c2e6b3a3');
|
||||||
values ('2fa314bc-f547-4b12-a8b6-bb789feabc12', 1, '19b5a76e-d7b1-4b76-8b02-4d0748e85809', 'b0e8f394-78c1-4d8a-9c57-dc6e8b36a5fa', 'BIRTHDAY', 'APPROVED', 15, '2025-12-31', '2024-12-01', '2024-12-15', 7, 8);
|
insert into employee (id, version, username, first_name, last_name, status, team_id) values ('f6ab3c6d-7078-45f6-9b22-4e37637bfec6', 1, 'agarcia', 'Ana', 'Garcia Rojas', 'ACTIVE', '8f6b61e7-efb2-4de7-b8ed-7438c9d8babe');
|
||||||
insert into time_off_request (id, version, employee_id, team_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
|
insert into employee (id, version, username, first_name, last_name, status, team_id) values ('2e2293b1-3f9a-4f3d-abc8-32639b0a5e15', 1, 'clopez', 'Carlos', 'Lopez Mendoza', 'INACTIVE', 'b0e8f394-78c1-4d8a-9c57-dc6e8b36a5fa');
|
||||||
values ('d5f6341a-913d-4e7f-a0b2-cfe0786acd34', 1, 'cba3efb7-32bc-44be-9fdc-fc5e4f211254', '8f6b61e7-efb2-4de7-b8ed-7438c9d8babe', 'FIXED_HOLIDAY', 'IN_USE', 20, '2025-11-30', '2024-11-10', '2024-11-20', 10, 10);
|
insert into employee (id, version, username, first_name, last_name, status, team_id) values ('4b1c6c35-4627-4b35-b6e9-dc75c68b2c31', 1, 'mfernandez', 'Maria', 'Fernandez Villca', 'ACTIVE', '6d63bc15-3f8b-46f7-9cf1-7e9b0b9a2b28');
|
||||||
insert into time_off_request (id, version, employee_id, team_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
|
insert into employee (id, version, username, first_name, last_name, status, team_id) values ('afc5c741-f70a-4394-853b-39d51b118927', 1, 'lgutierrez', 'Luis', 'Gutierrez Mamani', 'ACTIVE', 'c3a8a7b1-f2d9-48c0-86ea-f215c2e6b3a3');
|
||||||
values ('4f913b23-ff23-4527-bcd6-adfe01234567', 1, 'e99b7af5-7d3a-4c0f-b8bc-e8d0388d8fc4', 'b0e8f394-78c1-4d8a-9c57-dc6e8b36a5fa', 'MATERNITY', 'TAKEN', 18, '2025-06-30', '2024-07-01', '2024-07-15', 10, 8);
|
insert into employee (id, version, username, first_name, last_name, status, team_id) values ('b2436b82-7b9f-4f0d-9463-f2c3173a45c3', 1, 'lmartinez', 'Laura', 'Martinez Paredes', 'INACTIVE', '8f6b61e7-efb2-4de7-b8ed-7438c9d8babe');
|
||||||
insert into time_off_request (id, version, employee_id, team_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
|
insert into employee (id, version, username, first_name, last_name, status, team_id) values ('6e6a8a4e-9f6b-44eb-8c69-40acfdc86756', 1, 'rsantos', 'Roberto', 'Santos Escobar', 'ACTIVE','b0e8f394-78c1-4d8a-9c57-dc6e8b36a5fa');
|
||||||
values ('8c653f2a-f9a3-4d67-b3b6-12ad98fe0983', 1, 'f6ab3c6d-7078-45f6-9b22-4e37637bfec6', '8f6b61e7-efb2-4de7-b8ed-7438c9d8babe', 'VACATION', 'REQUESTED', 10, '2025-10-31', '2024-09-15', '2024-09-20', 5, 5);
|
insert into employee (id, version, username, first_name, last_name, status, team_id) values ('36b0d1c6-bdc0-4d98-94bb-08b9bce3f0d5', 1, 'vmorales', 'Valeria', 'Morales Ochoa', 'INACTIVE', '6d63bc15-3f8b-46f7-9cf1-7e9b0b9a2b28');
|
||||||
insert into time_off_request (id, version, employee_id, team_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
|
insert into employee (id, version, username, first_name, last_name, status, team_id) values ('5a1c6d80-58b3-43e3-a5a5-24b4a2d1d54a', 1, 'jramirez', 'Jorge', 'Ramirez Tapia', 'ACTIVE', 'c3a8a7b1-f2d9-48c0-86ea-f215c2e6b3a3');
|
||||||
values ('fb9d9d75-b2ab-4ea4-b8b3-0a8f89e5c123', 1, '2e2293b1-3f9a-4f3d-abc8-32639b0a5e15', '6d63bc15-3f8b-46f7-9cf1-7e9b0b9a2b28', 'FIXED_HOLIDAY', 'IN_USE', 12, '2025-08-31', '2024-08-05', '2024-08-15', 6, 6);
|
insert into employee (id, version, username, first_name, last_name, status, team_id) values ('9d6a5b2e-6d0b-4b89-8d6a-d3f3d1bfc047', 1, 'storres', 'Sandra', 'Torres Huanca', 'ACTIVE', '8f6b61e7-efb2-4de7-b8ed-7438c9d8babe');
|
||||||
insert into time_off_request (id, version, employee_id, team_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
|
insert into employee (id, version, username, first_name, last_name, status, team_id) values ('f8b3e0c0-0d5a-4e5c-bf9d-207b9b5e8279', 1, 'fquispe', 'Felipe', 'Quispe Huanca', 'INACTIVE','b0e8f394-78c1-4d8a-9c57-dc6e8b36a5fa');
|
||||||
values ('1c913a12-46e9-47b7-9e31-ab903fedc789', 1, '4b1c6c35-4627-4b35-b6e9-dc75c68b2c31', 'c3a8a7b1-f2d9-48c0-86ea-f215c2e6b3a3', 'BIRTHDAY', 'TAKEN', 14, '2025-12-31', '2024-10-20', '2024-10-25', 5, 9);
|
insert into employee (id, version, username, first_name, last_name, status, team_id) values ('cd80e1d0-9a08-44a6-bd63-2c63eaa003d4', 1, 'grivas', 'Gabriela', 'Rivas Arana', 'ACTIVE', '6d63bc15-3f8b-46f7-9cf1-7e9b0b9a2b28');
|
||||||
insert into time_off_request (id, version, employee_id, team_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
|
insert into employee (id, version, username, first_name, last_name, status, team_id) values ('62d3c1b7-815e-4e96-8d7e-f8c4236bca55', 1, 'oflores', 'Oscar', 'Flores Quiroga', 'INACTIVE', 'c3a8a7b1-f2d9-48c0-86ea-f215c2e6b3a3');
|
||||||
values ('b1249d3a-cc34-4954-88d9-1e4f67fe2436', 1, 'afc5c741-f70a-4394-853b-39d51b118927', 'c3a8a7b1-f2d9-48c0-86ea-f215c2e6b3a3', 'MATERNITY', 'APPROVED', 20, '2025-11-30', '2024-11-05', '2024-11-12', 7, 13);
|
insert into employee (id, version, username, first_name, last_name, status, team_id) values ('f20b7c5a-5a67-44f0-9ec1-4c1b8e80de05', 1, 'mvargas', 'Marta', 'Vargas Soria', 'ACTIVE', '8f6b61e7-efb2-4de7-b8ed-7438c9d8babe');
|
||||||
insert into time_off_request (id, version, employee_id, team_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
|
insert into employee (id, version, username, first_name, last_name, status, team_id) values ('19b5a76e-d7b1-4b76-8b02-4d0748e85809', 1, 'aespinoza', 'Andres', 'Espinoza Chura', 'INACTIVE','b0e8f394-78c1-4d8a-9c57-dc6e8b36a5fa');
|
||||||
values ('6fdc47a8-127b-41c4-8d12-7fc12098ab12', 1, 'b2436b82-7b9f-4f0d-9463-f2c3173a45c3', 'c3a8a7b1-f2d9-48c0-86ea-f215c2e6b3a3', 'VACATION', 'TAKEN', 18, '2025-06-30', '2024-07-10', '2024-07-20', 8, 10);
|
insert into employee (id, version, username, first_name, last_name, status, team_id) values ('5c1a7b82-832d-4f24-8377-54b77b91b6a8', 1, 'cvillanueva', 'Carla', 'Villanueva Arce', 'ACTIVE', '6d63bc15-3f8b-46f7-9cf1-7e9b0b9a2b28');
|
||||||
insert into time_off_request (id, version, employee_id, team_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
|
|
||||||
values ('12ec8b74-983d-4a17-b67e-134f45ae904c', 1, '5c1a7b82-832d-4f24-8377-54b77b91b6a8', '8f6b61e7-efb2-4de7-b8ed-7438c9d8babe', 'FIXED_HOLIDAY', 'PENDING', 15, '2025-12-31', '2024-09-01', '2024-09-05', 4, 11);
|
|
||||||
insert into time_off_request (id, version, employee_id, team_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
|
insert into time_off_request (id, version, employee_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
|
||||||
values ('89bc4b2a-943f-487c-a9f3-bacf78145e67', 1, 'cba3efb7-32bc-44be-9fdc-fc5e4f211254', '8f6b61e7-efb2-4de7-b8ed-7438c9d8babe', 'VACATION', 'APPROVED', 20, '2025-11-30', '2024-10-25', '2024-11-05', 9, 11);
|
values ('9d6f12ba-e341-4e7a-b8a6-cab0982bd8c1', 1, '5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 'VACATION', 'TAKEN', 15, '2025-12-31', '2024-10-01', '2024-10-10', 5, 10);
|
||||||
insert into time_off_request (id, version, employee_id, team_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
|
insert into time_off_request (id, version, employee_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
|
||||||
values ('37adfc2a-7463-4b2d-a7c1-fae04567cdef', 1, 'e99b7af5-7d3a-4c0f-b8bc-e8d0388d8fc4', 'c3a8a7b1-f2d9-48c0-86ea-f215c2e6b3a3', 'BIRTHDAY', 'TAKEN', 18, '2025-06-30', '2024-06-01', '2024-06-10', 6, 12);
|
values ('2fa314bc-f547-4b12-a8b6-bb789feabc12', 1, '19b5a76e-d7b1-4b76-8b02-4d0748e85809', 'BIRTHDAY', 'APPROVED', 15, '2025-12-31', '2024-12-01', '2024-12-15', 7, 8);
|
||||||
insert into time_off_request (id, version, employee_id, team_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
|
insert into time_off_request (id, version, employee_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
|
||||||
values ('2bc138ea-12db-4b89-a0b4-78e045e34b4e', 1, 'f6ab3c6d-7078-45f6-9b22-4e37637bfec6', 'b0e8f394-78c1-4d8a-9c57-dc6e8b36a5fa', 'MATERNITY', 'REQUESTED', 10, '2025-10-31', '2024-10-01', '2024-10-10', 3, 7);
|
values ('d5f6341a-913d-4e7f-a0b2-cfe0786acd34', 1, 'cba3efb7-32bc-44be-9fdc-fc5e4f211254', 'FIXED_HOLIDAY', 'IN_USE', 20, '2025-11-30', '2024-11-10', '2024-11-20', 10, 10);
|
||||||
insert into time_off_request (id, version, employee_id, team_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
|
insert into time_off_request (id, version, employee_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
|
||||||
values ('14de1a56-6893-4e12-90f3-4faec457f002', 1, 'cd80e1d0-9a08-44a6-bd63-2c63eaa003d4', 'b0e8f394-78c1-4d8a-9c57-dc6e8b36a5fa', 'FIXED_HOLIDAY', 'PENDING', 22, '2025-08-31', '2024-07-15', '2024-07-25', 8, 14);
|
values ('4f913b23-ff23-4527-bcd6-adfe01234567', 1, 'e99b7af5-7d3a-4c0f-b8bc-e8d0388d8fc4', 'MATERNITY', 'IN_USE', 18, '2025-06-30', '2024-07-01', '2024-07-15', 10, 8);
|
||||||
insert into time_off_request (id, version, employee_id, team_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
|
insert into time_off_request (id, version, employee_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
|
||||||
values ('fb08a6c9-cd17-42e8-b9e2-734ec834cae2', 1, '4b1c6c35-4627-4b35-b6e9-dc75c68b2c31', 'c3a8a7b1-f2d9-48c0-86ea-f215c2e6b3a3', 'VACATION', 'TAKEN', 16, '2025-12-31', '2024-09-30', '2024-10-05', 4, 12);
|
values ('8c653f2a-f9a3-4d67-b3b6-12ad98fe0983', 1, 'f6ab3c6d-7078-45f6-9b22-4e37637bfec6', 'VACATION', 'REQUESTED', 10, '2025-10-31', '2024-09-15', '2024-09-20', 5, 5);
|
||||||
|
insert into time_off_request (id, version, employee_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
|
||||||
|
values ('fb9d9d75-b2ab-4ea4-b8b3-0a8f89e5c123', 1, '2e2293b1-3f9a-4f3d-abc8-32639b0a5e15', 'FIXED_HOLIDAY', 'IN_USE', 12, '2025-08-31', '2024-08-05', '2024-08-15', 6, 6);
|
||||||
|
insert into time_off_request (id, version, employee_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
|
||||||
|
values ('1c913a12-46e9-47b7-9e31-ab903fedc789', 1, '4b1c6c35-4627-4b35-b6e9-dc75c68b2c31', 'BIRTHDAY', 'APPROVED', 14, '2025-12-31', '2024-10-20', '2024-10-25', 5, 9);
|
||||||
|
insert into time_off_request (id, version, employee_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
|
||||||
|
values ('b1249d3a-cc34-4954-88d9-1e4f67fe2436', 1, 'afc5c741-f70a-4394-853b-39d51b118927', 'MATERNITY', 'APPROVED', 20, '2025-11-30', '2024-11-05', '2024-11-12', 7, 13);
|
||||||
|
insert into time_off_request (id, version, employee_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
|
||||||
|
values ('6fdc47a8-127b-41c4-8d12-7fc12098ab12', 1, 'b2436b82-7b9f-4f0d-9463-f2c3173a45c3', 'VACATION', 'PENDING', 18, '2025-06-30', '2024-07-10', '2024-07-20', 8, 10);
|
||||||
|
insert into time_off_request (id, version, employee_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
|
||||||
|
values ('12ec8b74-983d-4a17-b67e-134f45ae904c', 1, '5c1a7b82-832d-4f24-8377-54b77b91b6a8', 'FIXED_HOLIDAY', 'PENDING', 15, '2025-12-31', '2024-09-01', '2024-09-05', 4, 11);
|
||||||
|
insert into time_off_request (id, version, employee_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
|
||||||
|
values ('89bc4b2a-943f-487c-a9f3-bacf78145e67', 1, 'cba3efb7-32bc-44be-9fdc-fc5e4f211254', 'VACATION', 'APPROVED', 20, '2025-11-30', '2024-10-25', '2024-11-05', 9, 11);
|
||||||
|
insert into time_off_request (id, version, employee_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
|
||||||
|
values ('37adfc2a-7463-4b2d-a7c1-fae04567cdef', 1, 'e99b7af5-7d3a-4c0f-b8bc-e8d0388d8fc4', 'BIRTHDAY', 'REQUESTED', 18, '2025-06-30', '2024-06-01', '2024-06-10', 6, 12);
|
||||||
|
insert into time_off_request (id, version, employee_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
|
||||||
|
values ('2bc138ea-12db-4b89-a0b4-78e045e34b4e', 1, 'f6ab3c6d-7078-45f6-9b22-4e37637bfec6', 'MATERNITY', 'REQUESTED', 10, '2025-10-31', '2024-10-01', '2024-10-10', 3, 7);
|
||||||
|
insert into time_off_request (id, version, employee_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
|
||||||
|
values ('14de1a56-6893-4e12-90f3-4faec457f002', 1, 'cd80e1d0-9a08-44a6-bd63-2c63eaa003d4', 'FIXED_HOLIDAY', 'PENDING', 22, '2025-08-31', '2024-07-15', '2024-07-25', 8, 14);
|
||||||
|
insert into time_off_request (id, version, employee_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
|
||||||
|
values ('fb08a6c9-cd17-42e8-b9e2-734ec834cae2', 1, '4b1c6c35-4627-4b35-b6e9-dc75c68b2c31', 'VACATION', 'PENDING', 16, '2025-12-31', '2024-09-30', '2024-10-05', 4, 12);
|
||||||
|
Loading…
Reference in New Issue
Block a user