From aa046622c59e9c232ce8b1fba30c7add18ef53c1 Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Tue, 3 Aug 2021 23:15:08 -0600 Subject: [PATCH] =?UTF-8?q?agregar=20llamado=20a=20confirmaci=C3=B3n=20de?= =?UTF-8?q?=20contrase=C3=B1a=20antes=20de=20cargar=20encuesta?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../encuesta/complete/complete.component.ts | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/main/webapp/app/entities/encuesta/complete/complete.component.ts b/src/main/webapp/app/entities/encuesta/complete/complete.component.ts index c023f9d..11899e4 100644 --- a/src/main/webapp/app/entities/encuesta/complete/complete.component.ts +++ b/src/main/webapp/app/entities/encuesta/complete/complete.component.ts @@ -13,6 +13,8 @@ import { EPreguntaCerradaService } from 'app/entities/e-pregunta-cerrada/service import { EPreguntaAbiertaService } from '../../e-pregunta-abierta/service/e-pregunta-abierta.service'; import { EPreguntaCerradaOpcionService } from '../../e-pregunta-cerrada-opcion/service/e-pregunta-cerrada-opcion.service'; import { faStar, faQuestion } from '@fortawesome/free-solid-svg-icons'; +import { AccesoEncuesta } from 'app/entities/enumerations/acceso-encuesta.model'; +import { EncuestaPasswordDialogComponent } from '../encuesta-password-dialog/encuesta-password-dialog.component'; @Component({ selector: 'jhi-complete', @@ -23,10 +25,11 @@ export class EncuestaCompleteComponent implements OnInit { usuarioExtrasSharedCollection: IUsuarioExtra[] = []; faStar = faStar; faQuestion = faQuestion; - encuesta: IEncuesta | null = null; + encuesta?: IEncuesta; isLoading = false; ePreguntas?: any[]; ePreguntasOpciones?: any[]; + isLocked?: boolean; constructor( protected activatedRoute: ActivatedRoute, @@ -43,13 +46,29 @@ export class EncuestaCompleteComponent implements OnInit { this.activatedRoute.data.subscribe(({ encuesta }) => { if (encuesta) { this.encuesta = encuesta; - this.loadAll(); - } else { + } + this.isLocked = this.verifyPassword(); + if (this.isLocked) { this.previousState(); + } else { + this.loadAll(); } }); } + verifyPassword(): boolean { + if (this.encuesta!.acceso === AccesoEncuesta.PUBLIC) { + return false; + } else { + const modalRef = this.modalService.open(EncuestaPasswordDialogComponent, { size: 'lg', backdrop: 'static' }); + modalRef.componentInstance.encuesta = this.encuesta; + modalRef.closed.subscribe(reason => { + return reason === 'success'; + }); + } + return true; + } + ngAfterViewChecked(): void { this.initListeners(); }