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 11, 2020
1 parent afa7451 commit 27e6cd1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<div class="columna prestacion-offset">
<div class="concepto border-0">&nbsp;</div>
<div class="concepto border-0">
<plex-button *ngIf='puedeDescargarInforme' type="info" [size]="btnSize" icon="download" title="Descargar PDF" class="ml-1"
[disabled]="requestInProgress" (click)="descargarInforme()" titlePosition="left">
</plex-button>
</div>
<div class="divisor">
<div class="datos-prestacion">
<svg xml:space="preserve" xmlns:xlink="http://www.w3.org/1999/xlink" height="36px" version="1.1"
Expand Down
30 changes: 28 additions & 2 deletions src/app/modules/rup/components/huds/vistaContextoPrestacion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Component, OnInit, ViewEncapsulation, Input } from '@angular/core';
import { IPrestacionRegistro } from '../../interfaces/prestacion.registro.interface';
import { IPrestacion } from '../../interfaces/prestacion.interface';
import { PrestacionesService } from '../../services/prestaciones.service';
import { DocumentosService } from '../../../../services/documentos.service';
import { Auth } from '@andes/auth';

@Component({
selector: 'vista-contexto-prestacion',
Expand All @@ -28,10 +30,34 @@ export class VistaContextoPrestacionComponent implements OnInit {

_registro: IPrestacionRegistro;
_prestacion: IPrestacion;
constructor(public _prestacionesService: PrestacionesService) { }
requestInProgress: boolean;
puedeDescargarInforme: boolean;

ngOnInit() {
constructor(public _prestacionesService: PrestacionesService, public servicioDocumentos: DocumentosService, private auth: Auth) { }

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

async descargarInforme() {
this.requestInProgress = true;
let term;

const informe: any = {
idPrestacion: this.prestacion.id
};

if (this.registro) {
term = this.registro.concepto.term;
informe.idRegistro = this.registro.id;
} else {
term = this.prestacion.solicitud.tipoPrestacion.term;
}

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

}
}

0 comments on commit 27e6cd1

Please sign in to comment.