feat(v3.4.7): add interactive floors and classrooms panel in building edit and preselect room creation
This commit is contained in:
@@ -7,25 +7,48 @@
|
||||
{% block content %}
|
||||
<div class="container-fluid pt-5 mt-4">
|
||||
<div class="row">
|
||||
<div class="col-lg-8 mx-auto">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1 class="h3 mb-0">
|
||||
<i class="bi bi-buildings text-primary me-2"></i>
|
||||
{% if building %}Editar Edificio{% else %}Nuevo Edificio{% endif %}
|
||||
</h1>
|
||||
<a href="/buildings/list_buildings" class="btn btn-outline-secondary">
|
||||
<i class="bi bi-arrow-left me-1"></i>Volver a Edificios
|
||||
</a>
|
||||
<div class="col-xl-9 col-lg-11 mx-auto">
|
||||
<!-- Breadcrumb y Encabezado Superior -->
|
||||
<div class="d-flex flex-wrap justify-content-between align-items-center mb-4 gap-2">
|
||||
<div>
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb mb-1 small">
|
||||
<li class="breadcrumb-item"><a href="/buildings/list_buildings" class="text-decoration-none">Edificios</a></li>
|
||||
{% if building %}
|
||||
<li class="breadcrumb-item"><a href="/buildings/view/{{ building.id }}" class="text-decoration-none">{{ building.name }}</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">Editar</li>
|
||||
{% else %}
|
||||
<li class="breadcrumb-item active" aria-current="page">Nuevo Edificio</li>
|
||||
{% endif %}
|
||||
</ol>
|
||||
</nav>
|
||||
<h1 class="h3 mb-0">
|
||||
<i class="bi bi-buildings text-primary me-2"></i>
|
||||
{% if building %}Editar Edificio: <span class="text-primary">{{ building.name }}</span>{% else %}Nuevo Edificio{% endif %}
|
||||
</h1>
|
||||
<p class="text-muted small mb-0 mt-1">Configura los datos de la sede, gestiona sus plantas físicas y administra sus aulas asociadas.</p>
|
||||
</div>
|
||||
<div class="d-flex gap-2">
|
||||
{% if building %}
|
||||
<a href="/buildings/view/{{ building.id }}" class="btn btn-outline-primary btn-sm">
|
||||
<i class="bi bi-eye me-1"></i>Ver Ficha de la Sede
|
||||
</a>
|
||||
{% endif %}
|
||||
<a href="/buildings/list_buildings" class="btn btn-outline-secondary btn-sm">
|
||||
<i class="bi bi-arrow-left me-1"></i>Volver a Edificios
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card border-0 shadow-sm">
|
||||
<!-- Card 1: Formulario Principal del Edificio -->
|
||||
<div class="card border-0 shadow-sm mb-4">
|
||||
<div class="card-header bg-body-tertiary border-0 py-3">
|
||||
<h5 class="mb-0 h6 fw-bold">
|
||||
<i class="bi bi-info-circle text-primary me-2"></i>Información del Edificio / Sede
|
||||
</h5>
|
||||
</div>
|
||||
<div class="card-body p-4">
|
||||
<form method="POST" action="{% if building %}/buildings/edit/{{ building.id }}{% else %}/buildings/add_building{% endif %}" novalidate>
|
||||
<form method="POST" action="{% if building %}/buildings/edit/{{ building.id }}{% else %}/buildings/add_building{% endif %}" id="buildingForm" novalidate>
|
||||
{% if building %}
|
||||
<input type="hidden" name="id" value="{{ building.id }}">
|
||||
{% endif %}
|
||||
@@ -33,7 +56,7 @@
|
||||
<div class="row g-3">
|
||||
<div class="col-md-8">
|
||||
{{ form.name.label(class="form-label fw-semibold") }}
|
||||
{{ form.name(class="form-control" + (" is-invalid" if form.name.errors else ""), placeholder="ej. Edificio Central, Pabellón de Ciencias, Sede Norte") }}
|
||||
{{ form.name(class="form-control" + (" is-invalid" if form.name.errors else ""), id="buildingNameInput", placeholder="ej. Edificio Central, Pabellón de Ciencias, Sede Norte") }}
|
||||
{% if form.name.errors %}
|
||||
<div class="invalid-feedback">{{ form.name.errors[0] }}</div>
|
||||
{% endif %}
|
||||
@@ -41,28 +64,61 @@
|
||||
|
||||
<div class="col-md-4">
|
||||
{{ form.code.label(class="form-label fw-semibold") }}
|
||||
{{ form.code(class="form-control" + (" is-invalid" if form.code.errors else ""), placeholder="ej. CENTRAL, VIRTUAL, PAB-A") }}
|
||||
{{ form.code(class="form-control" + (" is-invalid" if form.code.errors else ""), id="buildingCodeInput", placeholder="ej. CENTRAL, VIRTUAL, PAB-A") }}
|
||||
{% if form.code.errors %}
|
||||
<div class="invalid-feedback">{{ form.code.errors[0] }}</div>
|
||||
{% endif %}
|
||||
<small class="text-muted">Código identificador corto</small>
|
||||
</div>
|
||||
|
||||
<div class="col-md-8">
|
||||
<div class="col-md-7">
|
||||
{{ form.address.label(class="form-label fw-semibold") }}
|
||||
{{ form.address(class="form-control" + (" is-invalid" if form.address.errors else ""), placeholder="ej. Av. Paseo Colón 255, CABA o campus.unicaba.edu.ar") }}
|
||||
{{ form.address(class="form-control" + (" is-invalid" if form.address.errors else ""), placeholder="ej. Tte. Gral. Juan Domingo Perón 802, CABA o campus.unicaba.edu.ar") }}
|
||||
{% if form.address.errors %}
|
||||
<div class="invalid-feedback">{{ form.address.errors[0] }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{{ form.floors.label(class="form-label fw-semibold") }}
|
||||
{{ form.floors(class="form-control" + (" is-invalid" if form.floors.errors else ""), min=0, max=100) }}
|
||||
<!-- Selector / Configurador de Pisos enriquecido -->
|
||||
<div class="col-md-5">
|
||||
<label for="floorsInput" class="form-label fw-semibold d-flex justify-content-between align-items-center mb-1">
|
||||
<span><i class="bi bi-layers me-1 text-primary"></i>Plantas Físicas (Floors)</span>
|
||||
<span class="badge bg-secondary-subtle text-secondary" id="floorModeBadge">
|
||||
{% if building and building.is_virtual %}Campus Virtual{% else %}Presencial{% endif %}
|
||||
</span>
|
||||
</label>
|
||||
<div class="input-group">
|
||||
<button class="btn btn-outline-secondary" type="button" id="btnFloorDec" title="Disminuir planta">-</button>
|
||||
{{ form.floors(class="form-control text-center fw-bold" + (" is-invalid" if form.floors.errors else ""), id="floorsInput", min=0, max=100) }}
|
||||
<button class="btn btn-outline-secondary" type="button" id="btnFloorInc" title="Aumentar planta">+</button>
|
||||
</div>
|
||||
{% if form.floors.errors %}
|
||||
<div class="invalid-feedback">{{ form.floors.errors[0] }}</div>
|
||||
<div class="invalid-feedback d-block">{{ form.floors.errors[0] }}</div>
|
||||
{% endif %}
|
||||
<small class="text-muted">Plantas físicas (0 para Campus Virtual)</small>
|
||||
<small class="text-muted d-block mt-1">Cantidad de niveles estructurales (0 para Campus Virtual)</small>
|
||||
</div>
|
||||
|
||||
<!-- Panel de Configuración Rápida de Niveles (Presets & Acciones) -->
|
||||
<div class="col-12">
|
||||
<div class="p-3 bg-body-tertiary rounded border border-light-subtle">
|
||||
<div class="d-flex flex-wrap justify-content-between align-items-center mb-2 gap-2">
|
||||
<div class="small fw-bold text-secondary">
|
||||
<i class="bi bi-diagram-3 me-1"></i>Configurador Rápido de Plantas y Niveles
|
||||
</div>
|
||||
<div class="d-flex flex-wrap gap-1">
|
||||
<button type="button" class="btn btn-outline-primary btn-sm py-0 px-2" id="presetPB">Preset PB (1)</button>
|
||||
<button type="button" class="btn btn-outline-primary btn-sm py-0 px-2" id="presetPBplus1">PB + 1 (2)</button>
|
||||
<button type="button" class="btn btn-outline-primary btn-sm py-0 px-2" id="presetPBplus3">PB + 3 (4)</button>
|
||||
<button type="button" class="btn btn-outline-secondary btn-sm py-0 px-2" id="presetVirtual">Virtual (0)</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex flex-wrap align-items-center gap-1" id="floorLevelChips">
|
||||
<!-- Generado dinámicamente según floorsInput -->
|
||||
</div>
|
||||
<small class="text-muted mt-2 d-block" style="font-size: 0.78rem;">
|
||||
<i class="bi bi-info-circle me-1"></i>Puedes usar los botones de acceso rápido para ajustar las plantas del edificio. Cada nivel admitirá creación y vinculación de aulas específicas.
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
@@ -75,7 +131,7 @@
|
||||
|
||||
<div class="col-12">
|
||||
<div class="form-check form-switch pt-2">
|
||||
{{ form.is_active(class="form-check-input", role="switch") }}
|
||||
{{ form.is_active(class="form-check-input", role="switch", id="isActiveInput") }}
|
||||
{{ form.is_active.label(class="form-check-label fw-semibold") }}
|
||||
</div>
|
||||
</div>
|
||||
@@ -91,7 +147,304 @@
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Card 2: Panel Interactivo de Plantas y Aulas de la Sede -->
|
||||
{% if building %}
|
||||
<div class="card border-0 shadow-sm mb-4">
|
||||
<div class="card-header bg-body-tertiary border-0 py-3 d-flex flex-wrap justify-content-between align-items-center gap-2">
|
||||
<div>
|
||||
<h5 class="mb-0 h6 fw-bold">
|
||||
<i class="bi bi-layers-fill text-primary me-2"></i>Plantas Físicas y Distribución de Aulas
|
||||
</h5>
|
||||
<small class="text-muted">Gestiona los pisos del edificio, visualiza sus aulas asignadas o crea nuevos espacios por nivel</small>
|
||||
</div>
|
||||
<div class="d-flex flex-wrap align-items-center gap-2">
|
||||
<span class="badge bg-primary-subtle text-primary border border-primary-subtle px-2 py-1">
|
||||
<i class="bi bi-building me-1"></i>{{ floors_list|length }} Niveles
|
||||
</span>
|
||||
<span class="badge bg-info-subtle text-info border border-info-subtle px-2 py-1">
|
||||
<i class="bi bi-door-open me-1"></i>{{ classrooms|length }} Aulas
|
||||
</span>
|
||||
<span class="badge bg-success-subtle text-success border border-success-subtle px-2 py-1">
|
||||
<i class="bi bi-people me-1"></i>{{ total_physical_capacity }} Plazas Físicas
|
||||
</span>
|
||||
{% if not building.is_virtual %}
|
||||
<a href="/classrooms/add_classroom?building_id={{ building.id }}" class="btn btn-sm btn-success">
|
||||
<i class="bi bi-plus-circle me-1"></i>Crear Nueva Aula
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-body p-4">
|
||||
{% if building.is_virtual %}
|
||||
<!-- Caso Sede Virtual -->
|
||||
<div class="alert alert-info border-0 shadow-sm d-flex align-items-center justify-content-between">
|
||||
<div>
|
||||
<i class="bi bi-cloud-check fs-4 me-2"></i>
|
||||
<strong>Sede Virtual:</strong> Las aulas de esta sede operan en el Campus Digital institucional (Moodle, Meet y MS Teams).
|
||||
</div>
|
||||
<a href="/classrooms/add_classroom?building_id={{ building.id }}&floor=Digital" class="btn btn-sm btn-outline-primary">
|
||||
<i class="bi bi-plus-lg me-1"></i>Nueva Sala Virtual
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if floors_list and floors_list|length > 0 %}
|
||||
<div class="d-flex flex-column gap-3">
|
||||
{% for f in floors_list %}
|
||||
<div class="card border border-light-subtle shadow-none">
|
||||
<!-- Cabecera de la Planta -->
|
||||
<div class="card-header bg-body py-2 px-3 d-flex flex-wrap justify-content-between align-items-center gap-2">
|
||||
<div class="d-flex align-items-center">
|
||||
{% if 'SUB' in f.floor_code|upper or 'SS' in f.floor_code|upper %}
|
||||
<i class="bi bi-box-arrow-in-down text-warning fs-5 me-2"></i>
|
||||
{% elif 'PB' in f.floor_code|upper or 'PLANTA' in f.floor_name|upper %}
|
||||
<i class="bi bi-door-closed text-primary fs-5 me-2"></i>
|
||||
{% elif 'EP' in f.floor_code|upper or 'ENTRE' in f.floor_name|upper %}
|
||||
<i class="bi bi-stack text-info fs-5 me-2"></i>
|
||||
{% elif f.floor_code == 'Digital' %}
|
||||
<i class="bi bi-cloud text-info fs-5 me-2"></i>
|
||||
{% else %}
|
||||
<i class="bi bi-layers text-secondary fs-5 me-2"></i>
|
||||
{% endif %}
|
||||
<div>
|
||||
<span class="fw-bold fs-6">{{ f.floor_name }}</span>
|
||||
<span class="badge bg-body-secondary text-secondary border ms-2">Código: {{ f.floor_code }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
<span class="badge bg-light text-dark border">
|
||||
<i class="bi bi-door-open me-1"></i>{{ f.classrooms|length }} aulas
|
||||
</span>
|
||||
<span class="badge bg-light text-dark border">
|
||||
<i class="bi bi-people me-1"></i>{{ f.total_capacity }} pers. cap.
|
||||
</span>
|
||||
<a href="/classrooms/add_classroom?building_id={{ building.id }}&floor={{ f.floor_code }}"
|
||||
class="btn btn-sm btn-outline-success py-1 px-2"
|
||||
title="Crear un aula directamente en {{ f.floor_name }}">
|
||||
<i class="bi bi-plus-lg me-1"></i>+ Nueva Aula en este Piso
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Listado de Aulas en esta Planta -->
|
||||
<div class="card-body p-0">
|
||||
{% if f.classrooms and f.classrooms|length > 0 %}
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover align-middle mb-0 table-sm">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th class="ps-3" style="width: 30%;">Aula / Espacio</th>
|
||||
<th style="width: 20%;">Capacidad</th>
|
||||
<th style="width: 25%;">Estado</th>
|
||||
<th class="text-end pe-3" style="width: 25%;">Acciones</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for c in f.classrooms %}
|
||||
<tr>
|
||||
<td class="ps-3">
|
||||
<a href="/classrooms/view_classroom?id={{ c.id }}" class="fw-semibold text-decoration-none">
|
||||
<i class="bi bi-door-open text-primary me-1"></i>{{ c.code_display or c.code or c.room_number }}
|
||||
</a>
|
||||
{% if c.description %}
|
||||
<small class="text-muted d-block" style="font-size: 0.75rem;">{{ c.description }}</small>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<span class="badge bg-primary-subtle text-primary border border-primary-subtle">
|
||||
{{ c.capacity }} alumnos
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
{% if c.is_active %}
|
||||
<span class="badge bg-success-subtle text-success border border-success-subtle">
|
||||
<i class="bi bi-check-circle me-1"></i>Activa
|
||||
</span>
|
||||
{% else %}
|
||||
<span class="badge bg-secondary-subtle text-secondary border border-secondary-subtle">
|
||||
<i class="bi bi-pause-circle me-1"></i>Inactiva
|
||||
</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="text-end pe-3">
|
||||
<div class="btn-group btn-group-sm">
|
||||
<a href="/classrooms/edit/{{ c.id }}" class="btn btn-outline-secondary py-0 px-2" title="Editar detalles del aula">
|
||||
<i class="bi bi-pencil me-1"></i>Editar
|
||||
</a>
|
||||
<a href="/schedule/add_reservation?classroom_id={{ c.id }}" class="btn btn-outline-primary py-0 px-2" title="Reservar espacio">
|
||||
<i class="bi bi-calendar-plus me-1"></i>Reservar
|
||||
</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="p-3 text-center bg-body-tertiary text-muted small">
|
||||
<i class="bi bi-inbox me-1"></i>Este nivel aún no tiene aulas asignadas.
|
||||
<a href="/classrooms/add_classroom?building_id={{ building.id }}&floor={{ f.floor_code }}" class="fw-semibold text-primary ms-1 text-decoration-none">
|
||||
+ Añadir la primera aula aquí →
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="text-center py-4 bg-body-tertiary rounded border border-dashed text-muted">
|
||||
<i class="bi bi-building-slash fs-3 d-block mb-2 text-secondary"></i>
|
||||
No se han registrado plantas físicas aún para esta sede.
|
||||
<div class="mt-2">
|
||||
<a href="/classrooms/add_classroom?building_id={{ building.id }}" class="btn btn-sm btn-primary">
|
||||
<i class="bi bi-plus-circle me-1"></i>Crear Primera Aula
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<!-- Card Informativa para Edificio Nuevo -->
|
||||
<div class="card border-0 shadow-sm mb-4">
|
||||
<div class="card-header bg-body-tertiary border-0 py-3">
|
||||
<h5 class="mb-0 h6 fw-bold">
|
||||
<i class="bi bi-layers-fill text-primary me-2"></i>Estructura Proyectada de Plantas
|
||||
</h5>
|
||||
</div>
|
||||
<div class="card-body p-4 text-center">
|
||||
<div class="py-3">
|
||||
<i class="bi bi-diagram-3 fs-1 text-primary mb-2 d-block"></i>
|
||||
<h6 class="fw-bold mb-1">Previsualización de Niveles Físicos</h6>
|
||||
<p class="text-muted small mb-3">
|
||||
Ajusta el número de plantas arriba para previsualizar los niveles que compondrán este edificio. Al guardar la sede, podrás incorporar aulas directamente en cada una de sus plantas.
|
||||
</p>
|
||||
<div class="d-inline-flex flex-wrap gap-2 justify-content-center p-3 bg-body-tertiary rounded border border-light-subtle" id="newBuildingFloorsPreview">
|
||||
<!-- Poblado dinámicamente -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_js %}
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const floorsInput = document.getElementById('floorsInput');
|
||||
const btnFloorInc = document.getElementById('btnFloorInc');
|
||||
const btnFloorDec = document.getElementById('btnFloorDec');
|
||||
const floorModeBadge = document.getElementById('floorModeBadge');
|
||||
const floorLevelChips = document.getElementById('floorLevelChips');
|
||||
const newBuildingPreview = document.getElementById('newBuildingFloorsPreview');
|
||||
const buildingCodeInput = document.getElementById('buildingCodeInput');
|
||||
const buildingNameInput = document.getElementById('buildingNameInput');
|
||||
|
||||
function isVirtualTarget() {
|
||||
const c = (buildingCodeInput ? buildingCodeInput.value : '').toUpperCase();
|
||||
const n = (buildingNameInput ? buildingNameInput.value : '').toUpperCase();
|
||||
return c.includes('VIRTUAL') || n.includes('VIRTUAL');
|
||||
}
|
||||
|
||||
function renderLevelChips(val) {
|
||||
if (!floorLevelChips) return;
|
||||
floorLevelChips.innerHTML = '';
|
||||
const count = parseInt(val, 10) || 0;
|
||||
|
||||
if (count === 0 || isVirtualTarget()) {
|
||||
if (floorModeBadge) floorModeBadge.textContent = 'Campus Virtual';
|
||||
const chip = document.createElement('span');
|
||||
chip.className = 'badge bg-info-subtle text-info border border-info-subtle px-2 py-1';
|
||||
chip.innerHTML = '<i class="bi bi-cloud-check me-1"></i>Campus Virtual (Nivel Digital)';
|
||||
floorLevelChips.appendChild(chip);
|
||||
if (newBuildingPreview) {
|
||||
newBuildingPreview.innerHTML = '<span class="badge bg-info-subtle text-info border px-3 py-2"><i class="bi bi-cloud me-1"></i>Campus Virtual (100% Remoto)</span>';
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (floorModeBadge) floorModeBadge.textContent = 'Presencial (' + count + ' pisos)';
|
||||
|
||||
const levels = [];
|
||||
// Standard levels
|
||||
levels.push({ code: 'PB', name: 'Planta Baja (PB)' });
|
||||
for (let i = 1; i < count; i++) {
|
||||
levels.push({ code: String(i), name: 'Piso ' + i });
|
||||
}
|
||||
|
||||
levels.forEach(function(lvl) {
|
||||
const chip = document.createElement('span');
|
||||
chip.className = 'badge bg-primary-subtle text-primary border border-primary-subtle px-2 py-1';
|
||||
chip.innerHTML = '<i class="bi bi-layers me-1"></i>' + lvl.name;
|
||||
floorLevelChips.appendChild(chip);
|
||||
});
|
||||
|
||||
if (newBuildingPreview) {
|
||||
newBuildingPreview.innerHTML = '';
|
||||
levels.forEach(function(lvl) {
|
||||
const bChip = document.createElement('div');
|
||||
bChip.className = 'p-2 rounded bg-body border text-center';
|
||||
bChip.style.minWidth = '110px';
|
||||
bChip.innerHTML = '<i class="bi bi-layers text-primary d-block mb-1"></i><small class="fw-bold d-block">' + lvl.name + '</small><span class="badge bg-light text-muted border" style="font-size: 0.7rem;">Nivel ' + lvl.code + '</span>';
|
||||
newBuildingPreview.appendChild(bChip);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (floorsInput) {
|
||||
floorsInput.addEventListener('input', function() {
|
||||
renderLevelChips(this.value);
|
||||
});
|
||||
|
||||
if (btnFloorInc) {
|
||||
btnFloorInc.addEventListener('click', function() {
|
||||
let v = parseInt(floorsInput.value, 10) || 0;
|
||||
floorsInput.value = v + 1;
|
||||
renderLevelChips(floorsInput.value);
|
||||
});
|
||||
}
|
||||
|
||||
if (btnFloorDec) {
|
||||
btnFloorDec.addEventListener('click', function() {
|
||||
let v = parseInt(floorsInput.value, 10) || 0;
|
||||
if (v > 0) {
|
||||
floorsInput.value = v - 1;
|
||||
renderLevelChips(floorsInput.value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Presets
|
||||
const pPB = document.getElementById('presetPB');
|
||||
const pPB1 = document.getElementById('presetPBplus1');
|
||||
const pPB3 = document.getElementById('presetPBplus3');
|
||||
const pVirt = document.getElementById('presetVirtual');
|
||||
|
||||
if (pPB) pPB.addEventListener('click', function() { floorsInput.value = 1; renderLevelChips(1); });
|
||||
if (pPB1) pPB1.addEventListener('click', function() { floorsInput.value = 2; renderLevelChips(2); });
|
||||
if (pPB3) pPB3.addEventListener('click', function() { floorsInput.value = 4; renderLevelChips(4); });
|
||||
if (pVirt) pVirt.addEventListener('click', function() { floorsInput.value = 0; renderLevelChips(0); });
|
||||
|
||||
// Initial render
|
||||
renderLevelChips(floorsInput.value);
|
||||
}
|
||||
|
||||
if (buildingCodeInput) {
|
||||
buildingCodeInput.addEventListener('input', function() {
|
||||
if (isVirtualTarget() && floorsInput) {
|
||||
floorsInput.value = 0;
|
||||
}
|
||||
if (floorsInput) renderLevelChips(floorsInput.value);
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
<a href="/buildings/edit/{{ building.id }}" class="btn btn-outline-secondary me-2">
|
||||
<i class="bi bi-pencil me-1"></i>Editar Edificio
|
||||
</a>
|
||||
<a href="/classrooms/add_classroom" class="btn btn-primary">
|
||||
<a href="/classrooms/add_classroom?building_id={{ building.id }}" class="btn btn-primary">
|
||||
<i class="bi bi-plus-circle me-1"></i>Nueva Aula
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user