Merge pull request #147 from Quantum-P3/fix/password
arreglar logica de contraseña
This commit is contained in:
commit
fc03659f7e
|
@ -75,12 +75,7 @@ export class EncuestaCompleteComponent implements OnInit {
|
||||||
this.cantidadCalificaciones = parseInt(this.encuesta!.calificacion!.toString().split('.')[1]);
|
this.cantidadCalificaciones = parseInt(this.encuesta!.calificacion!.toString().split('.')[1]);
|
||||||
this.sumCalificacion = this.avgCalificacion * this.cantidadCalificaciones;
|
this.sumCalificacion = this.avgCalificacion * this.cantidadCalificaciones;
|
||||||
}
|
}
|
||||||
this.isLocked = this.verifyPassword();
|
this.verifyPassword();
|
||||||
if (this.isLocked) {
|
|
||||||
this.previousState();
|
|
||||||
} else {
|
|
||||||
this.loadAll();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
for (let pregunta of this.ePreguntas!) {
|
for (let pregunta of this.ePreguntas!) {
|
||||||
if (pregunta.tipo && pregunta.tipo === PreguntaCerradaTipo.SINGLE) {
|
if (pregunta.tipo && pregunta.tipo === PreguntaCerradaTipo.SINGLE) {
|
||||||
|
@ -89,17 +84,22 @@ export class EncuestaCompleteComponent implements OnInit {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
verifyPassword(): boolean {
|
verifyPassword(): void {
|
||||||
if (this.encuesta!.acceso === AccesoEncuesta.PUBLIC) {
|
if (this.encuesta!.acceso === AccesoEncuesta.PUBLIC) {
|
||||||
return false;
|
this.loadAll();
|
||||||
|
this.isLocked = false;
|
||||||
} else {
|
} else {
|
||||||
const modalRef = this.modalService.open(EncuestaPasswordDialogComponent, { size: 'lg', backdrop: 'static' });
|
const modalRef = this.modalService.open(EncuestaPasswordDialogComponent, { size: 'lg', backdrop: 'static' });
|
||||||
modalRef.componentInstance.encuesta = this.encuesta;
|
modalRef.componentInstance.encuesta = this.encuesta;
|
||||||
modalRef.closed.subscribe(reason => {
|
modalRef.closed.subscribe(reason => {
|
||||||
return reason === 'success';
|
this.isLocked = reason != 'success';
|
||||||
|
if (this.isLocked) {
|
||||||
|
this.previousState();
|
||||||
|
} else {
|
||||||
|
this.loadAll();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewChecked(): void {
|
ngAfterViewChecked(): void {
|
||||||
|
@ -194,7 +194,6 @@ export class EncuestaCompleteComponent implements OnInit {
|
||||||
this.getOpenQuestionAnswers();
|
this.getOpenQuestionAnswers();
|
||||||
this.registerOpenQuestionAnswers();
|
this.registerOpenQuestionAnswers();
|
||||||
this.updateEncuestaRating();
|
this.updateEncuestaRating();
|
||||||
|
|
||||||
this.previousState();
|
this.previousState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
<form class="ds-form" [formGroup]="passwordForm" name="deleteForm" (ngSubmit)="submitPassword()">
|
<form class="ds-form" name="deleteForm">
|
||||||
<div *ngIf="this.isWrong">
|
|
||||||
<p>Contraseña incorrecta</p>
|
|
||||||
</div>
|
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<p class="ds-title--small" jhiTranslate="dataSurveyApp.encuesta.password.title">Enter password</p>
|
<p class="ds-title--small" jhiTranslate="dataSurveyApp.encuesta.password.title">Enter password</p>
|
||||||
<p class="ds-subtitle" id="jhi-delete-encuesta-heading" jhiTranslate="dataSurveyApp.encuesta.password.text">
|
<p class="ds-subtitle" id="jhi-delete-encuesta-heading" jhiTranslate="dataSurveyApp.encuesta.password.text">
|
||||||
This survey is marked as private, please enter the password
|
This survey is marked as private, please enter the password
|
||||||
</p>
|
</p>
|
||||||
|
<div class="alert alert-danger" *ngIf="this.isWrong">
|
||||||
|
<p>Contraseña incorrecta</p>
|
||||||
|
</div>
|
||||||
<input [(ngModel)]="passwordInput" type="password" name="passwordInput" id="passwordInput" placeholder="qwerty..." />
|
<input [(ngModel)]="passwordInput" type="password" name="passwordInput" id="passwordInput" placeholder="qwerty..." />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -15,13 +15,7 @@
|
||||||
<fa-icon icon="arrow-left"></fa-icon> <span jhiTranslate="entity.action.cancel">Cancel</span>
|
<fa-icon icon="arrow-left"></fa-icon> <span jhiTranslate="entity.action.cancel">Cancel</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button
|
<button class="ds-btn ds-btn--primary" (click)="submitPassword()">
|
||||||
id="jhi-confirm-delete-option"
|
|
||||||
data-cy="submit"
|
|
||||||
type="submit"
|
|
||||||
class="ds-btn ds-btn--primary"
|
|
||||||
[disabled]="passwordForm.get('password')!.invalid"
|
|
||||||
>
|
|
||||||
<span jhiTranslate="entity.action.submit">Submit</span>
|
<span jhiTranslate="entity.action.submit">Submit</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { FormBuilder, Validators } from '@angular/forms';
|
|
||||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
import { IEncuesta } from '../encuesta.model';
|
import { IEncuesta } from '../encuesta.model';
|
||||||
|
|
||||||
|
@ -9,21 +8,16 @@ import { IEncuesta } from '../encuesta.model';
|
||||||
styleUrls: ['./encuesta-password-dialog.component.scss'],
|
styleUrls: ['./encuesta-password-dialog.component.scss'],
|
||||||
})
|
})
|
||||||
export class EncuestaPasswordDialogComponent implements OnInit {
|
export class EncuestaPasswordDialogComponent implements OnInit {
|
||||||
passwordForm = this.fb.group({
|
|
||||||
password: [null, [Validators.required]],
|
|
||||||
});
|
|
||||||
encuesta?: IEncuesta;
|
encuesta?: IEncuesta;
|
||||||
isWrong?: boolean;
|
isWrong?: boolean;
|
||||||
passwordInput?: string;
|
passwordInput?: string;
|
||||||
|
|
||||||
constructor(protected activeModal: NgbActiveModal, protected fb: FormBuilder) {}
|
constructor(protected activeModal: NgbActiveModal) {}
|
||||||
|
|
||||||
ngOnInit(): void {}
|
ngOnInit(): void {}
|
||||||
|
|
||||||
submitPassword() {
|
submitPassword() {
|
||||||
const password = this.passwordForm.get(['password'])!.value;
|
if (this.passwordInput != undefined && this.passwordInput === this.encuesta!.contrasenna) {
|
||||||
|
|
||||||
if (this.passwordForm.valid && password === this.encuesta!.contrasenna) {
|
|
||||||
this.activeModal.close('success');
|
this.activeModal.close('success');
|
||||||
} else {
|
} else {
|
||||||
this.isWrong = true;
|
this.isWrong = true;
|
||||||
|
|
|
@ -58,7 +58,7 @@
|
||||||
[disabled]="isLoading"
|
[disabled]="isLoading"
|
||||||
data-toggle="modal"
|
data-toggle="modal"
|
||||||
data-target="#crearPregunta"
|
data-target="#crearPregunta"
|
||||||
*ngIf="encuesta!.estado !== 'FINISHED' && (isAutor() || isEscritor())"
|
*ngIf="encuesta!.estado !== 'ACTIVE' && encuesta!.estado !== 'FINISHED' && (isAutor() || isEscritor())"
|
||||||
>
|
>
|
||||||
<fa-icon icon="sync" [icon]="faPlus"></fa-icon> <span>Crear pregunta</span>
|
<fa-icon icon="sync" [icon]="faPlus"></fa-icon> <span>Crear pregunta</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
Loading…
Reference in New Issue