Merge pull request #112 from Quantum-P3/feature/US-39
add visualizar plantillas compradas
This commit is contained in:
		
						commit
						f1f2542963
					
				| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 */
 | 
			
		||||
    ]),
 | 
			
		||||
  ],
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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',
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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