Skip to content

Commit

Permalink
feat(HUDS): boton descarga informe
Browse files Browse the repository at this point in the history
  • Loading branch information
plammel committed Jun 16, 2020
1 parent 199656e commit 5c06302
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
10 changes: 6 additions & 4 deletions src/app/modules/rup/components/huds/vistaPrestacion.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<div class="prestaciones mt-3 ml-3" *ngIf="ready$ | async">
<ng-container *ngIf="prestacion">
<h4 class="text-capitalize" justify>
{{ prestacion.solicitud.tipoPrestacion.term }}
<ng-content></ng-content>
</h4>

<plex-title main titulo="{{ prestacion.solicitud.tipoPrestacion.term }}">
<plex-button *ngIf='puedeDescargarInforme' type="info" size="sm" icon="download" title="Descargar PDF" [disabled]="requestInProgress"
(click)="descargarInforme()" titlePosition="left">
</plex-button>
</plex-title>
<div class="row">
<div class="col-6">
<b> Fecha: </b>
Expand Down
25 changes: 22 additions & 3 deletions src/app/modules/rup/components/huds/vistaPrestacion.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Component, ViewEncapsulation, Input, HostBinding } from '@angular/core';
import { Component, ViewEncapsulation, Input, HostBinding, OnInit } from '@angular/core';
import { IPrestacion } from '../../interfaces/prestacion.interface';
import { PrestacionesService } from '../../services/prestaciones.service';
import { ElementosRUPService } from '../../services/elementosRUP.service';
import { Plex } from '@andes/plex';
import { Auth } from '@andes/auth';
import { IPaciente } from '../../../../core/mpi/interfaces/IPaciente';
import { PacienteService } from '../../../../core/mpi/services/paciente.service';
import { DocumentosService } from '../../../../services/documentos.service';

@Component({
selector: 'vista-prestacion',
Expand All @@ -14,7 +15,7 @@ import { PacienteService } from '../../../../core/mpi/services/paciente.service'
encapsulation: ViewEncapsulation.None,
})

export class VistaPrestacionComponent {
export class VistaPrestacionComponent implements OnInit {
@HostBinding('class.plex-layout') layout = true;

@Input() paciente: IPaciente;
Expand All @@ -23,13 +24,20 @@ export class VistaPrestacionComponent {
@Input() indice = 0;

public ready$ = this.elementosRUPService.ready;

public puedeDescargarInforme: boolean;
private requestInProgress: boolean;
constructor(
private auth: Auth,
private servicioDocumentos: DocumentosService,
public servicioPrestacion: PrestacionesService,
private servicioPaciente: PacienteService,
public elementosRUPService: ElementosRUPService) {
}

ngOnInit() {
this.puedeDescargarInforme = this.auth.check('huds:impresion');
}

private _idPrestacion;
@Input()
set idPrestacion(value: any) {
Expand All @@ -52,4 +60,15 @@ export class VistaPrestacionComponent {
}


descargarInforme() {
this.requestInProgress = true;
const term = this.prestacion.solicitud.tipoPrestacion.term;
const informe = { idPrestacion: this.prestacion.id };

this.servicioDocumentos.descargarInformeRUP(informe, term).subscribe(
() => this.requestInProgress = false,
() => this.requestInProgress = false
);
}

}

0 comments on commit 5c06302

Please sign in to comment.