dmencu 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -38,6 +38,7 @@ import{
38
38
  getFormulariosForValuePkRaiz,
39
39
  getMainFormForVivienda,
40
40
  intentarBackup,
41
+ respuestasForPk,
41
42
  setCalcularVariables
42
43
  } from "./bypass-formulario"
43
44
  import { dmTraerDatosFormulario, dispatchers,
@@ -442,6 +443,8 @@ type CasilleroEncabezable = Formulario|Bloque|Filtro|ConjuntoPreguntas|Pregunta|
442
443
 
443
444
  function EncabezadoDespliegue(props:{casillero:CasilleroEncabezable, verIdGuion?:boolean, leer?:boolean, forPk:ForPk}){
444
445
  var {casillero, forPk} = props;
446
+ var [openConfirm, setOpenConfirm] = useState(false)
447
+ var [posGPS, setPosGPS] = useState(null)
445
448
  var conCampoOpciones = useSelector((state:CasoState)=>state.opciones.conCampoOpciones)
446
449
  var handleClickBorrar=()=>{
447
450
  dispatchByPass(accion_registrar_respuesta, {respuesta:null, variable:casillero.var_name as IdVariable, forPk:forPk})
@@ -451,6 +454,9 @@ function EncabezadoDespliegue(props:{casillero:CasilleroEncabezable, verIdGuion?
451
454
  var calculada = casillero.calculada;
452
455
  var id = `id-div-${casillero.var_name||casillero.casillero}`;
453
456
  var idAcciones = "acciones-"+id;
457
+ const handleClose = () => {
458
+ setOpenConfirm(false);
459
+ };
454
460
  return <div
455
461
  className="encabezado"
456
462
  debe-leer={props.leer?'SI':'NO'}
@@ -494,20 +500,55 @@ function EncabezadoDespliegue(props:{casillero:CasilleroEncabezable, verIdGuion?
494
500
  <div className="nombre">{breakeableText(casillero.nombre)}
495
501
  {casillero.especial?.gps?
496
502
  <span>
497
- <Button color="primary" variant="outlined" style={{marginLeft:'10px'}} onClick={(event)=>{
498
- navigator.geolocation.getCurrentPosition(position => {
499
- let {siguienteVariable} = dispatchByPass(accion_registrar_respuesta, {forPk:props.forPk, variable:casillero.var_name, respuesta:JSON.stringify(position)})
500
- console.log(position);
501
- if(siguienteVariable){
502
- enfocarElementoDeVariable(siguienteVariable);
503
+ {openConfirm?
504
+ <Dialog
505
+ open={openConfirm}
506
+ onClose={handleClose}
507
+ aria-labelledby="responsive-dialog-title"
508
+ >
509
+ <DialogTitle id="responsive-dialog-title">Registro punto GPS</DialogTitle>
510
+ <DialogContent>
511
+ <DialogContentText>
512
+ Ya existe un punto registrado, si continúa se va a sobrescribir, <b>si no está un DM DESCARTE el punto</b>
513
+ </DialogContentText>
514
+ </DialogContent>
515
+ <DialogActions>
516
+ <Button onClick={()=>{
517
+ let {siguienteVariable} = dispatchByPass(accion_registrar_respuesta, {forPk:props.forPk, variable:casillero.var_name, respuesta:posGPS})
518
+ if(siguienteVariable){
519
+ enfocarElementoDeVariable(siguienteVariable);
520
+ }
521
+ handleClose();
522
+ }} color="secondary" variant="outlined">
523
+ Guardar
524
+ </Button>
525
+ <Button onClick={handleClose} color="primary" variant="outlined">
526
+ Descartar
527
+ </Button>
528
+ </DialogActions>
529
+ </Dialog>
530
+ :null}
531
+ <Button color="primary" variant="outlined" style={{marginLeft:'10px'}} onClick={(_event)=>{
532
+ const {respuestas} = respuestasForPk(forPk);
533
+ const checkGPS = () =>{
534
+ if(!respuestas[casillero.var_name!]){
535
+ let {siguienteVariable} = dispatchByPass(accion_registrar_respuesta, {forPk:props.forPk, variable:casillero.var_name, respuesta:posGPS})
536
+ if(siguienteVariable){
537
+ enfocarElementoDeVariable(siguienteVariable);
538
+ }
539
+ setOpenConfirm(false);
540
+ }else{
541
+ setOpenConfirm(true);
503
542
  }
543
+ }
544
+ navigator.geolocation.getCurrentPosition(position => {
545
+ setPosGPS(JSON.stringify(position));
546
+ checkGPS();
547
+
504
548
  }, e => {
505
- let {siguienteVariable} = dispatchByPass(accion_registrar_respuesta, {forPk:props.forPk, variable:casillero.var_name, respuesta:"no se pudo obtener el punto, active el gps"})
506
- if(siguienteVariable){
507
- enfocarElementoDeVariable(siguienteVariable);
508
- }
549
+ setPosGPS(e.message);
550
+ checkGPS();
509
551
  });
510
-
511
552
  }}><ICON.Location/></Button>
512
553
  </span>
513
554
  :null}
@@ -644,7 +685,7 @@ function Campo(props:{disabled:boolean, pregunta:PreguntaSimple|PreguntaConOpcio
644
685
  }}
645
686
  />
646
687
  </div>
647
- {disabled || mini?null:
688
+ {disabled || pregunta.especial?.gps || mini?null:
648
689
  <div className="boton-confirmar-campo">
649
690
  <Button variant={editando?"contained":'outlined'} size="small" color={editando?'primary':'default'}
650
691
  boton-confirmar={pregunta.var_name}