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

153 lines
7.3 KiB
HTML

{% extends "layouts/base.html" %}
{% load i18n %}
{% load static %}
{% block title %}Journey 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-diagram-2 text-primary me-2"></i>
Journey Templates
</h2>
<p class="text-muted mb-0">Manage journey templates and stages</p>
</div>
<a href="{% url 'journeys:template_create' %}" class="btn btn-primary">
<i class="bi bi-plus-circle me-1"></i> Create Journey 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 "Journey Type" %}</th>
<th>{% trans "Hospital" %}</th>
<th>{% trans "Stages" %}</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-primary">{{ template.get_journey_type_display }}</span></td>
<td><small>{{ template.hospital.name_en }}</small></td>
<td><span class="badge bg-info">{{ template.stages.count }} stages</span></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 'journeys:template_detail' template.pk %}">
<i class="bi bi-eye me-2"></i>View
</a>
</li>
<li>
<a class="dropdown-item" href="{% url 'journeys:template_edit' template.pk %}">
<i class="bi bi-pencil me-2"></i>Edit
</a>
</li>
<li>
<a class="dropdown-item" href="{% url 'journeys:instance_list' %}?journey_type={{ template.journey_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="6" 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 journey template "<strong>{{ template.name }}</strong>"?</p>
<p class="text-muted">This will also delete all associated stages 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 'journeys:template_delete' template.pk %}">
{% csrf_token %}
<button type="submit" class="btn btn-danger">Delete</button>
</form>
</div>
</div>
</div>
</div>
{% endfor %}
{% endblock %}