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/java/org/datasurvey/web/rest/EncuestaResource.java b/src/main/java/org/datasurvey/web/rest/EncuestaResource.java index 992ae8f..5744a97 100644 --- a/src/main/java/org/datasurvey/web/rest/EncuestaResource.java +++ b/src/main/java/org/datasurvey/web/rest/EncuestaResource.java @@ -11,10 +11,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import javax.validation.Valid; import javax.validation.constraints.NotNull; -import org.datasurvey.domain.EPreguntaAbierta; -import org.datasurvey.domain.EPreguntaCerrada; -import org.datasurvey.domain.EPreguntaCerradaOpcion; -import org.datasurvey.domain.Encuesta; +import org.datasurvey.domain.*; import org.datasurvey.domain.enumeration.AccesoEncuesta; import org.datasurvey.repository.EncuestaRepository; import org.datasurvey.service.*; @@ -59,6 +56,14 @@ public class EncuestaResource { private final EPreguntaCerradaOpcionService ePreguntaCerradaOpcionService; + private final PlantillaService plantillaService; + + private final PPreguntaCerradaService pPreguntaCerradaService; + + private final PPreguntaAbiertaService pPreguntaAbiertaService; + + private final PPreguntaCerradaOpcionService pPreguntaCerradaOpcionService; + public EncuestaResource( EncuestaService encuestaService, EncuestaRepository encuestaRepository, @@ -66,7 +71,11 @@ public class EncuestaResource { MailService mailService, EPreguntaCerradaService ePreguntaCerradaService, EPreguntaAbiertaService ePreguntaAbiertaService, - EPreguntaCerradaOpcionService ePreguntaCerradaOpcionService + EPreguntaCerradaOpcionService ePreguntaCerradaOpcionService, + PlantillaService plantillaService, + PPreguntaCerradaService pPreguntaCerradaService, + PPreguntaAbiertaService pPreguntaAbiertaService, + PPreguntaCerradaOpcionService pPreguntaCerradaOpcionService ) { this.encuestaService = encuestaService; this.encuestaRepository = encuestaRepository; @@ -75,6 +84,10 @@ public class EncuestaResource { this.ePreguntaCerradaService = ePreguntaCerradaService; this.ePreguntaAbiertaService = ePreguntaAbiertaService; this.ePreguntaCerradaOpcionService = ePreguntaCerradaOpcionService; + this.plantillaService = plantillaService; + this.pPreguntaCerradaService = pPreguntaCerradaService; + this.pPreguntaAbiertaService = pPreguntaAbiertaService; + this.pPreguntaCerradaOpcionService = pPreguntaCerradaOpcionService; } /** @@ -97,6 +110,78 @@ public class EncuestaResource { .body(result); } + @PostMapping("/encuestas/{plantillaId}") + public ResponseEntity createEncuestaFromTemplate( + @Valid @RequestBody Encuesta encuesta, + @PathVariable(value = "plantillaId", required = false) final Long plantillaId + ) throws URISyntaxException { + log.debug("REST request to save Encuesta : {}", encuesta); + if (encuesta.getId() != null) { + throw new BadRequestAlertException("A new encuesta cannot already have an ID", ENTITY_NAME, "idexists"); + } + + // Copy from survey template to survey + Optional plantilla = plantillaService.findOne(plantillaId); + + if (plantilla.isPresent()) { + encuesta.setNombre(plantilla.get().getNombre()); + encuesta.setDescripcion(plantilla.get().getDescripcion()); + encuesta.setCategoria(plantilla.get().getCategoria()); + + Encuesta encuestaCreated = encuestaService.save(encuesta); + + // Preguntas cerradas + List preguntasCerradas = pPreguntaCerradaService.findAll(); + for (PPreguntaCerrada pPreguntaCerrada : preguntasCerradas) { + if (pPreguntaCerrada.getPlantilla().getId().equals(plantillaId)) { + EPreguntaCerrada newEPreguntaCerrada = new EPreguntaCerrada(); + newEPreguntaCerrada.setNombre(pPreguntaCerrada.getNombre()); + newEPreguntaCerrada.setTipo(pPreguntaCerrada.getTipo()); + newEPreguntaCerrada.setOpcional(pPreguntaCerrada.getOpcional()); + newEPreguntaCerrada.setOrden(pPreguntaCerrada.getOrden()); + newEPreguntaCerrada.setEncuesta(encuestaCreated); + + ePreguntaCerradaService.save(newEPreguntaCerrada); + + // Opciones de preguntas cerradas + List opciones = pPreguntaCerradaOpcionService.findAll(); + for (PPreguntaCerradaOpcion pPreguntaCerradaOpcion : opciones) { + if (pPreguntaCerradaOpcion.getPPreguntaCerrada().getId().equals(pPreguntaCerrada.getId())) { + EPreguntaCerradaOpcion newEPreguntaCerradaOpcion = new EPreguntaCerradaOpcion(); + newEPreguntaCerradaOpcion.setNombre(pPreguntaCerradaOpcion.getNombre()); + newEPreguntaCerradaOpcion.setOrden(pPreguntaCerradaOpcion.getOrden()); + newEPreguntaCerradaOpcion.setCantidad(0); + newEPreguntaCerradaOpcion.setEPreguntaCerrada(newEPreguntaCerrada); + + ePreguntaCerradaOpcionService.save(newEPreguntaCerradaOpcion); + } + } + } + } + + // Preguntas abiertas + List preguntasAbiertas = pPreguntaAbiertaService.findAll(); + for (PPreguntaAbierta pPreguntaAbierta : preguntasAbiertas) { + if (pPreguntaAbierta.getPlantilla().getId().equals(plantillaId)) { + EPreguntaAbierta newEPreguntaAbierta = new EPreguntaAbierta(); + newEPreguntaAbierta.setNombre(pPreguntaAbierta.getNombre()); + newEPreguntaAbierta.setOpcional(pPreguntaAbierta.getOpcional()); + newEPreguntaAbierta.setOrden(pPreguntaAbierta.getOrden()); + newEPreguntaAbierta.setEncuesta(encuestaCreated); + + ePreguntaAbiertaService.save(newEPreguntaAbierta); + } + } + + return ResponseEntity + .created(new URI("/api/encuestas/" + encuestaCreated.getId())) + .headers(HeaderUtil.createEntityCreationAlert(applicationName, true, ENTITY_NAME, encuestaCreated.getId().toString())) + .body(encuestaCreated); + } + + return ResponseEntity.ok().body(null); + } + /** * {@code PUT /encuestas/:id} : Updates an existing encuesta. * diff --git a/src/main/webapp/app/entities/categoria/delete/categoria-delete-dialog.component.html b/src/main/webapp/app/entities/categoria/delete/categoria-delete-dialog.component.html index d1ad4e4..a603aea 100644 --- a/src/main/webapp/app/entities/categoria/delete/categoria-delete-dialog.component.html +++ b/src/main/webapp/app/entities/categoria/delete/categoria-delete-dialog.component.html @@ -19,7 +19,7 @@  Cancel - 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/categoria/list/categoria.component.html b/src/main/webapp/app/entities/categoria/list/categoria.component.html index b486a5d..780d299 100644 --- a/src/main/webapp/app/entities/categoria/list/categoria.component.html +++ b/src/main/webapp/app/entities/categoria/list/categoria.component.html @@ -44,7 +44,7 @@ - +
@@ -67,7 +67,7 @@ Edit - diff --git a/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.html b/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.html new file mode 100644 index 0000000..c452af6 --- /dev/null +++ b/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.html @@ -0,0 +1 @@ +

dashboard-admin works!

diff --git a/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.scss b/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.spec.ts b/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.spec.ts new file mode 100644 index 0000000..f199b58 --- /dev/null +++ b/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.spec.ts @@ -0,0 +1,24 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { DashboardAdminComponent } from './dashboard-admin.component'; + +describe('DashboardAdminComponent', () => { + let component: DashboardAdminComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [DashboardAdminComponent], + }).compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(DashboardAdminComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.ts b/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.ts new file mode 100644 index 0000000..74c742e --- /dev/null +++ b/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.ts @@ -0,0 +1,12 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'jhi-dashboard-admin', + templateUrl: './dashboard-admin.component.html', + styleUrls: ['./dashboard-admin.component.scss'], +}) +export class DashboardAdminComponent implements OnInit { + constructor() {} + + ngOnInit(): void {} +} diff --git a/src/main/webapp/app/entities/dashboard/dashboard-user/dashboard-user.component.html b/src/main/webapp/app/entities/dashboard/dashboard-user/dashboard-user.component.html new file mode 100644 index 0000000..3c30945 --- /dev/null +++ b/src/main/webapp/app/entities/dashboard/dashboard-user/dashboard-user.component.html @@ -0,0 +1 @@ +

dashboard-user works!

diff --git a/src/main/webapp/app/entities/dashboard/dashboard-user/dashboard-user.component.scss b/src/main/webapp/app/entities/dashboard/dashboard-user/dashboard-user.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/main/webapp/app/entities/dashboard/dashboard-user/dashboard-user.component.spec.ts b/src/main/webapp/app/entities/dashboard/dashboard-user/dashboard-user.component.spec.ts new file mode 100644 index 0000000..d1665ea --- /dev/null +++ b/src/main/webapp/app/entities/dashboard/dashboard-user/dashboard-user.component.spec.ts @@ -0,0 +1,24 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { DashboardUserComponent } from './dashboard-user.component'; + +describe('DashboardUserComponent', () => { + let component: DashboardUserComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [DashboardUserComponent], + }).compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(DashboardUserComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/main/webapp/app/entities/dashboard/dashboard-user/dashboard-user.component.ts b/src/main/webapp/app/entities/dashboard/dashboard-user/dashboard-user.component.ts new file mode 100644 index 0000000..4a4a261 --- /dev/null +++ b/src/main/webapp/app/entities/dashboard/dashboard-user/dashboard-user.component.ts @@ -0,0 +1,12 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'jhi-dashboard-user', + templateUrl: './dashboard-user.component.html', + styleUrls: ['./dashboard-user.component.scss'], +}) +export class DashboardUserComponent implements OnInit { + constructor() {} + + ngOnInit(): void {} +} diff --git a/src/main/webapp/app/entities/dashboard/dashboard.module.ts b/src/main/webapp/app/entities/dashboard/dashboard.module.ts new file mode 100644 index 0000000..c172c5c --- /dev/null +++ b/src/main/webapp/app/entities/dashboard/dashboard.module.ts @@ -0,0 +1,14 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; + +import { DashboardUserComponent } from './dashboard-user/dashboard-user.component'; +import { DashboardAdminComponent } from './dashboard-admin/dashboard-admin.component'; +import { SharedModule } from '../../shared/shared.module'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { DashboardRoutingModule } from './route/dashboard-routing.module'; + +@NgModule({ + declarations: [DashboardUserComponent, DashboardAdminComponent], + imports: [CommonModule, SharedModule, DashboardRoutingModule, FontAwesomeModule], +}) +export class DashboardModule {} diff --git a/src/main/webapp/app/entities/dashboard/route/dashboard-routing.module.ts b/src/main/webapp/app/entities/dashboard/route/dashboard-routing.module.ts new file mode 100644 index 0000000..6e23128 --- /dev/null +++ b/src/main/webapp/app/entities/dashboard/route/dashboard-routing.module.ts @@ -0,0 +1,25 @@ +import { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; + +import { DashboardUserComponent } from '../dashboard-user/dashboard-user.component'; +import { DashboardAdminComponent } from '../dashboard-admin/dashboard-admin.component'; +import { UserRouteAccessService } from '../../../core/auth/user-route-access.service'; + +const dashboardRoute: Routes = [ + { + path: 'admin', + component: DashboardAdminComponent, + canActivate: [UserRouteAccessService], + }, + { + path: 'user', + component: DashboardUserComponent, + canActivate: [UserRouteAccessService], + }, +]; + +@NgModule({ + imports: [RouterModule.forChild(dashboardRoute)], + exports: [RouterModule], +}) +export class DashboardRoutingModule {} 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/detail/encuesta-detail.component.html b/src/main/webapp/app/entities/encuesta/detail/encuesta-detail.component.html index 81681aa..b70a0a8 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 @@ -34,7 +34,7 @@

Inicie creando preguntas y opciones para su encuesta.

-
+
- + 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/list/encuesta.component.html b/src/main/webapp/app/entities/encuesta/list/encuesta.component.html index 249c71d..6032fc6 100644 --- a/src/main/webapp/app/entities/encuesta/list/encuesta.component.html +++ b/src/main/webapp/app/entities/encuesta/list/encuesta.component.html @@ -40,10 +40,6 @@
-
- No surveys found -
-
@@ -83,8 +79,17 @@
+
+
+ +

No posee encuestas

+

Incie a explorar, colaborar y adquirir datos al crear encuestas mundialmente

+
+
+
+ -
+
    @@ -208,7 +213,7 @@
-
Nombre
+
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/encuesta/service/encuesta.service.ts b/src/main/webapp/app/entities/encuesta/service/encuesta.service.ts index 8e241c3..3d854c5 100644 --- a/src/main/webapp/app/entities/encuesta/service/encuesta.service.ts +++ b/src/main/webapp/app/entities/encuesta/service/encuesta.service.ts @@ -26,6 +26,13 @@ export class EncuestaService { .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); } + createFromTemplate(encuesta: IEncuesta, plantillaId: Number): Observable { + const copy = this.convertDateFromClient(encuesta); + return this.http + .post(`${this.resourceUrl}/${plantillaId}`, copy, { observe: 'response' }) + .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); + } + //update para publicar update(encuesta: IEncuesta): Observable { const copy = this.convertDateFromClient(encuesta); diff --git a/src/main/webapp/app/entities/encuesta/update/encuesta-update.component.html b/src/main/webapp/app/entities/encuesta/update/encuesta-update.component.html index 5f0a4d0..b857f99 100644 --- a/src/main/webapp/app/entities/encuesta/update/encuesta-update.component.html +++ b/src/main/webapp/app/entities/encuesta/update/encuesta-update.component.html @@ -42,9 +42,6 @@

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

-
+ +
diff --git a/src/main/webapp/app/entities/entity-routing.module.ts b/src/main/webapp/app/entities/entity-routing.module.ts index f01eb05..47e08ea 100644 --- a/src/main/webapp/app/entities/entity-routing.module.ts +++ b/src/main/webapp/app/entities/entity-routing.module.ts @@ -77,6 +77,21 @@ 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), + }, + { + path: 'dashboard', + data: { pageTitle: 'dataSurveyApp.Dashboard.title' }, + loadChildren: () => import('./dashboard/dashboard.module').then(m => m.DashboardModule), + }, + { + path: 'dashboard', + data: { pageTitle: 'dataSurveyApp.Dashboard.title' }, + loadChildren: () => import('./dashboard/dashboard.module').then(m => m.DashboardModule), + }, /* 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.html b/src/main/webapp/app/entities/plantilla/delete/plantilla-delete-dialog.component.html index e43778d..4042602 100644 --- a/src/main/webapp/app/entities/plantilla/delete/plantilla-delete-dialog.component.html +++ b/src/main/webapp/app/entities/plantilla/delete/plantilla-delete-dialog.component.html @@ -1,24 +1,23 @@ -
- - + 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.spec.ts deleted file mode 100644 index 0e2d24c..0000000 --- a/src/main/webapp/app/entities/plantilla/delete/plantilla-delete-dialog.component.spec.ts +++ /dev/null @@ -1,65 +0,0 @@ -jest.mock('@ng-bootstrap/ng-bootstrap'); - -import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing'; -import { HttpResponse } from '@angular/common/http'; -import { HttpClientTestingModule } from '@angular/common/http/testing'; -import { of } from 'rxjs'; -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; - -import { PlantillaService } from '../service/plantilla.service'; - -import { PlantillaDeleteDialogComponent } from './plantilla-delete-dialog.component'; - -describe('Component Tests', () => { - describe('Plantilla Management Delete Component', () => { - let comp: PlantillaDeleteDialogComponent; - let fixture: ComponentFixture; - let service: PlantillaService; - let mockActiveModal: NgbActiveModal; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], - declarations: [PlantillaDeleteDialogComponent], - providers: [NgbActiveModal], - }) - .overrideTemplate(PlantillaDeleteDialogComponent, '') - .compileComponents(); - fixture = TestBed.createComponent(PlantillaDeleteDialogComponent); - comp = fixture.componentInstance; - service = TestBed.inject(PlantillaService); - mockActiveModal = TestBed.inject(NgbActiveModal); - }); - - describe('confirmDelete', () => { - it('Should call delete service on confirmDelete', inject( - [], - fakeAsync(() => { - // GIVEN - jest.spyOn(service, 'delete').mockReturnValue(of(new HttpResponse({}))); - - // WHEN - comp.confirmDelete(123); - tick(); - - // THEN - expect(service.delete).toHaveBeenCalledWith(123); - expect(mockActiveModal.close).toHaveBeenCalledWith('deleted'); - }) - )); - - it('Should not call delete service on clear', () => { - // GIVEN - jest.spyOn(service, 'delete'); - - // WHEN - comp.cancel(); - - // THEN - expect(service.delete).not.toHaveBeenCalled(); - expect(mockActiveModal.close).not.toHaveBeenCalled(); - expect(mockActiveModal.dismiss).toHaveBeenCalled(); - }); - }); - }); -}); diff --git a/src/main/webapp/app/entities/plantilla/delete/plantilla-delete-dialog.component.ts b/src/main/webapp/app/entities/plantilla/delete/plantilla-delete-dialog.component.ts index 972e8c8..55326af 100644 --- a/src/main/webapp/app/entities/plantilla/delete/plantilla-delete-dialog.component.ts +++ b/src/main/webapp/app/entities/plantilla/delete/plantilla-delete-dialog.component.ts @@ -3,6 +3,7 @@ import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { IPlantilla } from '../plantilla.model'; import { PlantillaService } from '../service/plantilla.service'; +import { EstadoPlantilla } from '../../enumerations/estado-plantilla.model'; @Component({ templateUrl: './plantilla-delete-dialog.component.html', @@ -16,8 +17,9 @@ export class PlantillaDeleteDialogComponent { this.activeModal.dismiss(); } - confirmDelete(id: number): void { - this.plantillaService.delete(id).subscribe(() => { + confirmDelete(pPlantilla: IPlantilla): void { + pPlantilla.estado = EstadoPlantilla.DELETED; + this.plantillaService.update(pPlantilla).subscribe(() => { this.activeModal.close('deleted'); }); } diff --git a/src/main/webapp/app/entities/plantilla/detail/plantilla-detail.component.html b/src/main/webapp/app/entities/plantilla/detail/plantilla-detail.component.html index 8308da3..06bcf5f 100644 --- a/src/main/webapp/app/entities/plantilla/detail/plantilla-detail.component.html +++ b/src/main/webapp/app/entities/plantilla/detail/plantilla-detail.component.html @@ -24,7 +24,7 @@

Inicie creando preguntas y opciones para su plantilla.

-
+
+ +
+
+
+ +
+
+
+ +
+ +
+ @@ -35,11 +64,10 @@
-
Nombre
+
- @@ -49,9 +77,11 @@ - + - @@ -70,7 +100,6 @@ Vista previa - - + + + + + diff --git a/src/main/webapp/app/entities/plantilla/plantilla-change-status-dialog/plantilla-change-status-dialog.component.scss b/src/main/webapp/app/entities/plantilla/plantilla-change-status-dialog/plantilla-change-status-dialog.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/main/webapp/app/entities/plantilla/plantilla-change-status-dialog/plantilla-change-status-dialog.component.temSpec.ts b/src/main/webapp/app/entities/plantilla/plantilla-change-status-dialog/plantilla-change-status-dialog.component.temSpec.ts new file mode 100644 index 0000000..0cd0af9 --- /dev/null +++ b/src/main/webapp/app/entities/plantilla/plantilla-change-status-dialog/plantilla-change-status-dialog.component.temSpec.ts @@ -0,0 +1,24 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { PlantillaChangeStatusDialogComponent } from './plantilla-change-status-dialog.component'; + +describe('PlantillaChangeStatusDialogComponent', () => { + let component: PlantillaChangeStatusDialogComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [PlantillaChangeStatusDialogComponent], + }).compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(PlantillaChangeStatusDialogComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/main/webapp/app/entities/plantilla/plantilla-change-status-dialog/plantilla-change-status-dialog.component.ts b/src/main/webapp/app/entities/plantilla/plantilla-change-status-dialog/plantilla-change-status-dialog.component.ts new file mode 100644 index 0000000..ff5f9f0 --- /dev/null +++ b/src/main/webapp/app/entities/plantilla/plantilla-change-status-dialog/plantilla-change-status-dialog.component.ts @@ -0,0 +1,36 @@ +import { Component } from '@angular/core'; +import { PlantillaService } from '../service/plantilla.service'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { EstadoPlantilla } from '../../enumerations/estado-plantilla.model'; +import { IPlantilla } from '../plantilla.model'; + +import { faExchangeAlt } from '@fortawesome/free-solid-svg-icons'; + +@Component({ + selector: 'jhi-plantilla-change-status-dialog', + templateUrl: './plantilla-change-status-dialog.component.html', + styleUrls: ['./plantilla-change-status-dialog.component.scss'], +}) +export class PlantillaChangeStatusDialogComponent { + plantilla?: IPlantilla; + + faExchangeAlt = faExchangeAlt; + constructor(protected plantillaService: PlantillaService, protected activeModal: NgbActiveModal) {} + + cancel(): void { + this.activeModal.dismiss(); + } + + confirmChangeStatus(pPlantilla: IPlantilla) { + if (this.plantilla) { + if (pPlantilla.estado === EstadoPlantilla.DISABLED) { + this.plantilla.estado = EstadoPlantilla.DRAFT; + } else { + this.plantilla.estado = EstadoPlantilla.DISABLED; + } + this.plantillaService.update(this.plantilla).subscribe(() => { + this.activeModal.close('updated'); + }); + } + } +} diff --git a/src/main/webapp/app/entities/plantilla/plantilla.module.ts b/src/main/webapp/app/entities/plantilla/plantilla.module.ts index 602dba7..5ead5a0 100644 --- a/src/main/webapp/app/entities/plantilla/plantilla.module.ts +++ b/src/main/webapp/app/entities/plantilla/plantilla.module.ts @@ -10,6 +10,7 @@ import { PlantillaDeleteQuestionDialogComponent } from './plantilla-delete-quest import { PlantillaDeleteOptionDialogComponent } from './plantilla-delete-option-dialog/plantilla-delete-option-dialog.component'; import { PlantillaPublishStoreDialogComponent } from './plantilla-publish-store-dialog/plantilla-publish-store-dialog.component'; import { PlantillaDeleteStoreDialogComponent } from './plantilla-delete-store-dialog/plantilla-delete-store-dialog.component'; +import { PlantillaChangeStatusDialogComponent } from './plantilla-change-status-dialog/plantilla-change-status-dialog.component'; @NgModule({ imports: [SharedModule, PlantillaRoutingModule, FontAwesomeModule], @@ -22,6 +23,7 @@ import { PlantillaDeleteStoreDialogComponent } from './plantilla-delete-store-di PlantillaDeleteOptionDialogComponent, PlantillaPublishStoreDialogComponent, PlantillaDeleteStoreDialogComponent, + PlantillaChangeStatusDialogComponent, ], entryComponents: [PlantillaDeleteDialogComponent], }) diff --git a/src/main/webapp/app/entities/usuario-encuesta/list/usuario-encuesta.component.html b/src/main/webapp/app/entities/usuario-encuesta/list/usuario-encuesta.component.html index 3d47290..167dae8 100644 --- a/src/main/webapp/app/entities/usuario-encuesta/list/usuario-encuesta.component.html +++ b/src/main/webapp/app/entities/usuario-encuesta/list/usuario-encuesta.component.html @@ -33,12 +33,18 @@ -
- No usuarioEncuestas found + +
+
+ +

No posee colaboraciones

+

Inicie colaborando con otros usuarios mundialmente al recibir una invitación

+
+
-
NombreDescripcion Fecha Publicacion Tienda Estado
{{ plantilla.nombre }}{{ plantilla.descripcion }} {{ plantilla.fechaPublicacionTienda | formatShortDatetime | titlecase }} No establecida
+
diff --git a/src/main/webapp/app/entities/usuario-extra/delete/usuario-extra-delete-dialog.component.html b/src/main/webapp/app/entities/usuario-extra/delete/usuario-extra-delete-dialog.component.html index e550920..9388306 100644 --- a/src/main/webapp/app/entities/usuario-extra/delete/usuario-extra-delete-dialog.component.html +++ b/src/main/webapp/app/entities/usuario-extra/delete/usuario-extra-delete-dialog.component.html @@ -15,7 +15,7 @@  Cancel - diff --git a/src/main/webapp/app/entities/usuario-extra/list/usuario-extra.component.html b/src/main/webapp/app/entities/usuario-extra/list/usuario-extra.component.html index 313c27a..aa52b7e 100644 --- a/src/main/webapp/app/entities/usuario-extra/list/usuario-extra.component.html +++ b/src/main/webapp/app/entities/usuario-extra/list/usuario-extra.component.html @@ -43,7 +43,7 @@
-
Rol
+
@@ -96,7 +96,7 @@ View --> - 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..fc43592 --- /dev/null +++ b/src/main/webapp/app/entities/usuario-plantillas/list/usuario-plantillas.component.html @@ -0,0 +1,73 @@ +
+

+ Mis Plantillas +

Cree encuestas a partir de las plantillas previamente compradas

+ +
+ +
+

+ + + + +
+
+
+ +
+ +
+
+ +

No posee plantillas

+

Adquiera y compre diferentes plantillas disponibles en nuestra tienda

+
+
+
+ +
+
Rol
+ + + + + + + + + + + + + + + + +
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..22fe062 --- /dev/null +++ b/src/main/webapp/app/entities/usuario-plantillas/list/usuario-plantillas.component.ts @@ -0,0 +1,100 @@ +import { Component, OnInit } from '@angular/core'; +import { UsuarioExtra } from '../../usuario-extra/usuario-extra.model'; +import { IPlantilla } from '../../plantilla/plantilla.model'; + +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 { DATE_TIME_FORMAT } from 'app/config/input.constants'; +import { Account } from '../../../core/auth/account.model'; +import { Encuesta } from './../../encuesta/encuesta.model'; +import { EncuestaService } from 'app/entities/encuesta/service/encuesta.service'; +import { AccesoEncuesta } from 'app/entities/enumerations/acceso-encuesta.model'; +import { EstadoEncuesta } from 'app/entities/enumerations/estado-encuesta.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; + searchString: string; + + constructor( + protected plantillaService: PlantillaService, + protected modalService: NgbModal, + protected categoriaService: CategoriaService, + protected usuarioExtraService: UsuarioExtraService, + protected activatedRoute: ActivatedRoute, + protected fb: FormBuilder, + protected accountService: AccountService, + protected encuestaService: EncuestaService, + protected router: Router + ) { + this.searchString = ''; + } + + 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!; + } + + crearEncuesta(plantillaId: any): void { + const now = dayjs(); + + const newSurvey = { + ...new Encuesta(), + id: undefined, + nombre: 'This is a survey', + descripcion: 'This is a survey', + fechaCreacion: dayjs(now, DATE_TIME_FORMAT), + calificacion: 5, + acceso: AccesoEncuesta.PUBLIC, + contrasenna: undefined, + estado: EstadoEncuesta.DRAFT, + categoria: undefined, + usuarioExtra: this.usuarioExtra, + }; + + console.log(plantillaId, newSurvey); + + this.encuestaService.createFromTemplate(newSurvey, plantillaId).subscribe(_res => { + this.router.navigate(['/encuesta']); + }); + } +} 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 816c8e9..4fdf18a 100644 --- a/src/main/webapp/app/layouts/sidebar/sidebar.constants.ts +++ b/src/main/webapp/app/layouts/sidebar/sidebar.constants.ts @@ -24,6 +24,12 @@ export const ADMIN_ROUTES: RouteInfo[] = [ // }, { path: '/pagina-principal', title: 'Inicio', type: 'link', icontype: 'nc-icon nc-world-2' }, + { + path: '/dashboard/admin', + title: 'Dashboard', + type: 'link', + icontype: 'nc-icon nc-chart-bar-32', + }, { path: '/encuesta', title: 'Encuestas', @@ -58,6 +64,12 @@ export const ADMIN_ROUTES: RouteInfo[] = [ export const USER_ROUTES: RouteInfo[] = [ { path: '/pagina-principal', title: 'Inicio', type: 'link', icontype: 'nc-icon nc-world-2' }, + { + path: '/dashboard/user', + title: 'Dashboard', + type: 'link', + icontype: 'nc-icon nc-chart-bar-32', + }, { path: '/encuesta', title: 'Encuestas', @@ -71,12 +83,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 5fe36e0..4603cbb 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/content/scss/paper-dashboard.scss b/src/main/webapp/content/scss/paper-dashboard.scss index 711d10e..6d31820 100644 --- a/src/main/webapp/content/scss/paper-dashboard.scss +++ b/src/main/webapp/content/scss/paper-dashboard.scss @@ -102,3 +102,4 @@ @import 'paper-dashboard/datasurvey-home'; @import 'paper-dashboard/datasurvey-filter'; @import 'paper-dashboard/datasurvey-survey'; +@import 'paper-dashboard/datasurvey-switch'; diff --git a/src/main/webapp/content/scss/paper-dashboard/_datasurvey-buttons.scss b/src/main/webapp/content/scss/paper-dashboard/_datasurvey-buttons.scss index d0c0c24..deacfdc 100644 --- a/src/main/webapp/content/scss/paper-dashboard/_datasurvey-buttons.scss +++ b/src/main/webapp/content/scss/paper-dashboard/_datasurvey-buttons.scss @@ -42,11 +42,11 @@ } .ds-btn--toggle { - background-color: #ffaa47; + background-color: #ff9a27; color: #fff; &:hover { - background-color: #e09935; + background-color: #d48020; } } diff --git a/src/main/webapp/content/scss/paper-dashboard/_datasurvey-switch.scss b/src/main/webapp/content/scss/paper-dashboard/_datasurvey-switch.scss new file mode 100644 index 0000000..5c27ff8 --- /dev/null +++ b/src/main/webapp/content/scss/paper-dashboard/_datasurvey-switch.scss @@ -0,0 +1,30 @@ +.ds-switch { + display: flex; + align-items: center; + justify-content: space-between; + + & input { + display: flex; + align-items: center; + } + + & label { + display: flex; + align-items: center; + font-size: 0.8rem; + color: #757d94; + margin: 0; + + &::before { + top: 2px !important; + display: flex; + align-items: center; + } + + &::after { + top: 3.5px !important; + display: flex; + align-items: center; + } + } +} diff --git a/src/main/webapp/content/scss/paper-dashboard/_datasurvey-table.scss b/src/main/webapp/content/scss/paper-dashboard/_datasurvey-table.scss index e69de29..ea4ee8c 100644 --- a/src/main/webapp/content/scss/paper-dashboard/_datasurvey-table.scss +++ b/src/main/webapp/content/scss/paper-dashboard/_datasurvey-table.scss @@ -0,0 +1,25 @@ +.ds-table { + thead { + th span { + color: #2f4159; + text-transform: uppercase; + font-size: 0.9rem; + font-weight: 700; + } + } + + tbody { + tr:nth-child(odd) { + background-color: #f1f5f9; + } + + td { + border: 0; + color: #2f4159; + } + } +} + +.table-responsive { + overflow: auto; +} diff --git a/src/main/webapp/i18n/es/dashboard.json b/src/main/webapp/i18n/es/dashboard.json new file mode 100644 index 0000000..27d4016 --- /dev/null +++ b/src/main/webapp/i18n/es/dashboard.json @@ -0,0 +1,7 @@ +{ + "dataSurveyApp": { + "Dashboard": { + "title": "Dashboard" + } + } +} diff --git a/src/main/webapp/i18n/es/encuesta.json b/src/main/webapp/i18n/es/encuesta.json index 37fb2fe..36b33b6 100644 --- a/src/main/webapp/i18n/es/encuesta.json +++ b/src/main/webapp/i18n/es/encuesta.json @@ -34,7 +34,12 @@ "ePreguntaAbierta": "Pregunta Abierta", "ePreguntaCerrada": "Pregunta Cerrada", "categoria": "Categoría", - "usuarioExtra": "Correo Usuario" + "usuarioExtra": "Correo Usuario", + "plantilla": "Plantilla", + "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/plantilla.json b/src/main/webapp/i18n/es/plantilla.json index 6ec8675..4e45c2f 100644 --- a/src/main/webapp/i18n/es/plantilla.json +++ b/src/main/webapp/i18n/es/plantilla.json @@ -9,10 +9,13 @@ "notFound": "No se encontró ninguna plantilla" }, "created": "Una nueva plantilla ha sido creada con el identificador {{ param }}", - "updated": "Una plantilla ha sido actualizada con el identificador {{ param }}", + "updated": { + "detail": "Una plantilla ha sido actualizada con el identificador {{ param }}", + "buttonChangeEstado": "Cambiar estado" + }, "deleted": "Una plantilla ha sido eliminada con el identificador {{ param }}", "delete": { - "question": "¿Seguro que quiere eliminar Plantilla {{ id }}?", + "question": "¿Seguro que quiere eliminar esta plantilla?", "deletefromstore": "¿Seguro que quiere eliminar esta plantilla de la tienda?" }, "publish": { @@ -21,6 +24,14 @@ "detail": { "title": "Plantilla" }, + "desactivar": { + "titulo": "Desactivar plantilla", + "question": "¿Seguro que quiere desactivar la plantilla?" + }, + "activar": { + "titulo": "Activar plantilla", + "question": "¿Seguro que quiere activar la plantilla?. Esta será activada en estado de 'Borrador'" + }, "id": "ID", "nombre": "Nombre", "descripcion": "Descripción", 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" + } } } }