452 lines
19 KiB
HTML
452 lines
19 KiB
HTML
{% extends "layouts/base.html" %}
|
|
{% load i18n %}
|
|
{% load static %}
|
|
|
|
{% block title %}{% if is_create %}Create{% else %}Edit{% endif %} Feedback - 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);
|
|
}
|
|
|
|
.form-section {
|
|
background: #fff;
|
|
border: 2px solid #e2e8f0;
|
|
border-radius: 1rem;
|
|
padding: 1.5rem;
|
|
margin-bottom: 1.5rem;
|
|
transition: all 0.3s ease;
|
|
}
|
|
.form-section:hover {
|
|
border-color: #005696;
|
|
box-shadow: 0 4px 12px rgba(0, 86, 150, 0.1);
|
|
}
|
|
|
|
.form-label {
|
|
display: block;
|
|
font-size: 0.875rem;
|
|
font-weight: 600;
|
|
color: #1e293b;
|
|
margin-bottom: 0.5rem;
|
|
}
|
|
|
|
.form-control, .form-select {
|
|
width: 100%;
|
|
padding: 0.75rem 1rem;
|
|
border: 2px solid #e2e8f0;
|
|
border-radius: 0.75rem;
|
|
font-size: 0.875rem;
|
|
transition: all 0.2s ease;
|
|
}
|
|
.form-control:focus, .form-select:focus {
|
|
outline: none;
|
|
border-color: #005696;
|
|
box-shadow: 0 0 0 3px rgba(0, 86, 150, 0.1);
|
|
}
|
|
|
|
.btn-primary {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 0.5rem;
|
|
padding: 0.75rem 1.5rem;
|
|
background: #005696;
|
|
color: white;
|
|
border-radius: 0.75rem;
|
|
font-weight: 600;
|
|
transition: all 0.2s ease;
|
|
border: none;
|
|
cursor: pointer;
|
|
}
|
|
.btn-primary:hover {
|
|
background: #007bbd;
|
|
}
|
|
|
|
.btn-secondary {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 0.5rem;
|
|
padding: 0.75rem 1.5rem;
|
|
background: white;
|
|
color: #64748b;
|
|
border: 2px solid #e2e8f0;
|
|
border-radius: 0.75rem;
|
|
font-weight: 600;
|
|
transition: all 0.2s ease;
|
|
}
|
|
.btn-secondary:hover {
|
|
background: #f1f5f9;
|
|
border-color: #005696;
|
|
}
|
|
|
|
.required-field::after {
|
|
content: " *";
|
|
color: #dc3545;
|
|
}
|
|
|
|
.form-help-text {
|
|
font-size: 0.875rem;
|
|
color: #64748b;
|
|
margin-top: 0.25rem;
|
|
}
|
|
|
|
.rating-input {
|
|
display: flex;
|
|
gap: 10px;
|
|
align-items: center;
|
|
flex-direction: row-reverse;
|
|
justify-content: flex-end;
|
|
}
|
|
.rating-input input[type="radio"] {
|
|
display: none;
|
|
}
|
|
.rating-input label {
|
|
font-size: 2rem;
|
|
color: #ddd;
|
|
cursor: pointer;
|
|
transition: color 0.2s;
|
|
}
|
|
.rating-input input[type="radio"]:checked ~ label,
|
|
.rating-input label:hover,
|
|
.rating-input label:hover ~ label {
|
|
color: #ffc107;
|
|
}
|
|
</style>
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="p-6 md:p-8 bg-gradient-to-br from-slate-50 to-blue-50 min-h-screen">
|
|
<!-- Page Header -->
|
|
<div class="page-header-gradient flex flex-col md:flex-row justify-between items-start md:items-center gap-4">
|
|
<div>
|
|
<nav aria-label="breadcrumb" class="mb-2">
|
|
<ol class="flex items-center gap-2 text-sm text-white/80">
|
|
<li><a href="{% url 'feedback:feedback_list' %}" class="hover:text-white transition">{% trans "Feedback" %}</a></li>
|
|
<li><i data-lucide="chevron-right" class="w-4 h-4"></i></li>
|
|
<li class="text-white">{% if is_create %}Create{% else %}Edit{% endif %}</li>
|
|
</ol>
|
|
</nav>
|
|
<h2 class="text-2xl font-bold flex items-center gap-2">
|
|
<i data-lucide="message-circle-heart" class="w-8 h-8"></i>
|
|
{% if is_create %}{% trans "Create New Feedback" %}{% else %}{% trans "Edit Feedback" %}{% endif %}
|
|
</h2>
|
|
</div>
|
|
<div>
|
|
<a href="{% url 'feedback:feedback_list' %}" class="inline-flex items-center gap-2 px-4 py-2 bg-white/20 text-white rounded-lg hover:bg-white/30 transition">
|
|
<i data-lucide="x-circle" class="w-4 h-4"></i>
|
|
{% trans "Cancel" %}
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="max-w-4xl mx-auto">
|
|
<form method="post" id="feedbackForm">
|
|
{% csrf_token %}
|
|
|
|
<!-- Display form errors -->
|
|
{% if form.non_field_errors %}
|
|
<div class="bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-lg mb-4">
|
|
{{ form.non_field_errors }}
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Patient/Contact Information -->
|
|
<div class="form-section">
|
|
<div class="flex items-center gap-2 mb-4 pb-3 border-b border-slate-100">
|
|
<i data-lucide="user" class="w-5 h-5 text-blue-600"></i>
|
|
<h3 class="text-lg font-bold text-slate-800">{% trans "Patient/Contact Information" %}</h3>
|
|
</div>
|
|
|
|
<!-- Anonymous Checkbox -->
|
|
<div class="mb-4">
|
|
<div class="flex items-center gap-3">
|
|
{{ form.is_anonymous }}
|
|
<label class="text-sm font-medium text-slate-700" for="{{ form.is_anonymous.id_for_label }}">
|
|
{% trans "Submit as Anonymous Feedback" %}
|
|
</label>
|
|
</div>
|
|
{% if form.is_anonymous.errors %}
|
|
<div class="text-red-500 text-sm mt-1">{{ form.is_anonymous.errors }}</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<!-- Patient Selection (shown when not anonymous) -->
|
|
<div class="mb-4" id="patientField">
|
|
<label for="{{ form.patient.id_for_label }}" class="form-label">{% trans "Patient" %}</label>
|
|
{{ form.patient }}
|
|
{% if form.patient.help_text %}
|
|
<div class="form-help-text">{{ form.patient.help_text }}</div>
|
|
{% endif %}
|
|
{% if form.patient.errors %}
|
|
<div class="text-red-500 text-sm mt-1">{{ form.patient.errors }}</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<!-- Anonymous Contact Fields (shown when anonymous) -->
|
|
<div id="anonymousFields" style="display: none;">
|
|
<div class="mb-4">
|
|
<label for="{{ form.contact_name.id_for_label }}" class="form-label required-field">{% trans "Contact Name" %}</label>
|
|
{{ form.contact_name }}
|
|
{% if form.contact_name.errors %}
|
|
<div class="text-red-500 text-sm mt-1">{{ form.contact_name.errors }}</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
|
<div>
|
|
<label for="{{ form.contact_email.id_for_label }}" class="form-label">{% trans "Email" %}</label>
|
|
{{ form.contact_email }}
|
|
{% if form.contact_email.errors %}
|
|
<div class="text-red-500 text-sm mt-1">{{ form.contact_email.errors }}</div>
|
|
{% endif %}
|
|
</div>
|
|
<div>
|
|
<label for="{{ form.contact_phone.id_for_label }}" class="form-label">{% trans "Phone" %}</label>
|
|
{{ form.contact_phone }}
|
|
{% if form.contact_phone.errors %}
|
|
<div class="text-red-500 text-sm mt-1">{{ form.contact_phone.errors }}</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Feedback Details -->
|
|
<div class="form-section">
|
|
<div class="flex items-center gap-2 mb-4 pb-3 border-b border-slate-100">
|
|
<i data-lucide="message-square-text" class="w-5 h-5 text-blue-600"></i>
|
|
<h3 class="text-lg font-bold text-slate-800">{% trans "Feedback Details" %}</h3>
|
|
</div>
|
|
|
|
<!-- Feedback Type -->
|
|
<div class="mb-4">
|
|
<label for="{{ form.feedback_type.id_for_label }}" class="form-label required-field">{% trans "Feedback Type" %}</label>
|
|
{{ form.feedback_type }}
|
|
{% if form.feedback_type.errors %}
|
|
<div class="text-red-500 text-sm mt-1">{{ form.feedback_type.errors }}</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<!-- Title -->
|
|
<div class="mb-4">
|
|
<label for="{{ form.title.id_for_label }}" class="form-label required-field">{% trans "Title" %}</label>
|
|
{{ form.title }}
|
|
{% if form.title.errors %}
|
|
<div class="text-red-500 text-sm mt-1">{{ form.title.errors }}</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<!-- Message -->
|
|
<div class="mb-4">
|
|
<label for="{{ form.message.id_for_label }}" class="form-label required-field">{% trans "Message" %}</label>
|
|
{{ form.message }}
|
|
<div class="form-help-text">{% trans "Please provide detailed feedback" %}</div>
|
|
{% if form.message.errors %}
|
|
<div class="text-red-500 text-sm mt-1">{{ form.message.errors }}</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<!-- Category and Subcategory -->
|
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4">
|
|
<div>
|
|
<label for="{{ form.category.id_for_label }}" class="form-label required-field">{% trans "Category" %}</label>
|
|
{{ form.category }}
|
|
{% if form.category.errors %}
|
|
<div class="text-red-500 text-sm mt-1">{{ form.category.errors }}</div>
|
|
{% endif %}
|
|
</div>
|
|
<div>
|
|
<label for="{{ form.subcategory.id_for_label }}" class="form-label">{% trans "Subcategory" %}</label>
|
|
{{ form.subcategory }}
|
|
{% if form.subcategory.errors %}
|
|
<div class="text-red-500 text-sm mt-1">{{ form.subcategory.errors }}</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Rating -->
|
|
<div class="mb-4">
|
|
<label class="form-label">{% trans "Rating (Optional)" %}</label>
|
|
<div class="rating-input">
|
|
<input type="radio" name="rating" value="5" id="rating5" {% if form.rating.value == 5 %}checked{% endif %}>
|
|
<label for="rating5"><i data-lucide="star" class="w-8 h-8 fill-current"></i></label>
|
|
<input type="radio" name="rating" value="4" id="rating4" {% if form.rating.value == 4 %}checked{% endif %}>
|
|
<label for="rating4"><i data-lucide="star" class="w-8 h-8 fill-current"></i></label>
|
|
<input type="radio" name="rating" value="3" id="rating3" {% if form.rating.value == 3 %}checked{% endif %}>
|
|
<label for="rating3"><i data-lucide="star" class="w-8 h-8 fill-current"></i></label>
|
|
<input type="radio" name="rating" value="2" id="rating2" {% if form.rating.value == 2 %}checked{% endif %}>
|
|
<label for="rating2"><i data-lucide="star" class="w-8 h-8 fill-current"></i></label>
|
|
<input type="radio" name="rating" value="1" id="rating1" {% if form.rating.value == 1 %}checked{% endif %}>
|
|
<label for="rating1"><i data-lucide="star" class="w-8 h-8 fill-current"></i></label>
|
|
</div>
|
|
<div class="form-help-text">{% trans "Rate your experience from 1 to 5 stars" %}</div>
|
|
{% if form.rating.errors %}
|
|
<div class="text-red-500 text-sm mt-1">{{ form.rating.errors }}</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<!-- Priority -->
|
|
<div class="mb-4">
|
|
<label for="{{ form.priority.id_for_label }}" class="form-label">{% trans "Priority" %}</label>
|
|
{{ form.priority }}
|
|
{% if form.priority.errors %}
|
|
<div class="text-red-500 text-sm mt-1">{{ form.priority.errors }}</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Organization Information -->
|
|
<div class="form-section">
|
|
<div class="flex items-center gap-2 mb-4 pb-3 border-b border-slate-100">
|
|
<i data-lucide="building-2" class="w-5 h-5 text-blue-600"></i>
|
|
<h3 class="text-lg font-bold text-slate-800">{% trans "Organization Information" %}</h3>
|
|
</div>
|
|
|
|
{% if not form.hospital.is_hidden %}
|
|
<!-- Hospital -->
|
|
<div class="mb-4">
|
|
<label for="{{ form.hospital.id_for_label }}" class="form-label required-field">{% trans "Hospital" %}</label>
|
|
{{ form.hospital }}
|
|
{% if form.hospital.errors %}
|
|
<div class="text-red-500 text-sm mt-1">{{ form.hospital.errors }}</div>
|
|
{% endif %}
|
|
</div>
|
|
{% else %}
|
|
{{ form.hospital }}
|
|
{% endif %}
|
|
|
|
<!-- Department -->
|
|
<div class="mb-4">
|
|
<label for="{{ form.department.id_for_label }}" class="form-label">{% trans "Department" %}</label>
|
|
{{ form.department }}
|
|
<div class="form-help-text">{% trans "Select the department related to this feedback (optional)" %}</div>
|
|
{% if form.department.errors %}
|
|
<div class="text-red-500 text-sm mt-1">{{ form.department.errors }}</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<!-- Physician -->
|
|
<div class="mb-4">
|
|
<label for="{{ form.physician.id_for_label }}" class="form-label">{% trans "Physician" %}</label>
|
|
{{ form.physician }}
|
|
<div class="form-help-text">{% trans "Select the physician mentioned in this feedback (optional)" %}</div>
|
|
{% if form.physician.errors %}
|
|
<div class="text-red-500 text-sm mt-1">{{ form.physician.errors }}</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<!-- Encounter ID -->
|
|
<div class="mb-4">
|
|
<label for="{{ form.encounter_id.id_for_label }}" class="form-label">{% trans "Encounter ID" %}</label>
|
|
{{ form.encounter_id }}
|
|
<div class="form-help-text">{% trans "Related encounter ID if applicable (optional)" %}</div>
|
|
{% if form.encounter_id.errors %}
|
|
<div class="text-red-500 text-sm mt-1">{{ form.encounter_id.errors }}</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Form Actions -->
|
|
<div class="flex justify-between items-center">
|
|
<a href="{% url 'feedback:feedback_list' %}" class="btn-secondary">
|
|
<i data-lucide="x-circle" class="w-4 h-4"></i>
|
|
{% trans "Cancel" %}
|
|
</a>
|
|
<button type="submit" class="btn-primary">
|
|
<i data-lucide="check-circle" class="w-4 h-4"></i>
|
|
{% if is_create %}{% trans "Create Feedback" %}{% else %}{% trans "Update Feedback" %}{% endif %}
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block extra_js %}
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const anonymousCheckbox = document.getElementById('{{ form.is_anonymous.id_for_label }}');
|
|
const patientField = document.getElementById('patientField');
|
|
const anonymousFields = document.getElementById('anonymousFields');
|
|
|
|
function toggleAnonymousFields() {
|
|
if (anonymousCheckbox.checked) {
|
|
patientField.style.display = 'none';
|
|
anonymousFields.style.display = 'block';
|
|
} else {
|
|
patientField.style.display = 'block';
|
|
anonymousFields.style.display = 'none';
|
|
}
|
|
}
|
|
|
|
// Initial state
|
|
toggleAnonymousFields();
|
|
|
|
// Listen for changes
|
|
anonymousCheckbox.addEventListener('change', toggleAnonymousFields);
|
|
|
|
// Rating stars interaction
|
|
const ratingLabels = document.querySelectorAll('.rating-input label');
|
|
ratingLabels.forEach(label => {
|
|
label.addEventListener('mouseenter', function() {
|
|
const rating = this.previousElementSibling.value;
|
|
highlightStars(rating);
|
|
});
|
|
});
|
|
|
|
document.querySelector('.rating-input').addEventListener('mouseleave', function() {
|
|
const checkedInput = document.querySelector('.rating-input input:checked');
|
|
if (checkedInput) {
|
|
highlightStars(checkedInput.value);
|
|
} else {
|
|
resetStars();
|
|
}
|
|
});
|
|
|
|
function highlightStars(rating) {
|
|
ratingLabels.forEach((label, index) => {
|
|
if (5 - index <= rating) {
|
|
label.style.color = '#ffc107';
|
|
} else {
|
|
label.style.color = '#ddd';
|
|
}
|
|
});
|
|
}
|
|
|
|
function resetStars() {
|
|
ratingLabels.forEach(label => {
|
|
label.style.color = '#ddd';
|
|
});
|
|
}
|
|
|
|
// Form validation
|
|
const form = document.getElementById('feedbackForm');
|
|
form.addEventListener('submit', function(e) {
|
|
const isAnonymous = anonymousCheckbox.checked;
|
|
const patient = document.getElementById('{{ form.patient.id_for_label }}').value;
|
|
const contactName = document.getElementById('{{ form.contact_name.id_for_label }}').value;
|
|
|
|
if (!isAnonymous && !patient) {
|
|
e.preventDefault();
|
|
alert('Please select a patient or mark as anonymous.');
|
|
return false;
|
|
}
|
|
|
|
if (isAnonymous && !contactName) {
|
|
e.preventDefault();
|
|
alert('Please enter a contact name for anonymous feedback.');
|
|
return false;
|
|
}
|
|
});
|
|
|
|
// Initialize Lucide icons
|
|
lucide.createIcons();
|
|
});
|
|
</script>
|
|
{% endblock %}
|