Distingue el estado vacio filtrado del listado sin datos

La tabla de gastos mostraba "No hay gastos / Anade el primero" tanto cuando el
usuario no tiene ningun gasto como cuando sus filtros no devuelven nada. En el
segundo caso el mensaje miente y ademas empuja a crear un gasto que no hace
falta.

Ahora, con cualquier filtro puesto (ano, mes, categoria, etiquetas, cuenta o
rango), el mensaje dice que no hay gastos que coincidan y ofrece quitarlos.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
JKuijperM 2026-09-16 08:33:20 +02:00
parent e48512d2c8
commit 8d3aaf1110
2 changed files with 12 additions and 2 deletions

View File

@ -157,8 +157,13 @@
{% empty %} {% empty %}
<tr> <tr>
<td colspan="6" class="empty-state"> <td colspan="6" class="empty-state">
<p>No hay gastos</p> {% if filters_active %}
<a href="{% url 'expense_create' %}">Añade el primero</a> <p>No hay gastos que coincidan con los filtros</p>
<a href="{% url 'expense_list' %}">Quitar los filtros</a>
{% else %}
<p>No hay gastos</p>
<a href="{% url 'expense_create' %}">Añade el primero</a>
{% endif %}
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}

View File

@ -445,6 +445,10 @@ def expense_list(request):
advanced_filters_open = bool(category or selected_tags) advanced_filters_open = bool(category or selected_tags)
filters_active = bool(
year or month or category or selected_tags or account_id or range_active
)
return render( return render(
request, request,
"expenses/expense_list.html", "expenses/expense_list.html",
@ -470,6 +474,7 @@ def expense_list(request):
"accounts": Account.objects.filter(owner=request.user), "accounts": Account.objects.filter(owner=request.user),
"selected_account": account_id, "selected_account": account_id,
"advanced_filters_open": advanced_filters_open, "advanced_filters_open": advanced_filters_open,
"filters_active": filters_active,
"query_params": query_params.urlencode(), "query_params": query_params.urlencode(),
}, },
) )