feat(sheets): refactor google sheets importer with granular entities and interactive preview grid v3.4.3
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "frontend",
|
||||
"version": "3.4.2",
|
||||
"version": "3.4.3",
|
||||
"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.2';
|
||||
const FRONTEND_VERSION = '3.4.2';
|
||||
const BACKEND_VERSION = '3.4.2';
|
||||
const APP_VERSION = '3.4.3';
|
||||
const FRONTEND_VERSION = '3.4.3';
|
||||
const BACKEND_VERSION = '3.4.3';
|
||||
|
||||
env.addGlobal('app_version', APP_VERSION);
|
||||
env.addGlobal('frontend_version', FRONTEND_VERSION);
|
||||
|
||||
@@ -91,10 +91,28 @@ const handleGoogleSheetsImport = async (req, res, justSynced = false) => {
|
||||
if (req.body.filter_career) syncPayload.filter_career = req.body.filter_career.trim();
|
||||
if (req.body.filter_subject) syncPayload.filter_subject = req.body.filter_subject.trim();
|
||||
if (req.body.filter_day) syncPayload.filter_day = req.body.filter_day.trim();
|
||||
if (req.body.filter_days) {
|
||||
syncPayload.filter_days = Array.isArray(req.body.filter_days) ? req.body.filter_days : [req.body.filter_days];
|
||||
}
|
||||
if (req.body.manual_date) syncPayload.manual_date = req.body.manual_date.trim();
|
||||
if (req.body.single_date_only === 'true' || req.body.single_date_only === true || req.body.single_date_only === 'on') {
|
||||
syncPayload.single_date_only = true;
|
||||
}
|
||||
// Toggles granulares de entidades
|
||||
syncPayload.import_careers = req.body.import_careers === 'true' || req.body.import_careers === true || req.body.import_careers === 'on';
|
||||
syncPayload.import_subjects = req.body.import_subjects === 'true' || req.body.import_subjects === true || req.body.import_subjects === 'on';
|
||||
syncPayload.import_commissions = req.body.import_commissions === 'true' || req.body.import_commissions === true || req.body.import_commissions === 'on';
|
||||
syncPayload.import_classrooms = req.body.import_classrooms === 'true' || req.body.import_classrooms === true || req.body.import_classrooms === 'on';
|
||||
syncPayload.import_reservations = req.body.import_reservations === 'true' || req.body.import_reservations === true || req.body.import_reservations === 'on';
|
||||
|
||||
// Filas preseleccionadas desde la grilla interactiva
|
||||
if (req.body.selected_rows_json) {
|
||||
try {
|
||||
syncPayload.selected_rows = JSON.parse(req.body.selected_rows_json);
|
||||
} catch (e) {
|
||||
console.warn('Could not parse selected_rows_json:', e.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
const syncRes = await req.apiClient.post('/dashboard/sync-sheets', syncPayload, { timeout: 90000 });
|
||||
if (syncRes.data && syncRes.data.stats) {
|
||||
@@ -143,6 +161,7 @@ const handleGoogleSheetsImport = async (req, res, justSynced = false) => {
|
||||
filter_career: req.body?.filter_career || '',
|
||||
filter_subject: req.body?.filter_subject || '',
|
||||
filter_day: req.body?.filter_day || '',
|
||||
filter_days: req.body?.filter_days || ['Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado'],
|
||||
manual_date: req.body?.manual_date || '',
|
||||
single_date_only: req.body?.single_date_only === 'true' || req.body?.single_date_only === 'on',
|
||||
flash_msg: flashMsg,
|
||||
@@ -161,10 +180,15 @@ router.post(['/google_sheets_import', '/import'], (req, res) => handleGoogleShee
|
||||
router.post('/sheets_inspect', async (req, res) => {
|
||||
try {
|
||||
const payload = {};
|
||||
if (req.body && req.body.sheets_url) {
|
||||
payload.sheets_url = req.body.sheets_url;
|
||||
if (req.body) {
|
||||
if (req.body.sheets_url) payload.sheets_url = req.body.sheets_url;
|
||||
if (req.body.filter_career) payload.filter_career = req.body.filter_career;
|
||||
if (req.body.filter_subject) payload.filter_subject = req.body.filter_subject;
|
||||
if (req.body.filter_day) payload.filter_day = req.body.filter_day;
|
||||
if (req.body.filter_days) payload.filter_days = req.body.filter_days;
|
||||
if (req.body.manual_date) payload.manual_date = req.body.manual_date;
|
||||
}
|
||||
const resp = await req.apiClient.post('/dashboard/sheets-inspect', payload, { timeout: 35000 });
|
||||
const resp = await req.apiClient.post('/dashboard/sheets-inspect', payload, { timeout: 45000 });
|
||||
res.json(resp.data);
|
||||
} catch (err) {
|
||||
console.error('Error inspecting sheets in BFF:', err.response?.data || err.message);
|
||||
|
||||
@@ -168,29 +168,107 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form method="POST" id="syncForm" action="/admin/google_sheets_import" onsubmit="startSync()">
|
||||
<form method="POST" id="syncForm" action="/admin/google_sheets_import">
|
||||
<input type="hidden" name="sheets_url" id="syncSheetsUrl" value="{{ sheets_config.active_url }}">
|
||||
<input type="hidden" name="selected_rows_json" id="selected_rows_json" value="">
|
||||
|
||||
<div class="row g-3 mb-4">
|
||||
<!-- 1. Filtro por Día -->
|
||||
<div class="col-md-6 col-lg-3">
|
||||
<label for="filter_day" class="form-label fw-semibold small">
|
||||
<i class="bi bi-calendar3 me-1 text-primary"></i>Día de Cursada:
|
||||
<!-- 1. Selección Granular de Entidades a Sincronizar (Estilo Tarjetas Checkbox) -->
|
||||
<div class="mb-4">
|
||||
<div class="d-flex flex-wrap justify-content-between align-items-center mb-2 gap-2">
|
||||
<label class="form-label fw-bold small text-uppercase text-secondary mb-0">
|
||||
<i class="bi bi-check2-square text-success me-1"></i>1. Entidades a Importar / Sincronizar:
|
||||
</label>
|
||||
<select name="filter_day" id="filter_day" class="form-select form-select-sm">
|
||||
<option value="" {% if not filter_day or filter_day == 'ALL' %}selected{% endif %}>Todos los Días (Lunes a Sábado)</option>
|
||||
<option value="Lunes" {% if filter_day == 'Lunes' %}selected{% endif %}>Lunes</option>
|
||||
<option value="Martes" {% if filter_day == 'Martes' %}selected{% endif %}>Martes</option>
|
||||
<option value="Miércoles" {% if filter_day == 'Miércoles' or filter_day == 'Miercoles' %}selected{% endif %}>Miércoles</option>
|
||||
<option value="Jueves" {% if filter_day == 'Jueves' %}selected{% endif %}>Jueves</option>
|
||||
<option value="Viernes" {% if filter_day == 'Viernes' %}selected{% endif %}>Viernes</option>
|
||||
<option value="Sábado" {% if filter_day == 'Sábado' or filter_day == 'Sabado' %}selected{% endif %}>Sábado</option>
|
||||
</select>
|
||||
<div class="form-text small">Procesa solo la pestaña del día indicado.</div>
|
||||
<div class="btn-group btn-group-sm" role="group">
|
||||
<button type="button" class="btn btn-outline-secondary py-0 px-2" onclick="toggleImportEntities(true)">
|
||||
<i class="bi bi-check-all me-1"></i>Marcar Todo
|
||||
</button>
|
||||
<button type="button" class="btn btn-outline-secondary py-0 px-2" onclick="toggleImportEntities(false)">
|
||||
<i class="bi bi-dash-square me-1"></i>Desmarcar Todo
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row g-2">
|
||||
<div class="col-sm-6 col-lg">
|
||||
<div class="form-check p-2 border rounded bg-body-tertiary h-100 shadow-sm-sm">
|
||||
<input class="form-check-input ms-1 me-2 import-entity-chk" type="checkbox" name="import_reservations" id="chk_import_reservations" value="true" checked>
|
||||
<label class="form-check-label fw-semibold small" for="chk_import_reservations">
|
||||
<i class="bi bi-calendar-check text-danger me-1"></i>Asignaciones (Reservas)
|
||||
<small class="d-block text-muted fw-normal">Clases y horarios en calendario.</small>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-lg">
|
||||
<div class="form-check p-2 border rounded bg-body-tertiary h-100 shadow-sm-sm">
|
||||
<input class="form-check-input ms-1 me-2 import-entity-chk" type="checkbox" name="import_classrooms" id="chk_import_classrooms" value="true" checked>
|
||||
<label class="form-check-label fw-semibold small" for="chk_import_classrooms">
|
||||
<i class="bi bi-door-open text-success me-1"></i>Aulas Físicas y Virtuales
|
||||
<small class="d-block text-muted fw-normal">Aulas presenciales y Zoom/PB.</small>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-lg">
|
||||
<div class="form-check p-2 border rounded bg-body-tertiary h-100 shadow-sm-sm">
|
||||
<input class="form-check-input ms-1 me-2 import-entity-chk" type="checkbox" name="import_commissions" id="chk_import_commissions" value="true" checked>
|
||||
<label class="form-check-label fw-semibold small" for="chk_import_commissions">
|
||||
<i class="bi bi-diagram-3 text-warning me-1"></i>Comisiones de Cursada
|
||||
<small class="d-block text-muted fw-normal">Turnos y comisiones académicas.</small>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-lg">
|
||||
<div class="form-check p-2 border rounded bg-body-tertiary h-100 shadow-sm-sm">
|
||||
<input class="form-check-input ms-1 me-2 import-entity-chk" type="checkbox" name="import_subjects" id="chk_import_subjects" value="true" checked>
|
||||
<label class="form-check-label fw-semibold small" for="chk_import_subjects">
|
||||
<i class="bi bi-book text-info me-1"></i>Asignaturas / Materias
|
||||
<small class="d-block text-muted fw-normal">Catálogo de materias curriculares.</small>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-lg">
|
||||
<div class="form-check p-2 border rounded bg-body-tertiary h-100 shadow-sm-sm">
|
||||
<input class="form-check-input ms-1 me-2 import-entity-chk" type="checkbox" name="import_careers" id="chk_import_careers" value="true" checked>
|
||||
<label class="form-check-label fw-semibold small" for="chk_import_careers">
|
||||
<i class="bi bi-mortarboard text-primary me-1"></i>Carreras Académicas
|
||||
<small class="d-block text-muted fw-normal">Planes de estudio y carreras.</small>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 2. Filtro por Carrera -->
|
||||
<div class="col-md-6 col-lg-3">
|
||||
<!-- 2. Selección de Días de la Semana (Checkboxes Múltiples) -->
|
||||
<div class="mb-4">
|
||||
<div class="p-3 border rounded bg-body-tertiary">
|
||||
<div class="d-flex flex-wrap justify-content-between align-items-center mb-2 gap-2">
|
||||
<label class="form-label fw-bold small text-uppercase text-secondary mb-0">
|
||||
<i class="bi bi-calendar3 text-primary me-1"></i>2. Días de la Semana a Procesar:
|
||||
</label>
|
||||
<div class="btn-group btn-group-sm" role="group">
|
||||
<button type="button" class="btn btn-outline-primary py-0 px-2" onclick="setDaysSelection('all')">Todos</button>
|
||||
<button type="button" class="btn btn-outline-secondary py-0 px-2" onclick="setDaysSelection('workdays')">Lun a Vie</button>
|
||||
<button type="button" class="btn btn-outline-secondary py-0 px-2" onclick="setDaysSelection('none')">Limpiar</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex flex-wrap gap-2" id="daysCheckboxesContainer">
|
||||
{% set all_days = ['Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado'] %}
|
||||
{% for d in all_days %}
|
||||
<div class="form-check form-check-inline border rounded px-3 py-1 bg-white shadow-sm mb-0">
|
||||
<input class="form-check-input filter-day-chk" type="checkbox" name="filter_days" id="day_chk_{{ loop.index }}" value="{{ d }}"
|
||||
{% if not filter_days or (d in filter_days) or (filter_day and (filter_day == d or filter_day == 'ALL')) %}checked{% endif %}>
|
||||
<label class="form-check-label small fw-semibold cursor-pointer" for="day_chk_{{ loop.index }}">{{ d }}</label>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="form-text small mt-1">
|
||||
<i class="bi bi-info-circle me-1"></i>Tilde uno o varios días específicos. Al inspeccionar o sincronizar se consultarán exclusivamente las pestañas seleccionadas.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 3. Filtros Específicos y Control de Fecha -->
|
||||
<div class="row g-3 mb-4">
|
||||
<!-- Filtro por Carrera -->
|
||||
<div class="col-md-4">
|
||||
<label for="filter_career" class="form-label fw-semibold small">
|
||||
<i class="bi bi-mortarboard me-1 text-primary"></i>Carrera Académica:
|
||||
</label>
|
||||
@@ -202,11 +280,11 @@
|
||||
<option value="{{ c.name if c.name else c }}"></option>
|
||||
{% endfor %}
|
||||
</datalist>
|
||||
<div class="form-text small">Coincidencia exacta o compartida.</div>
|
||||
<div class="form-text small">Coincidencia en materia principal o compartida.</div>
|
||||
</div>
|
||||
|
||||
<!-- 3. Filtro por Materia -->
|
||||
<div class="col-md-6 col-lg-3">
|
||||
<!-- Filtro por Materia -->
|
||||
<div class="col-md-4">
|
||||
<label for="filter_subject" class="form-label fw-semibold small">
|
||||
<i class="bi bi-book me-1 text-primary"></i>Materia / Asignatura:
|
||||
</label>
|
||||
@@ -218,33 +296,36 @@
|
||||
<option value="{{ s.code }} - {{ s.name }}"></option>
|
||||
{% endfor %}
|
||||
</datalist>
|
||||
<div class="form-text small">Busca por código o nombre de materia.</div>
|
||||
<div class="form-text small">Busca por código o nombre curricular.</div>
|
||||
</div>
|
||||
|
||||
<!-- 4. Fecha Manual y Control Puntual -->
|
||||
<div class="col-md-6 col-lg-3">
|
||||
<!-- Fecha Manual y Control Puntual -->
|
||||
<div class="col-md-4">
|
||||
<label for="manual_date" class="form-label fw-semibold small">
|
||||
<i class="bi bi-calendar-event me-1 text-danger"></i>Fecha Manual (Corrección):
|
||||
<i class="bi bi-calendar-event me-1 text-danger"></i>Fecha Manual Sugerida:
|
||||
</label>
|
||||
<input type="date" name="manual_date" id="manual_date" class="form-control form-control-sm"
|
||||
value="{{ manual_date }}">
|
||||
<div class="form-text small">Asigna/fuerza una fecha si falta en el Sheet.</div>
|
||||
<div class="form-text small">Fecha por defecto para registros sin fecha inferida.</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Opciones adicionales de Fecha Manual -->
|
||||
<!-- Opciones de Cursada y Acciones Principales -->
|
||||
<div class="p-3 bg-body-tertiary rounded border mb-4">
|
||||
<div class="d-flex flex-wrap justify-content-between align-items-center gap-2">
|
||||
<div class="d-flex flex-wrap justify-content-between align-items-center gap-3">
|
||||
<div class="form-check form-switch mb-0">
|
||||
<input class="form-check-input" type="checkbox" role="switch" id="single_date_only" name="single_date_only" value="true" {% if single_date_only %}checked{% endif %}>
|
||||
<label class="form-check-label fw-semibold small" for="single_date_only">
|
||||
<i class="bi bi-pin-angle-fill text-warning me-1"></i>Importar ÚNICAMENTE para esta fecha puntual
|
||||
<i class="bi bi-pin-angle-fill text-warning me-1"></i>Importar ÚNICAMENTE para fecha puntual
|
||||
</label>
|
||||
<span class="d-block text-muted small">Crea 1 sola asignación/reserva en el calendario en lugar del cuatrimestre regular (16 semanas). Requiere indicar Fecha Manual.</span>
|
||||
<span class="d-block text-muted small">Crea 1 sola asignación por fila en lugar del cuatrimestre regular (16 semanas).</span>
|
||||
</div>
|
||||
<div class="d-flex gap-2">
|
||||
<button type="submit" id="syncBtn" class="btn btn-success px-4 py-2 shadow-sm fw-semibold">
|
||||
<i class="bi bi-arrow-repeat me-2"></i>Iniciar Sincronización
|
||||
<button type="button" class="btn btn-outline-primary px-3 shadow-sm fw-semibold" id="btnInspectSheet" onclick="inspectOnlineSheets()">
|
||||
<i class="bi bi-search me-1"></i><span id="inspectBtnText">Inspeccionar Sheet Online</span>
|
||||
</button>
|
||||
<button type="button" id="syncBtn" class="btn btn-success px-4 shadow-sm fw-semibold" onclick="openSyncConfirmModal()">
|
||||
<i class="bi bi-arrow-repeat me-1"></i>Iniciar Sincronización
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -256,6 +337,93 @@
|
||||
<strong>Conectando a Google Sheets y sincronizando registros según filtros seleccionados...</strong>
|
||||
</div>
|
||||
|
||||
<!-- 4. Grilla de Inspección Previa (Pre-visualización Interactiva) -->
|
||||
<div id="previewSection" class="card border border-primary border-opacity-25 shadow-sm mb-4 d-none">
|
||||
<div class="card-header bg-primary bg-opacity-10 py-3 d-flex flex-wrap justify-content-between align-items-center gap-2">
|
||||
<div>
|
||||
<h6 class="mb-0 fw-bold text-primary">
|
||||
<i class="bi bi-table me-2"></i>Grilla de Inspección Previa (Previsualización Interactiva)
|
||||
</h6>
|
||||
<small class="text-muted">Revise, deseleccione filas individuales y ajuste las fechas de cursada antes de confirmar la subida.</small>
|
||||
</div>
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
<span class="badge bg-white text-dark border">
|
||||
Total detectado: <strong id="previewTotalCount">0</strong>
|
||||
</span>
|
||||
<span class="badge bg-success text-white">
|
||||
Seleccionados: <strong id="previewSelectedCount">0</strong>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body p-3">
|
||||
<!-- Barra de Controles de la Grilla -->
|
||||
<div class="row g-2 align-items-center mb-3">
|
||||
<div class="col-md-5">
|
||||
<div class="input-group input-group-sm">
|
||||
<span class="input-group-text bg-white"><i class="bi bi-search"></i></span>
|
||||
<input type="text" id="previewSearchInput" class="form-control" placeholder="Buscar por código, materia, carrera o aula..." oninput="onPreviewSearch()">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="input-group input-group-sm">
|
||||
<span class="input-group-text bg-white small"><i class="bi bi-calendar-event me-1"></i>Fecha masiva:</span>
|
||||
<input type="date" id="bulkDateInput" class="form-control">
|
||||
<button type="button" class="btn btn-outline-secondary" onclick="applyBulkDate()" title="Aplica esta fecha a todos los registros seleccionados">
|
||||
Aplicar
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3 text-end">
|
||||
<div class="btn-group btn-group-sm" role="group">
|
||||
<button type="button" class="btn btn-outline-secondary" onclick="toggleSelectAllFiltered(true)">Marcar Todos</button>
|
||||
<button type="button" class="btn btn-outline-secondary" onclick="toggleSelectAllFiltered(false)">Desmarcar</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Tabla de Previsualización -->
|
||||
<div class="table-responsive border rounded mb-3" style="max-height: 520px; overflow-y: auto;">
|
||||
<table class="table table-hover table-striped align-middle mb-0 small" id="previewTable">
|
||||
<thead class="table-light sticky-top shadow-sm">
|
||||
<tr>
|
||||
<th class="text-center" style="width: 40px;">
|
||||
<input class="form-check-input" type="checkbox" id="chkSelectAllPreview" onchange="toggleMasterPreviewCheckbox(this.checked)" checked title="Seleccionar/Deseleccionar todos">
|
||||
</th>
|
||||
<th style="width: 50px;">#</th>
|
||||
<th style="width: 100px;">Día</th>
|
||||
<th style="width: 110px;">Turno / Horario</th>
|
||||
<th>Código & Asignatura</th>
|
||||
<th>Carrera(s)</th>
|
||||
<th style="width: 150px;">Aula Detectada</th>
|
||||
<th style="width: 175px;">Fecha Cursada (Editable)</th>
|
||||
<th style="width: 130px;">Estado</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="previewTableBody">
|
||||
<!-- Poblado dinámicamente con JavaScript -->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Paginación y Resumen -->
|
||||
<div class="d-flex flex-wrap justify-content-between align-items-center gap-2">
|
||||
<div class="small text-muted" id="previewPaginationInfo">
|
||||
Mostrando registros 1-25
|
||||
</div>
|
||||
<nav aria-label="Navegación de previsualización">
|
||||
<ul class="pagination pagination-sm mb-0" id="previewPaginationNav">
|
||||
<!-- Botones de paginación generados por JS -->
|
||||
</ul>
|
||||
</nav>
|
||||
<div>
|
||||
<button type="button" class="btn btn-sm btn-success px-3 shadow-sm fw-semibold" onclick="openSyncConfirmModal()">
|
||||
<i class="bi bi-arrow-repeat me-1"></i>Confirmar Sincronización (<span id="previewSelectedCountBtn">0</span>)
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Etiquetas de Días cubiertos en cartelera -->
|
||||
<div class="d-flex flex-wrap align-items-center gap-1 pt-2 border-top">
|
||||
<span class="small text-muted me-2">Hojas de cursada configuradas:</span>
|
||||
@@ -600,32 +768,79 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal: Confirmación de Sincronización Académica -->
|
||||
<div class="modal fade" id="syncConfirmModal" tabindex="-1" aria-labelledby="syncConfirmModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content border-0 shadow-lg">
|
||||
<div class="modal-header bg-success text-white py-3">
|
||||
<h5 class="modal-title h6 fw-bold" id="syncConfirmModalLabel">
|
||||
<i class="bi bi-cloud-arrow-up-fill me-2"></i>Confirmar Sincronización Académica
|
||||
</h5>
|
||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body p-4">
|
||||
<p class="mb-2 text-body">
|
||||
¿Desea iniciar el procesamiento y sincronización de datos con el siguiente alcance?
|
||||
</p>
|
||||
<div class="p-3 bg-body-tertiary border rounded mb-3 small" id="syncConfirmDetails">
|
||||
<!-- Poblado dinámicamente -->
|
||||
</div>
|
||||
<div class="alert alert-info small mb-0 d-flex gap-2 align-items-start">
|
||||
<i class="bi bi-info-circle-fill fs-5 text-info flex-shrink-0"></i>
|
||||
<div>
|
||||
<strong>Nota:</strong> Los registros se validarán contra la matriz de disponibilidad. Las fechas editadas en la grilla se aplicarán a cada asignación individual.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer bg-body-tertiary border-top py-2">
|
||||
<button type="button" class="btn btn-outline-secondary btn-sm" data-bs-dismiss="modal">Cancelar</button>
|
||||
<button type="button" class="btn btn-success btn-sm px-4 fw-semibold" id="btnDoSyncConfirm" onclick="confirmSyncSubmission()">
|
||||
<i class="bi bi-check2-circle me-1"></i>Sí, Iniciar Sincronización
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_js %}
|
||||
<script>
|
||||
function startSync() {
|
||||
const btn = document.getElementById('syncBtn');
|
||||
const spinner = document.getElementById('syncSpinner');
|
||||
const urlInput = document.getElementById('google_sheets_url');
|
||||
const syncUrlInput = document.getElementById('syncSheetsUrl');
|
||||
// Variables globales para el manejo de la previsualización interactiva
|
||||
window.inspectedRows = [];
|
||||
window.previewCurrentPage = 1;
|
||||
window.previewPageSize = 25;
|
||||
window.previewSearchTerm = '';
|
||||
|
||||
if (urlInput && syncUrlInput) {
|
||||
syncUrlInput.value = urlInput.value.trim();
|
||||
}
|
||||
|
||||
if (btn) {
|
||||
btn.disabled = true;
|
||||
btn.innerHTML = '<span class="spinner-border spinner-border-sm me-2" role="status"></span>Sincronizando con Google Sheets...';
|
||||
}
|
||||
if (spinner) {
|
||||
spinner.classList.remove('d-none');
|
||||
}
|
||||
// Gestión de Entidades
|
||||
function toggleImportEntities(checked) {
|
||||
document.querySelectorAll('.import-entity-chk').forEach(el => el.checked = checked);
|
||||
}
|
||||
|
||||
// Gestión de Días de la Semana
|
||||
function setDaysSelection(mode) {
|
||||
const chks = document.querySelectorAll('.filter-day-chk');
|
||||
chks.forEach(el => {
|
||||
if (mode === 'all') {
|
||||
el.checked = true;
|
||||
} else if (mode === 'none') {
|
||||
el.checked = false;
|
||||
} else if (mode === 'workdays') {
|
||||
el.checked = (el.value !== 'Sábado' && el.value !== 'Sabado');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getSelectedDays() {
|
||||
const selected = [];
|
||||
document.querySelectorAll('.filter-day-chk:checked').forEach(el => {
|
||||
selected.push(el.value);
|
||||
});
|
||||
return selected;
|
||||
}
|
||||
|
||||
// Limpieza de Filtros
|
||||
function clearFilters() {
|
||||
const d = document.getElementById('filter_day');
|
||||
if (d) d.value = '';
|
||||
const c = document.getElementById('filter_career');
|
||||
if (c) c.value = '';
|
||||
const s = document.getElementById('filter_subject');
|
||||
@@ -634,22 +849,40 @@
|
||||
if (m) m.value = '';
|
||||
const single = document.getElementById('single_date_only');
|
||||
if (single) single.checked = false;
|
||||
setDaysSelection('all');
|
||||
}
|
||||
|
||||
// Restaurar URL oficial
|
||||
function restoreDefaultUrl() {
|
||||
const defaultUrl = "{{ sheets_config.default_url }}";
|
||||
const input = document.getElementById('google_sheets_url');
|
||||
if (input && defaultUrl) {
|
||||
input.value = defaultUrl;
|
||||
}
|
||||
}
|
||||
|
||||
// Inspección Online del Sheet
|
||||
async function inspectOnlineSheets() {
|
||||
const btn = document.getElementById('btnInspectSheet');
|
||||
const btnText = document.getElementById('inspectBtnText');
|
||||
const alertBox = document.getElementById('inspectAlert');
|
||||
const alertMsg = document.getElementById('inspectAlertMsg');
|
||||
const urlInput = document.getElementById('google_sheets_url');
|
||||
const previewSec = document.getElementById('previewSection');
|
||||
|
||||
if (btn) btn.disabled = true;
|
||||
if (btnText) btnText.innerText = 'Inspeccionando...';
|
||||
|
||||
try {
|
||||
const selectedDays = getSelectedDays();
|
||||
const payload = {
|
||||
sheets_url: urlInput ? urlInput.value.trim() : ''
|
||||
sheets_url: urlInput ? urlInput.value.trim() : '',
|
||||
filter_career: (document.getElementById('filter_career')?.value || '').trim(),
|
||||
filter_subject: (document.getElementById('filter_subject')?.value || '').trim(),
|
||||
filter_days: selectedDays,
|
||||
manual_date: (document.getElementById('manual_date')?.value || '').trim()
|
||||
};
|
||||
|
||||
const resp = await fetch('/admin/sheets_inspect', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
@@ -659,7 +892,8 @@
|
||||
|
||||
if (data.status === 'success' && data.metadata) {
|
||||
const meta = data.metadata;
|
||||
// Poblar datalists dinámicamente con carreras del Sheet online
|
||||
|
||||
// Actualizar datalist de Carreras
|
||||
const careersList = document.getElementById('careersDataList');
|
||||
if (careersList && meta.careers) {
|
||||
careersList.innerHTML = '';
|
||||
@@ -670,7 +904,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
// Poblar datalists dinámicamente con materias del Sheet online
|
||||
// Actualizar datalist de Materias
|
||||
const subjectsList = document.getElementById('subjectsDataList');
|
||||
if (subjectsList && meta.subjects) {
|
||||
subjectsList.innerHTML = '';
|
||||
@@ -681,11 +915,33 @@
|
||||
});
|
||||
}
|
||||
|
||||
// Cargar filas en memoria para la grilla interactiva
|
||||
const rawRows = meta.preview_rows || [];
|
||||
window.inspectedRows = rawRows.map(function(r) {
|
||||
return Object.assign({}, r, {
|
||||
selected: r.is_valid !== false,
|
||||
date: r.inferred_date || document.getElementById('manual_date')?.value || ''
|
||||
});
|
||||
});
|
||||
|
||||
// Mostrar Alert resumen
|
||||
if (alertBox && alertMsg) {
|
||||
alertBox.className = 'alert alert-success border-0 shadow-sm mb-4';
|
||||
alertMsg.innerHTML = '<strong>Inspección completada con éxito:</strong> Se detectaron <strong>' + (meta.total_rows || 0) + ' filas</strong>, <strong>' + (meta.careers ? meta.careers.length : 0) + ' carreras</strong> y <strong>' + (meta.subjects ? meta.subjects.length : 0) + ' materias</strong> disponibles en el Sheet online. Las sugerencias se han cargado en los campos de filtro.';
|
||||
alertMsg.innerHTML = '<strong>Inspección completada con éxito:</strong> Se detectaron <strong>' +
|
||||
(meta.total_rows || 0) + ' filas procesables</strong>, <strong>' +
|
||||
(meta.careers ? meta.careers.length : 0) + ' carreras</strong> y <strong>' +
|
||||
(meta.subjects ? meta.subjects.length : 0) + ' materias</strong> en los días seleccionados (' +
|
||||
(selectedDays.join(', ') || 'Todos') + '). Revise los registros en la grilla inferior.';
|
||||
alertBox.classList.remove('d-none');
|
||||
}
|
||||
|
||||
// Desplegar y renderizar la grilla
|
||||
if (previewSec) {
|
||||
previewSec.classList.remove('d-none');
|
||||
window.previewCurrentPage = 1;
|
||||
renderPreview();
|
||||
previewSec.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
}
|
||||
} else {
|
||||
throw new Error(data.message || 'No se pudieron extraer datos del Sheet online.');
|
||||
}
|
||||
@@ -701,14 +957,320 @@
|
||||
}
|
||||
}
|
||||
|
||||
function restoreDefaultUrl() {
|
||||
const defaultUrl = "{{ sheets_config.default_url }}";
|
||||
const input = document.getElementById('google_sheets_url');
|
||||
if (input && defaultUrl) {
|
||||
input.value = defaultUrl;
|
||||
// Filtro de búsqueda en la grilla
|
||||
function onPreviewSearch() {
|
||||
const inp = document.getElementById('previewSearchInput');
|
||||
window.previewSearchTerm = (inp ? inp.value : '').toLowerCase().trim();
|
||||
window.previewCurrentPage = 1;
|
||||
renderPreview();
|
||||
}
|
||||
|
||||
function getFilteredRows() {
|
||||
if (!window.previewSearchTerm) {
|
||||
return window.inspectedRows;
|
||||
}
|
||||
const term = window.previewSearchTerm;
|
||||
return window.inspectedRows.filter(function(r) {
|
||||
const str = [
|
||||
r.dia || '',
|
||||
r.codigo || '',
|
||||
r.asignatura || '',
|
||||
r.carrera || '',
|
||||
(r.carreras_list || []).join(' '),
|
||||
r.aula || '',
|
||||
r.horario || '',
|
||||
r.turno || ''
|
||||
].join(' ').toLowerCase();
|
||||
return str.indexOf(term) !== -1;
|
||||
});
|
||||
}
|
||||
|
||||
// Renderizado dinámico de la Grilla Interactiva
|
||||
function renderPreview() {
|
||||
const tbody = document.getElementById('previewTableBody');
|
||||
if (!tbody) return;
|
||||
|
||||
const filtered = getFilteredRows();
|
||||
const totalFiltered = filtered.length;
|
||||
const totalAll = window.inspectedRows.length;
|
||||
const selectedCount = window.inspectedRows.filter(r => r.selected).length;
|
||||
|
||||
// Actualizar contadores
|
||||
const totalCountEl = document.getElementById('previewTotalCount');
|
||||
const selCountEl = document.getElementById('previewSelectedCount');
|
||||
const selCountBtnEl = document.getElementById('previewSelectedCountBtn');
|
||||
if (totalCountEl) totalCountEl.innerText = totalAll;
|
||||
if (selCountEl) selCountEl.innerText = selectedCount;
|
||||
if (selCountBtnEl) selCountBtnEl.innerText = selectedCount;
|
||||
|
||||
// Paginación
|
||||
const totalPages = Math.max(1, Math.ceil(totalFiltered / window.previewPageSize));
|
||||
if (window.previewCurrentPage > totalPages) window.previewCurrentPage = totalPages;
|
||||
const startIdx = (window.previewCurrentPage - 1) * window.previewPageSize;
|
||||
const pageRows = filtered.slice(startIdx, startIdx + window.previewPageSize);
|
||||
|
||||
if (pageRows.length === 0) {
|
||||
tbody.innerHTML = '<tr><td colspan="9" class="text-center py-4 text-muted">' +
|
||||
'<i class="bi bi-search fs-3 d-block mb-1 text-secondary"></i>' +
|
||||
'No se encontraron registros que coincidan con la búsqueda.</td></tr>';
|
||||
renderPreviewPagination(totalFiltered, totalPages);
|
||||
return;
|
||||
}
|
||||
|
||||
let html = '';
|
||||
pageRows.forEach(function(row, idx) {
|
||||
const globalIdx = startIdx + idx + 1;
|
||||
const isInvalid = (row.is_valid === false);
|
||||
const hasWarning = (row.has_warning === true);
|
||||
const rowClass = isInvalid ? 'table-danger' : (hasWarning ? 'table-warning' : '');
|
||||
|
||||
// Badge de Aula
|
||||
let aulaBadge = '';
|
||||
if (row.is_virtual) {
|
||||
aulaBadge = '<span class="badge bg-info-subtle text-info border border-info-subtle"><i class="bi bi-camera-video me-1"></i>' + (row.aula || 'Virtual') + '</span>';
|
||||
} else if (row.aula) {
|
||||
aulaBadge = '<span class="badge bg-secondary-subtle text-secondary border"><i class="bi bi-door-open me-1"></i>' + row.aula + '</span>';
|
||||
} else {
|
||||
aulaBadge = '<span class="badge bg-warning-subtle text-warning border border-warning-subtle"><i class="bi bi-question-circle me-1"></i>Sin Aula</span>';
|
||||
}
|
||||
|
||||
// Badge de Estado
|
||||
let estadoBadge = '';
|
||||
if (isInvalid) {
|
||||
estadoBadge = '<span class="badge bg-danger text-white"><i class="bi bi-x-circle me-1"></i>Inválido</span>';
|
||||
} else if (hasWarning) {
|
||||
estadoBadge = '<span class="badge bg-warning-subtle text-dark border border-warning-subtle" title="' + (row.warning_msg || 'Advertencia') + '"><i class="bi bi-exclamation-triangle me-1"></i>' + (row.warning_msg || 'Alerta') + '</span>';
|
||||
} else {
|
||||
estadoBadge = '<span class="badge bg-success-subtle text-success border border-success-subtle"><i class="bi bi-check-circle me-1"></i>Listo</span>';
|
||||
}
|
||||
|
||||
// Carrera format
|
||||
const carText = (row.carreras_list && row.carreras_list.length > 0) ? row.carreras_list.join(', ') : (row.carrera || 'General');
|
||||
|
||||
html += '<tr class="' + rowClass + '">' +
|
||||
'<td class="text-center">' +
|
||||
'<input class="form-check-input preview-row-chk" type="checkbox" ' +
|
||||
(row.selected ? 'checked' : '') + ' ' +
|
||||
(isInvalid ? 'disabled' : '') + ' ' +
|
||||
'onchange="toggleRowSelection(\'' + row.id + '\', this.checked)">' +
|
||||
'</td>' +
|
||||
'<td class="text-muted font-monospace">' + globalIdx + '</td>' +
|
||||
'<td><span class="badge bg-primary-subtle text-primary border border-primary-subtle">' + (row.dia || '-') + '</span></td>' +
|
||||
'<td><div class="fw-semibold">' + (row.turno || '') + '</div><small class="text-muted">' + (row.horario || '') + '</small></td>' +
|
||||
'<td>' +
|
||||
'<div class="fw-bold text-dark">' + (row.codigo || '') + '</div>' +
|
||||
'<div class="small text-secondary text-truncate" style="max-width: 220px;" title="' + (row.asignatura || '') + '">' + (row.asignatura || '') + '</div>' +
|
||||
'</td>' +
|
||||
'<td><small class="text-muted d-block text-truncate" style="max-width: 160px;" title="' + carText + '">' + carText + '</small></td>' +
|
||||
'<td>' + aulaBadge + '</td>' +
|
||||
'<td>' +
|
||||
'<input type="date" class="form-control form-control-sm font-monospace" ' +
|
||||
'value="' + (row.date || row.inferred_date || '') + '" ' +
|
||||
'onchange="updateRowDate(\'' + row.id + '\', this.value)">' +
|
||||
'</td>' +
|
||||
'<td>' + estadoBadge + '</td>' +
|
||||
'</tr>';
|
||||
});
|
||||
|
||||
tbody.innerHTML = html;
|
||||
renderPreviewPagination(totalFiltered, totalPages);
|
||||
|
||||
// Actualizar checkbox maestro
|
||||
const masterChk = document.getElementById('chkSelectAllPreview');
|
||||
if (masterChk) {
|
||||
const visibleSelectable = pageRows.filter(r => r.is_valid !== false);
|
||||
masterChk.checked = visibleSelectable.length > 0 && visibleSelectable.every(r => r.selected);
|
||||
}
|
||||
}
|
||||
|
||||
// Paginación visual
|
||||
function renderPreviewPagination(totalFiltered, totalPages) {
|
||||
const infoEl = document.getElementById('previewPaginationInfo');
|
||||
const navEl = document.getElementById('previewPaginationNav');
|
||||
if (!infoEl || !navEl) return;
|
||||
|
||||
const startIdx = totalFiltered === 0 ? 0 : (window.previewCurrentPage - 1) * window.previewPageSize + 1;
|
||||
const endIdx = Math.min(window.previewCurrentPage * window.previewPageSize, totalFiltered);
|
||||
infoEl.innerHTML = 'Mostrando registros <strong>' + startIdx + '</strong> - <strong>' + endIdx + '</strong> de <strong>' + totalFiltered + '</strong>';
|
||||
|
||||
let navHtml = '';
|
||||
navHtml += '<li class="page-item ' + (window.previewCurrentPage === 1 ? 'disabled' : '') + '">' +
|
||||
'<button class="page-link py-1 px-2" onclick="goToPreviewPage(' + (window.previewCurrentPage - 1) + ')">«</button>' +
|
||||
'</li>';
|
||||
|
||||
let startP = Math.max(1, window.previewCurrentPage - 2);
|
||||
let endP = Math.min(totalPages, startP + 4);
|
||||
if (endP - startP < 4) startP = Math.max(1, endP - 4);
|
||||
|
||||
for (let p = startP; p <= endP; p++) {
|
||||
navHtml += '<li class="page-item ' + (p === window.previewCurrentPage ? 'active' : '') + '">' +
|
||||
'<button class="page-link py-1 px-2" onclick="goToPreviewPage(' + p + ')">' + p + '</button>' +
|
||||
'</li>';
|
||||
}
|
||||
|
||||
navHtml += '<li class="page-item ' + (window.previewCurrentPage === totalPages ? 'disabled' : '') + '">' +
|
||||
'<button class="page-link py-1 px-2" onclick="goToPreviewPage(' + (window.previewCurrentPage + 1) + ')">»</button>' +
|
||||
'</li>';
|
||||
|
||||
navEl.innerHTML = navHtml;
|
||||
}
|
||||
|
||||
function goToPreviewPage(page) {
|
||||
const filtered = getFilteredRows();
|
||||
const totalPages = Math.max(1, Math.ceil(filtered.length / window.previewPageSize));
|
||||
if (page < 1 || page > totalPages) return;
|
||||
window.previewCurrentPage = page;
|
||||
renderPreview();
|
||||
}
|
||||
|
||||
// Edición Inline de Fechas en la Grilla
|
||||
function updateRowDate(rowId, newDate) {
|
||||
const row = window.inspectedRows.find(r => r.id === rowId);
|
||||
if (row) {
|
||||
row.date = newDate;
|
||||
row.inferred_date = newDate;
|
||||
}
|
||||
}
|
||||
|
||||
// Toggle individual de selección de fila
|
||||
function toggleRowSelection(rowId, checked) {
|
||||
const row = window.inspectedRows.find(r => r.id === rowId);
|
||||
if (row) {
|
||||
row.selected = checked;
|
||||
}
|
||||
const selCount = window.inspectedRows.filter(r => r.selected).length;
|
||||
const selCountEl = document.getElementById('previewSelectedCount');
|
||||
const selCountBtnEl = document.getElementById('previewSelectedCountBtn');
|
||||
if (selCountEl) selCountEl.innerText = selCount;
|
||||
if (selCountBtnEl) selCountBtnEl.innerText = selCount;
|
||||
}
|
||||
|
||||
// Checkbox Maestro de la Grilla
|
||||
function toggleMasterPreviewCheckbox(checked) {
|
||||
const filtered = getFilteredRows();
|
||||
filtered.forEach(function(r) {
|
||||
if (r.is_valid !== false) {
|
||||
r.selected = checked;
|
||||
}
|
||||
});
|
||||
renderPreview();
|
||||
}
|
||||
|
||||
function toggleSelectAllFiltered(checked) {
|
||||
const filtered = getFilteredRows();
|
||||
filtered.forEach(function(r) {
|
||||
if (r.is_valid !== false) {
|
||||
r.selected = checked;
|
||||
}
|
||||
});
|
||||
renderPreview();
|
||||
}
|
||||
|
||||
// Aplicar Fecha Masiva a todas las filas seleccionadas
|
||||
function applyBulkDate() {
|
||||
const bulkInput = document.getElementById('bulkDateInput');
|
||||
const val = bulkInput ? bulkInput.value : '';
|
||||
if (!val) {
|
||||
alert('Por favor ingrese una fecha válida en el campo de Fecha masiva.');
|
||||
return;
|
||||
}
|
||||
let updatedCount = 0;
|
||||
window.inspectedRows.forEach(function(r) {
|
||||
if (r.selected) {
|
||||
r.date = val;
|
||||
r.inferred_date = val;
|
||||
updatedCount++;
|
||||
}
|
||||
});
|
||||
renderPreview();
|
||||
alert('Se aplicó la fecha ' + val + ' a ' + updatedCount + ' fila(s) seleccionada(s).');
|
||||
}
|
||||
|
||||
// Modal de Confirmación de Sincronización
|
||||
function openSyncConfirmModal() {
|
||||
const hasInspected = (window.inspectedRows && window.inspectedRows.length > 0);
|
||||
const selCount = hasInspected ? window.inspectedRows.filter(r => r.selected).length : null;
|
||||
|
||||
if (hasInspected && selCount === 0) {
|
||||
alert('Atención: Tiene 0 filas seleccionadas en la grilla de previsualización. Seleccione al menos una fila para sincronizar.');
|
||||
return;
|
||||
}
|
||||
|
||||
// Resumen de entidades marcadas
|
||||
const chkRes = document.getElementById('chk_import_reservations')?.checked;
|
||||
const chkCls = document.getElementById('chk_import_classrooms')?.checked;
|
||||
const chkCom = document.getElementById('chk_import_commissions')?.checked;
|
||||
const chkSub = document.getElementById('chk_import_subjects')?.checked;
|
||||
const chkCar = document.getElementById('chk_import_careers')?.checked;
|
||||
|
||||
const detailsEl = document.getElementById('syncConfirmDetails');
|
||||
if (detailsEl) {
|
||||
let html = '<ul class="list-unstyled mb-0">';
|
||||
if (hasInspected) {
|
||||
html += '<li class="mb-1"><i class="bi bi-check2-circle text-success me-2"></i><strong>' + selCount + ' registros específicos seleccionados</strong> desde la grilla interactiva.</li>';
|
||||
} else {
|
||||
html += '<li class="mb-1"><i class="bi bi-layers text-primary me-2"></i>Sincronización completa de las pestañas de días seleccionadas.</li>';
|
||||
}
|
||||
|
||||
html += '<li class="mt-2 text-muted fw-semibold">Entidades a crear / sincronizar:</li>';
|
||||
if (chkRes) html += '<li class="ms-3"><i class="bi bi-calendar-check text-danger me-2"></i>Asignaciones de aulas (Reservas en Calendario)</li>';
|
||||
if (chkCls) html += '<li class="ms-3"><i class="bi bi-door-open text-success me-2"></i>Aulas físicas y virtuales</li>';
|
||||
if (chkCom) html += '<li class="ms-3"><i class="bi bi-diagram-3 text-warning me-2"></i>Comisiones de cursada</li>';
|
||||
if (chkSub) html += '<li class="ms-3"><i class="bi bi-book text-info me-2"></i>Asignaturas / Materias</li>';
|
||||
if (chkCar) html += '<li class="ms-3"><i class="bi bi-mortarboard text-primary me-2"></i>Carreras Académicas</li>';
|
||||
|
||||
const days = getSelectedDays();
|
||||
html += '<li class="mt-2 text-muted fw-semibold">Días de cursada: ' + (days.length > 0 ? days.join(', ') : 'Ninguno seleccionado') + '</li>';
|
||||
html += '</ul>';
|
||||
detailsEl.innerHTML = html;
|
||||
}
|
||||
|
||||
const modalEl = document.getElementById('syncConfirmModal');
|
||||
if (modalEl && typeof bootstrap !== 'undefined' && bootstrap.Modal) {
|
||||
try {
|
||||
const modal = new bootstrap.Modal(modalEl);
|
||||
modal.show();
|
||||
return;
|
||||
} catch (e) {
|
||||
console.warn('Bootstrap modal error, fallback:', e);
|
||||
}
|
||||
}
|
||||
|
||||
if (confirm("¿Confirma iniciar la sincronización de las entidades seleccionadas?")) {
|
||||
confirmSyncSubmission();
|
||||
}
|
||||
}
|
||||
|
||||
function confirmSyncSubmission() {
|
||||
const btnConfirm = document.getElementById('btnDoSyncConfirm');
|
||||
if (btnConfirm) {
|
||||
btnConfirm.disabled = true;
|
||||
btnConfirm.innerHTML = '<span class="spinner-border spinner-border-sm me-2"></span>Iniciando...';
|
||||
}
|
||||
|
||||
// Si se inspeccionó previamente, serializar las filas seleccionadas
|
||||
const hiddenSelectedRows = document.getElementById('selected_rows_json');
|
||||
if (hiddenSelectedRows && window.inspectedRows && window.inspectedRows.length > 0) {
|
||||
const selectedOnly = window.inspectedRows.filter(r => r.selected);
|
||||
hiddenSelectedRows.value = JSON.stringify(selectedOnly);
|
||||
}
|
||||
|
||||
const urlInput = document.getElementById('google_sheets_url');
|
||||
const syncUrlInput = document.getElementById('syncSheetsUrl');
|
||||
if (urlInput && syncUrlInput) {
|
||||
syncUrlInput.value = urlInput.value.trim();
|
||||
}
|
||||
|
||||
const spinner = document.getElementById('syncSpinner');
|
||||
if (spinner) spinner.classList.remove('d-none');
|
||||
|
||||
const form = document.getElementById('syncForm');
|
||||
if (form) {
|
||||
form.submit();
|
||||
}
|
||||
}
|
||||
|
||||
// Modal de Purga
|
||||
function toggleSelectAll(checked) {
|
||||
document.getElementById('chk_reservations').checked = checked;
|
||||
document.getElementById('chk_classrooms').checked = checked;
|
||||
|
||||
Reference in New Issue
Block a user