crear tabla para visuaizar las actividades creadas

This commit is contained in:
Melina Gutierrez 2024-11-13 16:08:20 -04:00
parent 090a4bb67a
commit addba4b70f
6 changed files with 62 additions and 60 deletions

View File

@ -4,7 +4,7 @@
"type": "module", "type": "module",
"dependencies": { "dependencies": {
"@f0rce/ace-widget": "1.0.2", "@f0rce/ace-widget": "1.0.2",
"@polymer/polymer": "3.5.2", "@polymer/polymer": "3.5.1",
"@vaadin-component-factory/vcf-pdf-viewer": "2.0.1", "@vaadin-component-factory/vcf-pdf-viewer": "2.0.1",
"@vaadin/bundles": "24.5.1", "@vaadin/bundles": "24.5.1",
"@vaadin/common-frontend": "0.0.19", "@vaadin/common-frontend": "0.0.19",
@ -19,30 +19,30 @@
"@vaadin/vaadin-usage-statistics": "2.1.3", "@vaadin/vaadin-usage-statistics": "2.1.3",
"construct-style-sheets-polyfill": "3.1.0", "construct-style-sheets-polyfill": "3.1.0",
"date-fns": "2.29.3", "date-fns": "2.29.3",
"lit": "3.2.1", "lit": "3.1.4",
"print-js": "1.6.0", "print-js": "1.6.0",
"proj4": "2.12.1", "proj4": "2.12.1",
"react": "18.3.1", "react": "18.3.1",
"react-dom": "18.3.1", "react-dom": "18.3.1",
"react-router-dom": "6.26.2" "react-router-dom": "6.23.1"
}, },
"devDependencies": { "devDependencies": {
"@babel/preset-react": "7.25.7", "@babel/preset-react": "7.24.7",
"@preact/signals-react-transform": "0.4.0", "@preact/signals-react-transform": "0.4.0",
"@rollup/plugin-replace": "6.0.1", "@rollup/plugin-replace": "5.0.7",
"@rollup/pluginutils": "5.1.2", "@rollup/pluginutils": "5.1.0",
"@types/react": "18.3.11", "@types/react": "18.3.3",
"@types/react-dom": "18.3.1", "@types/react-dom": "18.3.0",
"@vitejs/plugin-react": "4.3.3", "@vitejs/plugin-react": "4.3.1",
"async": "3.2.6", "async": "3.2.5",
"glob": "10.4.5", "glob": "10.4.1",
"rollup-plugin-brotli": "3.1.0", "rollup-plugin-brotli": "3.1.0",
"rollup-plugin-visualizer": "5.12.0", "rollup-plugin-visualizer": "5.12.0",
"strip-css-comments": "5.0.0", "strip-css-comments": "5.0.0",
"transform-ast": "2.4.4", "transform-ast": "2.4.4",
"typescript": "5.6.3", "typescript": "5.4.5",
"vite": "5.4.9", "vite": "5.3.3",
"vite-plugin-checker": "0.8.0", "vite-plugin-checker": "0.6.4",
"workbox-build": "7.1.1", "workbox-build": "7.1.1",
"workbox-core": "7.1.0", "workbox-core": "7.1.0",
"workbox-precaching": "7.1.0" "workbox-precaching": "7.1.0"
@ -50,7 +50,7 @@
"vaadin": { "vaadin": {
"dependencies": { "dependencies": {
"@f0rce/ace-widget": "1.0.2", "@f0rce/ace-widget": "1.0.2",
"@polymer/polymer": "3.5.2", "@polymer/polymer": "3.5.1",
"@vaadin-component-factory/vcf-pdf-viewer": "2.0.1", "@vaadin-component-factory/vcf-pdf-viewer": "2.0.1",
"@vaadin/bundles": "24.5.1", "@vaadin/bundles": "24.5.1",
"@vaadin/common-frontend": "0.0.19", "@vaadin/common-frontend": "0.0.19",
@ -65,30 +65,30 @@
"@vaadin/vaadin-usage-statistics": "2.1.3", "@vaadin/vaadin-usage-statistics": "2.1.3",
"construct-style-sheets-polyfill": "3.1.0", "construct-style-sheets-polyfill": "3.1.0",
"date-fns": "2.29.3", "date-fns": "2.29.3",
"lit": "3.2.1", "lit": "3.1.4",
"print-js": "1.6.0", "print-js": "1.6.0",
"proj4": "2.12.1", "proj4": "2.12.1",
"react": "18.3.1", "react": "18.3.1",
"react-dom": "18.3.1", "react-dom": "18.3.1",
"react-router-dom": "6.26.2" "react-router-dom": "6.23.1"
}, },
"devDependencies": { "devDependencies": {
"@babel/preset-react": "7.25.7", "@babel/preset-react": "7.24.7",
"@preact/signals-react-transform": "0.4.0", "@preact/signals-react-transform": "0.4.0",
"@rollup/plugin-replace": "6.0.1", "@rollup/plugin-replace": "5.0.7",
"@rollup/pluginutils": "5.1.2", "@rollup/pluginutils": "5.1.0",
"@types/react": "18.3.11", "@types/react": "18.3.3",
"@types/react-dom": "18.3.1", "@types/react-dom": "18.3.0",
"@vitejs/plugin-react": "4.3.3", "@vitejs/plugin-react": "4.3.1",
"async": "3.2.6", "async": "3.2.5",
"glob": "10.4.5", "glob": "10.4.1",
"rollup-plugin-brotli": "3.1.0", "rollup-plugin-brotli": "3.1.0",
"rollup-plugin-visualizer": "5.12.0", "rollup-plugin-visualizer": "5.12.0",
"strip-css-comments": "5.0.0", "strip-css-comments": "5.0.0",
"transform-ast": "2.4.4", "transform-ast": "2.4.4",
"typescript": "5.6.3", "typescript": "5.4.5",
"vite": "5.4.9", "vite": "5.3.3",
"vite-plugin-checker": "0.8.0", "vite-plugin-checker": "0.6.4",
"workbox-build": "7.1.1", "workbox-build": "7.1.1",
"workbox-core": "7.1.0", "workbox-core": "7.1.0",
"workbox-precaching": "7.1.0" "workbox-precaching": "7.1.0"

View File

@ -25,7 +25,7 @@ public class Actividad extends BaseEntity {
private String tarea; private String tarea;
private double horas; private double horas;
public Actividad() {} public Actividad() { }
public Actividad(final Builder builder) { public Actividad(final Builder builder) {
this.nombre = builder.nombre; this.nombre = builder.nombre;
@ -49,46 +49,46 @@ public class Actividad extends BaseEntity {
return nombre; return nombre;
} }
public void setLunes(double lunes) { public void setLunes(final double lunes) {
this.lunes = lunes; this.lunes = lunes;
return; return;
} }
public void setMartes(double martes) { public void setMartes(final double martes) {
this.martes = martes; this.martes = martes;
return; return;
} }
public void setMiercoles(double miercoles) { public void setMiercoles(final double miercoles) {
this.miercoles = miercoles; this.miercoles = miercoles;
return; return;
} }
public void setJueves(double jueves) { public void setJueves(final double jueves) {
this.jueves = jueves; this.jueves = jueves;
return; return;
} }
public void setViernes(double viernes) { public void setViernes(final double viernes) {
this.viernes = viernes; this.viernes = viernes;
return; return;
} }
public void setSabado(double sabado) { public void setSabado(final double sabado) {
this.sabado = sabado; this.sabado = sabado;
return; return;
} }
public void setDomingo(double domingo) { public void setDomingo(final double domingo) {
this.domingo = domingo; this.domingo = domingo;
return; return;
} }
public void setTarea(String tarea) { public void setTarea(final String tarea) {
this.tarea = tarea; this.tarea = tarea;
return; return;
} }
public void setHoras(double horas) { public void setHoras(final double horas) {
this.horas = horas; this.horas = horas;
return; return;
} }

View File

@ -35,7 +35,7 @@ public class ActividadesHours {
return id; return id;
} }
public void setId(UUID id) { public void setId(final UUID id) {
this.id = id; this.id = id;
} }
@ -43,7 +43,7 @@ public class ActividadesHours {
return employee; return employee;
} }
public void setEmployee(Employee employee) { public void setEmployee(final Employee employee) {
this.employee = employee; this.employee = employee;
} }
@ -51,7 +51,7 @@ public class ActividadesHours {
return actividad; return actividad;
} }
public void setActividad(Actividad actividad) { public void setActividad(final Actividad actividad) {
this.actividad = actividad; this.actividad = actividad;
} }
@ -59,7 +59,7 @@ public class ActividadesHours {
return totalHours; return totalHours;
} }
public void setTotalHours(double totalHours) { public void setTotalHours(final double totalHours) {
this.totalHours = totalHours; this.totalHours = totalHours;
} }
@ -67,7 +67,7 @@ public class ActividadesHours {
return weekNumber; return weekNumber;
} }
public void setWeekNumber(int weekNumber) { public void setWeekNumber(final int weekNumber) {
this.weekNumber = weekNumber; this.weekNumber = weekNumber;
} }
@ -75,7 +75,7 @@ public class ActividadesHours {
return fecha; return fecha;
} }
public void setFecha(LocalDate fecha) { public void setFecha(final LocalDate fecha) {
this.fecha = fecha; this.fecha = fecha;
} }
} }

