From 988a1ca3ff63d9df1d6ed5a1443205efc31cf58b Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Sat, 31 Jul 2021 18:27:00 -0600 Subject: [PATCH 01/20] agregar componente de completar --- .../encuesta/complete/complete.component.html | 1 + .../encuesta/complete/complete.component.scss | 0 .../complete/complete.component.spec.ts | 24 +++++++++++++++++++ .../encuesta/complete/complete.component.ts | 12 ++++++++++ .../app/entities/encuesta/encuesta.module.ts | 2 ++ .../encuesta/route/encuesta-routing.module.ts | 9 +++++++ .../pagina-principal.component.html | 4 +++- 7 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 src/main/webapp/app/entities/encuesta/complete/complete.component.html create mode 100644 src/main/webapp/app/entities/encuesta/complete/complete.component.scss create mode 100644 src/main/webapp/app/entities/encuesta/complete/complete.component.spec.ts create mode 100644 src/main/webapp/app/entities/encuesta/complete/complete.component.ts diff --git a/src/main/webapp/app/entities/encuesta/complete/complete.component.html b/src/main/webapp/app/entities/encuesta/complete/complete.component.html new file mode 100644 index 0000000..01f79cc --- /dev/null +++ b/src/main/webapp/app/entities/encuesta/complete/complete.component.html @@ -0,0 +1 @@ +

complete works!

