Enable archiving accounts
This commit is contained in:
parent
50ae922a99
commit
cf25fd1826
7 changed files with 42 additions and 1 deletions
|
@ -10,4 +10,5 @@ class AccountForm(NummiForm):
|
|||
"name",
|
||||
"icon",
|
||||
"default",
|
||||
"archived",
|
||||
]
|
||||
|
|
17
nummi/account/migrations/0003_account_archived.py
Normal file
17
nummi/account/migrations/0003_account_archived.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
# Generated by Django 4.2 on 2024-12-29 09:24
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("account", "0002_alter_account_table"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="account",
|
||||
name="archived",
|
||||
field=models.BooleanField(default=False, verbose_name="Archived"),
|
||||
),
|
||||
]
|
|
@ -15,6 +15,7 @@ class Account(UserModel):
|
|||
verbose_name=_("Icon"),
|
||||
)
|
||||
default = models.BooleanField(default=False, verbose_name=_("Default"))
|
||||
archived = models.BooleanField(default=False, verbose_name=_("Archived"))
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
if self.default:
|
||||
|
|
|
@ -33,6 +33,9 @@ table {
|
|||
border-style: dashed;
|
||||
}
|
||||
}
|
||||
&:not(.show-archive) tr.archived {
|
||||
display: none;
|
||||
}
|
||||
td,
|
||||
th {
|
||||
padding: 0 var(--gap);
|
||||
|
|
8
nummi/main/static/main/js/index.js
Normal file
8
nummi/main/static/main/js/index.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
for (let table of document.querySelectorAll("table")) {
|
||||
let btn = table.querySelector("button.show-archive");
|
||||
if (btn) {
|
||||
btn.addEventListener("click", (event) => {
|
||||
table.classList.toggle("show-archive");
|
||||
});
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@
|
|||
{{ block.super }}
|
||||
{% css "main/css/table.css" %}
|
||||
{% css "main/css/plot.css" %}
|
||||
{% js "main/js/index.js" %}
|
||||
{% endblock %}
|
||||
{% block body %}
|
||||
<div class="split">
|
||||
|
@ -22,7 +23,7 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
{% for acc in accounts %}
|
||||
<tr>
|
||||
<tr class="{% if acc.archived %}archived{% endif %}">
|
||||
<td>{{ acc.icon|remix }}</td>
|
||||
<th class="l">
|
||||
<a href="{{ acc.get_absolute_url }}">{{ acc }}</a>
|
||||
|
@ -52,6 +53,11 @@
|
|||
<a href="{% url "new_account" %}">{% translate "Create account" %}</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
<button class="show-archive">{% translate "Show archived" %}</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
|
|
|
@ -61,6 +61,11 @@ def css(href):
|
|||
)
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def js(href):
|
||||
return mark_safe(f"""<script src="{static(href)}" defer></script>""")
|
||||
|
||||
|
||||
@register.filter
|
||||
def balance(accounts):
|
||||
return sum(
|
||||
|
|
Loading…
Reference in a new issue