133 lines
6.4 KiB
HTML
133 lines
6.4 KiB
HTML
{# Macros dédiés à la page de gestion des tâches (évite les collisions de signatures) #}
|
|
{% macro _priority_badge(priority) -%}
|
|
{% set cls = {'haute':'bg-danger','normale':'bg-primary','basse':'bg-success'} %}
|
|
<span class="badge {{ cls.get(priority, 'bg-primary') }}">{{ priority|capitalize }}</span>
|
|
{%- endmacro %}
|
|
|
|
{% macro _status_badge(status) -%}
|
|
{% set cls = {'todo':'bg-warning text-dark','done':'bg-success','canceled':'bg-danger'} %}
|
|
{% set labels = {'todo': 'À faire', 'done': 'Fait', 'canceled': 'Annulée'} %}
|
|
<span class="badge {{ cls.get(status, 'bg-secondary') }}">{{ labels.get(status, status) }}</span>
|
|
{%- endmacro %}
|
|
|
|
{% macro _entity_badge(entity_type) -%}
|
|
{% if entity_type %}
|
|
{% set labels = {'client': 'Client', 'prospect': 'Prospect', 'project': 'Projet', 'campaign': 'Campagne'} %}
|
|
<span class="badge bg-secondary-subtle text-dark">{{ labels.get(entity_type, entity_type|capitalize) }}</span>
|
|
{% endif %}
|
|
{%- endmacro %}
|
|
|
|
{% macro render_tasks_table_actions(tasks, show_entity=True, show_due_date=True, empty_text="Aucune tâche") -%}
|
|
<div class="table-responsive">
|
|
<table class="table table-hover align-middle">
|
|
{% set cols = 3 + (1 if show_entity else 0) + (1 if show_due_date else 0) + 1 %}
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th>Statut</th>
|
|
<th>Tâche</th>
|
|
{% if show_entity %}<th>Liée à</th>{% endif %}
|
|
{% if show_due_date %}<th>Échéance</th>{% endif %}
|
|
<th class="text-end">Priorité</th>
|
|
<th class="text-end">Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% if tasks and tasks|length > 0 %}
|
|
{% for task in tasks %}
|
|
<tr>
|
|
<td class="text-nowrap">
|
|
{{ _status_badge(task.status) }}
|
|
</td>
|
|
<td>
|
|
<div class="fw-semibold">{{ task.title }}</div>
|
|
{% if task.description %}
|
|
<div class="small text-muted">{{ task.description }}</div>
|
|
{% endif %}
|
|
{% if task.metadata and task.metadata.ref %}
|
|
<div class="small text-secondary">Ref: {{ task.metadata.ref }}</div>
|
|
{% endif %}
|
|
</td>
|
|
{% if show_entity %}
|
|
<td class="text-nowrap">
|
|
{{ _entity_badge(task.entity_type) }}
|
|
{% if task.entity_id %}
|
|
<div class="small text-muted">{{ task.entity_id }}</div>
|
|
{% endif %}
|
|
</td>
|
|
{% endif %}
|
|
{% if show_due_date %}
|
|
<td class="text-nowrap">
|
|
<span>{{ task.due_date }}</span>
|
|
{% if task.completed_at and task.status == 'done' %}
|
|
<div class="small text-muted">Clôturée: {{ task.completed_at }}</div>
|
|
{% endif %}
|
|
</td>
|
|
{% endif %}
|
|
<td class="text-nowrap text-end">
|
|
{{ _priority_badge(task.priority) }}
|
|
</td>
|
|
<td class="text-nowrap text-end">
|
|
<div class="d-flex gap-1 justify-content-end">
|
|
<button type="button"
|
|
class="btn btn-sm btn-outline-secondary btn-edit-task"
|
|
data-bs-toggle="modal"
|
|
data-bs-target="#editTaskModal"
|
|
data-id="{{ task.id }}"
|
|
data-title="{{ task.title }}"
|
|
data-due_date="{{ task.due_date }}"
|
|
data-priority="{{ task.priority }}"
|
|
data-description="{{ task.description or '' }}"
|
|
data-entity_type="{{ task.entity_type or '' }}"
|
|
data-entity_id="{{ task.entity_id or '' }}"
|
|
title="Éditer">
|
|
<i class="fas fa-pen"></i>
|
|
</button>
|
|
|
|
<div class="btn-group">
|
|
<button type="button" class="btn btn-sm btn-outline-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false" title="Changer le statut">
|
|
<i class="fas fa-exchange-alt"></i>
|
|
</button>
|
|
<ul class="dropdown-menu dropdown-menu-end">
|
|
<li>
|
|
<form method="post" action="{{ url_for('tasks.set_status') }}">
|
|
<input type="hidden" name="task_id" value="{{ task.id }}">
|
|
<input type="hidden" name="status" value="todo">
|
|
<button type="submit" class="dropdown-item {% if task.status=='todo' %}active{% endif %}">À faire</button>
|
|
</form>
|
|
</li>
|
|
<li>
|
|
<form method="post" action="{{ url_for('tasks.set_status') }}">
|
|
<input type="hidden" name="task_id" value="{{ task.id }}">
|
|
<input type="hidden" name="status" value="done">
|
|
<button type="submit" class="dropdown-item {% if task.status=='done' %}active{% endif %}">Fait</button>
|
|
</form>
|
|
</li>
|
|
<li>
|
|
<form method="post" action="{{ url_for('tasks.set_status') }}">
|
|
<input type="hidden" name="task_id" value="{{ task.id }}">
|
|
<input type="hidden" name="status" value="canceled">
|
|
<button type="submit" class="dropdown-item {% if task.status=='canceled' %}active{% endif %}">Annulée</button>
|
|
</form>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<form method="post" action="{{ url_for('tasks.delete_task') }}" onsubmit="return confirm('Supprimer cette tâche ?');">
|
|
<input type="hidden" name="task_id" value="{{ task.id }}">
|
|
<button type="submit" class="btn btn-sm btn-outline-danger" title="Supprimer">
|
|
<i class="fas fa-trash"></i>
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
{% else %}
|
|
<tr>
|
|
<td colspan="{{ cols }}" class="text-muted"> {{ empty_text }} </td>
|
|
</tr>
|
|
{% endif %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{%- endmacro %}
|