diff --git a/default.nix b/default.nix deleted file mode 100644 index 75a5849..0000000 --- a/default.nix +++ /dev/null @@ -1,11 +0,0 @@ -with import { }; -mkShell { - nativeBuildInputs = [ - bashInteractive - maven - ]; - buildInputs = [ - openjdk11 - nodejs-14_x - ]; -} diff --git a/src/main/webapp/app/entities/encuesta/detail/encuesta-detail.component.html b/src/main/webapp/app/entities/encuesta/detail/encuesta-detail.component.html index 6873d16..0b5bbed 100644 --- a/src/main/webapp/app/entities/encuesta/detail/encuesta-detail.component.html +++ b/src/main/webapp/app/entities/encuesta/detail/encuesta-detail.component.html @@ -1,4 +1,4 @@ -
+ + +
+
+

+

Vista previa de {{ encuesta!.nombre }}

+

Creada el día {{ encuesta!.fechaCreacion | formatShortDatetime | lowercase }}

+
+ + + + +
+

+ + + + + + +
+ No se encontraron preguntas +
+ +
+
+
+
+
+ {{ i + 1 }}. {{ ePregunta.nombre }} +
+
+ Pregunta de respuesta {{ 'dataSurveyApp.PreguntaCerradaTipo.SINGLE' | translate | lowercase }} + {{ ePregunta.opcional ? '(opcional)' : '' }} + Pregunta de respuesta {{ 'dataSurveyApp.PreguntaCerradaTipo.MULTIPLE' | translate | lowercase }} + {{ ePregunta.opcional ? '(opcional)' : '' }} + Pregunta de respuesta abierta {{ ePregunta.opcional ? '(opcional)' : '' }} +
+ + + + +
+
+ + + +
+
+ + + +
+
+
+
+
+
+
+ +
+
+
+
+
+

Cantidad de preguntas: {{ ePreguntas?.length }}

