Files
site_aegisone/py_service/app/templates/pages/tasks.html
T

76 lines
5.3 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{% extends "page.html" %}
{% block page_content %}
<div class="card">
<div class="card-header"><h2>Задачи</h2>
{% if user.role in ['owner','engineer'] %}
<button class="btn btn-primary btn-sm" onclick="document.getElementById('modal-task').classList.add('open')">+ Создать</button>
{% endif %}
</div>
<form method="get" class="filter-bar">
<select name="status_filter" onchange="this.form.submit()"><option value="">Все статусы</option><option value="open" {% if status_filter == 'open' %}selected{% endif %}>Открытые</option><option value="in_progress" {% if status_filter == 'in_progress' %}selected{% endif %}>В работе</option><option value="completed" {% if status_filter == 'completed' %}selected{% endif %}>Завершённые</option></select>
<input type="text" name="search" placeholder="Поиск..." value="{{ search }}">
<button class="btn btn-primary btn-sm">Найти</button>
</form>
<div class="table-wrap"><table><thead><tr><th>Приоритет</th><th>Название</th><th>Объект</th><th>Исполнитель</th><th>Статус</th><th>Срок</th><th class="actions"></th></tr></thead>
<tbody>{% for t in tasks %}<tr>
<td><span class="badge badge-{{ {'P1':'critical','P2':'high','P3':'medium','P4':'low'}[t.priority] }}">{{ t.priority }}</span></td>
<td>{{ t.title }}</td><td>{{ t.object.name if t.object else '' }}</td>
<td>{{ t.assignee.full_name if t.assignee else '' }}</td>
<td><span class="badge badge-{{ t.status }}">{{ {'open':'Открыта','in_progress':'В работе','completed':'Завершена','cancelled':'Отменена'}[t.status] }}</span></td>
<td><small>{{ t.deadline.strftime('%d.%m.%Y') if t.deadline else '' }}</small></td>
<td class="actions">{% if t.status in ['open','in_progress'] and (user.role in ['owner','engineer'] or t.assigned_to == user.id) %}
<form method="post" action="/service/tasks/close" style="display:inline" id="close-task-form-{{ t.id }}"><input type="hidden" name="id" value="{{ t.id }}"><button type="button" class="btn btn-success btn-sm" onclick="openConfirmCloseTask({{ t.id }},'{{ t.title|e }}')" title="Завершить">✓ Закрыть</button></form>
{% endif %}
</td>
</tr>{% endfor %}</tbody></table>
</div>
</div>
<div class="modal-overlay" id="modal-task"><div class="modal">
<button type="button" class="modal-close" onclick="this.closest('.modal-overlay').classList.remove('open')"></button>
<h2>Новая задача</h2>
<form method="post" action="/service/tasks/create">
<div class="form-group"><label>Название</label><input type="text" name="title" required></div>
<div class="form-group"><label>Описание</label><textarea name="description"></textarea></div>
<div class="form-row">
<div class="form-group"><label>Объект</label><select name="object_id" required>{% for o in objects %}<option value="{{ o.id }}">{{ o.name }}</option>{% endfor %}</select></div>
<div class="form-group"><label>Исполнитель</label><select name="assigned_to"><option value=""></option>{% for u in users %}<option value="{{ u.id }}">{{ u.full_name }}</option>{% endfor %}</select></div>
</div>
<div class="form-row">
<div class="form-group"><label>Приоритет</label><select name="priority"><option value="P3">P3 — Medium</option><option value="P1">P1 — Critical</option><option value="P2">P2 — High</option><option value="P4">P4 — Low</option></select></div>
<div class="form-group"><label>Срок</label><input type="date" name="deadline"></div>
</div>
<div class="form-actions"><button type="submit" class="btn btn-primary">Создать</button>
<button type="button" class="btn btn-secondary" onclick="this.closest('.modal-overlay').classList.remove('open')">Отмена</button></div>
</form>
</div></div>
<div class="modal-overlay" id="confirm-close-task">
<div class="modal" style="max-width:420px;">
<h2 style="font-size:16px;margin-bottom:8px;">Завершить задачу?</h2>
<p style="color:var(--text-secondary);font-size:14px;margin-bottom:20px;">
<strong id="delete-task-name"></strong> будет завершена. Это действие нельзя отменить.
</p>
<div class="form-actions" style="justify-content:flex-end;">
<button type="button" class="btn btn-success" onclick="confirmCloseTask()">Завершить</button>
<button type="button" class="btn" onclick="closeConfirmCloseTask()">Отмена</button>
</div>
</div>
</div>
<script>
var closeTaskId = null;
function openConfirmCloseTask(id, name){
closeTaskId = id;
document.getElementById('delete-task-name').textContent = name || '#' + id;
document.getElementById('confirm-close-task').classList.add('open');
}
function closeConfirmCloseTask(){
document.getElementById('confirm-close-task').classList.remove('open');
closeTaskId = null;
}
function confirmCloseTask(){
if(!closeTaskId) return;
document.getElementById('close-task-form-' + closeTaskId).submit();
closeConfirmCloseTask();
}
</script>
{% endblock %}