Enhances user experience with dark‑mode detection, responsive layout, and streamlined role selection workflow
71 lines
4.6 KiB
HTML
71 lines
4.6 KiB
HTML
<div class="py-4 border-b border-gray-200 dark:border-gray-600 last:border-b-0" x-data="{ showReply: false, replyContent: '' }">
|
|
<div class="flex items-start gap-x-4">
|
|
<div class="shrink-0">
|
|
<div class="w-8 h-8 rounded-full bg-primary-500 flex items-center justify-center text-white font-medium text-sm">
|
|
{{ comment.user.get_full_name|default:comment.user.username|make_list|first|upper }}
|
|
</div>
|
|
</div>
|
|
<div class="flex-1 min-w-0">
|
|
<div class="flex flex-col sm:flex-row sm:justify-between sm:items-center mb-2">
|
|
<div class="text-sm font-medium text-gray-900 dark:text-gray-100">
|
|
{{ comment.user.get_full_name|default:comment.user.username }}
|
|
</div>
|
|
<div class="flex items-center gap-x-2">
|
|
<div class="text-xs text-gray-500 dark:text-gray-400">
|
|
{{ comment.created_at|timesince }} ago
|
|
</div>
|
|
{% if request.user == comment.user or request.user.is_superuser %}
|
|
<div class="flex gap-3">
|
|
<a href="{% url 'ticket-edit' comment.ticket.id %}" class="inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-900 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors shadow-sm" title="Edit comment">
|
|
<svg xmlns="http://www.w3.org/2000/svg" class="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"/>
|
|
</svg>
|
|
Edit
|
|
</a>
|
|
<button type="button" class="inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium text-red-600 dark:text-red-400 bg-white dark:bg-gray-900 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors shadow-sm"
|
|
@click="confirmAction({title:'Delete Comment', message:'Delete this comment?', confirmText:'Delete', danger:true, onConfirm:function(){ fetch('/dashboard/tickets/{{ comment.ticket.id }}/comments/{{ comment.id }}/delete/', {method:'POST', headers:{'X-CSRFToken':'{{ csrf_token }}'}}).then(function(){ window.location.reload() }) }})"
|
|
title="Delete comment">
|
|
<svg xmlns="http://www.w3.org/2000/svg" class="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/>
|
|
</svg>
|
|
Delete
|
|
</button>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
<div class="prose prose-sm dark:prose-invert max-w-none">
|
|
{{ comment.comment|safe }}
|
|
</div>
|
|
{% if comment.created_at|date:"U" != comment.updated_at|date:"U" %}
|
|
<div class="text-xs text-gray-400 dark:text-gray-500 mt-1">(edited {{ comment.updated_at|timesince }} ago)</div>
|
|
{% endif %}
|
|
<div class="mt-2 flex items-center gap-4">
|
|
<button @click="showReply = !showReply" class="text-xs text-primary hover:text-primary-hover font-medium">
|
|
<i class="fas fa-reply mr-1"></i>Reply
|
|
</button>
|
|
</div>
|
|
<div x-show="showReply" x-cloak class="mt-3">
|
|
<form @htmx:after-request="if($event.detail.successful) { replyContent = ''; showReply = false; }"
|
|
hx-post="/dashboard/tickets/{{ comment.ticket.id }}/comments/add/"
|
|
hx-target="#comments-list"
|
|
hx-swap="innerHTML">
|
|
{% csrf_token %}
|
|
<input type="hidden" name="parent_id" value="{{ comment.id }}">
|
|
{% include "components/rich_text_editor.html" with input_name="comment" alpine_model="replyContent" %}
|
|
<div class="flex gap-2 mt-1">
|
|
<button type="submit" class="dk-btn dk-btn-primary text-xs px-3 py-1"><i class="fas fa-paper-plane"></i> Reply</button>
|
|
<button type="button" @click="showReply = false" class="dk-btn-ghost text-xs px-3 py-1">Cancel</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
{% if comment.replies.all %}
|
|
<div class="ml-6 mt-3 border-l-2 border-gray-200 dark:border-gray-600 pl-4 space-y-3">
|
|
{% for reply in comment.replies.all %}
|
|
{% include "tickets/partials/comment_item.html" with comment=reply %}
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div> |