Update code with changes from git diff

This commit is contained in:
2023-11-10 18:15:14 +00:00
parent 2e00fbec20
commit 2173869717
33 changed files with 7013 additions and 615 deletions

View File

@@ -6,6 +6,7 @@ $('div.modal#cargando').modal({
});
const store = reactive({
loading: false,
perido: null,
current: {
comentario: '',
clase_vista: null,
@@ -132,8 +133,8 @@ const store = reactive({
store.current.justificada.registro_justificada = true;
let data;
try {
const res = await fetch('action/action_justificar.php', {
method: 'PUT',
const res = await fetch('action/justificar.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
@@ -154,6 +155,43 @@ const store = reactive({
store.current.justificada.justificador_rol = data.justificador_rol;
store.current.justificada.registro_fecha_justificacion = data.registro_fecha_justificacion;
},
async justificarBloque(fecha, bloques, justificacion) {
if (bloques.length === 0) {
alert('No se ha seleccionado ningún bloque');
return;
}
if (!justificacion) {
alert('No se ha ingresado ninguna observación');
return;
}
try {
const res = await fetch('action/action_justificar.php', {
method: 'PUT',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
fecha,
bloques,
justificacion,
})
});
const resData = await res.json();
if (resData.status === 'success') {
alert('Se ha justificado el bloque');
store.current.modal_state = 'Cargando datos...';
$('div.modal#cargando').modal('show');
await store.registros.fetch();
$('div.modal#cargando').modal('hide');
}
else {
alert('No se ha podido justificar el bloque');
}
}
catch (error) {
alert('Error al justificar');
}
},
registros: {
data: [],
async fetch(fecha, fecha_inicio, fecha_fin) {
@@ -203,7 +241,7 @@ const store = reactive({
if one of the filters is null, then it is not relevant
*/
const filters = Object.keys(store.filters).filter((filtro) => store.filters[filtro] || store.filters[filtro]?.length > 0);
const filters = Object.keys(store.filters).filter((filtro) => store.filters[filtro] !== null || store.filters[filtro]?.length > 0);
return this.data.filter((registro) => {
return filters.every((filtro) => {
switch (filtro) {
@@ -279,6 +317,7 @@ const store = reactive({
});
createApp({
store,
messages: [],
get clase_vista() {
return store.current.clase_vista;
},
@@ -294,12 +333,21 @@ createApp({
profesores: [],
async mounted() {
$('div.modal#cargando').modal('show');
// await store.registros.fetch()
await store.facultades.fetch();
await store.estados.fetch();
await store.bloques_horario.fetch();
await store.filters.switchFechas();
this.profesores = await (await fetch('action/action_profesor.php')).json();
$('div.modal#cargando').modal('hide');
try {
// await store.registros.fetch()
await store.facultades.fetch();
await store.estados.fetch();
await store.bloques_horario.fetch();
await store.filters.switchFechas();
store.periodo = await fetch('action/periodo_datos.php').then(res => res.json());
this.profesores = await (await fetch('action/action_profesor.php')).json();
this.messages.push({ title: 'Datos cargados', text: 'Los datos se han cargado correctamente', type: 'success', timestamp: new Date() });
}
catch (error) {
this.messages.push({ title: 'Error al cargar datos', text: 'No se pudieron cargar los datos', type: 'danger', timestamp: new Date() });
}
finally {
$('div.modal#cargando').modal('hide');
}
}
}).mount('#app');