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 12, 2020
1 parent c93c275 commit 7130da9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ export class VistaContextoPrestacionComponent implements OnInit {

}

}
}
3 changes: 3 additions & 0 deletions src/app/modules/rup/components/huds/vistaPrestacion.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ <h4 class="text-capitalize" justify>
{{ prestacion.solicitud.tipoPrestacion.term }}
<ng-content></ng-content>
</h4>
<plex-button *ngIf='puedeDescargarInforme' type="info" size="sm" icon="download" title="Descargar PDF" class="ml-1"
[disabled]="requestInProgress" (click)="descargarInforme()" titlePosition="right">
</plex-button>
<div class="row">
<div class="col-6">
<b> Fecha: </b>
Expand Down
21 changes: 20 additions & 1 deletion src/app/modules/rup/components/huds/vistaPrestacion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ 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 @@ -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:impresionHuds');
}

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 7130da9

Please sign in to comment.