diff --git a/src/main/java/org/datasurvey/domain/UsuarioExtra.java b/src/main/java/org/datasurvey/domain/UsuarioExtra.java index 9f8708b..411dbc3 100644 --- a/src/main/java/org/datasurvey/domain/UsuarioExtra.java +++ b/src/main/java/org/datasurvey/domain/UsuarioExtra.java @@ -64,7 +64,7 @@ public class UsuarioExtra implements Serializable { joinColumns = @JoinColumn(name = "usuario_extra_id"), inverseJoinColumns = @JoinColumn(name = "plantilla_id") ) - @JsonIgnoreProperties(value = { "pPreguntaCerradas", "pPreguntaAbiertas", "categoria", "usuarioExtras" }, allowSetters = true) + @JsonIgnoreProperties(value = { "pPreguntaCerradas", "pPreguntaAbiertas", "usuarioExtras" }, allowSetters = true) private Set plantillas = new HashSet<>(); // jhipster-needle-entity-add-field - JHipster will add fields here 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/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'; 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.html b/src/main/webapp/app/entities/encuesta/complete/complete.component.html new file mode 100644 index 0000000..057f800 --- /dev/null +++ b/src/main/webapp/app/entities/encuesta/complete/complete.component.html @@ -0,0 +1,175 @@ +
+
+