View File

@ -28,7 +28,7 @@ public class HoursWorked extends BaseEntity {
private double totalHours; private double totalHours;
private LocalDate fecha; private LocalDate fecha;
public HoursWorked() {} public HoursWorked() { }
// Getters y Setters // Getters y Setters
public UUID getId() { public UUID getId() {
@ -84,20 +84,19 @@ public class HoursWorked extends BaseEntity {
} }
// Método adicional para calcular el número de semana basado en la fecha // Método adicional para calcular el número de semana basado en la fecha
private int calculateWeekNumber(LocalDate date) { private int calculateWeekNumber(final LocalDate date) {
WeekFields weekFields = WeekFields.of(Locale.getDefault()); WeekFields weekFields = WeekFields.of(Locale.getDefault());
return date.get(weekFields.weekOfWeekBasedYear()); return date.get(weekFields.weekOfWeekBasedYear());
} }
@Override @Override
public String toString() { public String toString() {
return "HoursWorked{" + return "HoursWorked{"
"id=" + id + + "id=" + id
", employee=" + (employee != null ? employee.getFirstName() : "N/A") + + ", employee=" + (employee != null ? employee.getFirstName() : "N/A")
", actividad=" + (actividad != null ? actividad.getNombre() : "N/A") + + ", actividad=" + (actividad != null ? actividad.getNombre() : "N/A")
", weekNumber=" + weekNumber + + ", weekNumber=" + weekNumber
", totalHours=" + totalHours + + ", totalHours=" + totalHours
", fecha=" + fecha + + ", fecha=" + fecha + '}';
'}';
} }
} }

