From 379e822572c2d6054419e1dd03df29573fefa3db Mon Sep 17 00:00:00 2001 From: Melina Gutierrez Date: Tue, 8 Oct 2024 13:14:34 -0400 Subject: [PATCH] #46 Perfil de Empleado - Registro Semanal de Horas trabajadas --- .../views/HoursWorkedView.java | 129 ++++++++++++++---- 1 file changed, 103 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/primefactorsolutions/views/HoursWorkedView.java b/src/main/java/com/primefactorsolutions/views/HoursWorkedView.java index dc3e9e2..faa4208 100644 --- a/src/main/java/com/primefactorsolutions/views/HoursWorkedView.java +++ b/src/main/java/com/primefactorsolutions/views/HoursWorkedView.java @@ -45,9 +45,36 @@ public class HoursWorkedView extends VerticalLayout { 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) + new Actividad.Builder() + .nombre("Actividad 1") + .lunes(3) + .martes(3) + .miercoles(3) + .jueves(3) + .viernes(3) + .sabado(1) + .domingo(2) + .build(), + new Actividad.Builder() + .nombre("Actividad 2") + .lunes(2) + .martes(2) + .miercoles(2) + .jueves(2) + .viernes(2) + .sabado(0) + .domingo(1) + .build(), + new Actividad.Builder() + .nombre("Meeting 1") + .lunes(0) + .martes(0.5) + .miercoles(0.5) + .jueves(0) + .viernes(0) + .sabado(0.5) + .domingo(0) + .build() ); Button actualizarButton = new Button("Actualizar"); @@ -59,30 +86,80 @@ public class HoursWorkedView extends VerticalLayout { 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 static final class Actividad { + private final String nombre; + private final double lunes; + private final double martes; + private final double miercoles; + private final double jueves; + private final double viernes; + private final double sabado; + private final 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; + private 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 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 lunes) { + this.lunes = lunes; + 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() {