+
+

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.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.tmpspec.ts b/src/main/webapp/app/entities/encuesta/complete/complete.component.tmpspec.ts new file mode 100644 index 0000000..7ac3c84 --- /dev/null +++ b/src/main/webapp/app/entities/encuesta/complete/complete.component.tmpspec.ts @@ -0,0 +1,24 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { EncuestaCompleteComponent } from './complete.component'; + +describe('EncuestaCompleteComponent', () => { + let component: EncuestaCompleteComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [EncuestaCompleteComponent], + }).compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(EncuestaCompleteComponent); + 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..c580402 --- /dev/null +++ b/src/main/webapp/app/entities/encuesta/complete/complete.component.ts @@ -0,0 +1,229 @@ +import { Component, OnInit } from '@angular/core'; +import { FormBuilder } from '@angular/forms'; +import { ActivatedRoute } from '@angular/router'; +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 { 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 { EPreguntaAbiertaService } from '../../e-pregunta-abierta/service/e-pregunta-abierta.service'; +import { EPreguntaAbiertaRespuestaService } from '../../e-pregunta-abierta-respuesta/service/e-pregunta-abierta-respuesta.service'; +import { EPreguntaCerradaOpcionService } from '../../e-pregunta-cerrada-opcion/service/e-pregunta-cerrada-opcion.service'; +import { faStar, faQuestion } from '@fortawesome/free-solid-svg-icons'; +import { AccesoEncuesta } from 'app/entities/enumerations/acceso-encuesta.model'; +import { EncuestaPasswordDialogComponent } from '../encuesta-password-dialog/encuesta-password-dialog.component'; +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', + templateUrl: './complete.component.html', +}) +export class EncuestaCompleteComponent implements OnInit { + categoriasSharedCollection: ICategoria[] = []; + usuarioExtrasSharedCollection: IUsuarioExtra[] = []; + faStar = faStar; + faQuestion = faQuestion; + encuesta?: IEncuesta; + isLoading = false; + ePreguntas?: any[]; + ePreguntasOpciones?: any[]; + isLocked?: boolean; + selectedOpenOptions: any; + selectedSingleOptions: any; + selectedMultiOptions: any; + error: boolean; + + constructor( + protected activatedRoute: ActivatedRoute, + protected encuestaService: EncuestaService, + protected usuarioExtraService: UsuarioExtraService, + protected fb: FormBuilder, + protected modalService: NgbModal, + protected ePreguntaCerradaService: EPreguntaCerradaService, + protected ePreguntaCerradaOpcionService: EPreguntaCerradaOpcionService, + protected ePreguntaAbiertaService: EPreguntaAbiertaService, + protected ePreguntaAbiertaRespuestaService: EPreguntaAbiertaRespuestaService + ) { + this.selectedOpenOptions = {}; + this.selectedSingleOptions = {}; + this.selectedMultiOptions = []; + this.error = false; + } + + ngOnInit(): void { + this.activatedRoute.data.subscribe(({ encuesta }) => { + if (encuesta) { + this.encuesta = encuesta; + } + this.isLocked = this.verifyPassword(); + if (this.isLocked) { + this.previousState(); + } else { + this.loadAll(); + } + }); + for (let pregunta of this.ePreguntas!) { + if (pregunta.tipo && pregunta.tipo === PreguntaCerradaTipo.SINGLE) { + this.selectedSingleOptions[pregunta.id] = null; + } + } + } + + verifyPassword(): boolean { + if (this.encuesta!.acceso === AccesoEncuesta.PUBLIC) { + return false; + } else { + const modalRef = this.modalService.open(EncuestaPasswordDialogComponent, { size: 'lg', backdrop: 'static' }); + modalRef.componentInstance.encuesta = this.encuesta; + modalRef.closed.subscribe(reason => { + return reason === 'success'; + }); + } + return true; + } + + ngAfterViewChecked(): void { + this.initListeners(); + } + + initListeners(): void { + const questions = document.getElementsByClassName('ds-survey--question-wrapper'); + for (let i = 0; i < questions.length; i++) { + if (questions[i].classList.contains('ds-survey--closed-option')) { + questions[i].addEventListener('click', e => { + if ((e.target as HTMLInputElement).checked) { + (e.target as HTMLElement).offsetParent!.classList.add('ds-survey--closed-option--active'); + (e.target as HTMLElement).id; + } 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!; + } + + 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; + } + ); + if (this.ePreguntas!.length == 0) { + this.previousState(); + } + } + + previousState(): void { + window.history.back(); + } + + onCheck(preguntaOpcion: { epreguntaCerrada: any; id: any }): void { + this.selectedSingleOptions[preguntaOpcion.epreguntaCerrada!.id!] = preguntaOpcion.id; + } + + toggleOption(ePreguntaOpcionFinal: { id: any }): void { + if (this.selectedMultiOptions.includes(ePreguntaOpcionFinal.id)) { + for (let i = 0; i < this.selectedMultiOptions.length; i++) { + if (this.selectedMultiOptions[i] === ePreguntaOpcionFinal.id) { + this.selectedMultiOptions.splice(i, 1); + } + } + } else { + this.selectedMultiOptions.push(ePreguntaOpcionFinal.id); + } + } + + 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; + } + }); + } +} 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..22a1e3c --- /dev/null +++ b/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.html @@ -0,0 +1,28 @@ +
+
+

Contraseña incorrecta

+
+ + + +
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..dc8c1be --- /dev/null +++ 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.tmpspec.ts b/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.tmpspec.ts new file mode 100644 index 0000000..f2285b2 --- /dev/null +++ b/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.tmpspec.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..f2514e1 --- /dev/null +++ b/src/main/webapp/app/entities/encuesta/encuesta-password-dialog/encuesta-password-dialog.component.ts @@ -0,0 +1,36 @@ +import { Component, OnInit } from '@angular/core'; +import { FormBuilder, Validators } from '@angular/forms'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { IEncuesta } from '../encuesta.model'; + +@Component({ + selector: 'jhi-encuesta-password-dialog', + templateUrl: './encuesta-password-dialog.component.html', + styleUrls: ['./encuesta-password-dialog.component.scss'], +}) +export class EncuestaPasswordDialogComponent implements OnInit { + passwordForm = this.fb.group({ + password: [null, [Validators.required]], + }); + encuesta?: IEncuesta; + isWrong?: boolean; + passwordInput?: string; + + constructor(protected activeModal: NgbActiveModal, protected fb: FormBuilder) {} + + ngOnInit(): void {} + + submitPassword() { + const password = this.passwordForm.get(['password'])!.value; + + if (this.passwordForm.valid && password === this.encuesta!.contrasenna) { + this.activeModal.close('success'); + } else { + this.isWrong = true; + } + } + + cancel(): void { + this.activeModal.close('cancel'); + } +} diff --git a/src/main/webapp/app/entities/encuesta/encuesta.module.ts b/src/main/webapp/app/entities/encuesta/encuesta.module.ts index 6d65e36..94ed589 100644 --- a/src/main/webapp/app/entities/encuesta/encuesta.module.ts +++ b/src/main/webapp/app/entities/encuesta/encuesta.module.ts @@ -10,9 +10,9 @@ 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'; +import { EncuestaPasswordDialogComponent } from './encuesta-password-dialog/encuesta-password-dialog.component'; import { EncuestaFinalizarDialogComponent } from './encuesta-finalizar-dialog/encuesta-finalizar-dialog.component'; - import { EncuestaDeleteColaboratorDialogComponent } from './encuesta-delete-colaborator-dialog/encuesta-delete-colaborator-dialog.component'; @NgModule({ @@ -26,6 +26,8 @@ import { EncuestaDeleteColaboratorDialogComponent } from './encuesta-delete-cola EncuestaDeleteQuestionDialogComponent, EncuestaDeleteOptionDialogComponent, EncuestaCompartirDialogComponent, + EncuestaCompleteComponent, + EncuestaPasswordDialogComponent, EncuestaFinalizarDialogComponent, EncuestaDeleteColaboratorDialogComponent, ], 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/entities/entity-routing.module.ts b/src/main/webapp/app/entities/entity-routing.module.ts index f01eb05..1e6285a 100644 --- a/src/main/webapp/app/entities/entity-routing.module.ts +++ b/src/main/webapp/app/entities/entity-routing.module.ts @@ -77,6 +77,11 @@ import { RouterModule } from '@angular/router'; loadChildren: () => import('./p-pregunta-cerrada-opcion/p-pregunta-cerrada-opcion.module').then(m => m.PPreguntaCerradaOpcionModule), }, + { + path: 'mis-plantillas', + data: { pageTitle: 'dataSurveyApp.usuarioExtra.plantillas.title' }, + loadChildren: () => import('./usuario-plantillas/usuario-plantillas.module').then(m => m.UsuarioPlantillasModule), + }, /* jhipster-needle-add-entity-route - JHipster will add entity modules routes here */ ]), ], diff --git a/src/main/webapp/app/entities/plantilla/delete/plantilla-delete-dialog.component.spec.ts b/src/main/webapp/app/entities/plantilla/delete/plantilla-delete-dialog.component.tmpSpec.ts similarity index 85% rename from src/main/webapp/app/entities/plantilla/delete/plantilla-delete-dialog.component.spec.ts rename to src/main/webapp/app/entities/plantilla/delete/plantilla-delete-dialog.component.tmpSpec.ts index 0e2d24c..696fc99 100644 --- a/src/main/webapp/app/entities/plantilla/delete/plantilla-delete-dialog.component.spec.ts +++ b/src/main/webapp/app/entities/plantilla/delete/plantilla-delete-dialog.component.tmpSpec.ts @@ -1,6 +1,5 @@ -jest.mock('@ng-bootstrap/ng-bootstrap'); - -import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing'; +import { Plantilla } from '../plantilla.model'; +import { ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angular/core/testing'; import { HttpResponse } from '@angular/common/http'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { of } from 'rxjs'; @@ -9,6 +8,9 @@ import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { PlantillaService } from '../service/plantilla.service'; import { PlantillaDeleteDialogComponent } from './plantilla-delete-dialog.component'; +import { EstadoPlantilla } from '../../enumerations/estado-plantilla.model'; + +jest.mock('@ng-bootstrap/ng-bootstrap'); describe('Component Tests', () => { describe('Plantilla Management Delete Component', () => { @@ -37,9 +39,12 @@ describe('Component Tests', () => { fakeAsync(() => { // GIVEN jest.spyOn(service, 'delete').mockReturnValue(of(new HttpResponse({}))); + const pPlantilla = new Plantilla(); + pPlantilla.id = 123; + pPlantilla.estado = EstadoPlantilla.DELETED; // WHEN - comp.confirmDelete(123); + comp.confirmDelete(pPlantilla); tick(); // THEN diff --git a/src/main/webapp/app/entities/usuario-plantillas/list/usuario-plantillas.component.html b/src/main/webapp/app/entities/usuario-plantillas/list/usuario-plantillas.component.html new file mode 100644 index 0000000..b8ce210 --- /dev/null +++ b/src/main/webapp/app/entities/usuario-plantillas/list/usuario-plantillas.component.html @@ -0,0 +1,57 @@ +
+

+ Mis Plantillas +

Hola

+ +
+ +
+

+ + + + +
+ No usuarioEncuestas found +
+ +
+ + + + + + + + + + + + + + + + + +
NombreDescripcionCategoria
{{ miPlantilla.nombre }}{{ miPlantilla.descripcion }}{{ miPlantilla.categoria?.nombre }} +
+ + + +
+
+
+
diff --git a/src/main/webapp/app/entities/usuario-plantillas/list/usuario-plantillas.component.scss b/src/main/webapp/app/entities/usuario-plantillas/list/usuario-plantillas.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/main/webapp/app/entities/usuario-plantillas/list/usuario-plantillas.component.ts b/src/main/webapp/app/entities/usuario-plantillas/list/usuario-plantillas.component.ts new file mode 100644 index 0000000..cc18ef0 --- /dev/null +++ b/src/main/webapp/app/entities/usuario-plantillas/list/usuario-plantillas.component.ts @@ -0,0 +1,68 @@ +import { Component, OnInit } from '@angular/core'; +import { IUsuarioExtra, UsuarioExtra } from '../../usuario-extra/usuario-extra.model'; +import { IPlantilla } from '../../plantilla/plantilla.model'; +import { HttpResponse } from '@angular/common/http'; + +import { PlantillaService } from '../../plantilla/service/plantilla.service'; +import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; +import { CategoriaService } from '../../categoria/service/categoria.service'; +import { UsuarioExtraService } from '../../usuario-extra/service/usuario-extra.service'; +import { ActivatedRoute, Router } from '@angular/router'; +import { FormBuilder } from '@angular/forms'; +import { AccountService } from '../../../core/auth/account.service'; +import * as dayjs from 'dayjs'; +import { Account } from '../../../core/auth/account.model'; + +@Component({ + selector: 'jhi-usuario-plantillas', + templateUrl: './usuario-plantillas.component.html', + styleUrls: ['./usuario-plantillas.component.scss'], +}) +export class UsuarioPlantillasComponent implements OnInit { + misPlantillas?: IPlantilla[] | null | undefined; + isLoading = false; + usuarioExtra: UsuarioExtra | null = null; + account: Account | null = null; + + constructor( + protected plantillaService: PlantillaService, + protected modalService: NgbModal, + protected categoriaService: CategoriaService, + protected usuarioExtraService: UsuarioExtraService, + protected activatedRoute: ActivatedRoute, + protected fb: FormBuilder, + protected accountService: AccountService, + protected router: Router + ) {} + + ngOnInit(): void { + this.accountService.getAuthenticationState().subscribe(account => { + if (account !== null) { + this.account = account; + this.loadAll(); + } + }); + } + + loadAll() { + this.isLoading = true; + // Get jhi_user and usuario_extra information + if (this.account !== null) { + this.usuarioExtraService.find(this.account.id).subscribe(usuarioExtra => { + this.usuarioExtra = usuarioExtra.body; + this.misPlantillas = usuarioExtra.body?.plantillas; + this.isLoading = false; + if (this.usuarioExtra !== null) { + if (this.usuarioExtra.id === undefined) { + const today = dayjs().startOf('day'); + this.usuarioExtra.fechaNacimiento = today; + } + } + }); + } + } + + trackId(index: number, item: IPlantilla): number { + return item.id!; + } +} diff --git a/src/main/webapp/app/entities/usuario-plantillas/route/usuario-plantillas.route.ts b/src/main/webapp/app/entities/usuario-plantillas/route/usuario-plantillas.route.ts new file mode 100644 index 0000000..b476951 --- /dev/null +++ b/src/main/webapp/app/entities/usuario-plantillas/route/usuario-plantillas.route.ts @@ -0,0 +1,11 @@ +import { Route, RouterModule } from '@angular/router'; + +import { UsuarioPlantillasComponent } from '../list/usuario-plantillas.component'; + +export const USUARIO_PLANTILLAS_ROUTE: Route = { + path: '', + component: UsuarioPlantillasComponent, + data: { + pageTitle: 'dataSurveyApp.usuarioExtra.plantillas.title', + }, +}; diff --git a/src/main/webapp/app/entities/usuario-plantillas/usuario-plantillas.model.ts b/src/main/webapp/app/entities/usuario-plantillas/usuario-plantillas.model.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/main/webapp/app/entities/usuario-plantillas/usuario-plantillas.module.ts b/src/main/webapp/app/entities/usuario-plantillas/usuario-plantillas.module.ts new file mode 100644 index 0000000..cee5e8e --- /dev/null +++ b/src/main/webapp/app/entities/usuario-plantillas/usuario-plantillas.module.ts @@ -0,0 +1,13 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { UsuarioPlantillasComponent } from './list/usuario-plantillas.component'; +import { RouterModule } from '@angular/router'; +import { USUARIO_PLANTILLAS_ROUTE } from './route/usuario-plantillas.route'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { SharedModule } from '../../shared/shared.module'; + +@NgModule({ + declarations: [UsuarioPlantillasComponent], + imports: [CommonModule, RouterModule.forChild([USUARIO_PLANTILLAS_ROUTE]), FontAwesomeModule, SharedModule], +}) +export class UsuarioPlantillasModule {} diff --git a/src/main/webapp/app/layouts/sidebar/sidebar.constants.ts b/src/main/webapp/app/layouts/sidebar/sidebar.constants.ts index 40bbb53..715b298 100644 --- a/src/main/webapp/app/layouts/sidebar/sidebar.constants.ts +++ b/src/main/webapp/app/layouts/sidebar/sidebar.constants.ts @@ -70,12 +70,12 @@ export const USER_ROUTES: RouteInfo[] = [ // type: 'link', // icontype: 'nc-icon nc-cart-simple', // }, - // { - // path: '/plantilla', - // title: 'Plantillas', - // type: 'link', - // icontype: 'nc-icon nc-album-2', - // }, + { + path: '/mis-plantillas', + title: 'Mis Plantillas', + type: 'link', + icontype: 'nc-icon nc-album-2', + }, { path: '/colaboraciones', title: 'Colaboraciones', 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..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,9 @@ >
- +
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..df5a08f 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,21 @@ export class PaginaPrincipalComponent implements OnInit { ); } - trackId(index: number, item: IEncuesta): number { + trackId(_index: number, item: IEncuesta): number { return item.id!; } + + completeEncuesta(encuesta: IEncuesta): void { + this.router.navigate(['/encuesta', encuesta.id, 'complete']); + } + + 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 02866f3..0cc744d 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", diff --git a/src/main/webapp/i18n/es/usuarioExtra.json b/src/main/webapp/i18n/es/usuarioExtra.json index 660fd9d..087360f 100644 --- a/src/main/webapp/i18n/es/usuarioExtra.json +++ b/src/main/webapp/i18n/es/usuarioExtra.json @@ -27,7 +27,12 @@ "correo": "Correo electrónico", "encuesta": "Encuesta", "usuarioEncuesta": "Usuario Encuesta", - "plantilla": "Plantilla" + "plantilla": "Plantilla", + "plantillas": { + "title": "Mis Plantillas", + "notFound": "No tiene plantillas compradas", + "crearEncuesta": "Crear encuesta" + } } } }