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 49ca308..8222598 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 @@ -80,70 +80,90 @@ -->
-
-
-
-

Encuesta

+
+

+

Vista previa de {{ encuesta!.nombre }}

+

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

+
+ + + +
+

+ + + -
-
-
-
-
-
-

{{ encuesta.nombre }}

-
-
-
-
-
- No se encontraron preguntas + + +
+ No se encontraron preguntas +
+ +
+
+
+
+
+ {{ i + 1 }}. {{ ePregunta.nombre }}
- -
-
-
- {{ ePregunta.nombre }} | - {{ ePregunta.tipo }} | - {{ ePregunta.opcional }} - - - - -
- - -
-
-
+
+ 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)' : '' }} +
+ + + + +
+ + + +
- -
-
+ + + +
+
-
-
-
Fecha Creacion
-
- {{ encuesta.fechaCreacion | formatMediumDatetime }} -
-
Fecha Publicacion
-
- {{ encuesta.fechaPublicacion | formatMediumDatetime }} -
-
Fecha Finalizar
-
- {{ encuesta.fechaFinalizar | formatMediumDatetime }} -
-
Fecha Finalizada
-
- {{ encuesta.fechaFinalizada | formatMediumDatetime }} -
+
+

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

+
+

Colaboradores

diff --git a/src/main/webapp/app/entities/encuesta/detail/encuesta-detail.component.ts b/src/main/webapp/app/entities/encuesta/detail/encuesta-detail.component.ts index e7b714f..f3b8cc9 100644 --- a/src/main/webapp/app/entities/encuesta/detail/encuesta-detail.component.ts +++ b/src/main/webapp/app/entities/encuesta/detail/encuesta-detail.component.ts @@ -21,6 +21,15 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { IEPreguntaCerrada } from 'app/entities/e-pregunta-cerrada/e-pregunta-cerrada.model'; import { EPreguntaCerradaService } from 'app/entities/e-pregunta-cerrada/service/e-pregunta-cerrada.service'; import { EPreguntaCerradaDeleteDialogComponent } from 'app/entities/e-pregunta-cerrada/delete/e-pregunta-cerrada-delete-dialog.component'; +import { IEPreguntaAbierta } from '../../e-pregunta-abierta/e-pregunta-abierta.model'; +import { EPreguntaCerrada } from '../../e-pregunta-cerrada/e-pregunta-cerrada.model'; +import { EPreguntaCerradaOpcion, IEPreguntaCerradaOpcion } from '../../e-pregunta-cerrada-opcion/e-pregunta-cerrada-opcion.model'; +import { EPreguntaAbiertaService } from '../../e-pregunta-abierta/service/e-pregunta-abierta.service'; +import { EPreguntaCerradaOpcionService } from '../../e-pregunta-cerrada-opcion/service/e-pregunta-cerrada-opcion.service'; +import { PreguntaCerradaTipo } from 'app/entities/enumerations/pregunta-cerrada-tipo.model'; + +import { faTimes, faPlus } from '@fortawesome/free-solid-svg-icons'; +import { EncuestaPublishDialogComponent } from '../encuesta-publish-dialog/encuesta-publish-dialog.component'; @Component({ selector: 'jhi-encuesta-detail', @@ -29,10 +38,11 @@ import { EPreguntaCerradaDeleteDialogComponent } from 'app/entities/e-pregunta-c export class EncuestaDetailComponent implements OnInit { categoriasSharedCollection: ICategoria[] = []; usuarioExtrasSharedCollection: IUsuarioExtra[] = []; - + faTimes = faTimes; + faPlus = faPlus; encuesta: IEncuesta | null = null; isLoading = false; - + successPublished = false; ePreguntas?: any[]; ePreguntasOpciones?: any[]; @@ -42,7 +52,10 @@ export class EncuestaDetailComponent implements OnInit { protected categoriaService: CategoriaService, protected usuarioExtraService: UsuarioExtraService, protected fb: FormBuilder, - protected modalService: NgbModal + protected modalService: NgbModal, + protected ePreguntaCerradaService: EPreguntaCerradaService, + protected ePreguntaCerradaOpcionService: EPreguntaCerradaOpcionService, + protected ePreguntaAbiertaService: EPreguntaAbiertaService ) {} ngOnInit(): void { @@ -56,10 +69,39 @@ export class EncuestaDetailComponent implements OnInit { }); } + ngAfterViewChecked(): void { + this.initListeners(); + } + + initListeners(): void { + const checkboxes = document.getElementsByClassName('ds-survey--checkbox'); + for (let i = 0; i < checkboxes.length; i++) { + checkboxes[i].addEventListener('click', e => { + if ((e.target as HTMLInputElement).checked) { + (e.target as HTMLElement).offsetParent!.classList.add('ds-survey--closed-option--active'); + } else { + (e.target as HTMLElement).offsetParent!.classList.remove('ds-survey--closed-option--active'); + } + }); + } + } + trackId(index: number, item: IEPreguntaCerrada): number { return item.id!; } + trackEPreguntaCerradaById(index: number, item: IEPreguntaCerrada): number { + return item.id!; + } + + trackCategoriaById(index: number, item: ICategoria): number { + return item.id!; + } + + trackUsuarioExtraById(index: number, item: IUsuarioExtra): number { + return item.id!; + } + getEncuesta(id: number) { return this.encuestaService.findEncuesta(id); } @@ -92,7 +134,7 @@ export class EncuestaDetailComponent implements OnInit { } ); - this.encuestaService.findQuestionsOptions(this.encuesta?.id!).subscribe( + /* this.encuestaService.findQuestionsOptions(this.encuesta?.id!).subscribe( (res: any) => { this.isLoading = false; this.ePreguntasOpciones = res.body ?? []; @@ -100,7 +142,18 @@ export class EncuestaDetailComponent implements OnInit { () => { this.isLoading = false; } - ); + );*/ + } + publishSurvey(): void { + const modalRef = this.modalService.open(EncuestaPublishDialogComponent, { size: 'lg', backdrop: 'static' }); + modalRef.componentInstance.encuesta = this.encuesta; + // unsubscribe not needed because closed completes on modal close + modalRef.closed.subscribe(reason => { + if (reason === 'published') { + this.successPublished = true; + this.loadAll(); + } + }); } previousState(): void { diff --git a/src/main/webapp/app/entities/encuesta/list/encuesta.component.ts b/src/main/webapp/app/entities/encuesta/list/encuesta.component.ts index 17efcb2..160f426 100644 --- a/src/main/webapp/app/entities/encuesta/list/encuesta.component.ts +++ b/src/main/webapp/app/entities/encuesta/list/encuesta.component.ts @@ -70,7 +70,6 @@ export class EncuestaComponent implements OnInit, AfterViewInit { isLoading = false; selectedSurvey?: IEncuesta | null = null; isSaving = false; - selectedSurvey: number = 0; categoriasSharedCollection: ICategoria[] = []; usuarioExtrasSharedCollection: IUsuarioExtra[] = []; @@ -438,7 +437,7 @@ export class EncuestaComponent implements OnInit, AfterViewInit { } openPreview() { - const surveyId = this.selectedSurvey; + const surveyId = this.selectedIdSurvey; this.router.navigate(['/encuesta', surveyId, 'preview']); } @@ -480,8 +479,6 @@ export class EncuestaComponent implements OnInit, AfterViewInit { event.target.classList.add('active'); document.getElementById('contextmenu-create--separator')!.style.display = 'none'; - this.selectedSurvey = Number(event.target.dataset.id); - this.selectedIdSurvey = Number(event.target.dataset.id); //this.selectedSurvey = event.target.dataset.encuesta; } 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 2d71efd..3bcf8e2 100644 --- a/src/main/webapp/app/entities/encuesta/service/encuesta.service.ts +++ b/src/main/webapp/app/entities/encuesta/service/encuesta.service.ts @@ -61,10 +61,6 @@ export class EncuestaService { .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); } - findEncuesta(id: number): Observable { - return this.http.get(`${this.resourceUrl}/${id}`); - } - deleteEncuesta(encuesta: IEncuesta): Observable { //const copy = this.convertDateFromClient(encuesta); return this.http.put(`${this.resourceUrl}/${getEncuestaIdentifier(encuesta) as number}`, encuesta, { observe: 'response' }); diff --git a/src/main/webapp/content/scss/paper-dashboard/_datasurvey-survey.scss b/src/main/webapp/content/scss/paper-dashboard/_datasurvey-survey.scss new file mode 100644 index 0000000..682b873 --- /dev/null +++ b/src/main/webapp/content/scss/paper-dashboard/_datasurvey-survey.scss @@ -0,0 +1,77 @@ +.preview-survey { + /* --------------------------------------- */ + /* ----- Radio Button */ + /* --------------------------------------- */ + /* --------------------------------------- */ + /* ----- Checkbox */ + /* --------------------------------------- */ +} +.preview-survey h2 { + font-size: 16px; + color: #001f3f; + margin-bottom: 20px; + margin-left: 20px; +} +.preview-survey > div { + padding: 20px 0; + border-bottom: 1px solid #ccc; +} +.preview-survey .radio label, +.preview-survey .checkbox label { + display: inline-block; + cursor: pointer; + color: #00b88d; + position: relative; + padding: 5px 15px 5px 51px; + font-size: 1em; + border-radius: 5px; + -webkit-transition: all 0.3s ease; + -o-transition: all 0.3s ease; + transition: all 0.3s ease; +} +.preview-survey .radio label:hover, +.preview-survey .checkbox label:hover { + background: rgba(0, 184, 141, 0.1); +} +.preview-survey .radio label:before, +.preview-survey .checkbox label:before { + content: ''; + display: inline-block; + width: 17px; + height: 17px; + position: absolute; + left: 15px; + border-radius: 50%; + background: none; + border: 3px solid #00b88d; +} +.preview-survey input[type='radio'] { + display: none; +} +.preview-survey input[type='radio']:checked + label:before { + display: none; +} +.preview-survey input[type='radio']:checked + label { + padding: 5px 15px; + background: #00b88d; + border-radius: 2px; + color: #fff; +} +.preview-survey .checkbox label:before { + border-radius: 3px; +} +.preview-survey .checkbox input[type='checkbox'] { + display: none; +} +.preview-survey .checkbox input[type='checkbox']:checked + label:before { + display: none; +} +.preview-survey .checkbox input[type='checkbox']:checked + label { + background: #00b88d; + color: #fff; + padding: 5px 15px; +} + +.preview-survey .ds-survey--open-option textarea { + border: 3px solid #00b88d; +}