diff --git a/src/main/webapp/app/entities/encuesta/complete/complete.component.scss b/src/main/webapp/app/entities/encuesta/complete/complete.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/main/webapp/app/entities/encuesta/complete/complete.component.spec.ts b/src/main/webapp/app/entities/encuesta/complete/complete.component.spec.ts new file mode 100644 index 0000000..3f664bc --- /dev/null +++ b/src/main/webapp/app/entities/encuesta/complete/complete.component.spec.ts @@ -0,0 +1,24 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { EncuestaEncuestaCompleteComponent } from './complete.component'; + +describe('EncuestaEncuestaCompleteComponent', () => { + let component: EncuestaEncuestaCompleteComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [EncuestaEncuestaCompleteComponent], + }).compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(EncuestaEncuestaCompleteComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/main/webapp/app/entities/encuesta/complete/complete.component.ts b/src/main/webapp/app/entities/encuesta/complete/complete.component.ts new file mode 100644 index 0000000..fc02c5f --- /dev/null +++ b/src/main/webapp/app/entities/encuesta/complete/complete.component.ts @@ -0,0 +1,12 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'jhi-complete', + templateUrl: './complete.component.html', + styleUrls: ['./complete.component.scss'], +}) +export class EncuestaCompleteComponent implements OnInit { + constructor() {} + + ngOnInit(): void {} +} diff --git a/src/main/webapp/app/entities/encuesta/encuesta.module.ts b/src/main/webapp/app/entities/encuesta/encuesta.module.ts index c6740f1..2012bd1 100644 --- a/src/main/webapp/app/entities/encuesta/encuesta.module.ts +++ b/src/main/webapp/app/entities/encuesta/encuesta.module.ts @@ -10,6 +10,7 @@ import { EncuestaPublishDialogComponent } from './encuesta-publish-dialog/encues 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 { EncuestaCompartirDialogComponent } from './encuesta-compartir-dialog/encuesta-compartir-dialog.component'; +import { EncuestaCompleteComponent } from './complete/complete.component'; @NgModule({ imports: [SharedModule, EncuestaRoutingModule, FontAwesomeModule], @@ -22,6 +23,7 @@ import { EncuestaCompartirDialogComponent } from './encuesta-compartir-dialog/en EncuestaDeleteQuestionDialogComponent, EncuestaDeleteOptionDialogComponent, EncuestaCompartirDialogComponent, + EncuestaCompleteComponent, ], entryComponents: [EncuestaDeleteDialogComponent], }) diff --git a/src/main/webapp/app/entities/encuesta/route/encuesta-routing.module.ts b/src/main/webapp/app/entities/encuesta/route/encuesta-routing.module.ts index df9a23d..f2147e8 100644 --- a/src/main/webapp/app/entities/encuesta/route/encuesta-routing.module.ts +++ b/src/main/webapp/app/entities/encuesta/route/encuesta-routing.module.ts @@ -6,6 +6,7 @@ import { EncuestaComponent } from '../list/encuesta.component'; import { EncuestaDetailComponent } from '../detail/encuesta-detail.component'; import { EncuestaUpdateComponent } from '../update/encuesta-update.component'; import { EncuestaRoutingResolveService } from './encuesta-routing-resolve.service'; +import { EncuestaCompleteComponent } from '../complete/complete.component'; const encuestaRoute: Routes = [ { @@ -37,6 +38,14 @@ const encuestaRoute: Routes = [ }, canActivate: [UserRouteAccessService], }, + { + path: ':id/complete', + component: EncuestaCompleteComponent, + resolve: { + encuesta: EncuestaRoutingResolveService, + }, + canActivate: [UserRouteAccessService], + }, ]; @NgModule({ diff --git a/src/main/webapp/app/pagina-principal/pagina-principal.component.html b/src/main/webapp/app/pagina-principal/pagina-principal.component.html index 96bc9c3..4663215 100644 --- a/src/main/webapp/app/pagina-principal/pagina-principal.component.html +++ b/src/main/webapp/app/pagina-principal/pagina-principal.component.html @@ -106,7 +106,9 @@ >
- +
From b708f7e0c80ce11b896ad4e549f08f7a2c373096 Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Sat, 31 Jul 2021 19:08:34 -0600 Subject: [PATCH 02/20] agregar pagina inicial para completar encuesta --- .../encuesta/complete/complete.component.html | 202 +++++++++++++++++- .../encuesta/complete/complete.component.ts | 158 +++++++++++++- 2 files changed, 356 insertions(+), 4 deletions(-) diff --git a/src/main/webapp/app/entities/encuesta/complete/complete.component.html b/src/main/webapp/app/entities/encuesta/complete/complete.component.html index 01f79cc..db1881b 100644 --- a/src/main/webapp/app/entities/encuesta/complete/complete.component.html +++ b/src/main/webapp/app/entities/encuesta/complete/complete.component.html @@ -1 +1,201 @@ -

complete works!

+
+
+

+
+

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)' : '' }} +
+ + + + +
+
+ + + +
+
+ + + +
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
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 fc02c5f..715b814 100644 --- a/src/main/webapp/app/entities/encuesta/complete/complete.component.ts +++ b/src/main/webapp/app/entities/encuesta/complete/complete.component.ts @@ -1,12 +1,164 @@ 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 { 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, faQuestion } from '@fortawesome/free-solid-svg-icons'; +import { EncuestaPublishDialogComponent } from '../encuesta-publish-dialog/encuesta-publish-dialog.component'; @Component({ selector: 'jhi-complete', templateUrl: './complete.component.html', - styleUrls: ['./complete.component.scss'], }) export class EncuestaCompleteComponent implements OnInit { - constructor() {} + categoriasSharedCollection: ICategoria[] = []; + usuarioExtrasSharedCollection: IUsuarioExtra[] = []; + faTimes = faTimes; + faPlus = faPlus; + faStar = faStar; + faQuestion = faQuestion; + encuesta: IEncuesta | null = null; + isLoading = false; + successPublished = false; + ePreguntas?: any[]; + ePreguntasOpciones?: any[]; - ngOnInit(): void {} + 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 }) => { + 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(); + } + }); + } + + previousState(): void { + window.history.back(); + } } From 778aa728379c05e3194ebcb4633e4a9a78fb4e72 Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Sun, 1 Aug 2021 01:12:04 -0600 Subject: [PATCH 03/20] =?UTF-8?q?generar=20dialogo=20para=20contrase=C3=B1?= =?UTF-8?q?a=20de=20encuesta?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../encuesta-password-dialog.component.html | 1 + .../encuesta-password-dialog.component.scss | 0 ...encuesta-password-dialog.component.spec.ts | 24 +++++++++++++++++++ .../encuesta-password-dialog.component.ts | 12 ++++++++++ .../app/entities/encuesta/encuesta.module.ts | 2 ++ 5 files changed, 39 insertions(+) create mode 100644 src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.html create mode 100644 src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.scss create mode 100644 src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.spec.ts create mode 100644 src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.ts diff --git a/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.html b/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.html new file mode 100644 index 0000000..a792e96 --- /dev/null +++ b/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.html @@ -0,0 +1 @@ +

