From 4eaa4c5d9b2985a9339c287e38180b735f14079f Mon Sep 17 00:00:00 2001 From: ma7payne Date: Mon, 26 Aug 2024 14:46:59 -0300 Subject: [PATCH] feat(CIT): implementa filtros de reasignacion de turnos --- .../gestor-agendas.component.ts | 12 ++++++++- .../reasignar/reasignar-turno.component.ts | 25 +++++++++++++++---- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/app/components/turnos/gestor-agendas/gestor-agendas.component.ts b/src/app/components/turnos/gestor-agendas/gestor-agendas.component.ts index d1631ea661..7ba8240966 100644 --- a/src/app/components/turnos/gestor-agendas/gestor-agendas.component.ts +++ b/src/app/components/turnos/gestor-agendas/gestor-agendas.component.ts @@ -328,6 +328,14 @@ export class GestorAgendasComponent implements OnInit, OnDestroy { this.getAgendas(); } + actualizarSeleccionada(agendas) { + agendas.forEach(nuevaAgenda => { + if (this.agendasSeleccionadas && this.agendasSeleccionadas[0].id === nuevaAgenda.id) { + this.agendasSeleccionadas[0] = nuevaAgenda; + } + }); + } + getAgendas() { if (this.lastRequestFecha) { this.lastRequestFecha.unsubscribe(); @@ -365,6 +373,9 @@ export class GestorAgendasComponent implements OnInit, OnDestroy { this.scrollEnd = true; } + if (this.agendasSeleccionadas[0]) { + this.actualizarSeleccionada(agendas); + } }, err => this.loader = false ); } @@ -387,7 +398,6 @@ export class GestorAgendasComponent implements OnInit, OnDestroy { this.parametros['tipoPrestaciones'] = this.prestacionesPermisos; } this.getAgendas(); - } agregarNotaAgenda() { diff --git a/src/app/components/turnos/gestor-agendas/operaciones-turnos/reasignar/reasignar-turno.component.ts b/src/app/components/turnos/gestor-agendas/operaciones-turnos/reasignar/reasignar-turno.component.ts index 2097c101e6..f9350e36d6 100644 --- a/src/app/components/turnos/gestor-agendas/operaciones-turnos/reasignar/reasignar-turno.component.ts +++ b/src/app/components/turnos/gestor-agendas/operaciones-turnos/reasignar/reasignar-turno.component.ts @@ -1,10 +1,10 @@ -import { Component, Input, EventEmitter, Output, OnInit } from '@angular/core'; -import { Plex } from '@andes/plex'; import { Auth } from '@andes/auth'; -import { IAgenda } from './../../../../../interfaces/turnos/IAgenda'; -import { ITurno } from './../../../../../interfaces/turnos/ITurno'; +import { Plex } from '@andes/plex'; +import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { AgendaService } from '../../../../../services/turnos/agenda.service'; import { TurnoService } from '../../../../../services/turnos/turno.service'; +import { IAgenda } from './../../../../../interfaces/turnos/IAgenda'; +import { ITurno } from './../../../../../interfaces/turnos/ITurno'; import { TiposDeTurnos } from './../../../enums'; @Component({ @@ -67,7 +67,7 @@ export class ReasignarTurnoComponent implements OnInit { actualizar() { this.serviceAgenda.getById(this.agendaAReasignar.id).subscribe(agendaActualizada => { - this.agendaAReasignar = agendaActualizada; + this.agendaAReasignar = this.filtrarTurnos(agendaActualizada); }); } @@ -155,4 +155,19 @@ export class ReasignarTurnoComponent implements OnInit { this.showReasignarTurno = false; } + filtrarTurnos(agenda) { + agenda.bloques.forEach((bloque) => { + const aReasignar = []; + + bloque.turnos.forEach(turno => { + if (turno.estado === 'suspendido' && turno.fechaHoraDacion) { + aReasignar.push(turno); + } + }); + + bloque.turnos = aReasignar; + }); + + return agenda; + } }