Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/app/components/turnos/dar-turnos/calendario-dia.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ export class CalendarioDia {
this.turnosDisponibles += unBloque.restantesProgramados + unBloque.restantesDelDia;
});
/* Quedan en estado 'disponible' (Para mostrarse en el calendario) los bloques que ..
- Sean exclusivos de gestión y tengan turnos disponibles
- Sean exclusivos de gestión (llave y/o profesional) y tengan turnos disponibles
- Tengan turnos del dia o programados disponibles
*/
if (this.esExclusivoGestion(unaAgenda)) {
this.estado = (unaAgenda.turnosRestantesGestion > 0) ? 'disponible' : 'ocupado';
this.turnosDisponibles = unaAgenda.turnosRestantesGestion;
const exclusivosGestion = this.bloquesExclusivosGestion(unaAgenda);
if (exclusivosGestion.length) {
this.estado = (exclusivosGestion.some(bloque => bloque.restantesGestion > 0) ? 'disponible' : 'ocupado');
this.turnosDisponibles += exclusivosGestion.map(bloque => bloque.restantesGestion).reduce((a, b) => a + b, 0);
} else {
this.estado = (this.delDiaDisponibles > 0 && this.gestionDisponibles === 0) ? 'disponible' : 'ocupado';
}
Expand Down Expand Up @@ -152,7 +153,8 @@ export class CalendarioDia {
}
}

esExclusivoGestion(agenda: any): boolean {
return agenda.bloques.every(bloque => bloque.reservadoGestion > 0 && bloque.accesoDirectoDelDia === 0 && bloque.accesoDirectoProgramado === 0 && bloque.reservadoProfesional === 0);
// retorna solo los bloques de la agenda que son de gestión
bloquesExclusivosGestion(agenda: any): IBloque[] {
return agenda.bloques.filter(bloque => bloque.reservadoGestion > 0 && bloque.accesoDirectoDelDia === 0 && bloque.accesoDirectoProgramado === 0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -529,13 +529,12 @@ export class DarTurnosComponent implements OnInit {
}
}

// retorna true si algun bloque de la agenda es exclusivo de gestión
// retorna true si algun bloque de la agenda es exclusivo de gestión (llave y/o profesional)
contieneExclusivoGestion(agenda: IAgenda): boolean {
return agenda.bloques.some(bloque =>
bloque.reservadoGestion > 0 &&
bloque.accesoDirectoDelDia === 0 &&
bloque.accesoDirectoProgramado === 0 &&
bloque.reservadoProfesional === 0);
bloque.accesoDirectoProgramado === 0);
}

hayTurnosEnHorario(agenda) {
Expand Down
Loading