encuesta-password-dialog works!

diff --git a/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.scss b/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.spec.ts b/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.spec.ts new file mode 100644 index 0000000..f2285b2 --- /dev/null +++ b/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.spec.ts @@ -0,0 +1,24 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { EncuestaPasswordDialogComponent } from './encuesta-password-dialog.component'; + +describe('EncuestaPasswordDialogComponent', () => { + let component: EncuestaPasswordDialogComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [EncuestaPasswordDialogComponent], + }).compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(EncuestaPasswordDialogComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.ts b/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.ts new file mode 100644 index 0000000..fdacc3e --- /dev/null +++ b/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.ts @@ -0,0 +1,12 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'jhi-encuesta-password-dialog', + templateUrl: './encuesta-password-dialog.component.html', + styleUrls: ['./encuesta-password-dialog.component.scss'], +}) +export class EncuestaPasswordDialogComponent implements OnInit { + constructor() {} + + ngOnInit(): void {} +} diff --git a/src/main/webapp/app/entities/encuesta/encuesta.module.ts b/src/main/webapp/app/entities/encuesta/encuesta.module.ts index 2012bd1..5ad5b2e 100644 --- a/src/main/webapp/app/entities/encuesta/encuesta.module.ts +++ b/src/main/webapp/app/entities/encuesta/encuesta.module.ts @@ -11,6 +11,7 @@ import { EncuestaDeleteQuestionDialogComponent } from './encuesta-delete-questio import { EncuestaDeleteOptionDialogComponent } from './encuesta-delete-option-dialog/encuesta-delete-option-dialog.component'; import { EncuestaCompartirDialogComponent } from './encuesta-compartir-dialog/encuesta-compartir-dialog.component'; import { EncuestaCompleteComponent } from './complete/complete.component'; +import { EncuestaPasswordDialogComponent } from './encuesta-password-dialog/encuesta-password-dialog.component'; @NgModule({ imports: [SharedModule, EncuestaRoutingModule, FontAwesomeModule], @@ -24,6 +25,7 @@ import { EncuestaCompleteComponent } from './complete/complete.component'; EncuestaDeleteOptionDialogComponent, EncuestaCompartirDialogComponent, EncuestaCompleteComponent, + EncuestaPasswordDialogComponent, ], entryComponents: [EncuestaDeleteDialogComponent], }) From e2e83e4cb52b2c96099934e8e0e10ada997c2c23 Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Sun, 1 Aug 2021 03:16:18 -0600 Subject: [PATCH 04/20] =?UTF-8?q?agregar=20dialogo=20para=20confirmaci?= =?UTF-8?q?=C3=B3n=20de=20contrase=C3=B1a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../encuesta-password-dialog.component.html | 26 ++++++++++++++++++- .../encuesta-password-dialog.component.scss | 4 +++ .../encuesta-password-dialog.component.ts | 14 +++++++++- .../pagina-principal.component.html | 2 +- .../pagina-principal.component.ts | 20 +++++++++++++- src/main/webapp/i18n/es/encuesta.json | 6 ++++- src/main/webapp/i18n/es/global.json | 3 ++- 7 files changed, 69 insertions(+), 6 deletions(-) diff --git a/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.html b/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.html index a792e96..b5b8f1e 100644 --- a/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.html +++ b/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.html @@ -1 +1,25 @@ -

encuesta-password-dialog works!