+ +
+
Acceso
+
+ - + {{ encuesta.acceso }} +
+
+
+
Contrasenna
+
+ - {{ encuesta.contrasenna }} +
+
+
+
Estado
+
+ - {{ encuesta.estado }} +
+
+
+
Categoria
+
+ - {{ encuesta.categoria?.nombre }} +
+
+
+
Fecha Publicacion
+
+ - + {{ + encuesta.fechaPublicacion === undefined ? 'Sin publicar' : (encuesta.fechaFinalizada | formatShortDatetime | lowercase) + }} +
+
+
+
Fecha Finalizar
+
+ + - + {{ + encuesta.fechaFinalizar === undefined + ? 'Sin fecha de finalización' + : (encuesta.fechaFinalizada | formatShortDatetime | lowercase) + }} +
+
+
+
Fecha Finalizada
+
+ + - + {{ + encuesta.fechaFinalizada === undefined ? 'Sin finalizar' : (encuesta.fechaFinalizada | formatShortDatetime | lowercase) + }} +
+
+
+
Calificacion
+
+ +
+
+
+
+
diff --git a/src/main/webapp/app/entities/encuesta/detail/encuesta-detail.component.spec.ts b/src/main/webapp/app/entities/encuesta/detail/encuesta-detail.component.tmpSpec.ts similarity index 100% rename from src/main/webapp/app/entities/encuesta/detail/encuesta-detail.component.spec.ts rename to src/main/webapp/app/entities/encuesta/detail/encuesta-detail.component.tmpSpec.ts diff --git a/src/main/webapp/app/entities/encuesta/detail/encuesta-detail.component.ts b/src/main/webapp/app/entities/encuesta/detail/encuesta-detail.component.ts index f04d377..7696f76 100644 --- a/src/main/webapp/app/entities/encuesta/detail/encuesta-detail.component.ts +++ b/src/main/webapp/app/entities/encuesta/detail/encuesta-detail.component.ts @@ -1,20 +1,159 @@ import { Component, OnInit } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +import { FormBuilder, Validators } from '@angular/forms'; import { ActivatedRoute } from '@angular/router'; +import { EstadoEncuesta } from 'app/entities/enumerations/estado-encuesta.model'; -import { IEncuesta } from '../encuesta.model'; +import { Observable } from 'rxjs'; +import { finalize, map } from 'rxjs/operators'; + +import * as dayjs from 'dayjs'; +import { DATE_TIME_FORMAT } from 'app/config/input.constants'; + +import { IEncuesta, Encuesta } from '../encuesta.model'; +import { EncuestaService } from '../service/encuesta.service'; +import { ICategoria } from 'app/entities/categoria/categoria.model'; +import { CategoriaService } from 'app/entities/categoria/service/categoria.service'; +import { IUsuarioExtra } from 'app/entities/usuario-extra/usuario-extra.model'; +import { UsuarioExtraService } from 'app/entities/usuario-extra/service/usuario-extra.service'; + +import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; +import { IEPreguntaCerrada } from 'app/entities/e-pregunta-cerrada/e-pregunta-cerrada.model'; +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 { IEPreguntaAbierta } from '../../e-pregunta-abierta/e-pregunta-abierta.model'; +import { EPreguntaCerrada } from '../../e-pregunta-cerrada/e-pregunta-cerrada.model'; +import { EPreguntaCerradaOpcion, IEPreguntaCerradaOpcion } from '../../e-pregunta-cerrada-opcion/e-pregunta-cerrada-opcion.model'; +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 { PreguntaCerradaTipo } from 'app/entities/enumerations/pregunta-cerrada-tipo.model'; + +import { faTimes, faPlus, faStar } from '@fortawesome/free-solid-svg-icons'; +import { EncuestaPublishDialogComponent } from '../encuesta-publish-dialog/encuesta-publish-dialog.component'; @Component({ selector: 'jhi-encuesta-detail', templateUrl: './encuesta-detail.component.html', }) export class EncuestaDetailComponent implements OnInit { + categoriasSharedCollection: ICategoria[] = []; + usuarioExtrasSharedCollection: IUsuarioExtra[] = []; + faTimes = faTimes; + faPlus = faPlus; + faStar = faStar; encuesta: IEncuesta | null = null; + isLoading = false; + successPublished = false; + ePreguntas?: any[]; + ePreguntasOpciones?: any[]; - constructor(protected activatedRoute: ActivatedRoute) {} + constructor( + protected activatedRoute: ActivatedRoute, + protected encuestaService: EncuestaService, + protected categoriaService: CategoriaService, + protected usuarioExtraService: UsuarioExtraService, + protected fb: FormBuilder, + protected modalService: NgbModal, + protected ePreguntaCerradaService: EPreguntaCerradaService, + protected ePreguntaCerradaOpcionService: EPreguntaCerradaOpcionService, + protected ePreguntaAbiertaService: EPreguntaAbiertaService + ) {} ngOnInit(): void { this.activatedRoute.data.subscribe(({ encuesta }) => { - this.encuesta = encuesta; + if (encuesta) { + this.encuesta = encuesta; + this.loadAll(); + } else { + this.previousState(); + } + }); + } + + ngAfterViewChecked(): void { + this.initListeners(); + } + + initListeners(): void { + const checkboxes = document.getElementsByClassName('ds-survey--checkbox'); + for (let i = 0; i < checkboxes.length; i++) { + checkboxes[i].addEventListener('click', e => { + if ((e.target as HTMLInputElement).checked) { + (e.target as HTMLElement).offsetParent!.classList.add('ds-survey--closed-option--active'); + } else { + (e.target as HTMLElement).offsetParent!.classList.remove('ds-survey--closed-option--active'); + } + }); + } + } + + trackId(index: number, item: IEPreguntaCerrada): number { + return item.id!; + } + + trackEPreguntaCerradaById(index: number, item: IEPreguntaCerrada): number { + return item.id!; + } + + trackCategoriaById(index: number, item: ICategoria): number { + return item.id!; + } + + trackUsuarioExtraById(index: number, item: IUsuarioExtra): number { + return item.id!; + } + + getEncuesta(id: number) { + return this.encuestaService.findEncuesta(id); + } + + loadAll(): void { + this.isLoading = true; + + this.encuestaService + .findQuestions(this.encuesta?.id!) + .pipe( + finalize(() => + this.encuestaService.findQuestionsOptions(this.encuesta?.id!).subscribe( + (res: any) => { + this.isLoading = false; + this.ePreguntasOpciones = res.body ?? []; + }, + () => { + this.isLoading = false; + } + ) + ) + ) + .subscribe( + (res: any) => { + this.isLoading = false; + this.ePreguntas = res.body ?? []; + }, + () => { + this.isLoading = false; + } + ); + + /* this.encuestaService.findQuestionsOptions(this.encuesta?.id!).subscribe( + (res: any) => { + this.isLoading = false; + this.ePreguntasOpciones = res.body ?? []; + }, + () => { + this.isLoading = false; + } + );*/ + } + publishSurvey(): void { + const modalRef = this.modalService.open(EncuestaPublishDialogComponent, { size: 'lg', backdrop: 'static' }); + modalRef.componentInstance.encuesta = this.encuesta; + // unsubscribe not needed because closed completes on modal close + modalRef.closed.subscribe(reason => { + if (reason === 'published') { + this.successPublished = true; + this.loadAll(); + } }); } diff --git a/src/main/webapp/app/entities/encuesta/list/encuesta.component.html b/src/main/webapp/app/entities/encuesta/list/encuesta.component.html index cb0d994..4dc3a46 100644 --- a/src/main/webapp/app/entities/encuesta/list/encuesta.component.html +++ b/src/main/webapp/app/entities/encuesta/list/encuesta.component.html @@ -96,7 +96,9 @@
  • - +
  • + - +
  • @@ -228,7 +232,7 @@ [formGroup]="editFormQuestion" >