View File

@ -2,5 +2,5 @@ package com.primefactorsolutions.repositories;
import com.primefactorsolutions.model.ActividadesHours; import com.primefactorsolutions.model.ActividadesHours;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import java.util.UUID; import java.util.UUID;
public interface ActividadesHoursRepository extends JpaRepository<ActividadesHours,UUID> { public interface ActividadesHoursRepository extends JpaRepository<ActividadesHours, UUID> {
} }

View File

@ -69,7 +69,8 @@ public class HoursWorkedView extends VerticalLayout {
private final Label totalCompletadoLabel = new Label(); private final Label totalCompletadoLabel = new Label();
private final Label horasPendientesLabel = new Label(); private final Label horasPendientesLabel = new Label();
public HoursWorkedView(final EmployeeService employeeService, final HoursWorkedService hoursWorkedService) { public HoursWorkedView(final EmployeeService employeeService,
final HoursWorkedService hoursWorkedService) {
this.employeeService = employeeService; this.employeeService = employeeService;
this.hoursWorkedService = hoursWorkedService; this.hoursWorkedService = hoursWorkedService;
configurarVista(); configurarVista();
@ -121,7 +122,8 @@ public class HoursWorkedView extends VerticalLayout {
employeeComboBox.setWidth("250px"); employeeComboBox.setWidth("250px");
employeeComboBox.setPlaceholder("Buscar empleado..."); employeeComboBox.setPlaceholder("Buscar empleado...");
employeeComboBox.setItems(employeeService.findAllEmployees()); employeeComboBox.setItems(employeeService.findAllEmployees());
employeeComboBox.setItemLabelGenerator(employee -> employee.getFirstName() + " " + employee.getLastName()); employeeComboBox.setItemLabelGenerator(employee -> employee.getFirstName()
+ " " + employee.getLastName());
employeeComboBox.setAllowCustomValue(false); employeeComboBox.setAllowCustomValue(false);
employeeComboBox.addCustomValueSetListener(event -> employeeComboBox.addCustomValueSetListener(event ->
Notification.show("Selecciona un empleado válido de la lista.") Notification.show("Selecciona un empleado válido de la lista.")
@ -192,7 +194,6 @@ public class HoursWorkedView extends VerticalLayout {
add(fechaPicker, filtersLayout, actividadFormLayout, add(fechaPicker, filtersLayout, actividadFormLayout,
equipoLabel, grid, empresaLabel, tareasEspecificasLayout, equipoLabel, grid, empresaLabel, tareasEspecificasLayout,
gridActividadesEspecificas, buttonsLayout, totalesLayout); gridActividadesEspecificas, buttonsLayout, totalesLayout);
} }
private void configurarGrid() { private void configurarGrid() {
@ -470,7 +471,8 @@ public class HoursWorkedView extends VerticalLayout {
hoursWorked.setFecha(LocalDate.now()); // Establecer la fecha actual o la seleccionada si es otra hoursWorked.setFecha(LocalDate.now()); // Establecer la fecha actual o la seleccionada si es otra
// Mostrar información de la actividad para depuración // Mostrar información de la actividad para depuración
System.out.println("Guardando actividad: " + actividad.getNombre() + " con " + totalHorasSemana + " horas."); System.out.println("Guardando actividad: " + actividad.getNombre()
+ " con " + totalHorasSemana + " horas.");
try { try {
// Guardar en el servicio // Guardar en el servicio
@ -478,7 +480,8 @@ public class HoursWorkedView extends VerticalLayout {
savedHoursWorked.add(hoursWorked); // Agregar a la lista de registros guardados savedHoursWorked.add(hoursWorked); // Agregar a la lista de registros guardados
Notification.show("Actividad guardada correctamente: " + actividad.getNombre()); Notification.show("Actividad guardada correctamente: " + actividad.getNombre());
} catch (Exception e) { } catch (Exception e) {
Notification.show("Error al guardar la actividad: " + actividad.getNombre() + " - " + e.getMessage()); Notification.show("Error al guardar la actividad: " + actividad.getNombre()
+ " - " + e.getMessage());
} }
} }