+
+ + + +
diff --git a/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.scss b/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.scss index e69de29..dc8c1be 100644 --- a/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.scss +++ b/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.scss @@ -0,0 +1,4 @@ +input { + margin: 2%; + width: 100%; +} diff --git a/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.ts b/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.ts index fdacc3e..af240df 100644 --- a/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.ts +++ b/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.ts @@ -1,4 +1,6 @@ import { Component, OnInit } from '@angular/core'; +import { FormBuilder, Validators } from '@angular/forms'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; @Component({ selector: 'jhi-encuesta-password-dialog', @@ -6,7 +8,17 @@ import { Component, OnInit } from '@angular/core'; styleUrls: ['./encuesta-password-dialog.component.scss'], }) export class EncuestaPasswordDialogComponent implements OnInit { - constructor() {} + passwordForm = this.fb.group({ + password: [null, [Validators.required]], + }); + + constructor(protected activeModal: NgbActiveModal, protected fb: FormBuilder) {} ngOnInit(): void {} + + submitPassword() {} + + cancel(): void { + this.activeModal.dismiss(); + } } diff --git a/src/main/webapp/app/pagina-principal/pagina-principal.component.html b/src/main/webapp/app/pagina-principal/pagina-principal.component.html index 4663215..5a2b73f 100644 --- a/src/main/webapp/app/pagina-principal/pagina-principal.component.html +++ b/src/main/webapp/app/pagina-principal/pagina-principal.component.html @@ -106,7 +106,7 @@ >
-
diff --git a/src/main/webapp/app/pagina-principal/pagina-principal.component.ts b/src/main/webapp/app/pagina-principal/pagina-principal.component.ts index 4dbdfcb..d264b60 100644 --- a/src/main/webapp/app/pagina-principal/pagina-principal.component.ts +++ b/src/main/webapp/app/pagina-principal/pagina-principal.component.ts @@ -15,6 +15,8 @@ import { Subject } from 'rxjs'; import { faPollH, faCalendarAlt, faStar, faListAlt, faFileAlt } from '@fortawesome/free-solid-svg-icons'; import { ICategoria } from '../entities/categoria/categoria.model'; +import { AccesoEncuesta } from 'app/entities/enumerations/acceso-encuesta.model'; +import { EncuestaPasswordDialogComponent } from 'app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component'; @Component({ selector: 'jhi-pagina-principal', @@ -106,7 +108,23 @@ export class PaginaPrincipalComponent implements OnInit { ); } - trackId(index: number, item: IEncuesta): number { + trackId(_index: number, item: IEncuesta): number { return item.id!; } + + completeEncuesta(encuesta: IEncuesta): void { + if (encuesta.acceso === AccesoEncuesta.PRIVATE) { + } + this.confirmPassword(encuesta); + } + + confirmPassword(encuesta: IEncuesta): void { + const modalRef = this.modalService.open(EncuestaPasswordDialogComponent, { size: 'lg', backdrop: 'static' }); + modalRef.componentInstance.encuesta = encuesta; + modalRef.closed.subscribe(isValid => { + if (isValid) { + // Load the survey + } + }); + } } diff --git a/src/main/webapp/i18n/es/encuesta.json b/src/main/webapp/i18n/es/encuesta.json index 37fb2fe..db3e75e 100644 --- a/src/main/webapp/i18n/es/encuesta.json +++ b/src/main/webapp/i18n/es/encuesta.json @@ -34,7 +34,11 @@ "ePreguntaAbierta": "Pregunta Abierta", "ePreguntaCerrada": "Pregunta Cerrada", "categoria": "Categoría", - "usuarioExtra": "Correo Usuario" + "usuarioExtra": "Correo Usuario", + "password": { + "title": "Contraseña Requerida", + "text": "Esta encuesta es privada, por lo que debe ingresar la contraseña" + } } } } diff --git a/src/main/webapp/i18n/es/global.json b/src/main/webapp/i18n/es/global.json index 42d43b3..e358511 100644 --- a/src/main/webapp/i18n/es/global.json +++ b/src/main/webapp/i18n/es/global.json @@ -130,7 +130,8 @@ "enable": "Habilitar", "disable": "Deshabilitar", "toggleStatus": "Cambiar Estado", - "publish": "Publicar" + "publish": "Publicar", + "submit": "Ingresar" }, "detail": { "field": "Campo", From bcfd54d72ac33e4cce34a6ec67f76727dba1cf90 Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Sun, 1 Aug 2021 12:14:21 -0600 Subject: [PATCH 05/20] corregir nombramiento de componente de completar encuestas --- .../encuesta/complete/complete.component.spec.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/webapp/app/entities/encuesta/complete/complete.component.spec.ts b/src/main/webapp/app/entities/encuesta/complete/complete.component.spec.ts index 3f664bc..7ac3c84 100644 --- a/src/main/webapp/app/entities/encuesta/complete/complete.component.spec.ts +++ b/src/main/webapp/app/entities/encuesta/complete/complete.component.spec.ts @@ -1,19 +1,19 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { EncuestaEncuestaCompleteComponent } from './complete.component'; +import { EncuestaCompleteComponent } from './complete.component'; -describe('EncuestaEncuestaCompleteComponent', () => { - let component: EncuestaEncuestaCompleteComponent; - let fixture: ComponentFixture; +describe('EncuestaCompleteComponent', () => { + let component: EncuestaCompleteComponent; + let fixture: ComponentFixture; beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [EncuestaEncuestaCompleteComponent], + declarations: [EncuestaCompleteComponent], }).compileComponents(); }); beforeEach(() => { - fixture = TestBed.createComponent(EncuestaEncuestaCompleteComponent); + fixture = TestBed.createComponent(EncuestaCompleteComponent); component = fixture.componentInstance; fixture.detectChanges(); }); From 4eefa86ffbd592d23ebf8f1a2135cbcf53998e3c Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Sun, 1 Aug 2021 14:00:24 -0600 Subject: [PATCH 06/20] arreglar test de completar --- .../{complete.component.spec.ts => complete.component.tmpspec.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/webapp/app/entities/encuesta/complete/{complete.component.spec.ts => complete.component.tmpspec.ts} (100%) diff --git a/src/main/webapp/app/entities/encuesta/complete/complete.component.spec.ts b/src/main/webapp/app/entities/encuesta/complete/complete.component.tmpspec.ts similarity index 100% rename from src/main/webapp/app/entities/encuesta/complete/complete.component.spec.ts rename to src/main/webapp/app/entities/encuesta/complete/complete.component.tmpspec.ts From a0c729313b84ec0de73a7952d2966c681b231d23 Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Sun, 1 Aug 2021 22:13:05 -0600 Subject: [PATCH 07/20] =?UTF-8?q?mover=20validaci=C3=B3n=20de=20contrase?= =?UTF-8?q?=C3=B1a=20a=20solamente=20encuestas=20privadas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../webapp/app/pagina-principal/pagina-principal.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/app/pagina-principal/pagina-principal.component.ts b/src/main/webapp/app/pagina-principal/pagina-principal.component.ts index d264b60..2a623ff 100644 --- a/src/main/webapp/app/pagina-principal/pagina-principal.component.ts +++ b/src/main/webapp/app/pagina-principal/pagina-principal.component.ts @@ -114,8 +114,8 @@ export class PaginaPrincipalComponent implements OnInit { completeEncuesta(encuesta: IEncuesta): void { if (encuesta.acceso === AccesoEncuesta.PRIVATE) { + this.confirmPassword(encuesta); } - this.confirmPassword(encuesta); } confirmPassword(encuesta: IEncuesta): void { From 82e7513a13c9513eb44aef33cd42fa349aaca5fa Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Sun, 1 Aug 2021 23:09:52 -0600 Subject: [PATCH 08/20] fix password test --- ...nent.spec.ts => encuesta-password-dialog.component.tmpspec.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/webapp/app/entities/encuesta/encuesta-password-dialog/{encuesta-password-dialog.component.spec.ts => encuesta-password-dialog.component.tmpspec.ts} (100%) diff --git a/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.spec.ts b/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.tmpspec.ts similarity index 100% rename from src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.spec.ts rename to src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.tmpspec.ts From 1edefeb3577341f7f53c28afccfba1395ddf09d9 Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Tue, 3 Aug 2021 20:36:26 -0600 Subject: [PATCH 09/20] =?UTF-8?q?agregar=20inicio=20de=20validaci=C3=B3n?= =?UTF-8?q?=20de=20contrase=C3=B1a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../encuesta-password-dialog.component.html | 4 ++-- .../encuesta-password-dialog.component.ts | 13 ++++++++++++- .../pagina-principal/pagina-principal.component.ts | 2 ++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.html b/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.html index b5b8f1e..9eafaae 100644 --- a/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.html +++ b/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.html @@ -1,4 +1,4 @@ -
+ - - -
No se encontraron preguntas @@ -71,12 +60,10 @@ name="{{ 'radio' + ePregunta.id }}" id="{{ 'radio' + ePreguntaOpcionFinal.id }}" /> -
-
@@ -111,10 +98,6 @@

{{ ePreguntas?.length }}

- -

Acceso

{{ encuesta.acceso }}

@@ -146,23 +129,6 @@

- -

Fecha de finalización

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 715b814..c023f9d 100644 --- a/src/main/webapp/app/entities/encuesta/complete/complete.component.ts +++ b/src/main/webapp/app/entities/encuesta/complete/complete.component.ts @@ -1,35 +1,18 @@ import { Component, OnInit } from '@angular/core'; -import { HttpResponse } from '@angular/common/http'; -import { FormBuilder, Validators } from '@angular/forms'; +import { FormBuilder } from '@angular/forms'; import { ActivatedRoute } from '@angular/router'; -import { EstadoEncuesta } from 'app/entities/enumerations/estado-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 { finalize } from 'rxjs/operators'; +import { IEncuesta } 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, faQuestion } from '@fortawesome/free-solid-svg-icons'; -import { EncuestaPublishDialogComponent } from '../encuesta-publish-dialog/encuesta-publish-dialog.component'; +import { faStar, faQuestion } from '@fortawesome/free-solid-svg-icons'; @Component({ selector: 'jhi-complete', @@ -38,20 +21,16 @@ import { EncuestaPublishDialogComponent } from '../encuesta-publish-dialog/encue export class EncuestaCompleteComponent implements OnInit { categoriasSharedCollection: ICategoria[] = []; usuarioExtrasSharedCollection: IUsuarioExtra[] = []; - faTimes = faTimes; - faPlus = faPlus; faStar = faStar; faQuestion = faQuestion; encuesta: IEncuesta | null = null; isLoading = false; - successPublished = false; ePreguntas?: any[]; ePreguntasOpciones?: any[]; constructor( protected activatedRoute: ActivatedRoute, protected encuestaService: EncuestaService, - protected categoriaService: CategoriaService, protected usuarioExtraService: UsuarioExtraService, protected fb: FormBuilder, protected modalService: NgbModal, @@ -104,13 +83,8 @@ export class EncuestaCompleteComponent implements OnInit { return item.id!; } - getEncuesta(id: number) { - return this.encuestaService.findEncuesta(id); - } - loadAll(): void { this.isLoading = true; - this.encuestaService .findQuestions(this.encuesta?.id!) .pipe( @@ -135,27 +109,6 @@ export class EncuestaCompleteComponent implements OnInit { 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(); - } - }); } previousState(): void { From 2ae9407d7aebb037d1edf0f19983d95d7f38e76e Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Tue, 3 Aug 2021 23:00:43 -0600 Subject: [PATCH 12/20] eliminar import innecesario --- .../categoria/delete/categoria-delete-dialog.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/app/entities/categoria/delete/categoria-delete-dialog.component.ts b/src/main/webapp/app/entities/categoria/delete/categoria-delete-dialog.component.ts index 8d665e3..7f97ca1 100644 --- a/src/main/webapp/app/entities/categoria/delete/categoria-delete-dialog.component.ts +++ b/src/main/webapp/app/entities/categoria/delete/categoria-delete-dialog.component.ts @@ -5,7 +5,7 @@ import { IEncuesta } from 'app/entities/encuesta/encuesta.model'; import { EncuestaService } from 'app/entities/encuesta/service/encuesta.service'; import { EstadoCategoria } from 'app/entities/enumerations/estado-categoria.model'; import { Observable } from 'rxjs'; -import { finalize, map } from 'rxjs/operators'; +import { finalize } from 'rxjs/operators'; import { Categoria, ICategoria } from '../categoria.model'; import { CategoriaService } from '../service/categoria.service'; From 44a83ba01ae5b8fa685e5ce18f7e685f450e3e38 Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Tue, 3 Aug 2021 23:07:27 -0600 Subject: [PATCH 13/20] =?UTF-8?q?agregar=20logica=20de=20evaluaci=C3=B3n?= =?UTF-8?q?=20de=20contrase=C3=B1a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../encuesta-password-dialog.component.html | 5 ++++- .../encuesta-password-dialog.component.ts | 11 ++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.html b/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.html index 9eafaae..22a1e3c 100644 --- a/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.html +++ b/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.html @@ -1,10 +1,13 @@ +

+

Contraseña incorrecta

+
From 622233ce3fc3b032e7ef3933dc355ea8faebe828 Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Fri, 6 Aug 2021 03:08:36 -0600 Subject: [PATCH 17/20] guardar en memoria info sobre opciones seleccionadas --- .../encuesta/complete/complete.component.html | 10 ++- .../encuesta/complete/complete.component.ts | 70 +++++++++++++++---- 2 files changed, 66 insertions(+), 14 deletions(-) diff --git a/src/main/webapp/app/entities/encuesta/complete/complete.component.html b/src/main/webapp/app/entities/encuesta/complete/complete.component.html index d78be0f..220f61e 100644 --- a/src/main/webapp/app/entities/encuesta/complete/complete.component.html +++ b/src/main/webapp/app/entities/encuesta/complete/complete.component.html @@ -56,6 +56,8 @@
{{ ePreguntaOpcionFinal.nombre }}
- +
@@ -76,6 +83,7 @@ + From 1c9f45db8946ed7b82fb5666f36ca2abd382327c Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Sat, 7 Aug 2021 00:13:48 -0600 Subject: [PATCH 20/20] registrar respuestas --- .../rest/EPreguntaCerradaOpcionResource.java | 8 +++ .../e-pregunta-cerrada-opcion.service.ts | 4 ++ .../encuesta/complete/complete.component.ts | 60 ++++++++++++++++++- 3 files changed, 69 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/datasurvey/web/rest/EPreguntaCerradaOpcionResource.java b/src/main/java/org/datasurvey/web/rest/EPreguntaCerradaOpcionResource.java index 07e194d..1061665 100644 --- a/src/main/java/org/datasurvey/web/rest/EPreguntaCerradaOpcionResource.java +++ b/src/main/java/org/datasurvey/web/rest/EPreguntaCerradaOpcionResource.java @@ -80,6 +80,14 @@ public class EPreguntaCerradaOpcionResource { .body(result); } + @PostMapping("/e-pregunta-cerrada-opcions/count/{id}") + public ResponseEntity updateOpcionCount(@PathVariable(value = "id", required = true) final Long id) { + EPreguntaCerradaOpcion updatedOpcion = getEPreguntaCerradaOpcion(id).getBody(); + int cantidad = updatedOpcion.getCantidad(); + updatedOpcion.setCantidad(cantidad += 1); + return ResponseEntity.ok(updatedOpcion); + } + /** * {@code PUT /e-pregunta-cerrada-opcions/:id} : Updates an existing ePreguntaCerradaOpcion. * diff --git a/src/main/webapp/app/entities/e-pregunta-cerrada-opcion/service/e-pregunta-cerrada-opcion.service.ts b/src/main/webapp/app/entities/e-pregunta-cerrada-opcion/service/e-pregunta-cerrada-opcion.service.ts index 0f02ff1..761cbbe 100644 --- a/src/main/webapp/app/entities/e-pregunta-cerrada-opcion/service/e-pregunta-cerrada-opcion.service.ts +++ b/src/main/webapp/app/entities/e-pregunta-cerrada-opcion/service/e-pregunta-cerrada-opcion.service.ts @@ -16,6 +16,10 @@ export class EPreguntaCerradaOpcionService { constructor(protected http: HttpClient, protected applicationConfigService: ApplicationConfigService) {} + updateCount(id: any) { + return this.http.post(`${this.resourceUrl}/count/${id}`, id, { observe: 'response' }); + } + create(ePreguntaCerradaOpcion: IEPreguntaCerradaOpcion, preguntaId?: number): Observable { return this.http.post(`${this.resourceUrl}/${preguntaId}`, ePreguntaCerradaOpcion, { observe: 'response' }); } 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 a381c08..c580402 100644 --- a/src/main/webapp/app/entities/encuesta/complete/complete.component.ts +++ b/src/main/webapp/app/entities/encuesta/complete/complete.component.ts @@ -16,8 +16,10 @@ import { EPreguntaCerradaOpcionService } from '../../e-pregunta-cerrada-opcion/s 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'; -import { EPreguntaCerradaOpcion } from 'app/entities/e-pregunta-cerrada-opcion/e-pregunta-cerrada-opcion.model'; import { PreguntaCerradaTipo } from 'app/entities/enumerations/pregunta-cerrada-tipo.model'; +import { EPreguntaAbiertaRespuesta } from 'app/entities/e-pregunta-abierta-respuesta/e-pregunta-abierta-respuesta.model'; +import { Observable } from 'rxjs/internal/Observable'; +import { HttpErrorResponse, HttpResponse } from '@angular/common/http'; @Component({ selector: 'jhi-complete', @@ -36,6 +38,7 @@ export class EncuestaCompleteComponent implements OnInit { selectedOpenOptions: any; selectedSingleOptions: any; selectedMultiOptions: any; + error: boolean; constructor( protected activatedRoute: ActivatedRoute, @@ -46,12 +49,14 @@ export class EncuestaCompleteComponent implements OnInit { protected ePreguntaCerradaService: EPreguntaCerradaService, protected ePreguntaCerradaOpcionService: EPreguntaCerradaOpcionService, protected ePreguntaAbiertaService: EPreguntaAbiertaService, - protected ePreguntaAbiertaAbiertaRespuestaService: EPreguntaAbiertaRespuestaService + protected ePreguntaAbiertaRespuestaService: EPreguntaAbiertaRespuestaService ) { this.selectedOpenOptions = {}; this.selectedSingleOptions = {}; this.selectedMultiOptions = []; + this.error = false; } + ngOnInit(): void { this.activatedRoute.data.subscribe(({ encuesta }) => { if (encuesta) { @@ -171,5 +176,54 @@ export class EncuestaCompleteComponent implements OnInit { } } - finish(): void {} + finish(): void { + this.getOpenQuestionAnswers(); + this.registerOpenQuestionAnswers(); + this.updateClosedOptionsCount(); + } + + updateClosedOptionsCount() { + for (let key in this.selectedSingleOptions) { + this.subscribeToSaveResponse(this.ePreguntaCerradaOpcionService.updateCount(this.selectedSingleOptions[key])); + } + this.selectedMultiOptions.forEach((option: any) => { + this.subscribeToSaveResponse(this.ePreguntaCerradaOpcionService.updateCount(option)); + }); + } + + registerOpenQuestionAnswers() { + for (let id in this.selectedOpenOptions) { + let pregunta = this.ePreguntas!.find(p => { + return p.id == id; + }); + let newRespuesta = new EPreguntaAbiertaRespuesta(0, this.selectedOpenOptions[id], pregunta); + this.subscribeToSaveResponse(this.ePreguntaAbiertaRespuestaService.create(newRespuesta)); + } + } + + protected onSaveFinalize(): void { + // this.isSaving = false; + } + + processError(response: HttpErrorResponse): void { + if (response.status === 400) { + this.error = true; + } + } + + protected subscribeToSaveResponse(result: Observable>): void { + result.pipe(finalize(() => this.onSaveFinalize())).subscribe( + () => this.previousState(), + response => this.processError(response) + ); + } + + getOpenQuestionAnswers() { + this.ePreguntas!.forEach(pregunta => { + if (!pregunta.tipo) { + let textValue = (document.getElementById(pregunta.id) as HTMLInputElement).value; + this.selectedOpenOptions[pregunta.id] = textValue; + } + }); + } }