My changes

This commit is contained in:
Cloud User
2024-03-06 18:11:42 -06:00
45 changed files with 4876 additions and 272 deletions

View File

@@ -77,6 +77,10 @@ $('div.modal#cargando').modal({
const store = reactive({
loading: false,
<<<<<<< HEAD
=======
perido: null as Periodo | null,
>>>>>>> 7688f1aac1824c234bc5f19b154e9ad1f4808d4f
current: {
comentario: '',
clase_vista: null,
@@ -216,8 +220,13 @@ const store = reactive({
registro_fecha_justificacion: Date;
};
try {
<<<<<<< HEAD
const res = await fetch('action/action_justificar.php', {
method: 'PUT',
=======
const res = await fetch('action/justificar.php', {
method: 'POST',
>>>>>>> 7688f1aac1824c234bc5f19b154e9ad1f4808d4f
headers: {
'Content-Type': 'application/json'
},
@@ -237,6 +246,44 @@ const store = reactive({
store.current.justificada.justificador_rol = data.justificador_rol
store.current.justificada.registro_fecha_justificacion = data.registro_fecha_justificacion
},
<<<<<<< HEAD
=======
async justificarBloque(fecha: Date, bloques: Array<number>, justificacion: string) {
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');
}
},
>>>>>>> 7688f1aac1824c234bc5f19b154e9ad1f4808d4f
registros: {
data: [] as Registro[],
async fetch(fecha?: Date, fecha_inicio?: Date, fecha_fin?: Date) {
@@ -284,7 +331,11 @@ const store = reactive({
if one of the filters is null, then it is not relevant
*/
<<<<<<< HEAD
const filters = Object.keys(store.filters).filter((filtro) => store.filters[filtro] !== null || store.filters[filtro]?.length > 0 )
=======
const filters = Object.keys(store.filters).filter((filtro) => store.filters[filtro] !== null || store.filters[filtro]?.length > 0)
>>>>>>> 7688f1aac1824c234bc5f19b154e9ad1f4808d4f
return this.data.filter((registro: Registro) => {
return filters.every((filtro) => {
switch (filtro) {
@@ -365,6 +416,10 @@ type Profesor = {
}
createApp({
store,
<<<<<<< HEAD
=======
messages: [] as Array<{ title: string, text: string, type: string, timestamp: string }>,
>>>>>>> 7688f1aac1824c234bc5f19b154e9ad1f4808d4f
get clase_vista() {
return store.current.clase_vista
},
@@ -381,6 +436,7 @@ createApp({
profesores: [] as Profesor[],
async mounted() {
$('div.modal#cargando').modal('show');
<<<<<<< HEAD
// await store.registros.fetch()
await store.facultades.fetch()
@@ -390,5 +446,24 @@ createApp({
this.profesores = await (await fetch('action/action_profesor.php')).json() as Profesor[];
$('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()) as Periodo;
this.profesores = await (await fetch('action/action_profesor.php')).json() as Profesor[];
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');
}
>>>>>>> 7688f1aac1824c234bc5f19b154e9ad1f4808d4f
}
}).mount('#app')