From 067941e5408a7ee03522ffe33ad2acf2abd5d8f5 Mon Sep 17 00:00:00 2001 From: Melina Gutierrez Date: Tue, 8 Oct 2024 12:16:19 -0400 Subject: [PATCH] #46 Perfil de Empleado - Registro Semanal de Horas trabajadas --- .../views/HoursWorkedView.java | 120 ++++++++++++++++++ .../views/MainLayout.java | 3 + 2 files changed, 123 insertions(+) create mode 100644 src/main/java/com/primefactorsolutions/views/HoursWorkedView.java diff --git a/src/main/java/com/primefactorsolutions/views/HoursWorkedView.java b/src/main/java/com/primefactorsolutions/views/HoursWorkedView.java new file mode 100644 index 0000000..dc3e9e2 --- /dev/null +++ b/src/main/java/com/primefactorsolutions/views/HoursWorkedView.java @@ -0,0 +1,120 @@ +package com.primefactorsolutions.views; + +import com.vaadin.flow.component.datepicker.DatePicker; +import com.vaadin.flow.component.orderedlayout.HorizontalLayout; +import com.vaadin.flow.component.textfield.TextField; +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.orderedlayout.VerticalLayout; +import com.vaadin.flow.component.html.H2; +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.time.LocalDate; + +@SpringComponent +@PermitAll +@Scope("prototype") +@PageTitle("Hours Worked") +@Route(value = "/hours-worked/me", layout = MainLayout.class) +public class HoursWorkedView extends VerticalLayout { + public HoursWorkedView() { + H2 title = new H2("Registro de Horas Trabajadas"); + + DatePicker datePicker = new DatePicker("Selecciona una fecha"); + datePicker.setValue(LocalDate.now()); + + ComboBox equipoDropdown = new ComboBox<>("Equipo"); + equipoDropdown.setItems("Equipo 1", "Equipo 2", "Equipo 3"); // Ejemplo de datos + + TextField empleadoSearch = new TextField("Empleado (Search)"); + + HorizontalLayout filtersLayout = new HorizontalLayout(equipoDropdown, empleadoSearch); + + Grid grid = new Grid<>(Actividad.class, false); + grid.addColumn(Actividad::getNombre).setHeader("Actividad"); + 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.setItems( + new Actividad("Actividad 1", 3, 3, 3, 3, 3, 1, 2), + new Actividad("Actividad 2", 2, 2, 2, 2, 2, 0, 1), + new Actividad("Meeting 1", 0, 0.5, 0.5, 0, 0, 0.5, 0) + ); + + Button actualizarButton = new Button("Actualizar"); + Button guardarButton = new Button("Guardar"); + Button cerrarButton = new Button("Cerrar"); + + HorizontalLayout buttonsLayout = new HorizontalLayout(actualizarButton, guardarButton, cerrarButton); + + add(title, datePicker, filtersLayout, grid, buttonsLayout); + } + + public static class Actividad { + final private String nombre; + final private double lunes; + final private double martes; + final private double miercoles; + final private double jueves; + final private double viernes; + final private double sabado; + final private double domingo; + + public Actividad( + final String nombre, final double lunes, + final double martes, final double miercoles, + final double jueves, final double viernes, + final double sabado, final double domingo) + { + this.nombre = nombre; + this.lunes = lunes; + this.martes = martes; + this.miercoles = miercoles; + this.jueves = jueves; + this.viernes = viernes; + this.sabado = sabado; + this.domingo = 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; + } + } +} diff --git a/src/main/java/com/primefactorsolutions/views/MainLayout.java b/src/main/java/com/primefactorsolutions/views/MainLayout.java index 81fa7f6..f8bd4a1 100644 --- a/src/main/java/com/primefactorsolutions/views/MainLayout.java +++ b/src/main/java/com/primefactorsolutions/views/MainLayout.java @@ -109,6 +109,9 @@ public class MainLayout extends AppLayout { LineAwesomeIcon.PLANE_DEPARTURE_SOLID.create()); SideNavItem timesheet = new SideNavItem("My Timesheet", TimesheetView.class, LineAwesomeIcon.HOURGLASS_START_SOLID.create()); + timesheet.addItem(new SideNavItem("Hours Worked", HoursWorkedView.class, + LineAwesomeIcon.ID_CARD_SOLID.create())); + SideNavItem profile = new SideNavItem("My Profile", ProfileView.class, LineAwesomeIcon.USER_EDIT_SOLID.create());