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" %}
<h3>{% translate "Statements" %}</h3>
{% include "statement/statement_table.html" %}
<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 %}
<h3>{% translate "Transactions" %}</h3>
{% include "transaction/transaction_table.html" %}
{% 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,25 +11,23 @@
<th>{% translate "Delete" %}</th>
</thead>
<tbody>
{% if transaction.invoices %}
{% for invoice in transaction.invoices %}
<tr>
<th scope="row" class="l">
<a href="{{ invoice.get_absolute_url }}">{{ invoice.name }}</a>
</th>
<td>
<a href="{{ invoice.file.url }}">{% translate "File" %} [{{ invoice.file|extension }}]</a>
{% for invoice in transaction.invoices %}
<tr>
<th scope="row" class="l">
<a href="{{ invoice.get_absolute_url }}">{{ invoice.name }}</a>
</th>
<td>
<a href="{{ invoice.file.url }}">{% translate "File" %} [{{ invoice.file|extension }}]</a>
</td>
<td>
<a href="{{ invoice.get_delete_url }}">{% translate "Delete" %}
</td>
<td>
<a href="{{ invoice.get_delete_url }}">{% translate "Delete" %}
</td>
</tr>
{% endfor %}
{% else %}
<tr>
<td colspan="3">{% translate "No invoice" %}</td>
</tr>
{% endif %}
{% empty %}
<tr>
<td class="empty" colspan="3">{% translate "No invoice" %}</td>
</tr>
{% 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>