Empty tables are now visible

This commit is contained in:
Edgar P. Burkhart 2023-04-22 14:28:49 +02:00
parent a3f28631df
commit 2d7957b813
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
7 changed files with 45 additions and 32 deletions

View file

@ -10,13 +10,11 @@
{% block h2 %}{{ form.instance.icon|remix }}{{ form.instance }}{% endblock %}
{% block tables %}
{% if not form.instance|adding %}
{% if statements %}
<h3>{% translate "Statements" %}</h3>
{% include "statement/statement_table.html" %}
{% endif %}
{% if transactions %}
<h3>{% translate "Transactions" %}</h3>
{% include "transaction/transaction_table.html" %}
{% if history.data %}
<h3>{% translate "History" %}</h3>
{% include "history/plot.html" %}
{% endif %}

View file

@ -9,10 +9,8 @@
{% endblock %}
{% block h2 %}{{ form.instance.icon|remix }}{{ form.instance }}{% endblock %}
{% block tables %}
{% if transactions %}
<h3>{% translate "Transactions" %}</h3>
{% include "transaction/transaction_table.html" %}
{% endif %}
{% if history.data %}
<h3>{% translate "History" %}</h3>
{% include "history/plot.html" %}

View file

@ -19,14 +19,17 @@ class CategoryUpdateView(NummiUpdateView):
pk_url_kwarg = "category"
def get_context_data(self, **kwargs):
_max = 8
data = super().get_context_data(**kwargs)
category = data["form"].instance
return data | {
"transactions": category.transaction_set.all()[:8],
"transactions_url": reverse_lazy(
data["transactions"] = category.transaction_set.all()[:_max]
if len(data["transactions"]) == _max:
data["transactions_url"] = reverse_lazy(
"category_transactions", args=(category.pk,)
),
)
return data | {
"history": history(category.transaction_set),
}

View file

@ -47,3 +47,8 @@ th {
.date {
text-align: center;
}
td.empty {
text-align: center;
opacity: 0.8;
font-weight: 300;
}

View file

@ -51,6 +51,10 @@
<td class="value">{{ snap.diff|pmvalue }}</td>
<td class="value">{{ snap.sum|pmvalue }}</td>
</tr>
{% empty %}
<tr>
<td class="empty" colspan="{% if account %}6{% else %}8{% endif %}">{% translate "No transaction" %}</td>
</tr>
{% endfor %}
</tbody>
</table>

View file

@ -11,7 +11,6 @@
<th>{% translate "Delete" %}</th>
</thead>
<tbody>
{% if transaction.invoices %}
{% for invoice in transaction.invoices %}
<tr>
<th scope="row" class="l">
@ -24,12 +23,11 @@
<a href="{{ invoice.get_delete_url }}">{% translate "Delete" %}
</td>
</tr>
{% endfor %}
{% else %}
{% empty %}
<tr>
<td colspan="3">{% translate "No invoice" %}</td>
<td class="empty" colspan="3">{% translate "No invoice" %}</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
<tfoot>
<tr>

View file

@ -64,6 +64,13 @@
</td>
{% endif %}
</tr>
{% empty %}
<tr>
<td class="empty"
colspan="{% if category and account %}5{% elif category or account %}7{% else %}9{% endif %}">
{% translate "No transaction" %}
</td>
</tr>
{% endfor %}
</tbody>
</table>