Skip to content

Commit

Permalink
feat(rup): ruta automatica y corrige error
Browse files Browse the repository at this point in the history
  • Loading branch information
liquid36 committed Aug 5, 2021
1 parent e6132e4 commit 78fff8d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/app/modules/rup/components/huds/vistaPrestacion.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<plex-button *ngIf="hasPacs" type="info" (click)="onPacs()" size="sm">
VER IMAGEN
</plex-button>
<plex-button *ngIf='puedeDescargarInforme' type="info" size="sm" icon="download" title="Descargar PDF"
<plex-button *ngIf="puedeDescargarInforme" type="info" size="sm" icon="download" title="Descargar PDF"
[disabled]="requestInProgress" (click)="descargarInforme()" titlePosition="left">
</plex-button>
<plex-button *ngIf='puedeEditar' type="info" size="sm" icon="pencil" title="Editar prestación"
<plex-button *ngIf="_puedeEditar" type="info" size="sm" icon="pencil" title="Editar prestación"
[disabled]="requestInProgress" (click)="abrirPrestacion()" titlePosition="left">
</plex-button>
<ng-content></ng-content>
Expand Down
24 changes: 15 additions & 9 deletions src/app/modules/rup/components/huds/vistaPrestacion.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

import { Auth } from '@andes/auth';
import { Component, Input, OnInit, ViewEncapsulation } from '@angular/core';
import { Router } from '@angular/router';
import { map } from 'rxjs/operators';
import { IPaciente } from '../../../../core/mpi/interfaces/IPaciente';
import { PacienteService } from '../../../../core/mpi/services/paciente.service';
Expand All @@ -9,8 +10,6 @@ import { IPrestacion } from '../../interfaces/prestacion.interface';
import { populateRelaciones } from '../../operators/populate-relaciones';
import { ElementosRUPService } from '../../services/elementosRUP.service';
import { PrestacionesService } from '../../services/prestaciones.service';
import { ActivatedRoute, Router } from '@angular/router';

@Component({
selector: 'vista-prestacion',
templateUrl: 'vistaPrestacion.html',
Expand All @@ -21,16 +20,16 @@ import { ActivatedRoute, Router } from '@angular/router';
export class VistaPrestacionComponent implements OnInit {
@Input() paciente: IPaciente;
@Input() prestacion: IPrestacion;
@Input() evolucionActual: any;
@Input() puedeEditar: boolean;
@Input() ruta: boolean;
@Input() indice = 0;

public ready$ = this.elementosRUPService.ready;
public puedeDescargarInforme: boolean;
public requestInProgress: boolean;
public hasPacs: boolean;

_puedeEditar: boolean;


constructor(
private auth: Auth,
private servicioDocumentos: DocumentosService,
Expand Down Expand Up @@ -62,10 +61,11 @@ export class VistaPrestacionComponent implements OnInit {
this.servicioPaciente.getById(prestacion.paciente.id).subscribe(paciente => {
this.prestacion = prestacion;
this.paciente = paciente;
this.puedeEditar = this.puedeEditar && this.prestacion.createdBy.id === this.auth.usuario.id;
this._puedeEditar = this.puedeEditar && this.checkUser();
});
});
}

get idPrestacion(): any {
return this._idPrestacion;
}
Expand All @@ -74,6 +74,10 @@ export class VistaPrestacionComponent implements OnInit {
return fecha.getTime();
}

checkUser() {
const permisoExtra = this.auth.check('rup:validacion:' + this.prestacion.solicitud.tipoPrestacion.id);
return permisoExtra || this.prestacion.createdBy.id === this.auth.usuario.id;
}

descargarInforme() {
this.requestInProgress = true;
Expand All @@ -91,9 +95,11 @@ export class VistaPrestacionComponent implements OnInit {
}

abrirPrestacion() {
if (this.ruta) {
this.servicioPrestacion.notificaRuta(this.ruta);
}
this.servicioPrestacion.notificaRuta({
// Generico por ahora
nombre: 'VOLVER',
ruta: this.router.url
});
this.router.navigate(['./rup/ejecucion', this.prestacion.id]);
}

Expand Down

0 comments on commit 78fff8d

Please sign in to comment.