HH/templates/complaints/partials/actions_panel.html
ismail badb6a9ebf
All checks were successful
Build and Push Docker Image / build (push) Successful in 2m41s
feat: QI Projects — team-member task management + My Tasks + notifications
Fixed 3 gaps in the QI Projects module:

Gap 1 (critical): team members couldn't manage their own tasks — the toggle
checkbox/edit/delete were gated behind admin-only can_edit. Now:
- _can_manage_task() helper: admins OR the task assignee OR project team members
- task_toggle_status + htmx_task_toggle_status use the new helper
- task_row.html shows the toggle for assignees (task.assigned_to.user_id check)

Gap 2: no "My QI Tasks" view — added /projects/my-tasks/ showing tasks assigned
to the current user across all projects, with toggle links + stats. Sidebar link.

Gap 3: no notification on task assignment — added apps/projects/signals.py
(post_save on QIProjectTask → create_in_app_notification). apps.py ready() wired.

Tested (headed, 11 PASS / 1 FAIL):
- Cross-department team members (Contact Center + different dept) can VIEW the
  project AND toggle their assigned tasks (both PASS)
- My Tasks view loads for team members
- Excel export returns 500 (real bug, reported)
- Project close via edit form needs correct hospital UUID (test harness issue)

Also bundles accumulated in-progress work across complaints, observations,
organizations, templates, and other modules.

Harness: seed_e2e_project + get_e2e_project_state CLI + qi-projects-workflow.spec.ts
2026-06-16 23:55:58 +03:00

56 lines
3.2 KiB
HTML

{% load i18n %}
<section class="bg-white rounded-2xl p-4 shadow-sm border border-slate-100">
<div class="flex flex-wrap items-center justify-between gap-3 mb-4">
<h3 class="text-lg font-bold text-navy">{% trans "Related PX Actions" %}</h3>
{% if can_admin and complaint.is_active_status %}
<div class="flex flex-wrap items-center gap-2">
<button onclick="createAction()" class="px-3 py-2 bg-gradient-to-r from-navy to-blue text-white rounded-xl font-semibold hover:opacity-90 transition inline-flex items-center gap-2 text-sm">
<i data-lucide="plus" class="w-4 h-4"></i> {% trans "Create Action" %}
</button>
<a href="{% url 'projects:project_create' %}?related_model=complaint&related_id={{ complaint.pk }}"
class="px-3 py-2 bg-teal-600 text-white rounded-xl font-semibold hover:bg-teal-700 transition inline-flex items-center gap-2 text-sm">
<i data-lucide="folder-plus" class="w-4 h-4"></i> {% trans "QI Project" %}
</a>
<a href="{% url 'rca:rca_create' %}?related_model=complaint&related_id={{ complaint.pk }}"
class="px-3 py-2 bg-purple-600 text-white rounded-xl font-semibold hover:bg-purple-700 transition inline-flex items-center gap-2 text-sm">
<i data-lucide="plus" class="w-4 h-4"></i> {% trans "Initiate RCA" %}
</a>
</div>
{% endif %}
</div>
{% if px_actions %}
<div class="space-y-3">
{% for action in px_actions %}
<div class="bg-white border border-slate-200 rounded-xl p-4 hover:shadow-md transition">
<div class="flex justify-between items-start">
<div class="flex-1 min-w-0">
<h4 class="font-bold text-navy mb-1">{{ action.title }}</h4>
<p class="text-slate text-sm">{{ action.description|truncatewords:20 }}</p>
<div class="flex gap-2 mt-2">
<span class="px-2 py-1 bg-blue-100 text-blue-600 rounded-lg text-xs font-bold">{{ action.get_status_display }}</span>
<span class="px-2 py-1 bg-slate-100 text-slate-600 rounded-lg text-xs font-bold">{{ action.get_priority_display }}</span>
</div>
</div>
<a href="{% url 'actions:action_detail' action.id %}" class="px-4 py-2 bg-navy text-white rounded-xl font-semibold hover:bg-blue transition flex items-center gap-2 text-sm shrink-0 ml-3">
{% trans "View" %} <i data-lucide="arrow-right" class="w-4 h-4"></i>
</a>
</div>
</div>
{% endfor %}
</div>
{% else %}
<div class="text-center py-8 bg-slate-50 rounded-xl border border-dashed border-slate-200">
<i data-lucide="zap" class="w-12 h-12 mx-auto text-slate-300 mb-3"></i>
<p class="text-slate text-sm">{% trans "No PX actions created yet" %}</p>
<p class="text-slate text-xs mt-1">{% trans "Use the buttons above to create an action, QI project, or RCA." %}</p>
</div>
{% endif %}
</section>
<script>
function createAction() {
window.location.href = "{% url 'actions:action_create' %}?source_type=complaint&complaint_id={{ complaint.id }}";
}
</script>