HH/templates/observations/category_list.html
2026-03-15 23:48:45 +03:00

164 lines
7.4 KiB
HTML

{% extends "layouts/base.html" %}
{% load i18n %}
{% load static %}
{% block title %}{% trans "Observation Categories" %} - PX360{% endblock %}
{% block extra_css %}
<style>
.page-header-gradient {
background: linear-gradient(135deg, #005696 0%, #0069a8 50%, #007bbd 100%);
color: white;
padding: 1.5rem 2rem;
border-radius: 1rem;
margin-bottom: 1.5rem;
box-shadow: 0 10px 15px -3px rgba(0, 86, 150, 0.2);
}
.section-card {
background: white;
border-radius: 1rem;
border: 2px solid #e2e8f0;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
overflow: hidden;
transition: all 0.3s ease;
}
.section-card:hover {
border-color: #005696;
box-shadow: 0 10px 25px -5px rgba(0, 86, 150, 0.15);
}
.section-header {
padding: 1rem 1.5rem;
border-bottom: 2px solid #e2e8f0;
background: linear-gradient(to right, #f8fafc, #f1f5f9);
display: flex;
align-items: center;
gap: 0.75rem;
}
.section-icon {
width: 40px;
height: 40px;
border-radius: 0.75rem;
display: flex;
align-items: center;
justify-content: center;
}
</style>
{% endblock %}
{% block content %}
<div class="container-fluid">
<!-- Page Header -->
<div class="page-header-gradient">
<div class="d-flex justify-content-between align-items-center">
<div>
<h2 class="mb-1">
<i data-lucide="tags" class="me-2" style="width: 28px; height: 28px; vertical-align: text-bottom;"></i>
{% trans "Observation Categories" %}
</h2>
<p class="mb-0 opacity-75">{% trans "Manage categories for observation classification" %}</p>
</div>
<div class="d-flex gap-2">
<a href="{% url 'observations:observation_list' %}" class="btn btn-light">
<i data-lucide="arrow-left" style="width: 16px; height: 16px; vertical-align: text-bottom;"></i>
{% trans "Back to Observations" %}
</a>
<a href="{% url 'observations:category_create' %}" class="btn btn-light fw-bold">
<i data-lucide="plus-circle" style="width: 16px; height: 16px; vertical-align: text-bottom;"></i>
{% trans "Add Category" %}
</a>
</div>
</div>
</div>
<!-- Categories Table -->
<div class="section-card">
<div class="section-header">
<div class="section-icon" style="background: linear-gradient(135deg, #005696, #007bbd);">
<i data-lucide="list" style="width: 20px; height: 20px; color: white;"></i>
</div>
<h5 class="mb-0 fw-bold">{% trans "Category List" %}</h5>
</div>
<div class="p-0">
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead class="table-light">
<tr>
<th style="width: 50px;">{% trans "Order" %}</th>
<th>{% trans "Name (English)" %}</th>
<th>{% trans "Name (Arabic)" %}</th>
<th>{% trans "Icon" %}</th>
<th>{% trans "Observations" %}</th>
<th>{% trans "Status" %}</th>
<th>{% trans "Actions" %}</th>
</tr>
</thead>
<tbody>
{% for category in categories %}
<tr>
<td>
<span class="badge bg-secondary">{{ category.sort_order }}</span>
</td>
<td>
<strong>{{ category.name_en }}</strong>
{% if category.description %}
<br><small class="text-muted">{{ category.description|truncatewords:10 }}</small>
{% endif %}
</td>
<td dir="rtl">{{ category.name_ar|default:"-" }}</td>
<td>
{% if category.icon %}
<i class="{{ category.icon }}"></i>
<small class="text-muted ms-1">{{ category.icon }}</small>
{% else %}
<span class="text-muted">-</span>
{% endif %}
</td>
<td>
<span class="badge bg-info">{{ category.observations.count }}</span>
</td>
<td>
{% if category.is_active %}
<span class="badge bg-success">{% trans "Active" %}</span>
{% else %}
<span class="badge bg-secondary">{% trans "Inactive" %}</span>
{% endif %}
</td>
<td>
<div class="btn-group btn-group-sm">
<a href="{% url 'observations:category_edit' category.id %}"
class="btn btn-outline-primary" title="{% trans 'Edit' %}">
<i data-lucide="pencil" style="width: 14px; height: 14px;"></i>
</a>
{% if not category.observations.exists %}
<form method="post" action="{% url 'observations:category_delete' category.id %}"
style="display: inline;"
onsubmit="return confirm('{% trans "Are you sure you want to delete this category?" %}');">
{% csrf_token %}
<button type="submit" class="btn btn-outline-danger" title="{% trans 'Delete' %}">
<i data-lucide="trash-2" style="width: 14px; height: 14px;"></i>
</button>
</form>
{% endif %}
</div>
</td>
</tr>
{% empty %}
<tr>
<td colspan="7" class="text-center py-5">
<i data-lucide="tags" style="width: 48px; height: 48px; color: #ccc;"></i>
<p class="text-muted mt-3">{% trans "No categories found" %}</p>
<a href="{% url 'observations:category_create' %}" class="btn btn-primary">
<i data-lucide="plus-circle" style="width: 16px; height: 16px; vertical-align: text-bottom;"></i>
{% trans "Add First Category" %}
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
{% endblock %}