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

84 lines
4.9 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>
<button class="btn btn-primary btn-sm" onclick="document.getElementById('modal-idea').classList.add('open')">+ Новая идея</button>
</div>
<div class="table-wrap"><table><thead><tr><th>ID</th><th>Название</th><th>Описание</th><th>Статус</th><th>Дата</th><th class="actions"></th></tr></thead>
<tbody>{% for idea in ideas %}<tr>
<td>{{ idea.id }}</td>
<td><strong>{{ idea.title }}</strong></td>
<td>{{ (idea.description or '')[:100] }}{% if (idea.description or '')|length > 100 %}…{% endif %}</td>
<td><span class="badge badge-{{ 'done' if idea.status == 'completed' else 'progress' if idea.status == 'in_progress' else 'default' }}">{{ {'normal':'Обычная','in_progress':'В работе','completed':'Выполнено'}.get(idea.status, idea.status) }}</span></td>
<td><small>{{ idea.updated_at.strftime('%d.%m.%Y') if idea.updated_at else '' }}</small></td>
<td class="actions">
<form method="post" action="/service/ideas/status" style="display:inline">
<input type="hidden" name="id" value="{{ idea.id }}">
<button class="btn btn-secondary btn-sm" title="Переключить статус"></button>
</form>
<button class="btn btn-secondary btn-sm" onclick="editIdea({{ idea.id }},{{ idea.title|tojson }},{{ idea.description|tojson }})"></button>
<form method="post" action="/service/ideas/delete" style="display:inline" id="delete-idea-form-{{ idea.id }}">
<input type="hidden" name="id" value="{{ idea.id }}">
<button type="button" class="btn btn-danger btn-sm" onclick="openConfirmDeleteIdea({{ idea.id }},{{ idea.title|tojson }})" title="Удалить"></button>
</form>
</td>
</tr>{% endfor %}</tbody></table>
</div>
</div>
<div class="modal-overlay" id="modal-idea"><div class="modal">
<button type="button" class="modal-close" onclick="this.closest('.modal-overlay').classList.remove('open')"></button>
<h2 id="modal-idea-title">Новая идея</h2>
<form method="post" id="modal-idea-form">
<input type="hidden" name="id" id="idea-id">
<div class="form-group"><label>Название</label><input type="text" name="title" id="idea-title" required></div>
<div class="form-group"><label>Описание</label><textarea name="description" id="idea-description" rows="4"></textarea></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-delete-idea">
<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-idea-name"></strong> будет удалён навсегда. Это действие нельзя отменить.
</p>
<div class="modal-actions" style="justify-content:flex-end;">
<button type="button" class="btn btn-danger" onclick="confirmDeleteIdea()">Удалить</button>
<button type="button" class="btn" onclick="closeConfirmDeleteIdea()">Отмена</button>
</div>
</div>
</div>
<script>
var deleteIdeaId = null;
function openConfirmDeleteIdea(id, name){
deleteIdeaId = id;
document.getElementById('delete-idea-name').textContent = name || '#' + id;
document.getElementById('confirm-delete-idea').classList.add('open');
}
function closeConfirmDeleteIdea(){
document.getElementById('confirm-delete-idea').classList.remove('open');
deleteIdeaId = null;
}
function confirmDeleteIdea(){
if(!deleteIdeaId) return;
document.getElementById('delete-idea-form-' + deleteIdeaId).submit();
closeConfirmDeleteIdea();
}
function editIdea(id,title,description){
document.getElementById('modal-idea').classList.add('open');
document.getElementById('modal-idea-title').textContent = 'Редактировать идею';
document.getElementById('modal-idea-form').action = '/service/ideas/edit';
document.getElementById('idea-id').value = id;
document.getElementById('idea-title').value = title;
document.getElementById('idea-description').value = description;
}
document.addEventListener('DOMContentLoaded', function(){
var form = document.getElementById('modal-idea-form');
if(form) form.action = '/service/ideas/create';
});
</script>
{% endblock %}