HH/templates/observations/category_list.html
2026-01-04 10:32:40 +03:00

112 lines
5.5 KiB
HTML

{% extends "layouts/base.html" %}
{% load i18n %}
{% load static %}
{% block title %}{% trans "Observation Categories" %} - PX360{% endblock %}
{% block content %}
<div class="container-fluid">
<!-- Page Header -->
<div class="d-flex justify-content-between align-items-center mb-4">
<div>
<h2 class="mb-1">
<i class="bi bi-tags text-primary me-2"></i>
{% trans "Observation Categories" %}
</h2>
<p class="text-muted mb-0">{% trans "Manage categories for observation classification" %}</p>
</div>
<div class="d-flex gap-2">
<a href="{% url 'observations:observation_list' %}" class="btn btn-outline-secondary">
<i class="bi bi-arrow-left me-1"></i>{% trans "Back to Observations" %}
</a>
<a href="{% url 'observations:category_create' %}" class="btn btn-primary">
<i class="bi bi-plus-circle me-1"></i>{% trans "Add Category" %}
</a>
</div>
</div>
<!-- Categories Table -->
<div class="card">
<div class="card-body 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 class="bi bi-pencil"></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 class="bi bi-trash"></i>
</button>
</form>
{% endif %}
</div>
</td>
</tr>
{% empty %}
<tr>
<td colspan="7" class="text-center py-5">
<i class="bi bi-tags" style="font-size: 3rem; 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 class="bi bi-plus-circle me-1"></i>{% trans "Add First Category" %}
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
{% endblock %}