fix(v3.4.6): fix reservation cascade, remove calendar mocks, strip auto meet links, friendly dates, dynamic building floors and career filter

This commit is contained in:
2026-10-08 08:26:15 -03:00
parent 25039efdeb
commit 368dc71b14
23 changed files with 291 additions and 149 deletions
+41 -1
View File
@@ -85,12 +85,17 @@ const handleListBuildings = async (req, res) => {
.filter(b => !b.is_virtual)
.reduce((acc, b) => acc + (b.physical_capacity || b.total_capacity || 0), 0);
const total_floors = stats.total_floors || buildings
.filter(b => !b.is_virtual)
.reduce((acc, b) => acc + (parseInt(b.floors, 10) || 0), 0);
res.render('buildings/list', {
title: 'Gestión de Edificios - Edu-Space Admin',
buildings,
total_classrooms: stats.total_classrooms || buildings.reduce((a, b) => a + (b.classrooms_count || 0), 0),
total_capacity: total_physical_capacity,
total_physical_capacity,
total_floors,
search,
status_filter: status
});
@@ -102,6 +107,7 @@ const handleListBuildings = async (req, res) => {
total_classrooms: 31,
total_capacity: 1250,
total_physical_capacity: 1250,
total_floors: 4,
search: '',
status_filter: ''
});
@@ -174,10 +180,44 @@ router.get(['/view/:id', '/view_building', '/:id'], async (req, res) => {
floors_display: is_virtual ? 'Digital' : String(building.floors ?? 1)
};
// Agrupación dinámica por piso / nivel
const floorsMap = new Map();
classrooms.forEach(c => {
const floorKey = c.floor_display || (c.floor === '0' || c.floor === 'PB' ? 'Planta Baja (PB)' : (c.floor ? (c.floor.toLowerCase().startsWith('piso') ? c.floor : `Piso ${c.floor}`) : 'Planta Baja (PB)'));
if (!floorsMap.has(floorKey)) {
floorsMap.set(floorKey, []);
}
floorsMap.get(floorKey).push(c);
});
const sortedFloorKeys = Array.from(floorsMap.keys()).sort((a, b) => {
const fA = String(a).toUpperCase();
const fB = String(b).toUpperCase();
if (fA.includes('SUB') || fA.includes('SS')) return -1;
if (fB.includes('SUB') || fB.includes('SS')) return 1;
if (fA.includes('PB') || fA.includes('PLANTA BAJA')) return -1;
if (fB.includes('PB') || fB.includes('PLANTA BAJA')) return 1;
if (fA.includes('EP') || fA.includes('ENTRE')) return -1;
if (fB.includes('EP') || fB.includes('ENTRE')) return 1;
return fA.localeCompare(fB, undefined, { numeric: true });
});
const floors_list = sortedFloorKeys.map(floorName => ({
floor_name: floorName,
classrooms: floorsMap.get(floorName)
}));
const classrooms_by_floor = {};
floorsMap.forEach((rooms, floorName) => {
classrooms_by_floor[floorName] = rooms;
});
res.render('buildings/view', {
title: `Edificio ${building.name} - Edu-Space Admin`,
building,
classrooms
classrooms,
classrooms_by_floor,
floors_list
});
});