All
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { Alert } from 'bootstrap';
|
||||
import { createApp, reactive } from 'https://unpkg.com/petite-vue?module'
|
||||
|
||||
type Registro = {
|
||||
@@ -87,6 +86,7 @@ const store = reactive({
|
||||
perPage: 10,
|
||||
modal_state: "Cargando datos...",
|
||||
justificada: null,
|
||||
fechas_clicked: false,
|
||||
},
|
||||
facultades: {
|
||||
data: [] as Facultad[],
|
||||
@@ -104,7 +104,6 @@ const store = reactive({
|
||||
profesor: null,
|
||||
periodo_id: null,
|
||||
bloque_horario: null,
|
||||
sin_registro: false,
|
||||
estados: [],
|
||||
|
||||
switchFecha: false,
|
||||
@@ -129,10 +128,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());
|
||||
});
|
||||
@@ -147,6 +148,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;
|
||||
@@ -161,7 +163,12 @@ const store = reactive({
|
||||
this.data = await res.json()
|
||||
},
|
||||
getEstado(id: number): Estado {
|
||||
return this.data.find((estado: Estado) => estado.estado_supervisor_id === id)
|
||||
return this.data.find((estado: 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)
|
||||
@@ -188,7 +195,7 @@ const store = reactive({
|
||||
toggle(arr: any, element: any) {
|
||||
const newArray = arr.includes(element) ? arr.filter((item: any) => 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)
|
||||
@@ -288,14 +295,12 @@ const store = reactive({
|
||||
return registro.facultad_id === store.filters[filtro];
|
||||
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_Horario) => bloque.id === store.filters[filtro]) as Bloque_Horario;
|
||||
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;
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user