feat: more changes and fixes

This commit is contained in:
Herculino Trotta
2025-11-08 14:06:01 -03:00
parent a878af28f1
commit cd54df6f2d
45 changed files with 412 additions and 476 deletions
@@ -1,13 +1,12 @@
{% load natural %}
{% load i18n %}
{% regroup page_obj by date|customnaturaldate as transactions_by_date %}
<div id="transactions-list">
<div id="transactions-list" class="show-loading">
{% for x in transactions_by_date %}
<div id="{{ x.grouper|slugify }}" class="transactions-divider"
_="on htmx:afterSwap from #transactions if sessionStorage.getItem(my id) is null then sessionStorage.setItem(my id, 'true')">
<div class="mt-3 mb-1 w-full text-base border-b border-base-300 bg-base-100 transactions-divider-title">
<div class="mt-3 mb-1 w-full border-b border-b-base-content/30 transactions-divider-title cursor-pointer">
<a class="no-underline inline-block w-full"
role="button"
data-bs-toggle="collapse"
@@ -18,7 +17,7 @@
{{ x.grouper }}
</a>
</div>
<div class="collapse transactions-divider-collapse overflow-visible isolation-auto" id="c-{{ x.grouper|slugify }}-collapse"
<div class="bs collapse transactions-divider-collapse overflow-visible isolation-auto" id="c-{{ x.grouper|slugify }}-collapse"
_="on shown.bs.collapse sessionStorage.setItem(the closest parent @id, 'true')
on hidden.bs.collapse sessionStorage.setItem(the closest parent @id, 'false')
on htmx:afterSettle from #transactions or toggle
@@ -41,14 +40,18 @@
</div>
</div>
</div>
{% empty %}
<c-msg.empty
title="{% translate "No transactions found" %}"
subtitle="{% translate "Try adding one" %}"></c-msg.empty>
{% endfor %}
{# Floating bar #}
<c-ui.transactions-action-bar></c-ui.transactions-action-bar>
{% if page_obj.has_other_pages %}
<div class="mt-auto">
<div class="my-3">
<input value="{{ page_obj.number }}" name="page" type="hidden" id="page">
<nav aria-label="{% translate 'Page navigation' %}">
@@ -86,7 +89,8 @@
hx-vals='{"page": {{ page_number }}}'
hx-include="#filter, #order"
hx-target="#transactions-list"
hx-swap="show:top">
hx-swap="outerHTML show:top"
hx-indicator="#transactions-list">
{{ page_number }}
</a>
</li>
@@ -102,10 +106,12 @@
</li>
<li>
<a class="join-item btn btn-sm"
hx-get="{% url 'transactions_all_list' %}" hx-target="#transactions-list"
hx-get="{% url 'transactions_all_list' %}"
hx-target="#transactions-list"
hx-vals='{"page": {{ page_obj.paginator.num_pages }}}'
hx-include="#filter, #order"
hx-swap="show:top"
hx-swap="outerHTML show:top"
hx-indicator="#transactions-list"
aria-label="Última página">
<span aria-hidden="true">{{ page_obj.paginator.num_pages }}</span>
</a>
@@ -116,8 +122,9 @@
hx-get="{% if page_obj.has_next %}{% url 'transactions_all_list' %}{% endif %}"
hx-vals='{"page": {{ page_obj.paginator.num_pages }}}'
hx-include="#filter, #order"
hx-swap="show:top"
hx-swap="outerHTML show:top"
hx-target="#transactions-list"
hx-indicator="#transactions-list"
aria-label="Next">
<span aria-hidden="true">&raquo;</span>
</a>
@@ -126,7 +133,4 @@
</nav>
</div>
{% endif %}
{# Floating bar#}
<c-ui.transactions-action-bar></c-ui.transactions-action-bar>
</div>
@@ -1,47 +1,30 @@
{% load tools %}
{% load i18n %}
{% load currency_display %}
<ul class="nav nav-tabs" id="all-trasactions-tab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="currency-tab" data-bs-toggle="tab" data-bs-target="#currency-tab-pane"
type="button" role="tab" aria-controls="currency-tab-pane"
aria-selected="true">{% trans 'Currencies' %}</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="account-tab" data-bs-toggle="tab" data-bs-target="#account-tab-pane" type="button"
role="tab" aria-controls="account-tab-pane" aria-selected="false">{% trans 'Accounts' %}</button>
</li>
</ul>
<div class="tab-content" id="all-transactions-content">
<div class="tab-pane fade show active" id="currency-tab-pane" role="tabpanel" aria-labelledby="currency-tab"
tabindex="0">
<div class="row row-cols-1 g-4 mt-2">
{% for currency_id, currency in currency_data.items %}
<div class="col">
<c-ui.currency_card :currency="currency" :currency_id="currency_id"
:percentages="currency_percentages"></c-ui.currency_card>
</div>
{% empty %}
<div class="col">
<c-msg.empty
title="{% translate "No information to display" %}"></c-msg.empty>
{% endfor %}
</div>
<div class="grid grid-cols-1 gap-4 mt-1 mb-3">
{% for currency_id, currency in currency_data.items %}
<div>
<c-ui.currency_card :currency="currency" :currency_id="currency_id"
:percentages="currency_percentages"></c-ui.currency_card>
</div>
</div>
<div class="tab-pane fade" id="account-tab-pane" role="tabpanel" aria-labelledby="account-tab" tabindex="0">
<div class="row row-cols-1 g-4 mt-2">
{% for account_id, account in account_data.items %}
<div class="col">
<c-ui.account_card :account="account" :account_id="account_id"
:percentages="account_percentages"></c-ui.account_card>
</div>
{% empty %}
<div class="col">
<c-msg.empty
title="{% translate "No information to display" %}"></c-msg.empty>
{% endfor %}
</div>
{% empty %}
<div>
<c-msg.empty
title="{% translate "No information to display" %}"></c-msg.empty>
</div>
{% endfor %}
</div>
<div class="grid grid-cols-1 gap-4 mt-1 mb-3">
{% for account_id, account in account_data.items %}
<div>
<c-ui.account_card :account="account" :account_id="account_id"
:percentages="account_percentages"></c-ui.account_card>
</div>
{% empty %}
<div>
<c-msg.empty
title="{% translate "No information to display" %}"></c-msg.empty>
{% endfor %}
</div>
</div>
@@ -5,12 +5,45 @@
{% block title %}{% translate 'Transactions' %}{% endblock %}
{% block content %}
<div class="container px-md-3 py-3 column-gap-5 overflow-x-hidden">
<div class="flex flex-wrap gap-x-xl-4 gap-y-3">
<div class="w-full xl:w-8/12 order-2 xl:order-1">
<div class="mb-3">
<div class="container gap-y-3">
<div class="row gap-y-3">
<div class="col-12 lg:col-4 lg:order-last! order-first!">
<div role="tablist" class="tabs tabs-border">
<input type="radio" name="all-transactions-summary" class="tab" aria-label="{% trans 'Currencies' %}"
role="tab"
{% if summary_tab == 'currency' %}checked="checked"{% endif %}
_="on click fetch {% url 'transaction_all_summary_select' selected='currency' %}"
aria-controls="currency-tab-pane" />
<div class="tab-content" id="currency-tab-pane" role="tabpanel">
<div id="currency-summary"
hx-get="{% url 'transaction_all_currency_summary' %}"
class="show-loading"
hx-trigger="load, selective_update from:window, updated from:window, change from:#filter, submit from:#filter, search from:#filter"
hx-include="#filter">
</div>
</div>
<input type="radio" name="all-transactions-summary" class="tab" aria-label="{% trans 'Accounts' %}"
role="tab"
{% if summary_tab == 'account' %}checked="checked"{% endif %}
_="on click fetch {% url 'transaction_all_summary_select' selected='account' %}"
aria-controls="account-tab-pane" />
<div class="tab-content" id="account-tab-pane" role="tabpanel">
<div id="account-summary"
hx-get="{% url 'transaction_all_account_summary' %}"
class="show-loading"
hx-trigger="load, selective_update from:window, updated from:window, change from:#filter, submit from:#filter, search from:#filter"
hx-include="#filter">
</div>
</div>
</div>
</div>
<div class="col-12 lg:col-8 lg:order-first! order-last!">
<div>
{# Hidden select to hold the order value and preserve the original update trigger #}
<select name="order" id="order" class="hidden" _="on change trigger updated on window">
<select name="order" id="order" class="d-none" _="on change trigger updated on window">
<option value="default" {% if order == 'default' %}selected{% endif %}>{% translate 'Default' %}</option>
<option value="older" {% if order == 'older' %}selected{% endif %}>{% translate 'Oldest first' %}</option>
<option value="newer" {% if order == 'newer' %}selected{% endif %}>{% translate 'Newest first' %}</option>
@@ -19,7 +52,7 @@
{# Main control bar with filter, search, and ordering #}
<div class="join w-full">
<button class="btn btn-secondary join-item" type="button"
<button class="btn btn-secondary join-item relative" type="button"
data-bs-toggle="collapse" data-bs-target="#collapse-filter"
aria-expanded="false" aria-controls="collapse-filter" id="filter-button" hx-preserve
title="{% translate 'Filter transactions' %}">
@@ -27,10 +60,10 @@
</button>
{# Search box #}
<label for="quick-search" class="join-item flex-grow">
<label for="quick-search" class="hidden">
</label>
<input type="search"
class="input input-bordered join-item flex-grow"
class="input input-bordered join-item flex-1"
placeholder="{% translate 'Search' %}"
hx-preserve
id="quick-search"
@@ -46,34 +79,33 @@
{# Order by icon dropdown #}
<div class="dropdown dropdown-end">
<button class="btn btn-secondary join-item" type="button"
tabindex="0" role="button"
<button tabindex="0" class="btn btn-secondary join-item" type="button"
title="{% translate 'Order by' %}">
<i class="fa-solid fa-sort fa-fw"></i>
</button>
<ul class="dropdown-content menu bg-base-100 rounded-box z-[1] w-52 p-2 shadow" tabindex="0">
<ul tabindex="0" class="dropdown-content menu bg-base-300 rounded-box z-1 w-62 p-2 shadow-md mt-1">
<li>
<button class="{% if order == 'default' %}active{% endif %}" type="button"
_="on click remove .active from <button/> in the closest <ul/>
then add .active to me
<button class="{% if order == 'default' %}menu-active{% endif %}" type="button"
_="on click remove .menu-active from <li > button/> in the closest <ul/>
then add .menu-active to me
then set the value of #order to 'default'
then trigger change on #order">
{% translate 'Default' %}
</button>
</li>
<li>
<button class="{% if order == 'older' %}active{% endif %}" type="button"
_="on click remove .active from <button/> in the closest <ul/>
then add .active to me
<button class="{% if order == 'older' %}menu-active{% endif %}" type="button"
_="on click remove .menu-active from <li > button/> in the closest <ul/>
then add .menu-active to me
then set the value of #order to 'older'
then trigger change on #order">
{% translate 'Oldest first' %}
</button>
</li>
<li>
<button class="{% if order == 'newer' %}active{% endif %}" type="button"
_="on click remove .active from <button/> in the closest <ul/>
then add .active to me
<button class="{% if order == 'newer' %}menu-active{% endif %}" type="button"
_="on click remove .menu-active from <li > button/> in the closest <ul/>
then add .menu-active to me
then set the value of #order to 'newer'
then trigger change on #order">
{% translate 'Newest first' %}
@@ -84,9 +116,9 @@
</div>
{# Filter transactions form #}
<div class="collapse" id="collapse-filter" hx-preserve>
<div class="card card-body bg-base-100 shadow-xl">
<div class="text-end">
<div class="bs collapse overflow-visible" id="collapse-filter" hx-preserve>
<div class="card card-body bg-base-200 mt-2">
<div class="text-right">
<button class="btn btn-outline btn-error btn-sm w-fit"
_="on click call #filter.reset() then trigger change on #filter">{% translate 'Clear' %}</button>
</div>
@@ -98,46 +130,20 @@
{% crispy filter.form %}
</form>
<div class="text-end">
<div class="text-right">
<button class="btn btn-outline btn-error btn-sm w-fit"
_="on click call #filter.reset() then trigger change on #filter">{% translate 'Clear' %}</button>
</div>
</div>
</div>
</div>
{# Transactions list#}
<div id="transactions"
class="show-loading"
hx-get="{% url 'transactions_all_list' %}"
hx-trigger="load, updated from:window" hx-include="#filter, #page, #order">
</div>
</div>
<div class="w-full xl:w-4/12 order-1 xl:order-2">
<div role="tablist" class="tabs tabs-lifted">
<input type="radio" name="all-transactions-summary" role="tab" class="tab" aria-label="{% trans 'Currencies' %}"
{% if summary_tab == 'currency' %}checked="checked"{% endif %}
_="on change fetch {% url 'transaction_all_summary_select' selected='currency' %}" />
<div role="tabpanel" class="tab-content border-base-300 rounded-box p-6">
<div id="currency-summary"
hx-get="{% url 'transaction_all_currency_summary' %}"
class="show-loading"
hx-trigger="load, selective_update from:window, updated from:window, change from:#filter, submit from:#filter, search from:#filter"
hx-include="#filter">
</div>
</div>
<input type="radio" name="all-transactions-summary" role="tab" class="tab" aria-label="{% trans 'Accounts' %}"
{% if summary_tab == 'account' %}checked="checked"{% endif %}
_="on change fetch {% url 'transaction_all_summary_select' selected='account' %}" />
<div role="tabpanel" class="tab-content border-base-300 rounded-box p-6">
<div id="account-summary"
hx-get="{% url 'transaction_all_account_summary' %}"
class="show-loading"
hx-trigger="load, selective_update from:window, updated from:window, change from:#filter, submit from:#filter, search from:#filter"
hx-include="#filter">
</div>
</div>
</div>
</div>
</div>
</div>
<c-ui.transactions_fab></c-ui.transactions_fab>