198 lines
7.7 KiB
HTML
198 lines
7.7 KiB
HTML
{% extends "base.html" %}
|
|
|
|
{% block title %}Add Classroom - 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> Add Classroom
|
|
</h1>
|
|
<a href="{{ url_for('classrooms.list_classrooms') }}" class="btn btn-outline-secondary">
|
|
<i class="bi bi-arrow-left"></i> Back to Classrooms
|
|
</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-white border-0">
|
|
<h5 class="mb-0">
|
|
<i class="bi bi-door-open text-primary"></i> Classroom Information
|
|
</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">
|
|
{{ form.capacity.label(class="form-label") }}
|
|
{{ form.capacity(class="form-control", placeholder="30") }}
|
|
{% 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">
|
|
{{ form.is_active.label(class="form-check-label") }}
|
|
<div class="form-check">
|
|
{{ form.is_active(class="form-check-input") }}
|
|
</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> Preview
|
|
</h6>
|
|
<div id="classroom-preview">
|
|
<p class="mb-0">Fill in the form to see a preview of the classroom code:
|
|
<span class="fw-bold" id="preview-code">-</span>
|
|
</p>
|
|
<p class="mb-0">Full location:
|
|
<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> Cancel
|
|
</a>
|
|
{{ form.submit(class="btn btn-primary") }}
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Resources Section -->
|
|
<div class="row mt-4">
|
|
<div class="col-lg-8 mx-auto">
|
|
<div class="card border-0 shadow-sm">
|
|
<div class="card-header bg-white border-0">
|
|
<h5 class="mb-0">
|
|
<i class="bi bi-tools text-warning"></i> Resources (Optional)
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<p class="text-muted">You can add classroom resources after creating the classroom.</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();
|
|
|
|
if (building && roomNumber && floor) {
|
|
$('#preview-code').text(`${building}-${roomNumber}`);
|
|
$('#preview-location').text(`${building} - Floor ${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;
|
|
|
|
// Required fields validation
|
|
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');
|
|
}
|
|
|
|
if (!$('#floor').val()) {
|
|
$('#floor').addClass('is-invalid');
|
|
isValid = false;
|
|
} else {
|
|
$('#floor').removeClass('is-invalid');
|
|
}
|
|
|
|
if (!$('#capacity').val() || $('#capacity').val() < 1) {
|
|
$('#capacity').addClass('is-invalid');
|
|
isValid = false;
|
|
} else {
|
|
$('#capacity').removeClass('is-invalid');
|
|
}
|
|
|
|
return isValid;
|
|
});
|
|
});
|
|
</script>
|
|
{% endblock %} |