All
This commit is contained in:
@@ -14,10 +14,32 @@ const profesores = reactive({
|
||||
return this.data.find((profesor) => profesor.profesor_clave === profesores.clave);
|
||||
},
|
||||
});
|
||||
const horarios = reactive({
|
||||
const facultades = reactive({
|
||||
data: [],
|
||||
fetch: async function () {
|
||||
if (profesores.current) {
|
||||
const facultades = await fetch('action/action_facultad.php').then(response => response.json());
|
||||
const carreras = await fetch(`action/carrera.php`).then(response => response.json());
|
||||
this.data = await Promise.all(facultades.map(async (facultad) => ({
|
||||
...facultad,
|
||||
carreras: await Promise.all(carreras.filter((carrera) => carrera.facultad_id === facultad.facultad_id).map(async (carrera) => {
|
||||
const grupos = await fetch(`action/action_grupo.php?carrera_id=${carrera.carrera_id}`).then(response => response.json());
|
||||
return {
|
||||
...carrera,
|
||||
grupos,
|
||||
};
|
||||
})),
|
||||
})));
|
||||
this.data = this.data.filter((facultad) => facultad.carreras.length > 0);
|
||||
}
|
||||
});
|
||||
const horarios = reactive({
|
||||
data: [],
|
||||
fetch: async function (grupo = null, carrera_id = null) {
|
||||
if (grupo && carrera_id) {
|
||||
const response = await fetch(`action/action_horario.php?grupo=${grupo}&carrera_id=${carrera_id}`);
|
||||
this.data = await response.json();
|
||||
}
|
||||
else if (profesores.current) {
|
||||
const response = await fetch(`action/action_horario.php?profesor_id=${profesores.current.profesor_id}`);
|
||||
this.data = await response.json();
|
||||
}
|
||||
@@ -76,7 +98,9 @@ const horarios = reactive({
|
||||
const app = createApp({
|
||||
profesores,
|
||||
horarios,
|
||||
facultades,
|
||||
mounted: async function () {
|
||||
await profesores.fetch();
|
||||
await facultades.fetch();
|
||||
}
|
||||
}).mount('#app');
|
||||
|
||||
@@ -15,6 +15,31 @@ const app = createApp({
|
||||
});
|
||||
const data = await res.json();
|
||||
this.puestos.push(data);
|
||||
// order by puesto.nombre
|
||||
this.puestos.sort((a, b) => a.nombre.localeCompare(b.nombre));
|
||||
}
|
||||
catch (error) {
|
||||
alert(`Error: ${error}`);
|
||||
}
|
||||
},
|
||||
to_delete: null,
|
||||
async eliminarPuesto(puesto_id) {
|
||||
try {
|
||||
const res = await fetch('action/puesto.php', {
|
||||
method: 'DELETE',
|
||||
body: JSON.stringify({
|
||||
puesto_id
|
||||
})
|
||||
});
|
||||
const data = await res.json();
|
||||
this.message = data.msg;
|
||||
// after 3 seconds, remove the message
|
||||
setTimeout(() => {
|
||||
this.message = null;
|
||||
}, 3000);
|
||||
this.puestos = this.puestos.filter((p) => p.puesto_id !== puesto_id);
|
||||
// order by puesto.nombre
|
||||
this.puestos.sort((a, b) => a.nombre.localeCompare(b.nombre));
|
||||
}
|
||||
catch (error) {
|
||||
alert(`Error: ${error}`);
|
||||
|
||||
Reference in New Issue
Block a user