feat(ux): separate physical and virtual classroom KPIs, fix month sessions filter, improve admin contrast, persist sidebar submenus, and relocate theme toggle (v3.8.14)
This commit is contained in:
+3
-3
@@ -86,9 +86,9 @@ const env = nunjucks.configure(path.join(__dirname, '../views'), {
|
||||
});
|
||||
|
||||
// Versiones institucionales del sistema
|
||||
const APP_VERSION = '3.8.13';
|
||||
const FRONTEND_VERSION = '3.8.13';
|
||||
const BACKEND_VERSION = '3.8.13';
|
||||
const APP_VERSION = '3.8.14';
|
||||
const FRONTEND_VERSION = '3.8.14';
|
||||
const BACKEND_VERSION = '3.8.14';
|
||||
|
||||
env.addGlobal('app_version', APP_VERSION);
|
||||
env.addGlobal('frontend_version', FRONTEND_VERSION);
|
||||
|
||||
@@ -265,10 +265,77 @@ function formatReservationDates(r) {
|
||||
// 3. Vista de Lista de Reservas
|
||||
const handleReservationsList = async (req, res) => {
|
||||
try {
|
||||
const response = await req.apiClient.get('/reservations');
|
||||
const rawReservations = (response.data && response.data.reservations) || [];
|
||||
let {
|
||||
search = '',
|
||||
status = 'all',
|
||||
floor = '',
|
||||
classroom_id = '',
|
||||
shift = '',
|
||||
date_from = '',
|
||||
date_to = '',
|
||||
hide_virtual = '',
|
||||
only_virtual = '',
|
||||
scope = ''
|
||||
} = req.query;
|
||||
|
||||
// Si scope es 'month', calcular fechas del mes actual si no vienen explícitas
|
||||
const now = new Date();
|
||||
if (scope === 'month' && !date_from && !date_to) {
|
||||
const y = now.getFullYear();
|
||||
const m = String(now.getMonth() + 1).padStart(2, '0');
|
||||
const lastDay = new Date(y, now.getMonth() + 1, 0).getDate();
|
||||
date_from = `${y}-${m}-01`;
|
||||
date_to = `${y}-${m}-${String(lastDay).padStart(2, '0')}`;
|
||||
} else if (scope === 'today' && !date_from && !date_to) {
|
||||
const todayStr = now.toISOString().split('T')[0];
|
||||
date_from = todayStr;
|
||||
date_to = todayStr;
|
||||
} else if (scope === 'week' && !date_from && !date_to) {
|
||||
const day = now.getDay();
|
||||
const diff = now.getDate() - day + (day === 0 ? -6 : 1);
|
||||
const mon = new Date(now.setDate(diff));
|
||||
const sun = new Date(mon);
|
||||
sun.setDate(mon.getDate() + 6);
|
||||
date_from = mon.toISOString().split('T')[0];
|
||||
date_to = sun.toISOString().split('T')[0];
|
||||
}
|
||||
|
||||
const params = {};
|
||||
if (date_from) params.date_from = date_from;
|
||||
if (date_to) params.date_to = date_to;
|
||||
if (scope) params.scope = scope;
|
||||
if (search) params.search = search;
|
||||
if (status && status !== 'all') params.status = status;
|
||||
if (floor) params.floor = floor;
|
||||
if (classroom_id) params.classroom_id = classroom_id;
|
||||
if (shift) params.shift = shift;
|
||||
if (hide_virtual === '1' || hide_virtual === 'true') params.hide_virtual = '1';
|
||||
if (only_virtual === '1' || only_virtual === 'true') params.only_virtual = '1';
|
||||
|
||||
// Obtener reservas y catálogo de aulas en paralelo
|
||||
const [resResponse, roomsResponse] = await Promise.all([
|
||||
req.apiClient.get('/reservations', { params }).catch(err => {
|
||||
console.error('Error fetching reservations:', err.message);
|
||||
return { data: { reservations: [] } };
|
||||
}),
|
||||
req.apiClient.get('/classrooms').catch(err => {
|
||||
console.error('Error fetching classrooms for filter:', err.message);
|
||||
return { data: { classrooms: [] } };
|
||||
})
|
||||
]);
|
||||
|
||||
const rawReservations = (resResponse.data && resResponse.data.reservations) || [];
|
||||
const reservations = rawReservations.map(formatReservationDates);
|
||||
|
||||
const all_classrooms = (roomsResponse.data && roomsResponse.data.classrooms) || [];
|
||||
const floorsSet = new Set();
|
||||
all_classrooms.forEach(c => {
|
||||
if (c.floor !== undefined && c.floor !== null && c.floor !== '') {
|
||||
floorsSet.add(c.floor);
|
||||
}
|
||||
});
|
||||
const available_floors = Array.from(floorsSet).sort((a, b) => String(a).localeCompare(String(b)));
|
||||
|
||||
res.render('schedule/list', {
|
||||
title: 'Listado de Reservas - Edu-Space Admin',
|
||||
reservations: {
|
||||
@@ -280,8 +347,18 @@ const handleReservationsList = async (req, res) => {
|
||||
has_next: false,
|
||||
iter_pages: () => [1]
|
||||
},
|
||||
classrooms: [],
|
||||
subjects: [],
|
||||
search,
|
||||
status_filter: status,
|
||||
floor_filter: floor,
|
||||
classroom_id,
|
||||
shift_filter: shift,
|
||||
date_from,
|
||||
date_to,
|
||||
hide_virtual: hide_virtual === '1' || hide_virtual === 'true',
|
||||
only_virtual: only_virtual === '1' || only_virtual === 'true',
|
||||
scope,
|
||||
all_classrooms,
|
||||
available_floors,
|
||||
session: { get: (k, d) => d }
|
||||
});
|
||||
} catch (error) {
|
||||
@@ -289,8 +366,18 @@ const handleReservationsList = async (req, res) => {
|
||||
res.render('schedule/list', {
|
||||
title: 'Listado de Reservas (Offline)',
|
||||
reservations: { items: [], total: 0, pages: 1, page: 1, has_prev: false, has_next: false, iter_pages: () => [1] },
|
||||
classrooms: [],
|
||||
subjects: [],
|
||||
search: '',
|
||||
status_filter: 'all',
|
||||
floor_filter: '',
|
||||
classroom_id: '',
|
||||
shift_filter: '',
|
||||
date_from: '',
|
||||
date_to: '',
|
||||
hide_virtual: false,
|
||||
only_virtual: false,
|
||||
scope: '',
|
||||
all_classrooms: [],
|
||||
available_floors: [],
|
||||
session: { get: (k, d) => d }
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user