Add create survey from template
This commit is contained in:
		
							parent
							
								
									ee2853820a
								
							
						
					
					
						commit
						80b55773d9
					
				| 
						 | 
				
			
			@ -34,9 +34,9 @@
 | 
			
		|||
    </div>
 | 
			
		||||
  </form>
 | 
			
		||||
 | 
			
		||||
  <div class="ds-survey" id="entities">
 | 
			
		||||
  <div class="ds-survey" id="entities" *ngIf="usuarioEncuestas?.length === 0">
 | 
			
		||||
    <div class="ds-survey--all-question-wrapper">
 | 
			
		||||
      <ng-container class="" *ngIf="usuarioEncuestas?.length === 0">
 | 
			
		||||
      <ng-container class="">
 | 
			
		||||
        <p class="ds-title text-center">No posee colaboraciones</p>
 | 
			
		||||
        <p class="ds-subtitle text-center">Inicie colaborando con otros usuarios mundialmente al recibir una invitación</p>
 | 
			
		||||
      </ng-container>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,9 +17,9 @@
 | 
			
		|||
  <!-- <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="ds-survey" id="entities">
 | 
			
		||||
  <div class="ds-survey" id="entities" *ngIf="misPlantillas?.length === 0">
 | 
			
		||||
    <div class="ds-survey--all-question-wrapper">
 | 
			
		||||
      <ng-container class="" *ngIf="misPlantillas?.length === 0">
 | 
			
		||||
      <ng-container class="">
 | 
			
		||||
        <p class="ds-title text-center">No posee plantillas</p>
 | 
			
		||||
        <p class="ds-subtitle text-center">Adquiera y compre diferentes plantillas disponibles en nuestra tienda</p>
 | 
			
		||||
      </ng-container>
 | 
			
		||||
| 
						 | 
				
			
			@ -53,7 +53,12 @@
 | 
			
		|||
                <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">
 | 
			
		||||
              <button
 | 
			
		||||
                type="submit"
 | 
			
		||||
                class="ds-btn ds-btn--primary btn-sm"
 | 
			
		||||
                data-cy="entityCreateButton"
 | 
			
		||||
                (click)="crearEncuesta(miPlantilla.id)"
 | 
			
		||||
              >
 | 
			
		||||
                <span class="d-none d-md-inline" jhiTranslate="dataSurveyApp.usuarioExtra.plantillas.crearEncuesta">Crear Encuesta</span>
 | 
			
		||||
              </button>
 | 
			
		||||
            </div>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,7 +11,12 @@ import { ActivatedRoute, Router } from '@angular/router';
 | 
			
		|||
import { FormBuilder } from '@angular/forms';
 | 
			
		||||
import { AccountService } from '../../../core/auth/account.service';
 | 
			
		||||
import * as dayjs from 'dayjs';
 | 
			
		||||
import { DATE_TIME_FORMAT } from 'app/config/input.constants';
 | 
			
		||||
import { Account } from '../../../core/auth/account.model';
 | 
			
		||||
import { IEncuesta, Encuesta } from './../../encuesta/encuesta.model';
 | 
			
		||||
import { EncuestaService } from 'app/entities/encuesta/service/encuesta.service';
 | 
			
		||||
import { AccesoEncuesta } from 'app/entities/enumerations/acceso-encuesta.model';
 | 
			
		||||
import { EstadoEncuesta } from 'app/entities/enumerations/estado-encuesta.model';
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
  selector: 'jhi-usuario-plantillas',
 | 
			
		||||
| 
						 | 
				
			
			@ -32,6 +37,7 @@ export class UsuarioPlantillasComponent implements OnInit {
 | 
			
		|||
    protected activatedRoute: ActivatedRoute,
 | 
			
		||||
    protected fb: FormBuilder,
 | 
			
		||||
    protected accountService: AccountService,
 | 
			
		||||
    protected encuestaService: EncuestaService,
 | 
			
		||||
    protected router: Router
 | 
			
		||||
  ) {}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -65,4 +71,28 @@ export class UsuarioPlantillasComponent implements OnInit {
 | 
			
		|||
  trackId(index: number, item: IPlantilla): number {
 | 
			
		||||
    return item.id!;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  crearEncuesta(plantillaId: any): void {
 | 
			
		||||
    const now = dayjs();
 | 
			
		||||
 | 
			
		||||
    const newSurvey = {
 | 
			
		||||
      ...new Encuesta(),
 | 
			
		||||
      id: undefined,
 | 
			
		||||
      nombre: 'This is a survey',
 | 
			
		||||
      descripcion: 'This is a survey',
 | 
			
		||||
      fechaCreacion: dayjs(now, DATE_TIME_FORMAT),
 | 
			
		||||
      calificacion: 5,
 | 
			
		||||
      acceso: AccesoEncuesta.PUBLIC,
 | 
			
		||||
      contrasenna: undefined,
 | 
			
		||||
      estado: EstadoEncuesta.DRAFT,
 | 
			
		||||
      categoria: undefined,
 | 
			
		||||
      usuarioExtra: this.usuarioExtra,
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    console.log(plantillaId, newSurvey);
 | 
			
		||||
 | 
			
		||||
    this.encuestaService.createFromTemplate(newSurvey, plantillaId).subscribe(res => {
 | 
			
		||||
      this.router.navigate(['/encuesta']);
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue