add listar colaboraciones de un usuario
This commit is contained in:
		
							parent
							
								
									ca63cdfe88
								
							
						
					
					
						commit
						3ce87a9c4c
					
				|  | @ -203,7 +203,7 @@ | ||||||
|             <span |             <span | ||||||
|               >- |               >- | ||||||
|               {{ |               {{ | ||||||
|                 encuesta.fechaPublicacion === undefined ? 'Sin publicar' : (encuesta.fechaFinalizada | formatShortDatetime | lowercase) |                 encuesta.fechaPublicacion === undefined ? 'Sin publicar' : (encuesta.fechaPublicacion | formatShortDatetime | lowercase) | ||||||
|               }}</span |               }}</span | ||||||
|             > |             > | ||||||
|           </dd> |           </dd> | ||||||
|  | @ -216,7 +216,7 @@ | ||||||
|               {{ |               {{ | ||||||
|                 encuesta.fechaFinalizar === undefined |                 encuesta.fechaFinalizar === undefined | ||||||
|                   ? 'Sin fecha de finalización' |                   ? 'Sin fecha de finalización' | ||||||
|                   : (encuesta.fechaFinalizada | formatShortDatetime | lowercase) |                   : (encuesta.fechaFinalizar | formatShortDatetime | lowercase) | ||||||
|               }}</span |               }}</span | ||||||
|             > |             > | ||||||
|           </dd> |           </dd> | ||||||
|  |  | ||||||
|  | @ -42,7 +42,7 @@ import { RouterModule } from '@angular/router'; | ||||||
|           import('./e-pregunta-cerrada-opcion/e-pregunta-cerrada-opcion.module').then(m => m.EPreguntaCerradaOpcionModule), |           import('./e-pregunta-cerrada-opcion/e-pregunta-cerrada-opcion.module').then(m => m.EPreguntaCerradaOpcionModule), | ||||||
|       }, |       }, | ||||||
|       { |       { | ||||||
|         path: 'usuario-encuesta', |         path: 'colaboraciones', | ||||||
|         data: { pageTitle: 'dataSurveyApp.usuarioEncuesta.home.title' }, |         data: { pageTitle: 'dataSurveyApp.usuarioEncuesta.home.title' }, | ||||||
|         loadChildren: () => import('./usuario-encuesta/usuario-encuesta.module').then(m => m.UsuarioEncuestaModule), |         loadChildren: () => import('./usuario-encuesta/usuario-encuesta.module').then(m => m.UsuarioEncuestaModule), | ||||||
|       }, |       }, | ||||||
|  |  | ||||||
|  | @ -1,22 +1,12 @@ | ||||||
| <div> | <div> | ||||||
|   <h2 id="page-heading" data-cy="UsuarioEncuestaHeading"> |   <h2 id="page-heading" data-cy="UsuarioEncuestaHeading"> | ||||||
|     <span jhiTranslate="dataSurveyApp.usuarioEncuesta.home.title">Usuario Encuestas</span> |     <span jhiTranslate="dataSurveyApp.usuarioEncuesta.home.title">Colaboraciones en Encuestas</span> | ||||||
| 
 | 
 | ||||||
|     <div class="d-flex justify-content-end"> |     <div class="d-flex justify-content-end"> | ||||||
|       <button class="btn btn-info mr-2" (click)="loadAll()" [disabled]="isLoading"> |       <button class="ds-btn ds-btn--secondary mr-2" (click)="loadAll()" [disabled]="isLoading"> | ||||||
|         <fa-icon icon="sync" [spin]="isLoading"></fa-icon> |         <fa-icon icon="sync" [spin]="isLoading"></fa-icon> | ||||||
|         <span jhiTranslate="dataSurveyApp.usuarioEncuesta.home.refreshListLabel">Refresh List</span> |         <span jhiTranslate="dataSurveyApp.usuarioEncuesta.home.refreshListLabel">Refresh List</span> | ||||||
|       </button> |       </button> | ||||||
| 
 |  | ||||||
|       <button |  | ||||||
|         id="jh-create-entity" |  | ||||||
|         data-cy="entityCreateButton" |  | ||||||
|         class="btn btn-primary jh-create-entity create-usuario-encuesta" |  | ||||||
|         [routerLink]="['/usuario-encuesta/new']" |  | ||||||
|       > |  | ||||||
|         <fa-icon icon="plus"></fa-icon> |  | ||||||
|         <span jhiTranslate="dataSurveyApp.usuarioEncuesta.home.createLabel"> Create a new Usuario Encuesta </span> |  | ||||||
|       </button> |  | ||||||
|     </div> |     </div> | ||||||
|   </h2> |   </h2> | ||||||
| 
 | 
 | ||||||
|  | @ -32,56 +22,49 @@ | ||||||
|     <table class="table table-striped" aria-describedby="page-heading"> |     <table class="table table-striped" aria-describedby="page-heading"> | ||||||
|       <thead> |       <thead> | ||||||
|         <tr> |         <tr> | ||||||
|           <th scope="col"><span jhiTranslate="global.field.id">ID</span></th> |  | ||||||
|           <th scope="col"><span jhiTranslate="dataSurveyApp.usuarioEncuesta.rol">Rol</span></th> |           <th scope="col"><span jhiTranslate="dataSurveyApp.usuarioEncuesta.rol">Rol</span></th> | ||||||
|           <th scope="col"><span jhiTranslate="dataSurveyApp.usuarioEncuesta.estado">Estado</span></th> |           <th scope="col"><span jhiTranslate="dataSurveyApp.usuarioEncuesta.estado">Estado</span></th> | ||||||
|           <th scope="col"><span jhiTranslate="dataSurveyApp.usuarioEncuesta.fechaAgregado">Fecha Agregado</span></th> |           <th scope="col"><span jhiTranslate="dataSurveyApp.usuarioEncuesta.fechaAgregado">Fecha Agregado</span></th> | ||||||
|           <th scope="col"><span jhiTranslate="dataSurveyApp.usuarioEncuesta.usuarioExtra">Usuario Extra</span></th> |           <th scope="col"><span jhiTranslate="dataSurveyApp.usuarioEncuesta.encuesta">Id encuesta</span></th> | ||||||
|           <th scope="col"><span jhiTranslate="dataSurveyApp.usuarioEncuesta.encuesta">Encuesta</span></th> |           <th scope="col"><span>Nombre encuesta</span></th> | ||||||
|           <th scope="col"></th> |           <th scope="col"></th> | ||||||
|         </tr> |         </tr> | ||||||
|       </thead> |       </thead> | ||||||
|       <tbody> |       <tbody> | ||||||
|         <tr *ngFor="let usuarioEncuesta of usuarioEncuestas; trackBy: trackId" data-cy="entityTable"> |         <tr *ngFor="let usuarioEncuesta of usuarioEncuestas; trackBy: trackId" data-cy="entityTable"> | ||||||
|           <td> |  | ||||||
|             <a [routerLink]="['/usuario-encuesta', usuarioEncuesta.id, 'view']">{{ usuarioEncuesta.id }}</a> |  | ||||||
|           </td> |  | ||||||
|           <td jhiTranslate="{{ 'dataSurveyApp.RolColaborador.' + usuarioEncuesta.rol }}">{{ usuarioEncuesta.rol }}</td> |           <td jhiTranslate="{{ 'dataSurveyApp.RolColaborador.' + usuarioEncuesta.rol }}">{{ usuarioEncuesta.rol }}</td> | ||||||
|           <td jhiTranslate="{{ 'dataSurveyApp.EstadoColaborador.' + usuarioEncuesta.estado }}">{{ usuarioEncuesta.estado }}</td> |           <td jhiTranslate="{{ 'dataSurveyApp.EstadoColaborador.' + usuarioEncuesta.estado }}">{{ usuarioEncuesta.estado }}</td> | ||||||
|           <td>{{ usuarioEncuesta.fechaAgregado | formatMediumDatetime }}</td> |           <td>{{ usuarioEncuesta.fechaAgregado | formatMediumDatetime }}</td> | ||||||
|           <td> |           <td> | ||||||
|             <div *ngIf="usuarioEncuesta.usuarioExtra"> |             <div *ngIf="usuarioEncuesta.encuesta"> | ||||||
|               <a [routerLink]="['/usuario-extra', usuarioEncuesta.usuarioExtra?.id, 'view']">{{ usuarioEncuesta.usuarioExtra?.id }}</a> |               <a>{{ usuarioEncuesta.encuesta?.id }}</a> | ||||||
|             </div> |             </div> | ||||||
|           </td> |           </td> | ||||||
|           <td> |           <td> | ||||||
|             <div *ngIf="usuarioEncuesta.encuesta"> |             <div *ngIf="usuarioEncuesta.encuesta"> | ||||||
|               <a [routerLink]="['/encuesta', usuarioEncuesta.encuesta?.id, 'view']">{{ usuarioEncuesta.encuesta?.id }}</a> |               <a>{{ usuarioEncuesta.encuesta?.nombre }}</a> | ||||||
|             </div> |             </div> | ||||||
|           </td> |           </td> | ||||||
|           <td class="text-right"> |           <td class="text-right"> | ||||||
|             <div class="btn-group"> |             <div class="btn-group" *ngIf="usuarioEncuesta.encuesta"> | ||||||
|               <button |               <button | ||||||
|                 type="submit" |                 *ngIf="usuarioEncuesta.rol === 'WRITE'" | ||||||
|                 [routerLink]="['/usuario-encuesta', usuarioEncuesta.id, 'view']" |                 type="button" | ||||||
|                 class="btn btn-info btn-sm" |                 [routerLink]="['/encuesta', usuarioEncuesta.encuesta.id, 'edit']" | ||||||
|                 data-cy="entityDetailsButton" |                 class="ds-btn ds-btn--primary" | ||||||
|  |                 [disabled]="isLoading" | ||||||
|               > |               > | ||||||
|                 <fa-icon icon="eye"></fa-icon> |                 <fa-icon [icon]="faPencilAlt"></fa-icon>  <span>Editar encuesta</span> | ||||||
|                 <span class="d-none d-md-inline" jhiTranslate="entity.action.view">View</span> |  | ||||||
|               </button> |               </button> | ||||||
| 
 |  | ||||||
|               <button |               <button | ||||||
|                 type="submit" |                 type="button" | ||||||
|                 [routerLink]="['/usuario-encuesta', usuarioEncuesta.id, 'edit']" |                 [routerLink]="['/encuesta', usuarioEncuesta.encuesta.id, 'preview']" | ||||||
|                 class="btn btn-primary btn-sm" |                 class="ds-btn ds-btn--success" | ||||||
|                 data-cy="entityEditButton" |                 [disabled]="isLoading" | ||||||
|               > |               > | ||||||
|                 <fa-icon icon="pencil-alt"></fa-icon> |                 <fa-icon [icon]="faPollH"></fa-icon>  <span>Ver vista previa</span> | ||||||
|                 <span class="d-none d-md-inline" jhiTranslate="entity.action.edit">Edit</span> |  | ||||||
|               </button> |               </button> | ||||||
| 
 |               <button type="submit" (click)="delete(usuarioEncuesta)" class="ds-btn ds-btn--danger btn-sm" data-cy="entityDeleteButton"> | ||||||
|               <button type="submit" (click)="delete(usuarioEncuesta)" class="btn btn-danger btn-sm" data-cy="entityDeleteButton"> |  | ||||||
|                 <fa-icon icon="times"></fa-icon> |                 <fa-icon icon="times"></fa-icon> | ||||||
|                 <span class="d-none d-md-inline" jhiTranslate="entity.action.delete">Delete</span> |                 <span class="d-none d-md-inline" jhiTranslate="entity.action.delete">Delete</span> | ||||||
|               </button> |               </button> | ||||||
|  |  | ||||||
|  | @ -5,16 +5,37 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; | ||||||
| import { IUsuarioEncuesta } from '../usuario-encuesta.model'; | import { IUsuarioEncuesta } from '../usuario-encuesta.model'; | ||||||
| import { UsuarioEncuestaService } from '../service/usuario-encuesta.service'; | import { UsuarioEncuestaService } from '../service/usuario-encuesta.service'; | ||||||
| import { UsuarioEncuestaDeleteDialogComponent } from '../delete/usuario-encuesta-delete-dialog.component'; | import { UsuarioEncuestaDeleteDialogComponent } from '../delete/usuario-encuesta-delete-dialog.component'; | ||||||
|  | import * as dayjs from 'dayjs'; | ||||||
|  | import { faPollH, faPencilAlt } from '@fortawesome/free-solid-svg-icons'; | ||||||
|  | 
 | ||||||
|  | import { AccountService } from 'app/core/auth/account.service'; | ||||||
|  | import { Account } from 'app/core/auth/account.model'; | ||||||
|  | import { IUsuarioExtra, UsuarioExtra } from 'app/entities/usuario-extra/usuario-extra.model'; | ||||||
|  | import { IUser } from '../../user/user.model'; | ||||||
|  | import { UsuarioExtraService } from 'app/entities/usuario-extra/service/usuario-extra.service'; | ||||||
|  | import { ActivatedRoute, Router } from '@angular/router'; | ||||||
| 
 | 
 | ||||||
