291 lines
14 KiB
HTML
291 lines
14 KiB
HTML
{% extends "layouts/base.html" %}
|
|
{% load i18n %}
|
|
|
|
{% block title %}{{ template.name }} - {% trans "Survey Template" %} - 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 %}
|
|
<!-- Back Button -->
|
|
<div class="mb-6">
|
|
<a href="{% url 'surveys:template_list' %}" class="inline-flex items-center gap-2 px-4 py-2 border border-slate-200 rounded-xl text-slate hover:text-navy hover:bg-light transition text-sm font-semibold">
|
|
<i data-lucide="arrow-left" class="w-4 h-4"></i> {% trans "Back to Templates" %}
|
|
</a>
|
|
</div>
|
|
|
|
<!-- Breadcrumb & Header -->
|
|
<header class="mb-6">
|
|
<div class="flex items-center gap-2 text-sm text-slate mb-2">
|
|
<a href="{% url 'surveys:template_list' %}">{% trans "Templates" %}</a>
|
|
<i data-lucide="chevron-right" class="w-4 h-4"></i>
|
|
<span class="font-bold text-navy">{{ template.name }}</span>
|
|
{% if template.is_active %}
|
|
<span class="ml-2 px-2 py-0.5 rounded-full text-[10px] font-bold uppercase tracking-wider bg-green-100 text-green-700">{% trans "Active" %}</span>
|
|
{% else %}
|
|
<span class="ml-2 px-2 py-0.5 rounded-full text-[10px] font-bold uppercase tracking-wider bg-slate-100 text-slate-600">{% trans "Inactive" %}</span>
|
|
{% endif %}
|
|
</div>
|
|
<div class="flex items-center justify-between">
|
|
<h1 class="text-2xl font-bold text-navy">{{ template.name }}</h1>
|
|
<div class="flex items-center gap-3">
|
|
<a href="{% url 'surveys:template_edit' template.pk %}" class="px-4 py-2 bg-navy text-white rounded-xl font-semibold hover:bg-blue transition flex items-center gap-2 text-sm">
|
|
<i data-lucide="pencil" class="w-4 h-4"></i> {% trans "Edit Template" %}
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
|
|
<!-- Stats Banner -->
|
|
{% if stats %}
|
|
<div class="bg-gradient-to-br from-navy to-blue rounded-2xl p-6 mb-6 text-white shadow-lg">
|
|
<div class="grid grid-cols-2 md:grid-cols-5 gap-6">
|
|
<div class="text-center">
|
|
<div class="text-white/80 text-xs font-semibold mb-1">{% trans "Total Sent" %}</div>
|
|
<div class="text-3xl font-bold">{{ stats.total_instances|default:0 }}</div>
|
|
</div>
|
|
<div class="text-center">
|
|
<div class="text-white/80 text-xs font-semibold mb-1">{% trans "Completed" %}</div>
|
|
<div class="text-3xl font-bold">{{ stats.completed_instances|default:0 }}</div>
|
|
</div>
|
|
<div class="text-center">
|
|
<div class="text-white/80 text-xs font-semibold mb-1">{% trans "Negative" %}</div>
|
|
<div class="text-3xl font-bold text-red-300">{{ stats.negative_instances|default:0 }}</div>
|
|
</div>
|
|
<div class="text-center">
|
|
<div class="text-white/80 text-xs font-semibold mb-1">{% trans "Completion Rate" %}</div>
|
|
<div class="text-3xl font-bold">{{ stats.completion_rate|floatformat:0|default:"0" }}%</div>
|
|
</div>
|
|
<div class="text-center">
|
|
<div class="text-white/80 text-xs font-semibold mb-1">{% trans "Avg Score" %}</div>
|
|
<div class="text-3xl font-bold">{{ stats.avg_score|floatformat:1|default:"-" }}</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Main Content Grid -->
|
|
<div class="grid grid-cols-12 gap-8">
|
|
<!-- Left Column -->
|
|
<div class="col-span-8 space-y-6">
|
|
|
|
<!-- Questions Card -->
|
|
<div class="section-card">
|
|
<div class="section-header">
|
|
<div class="section-icon bg-blue-100">
|
|
<i data-lucide="list-ordered" class="w-5 h-5 text-blue-600"></i>
|
|
</div>
|
|
<h3 class="font-bold text-navy">{% trans "Questions" %}</h3>
|
|
<div class="ml-auto text-xs text-slate font-medium">
|
|
{{ questions|length }} {% trans "question" %}{{ questions|length|pluralize:"s" }}
|
|
</div>
|
|
</div>
|
|
|
|
{% if questions %}
|
|
<div class="overflow-x-auto">
|
|
<table class="w-full">
|
|
<thead class="bg-slate-50 border-b border-slate-100">
|
|
<tr class="text-xs font-bold text-slate uppercase tracking-wider">
|
|
<th class="px-6 py-4 text-left">{% trans "Order" %}</th>
|
|
<th class="px-6 py-4 text-left">{% trans "Question (English)" %}</th>
|
|
<th class="px-6 py-4 text-left">{% trans "Question (Arabic)" %}</th>
|
|
<th class="px-6 py-4 text-left">{% trans "Type" %}</th>
|
|
<th class="px-6 py-4 text-left">{% trans "Required" %}</th>
|
|
<th class="px-6 py-4 text-left">{% trans "Actions" %}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-slate-100">
|
|
{% for question in questions %}
|
|
<tr class="hover:bg-light/30 transition">
|
|
<td class="px-6 py-4">
|
|
<span class="font-semibold text-slate">{{ question.order }}</span>
|
|
</td>
|
|
<td class="px-6 py-4">
|
|
<span class="font-semibold text-navy">{{ question.text|truncatewords:10 }}</span>
|
|
</td>
|
|
<td class="px-6 py-4">
|
|
<span class="text-sm text-slate" dir="rtl">{{ question.text_ar|truncatewords:10 }}</span>
|
|
</td>
|
|
<td class="px-6 py-4">
|
|
<span class="px-2.5 py-1 rounded-lg text-xs font-bold bg-blue-100 text-blue-700">{{ question.get_question_type_display }}</span>
|
|
</td>
|
|
<td class="px-6 py-4">
|
|
{% if question.is_required %}
|
|
<span class="px-2.5 py-1 rounded-lg text-xs font-bold bg-green-100 text-green-700">{% trans "Yes" %}</span>
|
|
{% else %}
|
|
<span class="px-2.5 py-1 rounded-lg text-xs font-bold bg-slate-100 text-slate-600">{% trans "No" %}</span>
|
|
{% endif %}
|
|
</td>
|
|
<td class="px-6 py-4">
|
|
<div class="relative">
|
|
<button type="button" class="dropdown-toggle p-2 text-slate hover:text-navy hover:bg-light rounded-lg transition" data-dropdown="q-dropdown-{{ question.pk }}">
|
|
<i data-lucide="more-horizontal" class="w-5 h-5"></i>
|
|
</button>
|
|
<div id="q-dropdown-{{ question.pk }}" class="dropdown-menu hidden absolute right-0 mt-2 w-48 bg-white rounded-xl shadow-lg border border-slate-100 py-2 z-10">
|
|
<a href="{% url 'surveys:template_edit' template.pk %}#question-{{ question.pk }}" class="flex items-center gap-2 px-4 py-2 text-sm text-slate hover:bg-light hover:text-navy transition">
|
|
<i data-lucide="pencil" class="w-4 h-4"></i> {% trans "Edit" %}
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{% else %}
|
|
<div class="text-center py-12">
|
|
<div class="inline-flex items-center justify-center w-16 h-16 bg-slate-100 rounded-full mb-3">
|
|
<i data-lucide="help-circle" class="w-8 h-8 text-slate-400"></i>
|
|
</div>
|
|
<h3 class="text-lg font-bold text-navy mb-1">{% trans "No Questions Yet" %}</h3>
|
|
<p class="text-slate text-sm mb-4">{% trans "Add questions to this template." %}</p>
|
|
<a href="{% url 'surveys:template_edit' template.pk %}" class="px-4 py-2 bg-navy text-white rounded-xl font-semibold hover:bg-blue transition inline-flex items-center gap-2 text-sm">
|
|
<i data-lucide="plus" class="w-4 h-4"></i> {% trans "Add Questions" %}
|
|
</a>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Right Column (Sidebar) -->
|
|
<div class="col-span-4 space-y-6">
|
|
|
|
<!-- Template Information -->
|
|
<section class="bg-white rounded-2xl p-6 shadow-sm border border-slate-100">
|
|
<h3 class="font-bold text-navy mb-4 text-sm flex items-center gap-2">
|
|
<i data-lucide="info" class="w-4 h-4 text-blue"></i>
|
|
{% trans "Template Information" %}
|
|
</h3>
|
|
<ul class="space-y-3 text-sm">
|
|
<li class="flex justify-between border-b border-slate-100 pb-2">
|
|
<span class="text-slate">{% trans "Name" %}</span>
|
|
<span class="font-bold text-navy">{{ template.name }}</span>
|
|
</li>
|
|
{% if template.name_ar %}
|
|
<li class="flex justify-between border-b border-slate-100 pb-2">
|
|
<span class="text-slate">{% trans "Name (Arabic)" %}</span>
|
|
<span class="font-bold text-navy" dir="rtl">{{ template.name_ar }}</span>
|
|
</li>
|
|
{% endif %}
|
|
<li class="flex justify-between border-b border-slate-100 pb-2">
|
|
<span class="text-slate">{% trans "Survey Type" %}</span>
|
|
<span class="px-2 py-0.5 rounded-lg text-xs font-bold bg-light text-navy">{{ template.get_survey_type_display }}</span>
|
|
</li>
|
|
<li class="flex justify-between border-b border-slate-100 pb-2">
|
|
<span class="text-slate">{% trans "Scoring" %}</span>
|
|
<span class="px-2 py-0.5 rounded-lg text-xs font-bold bg-purple-100 text-purple-700">{{ template.get_scoring_method_display }}</span>
|
|
</li>
|
|
{% if template.negative_threshold %}
|
|
<li class="flex justify-between border-b border-slate-100 pb-2">
|
|
<span class="text-slate">{% trans "Negative Threshold" %}</span>
|
|
<span class="font-bold text-slate-800">{{ template.negative_threshold }}</span>
|
|
</li>
|
|
{% endif %}
|
|
{% if template.hospital %}
|
|
<li class="flex justify-between border-b border-slate-100 pb-2">
|
|
<span class="text-slate">{% trans "Hospital" %}</span>
|
|
<span class="font-bold text-slate-800">{{ template.hospital.name }}</span>
|
|
</li>
|
|
{% endif %}
|
|
<li class="flex justify-between">
|
|
<span class="text-slate">{% trans "Status" %}</span>
|
|
{% if template.is_active %}
|
|
<span class="px-2 py-0.5 rounded-lg text-xs font-bold bg-green-100 text-green-600">{% trans "Active" %}</span>
|
|
{% else %}
|
|
<span class="px-2 py-0.5 rounded-lg text-xs font-bold bg-slate-100 text-slate-600">{% trans "Inactive" %}</span>
|
|
{% endif %}
|
|
</li>
|
|
</ul>
|
|
</section>
|
|
|
|
<!-- Quick Actions -->
|
|
<section class="bg-white rounded-2xl p-6 shadow-sm border border-slate-100">
|
|
<h3 class="font-bold text-navy mb-4 text-sm flex items-center gap-2">
|
|
<i data-lucide="zap" class="w-4 h-4 text-blue"></i>
|
|
{% trans "Quick Actions" %}
|
|
</h3>
|
|
<div class="space-y-2">
|
|
<a href="{% url 'surveys:template_edit' template.pk %}" class="w-full px-4 py-3 bg-navy text-white rounded-xl font-semibold hover:bg-blue transition flex items-center justify-center gap-2 text-sm">
|
|
<i data-lucide="pencil" class="w-4 h-4"></i>{% trans "Edit Template" %}
|
|
</a>
|
|
<a href="{% url 'surveys:template_delete' template.pk %}" class="w-full px-4 py-3 bg-white border border-red-200 text-red-600 rounded-xl font-semibold hover:bg-red-50 transition flex items-center justify-center gap-2 text-sm">
|
|
<i data-lucide="trash-2" class="w-4 h-4"></i>{% trans "Delete Template" %}
|
|
</a>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block extra_js %}
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
lucide.createIcons();
|
|
|
|
document.querySelectorAll('.dropdown-toggle').forEach(function(button) {
|
|
button.addEventListener('click', function(e) {
|
|
e.stopPropagation();
|
|
var dropdownId = this.getAttribute('data-dropdown');
|
|
var dropdown = document.getElementById(dropdownId);
|
|
|
|
document.querySelectorAll('.dropdown-menu').forEach(function(menu) {
|
|
if (menu.id !== dropdownId) {
|
|
menu.classList.add('hidden');
|
|
}
|
|
});
|
|
|
|
dropdown.classList.toggle('hidden');
|
|
});
|
|
});
|
|
|
|
document.addEventListener('click', function() {
|
|
document.querySelectorAll('.dropdown-menu').forEach(function(menu) {
|
|
menu.classList.add('hidden');
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
{% endblock %}
|