218 lines
9.6 KiB
HTML
218 lines
9.6 KiB
HTML
{% extends "base.html" %}
|
|
|
|
{% block title %}{% trans %}Add Classroom{% endtrans %} - Edu-Space Admin{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="container-fluid pt-5 mt-4">
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
|
<h1 class="h3">
|
|
<i class="bi bi-plus-circle text-primary"></i> {% trans %}Add Classroom{% endtrans %}
|
|
</h1>
|
|
<a href="{{ url_for('classrooms.list_classrooms') }}" class="btn btn-outline-secondary">
|
|
<i class="bi bi-arrow-left"></i> {% trans %}Back to Classrooms{% endtrans %}
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-lg-8 mx-auto">
|
|
<div class="card border-0 shadow-sm">
|
|
<div class="card-header bg-body-tertiary border-0 py-3">
|
|
<h5 class="mb-0 h6 fw-bold">
|
|
<i class="bi bi-door-open text-primary me-2"></i> {% trans %}Classroom Information{% endtrans %}
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<form method="POST" id="classroom-form" novalidate>
|
|
{{ form.hidden_tag() }}
|
|
|
|
<div class="row">
|
|
<div class="col-md-4 mb-3">
|
|
{{ form.building.label(class="form-label") }}
|
|
{{ form.building(class="form-control", placeholder="A") }}
|
|
{% if form.building.errors %}
|
|
<div class="text-danger small mt-1">
|
|
{{ form.building.errors[0] }}
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<div class="col-md-4 mb-3">
|
|
{{ form.room_number.label(class="form-label") }}
|
|
{{ form.room_number(class="form-control", placeholder="101") }}
|
|
{% if form.room_number.errors %}
|
|
<div class="text-danger small mt-1">
|
|
{{ form.room_number.errors[0] }}
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<div class="col-md-4 mb-3">
|
|
{{ form.floor.label(class="form-label") }}
|
|
{{ form.floor(class="form-control") }}
|
|
{% if form.floor.errors %}
|
|
<div class="text-danger small mt-1">
|
|
{{ form.floor.errors[0] }}
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-md-6 mb-3">
|
|
<div class="d-flex justify-content-between align-items-center mb-1">
|
|
{{ form.capacity.label(class="form-label mb-0") }}
|
|
<button type="button" class="btn btn-sm btn-outline-primary py-0 px-2" id="btnInfinityAdd" style="font-size: 0.8rem;" title="{% trans %}Asignar capacidad ilimitada{% endtrans %}">
|
|
<i class="bi bi-infinity me-1"></i>{% trans %}Ilimitada (∞){% endtrans %}
|
|
</button>
|
|
</div>
|
|
<div class="input-group">
|
|
{{ form.capacity(class="form-control", id="capacity", placeholder="ej. 30 o ∞") }}
|
|
<span class="input-group-text bg-body-tertiary text-muted font-monospace"><i class="bi bi-people"></i></span>
|
|
</div>
|
|
<div class="form-text small text-muted mt-1">
|
|
<i class="bi bi-info-circle text-info me-1"></i>{% trans %}Para aulas virtuales o sin límite de aforo, ingrese <strong>∞</strong> o <strong>0</strong> (Capacidad ilimitada).{% endtrans %}
|
|
</div>
|
|
{% if form.capacity.errors %}
|
|
<div class="text-danger small mt-1">
|
|
{{ form.capacity.errors[0] }}
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<div class="col-md-6 mb-3">
|
|
<label class="form-label d-block"> </label>
|
|
<div class="form-check pt-2">
|
|
{{ form.is_active(class="form-check-input") }}
|
|
{{ form.is_active.label(class="form-check-label") }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mb-4">
|
|
{{ form.description.label(class="form-label") }}
|
|
{{ form.description(class="form-control", rows="3", placeholder=_("Optional: Add any additional details about this classroom...")) }}
|
|
{% if form.description.errors %}
|
|
<div class="text-danger small mt-1">
|
|
{{ form.description.errors[0] }}
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<!-- Preview Section -->
|
|
<div class="alert alert-info">
|
|
<h6 class="alert-heading">
|
|
<i class="bi bi-info-circle"></i> {% trans %}Preview{% endtrans %}
|
|
</h6>
|
|
<div id="classroom-preview">
|
|
<p class="mb-1">{% trans %}Fill in the form to see a preview of the classroom code:{% endtrans %}
|
|
<span class="fw-bold" id="preview-code">-</span>
|
|
</p>
|
|
<p class="mb-0">{% trans %}Full location:{% endtrans %}
|
|
<span class="fw-bold" id="preview-location">-</span>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="d-flex justify-content-between">
|
|
<a href="{{ url_for('classrooms.list_classrooms') }}" class="btn btn-outline-secondary">
|
|
<i class="bi bi-x-circle"></i> {% trans %}Cancel{% endtrans %}
|
|
</a>
|
|
<button type="submit" class="btn btn-primary">
|
|
<i class="bi bi-save me-1"></i> {{ form.submit.label.text }}
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Resources Section -->
|
|
<div class="row mt-4 mb-4">
|
|
<div class="col-lg-8 mx-auto">
|
|
<div class="card border-0 shadow-sm">
|
|
<div class="card-header bg-body-tertiary border-0 py-3">
|
|
<h5 class="mb-0 h6 fw-bold">
|
|
<i class="bi bi-tools text-warning me-2"></i> {% trans %}Resources (Optional){% endtrans %}
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<p class="text-muted mb-0">{% trans %}You can add classroom resources after creating the classroom.{% endtrans %}</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block extra_js %}
|
|
<script>
|
|
$(document).ready(function() {
|
|
function updatePreview() {
|
|
const building = $('#building').val();
|
|
const roomNumber = $('#room_number').val();
|
|
const floor = $('#floor').val();
|
|
const floorLabel = '{{ _("Floor") }}';
|
|
|
|
if (building && roomNumber && floor) {
|
|
$('#preview-code').text(`${building}-${roomNumber}`);
|
|
$('#preview-location').text(`${building} - ${floorLabel} ${floor}`);
|
|
} else {
|
|
$('#preview-code').text('-');
|
|
$('#preview-location').text('-');
|
|
}
|
|
}
|
|
|
|
// Update preview when inputs change
|
|
$('#building, #room_number, #floor').on('input', updatePreview);
|
|
|
|
// Initialize preview
|
|
updatePreview();
|
|
|
|
// Form validation
|
|
$('#classroom-form').on('submit', function(e) {
|
|
let isValid = true;
|
|
|
|
if (!$('#building').val().trim()) {
|
|
$('#building').addClass('is-invalid');
|
|
isValid = false;
|
|
} else {
|
|
$('#building').removeClass('is-invalid');
|
|
}
|
|
|
|
if (!$('#room_number').val().trim()) {
|
|
$('#room_number').addClass('is-invalid');
|
|
isValid = false;
|
|
} else {
|
|
$('#room_number').removeClass('is-invalid');
|
|
}
|
|
|
|
var floorVal = $('#floor').val();
|
|
if (floorVal === '' || isNaN(floorVal)) {
|
|
$('#floor').addClass('is-invalid');
|
|
isValid = false;
|
|
} else {
|
|
$('#floor').removeClass('is-invalid');
|
|
}
|
|
|
|
var capVal = $('#capacity').val() ? $('#capacity').val().trim() : '';
|
|
if (!capVal || (capVal !== '∞' && capVal !== '0' && isNaN(capVal))) {
|
|
$('#capacity').addClass('is-invalid');
|
|
isValid = false;
|
|
} else {
|
|
$('#capacity').removeClass('is-invalid');
|
|
}
|
|
|
|
return isValid;
|
|
});
|
|
|
|
$('#btnInfinityAdd').on('click', function() {
|
|
$('#capacity').val('∞').focus();
|
|
});
|
|
});
|
|
</script>
|
|
{% endblock %} |