setup update 3
This commit is contained in:
@@ -0,0 +1,198 @@
|
||||
{% 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 %}
|
||||
+128
-111
@@ -3,124 +3,130 @@
|
||||
{% block title %}Classrooms - Edu-Space Admin{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row mb-4">
|
||||
<div class="container-fluid pt-5 mt-4">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h1 class="h3 mb-0">
|
||||
<i class="bi bi-door-open text-primary"></i> Classrooms
|
||||
<small class="text-muted ms-2">Management</small>
|
||||
</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Search and Filter -->
|
||||
<div class="card border-0 shadow-sm mb-4">
|
||||
<div class="card-body">
|
||||
<form method="GET" class="row g-3">
|
||||
<div class="col-md-4">
|
||||
<input type="text" class="form-control" name="search"
|
||||
placeholder="Search classrooms..." value="{{ search }}">
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<select class="form-select" name="campus">
|
||||
<option value="">All Campuses</option>
|
||||
<option value="Main Campus" {% if campus == 'Main Campus' %}selected{% endif %}>Main Campus</option>
|
||||
<option value="North Campus" {% if campus == 'North Campus' %}selected{% endif %}>North Campus</option>
|
||||
<option value="Science & Technology Campus" {% if campus == 'Science & Technology Campus' %}selected{% endif %}>Science & Technology Campus</option>
|
||||
<option value="Downtown Campus" {% if campus == 'Downtown Campus' %}selected{% endif %}>Downtown Campus</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="bi bi-search"></i> Search
|
||||
</button>
|
||||
<a href="{{ url_for('classrooms.list_classrooms') }}" class="btn btn-outline-secondary">
|
||||
<i class="bi bi-arrow-clockwise"></i> Reset
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-md-2 text-end">
|
||||
<a href="{{ url_for('classrooms.add_classroom') }}" class="btn btn-success">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1 class="h3">
|
||||
<i class="bi bi-door-open text-primary"></i> Classrooms
|
||||
</h1>
|
||||
<div>
|
||||
<a href="{{ url_for('classrooms.add_classroom') }}" class="btn btn-primary">
|
||||
<i class="bi bi-plus-circle"></i> Add Classroom
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Filters -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card border-0 shadow-sm">
|
||||
<div class="card-body">
|
||||
<form method="GET" class="row g-3">
|
||||
<div class="col-md-4">
|
||||
<input type="text" name="search" class="form-control"
|
||||
placeholder="Search by building, room, description..."
|
||||
value="{{ search }}">
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" name="active_only"
|
||||
id="activeOnly" {% if active_only %}checked{% endif %}>
|
||||
<label class="form-check-label" for="activeOnly">
|
||||
Show active classrooms only
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<button type="submit" class="btn btn-outline-primary">
|
||||
<i class="bi bi-search"></i> Search
|
||||
</button>
|
||||
<a href="{{ url_for('classrooms.list_classrooms') }}" class="btn btn-outline-secondary">
|
||||
<i class="bi bi-x-circle"></i> Clear
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Classrooms Grid -->
|
||||
<div class="row">
|
||||
{% if classrooms and classrooms.items %}
|
||||
<div class="row mt-4">
|
||||
{% for classroom in classrooms.items %}
|
||||
<div class="col-md-6 col-lg-4 mb-4">
|
||||
<div class="col-lg-4 col-md-6 mb-4">
|
||||
<div class="card border-0 shadow-sm h-100">
|
||||
<div class="card-header bg-white border-0">
|
||||
<div class="d-flex justify-content-between align-items-start">
|
||||
<div>
|
||||
<h5 class="card-title mb-1">{{ classroom.code }}</h5>
|
||||
<p class="text-muted small mb-0">{{ classroom.name }}</p>
|
||||
</div>
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-sm btn-outline-secondary" data-bs-toggle="dropdown">
|
||||
<i class="bi bi-three-dots-vertical"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="{{ url_for('classrooms.view_classroom', Id=classroom.id) }}">
|
||||
<i class="bi bi-eye"></i> View Details
|
||||
</a></li>
|
||||
<li><a class="dropdown-item" href="{{ url_for('classrooms.edit_classroom', Id=classroom.id) }}">
|
||||
<i class="bi bi-pencil"></i> Edit
|
||||
</a></li>
|
||||
<li><a class="dropdown-item text-danger" href="{{ url_for('classrooms.delete_classroom', Id=classroom.id) }}">
|
||||
<i class="bi bi-trash"></i> Delete
|
||||
</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row g-2">
|
||||
<div class="d-flex justify-content-between align-items-start mb-3">
|
||||
<div>
|
||||
<h5 class="card-title mb-1">
|
||||
{{ classroom.code }}
|
||||
</h5>
|
||||
<p class="text-muted small mb-2">
|
||||
<i class="bi bi-geo-alt"></i> {{ classroom.get_full_location() }}
|
||||
</p>
|
||||
</div>
|
||||
<span class="badge {% if classroom.is_active %}bg-success{% else %}bg-secondary{% endif %}">
|
||||
{% if classroom.is_active %}Active{% else %}Inactive{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="row small">
|
||||
<div class="col-6">
|
||||
<div class="d-flex align-items-center">
|
||||
<i class="bi bi-building text-primary me-2"></i>
|
||||
<span class="small">{{ classroom.building }}</span>
|
||||
</div>
|
||||
<span class="text-muted">Capacity:</span>
|
||||
<strong>{{ classroom.capacity }}</strong>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="d-flex align-items-center">
|
||||
<i class="bi bi-layers text-info me-2"></i>
|
||||
<span class="small">Floor {{ classroom.floor }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="d-flex align-items-center">
|
||||
<i class="bi bi-people text-success me-2"></i>
|
||||
<span class="small">{{ classroom.capacity }} seats</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="d-flex align-items-center">
|
||||
<i class="bi bi-geo-alt text-warning me-2"></i>
|
||||
<span class="small">{{ classroom.campus_location }}</span>
|
||||
</div>
|
||||
<span class="text-muted">Building:</span>
|
||||
<strong>{{ classroom.building }}</strong>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if classroom.description %}
|
||||
<div class="mt-3">
|
||||
<p class="small text-muted">{{ classroom.description[:100] }}{% if classroom.description|length > 100 %}...{% endif %}</p>
|
||||
</div>
|
||||
<p class="card-text small text-muted mt-2">
|
||||
{{ classroom.description[:100] }}{% if classroom.description|length > 100 %}...{% endif %}
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
<div class="mt-3">
|
||||
<span class="badge bg-success">
|
||||
<i class="bi bi-check-circle"></i> Active
|
||||
</span>
|
||||
|
||||
<!-- Resources indicator -->
|
||||
<div class="mt-2">
|
||||
<small class="text-muted">
|
||||
<i class="bi bi-tools"></i>
|
||||
{% if classroom.resources %}
|
||||
{{ classroom.resources|length }} resources
|
||||
{% else %}
|
||||
No resources registered
|
||||
{% endif %}
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-footer bg-white border-0">
|
||||
<div class="d-grid">
|
||||
<a href="{{ url_for('classrooms.view_classroom', Id=classroom.id) }}"
|
||||
class="btn btn-outline-primary btn-sm">
|
||||
<i class="bi bi-eye"></i> View Details
|
||||
</a>
|
||||
<div class="d-flex justify-content-between">
|
||||
<div>
|
||||
<a href="{{ url_for('classrooms.view_classroom', id=classroom.id) }}"
|
||||
class="btn btn-sm btn-outline-primary">
|
||||
<i class="bi bi-eye"></i> View
|
||||
</a>
|
||||
<a href="{{ url_for('classrooms.edit_classroom', id=classroom.id) }}"
|
||||
class="btn btn-sm btn-outline-secondary">
|
||||
<i class="bi bi-pencil"></i> Edit
|
||||
</a>
|
||||
</div>
|
||||
<form method="POST" action="{{ url_for('classrooms.toggle_classroom', id=classroom.id) }}"
|
||||
class="d-inline">
|
||||
<button type="submit" class="btn btn-sm
|
||||
{% if classroom.is_active %}btn-outline-warning{% else %}btn-outline-success{% endif %}">
|
||||
{% if classroom.is_active %}
|
||||
<i class="bi bi-pause-circle"></i> Deactivate
|
||||
{% else %}
|
||||
<i class="bi bi-play-circle"></i> Activate
|
||||
{% endif %}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -130,12 +136,12 @@
|
||||
|
||||
<!-- Pagination -->
|
||||
{% if classrooms.pages > 1 %}
|
||||
<nav aria-label="Classrooms pagination">
|
||||
<nav aria-label="Classroom pagination">
|
||||
<ul class="pagination justify-content-center">
|
||||
{% if classrooms.has_prev %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{{ url_for('classrooms.list_classrooms', page=classrooms.prev_num, search=search, campus=campus) }}">
|
||||
<i class="bi bi-chevron-left"></i>
|
||||
<a class="page-link" href="{{ url_for('classrooms.list_classrooms', page=classrooms.prev_num, search=search, active_only=active_only) }}">
|
||||
Previous
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
@@ -144,7 +150,7 @@
|
||||
{% if page_num %}
|
||||
{% if page_num != classrooms.page %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{{ url_for('classrooms.list_classrooms', page=page_num, search=search, campus=campus) }}">
|
||||
<a class="page-link" href="{{ url_for('classrooms.list_classrooms', page=page_num, search=search, active_only=active_only) }}">
|
||||
{{ page_num }}
|
||||
</a>
|
||||
</li>
|
||||
@@ -155,15 +161,15 @@
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<li class="page-item disabled">
|
||||
<span class="page-link">...</span>
|
||||
<span class="page-link">…</span>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% if classrooms.has_next %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{{ url_for('classrooms.list_classrooms', page=classrooms.next_num, search=search, campus=campus) }}">
|
||||
<i class="bi bi-chevron-right"></i>
|
||||
<a class="page-link" href="{{ url_for('classrooms.list_classrooms', page=classrooms.next_num, search=search, active_only=active_only) }}">
|
||||
Next
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
@@ -171,14 +177,25 @@
|
||||
</nav>
|
||||
{% endif %}
|
||||
|
||||
{% if not classrooms.items %}
|
||||
<div class="text-center py-5">
|
||||
<i class="bi bi-x-circle text-muted" style="font-size: 3rem;"></i>
|
||||
<h4 class="text-muted mt-3">No classrooms found</h4>
|
||||
<p class="text-muted">Try adjusting your search criteria or add a new classroom.</p>
|
||||
<a href="{{ url_for('classrooms.add_classroom') }}" class="btn btn-primary">
|
||||
<i class="bi bi-plus-circle"></i> Add First Classroom
|
||||
</a>
|
||||
{% else %}
|
||||
<div class="row mt-4">
|
||||
<div class="col-12">
|
||||
<div class="text-center py-5">
|
||||
<i class="bi bi-door-open text-muted" style="font-size: 4rem;"></i>
|
||||
<h4 class="mt-3 text-muted">No classrooms found</h4>
|
||||
<p class="text-muted">
|
||||
{% if search %}
|
||||
No classrooms match your search criteria.
|
||||
{% else %}
|
||||
No classrooms have been registered yet.
|
||||
{% endif %}
|
||||
</p>
|
||||
<a href="{{ url_for('classrooms.add_classroom') }}" class="btn btn-primary">
|
||||
<i class="bi bi-plus-circle"></i> Add First Classroom
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user