| @Component({ | @Component({ | ||||||
|   selector: 'jhi-usuario-encuesta', |   selector: 'jhi-usuario-encuesta', | ||||||
|   templateUrl: './usuario-encuesta.component.html', |   templateUrl: './usuario-encuesta.component.html', | ||||||
| }) | }) | ||||||
| export class UsuarioEncuestaComponent implements OnInit { | export class UsuarioEncuestaComponent implements OnInit { | ||||||
|  |   faPollH = faPollH; | ||||||
|  |   faPencilAlt = faPencilAlt; | ||||||
|  | 
 | ||||||
|   usuarioEncuestas?: IUsuarioEncuesta[]; |   usuarioEncuestas?: IUsuarioEncuesta[]; | ||||||
|   isLoading = false; |   isLoading = false; | ||||||
|  |   usuarioExtra: IUsuarioExtra | null = null; | ||||||
|  |   user: IUser | null = null; | ||||||
| 
 | 
 | ||||||
|   constructor(protected usuarioEncuestaService: UsuarioEncuestaService, protected modalService: NgbModal) {} |   constructor( | ||||||
|  |     protected usuarioEncuestaService: UsuarioEncuestaService, | ||||||
|  |     protected modalService: NgbModal, | ||||||
|  |     protected usuarioExtraService: UsuarioExtraService, | ||||||
|  |     protected activatedRoute: ActivatedRoute, | ||||||
|  |     protected accountService: AccountService, | ||||||
|  |     protected router: Router | ||||||
|  |   ) {} | ||||||
| 
 | 
 | ||||||
|   loadAll(): void { |   loadAll(): void { | ||||||
|     this.isLoading = true; |     this.isLoading = true; | ||||||
|  | @ -22,7 +43,11 @@ export class UsuarioEncuestaComponent implements OnInit { | ||||||
|     this.usuarioEncuestaService.query().subscribe( |     this.usuarioEncuestaService.query().subscribe( | ||||||
|       (res: HttpResponse<IUsuarioEncuesta[]>) => { |       (res: HttpResponse<IUsuarioEncuesta[]>) => { | ||||||
|         this.isLoading = false; |         this.isLoading = false; | ||||||
|         this.usuarioEncuestas = res.body ?? []; |         const tempUsuarioEncuestas = res.body ?? []; | ||||||
|  |         this.usuarioEncuestas = tempUsuarioEncuestas | ||||||
|  |           .filter(c => c.usuarioExtra?.id === this.usuarioExtra?.id) | ||||||
|  |           .filter(c => c.estado === 'ACTIVE') | ||||||
|  |           .filter(c => c.encuesta?.estado !== 'DELETED'); | ||||||
|       }, |       }, | ||||||
|       () => { |       () => { | ||||||
|         this.isLoading = false; |         this.isLoading = false; | ||||||
|  | @ -31,7 +56,20 @@ export class UsuarioEncuestaComponent implements OnInit { | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   ngOnInit(): void { |   ngOnInit(): void { | ||||||
|  |     this.accountService.getAuthenticationState().subscribe(account => { | ||||||
|  |       if (account !== null) { | ||||||
|  |         this.usuarioExtraService.find(account.id).subscribe(usuarioExtra => { | ||||||
|  |           this.usuarioExtra = usuarioExtra.body; | ||||||
|           this.loadAll(); |           this.loadAll(); | ||||||
|  |           if (this.usuarioExtra !== null) { | ||||||
|  |             if (this.usuarioExtra.id === undefined) { | ||||||
|  |               const today = dayjs().startOf('day'); | ||||||
|  |               this.usuarioExtra.fechaNacimiento = today; | ||||||
|  |             } | ||||||
|  |           } | ||||||
|  |         }); | ||||||
|  |       } | ||||||
|  |     }); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   trackId(index: number, item: IUsuarioEncuesta): number { |   trackId(index: number, item: IUsuarioEncuesta): number { | ||||||
|  |  | ||||||
|  | @ -6,6 +6,9 @@ import { UsuarioEncuestaComponent } from '../list/usuario-encuesta.component'; | ||||||
| import { UsuarioEncuestaDetailComponent } from '../detail/usuario-encuesta-detail.component'; | import { UsuarioEncuestaDetailComponent } from '../detail/usuario-encuesta-detail.component'; | ||||||
| import { UsuarioEncuestaUpdateComponent } from '../update/usuario-encuesta-update.component'; | import { UsuarioEncuestaUpdateComponent } from '../update/usuario-encuesta-update.component'; | ||||||
| import { UsuarioEncuestaRoutingResolveService } from './usuario-encuesta-routing-resolve.service'; | import { UsuarioEncuestaRoutingResolveService } from './usuario-encuesta-routing-resolve.service'; | ||||||
|  | import { EncuestaDetailComponent } from '../../encuesta/detail/encuesta-detail.component'; | ||||||
|  | import { EncuestaUpdateComponent } from '../../encuesta/update/encuesta-update.component'; | ||||||
|  | import { EncuestaRoutingResolveService } from '../../encuesta/route/encuesta-routing-resolve.service'; | ||||||
| 
 | 
 | ||||||
| const usuarioEncuestaRoute: Routes = [ | const usuarioEncuestaRoute: Routes = [ | ||||||
|   { |   { | ||||||
|  | @ -37,6 +40,22 @@ const usuarioEncuestaRoute: Routes = [ | ||||||
|     }, |     }, | ||||||
|     canActivate: [UserRouteAccessService], |     canActivate: [UserRouteAccessService], | ||||||
|   }, |   }, | ||||||
|  |   { | ||||||
|  |     path: '/encuesta/:id/preview', | ||||||
|  |     component: EncuestaDetailComponent, | ||||||
|  |     resolve: { | ||||||
|  |       usuarioEncuesta: EncuestaRoutingResolveService, | ||||||
|  |     }, | ||||||
|  |     canActivate: [UserRouteAccessService], | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     path: '/encuesta/:id/edit', | ||||||
|  |     component: EncuestaUpdateComponent, | ||||||
|  |     resolve: { | ||||||
|  |       usuarioEncuesta: EncuestaRoutingResolveService, | ||||||
|  |     }, | ||||||
|  |     canActivate: [UserRouteAccessService], | ||||||
|  |   }, | ||||||
| ]; | ]; | ||||||
| 
 | 
 | ||||||
| @NgModule({ | @NgModule({ | ||||||
|  |  | ||||||
|  | @ -2,27 +2,27 @@ | ||||||
|   "dataSurveyApp": { |   "dataSurveyApp": { | ||||||
|     "usuarioEncuesta": { |     "usuarioEncuesta": { | ||||||
|       "home": { |       "home": { | ||||||
|         "title": "Usuario Encuestas", |         "title": "Colaboraciones en Encuestas", | ||||||
|         "refreshListLabel": "Refrescar lista", |         "refreshListLabel": "Refrescar lista", | ||||||
|         "createLabel": "Crear nuevo Usuario Encuesta", |         "createLabel": "Crear nuevo Colaborador", | ||||||
|         "createOrEditLabel": "Crear o editar Usuario Encuesta", |         "createOrEditLabel": "Crear o editar Colaboración", | ||||||
|         "notFound": "Ningún Usuario Encuestas encontrado" |         "notFound": "Ninguna colaboración encontrada" | ||||||
|       }, |       }, | ||||||
|       "created": "Un nuevo Usuario Encuesta ha sido creado con el identificador {{ param }}", |       "created": "Una nueva colaboración ha sido creada con el identificador {{ param }}", | ||||||
|       "updated": "Un Usuario Encuesta ha sido actualizado con el identificador {{ param }}", |       "updated": "Una colaboración ha sido actualizada con el identificador {{ param }}", | ||||||
|       "deleted": "Un Usuario Encuesta ha sido eliminado con el identificador {{ param }}", |       "deleted": "Una colaboracióna ha sido eliminada con el identificador {{ param }}", | ||||||
|       "delete": { |       "delete": { | ||||||
|         "question": "¿Seguro que quiere eliminar Usuario Encuesta {{ id }}?" |         "question": "¿Seguro que quiere eliminar la colaboración {{ id }}?" | ||||||
|       }, |       }, | ||||||
|       "detail": { |       "detail": { | ||||||
|         "title": "Usuario Encuesta" |         "title": "Colaboración en encuesta" | ||||||
|       }, |       }, | ||||||
|       "id": "ID", |       "id": "ID", | ||||||
|       "rol": "Rol", |       "rol": "Rol", | ||||||
|       "estado": "Estado", |       "estado": "Estado", | ||||||
|       "fechaAgregado": "Fecha Agregado", |       "fechaAgregado": "Fecha Agregado", | ||||||
|       "usuarioExtra": "Usuario Extra", |       "usuarioExtra": "Usuario", | ||||||
|       "encuesta": "Encuesta" |       "encuesta": "Id de Encuesta" | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue