fix(requests): исправлено отображение дат в табличном виде

Проблема: API возвращает даты как строки ISO, фильтр date не работал
Решение: используется slice для извлечения даты и времени из ISO строк
- date_from/date_to: slice:":10" для YYYY-MM-DD
- created_at: slice:":10" для даты, slice:"11:16" для времени
- Добавлены проверки на существование значений
This commit is contained in:
admin i 2025-12-03 07:44:25 +03:00
parent 2ec6cdfce8
commit c01c615cb2
2 changed files with 90 additions and 5 deletions

View File

@ -12,6 +12,47 @@
padding: 0;
}
/* Заголовок таблицы */
#reqList .req-table-header {
position: sticky;
top: 0;
z-index: 10;
background: var(--bs-body-bg);
border-bottom: 2px solid var(--bs-border-color);
}
#reqList .req-table-header .req-table-row {
padding: 0.625rem 1rem;
}
#reqList .req-table-header h6 {
font-size: 0.75rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.5px;
color: var(--bs-secondary-color);
margin: 0;
}
#reqList .req-table-header .req-cell {
align-items: center;
}
#reqList .req-table-header .req-cell-title h6,
#reqList .req-table-header .req-cell-author h6 {
text-align: left;
}
#reqList .req-table-header .req-cell-dates h6,
#reqList .req-table-header .req-cell-status h6,
#reqList .req-table-header .req-cell-created h6 {
text-align: center;
}
#reqList .req-table-header .req-cell-actions h6 {
text-align: center;
}
/* Строка заявления */
#reqList .req-row {
padding: 0;
@ -144,6 +185,7 @@
/* Адаптивность для планшетов */
@media (max-width: 992px) {
#reqList .req-table-header .req-table-row,
#reqList .req-table-row {
grid-template-columns:
42px /* Иконка */
@ -155,6 +197,7 @@
}
/* Прячем отдельную колонку действий */
#reqList .req-table-header .req-cell-actions,
#reqList .req-cell-actions {
display: none;
}
@ -168,6 +211,11 @@
/* Адаптивность для мобильных */
@media (max-width: 768px) {
/* Скрываем заголовок таблицы на мобильных */
#reqList .req-table-header {
display: none;
}
#reqList .req-table-row {
grid-template-columns: 36px 1fr;
gap: 0.5rem;

View File

@ -23,6 +23,31 @@
{# ===== Список ===== #}
{# DEBUG: Фильтры - type: {{ filters.type }}, status: {{ filters.status }}, count: {{ requests|length }} #}
<div id="reqList" class="card mb-3">
<!-- Заголовок таблицы -->
<div class="req-table-header">
<div class="req-table-row">
<div class="req-cell req-cell-icon"></div>
<div class="req-cell req-cell-title">
<h6 class="mb-0 text-secondary">Заявление</h6>
</div>
<div class="req-cell req-cell-author">
<h6 class="mb-0 text-secondary">Автор</h6>
</div>
<div class="req-cell req-cell-dates">
<h6 class="mb-0 text-secondary">Период</h6>
</div>
<div class="req-cell req-cell-status">
<h6 class="mb-0 text-secondary">Статус</h6>
</div>
<div class="req-cell req-cell-created">
<h6 class="mb-0 text-secondary">Создано</h6>
</div>
<div class="req-cell req-cell-actions">
<h6 class="mb-0 text-secondary">Действия</h6>
</div>
</div>
</div>
{% if requests %}
{% for obj in requests %}
<article class="req-row" id="req-{{ obj.id }}">
@ -80,10 +105,18 @@
<div class="req-cell req-cell-dates">
<div class="req-cell-content text-mono">
{% if obj.date_from or obj.date_to %}
{{ obj.date_from|date:"d.m.Y"|default:"—" }}<br>
{{ obj.date_to|date:"d.m.Y"|default:"—" }}
{% if obj.date_from %}
{{ obj.date_from|slice:":10" }}<br>
{% else %}
—<br>
{% endif %}
{% if obj.date_to %}
{{ obj.date_to|slice:":10" }}
{% else %}
—
{% endif %}
{% else %}
—
<span class="text-body-secondary">—</span>
{% endif %}
</div>
</div>
@ -113,8 +146,12 @@
<!-- Дата создания -->
<div class="req-cell req-cell-created">
<div class="req-cell-content small text-body-secondary">
{{ obj.created_at|date:"d.m.Y" }}<br>
{{ obj.created_at|date:"H:i" }}
{% if obj.created_at %}
{{ obj.created_at|slice:":10" }}<br>
{{ obj.created_at|slice:"11:16" }}
{% else %}
<span class="text-body-secondary">—</span>
{% endif %}
</div>
</div>