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:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "frontend",
|
||||
"version": "3.4.5",
|
||||
"version": "3.4.6",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
+3
-3
@@ -85,9 +85,9 @@ const env = nunjucks.configure(path.join(__dirname, '../views'), {
|
||||
});
|
||||
|
||||
// Versiones institucionales del sistema
|
||||
const APP_VERSION = '3.4.5';
|
||||
const FRONTEND_VERSION = '3.4.5';
|
||||
const BACKEND_VERSION = '3.4.5';
|
||||
const APP_VERSION = '3.4.6';
|
||||
const FRONTEND_VERSION = '3.4.6';
|
||||
const BACKEND_VERSION = '3.4.6';
|
||||
|
||||
env.addGlobal('app_version', APP_VERSION);
|
||||
env.addGlobal('frontend_version', FRONTEND_VERSION);
|
||||
|
||||
@@ -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
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -456,16 +456,53 @@ const handleViewClassroom = async (req, res) => {
|
||||
classroom.code_display = classroom.code_display || classroom.code || `Aula-${classroomId}`;
|
||||
classroom.building_entity = classroom.building_entity || null;
|
||||
|
||||
// Fetch upcoming reservations for this classroom
|
||||
// Fetch upcoming reservations for this classroom (encompassing full 2026 academic term)
|
||||
try {
|
||||
const rRes = await req.apiClient.get(`/reservations?classroom_id=${classroomId}&start_date=2026-08-31&end_date=2026-10-01`);
|
||||
const rRes = await req.apiClient.get(`/reservations?classroom_id=${classroomId}&start_date=2026-08-01&end_date=2026-12-31`);
|
||||
const allClassroomRes = (rRes.data && (rRes.data.reservations || rRes.data)) || [];
|
||||
upcomingReservations = allClassroomRes.map(r => ({
|
||||
...r,
|
||||
date_display: r.start_time ? r.start_time.split('T')[0] : '',
|
||||
start_time_display: r.start_time ? (r.start_time.includes('T') ? r.start_time.split('T')[1].substring(0, 5) : r.start_time) : '',
|
||||
end_time_display: r.end_time ? (r.end_time.includes('T') ? r.end_time.split('T')[1].substring(0, 5) : r.end_time) : ''
|
||||
})).sort((a, b) => a.start_time.localeCompare(b.start_time)).slice(0, 20);
|
||||
const dayNames = ['Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado'];
|
||||
|
||||
upcomingReservations = allClassroomRes.map(r => {
|
||||
let dateDisplayFriendly = '';
|
||||
let timeRangeFriendly = '';
|
||||
let fullDisplay = '';
|
||||
|
||||
if (r.start_time) {
|
||||
try {
|
||||
const rawStart = String(r.start_time).replace(' ', 'T');
|
||||
const rawEnd = r.end_time ? String(r.end_time).replace(' ', 'T') : '';
|
||||
const dtStart = new Date(rawStart);
|
||||
const dtEnd = rawEnd ? new Date(rawEnd) : null;
|
||||
|
||||
const dayName = dayNames[dtStart.getDay()];
|
||||
const d = String(dtStart.getDate()).padStart(2, '0');
|
||||
const m = String(dtStart.getMonth() + 1).padStart(2, '0');
|
||||
const y = dtStart.getFullYear();
|
||||
dateDisplayFriendly = `${dayName} ${d}/${m}/${y}`;
|
||||
|
||||
const sH = String(dtStart.getHours()).padStart(2, '0');
|
||||
const sM = String(dtStart.getMinutes()).padStart(2, '0');
|
||||
const eH = dtEnd ? String(dtEnd.getHours()).padStart(2, '0') : '';
|
||||
const eM = dtEnd ? String(dtEnd.getMinutes()).padStart(2, '0') : '';
|
||||
timeRangeFriendly = dtEnd ? `${sH}:${sM} a ${eH}:${eM} hs` : `${sH}:${sM} hs`;
|
||||
fullDisplay = `${dateDisplayFriendly} · ${timeRangeFriendly}`;
|
||||
} catch (e) {
|
||||
dateDisplayFriendly = r.start_time.split('T')[0] || r.start_time;
|
||||
timeRangeFriendly = r.end_time ? `${r.start_time} - ${r.end_time}` : r.start_time;
|
||||
fullDisplay = `${dateDisplayFriendly} · ${timeRangeFriendly}`;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
...r,
|
||||
date_display: r.start_time ? r.start_time.split('T')[0] : '',
|
||||
date_display_friendly: dateDisplayFriendly,
|
||||
time_range_friendly: timeRangeFriendly,
|
||||
full_display: fullDisplay,
|
||||
start_time_display: r.start_time ? (r.start_time.includes('T') ? r.start_time.split('T')[1].substring(0, 5) : r.start_time) : '',
|
||||
end_time_display: r.end_time ? (r.end_time.includes('T') ? r.end_time.split('T')[1].substring(0, 5) : r.end_time) : ''
|
||||
};
|
||||
}).sort((a, b) => (a.start_time || '').localeCompare(b.start_time || '')).slice(0, 30);
|
||||
} catch (e) {
|
||||
console.warn('Could not fetch reservations for classroom:', e.message);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,23 @@ const handleCalendarView = async (req, res) => {
|
||||
console.warn('Could not fetch unassigned commissions for calendar:', e.message);
|
||||
}
|
||||
|
||||
let careers = [];
|
||||
let subjects = [];
|
||||
try {
|
||||
const [carRes, subRes] = await Promise.allSettled([
|
||||
req.apiClient.get('/careers'),
|
||||
req.apiClient.get('/subjects')
|
||||
]);
|
||||
if (carRes.status === 'fulfilled' && carRes.value.data) {
|
||||
careers = carRes.value.data.careers || [];
|
||||
}
|
||||
if (subRes.status === 'fulfilled' && subRes.value.data) {
|
||||
subjects = subRes.value.data.subjects || [];
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('Could not fetch real careers/subjects for calendar filters:', e.message);
|
||||
}
|
||||
|
||||
res.render('schedule/calendar', {
|
||||
title: 'Reservations Calendar - Edu-Space Admin',
|
||||
today_date: new Date().toISOString().split('T')[0],
|
||||
@@ -39,15 +56,8 @@ const handleCalendarView = async (req, res) => {
|
||||
capacity: c.capacity || 40
|
||||
})),
|
||||
unassigned_commissions: unassignedCommissions,
|
||||
subjects: [
|
||||
{ id: 1, name: 'Arquitectura de Software', code: 'ARQ-101' },
|
||||
{ id: 2, name: 'Bases de Datos II', code: 'BD-201' },
|
||||
{ id: 3, name: 'Programación Avanzada', code: 'PRG-301' }
|
||||
],
|
||||
careers: [
|
||||
{ id: 1, name: 'Licenciatura en Sistemas' },
|
||||
{ id: 2, name: 'Tecnicatura Universitaria en Desarrollo de Software' }
|
||||
],
|
||||
subjects,
|
||||
careers,
|
||||
buildings: Array.from(buildingsMap.values()),
|
||||
available_floors: Array.from(floorsSet).sort(),
|
||||
session: { get: (k, d) => d }
|
||||
@@ -89,27 +99,34 @@ const handleCalendarData = async (req, res) => {
|
||||
if (r.status === 'PENDING') eventColor = '#F59E0B';
|
||||
else if (isVirtual) eventColor = '#6366F1';
|
||||
|
||||
const subjectName = r.subject_name || r.purpose || 'Clase Regular';
|
||||
const subjectCode = r.subject_code || '';
|
||||
const careerName = (r.commission && r.commission.career_names) || (r.commission && r.commission.career_name) || r.career_names || r.career_name || '';
|
||||
const commissionCode = (r.commission && r.commission.code) || r.commission_code || '';
|
||||
const roomName = r.classroom_name || (r.classroom ? r.classroom.code : 'Aula');
|
||||
const locationDisplay = (r.classroom && r.classroom.location_display) || (r.classroom && r.classroom.building) || r.classroom_name || 'Edificio Central';
|
||||
|
||||
return {
|
||||
id: r.id,
|
||||
title: `${r.purpose || 'Clase Regular'} - ${r.classroom_name || 'Aula'}`,
|
||||
title: `${subjectName} - ${roomName}`,
|
||||
start: r.start_time,
|
||||
end: r.end_time,
|
||||
backgroundColor: eventColor,
|
||||
borderColor: eventColor,
|
||||
extendedProps: {
|
||||
subject_name: 'Arquitectura de Software',
|
||||
subject_code: 'ARQ-101',
|
||||
classroom: r.classroom_name || 'Aula Principal',
|
||||
subject_name: subjectName,
|
||||
subject_code: subjectCode,
|
||||
classroom: roomName,
|
||||
is_virtual: isVirtual,
|
||||
location_display: r.classroom_name || 'Edificio Central',
|
||||
career: 'Licenciatura en Sistemas',
|
||||
commission: 'COM-A',
|
||||
shift: r.shift || 'Noche',
|
||||
location_display: locationDisplay,
|
||||
career: careerName,
|
||||
commission: commissionCode,
|
||||
shift: r.shift || 'Mañana',
|
||||
status: (r.status || 'CONFIRMED').toUpperCase(),
|
||||
purpose: r.purpose || 'Clase Regular',
|
||||
attendees: r.expected_attendees || 35,
|
||||
teacher: r.teacher_name || 'Profesor Titular',
|
||||
virtual_link: r.virtual_link || '',
|
||||
purpose: r.purpose || subjectName,
|
||||
attendees: r.expected_attendees || 30,
|
||||
teacher: r.teacher_name || '',
|
||||
virtual_link: r.effective_virtual_link || r.virtual_link || '',
|
||||
cancel_url: `/schedule/cancel_reservation?id=${r.id}`
|
||||
}
|
||||
};
|
||||
@@ -528,11 +545,18 @@ const handleAddReservation = async (req, res) => {
|
||||
commission_id: commissionOptions
|
||||
});
|
||||
|
||||
const classroomDataMap = {};
|
||||
classroomList.forEach(c => { classroomDataMap[c.id] = c; });
|
||||
const commissionDataMap = {};
|
||||
commissionList.forEach(c => { commissionDataMap[c.id] = c; });
|
||||
|
||||
res.render('schedule/add', {
|
||||
title: 'New Reservation - Edu-Space Admin',
|
||||
form,
|
||||
classroom_list: classroomList,
|
||||
commission_list: commissionList,
|
||||
classroom_data_json: JSON.stringify(classroomDataMap),
|
||||
commission_data_json: JSON.stringify(commissionDataMap),
|
||||
buildings: Array.from(buildingsMap.values()),
|
||||
initial_commission_id: initialCommissionId,
|
||||
initial_classroom_id: initialClassroomId
|
||||
@@ -737,12 +761,19 @@ const handleEditReservation = async (req, res) => {
|
||||
commission_id: commissionOptions
|
||||
});
|
||||
|
||||
const classroomDataMap = {};
|
||||
classroomList.forEach(c => { classroomDataMap[c.id] = c; });
|
||||
const commissionDataMap = {};
|
||||
commissionList.forEach(c => { commissionDataMap[c.id] = c; });
|
||||
|
||||
res.render('schedule/edit', {
|
||||
title: `Modificar Reserva #${id} - Edu-Space Admin`,
|
||||
reservation,
|
||||
form,
|
||||
classroom_list: classroomList,
|
||||
commission_list: commissionList,
|
||||
classroom_data_json: JSON.stringify(classroomDataMap),
|
||||
commission_data_json: JSON.stringify(commissionDataMap),
|
||||
buildings: Array.from(buildingsMap.values())
|
||||
});
|
||||
} catch (error) {
|
||||
|
||||
@@ -1127,7 +1127,7 @@
|
||||
|
||||
<div class="sidebar-footer-text mt-3 pt-2 border-top border-secondary-subtle text-center">
|
||||
<span class="badge bg-secondary-subtle text-secondary-emphasis font-monospace px-2 py-1" style="font-size:0.68rem;" title="Versión Institucional de Edu-Space">
|
||||
<i class="bi bi-tag-fill me-1"></i>v{{ app_version or '3.4.1' }} <span class="opacity-75">(FE: {{ frontend_version or '3.4.1' }} · BE: {{ backend_version or '3.4.1' }})</span>
|
||||
<i class="bi bi-tag-fill me-1"></i>v{{ app_version or '3.4.6' }} <span class="opacity-75">(FE: {{ frontend_version or '3.4.6' }} · BE: {{ backend_version or '3.4.6' }})</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -97,7 +97,7 @@
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-muted small fw-semibold">Pisos Presenciales</div>
|
||||
<h3 class="fw-bold mb-0 text-warning">{{ buildings|sum(attribute='floors') }}</h3>
|
||||
<h3 class="fw-bold mb-0 text-warning">{{ total_floors or 4 }}</h3>
|
||||
<small class="text-muted" style="font-size: 0.72rem;">Plantas físicas activas</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -97,27 +97,27 @@
|
||||
<span class="badge badge-brand">{{ classrooms|length }} aulas configuradas</span>
|
||||
</div>
|
||||
<div class="card-body p-4">
|
||||
{% if classrooms_by_floor %}
|
||||
{% for floor_num in classrooms_by_floor|sort %}
|
||||
{% if floors_list and (classrooms|length > 0) %}
|
||||
{% for fl in floors_list %}
|
||||
<div class="mb-4">
|
||||
<div class="d-flex align-items-center mb-3">
|
||||
<span class="badge bg-dark bg-opacity-75 fs-6 px-3 py-2 me-2">
|
||||
<i class="bi bi-layer-forward me-1"></i>
|
||||
{% if floor_num == 0 %}Planta Baja{% else %}Piso {{ floor_num }}{% endif %}
|
||||
{{ fl.floor_name }}
|
||||
</span>
|
||||
<div class="border-bottom flex-grow-1"></div>
|
||||
<small class="text-muted ms-2">{{ classrooms_by_floor[floor_num]|length }} aulas</small>
|
||||
<small class="text-muted ms-2">{{ fl.classrooms|length }} aula(s)</small>
|
||||
</div>
|
||||
|
||||
<div class="row g-3">
|
||||
{% for c in classrooms_by_floor[floor_num] %}
|
||||
{% for c in fl.classrooms %}
|
||||
<div class="col-md-6 col-xl-4">
|
||||
<div class="card border border-light-subtle shadow-sm h-100">
|
||||
<div class="card-body p-3">
|
||||
<div class="d-flex justify-content-between align-items-start mb-2">
|
||||
<h6 class="fw-bold mb-0">
|
||||
<a href="/classrooms/view_classroom" class="text-decoration-none text-primary">
|
||||
<i class="bi bi-door-open me-1"></i>{{ c.code }}
|
||||
<a href="/classrooms/view_classroom?id={{ c.id }}" class="text-decoration-none text-primary">
|
||||
<i class="bi bi-door-open me-1"></i>{{ c.code or c.room_number or ('Aula ' + c.id) }}
|
||||
</a>
|
||||
</h6>
|
||||
{% if c.is_active %}
|
||||
@@ -128,7 +128,7 @@
|
||||
</div>
|
||||
|
||||
<div class="small text-muted mb-2">
|
||||
<i class="bi bi-people me-1"></i>Capacidad: <strong>{{ c.capacity }}</strong> estudiantes
|
||||
<i class="bi bi-people me-1"></i>Capacidad: <strong>{{ c.capacity or 35 }}</strong> estudiantes
|
||||
</div>
|
||||
|
||||
{% if c.description %}
|
||||
@@ -136,11 +136,14 @@
|
||||
{% endif %}
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center pt-2 border-top">
|
||||
<a href="/classrooms/view_classroom" class="btn btn-outline-primary btn-sm py-0 px-2">
|
||||
<a href="/classrooms/view_classroom?id={{ c.id }}" class="btn btn-outline-primary btn-sm py-0 px-2">
|
||||
<small>Ver Ficha</small>
|
||||
</a>
|
||||
<a href="/schedule/add_reservation?classroom_id={{ c.id }}" class="btn btn-outline-success btn-sm py-0 px-2">
|
||||
<small><i class="bi bi-calendar-plus me-1"></i>Reservar</small>
|
||||
</a>
|
||||
{% if user.has_permission('classrooms', 'read_write') %}
|
||||
<a href="/classrooms/edit_classroom" class="btn btn-outline-secondary btn-sm py-0 px-2">
|
||||
<a href="/classrooms/edit_classroom?id={{ c.id }}" class="btn btn-outline-secondary btn-sm py-0 px-2">
|
||||
<small>Editar</small>
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
@@ -195,10 +195,12 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
if (!floorDatalist) return;
|
||||
floorDatalist.innerHTML = '';
|
||||
var floors = buildingFloors[bId] || [];
|
||||
floors.forEach(function(f) {
|
||||
var dynamicDefaults = ['Planta Baja (PB)', 'Entrepiso (EP)', 'Subsuelo', 'Piso 1', 'Piso 2', 'Piso 3', 'Piso 4'];
|
||||
var allOptions = Array.from(new Set([...dynamicDefaults, ...floors]));
|
||||
allOptions.forEach(function(f) {
|
||||
var opt = document.createElement('option');
|
||||
opt.value = f;
|
||||
opt.textContent = (f === '0' || f === 'PB') ? 'Planta Baja' : 'Piso ' + f;
|
||||
opt.textContent = f;
|
||||
floorDatalist.appendChild(opt);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -188,10 +188,12 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
if (!floorDatalist) return;
|
||||
floorDatalist.innerHTML = '';
|
||||
var floors = buildingFloors[bId] || [];
|
||||
floors.forEach(function(f) {
|
||||
var dynamicDefaults = ['Planta Baja (PB)', 'Entrepiso (EP)', 'Subsuelo', 'Piso 1', 'Piso 2', 'Piso 3', 'Piso 4'];
|
||||
var allOptions = Array.from(new Set([...dynamicDefaults, ...floors]));
|
||||
allOptions.forEach(function(f) {
|
||||
var opt = document.createElement('option');
|
||||
opt.value = f;
|
||||
opt.textContent = (f === '0' || f === 'PB') ? 'Planta Baja' : 'Piso ' + f;
|
||||
opt.textContent = f;
|
||||
floorDatalist.appendChild(opt);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -122,11 +122,11 @@
|
||||
{% for res in upcoming_reservations %}
|
||||
<tr>
|
||||
<td class="ps-3">
|
||||
<div class="fw-bold font-monospace text-primary fs-6 mb-1">
|
||||
<i class="bi bi-calendar-event text-primary me-1"></i>{{ res.start_time }}
|
||||
<div class="fw-bold text-primary fs-6 mb-1">
|
||||
<i class="bi bi-calendar-event text-primary me-1"></i>{{ res.date_display_friendly or res.date_display or res.start_time }}
|
||||
</div>
|
||||
<div class="small font-monospace text-body-secondary">
|
||||
<i class="bi bi-clock text-warning me-1"></i>{{ res.start_time }} - {{ res.end_time }} hs
|
||||
<div class="small text-body-secondary font-monospace">
|
||||
<i class="bi bi-clock text-warning me-1"></i>{{ res.time_range_friendly or (res.start_time_display + ' a ' + res.end_time_display + ' hs') }}
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
@@ -248,36 +248,11 @@
|
||||
|
||||
{% block extra_js %}
|
||||
<script type="application/json" id="classroom-data">
|
||||
{
|
||||
{% for c in classroom_list %}
|
||||
"{{ c.id }}": {
|
||||
"id": {{ c.id }},
|
||||
"building_id": {{ (c.building_id or 0)|tojson }},
|
||||
"building_name": {{ c.building_name|tojson }},
|
||||
"floor": {{ c.floor|tojson }},
|
||||
"floor_display": {{ c.floor_display|tojson }},
|
||||
"code": {{ c.code|tojson }},
|
||||
"code_display": {{ c.code_display|tojson }},
|
||||
"location_display": {{ c.location_display|tojson }},
|
||||
"capacity": {{ c.capacity_display|tojson }},
|
||||
"capacity_num": {{ c.capacity }},
|
||||
"is_virtual": {{ c.is_virtual|tojson }}
|
||||
}{% if not loop.last %},{% endif %}
|
||||
{% endfor %}
|
||||
}
|
||||
{{ classroom_data_json | safe }}
|
||||
</script>
|
||||
|
||||
<script type="application/json" id="commission-data">
|
||||
{
|
||||
{% for c in commission_list %}
|
||||
"{{ c.id }}": {
|
||||
"id": {{ c.id }},
|
||||
"code": {{ c.code|tojson }},
|
||||
"virtual_link": {{ (c.virtual_link or '')|tojson }},
|
||||
"max_students": {{ c.max_students }}
|
||||
}{% if not loop.last %},{% endif %}
|
||||
{% endfor %}
|
||||
}
|
||||
{{ commission_data_json | safe }}
|
||||
</script>
|
||||
|
||||
<script type="application/json" id="i18n-strings">
|
||||
@@ -386,21 +361,30 @@ $(document).ready(function() {
|
||||
// Extraer pisos únicos de este edificio
|
||||
const buildingFloors = [];
|
||||
Object.values(classroomData).forEach(c => {
|
||||
if (c.building_id == selectedBuildingId && c.floor) {
|
||||
if (!buildingFloors.some(f => f.floor === c.floor)) {
|
||||
const matchesBuilding = (String(c.building_id) === String(selectedBuildingId)) ||
|
||||
(!c.is_virtual && String(selectedBuildingId) === '1') ||
|
||||
(c.building_name && c.building_name.toLowerCase().includes('central') && String(selectedBuildingId) === '1');
|
||||
if (matchesBuilding && c.floor) {
|
||||
if (!buildingFloors.some(f => String(f.floor).toLowerCase() === String(c.floor).toLowerCase())) {
|
||||
buildingFloors.push({
|
||||
floor: c.floor,
|
||||
floor_display: c.floor_display
|
||||
floor_display: c.floor_display || `Piso ${c.floor}`
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Ordenar pisos: PB primero, luego numérico
|
||||
// Ordenar pisos: Subsuelos, PB, Entrepisos, luego numéricos
|
||||
buildingFloors.sort((a, b) => {
|
||||
if (a.floor === '0' || a.floor.toUpperCase() === 'PB') return -1;
|
||||
if (b.floor === '0' || b.floor.toUpperCase() === 'PB') return 1;
|
||||
return a.floor.localeCompare(b.floor, undefined, { numeric: true });
|
||||
const fA = String(a.floor || '').toUpperCase();
|
||||
const fB = String(b.floor || '').toUpperCase();
|
||||
if (fA.includes('SUB') || fA === 'SS') return -1;
|
||||
if (fB.includes('SUB') || fB === 'SS') return 1;
|
||||
if (fA === '0' || fA.includes('PB') || fA.includes('PLANTA BAJA')) return -1;
|
||||
if (fB === '0' || 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 });
|
||||
});
|
||||
|
||||
buildingFloors.forEach(f => {
|
||||
@@ -412,7 +396,10 @@ $(document).ready(function() {
|
||||
|
||||
// Poblar aulas de este edificio inicialmente
|
||||
Object.values(classroomData).forEach(c => {
|
||||
if (c.building_id == selectedBuildingId) {
|
||||
const matchesBuilding = (String(c.building_id) === String(selectedBuildingId)) ||
|
||||
(!c.is_virtual && String(selectedBuildingId) === '1') ||
|
||||
(c.building_name && c.building_name.toLowerCase().includes('central') && String(selectedBuildingId) === '1');
|
||||
if (matchesBuilding) {
|
||||
$classroom.append($('<option>', {
|
||||
value: c.id,
|
||||
text: `${c.code} · ${c.floor_display} (Cap: ${c.capacity})`
|
||||
@@ -434,13 +421,16 @@ $(document).ready(function() {
|
||||
let lastId = null;
|
||||
|
||||
Object.values(classroomData).forEach(c => {
|
||||
const matchesBuilding = !selectedBuildingId || c.building_id == selectedBuildingId;
|
||||
const matchesFloor = !selectedFloor || c.floor == selectedFloor;
|
||||
const matchesBuilding = !selectedBuildingId ||
|
||||
(String(c.building_id) === String(selectedBuildingId)) ||
|
||||
(!c.is_virtual && String(selectedBuildingId) === '1') ||
|
||||
(c.building_name && c.building_name.toLowerCase().includes('central') && String(selectedBuildingId) === '1');
|
||||
const matchesFloor = !selectedFloor || String(c.floor).toLowerCase() === String(selectedFloor).toLowerCase();
|
||||
|
||||
if (matchesBuilding && matchesFloor) {
|
||||
$classroom.append($('<option>', {
|
||||
value: c.id,
|
||||
text: `${c.code} (Cap: ${c.capacity})`
|
||||
text: `${c.code} · ${c.floor_display} (Cap: ${c.capacity})`
|
||||
}));
|
||||
lastId = c.id;
|
||||
count++;
|
||||
|
||||
@@ -260,36 +260,11 @@
|
||||
|
||||
{% block extra_js %}
|
||||
<script type="application/json" id="classroom-data">
|
||||
{
|
||||
{% for c in classroom_list %}
|
||||
"{{ c.id }}": {
|
||||
"id": {{ c.id }},
|
||||
"building_id": {{ (c.building_id or 0)|tojson }},
|
||||
"building_name": {{ c.building_name|tojson }},
|
||||
"floor": {{ c.floor|tojson }},
|
||||
"floor_display": {{ c.floor_display|tojson }},
|
||||
"code": {{ c.code|tojson }},
|
||||
"code_display": {{ c.code_display|tojson }},
|
||||
"location_display": {{ c.location_display|tojson }},
|
||||
"capacity": {{ c.capacity_display|tojson }},
|
||||
"capacity_num": {{ c.capacity }},
|
||||
"is_virtual": {{ c.is_virtual|tojson }}
|
||||
}{% if not loop.last %},{% endif %}
|
||||
{% endfor %}
|
||||
}
|
||||
{{ classroom_data_json | safe }}
|
||||
</script>
|
||||
|
||||
<script type="application/json" id="commission-data">
|
||||
{
|
||||
{% for c in commission_list %}
|
||||
"{{ c.id }}": {
|
||||
"id": {{ c.id }},
|
||||
"code": {{ c.code|tojson }},
|
||||
"virtual_link": {{ (c.virtual_link or '')|tojson }},
|
||||
"max_students": {{ c.max_students }}
|
||||
}{% if not loop.last %},{% endif %}
|
||||
{% endfor %}
|
||||
}
|
||||
{{ commission_data_json | safe }}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
@@ -334,15 +309,24 @@ $(document).ready(function() {
|
||||
|
||||
const floors = new Set();
|
||||
Object.values(classroomData).forEach(function(room) {
|
||||
if (String(room.building_id) === String(selectedBldg)) {
|
||||
const matchesBuilding = (String(room.building_id) === String(selectedBldg)) ||
|
||||
(!room.is_virtual && String(selectedBldg) === '1') ||
|
||||
(room.building_name && room.building_name.toLowerCase().includes('central') && String(selectedBldg) === '1');
|
||||
if (matchesBuilding && room.floor) {
|
||||
floors.add(room.floor);
|
||||
}
|
||||
});
|
||||
|
||||
const sortedFloors = Array.from(floors).sort(function(a, b) {
|
||||
if (a === '0' || a === 'PB') return -1;
|
||||
if (b === '0' || b === 'PB') return 1;
|
||||
return String(a).localeCompare(String(b), undefined, {numeric: true});
|
||||
const fA = String(a || '').toUpperCase();
|
||||
const fB = String(b || '').toUpperCase();
|
||||
if (fA.includes('SUB') || fA === 'SS') return -1;
|
||||
if (fB.includes('SUB') || fB === 'SS') return 1;
|
||||
if (fA === '0' || fA.includes('PB') || fA.includes('PLANTA BAJA')) return -1;
|
||||
if (fB === '0' || 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});
|
||||
});
|
||||
|
||||
sortedFloors.forEach(function(fl) {
|
||||
@@ -368,7 +352,12 @@ $(document).ready(function() {
|
||||
}
|
||||
|
||||
const matchingRooms = Object.values(classroomData).filter(function(room) {
|
||||
return String(room.building_id) === String(selectedBldg) && String(room.floor) === String(selectedFloor);
|
||||
const matchesBuilding = !selectedBldg ||
|
||||
(String(room.building_id) === String(selectedBldg)) ||
|
||||
(!room.is_virtual && String(selectedBldg) === '1') ||
|
||||
(room.building_name && room.building_name.toLowerCase().includes('central') && String(selectedBldg) === '1');
|
||||
const matchesFloor = String(room.floor).toLowerCase() === String(selectedFloor).toLowerCase();
|
||||
return matchesBuilding && matchesFloor;
|
||||
});
|
||||
|
||||
matchingRooms.sort(function(a, b) { return a.code.localeCompare(b.code); });
|
||||
|
||||
Reference in New Issue
Block a user