Merge branch 'dev' into feature/US-29

This commit is contained in:
Mariela Bonilla 2021-07-25 22:59:04 -06:00
commit b42ea0ad5a
12 changed files with 577 additions and 422 deletions

View File

@ -158,4 +158,9 @@ public class MailService {
log.debug("Sending reactivated account mail to '{}'", user.getUser().getEmail());
sendEmailFromTemplate(user.getUser(), "mail/encuestaPublicaEmail", "email.public.title");
}
public void sendEncuestaDeleted(UsuarioExtra user) {
log.debug("Sending encuesta deletion notification mail to '{}'", user.getUser().getEmail());
sendEmailFromTemplate(user.getUser(), "mail/encuestaDeletedEmail", "email.encuestaDeleted.title");
}
}

View File

@ -125,6 +125,31 @@ public class EncuestaResource {
Encuesta result = encuestaService.save(encuesta);
return ResponseEntity
.ok()
.headers(HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, encuesta.getId().toString()))
.body(result);
}
@PutMapping("/encuestas/publish/{id}")
public ResponseEntity<Encuesta> publishEncuesta(
@PathVariable(value = "id", required = false) final Long id,
@Valid @RequestBody Encuesta encuesta
) throws URISyntaxException {
log.debug("REST request to update Encuesta : {}, {}", id, encuesta);
if (encuesta.getId() == null) {
throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull");
}
if (!Objects.equals(id, encuesta.getId())) {
throw new BadRequestAlertException("Invalid ID", ENTITY_NAME, "idinvalid");
}
if (!encuestaRepository.existsById(id)) {
throw new BadRequestAlertException("Entity not found", ENTITY_NAME, "idnotfound");
}
Encuesta result = encuestaService.save(encuesta);
if (result.getAcceso().equals(AccesoEncuesta.PRIVATE)) {
mailService.sendPublishedPrivateMail(result.getUsuarioExtra(), result.getContrasenna());
} else {
@ -274,4 +299,11 @@ public class EncuestaResource {
.headers(HeaderUtil.createEntityDeletionAlert(applicationName, true, ENTITY_NAME, id.toString()))
.build();
}
@DeleteMapping("encuestas/notify/{id}")
public ResponseEntity<Void> notifyEncuestaDeleted(@PathVariable Long id, @Valid @RequestBody Encuesta encuesta) {
log.debug("REST request to notify {} of deleted Encuesta", encuesta.getUsuarioExtra().getUser().getEmail());
mailService.sendEncuestaDeleted(encuesta.getUsuarioExtra());
return ResponseEntity.noContent().build();
}
}

View File

@ -52,3 +52,9 @@ email.private.title=Su encuesta ha sido publicada de manera privada
email.private.greeting=¡Felicidades {0}!
email.private.text1=Su encuesta ha sdo publicada de manera privada. Su contraseña de acceso es: {0}
email.private.text2=Saludos,
#DeletedEncuesta
email.encuestaDeleted.title=Su encuesta ha sido eliminada
email.encuestaDeleted.greeting=Estimado {0}
email.encuestaDeleted.text1=Su encuesta ha sido eliminada por un administrador
email.encuestaDeleted.text2=Saludos,

View File

@ -0,0 +1,310 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" th:lang="${#locale.language}" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width" />
<!-- Forcing initial-scale shouldn't be necessary -->
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!-- Use the latest (edge) version of IE rendering engine -->
<meta name="x-apple-disable-message-reformatting" />
<!-- Disable auto-scale in iOS 10 Mail entirely -->
<title th:text="#{email.encuestaDeleted.title}">Encuesta Eliminada</title>
<link rel="icon" th:href="@{|${baseUrl}/favicon.ico|}" />
<link href="https://fonts.googleapis.com/css?family=NotoSansSP:300,400,700" rel="stylesheet" />
<link rel="manifest" href="manifest.webapp" />
<style>
.bg_white {
background: #ffffff;
}
.bg_light {
background: #fafafa;
}
.bg_black {
background: #000000;
}
.bg_dark {
background: rgba(0, 0, 0, 0.8);
}
.email-section {
padding: 2.5em;
}
/*BUTTON*/
.btn {
padding: 10px 15px;
display: inline-block;
}
.btn.btn-primary {
border-radius: 5px;
background: #007bff;
color: #ffffff;
}
.btn.btn-white {
border-radius: 5px;
background: #ffffff;
color: #000000;
}
.btn.btn-white-outline {
border-radius: 5px;
background: transparent;
border: 1px solid #fff;
color: #fff;
}
.btn.btn-black-outline {
border-radius: 0px;
background: transparent;
border: 2px solid #000;
color: #000;
font-weight: 700;
}
h1,
h2,
h3,
h4,
h5,
h6 {
font-family: 'Lato', sans-serif;
color: #000000;
margin-top: 0;
font-weight: 400;
}
body {
font-family: 'Noto Sans JP', sans-serif;
font-weight: 400;
font-size: 15px;
line-height: 1.8;
color: rgba(0, 0, 0, 0.4);
}
a {
color: #30e3ca;
}
table {
}
/*LOGO*/
.logo h1 {
margin: 0;
}
.logo h1 a {
color: #30e3ca;
font-size: 24px;
font-weight: 700;
font-family: 'Lato', sans-serif;
}
/*HERO*/
.hero {
position: relative;
z-index: 0;
}
.hero .text {
color: rgba(0, 0, 0, 0.3);
}
.hero .text h2 {
color: #000;
font-size: 40px;
margin-bottom: 0;
font-weight: 400;
line-height: 1.4;
}
.hero .text h3 {
font-size: 24px;
font-weight: 300;
}
.hero .text h2 span {
font-weight: 600;
color: #30e3ca;
}
/*HEADING SECTION*/
.heading-section {
}
.heading-section h2 {
color: #000000;
font-size: 28px;
margin-top: 0;
line-height: 1.4;
font-weight: 400;
}
.heading-section .subheading {
margin-bottom: 20px !important;
display: inline-block;
font-size: 13px;
text-transform: uppercase;
letter-spacing: 2px;
color: rgba(0, 0, 0, 0.4);
position: relative;
}
.heading-section .subheading::after {
position: absolute;
left: 0;
right: 0;
bottom: -10px;
content: '';
width: 100%;
height: 2px;
background: #30e3ca;
margin: 0 auto;
}
.heading-section-white {
color: rgba(255, 255, 255, 0.8);
}
.heading-section-white h2 {
/*font-family: ;*/
line-height: 1;
padding-bottom: 0;
}
.heading-section-white h2 {
color: #ffffff;
}
.heading-section-white .subheading {
margin-bottom: 0;
display: inline-block;
font-size: 13px;
text-transform: uppercase;
letter-spacing: 2px;
color: rgba(255, 255, 255, 0.4);
}
ul.social {
padding: 0;
}
ul.social li {
display: inline-block;
margin-right: 10px;
}
.footer {
border-top: 1px solid rgba(0, 0, 0, 0.05);
color: rgba(0, 0, 0, 0.5);
}
.footer .heading {
color: #000;
font-size: 20px;
}
.footer ul {
margin: 0;
padding: 0;
}
.footer ul li {
list-style: none;
margin-bottom: 10px;
}
.footer ul li a {
color: rgba(0, 0, 0, 1);
}
</style>
</head>
<body width="100%" style="margin: 0; padding: 0 !important; mso-line-height-rule: exactly; background-color: #f1f1f1">
<center style="width: 100%; background-color: #f1f1f1">
<div
style="
display: none;
font-size: 1px;
max-height: 0px;
max-width: 0px;
opacity: 0;
overflow: hidden;
mso-hide: all;
font-family: sans-serif;
"
>
&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;
</div>
<div style="max-width: 600px; margin: 0 auto" class="email-container">
<!-- BEGIN BODY -->
<table align="center" role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%" style="margin: auto">
<tr>
<td valign="top" class="bg_white" style="padding: 1em 2.5em 0 2.5em">
<table role="presentation" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td class="logo" style="text-align: center">
<h1>
<a href="#"
><img
src="https://res.cloudinary.com/marielascloud/image/upload/v1626333881/DataSurveyLogo2_smr2ok.png"
alt=""
width="300"
/></a>
</h1>
</td>
</tr>
</table>
</td>
</tr>
<!-- end tr -->
<tr>
<td valign="middle" class="hero bg_white" style="padding: 3em 0 2em 0">
<img
src="https://res.cloudinary.com/marielascloud/image/upload/v1626333882/email_v7pjtv.png"
alt=""
style="width: 300px; max-width: 600px; height: auto; margin: auto; display: block"
/>
</td>
</tr>
<!-- end tr -->
<tr>
<td valign="middle" class="hero bg_white" style="padding: 2em 0 4em 0">
<table>
<tr>
<td>
<div class="text" style="padding: 0 2.5em; text-align: center">
<h2 th:text="#{email.encuestaDeleted.greeting(${user.login})}">¡Encuesta eliminada!</h2>
<h3 th:text="#{email.encuestaDeleted.text1}">¡Su encuesta ha sido eliminada exitosamente!</h3>
</div>
</td>
</tr>
</table>
</td>
</tr>
<!-- end tr -->
<!-- 1 Column Text + Button : END -->
</table>
<table align="center" role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%" style="margin: auto">
<tr>
<td valign="middle" class="bg_light footer email-section">
<table>
<tr>
<td valign="top" width="33.333%" style="padding-top: 20px">
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td style="text-align: left; padding-right: 10px">
<h3 class="heading">Acerca de</h3>
<p>DataSurvey es su compañero más cercano para poder recolectar información valiosa para usted.</p>
</td>
</tr>
</table>
</td>
<td valign="top" width="33.333%" style="padding-top: 20px">
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td style="text-align: left; padding-left: 5px; padding-right: 5px">
<h3 class="heading">Información de contacto</h3>
<ul>
<li><span href="mailto:datasurveyapp@gmail.com" class="text">datasurveyapp@gmail.com</span></li>
</ul>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<!-- end: tr -->
<tr>
<td class="bg_light" style="text-align: center">
<p><a href="https://datasurvey.org" style="color: rgba(0, 0, 0, 0.8)">DataSurvey.org</a></p>
</td>
</tr>
</table>
</div>
</center>
</body>
</html>

View File

@ -3,12 +3,14 @@ import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { IEncuesta } from '../encuesta.model';
import { EncuestaService } from '../service/encuesta.service';
import { EstadoEncuesta } from 'app/entities/enumerations/estado-encuesta.model';
import { IUsuarioExtra } from 'app/entities/usuario-extra/usuario-extra.model';
@Component({
templateUrl: './encuesta-delete-dialog.component.html',
})
export class EncuestaDeleteDialogComponent {
encuesta?: IEncuesta;
usuarioExtra?: IUsuarioExtra;
constructor(protected encuestaService: EncuestaService, protected activeModal: NgbActiveModal) {}
@ -16,10 +18,14 @@ export class EncuestaDeleteDialogComponent {
this.activeModal.dismiss();
}
confirmDelete(encuest: IEncuesta): void {
encuest.estado = EstadoEncuesta.DELETED;
this.encuestaService.deleteEncuesta(encuest).subscribe(() => {
confirmDelete(encuesta: IEncuesta): void {
encuesta.estado = EstadoEncuesta.DELETED;
this.encuestaService.deleteEncuesta(encuesta).subscribe(() => {
this.activeModal.close('deleted');
});
if (encuesta.usuarioExtra != undefined) {
const userEmail = encuesta.usuarioExtra!.user!.login;
this.encuestaService.deletedNotification(userEmail!);
}
}
}

View File

@ -21,7 +21,6 @@ export class EncuestaPublishDialogComponent implements OnInit {
}
confirmPublish(encuesta: IEncuesta): void {
debugger;
if (encuesta.estado === 'DRAFT') {
encuesta.estado = EstadoEncuesta.ACTIVE;
}
@ -30,13 +29,12 @@ export class EncuestaPublishDialogComponent implements OnInit {
encuesta.contrasenna = this.generatePassword();
}
this.encuestaService.update(encuesta).subscribe(() => {
this.encuestaService.publishEncuesta(encuesta).subscribe(() => {
this.activeModal.close('published');
});
}
generatePassword(): string {
debugger;
const alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
let password = '';

View File

@ -85,14 +85,8 @@
<div class="ds-contextmenu ds-contextmenu--closed" id="contextmenu">
<ul id="ds-context-menu__list">
<div class="ds-contextmenu__divider ds-contextmenu__divider--separator-bottom" id="contextmenu-create--separator">
<li>
<button
*ngIf="!isAdmin() && isAuthenticated()"
type="button"
(click)="resetForm()"
data-toggle="modal"
data-target="#crearEncuesta"
>
<li *ngIf="!isAdmin() && isAuthenticated()">
<button type="button" (click)="resetForm()" data-toggle="modal" data-target="#crearEncuesta">
<fa-icon class="contextmenu__icon" [icon]="faPlus"></fa-icon>Crear
</button>
</li>
@ -114,15 +108,14 @@
(click)="publish()"
data-toggle="modal"
data-target="#publicarEncuesta"
*ngIf="isPublished"
>
<!--Agarrar el id de la encuesta -->
<fa-icon class="contextmenu__icon" [icon]="faUpload"></fa-icon>Publicar
</button>
</li>
<li>
<!-- <li>
<button type="button" id="contextmenu-share"><fa-icon class="contextmenu__icon" [icon]="faShareAlt"></fa-icon>Compartir</button>
</li>
</li> -->
</div>
<div class="ds-contextmenu__divider" id="contextmenu-delete--separator">
<li>
@ -303,7 +296,7 @@
<thead>
<tr>
<th scope="col"><span jhiTranslate="dataSurveyApp.encuesta.nombre">Nombre</span></th>
<th scope="col"><span jhiTranslate="dataSurveyApp.encuesta.fechaCreacion">Fecha Creacion</span></th>
<th scope="col"><span jhiTranslate="dataSurveyApp.encuesta.fechaCreacion">Fecha Creación</span></th>
<th scope="col"><span jhiTranslate="dataSurveyApp.encuesta.acceso">Acceso</span></th>
<th scope="col"><span jhiTranslate="dataSurveyApp.encuesta.estado">Estado</span></th>
<th scope="col"><span jhiTranslate="dataSurveyApp.encuesta.categoria">Categoria</span></th>

View File

@ -59,7 +59,7 @@ export class EncuestaComponent implements OnInit, AfterViewInit {
faPlus = faPlus;
faStar = faStar;
faUpload = faUpload;
isPublished = false;
isPublished: Boolean = false;
successPublished = false;
faPollH = faPollH;
account: Account | null = null;
@ -75,7 +75,6 @@ export class EncuestaComponent implements OnInit, AfterViewInit {
usuarioExtrasSharedCollection: IUsuarioExtra[] = [];
userSharedCollection: IUser[] = [];
selectedIdSurvey: number | null = null;
encuestaencontrada: IEncuesta | null = null;
public searchString: string;
@ -100,7 +99,7 @@ export class EncuestaComponent implements OnInit, AfterViewInit {
});
createAnother: Boolean = false;
selectedSurveyId: Number = 0;
selectedSurveyId: number | null = null;
constructor(
protected encuestaService: EncuestaService,
@ -126,7 +125,7 @@ export class EncuestaComponent implements OnInit, AfterViewInit {
this.usuarioExtraService
.retrieveAllPublicUsers()
.pipe(finalize(() => this.loadUserExtras()))
.pipe(finalize(() => this.loadPublicUser()))
.subscribe(res => {
this.userSharedCollection = res;
});
@ -253,8 +252,8 @@ export class EncuestaComponent implements OnInit, AfterViewInit {
}
deleteSurvey(): void {
if (this.selectedIdSurvey != null) {
this.getEncuesta(this.selectedIdSurvey)
if (this.selectedSurveyId != null) {
this.getEncuesta(this.selectedSurveyId)
.pipe(
finalize(() => {
const modalRef = this.modalService.open(EncuestaDeleteDialogComponent, { size: 'lg', backdrop: 'static' });
@ -450,13 +449,12 @@ export class EncuestaComponent implements OnInit, AfterViewInit {
}
async openContextMenu(event: any): Promise<void> {
document.querySelectorAll('.ds-list--entity').forEach(e => {
e.classList.remove('active');
});
if (event.type === 'contextmenu') {
event.preventDefault();
this.selectedSurveyId = event.target.dataset.id;
if (event.target === null) return;
document.querySelectorAll('.ds-list--entity').forEach(e => {
e.classList.remove('active');
});
let res = await this.encuestaService.find(this.selectedSurveyId).toPromise();
this.selectedSurvey = res.body;
@ -473,14 +471,31 @@ export class EncuestaComponent implements OnInit, AfterViewInit {
document.getElementById('contextmenu-share')!.style.display = 'block';
if ((event.target as HTMLElement).classList.contains('ds-list')) {
document;
document.getElementById('contextmenu-create--separator')!.style.display = 'block';
document.getElementById('contextmenu-edit--separator')!.style.display = 'none';
document.getElementById('contextmenu-delete--separator')!.style.display = 'none';
} else if ((event.target as HTMLElement).classList.contains('ds-list--entity')) {
this.selectedSurveyId = Number(event.target.dataset.id);
event.target.classList.add('active');
document.getElementById('contextmenu-create--separator')!.style.display = 'none';
this.selectedIdSurvey = Number(event.target.dataset.id);
//this.selectedSurvey = event.target.dataset.encuesta;
let res = await this.encuestaService.find(this.selectedSurveyId).toPromise();
this.selectedSurvey = res.body;
this.isPublished = this.selectedSurvey!.estado === 'ACTIVE' || this.selectedSurvey!.estado === 'FINISHED'; // QUE SE LE MUESTRE CUANDO ESTE EN DRAFT
document.getElementById('contextmenu-create--separator')!.style.display = 'none';
document.getElementById('contextmenu-edit--separator')!.style.display = 'block';
document.getElementById('contextmenu-delete--separator')!.style.display = 'block';
document.getElementById('contextmenu-edit')!.style.display = 'block';
document.getElementById('contextmenu-duplicate')!.style.display = 'block';
if (!this.isPublished) {
document.getElementById('contextmenu-publish')!.style.display = 'block';
} else {
document.getElementById('contextmenu-publish')!.style.display = 'none';
}
// document.getElementById('contextmenu-share')!.style.display = 'block';
document.getElementById('contextmenu-create--separator')!.style.display = 'none';
}
document.getElementById('contextmenu')!.style.top = event.layerY + 'px';

View File

@ -61,6 +61,13 @@ export class EncuestaService {
.pipe(map((res: EntityResponseType) => this.convertDateFromServer(res)));
}
publishEncuesta(encuesta: IEncuesta): Observable<EntityResponseType> {
//const copy = this.convertDateFromClient(encuesta);
return this.http.put<IEncuesta>(`${this.resourceUrl}/publish/${getEncuestaIdentifier(encuesta) as number}`, encuesta, {
observe: 'response',
});
}
deleteEncuesta(encuesta: IEncuesta): Observable<EntityResponseType> {
//const copy = this.convertDateFromClient(encuesta);
return this.http.put<IEncuesta>(`${this.resourceUrl}/${getEncuestaIdentifier(encuesta) as number}`, encuesta, { observe: 'response' });
@ -77,6 +84,10 @@ export class EncuestaService {
return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' });
}
deletedNotification(email: string): Observable<HttpResponse<{}>> {
return this.http.delete(`${this.resourceUrl}/${email}`, { observe: 'response' });
}
addEncuestaToCollectionIfMissing(encuestaCollection: IEncuesta[], ...encuestasToCheck: (IEncuesta | null | undefined)[]): IEncuesta[] {
const encuestas: IEncuesta[] = encuestasToCheck.filter(isPresent);
if (encuestas.length > 0) {

View File

@ -1,6 +1,16 @@
<div>
<h2 id="page-heading" data-cy="EPreguntaCerradaHeading">
<p class="ds-title">{{ encuesta!.nombre }}</p>
<div class="d-flex align-items-center">
<p class="ds-title">{{ encuesta!.nombre }}</p>
&nbsp;&nbsp;<fa-icon
class="ds-info--icon"
[icon]="faQuestion"
data-toggle="modal"
data-target="#verParametros"
(click)="loadAplicationParameters()"
></fa-icon>
</div>
<p class="ds-subtitle">Creada el día {{ encuesta!.fechaCreacion | formatShortDatetime | lowercase }}</p>
<div class="d-flex justify-content-end">
@ -13,7 +23,7 @@
<button
type="button"
class="ds-btn ds-btn--secondary"
class="ds-btn ds-btn--primary"
(click)="createQuestion()"
[disabled]="isLoading"
data-toggle="modal"
@ -30,6 +40,7 @@
<ng-container *ngIf="encuesta!.estado === 'ACTIVE'">
<button type="button" class="ds-btn ds-btn--danger" (click)="finishSurvey()">Finalizar encuesta</button>
</ng-container>
-->
</div>
</h2>
@ -37,147 +48,100 @@
<!-- <jhi-alert></jhi-alert> -->
<div class="alert alert-warning" id="no-result" *ngIf="ePreguntas?.length === 0">
<!-- <div class="alert alert-warning" id="no-result" *ngIf="ePreguntas?.length === 0">
<span>No se encontraron preguntas</span>
</div>
<div class="ds-survey" id="entities" *ngIf="ePreguntas && ePreguntas.length > 0">
</div> -->
<!-- *ngIf="ePreguntas && ePreguntas.length > 0" -->
<div class="ds-survey" id="entities">
<div class="ds-survey--all-question-wrapper">
<div class="ds-survey--question-wrapper" *ngFor="let ePregunta of ePreguntas; let i = index; trackBy: trackId">
<div
[attr.data-index]="ePregunta.id"
[attr.data-tipo]="ePregunta.tipo"
[attr.data-opcional]="ePregunta.opcional"
class="ds-survey--question"
>
<div class="ds-survey--titulo">
<span class="ds-survey--titulo--name">{{ i + 1 }}. {{ ePregunta.nombre }}</span>
<fa-icon
*ngIf="encuesta!.estado === 'DRAFT'"
class="ds-survey--titulo--icon"
[icon]="faTimes"
(click)="deleteQuestion($event)"
[attr.data-id]="ePregunta.id"
[attr.data-type]="ePregunta.tipo"
></fa-icon>
</div>
<div>
<span *ngIf="ePregunta.tipo === 'SINGLE'" class="ds-subtitle"
>Pregunta de respuesta {{ 'dataSurveyApp.PreguntaCerradaTipo.SINGLE' | translate | lowercase }}
{{ ePregunta.opcional ? '(opcional)' : '' }}</span
>
<span *ngIf="ePregunta.tipo === 'MULTIPLE'" class="ds-subtitle"
>Pregunta de respuesta {{ 'dataSurveyApp.PreguntaCerradaTipo.MULTIPLE' | translate | lowercase }}
{{ ePregunta.opcional ? '(opcional)' : '' }}</span
>
<span *ngIf="!ePregunta.tipo" class="ds-subtitle"
>Pregunta de respuesta abierta {{ ePregunta.opcional ? '(opcional)' : '' }}</span
>
</div>
<ng-container *ngIf="ePregunta.tipo">
<ng-container *ngFor="let ePreguntaOpcion of ePreguntasOpciones; let j = index; trackBy: trackId">
<ng-container *ngFor="let ePreguntaOpcionFinal of ePreguntaOpcion">
<ng-container *ngIf="ePregunta.id === ePreguntaOpcionFinal.epreguntaCerrada.id">
<div
class="ds-survey--option ds-survey--option--base ds-survey--closed-option can-delete"
[attr.data-id]="ePreguntaOpcionFinal.id"
>
<!-- <input class="ds-survey--checkbox" id="{{ ePregunta.id }}-{{ ePreguntaOpcionFinal.id }}" type="checkbox" disabled /> -->
<!-- <label for="{{ ePregunta.id }}-{{ ePreguntaOpcionFinal.id }}">{{ ePreguntaOpcionFinal.nombre }}</label> -->
<label>{{ ePreguntaOpcionFinal.nombre }}</label>
<fa-icon
*ngIf="encuesta!.estado === 'DRAFT'"
class="ds-survey--titulo--icon ds-survey--titulo--icon--small"
[icon]="faTimes"
(click)="deleteOption($event)"
[attr.data-optionid]="ePreguntaOpcionFinal.id"
></fa-icon>
</div>
</ng-container>
</ng-container>
</ng-container>
<div
class="ds-survey--option ds-survey--option--add ds-survey--closed-option"
(click)="resetForm($event)"
data-toggle="modal"
data-target="#crearOpcion"
[attr.data-id]="ePregunta.id"
>
<ng-container *ngIf="encuesta!.estado === 'ACTIVE'">
<p class="ds-title text-center">Encuesta en progreso</p>
<p class="ds-subtitle">No puede modificar la encuesta debido a que esta ya está en progreso.</p>
</ng-container>
<ng-container *ngIf="encuesta!.estado === 'FINISHED'">
<p class="ds-title text-center">Encuesta finalizada</p>
<p class="ds-subtitle">No puede modificar la encuesta debido a que esta ya ha concluido.</p>
</ng-container>
<ng-container *ngIf="encuesta!.estado === 'DRAFT' && ePreguntas && ePreguntas.length === 0">
<p class="ds-title text-center">Encuesta vacía</p>
<p class="ds-subtitle">Inicie creando preguntas y opciones para su encuesta.</p>
</ng-container>
<ng-container *ngIf="encuesta!.estado === 'DRAFT'">
<div class="ds-survey--question-wrapper" *ngFor="let ePregunta of ePreguntas; let i = index; trackBy: trackId">
<div
[attr.data-index]="ePregunta.id"
[attr.data-tipo]="ePregunta.tipo"
[attr.data-opcional]="ePregunta.opcional"
class="ds-survey--question"
>
<div class="ds-survey--titulo">
<span class="ds-survey--titulo--name">{{ i + 1 }}. {{ ePregunta.nombre }}</span>
<fa-icon
class="ds-survey--add-option--icon"
[icon]="faPlus"
*ngIf="encuesta!.estado === 'DRAFT'"
class="ds-survey--titulo--icon"
[icon]="faTimes"
(click)="deleteQuestion($event)"
[attr.data-id]="ePregunta.id"
[attr.data-type]="ePregunta.tipo"
></fa-icon>
<span class="ds-survey--add-option">Añadir opción</span>
</div>
</ng-container>
<div class="ds-survey--option ds-survey--option--base ds-survey--open-option" *ngIf="!ePregunta.tipo">
<textarea name="" id="" cols="30" rows="10" disabled></textarea>
<div>
<span *ngIf="ePregunta.tipo === 'SINGLE'" class="ds-subtitle"
>Pregunta de respuesta {{ 'dataSurveyApp.PreguntaCerradaTipo.SINGLE' | translate | lowercase }}
{{ ePregunta.opcional ? '(opcional)' : '' }}</span
>
<span *ngIf="ePregunta.tipo === 'MULTIPLE'" class="ds-subtitle"
>Pregunta de respuesta {{ 'dataSurveyApp.PreguntaCerradaTipo.MULTIPLE' | translate | lowercase }}
{{ ePregunta.opcional ? '(opcional)' : '' }}</span
>
<span *ngIf="!ePregunta.tipo" class="ds-subtitle"
>Pregunta de respuesta abierta {{ ePregunta.opcional ? '(opcional)' : '' }}</span
>
</div>
<ng-container *ngIf="ePregunta.tipo">
<ng-container *ngFor="let ePreguntaOpcion of ePreguntasOpciones; let j = index; trackBy: trackId">
<ng-container *ngFor="let ePreguntaOpcionFinal of ePreguntaOpcion">
<ng-container *ngIf="ePregunta.id === ePreguntaOpcionFinal.epreguntaCerrada.id">
<div
class="ds-survey--option ds-survey--option--base ds-survey--closed-option can-delete"
[attr.data-id]="ePreguntaOpcionFinal.id"
>
<!-- <input class="ds-survey--checkbox" id="{{ ePregunta.id }}-{{ ePreguntaOpcionFinal.id }}" type="checkbox" disabled /> -->
<label for="{{ ePregunta.id }}-{{ ePreguntaOpcionFinal.id }}">{{ ePreguntaOpcionFinal.nombre }}</label>
<fa-icon
*ngIf="encuesta!.estado === 'DRAFT'"
class="ds-survey--titulo--icon ds-survey--titulo--icon--small"
[icon]="faTimes"
(click)="deleteOption($event)"
[attr.data-optionid]="ePreguntaOpcionFinal.id"
></fa-icon>
</div>
</ng-container>
</ng-container>
</ng-container>
<div
class="ds-survey--option ds-survey--option--add ds-survey--closed-option"
(click)="resetForm($event)"
data-toggle="modal"
data-target="#crearOpcion"
[attr.data-id]="ePregunta.id"
>
<fa-icon
class="ds-survey--add-option--icon"
[icon]="faPlus"
[attr.data-id]="ePregunta.id"
[attr.data-type]="ePregunta.tipo"
></fa-icon>
<span class="ds-survey--add-option">Añadir opción</span>
</div>
</ng-container>
<div class="ds-survey--option ds-survey--option--base ds-survey--open-option" *ngIf="!ePregunta.tipo">
<textarea name="" id="" cols="30" rows="10" disabled></textarea>
</div>
</div>
</div>
</div>
</ng-container>
</div>
<!-- <table class="table table-striped" aria-describedby="page-heading">
<thead>
<tr>
<th scope="col"><span jhiTranslate="global.field.id">ID</span></th>
<th scope="col"><span jhiTranslate="dataSurveyApp.ePreguntaCerrada.nombre">Nombre</span></th>
<th scope="col"><span jhiTranslate="dataSurveyApp.ePreguntaCerrada.tipo">Tipo</span></th>
<th scope="col"><span jhiTranslate="dataSurveyApp.ePreguntaCerrada.opcional">Opcional</span></th>
<th scope="col"><span jhiTranslate="dataSurveyApp.ePreguntaCerrada.orden">Orden</span></th>
<th scope="col"><span jhiTranslate="dataSurveyApp.ePreguntaCerrada.encuesta">Encuesta</span></th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<tr *ngFor="let ePreguntaCerrada of ePreguntaCerradas; trackBy: trackId" data-cy="entityTable">
<td>
<a [routerLink]="['/e-pregunta-cerrada', ePreguntaCerrada.id, 'view']">{{ ePreguntaCerrada.id }}</a>
</td>
<td>{{ ePreguntaCerrada.nombre }}</td>
<td *ngIf="ePreguntaCerrada.tipo != undefined" jhiTranslate="{{ 'dataSurveyApp.PreguntaCerradaTipo.' + ePreguntaCerrada.tipo }}">{{ ePreguntaCerrada.tipo }}</td>
<td *ngIf="ePreguntaCerrada.tipo == undefined"></td>
<td>{{ ePreguntaCerrada.opcional }}</td>
<td>{{ ePreguntaCerrada.orden }}</td>
<td>
<div *ngIf="ePreguntaCerrada.encuesta">
<a [routerLink]="['/encuesta', ePreguntaCerrada.encuesta?.id, 'view']">{{ ePreguntaCerrada.encuesta?.id }}</a>
</div>
</td>
<td class="text-right">
<div class="btn-group">
<button
type="submit"
[routerLink]="['/e-pregunta-cerrada', ePreguntaCerrada.id, 'view']"
class="btn btn-info btn-sm"
data-cy="entityDetailsButton"
>
<fa-icon icon="eye"></fa-icon>
<span class="d-none d-md-inline" jhiTranslate="entity.action.view">View</span>
</button>
<button
type="submit"
[routerLink]="['/e-pregunta-cerrada', ePreguntaCerrada.id, 'edit']"
class="btn btn-primary btn-sm"
data-cy="entityEditButton"
>
<fa-icon icon="pencil-alt"></fa-icon>
<span class="d-none d-md-inline" jhiTranslate="entity.action.edit">Edit</span>
</button>
<button type="submit" (click)="delete(ePreguntaCerrada)" class="btn btn-danger btn-sm" data-cy="entityDeleteButton">
<fa-icon icon="times"></fa-icon>
<span class="d-none d-md-inline" jhiTranslate="entity.action.delete">Delete</span>
</button>
</div>
</td>
</tr>
</tbody>
</table> -->
</div>
</div>
@ -400,265 +364,48 @@
<!-- ------------------------------------------------------------------------------------------------- -->
<!-- <div class="row justify-content-center">
<div class="col-8">
<form name="editForm" role="form" novalidate (ngSubmit)="save()" [formGroup]="editForm">
<h2 id="jhi-encuesta-heading" data-cy="EncuestaCreateUpdateHeading" jhiTranslate="dataSurveyApp.encuesta.home.createOrEditLabel">
Create or edit a Encuesta
</h2>
<div>
<jhi-alert-error></jhi-alert-error>
<div class="form-group" [hidden]="editForm.get('id')!.value == null">
<label class="form-control-label" jhiTranslate="global.field.id" for="field_id">ID</label>
<input type="number" class="form-control" name="id" id="field_id" data-cy="id" formControlName="id" [readonly]="true" />
</div>
<div class="form-group">
<label class="form-control-label" jhiTranslate="dataSurveyApp.encuesta.nombre" for="field_nombre">Nombre</label>
<input type="text" class="form-control" name="nombre" id="field_nombre" data-cy="nombre" formControlName="nombre" />
<div *ngIf="editForm.get('nombre')!.invalid && (editForm.get('nombre')!.dirty || editForm.get('nombre')!.touched)">
<small class="form-text text-danger" *ngIf="editForm.get('nombre')?.errors?.required" jhiTranslate="entity.validation.required">
This field is required.
</small>
<small
class="form-text text-danger"
*ngIf="editForm.get('nombre')?.errors?.minlength"
jhiTranslate="entity.validation.minlength"
[translateValues]="{ min: 1 }"
>
This field is required to be at least 1 characters.
</small>
<small
class="form-text text-danger"
*ngIf="editForm.get('nombre')?.errors?.maxlength"
jhiTranslate="entity.validation.maxlength"
[translateValues]="{ max: 50 }"
>
This field cannot be longer than 50 characters.
</small>
</div>
</div>
<div class="form-group">
<label class="form-control-label" jhiTranslate="dataSurveyApp.encuesta.descripcion" for="field_descripcion">Descripcion</label>
<input
type="text"
class="form-control"
name="descripcion"
id="field_descripcion"
data-cy="descripcion"
formControlName="descripcion"
/>
</div>
<div class="form-group">
<label class="form-control-label" jhiTranslate="dataSurveyApp.encuesta.fechaCreacion" for="field_fechaCreacion"
>Fecha Creacion</label
>
<div class="d-flex">
<input
id="field_fechaCreacion"
data-cy="fechaCreacion"
type="datetime-local"
class="form-control"
name="fechaCreacion"
formControlName="fechaCreacion"
placeholder="YYYY-MM-DD HH:mm"
/>
</div>
<div
*ngIf="
editForm.get('fechaCreacion')!.invalid && (editForm.get('fechaCreacion')!.dirty || editForm.get('fechaCreacion')!.touched)
"
>
<small
class="form-text text-danger"
*ngIf="editForm.get('fechaCreacion')?.errors?.required"
jhiTranslate="entity.validation.required"
>
This field is required.
</small>
<small
class="form-text text-danger"
[hidden]="!editForm.get('fechaCreacion')?.errors?.ZonedDateTimelocal"
jhiTranslate="entity.validation.ZonedDateTimelocal"
>
This field should be a date and time.
</small>
</div>
</div>
<div class="form-group">
<label class="form-control-label" jhiTranslate="dataSurveyApp.encuesta.fechaPublicacion" for="field_fechaPublicacion"
>Fecha Publicacion</label
>
<div class="d-flex">
<input
id="field_fechaPublicacion"
data-cy="fechaPublicacion"
type="datetime-local"
class="form-control"
name="fechaPublicacion"
formControlName="fechaPublicacion"
placeholder="YYYY-MM-DD HH:mm"
/>
</div>
</div>
<div class="form-group">
<label class="form-control-label" jhiTranslate="dataSurveyApp.encuesta.fechaFinalizar" for="field_fechaFinalizar"
>Fecha Finalizar</label
>
<div class="d-flex">
<input
id="field_fechaFinalizar"
data-cy="fechaFinalizar"
type="datetime-local"
class="form-control"
name="fechaFinalizar"
formControlName="fechaFinalizar"
placeholder="YYYY-MM-DD HH:mm"
/>
</div>
</div>
<div class="form-group">
<label class="form-control-label" jhiTranslate="dataSurveyApp.encuesta.fechaFinalizada" for="field_fechaFinalizada"
>Fecha Finalizada</label
>
<div class="d-flex">
<input
id="field_fechaFinalizada"
data-cy="fechaFinalizada"
type="datetime-local"
class="form-control"
name="fechaFinalizada"
formControlName="fechaFinalizada"
placeholder="YYYY-MM-DD HH:mm"
/>
</div>
</div>
<div class="form-group">
<label class="form-control-label" jhiTranslate="dataSurveyApp.encuesta.calificacion" for="field_calificacion">Calificacion</label>
<input
type="number"
class="form-control"
name="calificacion"
id="field_calificacion"
data-cy="calificacion"
formControlName="calificacion"
/>
<div
*ngIf="editForm.get('calificacion')!.invalid && (editForm.get('calificacion')!.dirty || editForm.get('calificacion')!.touched)"
>
<small
class="form-text text-danger"
*ngIf="editForm.get('calificacion')?.errors?.required"
jhiTranslate="entity.validation.required"
>
This field is required.
</small>
<small
class="form-text text-danger"
[hidden]="!editForm.get('calificacion')?.errors?.number"
jhiTranslate="entity.validation.number"
>
This field should be a number.
</small>
</div>
</div>
<div class="form-group">
<label class="form-control-label" jhiTranslate="dataSurveyApp.encuesta.acceso" for="field_acceso">Acceso</label>
<select class="form-control" name="acceso" formControlName="acceso" id="field_acceso" data-cy="acceso">
<option [ngValue]="null">{{ 'dataSurveyApp.AccesoEncuesta.null' | translate }}</option>
<option value="PUBLIC">{{ 'dataSurveyApp.AccesoEncuesta.PUBLIC' | translate }}</option>
<option value="PRIVATE">{{ 'dataSurveyApp.AccesoEncuesta.PRIVATE' | translate }}</option>
</select>
<div *ngIf="editForm.get('acceso')!.invalid && (editForm.get('acceso')!.dirty || editForm.get('acceso')!.touched)">
<small class="form-text text-danger" *ngIf="editForm.get('acceso')?.errors?.required" jhiTranslate="entity.validation.required">
This field is required.
</small>
</div>
</div>
<div class="form-group">
<label class="form-control-label" jhiTranslate="dataSurveyApp.encuesta.contrasenna" for="field_contrasenna">Contrasenna</label>
<input
type="text"
class="form-control"
name="contrasenna"
id="field_contrasenna"
data-cy="contrasenna"
formControlName="contrasenna"
/>
</div>
<div class="form-group">
<label class="form-control-label" jhiTranslate="dataSurveyApp.encuesta.estado" for="field_estado">Estado</label>
<select class="form-control" name="estado" formControlName="estado" id="field_estado" data-cy="estado">
<option [ngValue]="null">{{ 'dataSurveyApp.EstadoEncuesta.null' | translate }}</option>
<option value="DRAFT">{{ 'dataSurveyApp.EstadoEncuesta.DRAFT' | translate }}</option>
<option value="ACTIVE">{{ 'dataSurveyApp.EstadoEncuesta.ACTIVE' | translate }}</option>
<option value="FINISHED">{{ 'dataSurveyApp.EstadoEncuesta.FINISHED' | translate }}</option>
<option value="DELETED">{{ 'dataSurveyApp.EstadoEncuesta.DELETED' | translate }}</option>
</select>
<div *ngIf="editForm.get('estado')!.invalid && (editForm.get('estado')!.dirty || editForm.get('estado')!.touched)">
<small class="form-text text-danger" *ngIf="editForm.get('estado')?.errors?.required" jhiTranslate="entity.validation.required">
This field is required.
</small>
</div>
</div>
<div class="form-group">
<label class="form-control-label" jhiTranslate="dataSurveyApp.encuesta.categoria" for="field_categoria">Categoria</label>
<select class="form-control" id="field_categoria" data-cy="categoria" name="categoria" formControlName="categoria">
<option [ngValue]="null"></option>
<option
[ngValue]="categoriaOption.id === editForm.get('categoria')!.value?.id ? editForm.get('categoria')!.value : categoriaOption"
*ngFor="let categoriaOption of categoriasSharedCollection; trackBy: trackCategoriaById"
>
{{ categoriaOption.nombre }}
</option>
</select>
</div>
<div class="form-group">
<label class="form-control-label" jhiTranslate="dataSurveyApp.encuesta.usuarioExtra" for="field_usuarioExtra"
>Usuario Extra</label
>
<select class="form-control" id="field_usuarioExtra" data-cy="usuarioExtra" name="usuarioExtra" formControlName="usuarioExtra">
<option [ngValue]="null"></option>
<option
[ngValue]="
usuarioExtraOption.id === editForm.get('usuarioExtra')!.value?.id ? editForm.get('usuarioExtra')!.value : usuarioExtraOption
"
*ngFor="let usuarioExtraOption of usuarioExtrasSharedCollection; trackBy: trackUsuarioExtraById"
>
{{ usuarioExtraOption.id }}
</option>
</select>
</div>
<!-- Survey Parameters Information -->
<div
class="modal fade ds-modal"
id="verParametros"
tabindex="-1"
role="dialog"
aria-labelledby="exampleModalCenterTitle"
aria-hidden="true"
>
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title" id="exampleModalLongTitle">Información de Encuesta</h1>
</div>
<div>
<button type="button" id="cancel-save" data-cy="entityCreateCancelButton" class="btn btn-secondary" (click)="previousState()">
<fa-icon icon="ban"></fa-icon>&nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span>
</button>
<!-- {
"id": 1,
"maxDiasEncuesta": 20,
"minDiasEncuesta": 2,
"maxCantidadPreguntas": 10,
"minCantidadPreguntas": 2
} -->
<button
type="submit"
id="save-entity"
data-cy="entityCreateSaveButton"
[disabled]="editForm.invalid || isSaving"
class="btn btn-primary"
>
<fa-icon icon="save"></fa-icon>&nbsp;<span jhiTranslate="entity.action.save">Save</span>
<div class="modal-body">
<div>
<div class="mb-5">
<p class="ds-subtitle">Duración de encuesta permitida</p>
<p>{{ parametrosAplicacion!.minDiasEncuesta }} - {{ parametrosAplicacion!.maxDiasEncuesta }} días</p>
</div>
<div>
<p class="ds-subtitle">Cantidad de preguntas por encuesta</p>
<p>{{ parametrosAplicacion!.minCantidadPreguntas }} - {{ parametrosAplicacion!.maxCantidadPreguntas }} preguntas</p>
</div>
</div>
</div>
<div class="modal-footer">
<button id="cancelBtnVerParametros" type="button" class="ds-btn ds-btn--secondary" data-dismiss="modal">
<fa-icon icon="arrow-left"></fa-icon>&nbsp;&nbsp;<span>Volver</span>
</button>
</div>
</form>
</div>
</div>
</div> -->
</div>
<!-- ------------------------------------------------------------------------------------------------- -->

View File

@ -25,11 +25,13 @@ import { IEPreguntaCerrada } from 'app/entities/e-pregunta-cerrada/e-pregunta-ce
import { EPreguntaCerradaService } from 'app/entities/e-pregunta-cerrada/service/e-pregunta-cerrada.service';
import { EPreguntaCerradaDeleteDialogComponent } from 'app/entities/e-pregunta-cerrada/delete/e-pregunta-cerrada-delete-dialog.component';
import { faTimes, faPlus, faPollH } from '@fortawesome/free-solid-svg-icons';
import { faTimes, faPlus, faQuestion, faPollH } from '@fortawesome/free-solid-svg-icons';
import { PreguntaCerradaTipo } from 'app/entities/enumerations/pregunta-cerrada-tipo.model';
import { EncuestaDeleteQuestionDialogComponent } from '../encuesta-delete-question-dialog/encuesta-delete-question-dialog.component';
import { EncuestaDeleteOptionDialogComponent } from '../encuesta-delete-option-dialog/encuesta-delete-option-dialog.component';
import { ParametroAplicacionService } from './../../parametro-aplicacion/service/parametro-aplicacion.service';
import { IParametroAplicacion } from './../../parametro-aplicacion/parametro-aplicacion.model';
import { Router } from '@angular/router';
@Component({
@ -40,6 +42,7 @@ export class EncuestaUpdateComponent implements OnInit, AfterViewChecked {
faTimes = faTimes;
faPlus = faPlus;
faPollH = faPollH;
faQuestion = faQuestion;
isSaving = false;
isSavingQuestion = false;
@ -82,6 +85,7 @@ export class EncuestaUpdateComponent implements OnInit, AfterViewChecked {
ePreguntas?: any[];
ePreguntasOpciones?: any[];
encuesta: Encuesta | null = null;
parametrosAplicacion?: IParametroAplicacion | null = null;
isLoading = false;
@ -99,6 +103,8 @@ export class EncuestaUpdateComponent implements OnInit, AfterViewChecked {
protected ePreguntaCerradaService: EPreguntaCerradaService,
protected ePreguntaCerradaOpcionService: EPreguntaCerradaOpcionService,
protected ePreguntaAbiertaService: EPreguntaAbiertaService,
protected parametroAplicacionService: ParametroAplicacionService,
protected ePreguntaAbiertaService: EPreguntaAbiertaService,
protected router: Router
) {}
@ -127,6 +133,12 @@ export class EncuestaUpdateComponent implements OnInit, AfterViewChecked {
);
}
async loadAplicationParameters(): Promise<void> {
const params = await this.parametroAplicacionService.find(1).toPromise();
this.parametrosAplicacion = params.body;
console.log(this.parametrosAplicacion);
}
ngOnInit(): void {
this.activatedRoute.data.subscribe(({ encuesta }) => {
if (encuesta.id === undefined) {
@ -138,6 +150,7 @@ export class EncuestaUpdateComponent implements OnInit, AfterViewChecked {
} else {
this.encuesta = encuesta;
this.loadAll();
this.loadAplicationParameters();
}
// this.updateForm(encuesta);

View File

@ -19,3 +19,22 @@
p {
margin: 0 !important;
}
.ds-info--icon {
border-radius: 50%;
background-color: #f1f5f9;
cursor: pointer;
transition: background-color 0.2s ease-in-out;
width: 20px;
height: 20px;
font-size: 0.7rem;
color: #313747;
pointer-events: visible !important;
display: flex;
align-items: center;
justify-content: center;
&:hover {
background-color: #e3e6e9;
}
}