Merge pull request #135 from Quantum-P3/feature/US-47
fix respuesta abierta
This commit is contained in:
		
						commit
						c1b8d1ed11
					
				| 
						 | 
				
			
			@ -1,7 +1,7 @@
 | 
			
		|||
<div class="content">
 | 
			
		||||
  <div class="py-2">
 | 
			
		||||
    <!--<button type="button" class="ds-btn ds-btn--primary" (click)="exportReportesGeneralesUserExcel()">Exportar como Excel</button>
 | 
			
		||||
    <button type="button" class="ds-btn ds-btn--primary" (click)="exportReportesGeneralesUserPDF()">Exportar como PDF</button>-->
 | 
			
		||||
    <button type="button" class="ds-btn ds-btn--primary" (click)="exportReportesGeneralesUserExcel()">Exportar como Excel</button>
 | 
			
		||||
    <button type="button" class="ds-btn ds-btn--primary" (click)="exportReportesGeneralesUserPDF()">Exportar como PDF</button>
 | 
			
		||||
    <button
 | 
			
		||||
      type="button"
 | 
			
		||||
      [hidden]="!reportsGeneral || (reportForEncuestas && reportColaboraciones)"
 | 
			
		||||
| 
						 | 
				
			
			@ -169,22 +169,22 @@
 | 
			
		|||
              </div>
 | 
			
		||||
              <div class="text-xs text-gray-500">
 | 
			
		||||
                <div class="entity-body">
 | 
			
		||||
                  <div class="entity-body--row m-2">
 | 
			
		||||
                    <span class="mt-2" *ngIf="duracion! > 0"
 | 
			
		||||
                      ><fa-icon class="entity-icon--access" [icon]="faCalendarAlt"></fa-icon> Duración:     {{
 | 
			
		||||
                        duracion
 | 
			
		||||
                  <!--<div class="entity-body--row m-2" *ngFor="let d of duracionArray">
 | 
			
		||||
                    <span class="mt-2" *ngIf="d! > 0"
 | 
			
		||||
                      ><fa-icon class="entity-icon--access" [icon]="faCalendarAlt"></fa-icon> Duración:     {{
 | 
			
		||||
                        d
 | 
			
		||||
                      }}</span
 | 
			
		||||
                    >
 | 
			
		||||
                    <span class="mt-2" *ngIf="duracion! == 0"
 | 
			
		||||
                      ><fa-icon class="entity-icon--access" [icon]="faCalendarAlt"></fa-icon> Duración:     Un día o
 | 
			
		||||
                    <span class="mt-2" *ngIf="d! == 0"
 | 
			
		||||
                      ><fa-icon class="entity-icon--access" [icon]="faCalendarAlt"></fa-icon> Duración:     Un día o
 | 
			
		||||
                      menos</span
 | 
			
		||||
                    >
 | 
			
		||||
 | 
			
		||||
                    <span class="mt-2" *ngIf="duracion! == -1"
 | 
			
		||||
                      ><fa-icon class="entity-icon--access" [icon]="faCalendarAlt"></fa-icon> Duración:     No ha
 | 
			
		||||
                    <span class="mt-2" *ngIf="d! == -1"
 | 
			
		||||
                      ><fa-icon class="entity-icon--access" [icon]="faCalendarAlt"></fa-icon> Duración:     No ha
 | 
			
		||||
                      finalizado</span
 | 
			
		||||
                    >
 | 
			
		||||
                  </div>
 | 
			
		||||
                  </div>-->
 | 
			
		||||
 | 
			
		||||
                  <div class="entity-body--row m-2">
 | 
			
		||||
                    <p>Calificación:</p>
 | 
			
		||||
| 
						 | 
				
			
			@ -287,7 +287,7 @@
 | 
			
		|||
                    </ul>-->
 | 
			
		||||
                    <!-- <textarea readonly class="ds-survey--textarea" cols="33" rows="10" *ngIf="res.epreguntaAbierta?.id == preguntaId" > {{ res.respuesta }} </textarea>-->
 | 
			
		||||
 | 
			
		||||
                    <div *ngIf="res.epreguntaAbierta?.id == preguntaId">
 | 
			
		||||
                    <div *ngIf="res.epreguntaAbierta?.id == ePregunta.id">
 | 
			
		||||
                      <label> {{ '- ' + res.respuesta }}</label> <br />
 | 
			
		||||
                    </div>
 | 
			
		||||
                  </div>
 | 
			
		||||
| 
						 | 
				
			
			@ -453,7 +453,7 @@
 | 
			
		|||
                    </ul>-->
 | 
			
		||||
                    <!-- <textarea readonly class="ds-survey--textarea" cols="33" rows="10" *ngIf="res.epreguntaAbierta?.id == preguntaId" > {{ res.respuesta }} </textarea>-->
 | 
			
		||||
 | 
			
		||||
                    <div *ngIf="res.epreguntaAbierta?.id == preguntaIdColaboracion">
 | 
			
		||||
                    <div *ngIf="res.epreguntaAbierta?.id == ePregunta.id">
 | 
			
		||||
                      <label> {{ '- ' + res.respuesta }}</label> <br />
 | 
			
		||||
                    </div>
 | 
			
		||||
                  </div>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,6 +15,9 @@ import { finalize } from 'rxjs/operators';
 | 
			
		|||
import { EPreguntaAbiertaRespuestaService } from '../../e-pregunta-abierta-respuesta/service/e-pregunta-abierta-respuesta.service';
 | 
			
		||||
import { IEPreguntaAbiertaRespuesta } from '../../e-pregunta-abierta-respuesta/e-pregunta-abierta-respuesta.model';
 | 
			
		||||
import { IUsuarioEncuesta } from '../../usuario-encuesta/usuario-encuesta.model';
 | 
			
		||||
import { exportAsExcelFile } from '../export/export_excel';
 | 
			
		||||
import { jsPDF } from 'jspdf';
 | 
			
		||||
import { createPDFTableHeaders, generatePDFTable, generatePDFTableData, saveGeneratedPDF } from '../export/export_pdf';
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
  selector: 'jhi-dashboard-user',
 | 
			
		||||
| 
						 | 
				
			
			@ -58,6 +61,7 @@ export class DashboardUserComponent implements OnInit {
 | 
			
		|||
  ePreguntasOpcionesColaboracion?: any[];
 | 
			
		||||
  respuestaAbiertaColaboracion?: IEPreguntaAbiertaRespuesta[];
 | 
			
		||||
  preguntaIdColaboracion?: number = 0;
 | 
			
		||||
  duracionArray?: number[] | null = null;
 | 
			
		||||
 | 
			
		||||
  constructor(
 | 
			
		||||
    protected encuestaService: EncuestaService,
 | 
			
		||||
| 
						 | 
				
			
			@ -126,21 +130,31 @@ export class DashboardUserComponent implements OnInit {
 | 
			
		|||
        this.cantPrivadas = tmpEncuestas.filter(
 | 
			
		||||
          e => e.acceso === 'PRIVATE' && e.usuarioExtra?.id === this.usuarioExtra?.id && e.estado !== 'DELETED'
 | 
			
		||||
        ).length;
 | 
			
		||||
        let cantidadCompletadas: number = 0;
 | 
			
		||||
        tmpEncuestas
 | 
			
		||||
          .filter(e => e.estado === 'ACTIVE')
 | 
			
		||||
          .forEach(e => {
 | 
			
		||||
            const _contadorCompletadas = e.calificacion;
 | 
			
		||||
            cantidadCompletadas = cantidadCompletadas + (Number(_contadorCompletadas?.toString().split('.')[1]) - 1);
 | 
			
		||||
          });
 | 
			
		||||
        this.cantPersonas = cantidadCompletadas;
 | 
			
		||||
 | 
			
		||||
        tmpEncuestas.forEach(encuesta => {
 | 
			
		||||
          const _calificacion = encuesta.calificacion;
 | 
			
		||||
          encuesta.calificacion = Number(_calificacion?.toString().split('.')[0]);
 | 
			
		||||
 | 
			
		||||
          if (encuesta.fechaFinalizada == null) {
 | 
			
		||||
          /* if (encuesta.fechaFinalizada == null) {
 | 
			
		||||
            this.duracion = -1;
 | 
			
		||||
            this.duracionArray?.push(this.duracion);
 | 
			
		||||
          } else {
 | 
			
		||||
            this.duracion = encuesta.fechaPublicacion?.diff(encuesta.fechaFinalizada!, 'days');
 | 
			
		||||
          }
 | 
			
		||||
            this.duracionArray?.push(this.duracion!);
 | 
			
		||||
          }*/
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        this.cantPersonas = tmpEncuestas.filter(
 | 
			
		||||
        /*this.cantPersonas = tmpEncuestas.filter(
 | 
			
		||||
          e => e.calificacion && e.usuarioExtra?.id === this.usuarioExtra?.id && e.estado !== 'DELETED'
 | 
			
		||||
        ).length;
 | 
			
		||||
        ).length;*/
 | 
			
		||||
        //cantidad de personas que han completado la encuesta
 | 
			
		||||
 | 
			
		||||
        this.loadFirstChart();
 | 
			
		||||
| 
						 | 
				
			
			@ -352,4 +366,98 @@ export class DashboardUserComponent implements OnInit {
 | 
			
		|||
      }
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  exportReportesGeneralesUserExcel(): void {
 | 
			
		||||
    /*REPORTES GENERALES:
 | 
			
		||||
     *Cantidad de encuestas creadas
 | 
			
		||||
     * cantidad de personas que han completado las encuestas
 | 
			
		||||
     *Cantidad de encuestas por estado
 | 
			
		||||
     * Cantidad de encuestas por acceso
 | 
			
		||||
     * */
 | 
			
		||||
 | 
			
		||||
    if (!this.reportsGeneral) {
 | 
			
		||||
      const _sheets = [
 | 
			
		||||
        'Cantidad encuestas creadas',
 | 
			
		||||
        'Cantidad usuarios encuestas',
 | 
			
		||||
        'Cantidad encuestas por estado',
 | 
			
		||||
        'Cantidad encuestas por acceso',
 | 
			
		||||
      ];
 | 
			
		||||
 | 
			
		||||
      const _reporteEncuestasCreadas = [{ total_encuestas: this.cantEncuestas }];
 | 
			
		||||
 | 
			
		||||
      const _reporteUsuariosCompletadas = [{ total_usuarios: this.cantPersonas }];
 | 
			
		||||
 | 
			
		||||
      const _reporteEncuestasEstado = [
 | 
			
		||||
        { total_borrador: this.cantPersonas, total_activas: this.cantActivas, total_finalizadas: this.cantFinalizadas },
 | 
			
		||||
      ];
 | 
			
		||||
 | 
			
		||||
      const _reporteEncuestasAcceso = [{ total_publicas: this.cantPublicas, total_privadas: this.cantPrivadas }];
 | 
			
		||||
 | 
			
		||||
      const _excelFinalData = [_reporteEncuestasCreadas, _reporteUsuariosCompletadas, _reporteEncuestasEstado, _reporteEncuestasAcceso];
 | 
			
		||||
      const _fileName = 'reportes_generales_encuestas_DataSurvey';
 | 
			
		||||
      exportAsExcelFile(_sheets, _excelFinalData, _fileName);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  exportReportesGeneralesUserPDF(): void {
 | 
			
		||||
    /*REPORTES GENERALES:
 | 
			
		||||
     *Cantidad de encuestas creadas
 | 
			
		||||
     * cantidad de personas que han completado las encuestas
 | 
			
		||||
     *Cantidad de encuestas por estado
 | 
			
		||||
     * Cantidad de encuestas por acceso
 | 
			
		||||
     * */
 | 
			
		||||
 | 
			
		||||
    if (!this.reportsGeneral) {
 | 
			
		||||
      const doc = new jsPDF();
 | 
			
		||||
      const _fileName = 'reportes_generales_encuestas_datasurvey';
 | 
			
		||||
      let _docData, _headers, _docHeaders, _docTitle;
 | 
			
		||||
 | 
			
		||||
      debugger;
 | 
			
		||||
      const _reporteEncuestasCreadas = [{ total_encuestas_creadas: this.cantEncuestas!.toString() }];
 | 
			
		||||
      debugger;
 | 
			
		||||
 | 
			
		||||
      _docData = generatePDFTableData(_reporteEncuestasCreadas);
 | 
			
		||||
      _headers = ['total_encuestas_creadas'];
 | 
			
		||||
      _docHeaders = createPDFTableHeaders(_headers);
 | 
			
		||||
      _docTitle = 'Reporte General Cantidad Encuestas Creadas';
 | 
			
		||||
 | 
			
		||||
      generatePDFTable(doc, _docData, _docHeaders, _docTitle);
 | 
			
		||||
      doc.addPage('p');
 | 
			
		||||
 | 
			
		||||
      const _reporteUsuariosCompletadas = [{ total_usuarios_completados: this.cantPersonas.toString() }];
 | 
			
		||||
      _docData = generatePDFTableData(_reporteUsuariosCompletadas);
 | 
			
		||||
      _headers = ['total_usuarios_completados'];
 | 
			
		||||
      _docHeaders = createPDFTableHeaders(_headers);
 | 
			
		||||
      _docTitle = 'Reporte General Cantidad Usuarios';
 | 
			
		||||
 | 
			
		||||
      generatePDFTable(doc, _docData, _docHeaders, _docTitle);
 | 
			
		||||
      doc.addPage('p');
 | 
			
		||||
 | 
			
		||||
      const _reporteEncuestasEstado = [
 | 
			
		||||
        {
 | 
			
		||||
          total_borrador: this.cantPersonas.toString(),
 | 
			
		||||
          total_activas: this.cantActivas.toString(),
 | 
			
		||||
          total_finalizadas: this.cantFinalizadas.toString(),
 | 
			
		||||
        },
 | 
			
		||||
      ];
 | 
			
		||||
      _docData = generatePDFTableData(_reporteEncuestasEstado);
 | 
			
		||||
      _headers = ['total_borrador', 'total_activas', 'total_finalizadas'];
 | 
			
		||||
      _docHeaders = createPDFTableHeaders(_headers);
 | 
			
		||||
      _docTitle = 'Reporte General Cantidad Encuestas Por Estado';
 | 
			
		||||
 | 
			
		||||
      generatePDFTable(doc, _docData, _docHeaders, _docTitle);
 | 
			
		||||
      doc.addPage('p');
 | 
			
		||||
 | 
			
		||||
      const _reporteEncuestasAcceso = [{ total_publicas: this.cantPublicas.toString(), total_privadas: this.cantPrivadas.toString() }];
 | 
			
		||||
      _docData = generatePDFTableData(_reporteEncuestasAcceso);
 | 
			
		||||
      _headers = ['total_publicas', 'total_privadas'];
 | 
			
		||||
      _docHeaders = createPDFTableHeaders(_headers);
 | 
			
		||||
      _docTitle = 'Reporte General Cantidad Encuestas Por Acceso';
 | 
			
		||||
 | 
			
		||||
      generatePDFTable(doc, _docData, _docHeaders, _docTitle);
 | 
			
		||||
      doc.addPage('p');
 | 
			
		||||
 | 
			
		||||
      saveGeneratedPDF(doc, _fileName);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -38,26 +38,25 @@
 | 
			
		|||
            </select>
 | 
			
		||||
          </div>-->
 | 
			
		||||
 | 
			
		||||
          <!--<div class="ds-filter">
 | 
			
		||||
 | 
			
		||||
          <!-- <div class="ds-filter">
 | 
			
		||||
            <div class="form-check pl-0 mb-3">
 | 
			
		||||
              <input type="radio" class="form-check-input" id="under25" name="materialExampleRadios" [value]="0">
 | 
			
		||||
              <input type="radio" class="form-check-input" id="under25" name="materialExampleRadios" [value]="0" />
 | 
			
		||||
              <label for="under25" [(ngModel)]="searchPrecio">GRATIS</label>
 | 
			
		||||
            </div>
 | 
			
		||||
            <div class="form-check pl-0 mb-3">
 | 
			
		||||
              <input type="radio" class="form-check-input" id="2550" name="materialExampleRadios" [value]="">
 | 
			
		||||
              <input type="radio" class="form-check-input" id="2550" name="materialExampleRadios" [value]="5" />
 | 
			
		||||
              <label for="2550" [(ngModel)]="searchPrecio"> $5 - $10</label>
 | 
			
		||||
            </div>
 | 
			
		||||
            <div class="form-check pl-0 mb-3">
 | 
			
		||||
              <input type="radio" class="form-check-input" id="50100" name="materialExampleRadios">
 | 
			
		||||
              <input type="radio" class="form-check-input" id="50100" name="materialExampleRadios" />
 | 
			
		||||
              <label for="50100" [(ngModel)]="searchPrecio">$10 - $20</label>
 | 
			
		||||
            </div>
 | 
			
		||||
            <div class="form-check pl-0 mb-3">
 | 
			
		||||
              <input type="radio" class="form-check-input" id="100200" name="materialExampleRadios">
 | 
			
		||||
              <input type="radio" class="form-check-input" id="100200" name="materialExampleRadios" />
 | 
			
		||||
              <label for="100200" [(ngModel)]="searchPrecio">$20 - $30</label>
 | 
			
		||||
            </div>
 | 
			
		||||
            <div class="form-check pl-0 mb-3">
 | 
			
		||||
              <input type="radio" class="form-check-input" id="200above" name="materialExampleRadios">
 | 
			
		||||
              <input type="radio" class="form-check-input" id="200above" name="materialExampleRadios" />
 | 
			
		||||
              <label [(ngModel)]="searchPrecio">Más de $30 </label>
 | 
			
		||||
            </div>
 | 
			
		||||
          </div>-->
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,7 +26,7 @@ export const ADMIN_ROUTES: RouteInfo[] = [
 | 
			
		|||
  { path: '/pagina-principal', title: 'Inicio', type: 'link', icontype: 'nc-icon nc-world-2' },
 | 
			
		||||
  {
 | 
			
		||||
    path: '/dashboard/admin',
 | 
			
		||||
    title: 'Dashboard',
 | 
			
		||||
    title: 'Reportes',
 | 
			
		||||
    type: 'link',
 | 
			
		||||
    icontype: 'nc-icon nc-chart-bar-32',
 | 
			
		||||
  },
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,6 +6,7 @@ import { Pipe, PipeTransform, Injectable } from '@angular/core';
 | 
			
		|||
@Injectable()
 | 
			
		||||
export class FilterPipe implements PipeTransform {
 | 
			
		||||
  transform(items: any[], field: string, value: string): any[] {
 | 
			
		||||
    debugger;
 | 
			
		||||
    if (!items) {
 | 
			
		||||
      return [];
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue