HH/templates/surveys/template_list.html
2026-01-24 15:27:30 +03:00

155 lines
7.5 KiB
HTML

{% extends "layouts/base.html" %}
{% load i18n %}
{% load static %}
{% block title %}{{ _("Survey Templates")}} - PX360{% endblock %}
{% block content %}
<div class="container-fluid">
<div class="d-flex justify-content-between align-items-center mb-4">
<div>
<h2 class="mb-1">
<i class="bi bi-clipboard2 text-info me-2"></i>
{{ _("Survey Templates")}}
</h2>
<p class="text-muted mb-0">{{ _("Manage survey templates and questions")}}</p>
</div>
<a href="{% url 'surveys:template_create' %}" class="btn btn-primary">
<i class="bi bi-plus-circle me-1"></i> Create Survey Template
</a>
</div>
<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>{% trans "Name" %}</th>
<th>{% trans "Survey Type" %}</th>
<th>{% trans "Hospital" %}</th>
<th>{% trans "Questions" %}</th>
<th>{% trans "Scoring" %}</th>
<th>{% trans "Status" %}</th>
<th>{% trans "Actions" %}</th>
</tr>
</thead>
<tbody>
{% for template in templates %}
<tr>
<td><strong>{{ template.name }}</strong></td>
<td><span class="badge bg-info">{{ template.get_survey_type_display }}</span></td>
<td><small>{{ template.hospital.name_en }}</small></td>
<td><span class="badge bg-secondary">{{ template.questions.count }} {{ _("questions") }}</span></td>
<td><small>{{ template.get_scoring_method_display }}</small></td>
<td>
{% if template.is_active %}
<span class="badge bg-success">{{ _("Active") }}</span>
{% else %}
<span class="badge bg-secondary">{{ _("Inactive") }}</span>
{% endif %}
</td>
<td>
<div class="dropdown">
<button class="btn btn-sm btn-light dropdown-toggle" type="button" data-bs-toggle="dropdown">
<i class="bi bi-three-dots-vertical"></i> Actions
</button>
<ul class="dropdown-menu">
<li>
<a class="dropdown-item" href="{% url 'surveys:template_detail' template.pk %}">
<i class="bi bi-eye me-2"></i>View
</a>
</li>
<li>
<a class="dropdown-item" href="{% url 'surveys:template_edit' template.pk %}">
<i class="bi bi-pencil me-2"></i>Edit
</a>
</li>
<li>
<a class="dropdown-item" href="{% url 'surveys:instance_list' %}?survey_type={{ template.survey_type }}">
<i class="bi bi-list-check me-2"></i>View Instances
</a>
</li>
<li><hr class="dropdown-divider"></li>
<li>
<button type="button" class="dropdown-item text-danger" data-bs-toggle="modal" data-bs-target="#deleteModal-{{ template.pk }}">
<i class="bi bi-trash me-2"></i>Delete
</button>
</li>
</ul>
</div>
</td>
</tr>
{% empty %}
<tr>
<td colspan="7" class="text-center py-5">
<i class="bi bi-inbox" style="font-size: 3rem; color: #ccc;"></i>
<p class="text-muted mt-3">{{ _("No templates found")}}</p>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% if page_obj.has_other_pages %}
<nav aria-label="Templates pagination" class="mt-4">
<ul class="pagination justify-content-center">
{% if page_obj.has_previous %}
<li class="page-item">
<a class="page-link" href="?page={{ page_obj.previous_page_number }}">
<i class="bi bi-chevron-left"></i>
</a>
</li>
{% endif %}
{% for num in page_obj.paginator.page_range %}
{% if page_obj.number == num %}
<li class="page-item active"><span class="page-link">{{ num }}</span></li>
{% elif num > page_obj.number|add:'-3' and num < page_obj.number|add:'3' %}
<li class="page-item">
<a class="page-link" href="?page={{ num }}">{{ num }}</a>
</li>
{% endif %}
{% endfor %}
{% if page_obj.has_next %}
<li class="page-item">
<a class="page-link" href="?page={{ page_obj.next_page_number }}">
<i class="bi bi-chevron-right"></i>
</a>
</li>
{% endif %}
</ul>
</nav>
{% endif %}
</div>
<!-- Delete Confirmation Modals -->
{% for template in templates %}
<div class="modal fade" id="deleteModal-{{ template.pk }}" tabindex="-1" aria-labelledby="deleteModalLabel-{{ template.pk }}" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header bg-danger text-white">
<h5 class="modal-title" id="deleteModalLabel-{{ template.pk }}">Confirm Delete</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p>Are you sure you want to delete the survey template "<strong>{{ template.name }}</strong>"?</p>
<p class="text-muted">This will also delete all associated questions and instances, and cannot be undone.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<form method="post" action="{% url 'surveys:template_delete' template.pk %}">
{% csrf_token %}
<button type="submit" class="btn btn-danger">Delete</button>
</form>
</div>
</div>
</div>
</div>
{% endfor %}
{% endblock %}