Merge branch 'dev' into feature/US-35
This commit is contained in:
		
						commit
						09d86ebaef
					
				| 
						 | 
				
			
			@ -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<Plantilla> plantillas = new HashSet<>();
 | 
			
		||||
 | 
			
		||||
    // jhipster-needle-entity-add-field - JHipster will add fields here
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -80,6 +80,14 @@ public class EPreguntaCerradaOpcionResource {
 | 
			
		|||
            .body(result);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @PostMapping("/e-pregunta-cerrada-opcions/count/{id}")
 | 
			
		||||
    public ResponseEntity<EPreguntaCerradaOpcion> 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.
 | 
			
		||||
     *
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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';
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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<EntityResponseType> {
 | 
			
		||||
    return this.http.post<IEPreguntaCerradaOpcion>(`${this.resourceUrl}/${preguntaId}`, ePreguntaCerradaOpcion, { observe: 'response' });
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,175 @@
 | 
			
		|||
<div class="container-fluid" *ngIf="encuesta">
 | 
			
		||||
  <div>
 | 
			
		||||
    <h2 id="page-heading" data-cy="EPreguntaCerradaHeading">
 | 
			
		||||
      <div class="d-flex align-items-center">
 | 
			
		||||
        <p class="ds-title">Vista previa de {{ encuesta!.nombre }}</p>
 | 
			
		||||
          <fa-icon class="ds-info--icon" [icon]="faQuestion" data-toggle="modal" data-target="#verParametros"></fa-icon>
 | 
			
		||||
      </div>
 | 
			
		||||
 | 
			
		||||
      <p class="ds-subtitle">Creada el día {{ encuesta!.fechaCreacion | formatShortDatetime | lowercase }}</p>
 | 
			
		||||
      <div class="d-flex justify-content-end">
 | 
			
		||||
        <button type="button" class="ds-btn ds-btn--secondary" (click)="previousState()">
 | 
			
		||||
          <fa-icon icon="arrow-left"></fa-icon>  <span jhiTranslate="entity.action.back">Back</span>
 | 
			
		||||
        </button>
 | 
			
		||||
      </div>
 | 
			
		||||
    </h2>
 | 
			
		||||
 | 
			
		||||
    <jhi-alert-error></jhi-alert-error>
 | 
			
		||||
 | 
			
		||||
    <div class="alert alert-warning" id="no-result" *ngIf="ePreguntas?.length === 0">
 | 
			
		||||
      <span>No se encontraron preguntas</span>
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
    <div class="ds-survey preview-survey" id="entities" *ngIf="ePreguntas && ePreguntas.length > 0">
 | 
			
		||||
      <div class="ds-survey--all-question-wrapper col-8">
 | 
			
		||||
        <div class="ds-survey--question-wrapper card-encuesta lift" *ngFor="let ePregunta of ePreguntas; let i = index; trackBy: trackId">
 | 
			
		||||
          <div
 | 
			
		||||
            [attr.data-index]="ePregunta.id"
 | 
			
		||||
            [attr.data-tipo]="ePregunta.tipo"
 | 
			
		||||
            [attr.data-opcional]="ePregunta.opcional"
 | 
			
		||||
            class="ds-survey--question"
 | 
			
		||||
          >
 | 
			
		||||
            <div class="ds-survey--titulo">
 | 
			
		||||
              <span class="ds-survey--titulo--name">{{ i + 1 }}. {{ ePregunta.nombre }}</span>
 | 
			
		||||
            </div>
 | 
			
		||||
            <div>
 | 
			
		||||
              <span *ngIf="ePregunta.tipo === 'SINGLE'" class="ds-subtitle"
 | 
			
		||||
                >Pregunta de respuesta {{ 'dataSurveyApp.PreguntaCerradaTipo.SINGLE' | translate | lowercase }}
 | 
			
		||||
                {{ ePregunta.opcional ? '(opcional)' : '' }}</span
 | 
			
		||||
              >
 | 
			
		||||
              <span *ngIf="ePregunta.tipo === 'MULTIPLE'" class="ds-subtitle"
 | 
			
		||||
                >Pregunta de respuesta {{ 'dataSurveyApp.PreguntaCerradaTipo.MULTIPLE' | translate | lowercase }}
 | 
			
		||||
                {{ ePregunta.opcional ? '(opcional)' : '' }}</span
 | 
			
		||||
              >
 | 
			
		||||
              <span *ngIf="!ePregunta.tipo" class="ds-subtitle"
 | 
			
		||||
                >Pregunta de respuesta abierta {{ ePregunta.opcional ? '(opcional)' : '' }}</span
 | 
			
		||||
              >
 | 
			
		||||
            </div>
 | 
			
		||||
            <ng-container *ngIf="ePregunta.tipo">
 | 
			
		||||
              <ng-container *ngFor="let ePreguntaOpcion of ePreguntasOpciones; let j = index; trackBy: trackId">
 | 
			
		||||
                <ng-container *ngFor="let ePreguntaOpcionFinal of ePreguntaOpcion">
 | 
			
		||||
                  <ng-container *ngIf="ePregunta.id === ePreguntaOpcionFinal.epreguntaCerrada.id">
 | 
			
		||||
                    <div
 | 
			
		||||
                      class="ds-survey--option ds-survey--option--base ds-survey--closed-option can-delete"
 | 
			
		||||
                      [attr.data-id]="ePreguntaOpcionFinal.id"
 | 
			
		||||
                    >
 | 
			
		||||
                      <div class="radio" *ngIf="ePregunta.tipo === 'SINGLE'">
 | 
			
		||||
                        <input
 | 
			
		||||
                          type="radio"
 | 
			
		||||
                          (change)="onCheck(ePreguntaOpcionFinal)"
 | 
			
		||||
                          [value]="ePreguntaOpcionFinal.id"
 | 
			
		||||
                          style="border-radius: 3px"
 | 
			
		||||
                          name="{{ 'radio' + ePregunta.id }}"
 | 
			
		||||
                          id="{{ 'radio' + ePreguntaOpcionFinal.id }}"
 | 
			
		||||
                        />
 | 
			
		||||
                        <label for="{{ 'radio' + ePreguntaOpcionFinal.id }}">{{ ePreguntaOpcionFinal.nombre }}</label>
 | 
			
		||||
                      </div>
 | 
			
		||||
                      <div class="checkbox" *ngIf="ePregunta.tipo === 'MULTIPLE'">
 | 
			
		||||
                        <input
 | 
			
		||||
                          (change)="toggleOption(ePreguntaOpcionFinal)"
 | 
			
		||||
                          type="checkbox"
 | 
			
		||||
                          style="border-radius: 3px"
 | 
			
		||||
                          id="{{ 'checkbox' + ePreguntaOpcionFinal.id }}"
 | 
			
		||||
                        />
 | 
			
		||||
                        <label for="{{ 'checkbox' + ePreguntaOpcionFinal.id }}">{{ ePreguntaOpcionFinal.nombre }}</label>
 | 
			
		||||
                      </div>
 | 
			
		||||
                    </div>
 | 
			
		||||
                  </ng-container>
 | 
			
		||||
                </ng-container>
 | 
			
		||||
              </ng-container>
 | 
			
		||||
            </ng-container>
 | 
			
		||||
            <div class="ds-survey--option ds-survey--option--base ds-survey--open-option" *ngIf="!ePregunta.tipo">
 | 
			
		||||
              <textarea id="{{ ePregunta.id }}" cols="33" rows="10"></textarea>
 | 
			
		||||
            </div>
 | 
			
		||||
          </div>
 | 
			
		||||
        </div>
 | 
			
		||||
        <button class="ds-btn ds-btn--primary" (click)="finish()">Terminar</button>
 | 
			
		||||
      </div>
 | 
			
		||||
      <div
 | 
			
		||||
        class="modal fade ds-modal"
 | 
			
		||||
        id="verParametros"
 | 
			
		||||
        tabindex="-1"
 | 
			
		||||
        role="dialog"
 | 
			
		||||
        aria-labelledby="exampleModalCenterTitle"
 | 
			
		||||
        aria-hidden="true"
 | 
			
		||||
      >
 | 
			
		||||
        <div class="modal-dialog modal-dialog-centered" role="document">
 | 
			
		||||
          <div class="modal-content">
 | 
			
		||||
            <div class="modal-header">
 | 
			
		||||
              <h1 class="modal-title" id="exampleModalLongTitle">Información de encuesta</h1>
 | 
			
		||||
            </div>
 | 
			
		||||
 | 
			
		||||
            <div class="modal-body">
 | 
			
		||||
              <div>
 | 
			
		||||
                <div class="mb-5">
 | 
			
		||||
                  <p style="font-size: 1.2em" class="ds-subtitle">Cantidad de preguntas</p>
 | 
			
		||||
                  <p>{{ ePreguntas?.length }}</p>
 | 
			
		||||
                </div>
 | 
			
		||||
 | 
			
		||||
                <div class="mb-5">
 | 
			
		||||
                  <p class="ds-subtitle" jhiTranslate="dataSurveyApp.encuesta.acceso">Acceso</p>
 | 
			
		||||
                  <p jhiTranslate="{{ 'dataSurveyApp.AccesoEncuesta.' + encuesta.acceso }}">{{ encuesta.acceso }}</p>
 | 
			
		||||
                </div>
 | 
			
		||||
 | 
			
		||||
                <div *ngIf="encuesta.acceso === 'PRIVATE'" class="mb-5">
 | 
			
		||||
                  <p class="ds-subtitle">Contraseña</p>
 | 
			
		||||
                  <p>{{ encuesta.contrasenna }}</p>
 | 
			
		||||
                </div>
 | 
			
		||||
 | 
			
		||||
                <div class="mb-5">
 | 
			
		||||
                  <p class="ds-subtitle">Estado:</p>
 | 
			
		||||
                  <p jhiTranslate="{{ 'dataSurveyApp.EstadoEncuesta.' + encuesta.estado }}">{{ encuesta.estado }}</p>
 | 
			
		||||
                </div>
 | 
			
		||||
 | 
			
		||||
                <div *ngIf="encuesta.categoria" class="mb-5">
 | 
			
		||||
                  <p class="ds-subtitle">Categoría</p>
 | 
			
		||||
                  <P> </P> {{ encuesta.categoria?.nombre }}
 | 
			
		||||
                </div>
 | 
			
		||||
 | 
			
		||||
                <div class="mb-5">
 | 
			
		||||
                  <p class="ds-subtitle">Fecha de publicación</p>
 | 
			
		||||
                  <P
 | 
			
		||||
                    >{{
 | 
			
		||||
                      encuesta.fechaPublicacion === undefined
 | 
			
		||||
                        ? 'Sin publicar'
 | 
			
		||||
                        : (encuesta.fechaPublicacion | formatShortDatetime | lowercase)
 | 
			
		||||
                    }}
 | 
			
		||||
                  </P>
 | 
			
		||||
                </div>
 | 
			
		||||
 | 
			
		||||
                <div class="mb-5">
 | 
			
		||||
                  <p class="ds-subtitle">Fecha de finalización</p>
 | 
			
		||||
                  <P>
 | 
			
		||||
                    {{
 | 
			
		||||
                      encuesta.fechaFinalizada === undefined
 | 
			
		||||
                        ? 'Sin finalizar'
 | 
			
		||||
                        : (encuesta.fechaFinalizada | formatShortDatetime | lowercase)
 | 
			
		||||
                    }}
 | 
			
		||||
                  </P>
 | 
			
		||||
                </div>
 | 
			
		||||
 | 
			
		||||
                <div class="mb-5">
 | 
			
		||||
                  <p class="ds-subtitle">Calificación</p>
 | 
			
		||||
                  <div>
 | 
			
		||||
                    <fa-icon *ngFor="let i of [].constructor(encuesta.calificacion)" class="entity-icon--star" [icon]="faStar"></fa-icon
 | 
			
		||||
                    ><fa-icon
 | 
			
		||||
                      *ngFor="let i of [].constructor(5 - encuesta.calificacion!)"
 | 
			
		||||
                      class="entity-icon--star--off"
 | 
			
		||||
                      [icon]="faStar"
 | 
			
		||||
                    ></fa-icon>
 | 
			
		||||
                  </div>
 | 
			
		||||
                </div>
 | 
			
		||||
              </div>
 | 
			
		||||
            </div>
 | 
			
		||||
 | 
			
		||||
            <div class="modal-footer">
 | 
			
		||||
              <button id="cancelBtnVerParametros" type="button" class="ds-btn ds-btn--secondary" data-dismiss="modal">
 | 
			
		||||
                <fa-icon icon="arrow-left"></fa-icon>  <span>Volver</span>
 | 
			
		||||
              </button>
 | 
			
		||||
            </div>
 | 
			
		||||
          </div>
 | 
			
		||||
        </div>
 | 
			
		||||
      </div>
 | 
			
		||||
    </div>
 | 
			
		||||
  </div>
 | 
			
		||||
</div>
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,24 @@
 | 
			
		|||
import { ComponentFixture, TestBed } from '@angular/core/testing';
 | 
			
		||||
 | 
			
		||||
import { EncuestaCompleteComponent } from './complete.component';
 | 
			
		||||
 | 
			
		||||
describe('EncuestaCompleteComponent', () => {
 | 
			
		||||
  let component: EncuestaCompleteComponent;
 | 
			
		||||
  let fixture: ComponentFixture<EncuestaCompleteComponent>;
 | 
			
		||||
 | 
			
		||||
  beforeEach(async () => {
 | 
			
		||||
    await TestBed.configureTestingModule({
 | 
			
		||||
      declarations: [EncuestaCompleteComponent],
 | 
			
		||||
    }).compileComponents();
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  beforeEach(() => {
 | 
			
		||||
    fixture = TestBed.createComponent(EncuestaCompleteComponent);
 | 
			
		||||
    component = fixture.componentInstance;
 | 
			
		||||
    fixture.detectChanges();
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('should create', () => {
 | 
			
		||||
    expect(component).toBeTruthy();
 | 
			
		||||
  });
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			@ -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<HttpResponse<any>>): 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;
 | 
			
		||||
      }
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,28 @@
 | 
			
		|||
<form class="ds-form" [formGroup]="passwordForm" name="deleteForm" (ngSubmit)="submitPassword()">
 | 
			
		||||
  <div *ngIf="this.isWrong">
 | 
			
		||||
    <p>Contraseña incorrecta</p>
 | 
			
		||||
  </div>
 | 
			
		||||
  <div class="modal-body">
 | 
			
		||||
    <p class="ds-title--small" jhiTranslate="dataSurveyApp.encuesta.password.title">Enter password</p>
 | 
			
		||||
    <p class="ds-subtitle" id="jhi-delete-encuesta-heading" jhiTranslate="dataSurveyApp.encuesta.password.text">
 | 
			
		||||
      This survey is marked as private, please enter the password
 | 
			
		||||
    </p>
 | 
			
		||||
    <input [(ngModel)]="passwordInput" type="password" name="passwordInput" id="passwordInput" placeholder="qwerty..." />
 | 
			
		||||
  </div>
 | 
			
		||||
 | 
			
		||||
  <div class="modal-footer">
 | 
			
		||||
    <button type="button" class="ds-btn ds-btn--secondary" data-dismiss="modal" (click)="cancel()">
 | 
			
		||||
      <fa-icon icon="arrow-left"></fa-icon> <span jhiTranslate="entity.action.cancel">Cancel</span>
 | 
			
		||||
    </button>
 | 
			
		||||
 | 
			
		||||
    <button
 | 
			
		||||
      id="jhi-confirm-delete-option"
 | 
			
		||||
      data-cy="submit"
 | 
			
		||||
      type="submit"
 | 
			
		||||
      class="ds-btn ds-btn--primary"
 | 
			
		||||
      [disabled]="passwordForm.get('password')!.invalid"
 | 
			
		||||
    >
 | 
			
		||||
      <span jhiTranslate="entity.action.submit">Submit</span>
 | 
			
		||||
    </button>
 | 
			
		||||
  </div>
 | 
			
		||||
</form>
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,4 @@
 | 
			
		|||
input {
 | 
			
		||||
  margin: 2%;
 | 
			
		||||
  width: 100%;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -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<EncuestaPasswordDialogComponent>;
 | 
			
		||||
 | 
			
		||||
  beforeEach(async () => {
 | 
			
		||||
    await TestBed.configureTestingModule({
 | 
			
		||||
      declarations: [EncuestaPasswordDialogComponent],
 | 
			
		||||
    }).compileComponents();
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  beforeEach(() => {
 | 
			
		||||
    fixture = TestBed.createComponent(EncuestaPasswordDialogComponent);
 | 
			
		||||
    component = fixture.componentInstance;
 | 
			
		||||
    fixture.detectChanges();
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('should create', () => {
 | 
			
		||||
    expect(component).toBeTruthy();
 | 
			
		||||
  });
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			@ -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');
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -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,
 | 
			
		||||
  ],
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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({
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -77,6 +77,11 @@ import { RouterModule } from '@angular/router';
 | 
			
		|||
        loadChildren: () =>
 | 
			
		||||
          import('./p-pregunta-cerrada-opcion/p-pregunta-cerrada-opcion.module').then(m => m.PPreguntaCerradaOpcionModule),
 | 
			
		||||
      },
 | 
			
		||||
      {
 | 
			
		||||
        path: 'mis-plantillas',
 | 
			
		||||
        data: { pageTitle: 'dataSurveyApp.usuarioExtra.plantillas.title' },
 | 
			
		||||
        loadChildren: () => import('./usuario-plantillas/usuario-plantillas.module').then(m => m.UsuarioPlantillasModule),
 | 
			
		||||
      },
 | 
			
		||||
      /* jhipster-needle-add-entity-route - JHipster will add entity modules routes here */
 | 
			
		||||
    ]),
 | 
			
		||||
  ],
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,5 @@
 | 
			
		|||
jest.mock('@ng-bootstrap/ng-bootstrap');
 | 
			
		||||
 | 
			
		||||
import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing';
 | 
			
		||||
import { Plantilla } from '../plantilla.model';
 | 
			
		||||
import { ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angular/core/testing';
 | 
			
		||||
import { HttpResponse } from '@angular/common/http';
 | 
			
		||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
 | 
			
		||||
import { of } from 'rxjs';
 | 
			
		||||
| 
						 | 
				
			
			@ -9,6 +8,9 @@ import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
 | 
			
		|||
import { PlantillaService } from '../service/plantilla.service';
 | 
			
		||||
 | 
			
		||||
import { PlantillaDeleteDialogComponent } from './plantilla-delete-dialog.component';
 | 
			
		||||
import { EstadoPlantilla } from '../../enumerations/estado-plantilla.model';
 | 
			
		||||
 | 
			
		||||
jest.mock('@ng-bootstrap/ng-bootstrap');
 | 
			
		||||
 | 
			
		||||
describe('Component Tests', () => {
 | 
			
		||||
  describe('Plantilla Management Delete Component', () => {
 | 
			
		||||
| 
						 | 
				
			
			@ -37,9 +39,12 @@ describe('Component Tests', () => {
 | 
			
		|||
        fakeAsync(() => {
 | 
			
		||||
          // GIVEN
 | 
			
		||||
          jest.spyOn(service, 'delete').mockReturnValue(of(new HttpResponse({})));
 | 
			
		||||
          const pPlantilla = new Plantilla();
 | 
			
		||||
 | 
			
		||||
          pPlantilla.id = 123;
 | 
			
		||||
          pPlantilla.estado = EstadoPlantilla.DELETED;
 | 
			
		||||
          // WHEN
 | 
			
		||||
          comp.confirmDelete(123);
 | 
			
		||||
          comp.confirmDelete(pPlantilla);
 | 
			
		||||
          tick();
 | 
			
		||||
 | 
			
		||||
          // THEN
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,57 @@
 | 
			
		|||
<div *ngIf="usuarioExtra">
 | 
			
		||||
  <h2 id="page-heading" data-cy="UsuarioEncuestaHeading">
 | 
			
		||||
    <span class="ds-title" jhiTranslate="dataSurveyApp.usuarioExtra.plantillas.title">Mis Plantillas </span>
 | 
			
		||||
    <p class="ds-subtitle">Hola</p>
 | 
			
		||||
 | 
			
		||||
    <div class="d-flex justify-content-end">
 | 
			
		||||
      <button class="ds-btn ds-btn--secondary mr-2" (click)="loadAll()" [disabled]="isLoading">
 | 
			
		||||
        <fa-icon icon="sync" [spin]="isLoading"></fa-icon>
 | 
			
		||||
        <span jhiTranslate="dataSurveyApp.usuarioExtra.home.refreshListLabel">Refresh List</span>
 | 
			
		||||
      </button>
 | 
			
		||||
    </div>
 | 
			
		||||
  </h2>
 | 
			
		||||
  <jhi-alert-error></jhi-alert-error>
 | 
			
		||||
 | 
			
		||||
  <jhi-alert></jhi-alert>
 | 
			
		||||
 | 
			
		||||
  <div class="alert alert-warning" id="no-result" *ngIf="misPlantillas?.length === 0">
 | 
			
		||||
    <span jhiTranslate="dataSurveyApp.usuarioExtra.plantillas.notFound">No usuarioEncuestas found</span>
 | 
			
		||||
  </div>
 | 
			
		||||
 | 
			
		||||
  <div class="table-responsive" id="entities" *ngIf="misPlantillas && misPlantillas.length > 0">
 | 
			
		||||
    <table class="table table-striped" aria-describedby="page-heading">
 | 
			
		||||
      <thead>
 | 
			
		||||
        <tr>
 | 
			
		||||
          <th scope="col"><span jhiTranslate="dataSurveyApp.plantilla.nombre">Nombre</span></th>
 | 
			
		||||
          <th scope="col"><span jhiTranslate="dataSurveyApp.plantilla.descripcion">Descripcion</span></th>
 | 
			
		||||
          <th scope="col"><span jhiTranslate="dataSurveyApp.plantilla.categoria">Categoria</span></th>
 | 
			
		||||
          <th scope="col"></th>
 | 
			
		||||
        </tr>
 | 
			
		||||
      </thead>
 | 
			
		||||
      <tbody>
 | 
			
		||||
        <tr *ngFor="let miPlantilla of misPlantillas; trackBy: trackId" data-cy="entityTable">
 | 
			
		||||
          <td>{{ miPlantilla.nombre }}</td>
 | 
			
		||||
          <td>{{ miPlantilla.descripcion }}</td>
 | 
			
		||||
          <td>{{ miPlantilla.categoria?.nombre }}</td>
 | 
			
		||||
          <td class="text-right">
 | 
			
		||||
            <div class="btn-group">
 | 
			
		||||
              <button
 | 
			
		||||
                type="submit"
 | 
			
		||||
                [routerLink]="['/plantilla', miPlantilla.id, 'preview']"
 | 
			
		||||
                class="ds-btn ds-btn--secondary btn-sm"
 | 
			
		||||
                data-cy="entityDetailsButton"
 | 
			
		||||
              >
 | 
			
		||||
                <fa-icon icon="eye"></fa-icon>
 | 
			
		||||
                <span class="d-none d-md-inline">Vista previa</span>
 | 
			
		||||
              </button>
 | 
			
		||||
 | 
			
		||||
              <button type="submit" class="ds-btn ds-btn--primary btn-sm" data-cy="entityCreateButton">
 | 
			
		||||
                <span class="d-none d-md-inline" jhiTranslate="dataSurveyApp.usuarioExtra.plantillas.crearEncuesta">Crear Encuesta</span>
 | 
			
		||||
              </button>
 | 
			
		||||
            </div>
 | 
			
		||||
          </td>
 | 
			
		||||
        </tr>
 | 
			
		||||
      </tbody>
 | 
			
		||||
    </table>
 | 
			
		||||
  </div>
 | 
			
		||||
</div>
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,68 @@
 | 
			
		|||
import { Component, OnInit } from '@angular/core';
 | 
			
		||||
import { IUsuarioExtra, UsuarioExtra } from '../../usuario-extra/usuario-extra.model';
 | 
			
		||||
import { IPlantilla } from '../../plantilla/plantilla.model';
 | 
			
		||||
import { HttpResponse } from '@angular/common/http';
 | 
			
		||||
 | 
			
		||||
import { PlantillaService } from '../../plantilla/service/plantilla.service';
 | 
			
		||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
 | 
			
		||||
import { CategoriaService } from '../../categoria/service/categoria.service';
 | 
			
		||||
import { UsuarioExtraService } from '../../usuario-extra/service/usuario-extra.service';
 | 
			
		||||
import { ActivatedRoute, Router } from '@angular/router';
 | 
			
		||||
import { FormBuilder } from '@angular/forms';
 | 
			
		||||
import { AccountService } from '../../../core/auth/account.service';
 | 
			
		||||
import * as dayjs from 'dayjs';
 | 
			
		||||
import { Account } from '../../../core/auth/account.model';
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
  selector: 'jhi-usuario-plantillas',
 | 
			
		||||
  templateUrl: './usuario-plantillas.component.html',
 | 
			
		||||
  styleUrls: ['./usuario-plantillas.component.scss'],
 | 
			
		||||
})
 | 
			
		||||
export class UsuarioPlantillasComponent implements OnInit {
 | 
			
		||||
  misPlantillas?: IPlantilla[] | null | undefined;
 | 
			
		||||
  isLoading = false;
 | 
			
		||||
  usuarioExtra: UsuarioExtra | null = null;
 | 
			
		||||
  account: Account | null = null;
 | 
			
		||||
 | 
			
		||||
  constructor(
 | 
			
		||||
    protected plantillaService: PlantillaService,
 | 
			
		||||
    protected modalService: NgbModal,
 | 
			
		||||
    protected categoriaService: CategoriaService,
 | 
			
		||||
    protected usuarioExtraService: UsuarioExtraService,
 | 
			
		||||
    protected activatedRoute: ActivatedRoute,
 | 
			
		||||
    protected fb: FormBuilder,
 | 
			
		||||
    protected accountService: AccountService,
 | 
			
		||||
    protected router: Router
 | 
			
		||||
  ) {}
 | 
			
		||||
 | 
			
		||||
  ngOnInit(): void {
 | 
			
		||||
    this.accountService.getAuthenticationState().subscribe(account => {
 | 
			
		||||
      if (account !== null) {
 | 
			
		||||
        this.account = account;
 | 
			
		||||
        this.loadAll();
 | 
			
		||||
      }
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  loadAll() {
 | 
			
		||||
    this.isLoading = true;
 | 
			
		||||
    // Get jhi_user and usuario_extra information
 | 
			
		||||
    if (this.account !== null) {
 | 
			
		||||
      this.usuarioExtraService.find(this.account.id).subscribe(usuarioExtra => {
 | 
			
		||||
        this.usuarioExtra = usuarioExtra.body;
 | 
			
		||||
        this.misPlantillas = usuarioExtra.body?.plantillas;
 | 
			
		||||
        this.isLoading = false;
 | 
			
		||||
        if (this.usuarioExtra !== null) {
 | 
			
		||||
          if (this.usuarioExtra.id === undefined) {
 | 
			
		||||
            const today = dayjs().startOf('day');
 | 
			
		||||
            this.usuarioExtra.fechaNacimiento = today;
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      });
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  trackId(index: number, item: IPlantilla): number {
 | 
			
		||||
    return item.id!;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -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',
 | 
			
		||||
  },
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			@ -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 {}
 | 
			
		||||
| 
						 | 
				
			
			@ -70,12 +70,12 @@ export const USER_ROUTES: RouteInfo[] = [
 | 
			
		|||
  //   type: 'link',
 | 
			
		||||
  //   icontype: 'nc-icon nc-cart-simple',
 | 
			
		||||
  // },
 | 
			
		||||
  // {
 | 
			
		||||
  //   path: '/plantilla',
 | 
			
		||||
  //   title: 'Plantillas',
 | 
			
		||||
  //   type: 'link',
 | 
			
		||||
  //   icontype: 'nc-icon nc-album-2',
 | 
			
		||||
  // },
 | 
			
		||||
  {
 | 
			
		||||
    path: '/mis-plantillas',
 | 
			
		||||
    title: 'Mis Plantillas',
 | 
			
		||||
    type: 'link',
 | 
			
		||||
    icontype: 'nc-icon nc-album-2',
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    path: '/colaboraciones',
 | 
			
		||||
    title: 'Colaboraciones',
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -106,7 +106,9 @@
 | 
			
		|||
                      ></fa-icon>
 | 
			
		||||
                    </div>
 | 
			
		||||
                    <div class="entity-body--row m-2">
 | 
			
		||||
                      <button class="ds-btn btn-card"><fa-icon [icon]="faPollH"></fa-icon>  Completar encuesta</button>
 | 
			
		||||
                      <button (click)="completeEncuesta(encuesta)" class="ds-btn btn-card">
 | 
			
		||||
                        <fa-icon [icon]="faPollH"></fa-icon>  Completar encuesta
 | 
			
		||||
                      </button>
 | 
			
		||||
                    </div>
 | 
			
		||||
                  </div>
 | 
			
		||||
                </div>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
      }
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -34,7 +34,11 @@
 | 
			
		|||
      "ePreguntaAbierta": "Pregunta Abierta",
 | 
			
		||||
      "ePreguntaCerrada": "Pregunta Cerrada",
 | 
			
		||||
      "categoria": "Categoría",
 | 
			
		||||
      "usuarioExtra": "Correo Usuario"
 | 
			
		||||
      "usuarioExtra": "Correo Usuario",
 | 
			
		||||
      "password": {
 | 
			
		||||
        "title": "Contraseña Requerida",
 | 
			
		||||
        "text": "Esta encuesta es privada, por lo que debe ingresar la contraseña"
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -130,7 +130,8 @@
 | 
			
		|||
      "enable": "Habilitar",
 | 
			
		||||
      "disable": "Deshabilitar",
 | 
			
		||||
      "toggleStatus": "Cambiar Estado",
 | 
			
		||||
      "publish": "Publicar"
 | 
			
		||||
      "publish": "Publicar",
 | 
			
		||||
      "submit": "Ingresar"
 | 
			
		||||
    },
 | 
			
		||||
    "detail": {
 | 
			
		||||
      "field": "Campo",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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"
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue