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 h2 %}{{ form.instance.icon|remix }}{{ form.instance }}{% endblock %}
{% block tables %} {% block tables %}
{% if not form.instance|adding %} {% if not form.instance|adding %}
{% if statements %} <h3>{% translate "Statements" %}</h3>
<h3>{% translate "Statements" %}</h3> {% include "statement/statement_table.html" %}
{% include "statement/statement_table.html" %} <h3>{% translate "Transactions" %}</h3>
{% endif %} {% include "transaction/transaction_table.html" %}
{% if transactions %} {% if history.data %}
<h3>{% translate "Transactions" %}</h3>
{% include "transaction/transaction_table.html" %}
<h3>{% translate "History" %}</h3> <h3>{% translate "History" %}</h3>
{% include "history/plot.html" %} {% include "history/plot.html" %}
{% endif %} {% endif %}

View file

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

View file

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

View file

@ -47,3 +47,8 @@ th {
.date { .date {
text-align: center; 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.diff|pmvalue }}</td>
<td class="value">{{ snap.sum|pmvalue }}</td> <td class="value">{{ snap.sum|pmvalue }}</td>
</tr> </tr>
{% empty %}
<tr>
<td class="empty" colspan="{% if account %}6{% else %}8{% endif %}">{% translate "No transaction" %}</td>
</tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>

View file

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

View file

@ -64,6 +64,13 @@
</td> </td>
{% endif %} {% endif %}
</tr> </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 %} {% endfor %}
</tbody> </tbody>
</table> </table>