From 3d7ec930847731fe52f81af5b1b5fc3a5ecb0d40 Mon Sep 17 00:00:00 2001 From: Mariela Bonilla Date: Thu, 22 Jul 2021 23:24:12 -0600 Subject: [PATCH 1/9] Add opcion de ver vista previa en la lista de encuestas --- .../app/entities/encuesta/list/encuesta.component.html | 6 ++++-- .../app/entities/encuesta/list/encuesta.component.ts | 10 +++++++++- .../entities/encuesta/route/encuesta-routing.module.ts | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) 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 f0545aa..01aef26 100644 --- a/src/main/webapp/app/entities/encuesta/list/encuesta.component.html +++ b/src/main/webapp/app/entities/encuesta/list/encuesta.component.html @@ -58,7 +58,9 @@
  • - +
  • - +
  • 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 9300138..0dfca97 100644 --- a/src/main/webapp/app/entities/encuesta/list/encuesta.component.ts +++ b/src/main/webapp/app/entities/encuesta/list/encuesta.component.ts @@ -63,7 +63,7 @@ export class EncuestaComponent implements OnInit, AfterViewInit { isLoading = false; isSaving = false; - selectedIdSurvey: number = 0; + selectedSurvey: number = 0; categoriasSharedCollection: ICategoria[] = []; usuarioExtrasSharedCollection: IUsuarioExtra[] = []; @@ -323,7 +323,7 @@ export class EncuestaComponent implements OnInit, AfterViewInit { } openPreview() { - const surveyId = this.selectedIdSurvey; + const surveyId = this.selectedSurvey; this.router.navigate(['/encuesta', surveyId, 'preview']); } @@ -347,7 +347,7 @@ export class EncuestaComponent implements OnInit, AfterViewInit { document.getElementById('contextmenu-edit--separator')!.style.display = 'block'; document.getElementById('contextmenu-delete--separator')!.style.display = 'block'; document.getElementById('contextmenu-edit')!.style.display = 'block'; - document.getElementById('contextmenu-duplicate')!.style.display = 'block'; + document.getElementById('contextmenu-preview')!.style.display = 'block'; document.getElementById('contextmenu-rename')!.style.display = 'block'; document.getElementById('contextmenu-share')!.style.display = 'block'; @@ -357,7 +357,8 @@ export class EncuestaComponent implements OnInit, AfterViewInit { } else if ((event.target as HTMLElement).classList.contains('ds-list--entity')) { event.target.classList.add('active'); document.getElementById('contextmenu-create--separator')!.style.display = 'none'; - this.selectedIdSurvey = Number(event.target.dataset.id); + + this.selectedSurvey = Number(event.target.dataset.id); } document.getElementById('contextmenu')!.style.top = event.layerY + 'px'; 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 ebb2c3f..df9a23d 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 @@ -14,7 +14,7 @@ const encuestaRoute: Routes = [ canActivate: [UserRouteAccessService], }, { - path: ':id/view', + path: ':id/preview', component: EncuestaDetailComponent, resolve: { encuesta: EncuestaRoutingResolveService, @@ -30,7 +30,7 @@ const encuestaRoute: Routes = [ canActivate: [UserRouteAccessService], }, { - path: ':id/preview', + path: ':id/edit', component: EncuestaUpdateComponent, resolve: { encuesta: EncuestaRoutingResolveService, 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 ef95403..8517aee 100644 --- a/src/main/webapp/app/entities/encuesta/service/encuesta.service.ts +++ b/src/main/webapp/app/entities/encuesta/service/encuesta.service.ts @@ -45,6 +45,22 @@ export class EncuestaService { .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); } + findEncuesta(id: number): Observable { + return this.http.get(`${this.resourceUrl}/${id}`); + } + + findQuestions(id: number): Observable { + return this.http + .get(`${this.resourceUrl}/preguntas/${id}`, { observe: 'response' }) + .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); + } + + findQuestionsOptions(id: number): Observable { + return this.http + .get(`${this.resourceUrl}/preguntas-opciones/${id}`, { observe: 'response' }) + .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); + } + query(req?: any): Observable { const options = createRequestOption(req); return this.http diff --git a/src/main/webapp/content/scss/paper-dashboard.scss b/src/main/webapp/content/scss/paper-dashboard.scss index 3eab78d..8f83aad 100644 --- a/src/main/webapp/content/scss/paper-dashboard.scss +++ b/src/main/webapp/content/scss/paper-dashboard.scss @@ -98,3 +98,4 @@ @import 'paper-dashboard/datasurvey-list'; @import 'paper-dashboard/datasurvey-table'; @import 'paper-dashboard/datasurvey-contextmenu'; +@import 'paper-dashboard/datasurvey-survey'; From 5e441a343f684ef0279780a5d32a39e775d8225e Mon Sep 17 00:00:00 2001 From: Mariela Bonilla Date: Sun, 25 Jul 2021 04:56:18 -0600 Subject: [PATCH 3/9] add vista previa --- .../detail/encuesta-detail.component.html | 130 ++++++++++-------- .../detail/encuesta-detail.component.ts | 63 ++++++++- .../encuesta/list/encuesta.component.ts | 5 +- .../encuesta/service/encuesta.service.ts | 4 - .../paper-dashboard/_datasurvey-survey.scss | 77 +++++++++++ 5 files changed, 211 insertions(+), 68 deletions(-) create mode 100644 src/main/webapp/content/scss/paper-dashboard/_datasurvey-survey.scss 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; +} From 8bb22a2602314a30ce66c028339098601bdc1952 Mon Sep 17 00:00:00 2001 From: Mariela Bonilla Date: Sun, 25 Jul 2021 16:48:21 -0600 Subject: [PATCH 4/9] modificaciones de visualizacion en vista previa --- .../detail/encuesta-detail.component.html | 98 ++++++++++++++++--- .../detail/encuesta-detail.component.ts | 3 +- .../update/encuesta-update.component.html | 17 ++-- .../update/encuesta-update.component.ts | 13 ++- .../paper-dashboard/_datasurvey-survey.scss | 38 +++++++ src/main/webapp/i18n/es/encuesta.json | 14 +-- 6 files changed, 155 insertions(+), 28 deletions(-) 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 8222598..680ab06 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 @@ -79,7 +79,7 @@
    --> -
    +

    Vista previa de {{ encuesta!.nombre }}

    @@ -141,14 +141,21 @@ class="ds-survey--option ds-survey--option--base ds-survey--closed-option can-delete checkbox" [attr.data-id]="ePreguntaOpcionFinal.id" > - - - +
    + + + +
    +
    + + + +

    @@ -160,10 +167,77 @@
    -
    -

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

    +
    +

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

    + +
    +
    Acceso
    +
    + - + {{ encuesta.acceso }} +
    +
    +
    +
    Contrasenna
    +
    + - {{ encuesta.contrasenna }} +
    +
    +
    +
    Estado
    +
    + - {{ encuesta.estado }} +
    +
    +
    +
    Categoria
    +
    + - {{ encuesta.categoria?.nombre }} +
    +
    +
    +
    Fecha Publicacion
    +
    + - + {{ + encuesta.fechaPublicacion === undefined ? 'Sin publicar' : (encuesta.fechaFinalizada | formatShortDatetime | lowercase) + }} +
    +
    +
    +
    Fecha Finalizar
    +
    + + - + {{ + encuesta.fechaFinalizar === undefined + ? 'Sin fecha de finalización' + : (encuesta.fechaFinalizada | formatShortDatetime | lowercase) + }} +
    +
    +
    +
    Fecha Finalizada
    +
    + + - + {{ + encuesta.fechaFinalizada === undefined ? 'Sin finalizar' : (encuesta.fechaFinalizada | formatShortDatetime | lowercase) + }} +
    +
    -

    Colaboradores

    +
    Calificacion
    +
    + +
    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 f3b8cc9..7696f76 100644 --- a/src/main/webapp/app/entities/encuesta/detail/encuesta-detail.component.ts +++ b/src/main/webapp/app/entities/encuesta/detail/encuesta-detail.component.ts @@ -28,7 +28,7 @@ import { EPreguntaAbiertaService } from '../../e-pregunta-abierta/service/e-preg 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 { faTimes, faPlus, faStar } from '@fortawesome/free-solid-svg-icons'; import { EncuestaPublishDialogComponent } from '../encuesta-publish-dialog/encuesta-publish-dialog.component'; @Component({ @@ -40,6 +40,7 @@ export class EncuestaDetailComponent implements OnInit { usuarioExtrasSharedCollection: IUsuarioExtra[] = []; faTimes = faTimes; faPlus = faPlus; + faStar = faStar; encuesta: IEncuesta | null = null; isLoading = false; successPublished = false; 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 8565e93..cabb0c1 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 @@ -5,11 +5,12 @@
    + + @@ -79,7 +83,8 @@ [attr.data-id]="ePreguntaOpcionFinal.id" > - + + {{ ePreguntaCerrada.nombre }} {{ ePreguntaCerrada.tipo }} - + {{ ePreguntaCerrada.opcional }} {{ ePreguntaCerrada.orden }} @@ -264,7 +269,7 @@ [formGroup]="editFormQuestion" >