|
|
@ -2,6 +2,7 @@ package mx.gob.jumapacelaya.views; |
|
|
|
|
|
|
|
import com.vaadin.flow.component.UI; |
|
|
|
import com.vaadin.flow.component.button.Button; |
|
|
|
import com.vaadin.flow.component.button.ButtonVariant; |
|
|
|
import com.vaadin.flow.component.grid.Grid; |
|
|
|
import com.vaadin.flow.component.html.*; |
|
|
|
import com.vaadin.flow.component.icon.Icon; |
|
|
@ -16,6 +17,7 @@ import com.vaadin.flow.component.textfield.NumberField; |
|
|
|
import com.vaadin.flow.router.PageTitle; |
|
|
|
import com.vaadin.flow.router.Route; |
|
|
|
import com.vaadin.flow.theme.lumo.LumoUtility; |
|
|
|
import de.f0rce.signaturepad.SignaturePad; |
|
|
|
import mx.gob.jumapacelaya.Services.GuardarSolicitudService; |
|
|
|
import mx.gob.jumapacelaya.Services.PredioService; |
|
|
|
import mx.gob.jumapacelaya.models.Predio; |
|
|
@ -27,7 +29,6 @@ import java.util.List; |
|
|
|
|
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
|
|
|
@PageTitle("Estudio Socioeconomico") |
|
|
|
@Route(value = "cuestionario", layout = MainLayout.class) |
|
|
|
public class CuestionarioView extends VerticalLayout { |
|
|
@ -37,6 +38,15 @@ public class CuestionarioView extends VerticalLayout { |
|
|
|
private Predio predio; |
|
|
|
private static final Logger logger = LoggerFactory.getLogger(CuestionarioView.class); |
|
|
|
private String vEstado="S"; |
|
|
|
private SignaturePad vFirmaCuest; |
|
|
|
private RadioButtonGroup<Integer> opcionesIng = new RadioButtonGroup<>(); |
|
|
|
private RadioButtonGroup<Integer> opcionesEnf = new RadioButtonGroup<>(); |
|
|
|
private RadioButtonGroup<Integer> opcionesDepen= new RadioButtonGroup<>(); |
|
|
|
private RadioButtonGroup<Integer> opcionesSalud= new RadioButtonGroup<>(); |
|
|
|
private RadioButtonGroup<Integer> opcionesZona= new RadioButtonGroup<>(); |
|
|
|
private RadioButtonGroup<Integer> opcionesEscolar= new RadioButtonGroup<>(); |
|
|
|
private RadioButtonGroup<Integer> opcionesEdad= new RadioButtonGroup<>(); |
|
|
|
private Button btnGuardar = new Button(); |
|
|
|
|
|
|
|
public CuestionarioView(PredioService predioService, GuardarSolicitudService guardarSolicitudService) { |
|
|
|
this.setSizeFull(); |
|
|
@ -44,6 +54,15 @@ public class CuestionarioView extends VerticalLayout { |
|
|
|
this.guardarSolicitudService = guardarSolicitudService; |
|
|
|
this.predioService = predioService; |
|
|
|
|
|
|
|
vFirmaCuest = new SignaturePad(); |
|
|
|
vFirmaCuest.setBackgroundColor("#FFFFFF"); |
|
|
|
vFirmaCuest.setHeight("200px"); |
|
|
|
vFirmaCuest.setPenColor("int red"); |
|
|
|
vFirmaCuest.getElement().getStyle().set("border", "1px solid black"); |
|
|
|
vFirmaCuest.setVisible(false); |
|
|
|
vFirmaCuest.setReadOnly(false); |
|
|
|
vFirmaCuest.getStyle().remove("pointer-events"); |
|
|
|
|
|
|
|
cabecera(); |
|
|
|
titulo(); |
|
|
|
form(); |
|
|
@ -67,7 +86,6 @@ public class CuestionarioView extends VerticalLayout { |
|
|
|
logoJmpa.setWidth("110px"); |
|
|
|
logoJmpa.setHeight("50px"); |
|
|
|
|
|
|
|
|
|
|
|
encabezadoLayout.add(logoJmpa); |
|
|
|
encabezadoLayout.addAndExpand(new HorizontalLayout()); |
|
|
|
encabezadoLayout.add(fecha); |
|
|
@ -75,7 +93,6 @@ public class CuestionarioView extends VerticalLayout { |
|
|
|
this.add(encabezadoLayout); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void titulo() { |
|
|
|
|
|
|
|
VerticalLayout tituloLayout = new VerticalLayout(); |
|
|
@ -90,6 +107,15 @@ public class CuestionarioView extends VerticalLayout { |
|
|
|
this.add(tituloLayout); |
|
|
|
} |
|
|
|
|
|
|
|
private boolean allRadioButtonsSelected() { |
|
|
|
return opcionesIng.getValue() != null && |
|
|
|
opcionesEnf.getValue() != null && |
|
|
|
opcionesDepen.getValue() != null && |
|
|
|
opcionesSalud.getValue() != null && |
|
|
|
opcionesZona.getValue() != null && |
|
|
|
opcionesEscolar.getValue() != null && |
|
|
|
opcionesEdad.getValue() != null; |
|
|
|
} |
|
|
|
|
|
|
|
private void form() { |
|
|
|
// Contenedor principal |
|
|
@ -142,11 +168,6 @@ public class CuestionarioView extends VerticalLayout { |
|
|
|
VerticalLayout etiquetaLayout = new VerticalLayout(puntosTotal, resultado, agua, drenaje, tratada); |
|
|
|
etiquetaLayout.setAlignItems(Alignment.END); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Columnas ingreso familiar |
|
|
|
VerticalLayout columnaCriterio = new VerticalLayout(); |
|
|
|
VerticalLayout columnaRangos = new VerticalLayout(); |
|
|
@ -196,7 +217,6 @@ public class CuestionarioView extends VerticalLayout { |
|
|
|
VerticalLayout columnaPuntosEdad = new VerticalLayout(); |
|
|
|
columnaPuntosEdad.setSpacing(false); |
|
|
|
|
|
|
|
|
|
|
|
// Columna Etiquetas |
|
|
|
Span etiquetaCriterio = new Span("Ingreso familiar mensual"); // Columna Criterio |
|
|
|
Span etiquetaCriterioEnf = new Span("Padece alguna enfermedad crónica o discapacidad comprobable"); |
|
|
@ -206,7 +226,6 @@ public class CuestionarioView extends VerticalLayout { |
|
|
|
Span etiquetaCriteriosEscolar = new Span("Grado de escolaridad"); |
|
|
|
Span etiquetaCriteriosEdad = new Span("Edad del solicitante en años cumplidos"); |
|
|
|
|
|
|
|
|
|
|
|
/* Columnas rangos */ |
|
|
|
// Columna Rangos Ingreso |
|
|
|
Span rango1 = new Span("$6,223.20 en adelante"); |
|
|
@ -249,52 +268,39 @@ public class CuestionarioView extends VerticalLayout { |
|
|
|
Span rangoEdad3 = new Span("41 a 60"); |
|
|
|
Span rangoEdad4 = new Span("A partir de 61"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Columnas puntos */ |
|
|
|
// Columna puntos Ingresos |
|
|
|
RadioButtonGroup<Integer> opcionesIng = new RadioButtonGroup<>(); |
|
|
|
opcionesIng.addThemeVariants(RadioGroupVariant.LUMO_VERTICAL); |
|
|
|
opcionesIng.setItems(0, 5, 10, 15); |
|
|
|
|
|
|
|
// Columna puntos enfermedades |
|
|
|
RadioButtonGroup<Integer> opcionesEnf = new RadioButtonGroup<>(); |
|
|
|
opcionesEnf.addThemeVariants(RadioGroupVariant.LUMO_VERTICAL); |
|
|
|
opcionesEnf.setItems(0, 5, 10); |
|
|
|
|
|
|
|
// Columna puntos dependientes |
|
|
|
RadioButtonGroup<Integer> opcionesDepen= new RadioButtonGroup<>(); |
|
|
|
opcionesDepen.addThemeVariants(RadioGroupVariant.LUMO_VERTICAL); |
|
|
|
opcionesDepen.setItems(0, 5, 10, 15); |
|
|
|
|
|
|
|
// Columna puntos salud |
|
|
|
RadioButtonGroup<Integer> opcionesSalud= new RadioButtonGroup<>(); |
|
|
|
opcionesSalud.addThemeVariants(RadioGroupVariant.LUMO_VERTICAL); |
|
|
|
opcionesSalud.setItems(3, 5, 7, 10); |
|
|
|
|
|
|
|
// Columna puntos zona habitacional |
|
|
|
RadioButtonGroup<Integer> opcionesZona= new RadioButtonGroup<>(); |
|
|
|
opcionesZona.addThemeVariants(RadioGroupVariant.LUMO_VERTICAL); |
|
|
|
opcionesZona.setItems(0, 5, 10, 15); |
|
|
|
|
|
|
|
// Columna puntos grado escolar |
|
|
|
RadioButtonGroup<Integer> opcionesEscolar= new RadioButtonGroup<>(); |
|
|
|
opcionesEscolar.addThemeVariants(RadioGroupVariant.LUMO_VERTICAL); |
|
|
|
opcionesEscolar.setItems(0, 5, 10, 15); |
|
|
|
|
|
|
|
// Columna puntos edad |
|
|
|
RadioButtonGroup<Integer> opcionesEdad= new RadioButtonGroup<>(); |
|
|
|
opcionesEdad.addThemeVariants(RadioGroupVariant.LUMO_VERTICAL); |
|
|
|
opcionesEdad.setItems(0, 4, 7, 10); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
columnaCriterio.add(new H5("Criterio"), etiquetaCriterio); |
|
|
|
columnaRangos.add(new H5("Rangos"), rango1, rango2, rango3, rango4); |
|
|
|
columnaPuntos.add(new H5("Puntos"), opcionesIng); |
|
|
|
|
|
|
|
|
|
|
|
colunaCriterioEnf.add(etiquetaCriterioEnf); |
|
|
|
colunaRangoEnf.add(rangoenf1, rangoenf2, rangoenf3); |
|
|
|
colunaPuntosEnf.add(opcionesEnf); |
|
|
@ -367,6 +373,13 @@ public class CuestionarioView extends VerticalLayout { |
|
|
|
opcionesEscolar.addValueChangeListener(event -> sumarPuntos.run()); |
|
|
|
opcionesZona.addValueChangeListener(event -> sumarPuntos.run()); |
|
|
|
|
|
|
|
opcionesIng.addValueChangeListener(event -> actualizarVisibilidad.run()); |
|
|
|
opcionesDepen.addValueChangeListener(event -> actualizarVisibilidad.run()); |
|
|
|
opcionesEdad.addValueChangeListener(event -> actualizarVisibilidad.run()); |
|
|
|
opcionesEnf.addValueChangeListener(event -> actualizarVisibilidad.run()); |
|
|
|
opcionesSalud.addValueChangeListener(event -> actualizarVisibilidad.run()); |
|
|
|
opcionesEscolar.addValueChangeListener(event -> actualizarVisibilidad.run()); |
|
|
|
opcionesZona.addValueChangeListener(event -> actualizarVisibilidad.run()); |
|
|
|
|
|
|
|
// Recuperar los datos de la sesión |
|
|
|
this.predio = (Predio) UI.getCurrent().getSession().getAttribute("predio"); |
|
|
@ -386,7 +399,7 @@ public class CuestionarioView extends VerticalLayout { |
|
|
|
logger.info("Predio: "+this.predio+" con tipo de solicitud: ["+tipoSolicitud+"] y nombre de Solicitante: "+ nombreSolicitante); |
|
|
|
|
|
|
|
// Boton para guardar la solicitud |
|
|
|
Button btnGuardar = new Button("Guardar", event -> { |
|
|
|
btnGuardar = new Button("Guardar", event -> { |
|
|
|
boolean vGuardado=false; |
|
|
|
String vDetDesc=""; |
|
|
|
String vDetCalif=""; |
|
|
@ -414,14 +427,16 @@ public class CuestionarioView extends VerticalLayout { |
|
|
|
vDetCalif |
|
|
|
); |
|
|
|
}); |
|
|
|
btnGuardar.addThemeVariants(ButtonVariant.LUMO_PRIMARY); |
|
|
|
btnGuardar.setVisible(false); |
|
|
|
|
|
|
|
|
|
|
|
VerticalLayout botonLayout = new VerticalLayout(btnGuardar); |
|
|
|
VerticalLayout botonLayout = new VerticalLayout(); |
|
|
|
botonLayout.setAlignItems(Alignment.END); |
|
|
|
botonLayout.setWidthFull(); |
|
|
|
botonLayout.setHeightFull(); |
|
|
|
botonLayout.add(btnGuardar, vFirmaCuest); |
|
|
|
VerticalLayout totalesLayout = new VerticalLayout(puntos, descuento, txtAgua, txtDrena, txtTrata); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
contenedor1.add(columnaCriterio, columnaRangos, columnaPuntos); |
|
|
|
contenedor2.add(colunaCriterioEnf, colunaRangoEnf, colunaPuntosEnf); |
|
|
|
contenedor3.add(columnaCriteriosDepen, columnaRangosDepen, columnaPuntosDepen); |
|
|
@ -441,4 +456,10 @@ public class CuestionarioView extends VerticalLayout { |
|
|
|
|
|
|
|
this.add(formLayout); |
|
|
|
} |
|
|
|
|
|
|
|
Runnable actualizarVisibilidad = () -> { |
|
|
|
boolean todosSelccionados = allRadioButtonsSelected(); |
|
|
|
btnGuardar.setVisible(todosSelccionados); |
|
|
|
vFirmaCuest.setVisible(todosSelccionados); |
|
|
|
}; |
|
|
|
} |