Skip to content

Commit 4932bfd

Browse files
committed
fix(CIT): visualizacion de turnos
1 parent fe18d9e commit 4932bfd

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

src/app/components/turnos/dar-turnos/calendario-dia.class.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,13 @@ export class CalendarioDia {
5959
this.turnosDisponibles += unBloque.restantesProgramados + unBloque.restantesDelDia;
6060
});
6161
/* Quedan en estado 'disponible' (Para mostrarse en el calendario) los bloques que ..
62-
- Sean exclusivos de gestión y tengan turnos disponibles
62+
- Sean exclusivos de gestión (llave y/o profesional) y tengan turnos disponibles
6363
- Tengan turnos del dia o programados disponibles
6464
*/
65-
if (this.esExclusivoGestion(unaAgenda)) {
66-
this.estado = (unaAgenda.turnosRestantesGestion > 0) ? 'disponible' : 'ocupado';
67-
this.turnosDisponibles = unaAgenda.turnosRestantesGestion;
65+
const exclusivosGestion = this.bloquesExclusivosGestion(unaAgenda);
66+
if (exclusivosGestion.length) {
67+
this.estado = (exclusivosGestion.some(bloque => bloque.restantesGestion > 0) ? 'disponible' : 'ocupado');
68+
this.turnosDisponibles += exclusivosGestion.map(bloque => bloque.restantesGestion).reduce((a, b) => a + b, 0);
6869
} else {
6970
this.estado = (this.delDiaDisponibles > 0 && this.gestionDisponibles === 0) ? 'disponible' : 'ocupado';
7071
}
@@ -152,7 +153,8 @@ export class CalendarioDia {
152153
}
153154
}
154155

155-
esExclusivoGestion(agenda: any): boolean {
156-
return agenda.bloques.every(bloque => bloque.reservadoGestion > 0 && bloque.accesoDirectoDelDia === 0 && bloque.accesoDirectoProgramado === 0 && bloque.reservadoProfesional === 0);
156+
// retorna solo los bloques de la agenda que son de gestión
157+
bloquesExclusivosGestion(agenda: any): IBloque[] {
158+
return agenda.bloques.filter(bloque => bloque.reservadoGestion > 0 && bloque.accesoDirectoDelDia === 0 && bloque.accesoDirectoProgramado === 0);
157159
}
158160
}

src/app/components/turnos/dar-turnos/dar-turnos.component.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,13 +529,12 @@ export class DarTurnosComponent implements OnInit {
529529
}
530530
}
531531

532-
// retorna true si algun bloque de la agenda es exclusivo de gestión
532+
// retorna true si algun bloque de la agenda es exclusivo de gestión (llave y/o profesional)
533533
contieneExclusivoGestion(agenda: IAgenda): boolean {
534534
return agenda.bloques.some(bloque =>
535535
bloque.reservadoGestion > 0 &&
536536
bloque.accesoDirectoDelDia === 0 &&
537-
bloque.accesoDirectoProgramado === 0 &&
538-
bloque.reservadoProfesional === 0);
537+
bloque.accesoDirectoProgramado === 0);
539538
}
540539

541540
hayTurnosEnHorario(agenda) {

0 commit comments

Comments
 (0)