HH/templates/px_sources/source_confirm_delete.html
2026-02-25 04:47:05 +03:00

145 lines
7.7 KiB
HTML

{% extends "layouts/base.html" %}
{% load i18n %}
{% block title %}{% trans "Delete Source" %}{% endblock %}
{% block content %}
<div class="p-6">
<!-- Breadcrumb -->
<nav class="mb-4">
<ol class="flex items-center gap-2 text-sm text-slate">
<li><a href="{% url 'px_sources:source_list' %}" class="text-blue hover:text-navy">{% trans "PX Sources" %}</a></li>
<li><i data-lucide="chevron-right" class="w-4 h-4"></i></li>
<li><a href="{% url 'px_sources:source_detail' source.pk %}" class="text-blue hover:text-navy">{{ source.name_en }}</a></li>
<li><i data-lucide="chevron-right" class="w-4 h-4"></i></li>
<li class="text-navy font-semibold">{% trans "Delete" %}</li>
</ol>
</nav>
<!-- Page Header -->
<div class="flex flex-wrap justify-between items-center gap-4 mb-6">
<div>
<h1 class="text-2xl font-bold text-navy flex items-center gap-3">
<i data-lucide="alert-triangle" class="w-8 h-8 text-red-500"></i>
{% trans "Delete Source" %}
</h1>
<p class="text-slate mt-1">{{ source.name_en }}</p>
</div>
<div>
<a href="{% url 'px_sources:source_detail' source.pk %}"
class="inline-flex items-center gap-2 px-4 py-2 border border-slate-200 text-slate-700 rounded-lg hover:bg-slate-50 transition">
<i data-lucide="x" class="w-4 h-4"></i> {% trans "Cancel" %}
</a>
</div>
</div>
<!-- Delete Confirmation Card -->
<div class="bg-white rounded-xl shadow-sm border border-slate-200">
<div class="p-4 border-b border-slate-200 bg-slate-50/50 rounded-t-xl">
<h2 class="text-lg font-semibold text-navy flex items-center gap-2">
<i data-lucide="alert-circle" class="w-5 h-5 text-slate"></i>
{% trans "Confirm Deletion" %}
</h2>
</div>
<div class="p-6">
<!-- Warning Alert -->
<div class="bg-amber-50 border border-amber-200 rounded-lg p-4 mb-6">
<div class="flex items-start gap-3">
<i data-lucide="alert-circle" class="w-5 h-5 text-amber-600 mt-0.5"></i>
<div>
<h4 class="font-semibold text-amber-800 mb-1">{% trans "Warning" %}</h4>
<p class="text-amber-700 text-sm">{% trans "Are you sure you want to delete this source? This action cannot be undone." %}</p>
</div>
</div>
</div>
<!-- Source Info Table -->
<div class="overflow-x-auto mb-6">
<table class="w-full border border-slate-200 rounded-lg">
<tbody class="divide-y divide-slate-200">
<tr>
<th class="py-3 px-4 text-left text-sm font-semibold text-navy bg-slate-50 w-1/3">{% trans "Name (English)" %}</th>
<td class="py-3 px-4 text-navy font-semibold">{{ source.name_en }}</td>
</tr>
<tr>
<th class="py-3 px-4 text-left text-sm font-semibold text-navy bg-slate-50">{% trans "Name (Arabic)" %}</th>
<td class="py-3 px-4 text-navy" dir="rtl">{{ source.name_ar|default:"-" }}</td>
</tr>
<tr>
<th class="py-3 px-4 text-left text-sm font-semibold text-navy bg-slate-50">{% trans "Description" %}</th>
<td class="py-3 px-4 text-slate">{{ source.description|default:"-"|truncatewords:20 }}</td>
</tr>
<tr>
<th class="py-3 px-4 text-left text-sm font-semibold text-navy bg-slate-50">{% trans "Status" %}</th>
<td class="py-3 px-4">
{% if source.is_active %}
<span class="inline-flex items-center gap-1 px-2.5 py-1 bg-green-100 text-green-700 rounded-full text-xs font-semibold">
<i data-lucide="check-circle" class="w-3 h-3"></i>
{% trans "Active" %}
</span>
{% else %}
<span class="inline-flex items-center gap-1 px-2.5 py-1 bg-slate-100 text-slate-600 rounded-full text-xs font-semibold">
<i data-lucide="x-circle" class="w-3 h-3"></i>
{% trans "Inactive" %}
</span>
{% endif %}
</td>
</tr>
<tr>
<th class="py-3 px-4 text-left text-sm font-semibold text-navy bg-slate-50">{% trans "Usage Count" %}</th>
<td class="py-3 px-4">
{% if usage_count > 0 %}
<span class="inline-flex items-center gap-1 px-2.5 py-1 bg-red-100 text-red-700 rounded-full text-xs font-semibold">{{ usage_count }}</span>
{% else %}
<span class="inline-flex items-center gap-1 px-2.5 py-1 bg-green-100 text-green-700 rounded-full text-xs font-semibold">0</span>
{% endif %}
</td>
</tr>
</tbody>
</table>
</div>
{% if usage_count > 0 %}
<!-- Cannot Delete Alert -->
<div class="bg-red-50 border border-red-200 rounded-lg p-4 mb-6">
<div class="flex items-start gap-3">
<i data-lucide="alert-triangle" class="w-5 h-5 text-red-600 mt-0.5"></i>
<div>
<h5 class="font-semibold text-red-800 mb-1">{% trans "Cannot Delete" %}</h5>
<p class="text-red-700 text-sm mb-2">{% trans "This source has been used in {{ usage_count }} record(s). You cannot delete sources that have usage records." %}</p>
<p class="text-red-700 text-sm"><strong>{% trans "Recommended action:" %}</strong> {% trans "Deactivate this source instead by editing it and unchecking the 'Active' checkbox." %}</p>
</div>
</div>
</div>
{% endif %}
<!-- Action Buttons -->
<form method="post" class="flex gap-3">
{% csrf_token %}
{% if usage_count == 0 %}
<button type="submit"
class="inline-flex items-center gap-2 px-6 py-2 bg-red-500 text-white rounded-lg hover:bg-red-600 transition shadow-lg shadow-red-500/20">
<i data-lucide="trash-2" class="w-4 h-4"></i> {% trans "Yes, Delete" %}
</button>
{% else %}
<button type="button" disabled
class="inline-flex items-center gap-2 px-6 py-2 bg-red-300 text-white rounded-lg cursor-not-allowed">
<i data-lucide="trash-2" class="w-4 h-4"></i> {% trans "Cannot Delete" %}
</button>
{% endif %}
<a href="{% url 'px_sources:source_detail' source.pk %}"
class="inline-flex items-center gap-2 px-6 py-2 border border-slate-200 text-slate-700 rounded-lg hover:bg-slate-50 transition">
{% trans "Cancel" %}
</a>
</form>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
lucide.createIcons();
});
</script>
{% endblock %}