This commit is contained in:
2023-08-21 19:33:00 +00:00
parent f407b01809
commit 6c15e330c4
8 changed files with 161 additions and 357 deletions

View File

@@ -15,6 +15,7 @@ const store = reactive({
perPage: 10,
modal_state: "Cargando datos...",
justificada: null,
fechas_clicked: false,
},
facultades: {
data: [],
@@ -32,7 +33,6 @@ const store = reactive({
profesor: null,
periodo_id: null,
bloque_horario: null,
sin_registro: false,
estados: [],
switchFecha: false,
async switchFechas() {
@@ -54,10 +54,12 @@ const store = reactive({
const fecha = $("#fecha"), inicio = $("#fecha_inicio"), fin = $("#fecha_fin");
fecha.datepicker("setDate", new Date(`${periodo_data.fecha_final}:00:00:00`));
inicio.on("change", function () {
store.current.fechas_clicked = false;
store.filters.fecha_inicio = inicio.val();
fin.datepicker("option", "minDate", inicio.val());
});
fin.on("change", function () {
store.current.fechas_clicked = false;
store.filters.fecha_fin = fin.val();
inicio.datepicker("option", "maxDate", fin.val());
});
@@ -70,6 +72,7 @@ const store = reactive({
});
},
async fetchByDate() {
store.current.fechas_clicked = true;
$('div.modal#cargando').modal('show');
await store.registros.fetch(undefined, store.filters.fecha_inicio, store.filters.fecha_fin);
store.current.page = 1;
@@ -84,7 +87,12 @@ const store = reactive({
this.data = await res.json();
},
getEstado(id) {
return this.data.find((estado) => estado.estado_supervisor_id === id);
return this.data.find((estado) => estado.estado_supervisor_id === id) ?? {
estado_color: 'dark',
estado_icon: 'ing-cancelar',
nombre: 'Sin registro',
estado_supervisor_id: -1,
};
},
printEstados() {
if (store.filters.estados.length > 0)
@@ -108,7 +116,7 @@ const store = reactive({
toggle(arr, element) {
const newArray = arr.includes(element) ? arr.filter((item) => item !== element) : [...arr, element];
// if all are selected, then unselect all
if (newArray.length === this.estados.data.length) {
if (newArray.length === (this.estados.data.length + 1)) {
setTimeout(() => {
document.querySelectorAll('#dlAsistencia>ul>li.selected').forEach(element => element.classList.remove('selected'));
}, 100);
@@ -213,16 +221,13 @@ const store = reactive({
case 'estados':
if (store.filters[filtro].length === 0)
return true;
else if (store.filters[filtro].includes(-1) && registro.estado_supervisor_id === null)
return true;
return store.filters[filtro].includes(registro.estado_supervisor_id);
case 'bloque_horario':
const bloque = store.bloques_horario.data.find((bloque) => bloque.id === store.filters[filtro]);
return registro.horario_hora < bloque.hora_fin && registro.horario_fin > bloque.hora_inicio;
default: {
if (store.filters.sin_registro)
return !registro.registro_fecha_supervisor;
else
return registro.registro_fecha_supervisor;
}
default: return true;
}
});
});