203 lines
9.0 KiB
HTML
203 lines
9.0 KiB
HTML
{% extends 'layouts/base.html' %}
|
|
{% load i18n static %}
|
|
|
|
{% block title %}{% if category %}{% trans "Update Category" %}{% else %}{% trans "Create Category" %}{% endif %}{% endblock %}
|
|
|
|
{% block extra_css %}
|
|
<style>
|
|
:root {
|
|
--hh-navy: #005696;
|
|
--hh-blue: #007bbd;
|
|
--hh-light: #eef6fb;
|
|
--hh-slate: #64748b;
|
|
}
|
|
|
|
.page-header-gradient {
|
|
background: linear-gradient(135deg, var(--hh-navy) 0%, #0069a8 50%, var(--hh-blue) 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;
|
|
}
|
|
|
|
.btn-transition {
|
|
transition: all 0.2s ease-in-out;
|
|
}
|
|
</style>
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="px-6 py-4">
|
|
<div class="page-header-gradient">
|
|
<div class="flex justify-between items-center">
|
|
<div>
|
|
<h1 class="text-2xl font-bold mb-1">{% if category %}{% trans "Update Category" %}{% else %}{% trans "Create Category" %}{% endif %}</h1>
|
|
<p class="text-blue-100 text-sm">{% if category %}{% trans "Edit standard category" %}{% else %}{% trans "Add new standard category" %}{% endif %}</p>
|
|
</div>
|
|
<div class="flex gap-2">
|
|
<a href="{% url 'standards:category_list' %}" class="btn-transition inline-flex items-center px-4 py-2.5 bg-white/10 border-2 border-white/30 text-white font-medium rounded-xl hover:bg-white hover:text-navy transition">
|
|
<i data-lucide="arrow-left" class="w-4 h-4 me-2"></i>{% trans "Back to Categories" %}
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
|
<div class="lg:col-span-2">
|
|
<div class="section-card">
|
|
<div class="section-header">
|
|
<div class="section-icon bg-navy/10">
|
|
<i data-lucide="tag" class="w-5 h-5 text-navy"></i>
|
|
</div>
|
|
<h5 class="text-lg font-semibold text-gray-800">{% trans "Category Information" %}</h5>
|
|
</div>
|
|
<div class="p-6">
|
|
<form method="post">
|
|
{% csrf_token %}
|
|
|
|
<div class="mb-4">
|
|
<label for="{{ form.name.id_for_label }}" class="block text-sm font-medium text-gray-700 mb-2">
|
|
{{ form.name.label }} <span class="text-red-500">*</span>
|
|
</label>
|
|
{{ form.name }}
|
|
{% if form.name.errors %}
|
|
<p class="mt-1 text-xs text-red-600">{{ form.name.errors }}</p>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<div class="mb-4">
|
|
<label for="{{ form.name_ar.id_for_label }}" class="block text-sm font-medium text-gray-700 mb-2">
|
|
{{ form.name_ar.label }}
|
|
</label>
|
|
{{ form.name_ar }}
|
|
{% if form.name_ar.errors %}
|
|
<p class="mt-1 text-xs text-red-600">{{ form.name_ar.errors }}</p>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<div class="mb-4">
|
|
<label for="{{ form.order.id_for_label }}" class="block text-sm font-medium text-gray-700 mb-2">
|
|
{{ form.order.label }} <span class="text-red-500">*</span>
|
|
</label>
|
|
{{ form.order }}
|
|
<p class="mt-1 text-xs text-gray-500">{% trans "Lower numbers appear first in lists" %}</p>
|
|
{% if form.order.errors %}
|
|
<p class="mt-1 text-xs text-red-600">{{ form.order.errors }}</p>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<div class="mb-4">
|
|
<label for="{{ form.description.id_for_label }}" class="block text-sm font-medium text-gray-700 mb-2">
|
|
{{ form.description.label }}
|
|
</label>
|
|
{{ form.description }}
|
|
{% if form.description.errors %}
|
|
<p class="mt-1 text-xs text-red-600">{{ form.description.errors }}</p>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<div class="mb-6">
|
|
<label class="flex items-center">
|
|
{{ form.is_active }}
|
|
<span class="ml-2 text-sm text-gray-700">{{ form.is_active.label }}</span>
|
|
</label>
|
|
</div>
|
|
|
|
<div class="flex gap-3">
|
|
<button type="submit" class="btn-transition inline-flex items-center px-6 py-2.5 bg-green-500 text-white font-medium rounded-xl hover:bg-green-600 transition">
|
|
<i data-lucide="save" class="w-4 h-4 me-2"></i>{% if category %}{% trans "Update Category" %}{% else %}{% trans "Create Category" %}{% endif %}
|
|
</button>
|
|
<a href="{% url 'standards:category_list' %}" class="btn-transition inline-flex items-center px-6 py-2.5 bg-gray-100 text-gray-700 font-medium rounded-xl hover:bg-gray-200 transition">
|
|
{% trans "Cancel" %}
|
|
</a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="lg:col-span-1">
|
|
<div class="section-card">
|
|
<div class="section-header">
|
|
<div class="section-icon bg-blue/10">
|
|
<i data-lucide="help-circle" class="w-5 h-5 text-blue"></i>
|
|
</div>
|
|
<h5 class="text-lg font-semibold text-gray-800">{% trans "Help" %}</h5>
|
|
</div>
|
|
<div class="p-6">
|
|
<div class="mb-4">
|
|
<h6 class="text-sm font-semibold text-gray-800 mb-2">{% trans "Category Order" %}</h6>
|
|
<p class="text-xs text-gray-600 mb-2">
|
|
{% trans "Use the order field to control how categories appear in lists and dropdowns. Lower numbers appear first." %}
|
|
</p>
|
|
<div class="text-xs text-gray-500 space-y-1">
|
|
<p><strong>{% trans "Example:" %}</strong></p>
|
|
<p class="ml-2">1 - Patient Safety</p>
|
|
<p class="ml-2">2 - Quality Management</p>
|
|
<p class="ml-2">3 - Infection Control</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div>
|
|
<h6 class="text-sm font-semibold text-gray-800 mb-2">{% trans "Active Status" %}</h6>
|
|
<p class="text-xs text-gray-600">
|
|
{% trans "Only active categories can be used when creating new standards. Inactive categories remain in the system but are not available for selection." %}
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const formInputs = document.querySelectorAll('input[type="text"], input[type="number"], select, textarea');
|
|
formInputs.forEach(input => {
|
|
if (!input.classList.contains('form-control') && input.type !== 'checkbox') {
|
|
input.classList.add('w-full', 'px-4', 'py-2.5', 'border', 'border-gray-300', 'rounded-lg', 'focus:ring-2', 'focus:ring-navy', 'focus:border-transparent', 'transition');
|
|
}
|
|
});
|
|
|
|
const checkboxes = document.querySelectorAll('input[type="checkbox"]');
|
|
checkboxes.forEach(checkbox => {
|
|
if (!checkbox.classList.contains('rounded')) {
|
|
checkbox.classList.add('rounded', 'border-gray-300', 'text-navy', 'focus:ring-navy', 'w-4', 'h-4');
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
{% endblock %}
|