feat: automated replacement

This commit is contained in:
Herculino Trotta
2025-10-28 14:13:30 -03:00
parent dd82289488
commit e600d87968
167 changed files with 4442 additions and 2503 deletions

View File

@@ -2,14 +2,14 @@
{% load i18n %}
{% load currency_display %}
<div class="row row-cols-1 g-4 mt-1 mb-3">
<div class="tw:grid tw:grid-cols-1 tw:gap-4 tw:mt-1 tw:mb-3">
{% for account_id, account in account_data.items %}
<div class="col">
<div class="tw:w-full">
<c-ui.account_card :account="account" :account_id="account_id"
:percentages="account_percentages"></c-ui.account_card>
</div>
{% empty %}
<div class="col">
<div class="tw:w-full">
<c-msg.empty
title="{% translate "No information to display" %}"></c-msg.empty>
{% endfor %}

View File

@@ -1,14 +1,14 @@
{% load tools %}
{% load i18n %}
{% load currency_display %}
<div class="row row-cols-1 g-4 mt-1 mb-3">
<div class="tw:grid tw:grid-cols-1 tw:gap-4 tw:mt-1 tw:mb-3">
{% for currency_id, currency in currency_data.items %}
<div class="col">
<div class="tw:w-full">
<c-ui.currency_card :currency="currency" :currency_id="currency_id"
:percentages="currency_percentages"></c-ui.currency_card>
</div>
{% empty %}
<div class="col">
<div class="tw:w-full">
<c-msg.empty
title="{% translate "No information to display" %}"></c-msg.empty>
</div>

View File

@@ -7,8 +7,8 @@
{% 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-100 tw:text-base border-bottom bg-body transactions-divider-title">
<a class="text-decoration-none d-inline-block w-100"
<div class="tw:mt-3 tw:mb-1 tw:w-full tw:text-base tw:border-b tw:border-base-300 tw:bg-base-100 transactions-divider-title">
<a class="tw:no-underline tw:inline-block tw:w-full"
role="button"
data-bs-toggle="collapse"
data-bs-target="#c-{{ x.grouper|slugify }}-collapse"
@@ -18,7 +18,7 @@
{{ x.grouper }}
</a>
</div>
<div class="collapse transactions-divider-collapse" id="c-{{ x.grouper|slugify }}-collapse"
<div class="tw:collapse transactions-divider-collapse" 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
@@ -33,7 +33,7 @@
on show
add .show to me
set @aria-expanded of #c-{{ x.grouper|slugify }}-collapsible to true">
<div class="d-flex flex-column">
<div class="tw:flex tw:flex-col">
{% for transaction in x.list %}
<c-transaction.item
:transaction="transaction"></c-transaction.item>
@@ -48,13 +48,13 @@
{% endfor %}
{% if page_obj.has_other_pages %}
<div class="mt-auto">
<div class="tw:mt-auto">
<input value="{{ page_obj.number }}" name="page" type="hidden" id="page">
<nav aria-label="{% translate 'Page navigation' %}">
<ul class="pagination justify-content-center mt-5">
<li class="page-item">
<a class="page-link tw:cursor-pointer {% if not page_obj.has_previous %}disabled{% endif %}"
<ul class="tw:join tw:flex tw:justify-center tw:mt-5">
<li>
<a class="tw:join-item tw:btn tw:btn-sm {% if not page_obj.has_previous %}tw:btn-disabled{% endif %}"
hx-get="{% if page_obj.has_previous %}{% url 'transactions_all_list' %}{% endif %}"
hx-vals='{"page": 1}'
hx-include="#filter, #order"
@@ -74,14 +74,14 @@
{% endcomment %}
{% if page_number <= page_obj.number|add:3 and page_number >= page_obj.number|add:-3 %}
{% if page_obj.number == page_number %}
<li class="page-item active">
<a class="page-link tw:cursor-pointer">
<li>
<a class="tw:join-item tw:btn tw:btn-sm tw:btn-active">
{{ page_number }}
</a>
</li>
{% else %}
<li class="page-item">
<a class="page-link tw:cursor-pointer"
<li>
<a class="tw:join-item tw:btn tw:btn-sm"
hx-get="{% url 'transactions_all_list' %}"
hx-vals='{"page": {{ page_number }}}'
hx-include="#filter, #order"
@@ -94,14 +94,14 @@
{% endif %}
{% endfor %}
{% if page_obj.number|add:3 < page_obj.paginator.num_pages %}
<li class="page-item">
<a class="page-link disabled"
<li>
<a class="tw:join-item tw:btn tw:btn-sm tw:btn-disabled"
aria-label="...">
<span aria-hidden="true">...</span>
</a>
</li>
<li class="page-item">
<a class="page-link tw:cursor-pointer"
<li>
<a class="tw:join-item tw:btn tw:btn-sm"
hx-get="{% url 'transactions_all_list' %}" hx-target="#transactions-list"
hx-vals='{"page": {{ page_obj.paginator.num_pages }}}'
hx-include="#filter, #order"
@@ -111,8 +111,8 @@
</a>
</li>
{% endif %}
<li class="page-item">
<a class="page-link {% if not page_obj.has_next %}disabled{% endif %} tw:cursor-pointer"
<li>
<a class="tw:join-item tw:btn tw:btn-sm {% if not page_obj.has_next %}tw:btn-disabled{% endif %}"
hx-get="{% if page_obj.has_next %}{% url 'transactions_all_list' %}{% endif %}"
hx-vals='{"page": {{ page_obj.paginator.num_pages }}}'
hx-include="#filter, #order"

View File

@@ -5,7 +5,7 @@
{% block title %}{% translate 'New transaction' %}{% endblock %}
{% block content %}
<div class="container py-3 column-gap-5"
<div class="tw:container tw:py-3 tw:column-gap-5"
_="install init_tom_select
install init_datepicker">
<form hx-post="{% url 'transaction_simple_add' %}" hx-swap="outerHTML" hx-target="body" novalidate>

View File

@@ -5,21 +5,21 @@
{% block title %}{% translate 'Transactions' %}{% endblock %}
{% block content %}
<div class="container px-md-3 py-3 column-gap-5">
<div class="row gx-xl-4 gy-3">
<div class="col-12 col-xl-8 order-2 order-xl-1">
<div class="mb-3">
<div class="tw:container tw:px-md-3 tw:py-3 tw:column-gap-5">
<div class="tw:flex tw:flex-wrap tw:gap-x-xl-4 tw:gap-y-3">
<div class="tw:w-full tw:xl:w-8/12 tw:order-2 tw:xl:order-1">
<div class="tw:mb-3">
{# Hidden select to hold the order value and preserve the original update trigger #}
<select name="order" id="order" class="d-none" _="on change trigger updated on window">
<select name="order" id="order" class="tw:hidden" _="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>
</select>
{# Main control bar with filter, search, and ordering #}
<div class="input-group">
<div class="tw:join tw:w-full">
<button class="btn btn-secondary position-relative" type="button"
<button class="tw:btn tw:btn-secondary tw:join-item" 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 +27,10 @@
</button>
{# Search box #}
<label for="quick-search">
<label for="quick-search" class="tw:join-item tw:flex-grow">
</label>
<input type="search"
class="form-control"
class="tw:input tw:input-bordered tw:join-item tw:flex-grow"
placeholder="{% translate 'Search' %}"
hx-preserve
id="quick-search"
@@ -45,59 +45,61 @@
when its textContent.toLowerCase() contains my value.toLowerCase()">
{# Order by icon dropdown #}
<button class="btn btn-secondary dropdown-toggle dropdown-toggle-no-icon" type="button"
data-bs-toggle="dropdown" aria-expanded="false"
title="{% translate 'Order by' %}">
<i class="fa-solid fa-sort fa-fw"></i>
</button>
<ul class="dropdown-menu dropdown-menu-end">
<li>
<button class="dropdown-item {% if order == 'default' %}active{% endif %}" type="button"
_="on click remove .active from .dropdown-item in the closest <ul/>
then add .active to me
then set the value of #order to 'default'
then trigger change on #order">
{% translate 'Default' %}
</button>
</li>
<li>
<button class="dropdown-item {% if order == 'older' %}active{% endif %}" type="button"
_="on click remove .active from .dropdown-item in the closest <ul/>
then add .active to me
then set the value of #order to 'older'
then trigger change on #order">
{% translate 'Oldest first' %}
</button>
</li>
<li>
<button class="dropdown-item {% if order == 'newer' %}active{% endif %}" type="button"
_="on click remove .active from .dropdown-item in the closest <ul/>
then add .active to me
then set the value of #order to 'newer'
then trigger change on #order">
{% translate 'Newest first' %}
</button>
</li>
</ul>
<div class="tw:dropdown tw:dropdown-end">
<button class="tw:btn tw:btn-secondary tw:join-item" type="button"
tabindex="0" role="button"
title="{% translate 'Order by' %}">
<i class="fa-solid fa-sort fa-fw"></i>
</button>
<ul class="tw:dropdown-content tw:menu tw:bg-base-100 tw:rounded-box tw:z-[1] tw:w-52 tw:p-2 tw:shadow" tabindex="0">
<li>
<button class="{% if order == 'default' %}tw:active{% endif %}" type="button"
_="on click remove .tw:active from <button/> in the closest <ul/>
then add .tw: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' %}tw:active{% endif %}" type="button"
_="on click remove .tw:active from <button/> in the closest <ul/>
then add .tw: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' %}tw:active{% endif %}" type="button"
_="on click remove .tw:active from <button/> in the closest <ul/>
then add .tw:active to me
then set the value of #order to 'newer'
then trigger change on #order">
{% translate 'Newest first' %}
</button>
</li>
</ul>
</div>
</div>
{# Filter transactions form #}
<div class="collapse" id="collapse-filter" hx-preserve>
<div class="card card-body">
<div class="text-end">
<button class="btn btn-outline-danger btn-sm tw:w-fit"
<div class="tw:collapse" id="collapse-filter" hx-preserve>
<div class="tw:card tw:card-body tw:bg-base-100 tw:shadow-xl">
<div class="tw:text-end">
<button class="tw:btn tw:btn-outline tw:btn-error tw:btn-sm tw:w-fit"
_="on click call #filter.reset() then trigger change on #filter">{% translate 'Clear' %}</button>
</div>
<form _="on change or submit or search trigger updated on window
install init_tom_select
install init_datepicker"
id="filter" class="mt-3">
id="filter" class="tw:mt-3">
{% crispy filter.form %}
</form>
<div class="text-end">
<button class="btn btn-outline-danger btn-sm tw:w-fit"
<div class="tw:text-end">
<button class="tw:btn tw:btn-outline tw:btn-error tw:btn-sm tw:w-fit"
_="on click call #filter.reset() then trigger change on #filter">{% translate 'Clear' %}</button>
</div>
</div>
@@ -109,41 +111,12 @@
hx-trigger="load, updated from:window" hx-include="#filter, #page, #order">
</div>
</div>
<div class="col-12 col-xl-4 order-1 order-xl-2">
<ul class="nav nav-tabs" id="all-transactions-summary" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link {% if summary_tab == 'currency' %}active{% endif %}"
id="currency-tab"
data-bs-toggle="tab"
data-bs-target="#currency-tab-pane"
type="button"
role="tab"
aria-controls="currency-tab-pane"
_="on click fetch {% url 'transaction_all_summary_select' selected='currency' %}"
aria-selected="{% if summary_tab == 'currency' %}true{% else %}false{% endif %}">
{% trans 'Currencies' %}
</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link {% if summary_tab == 'account' %}active{% endif %}"
id="account-tab"
data-bs-toggle="tab"
data-bs-target="#account-tab-pane"
type="button"
role="tab"
aria-controls="account-tab-pane"
_="on click fetch {% url 'transaction_all_summary_select' selected='account' %}"
aria-selected="{% if summary_tab == 'account' %}true{% else %}false{% endif %}">
{% trans 'Accounts' %}
</button>
</li>
</ul>
<div class="tab-content" id="all-transactions-content">
<div class="tab-pane fade {% if summary_tab == 'currency' %}show active{% endif %}"
id="currency-tab-pane"
role="tabpanel"
aria-labelledby="currency-tab"
tabindex="0">
<div class="tw:w-full tw:xl:w-4/12 tw:order-1 tw:xl:order-2">
<div role="tablist" class="tw:tabs tw:tabs-lifted">
<input type="radio" name="all-transactions-summary" role="tab" class="tw: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="tw:tab-content tw:bg-base-100 tw:border-base-300 tw:rounded-box tw:p-6">
<div id="currency-summary"
hx-get="{% url 'transaction_all_currency_summary' %}"
class="show-loading"
@@ -151,11 +124,11 @@
hx-include="#filter">
</div>
</div>
<div class="tab-pane fade {% if summary_tab == 'account' %}show active{% endif %}"
id="account-tab-pane"
role="tabpanel"
aria-labelledby="account-tab"
tabindex="0">
<input type="radio" name="all-transactions-summary" role="tab" class="tw: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="tw:tab-content tw:bg-base-100 tw:border-base-300 tw:rounded-box tw:p-6">
<div id="account-summary"
hx-get="{% url 'transaction_all_account_summary' %}"
class="show-loading"

View File

@@ -4,8 +4,8 @@
{% block title %}{% translate 'Deleted transactions' %}{% endblock %}
{% block content %}
<div class="container px-md-3 py-3 column-gap-5">
<div class="tw:text-3xl fw-bold font-monospace tw:w-full mb-3">
<div class="tw:container tw:px-md-3 tw:py-3 tw:column-gap-5">
<div class="tw:text-3xl tw:font-bold tw:font-mono tw:w-full tw:mb-3">
<div>{% translate 'Deleted transactions' %}</div>
</div>

View File

@@ -1,28 +1,25 @@
{% load crispy_forms_field %}
<div class="form-group mb-3">
<div class="btn-group w-100" role="group" aria-label="{{ field.label }}">
<div class="tw:form-group tw:mb-3">
<div class="tw:join tw:w-full" role="group" aria-label="{{ field.label }}">
{% for choice in field.field.choices %}
<input type="radio"
class="btn-check"
class="tw:join-item tw:btn {% if forloop.first %}tw:btn-success{% elif forloop.last %}tw:btn-error{% else %}tw:btn-primary{% endif %} {% if field.errors %}tw:input-error{% endif %}"
name="{{ field.html_name }}"
id="{{ field.html_name }}_{{ forloop.counter }}_tr"
value="{{ choice.0 }}"
aria-label="{{ choice.1 }}"
{% if choice.0 == field.value %}checked{% endif %}>
<label class="btn {% if forloop.first %}btn-outline-success{% elif forloop.last %}btn-outline-danger{% else %}btn-outline-primary{% endif %} {% if field.errors %}is-invalid{% endif %} w-100"
for="{{ field.html_name }}_{{ forloop.counter }}_tr">
{{ choice.1 }}
</label>
{% endfor %}
</div>
{% if field.errors %}
<div class="invalid-feedback d-block">
<div class="tw:text-error tw:text-sm tw:mt-1">
{% for error in field.errors %}
{{ error }}
{% endfor %}
</div>
{% endif %}
{% if field.help_text %}
<small class="form-text text-muted">{{ field.help_text }}</small>
<small class="tw:text-base-content/60 tw:text-sm">{{ field.help_text }}</small>
{% endif %}
</div>

View File

@@ -1,18 +1,16 @@
{% load i18n %}
{% load crispy_forms_field %}
<div class="form-group mb-3">
<div class="btn-group w-100" role="group" aria-label="{{ field.label }}">
<input type="radio" class="btn-check" name="{{ field.name }}" id="{{ field.id_for_label }}_false"
value="false" {% if not field.value %}checked{% endif %}>
<label class="btn btn-outline-primary w-50" for="{{ field.id_for_label }}_false">{% trans 'Projected' %}</label>
<div class="tw:form-group tw:mb-3">
<div class="tw:join tw:w-full" role="group" aria-label="{{ field.label }}">
<input type="radio" class="tw:join-item tw:btn tw:btn-primary" name="{{ field.name }}" id="{{ field.id_for_label }}_false"
value="false" aria-label="{% trans 'Projected' %}" {% if not field.value %}checked{% endif %}>
<input type="radio" class="btn-check" name="{{ field.name }}" id="{{ field.id_for_label }}_true"
value="true" {% if field.value %}checked{% endif %}>
<label class="btn btn-outline-success w-50" for="{{ field.id_for_label }}_true">{% trans 'Paid' %}</label>
<input type="radio" class="tw:join-item tw:btn tw:btn-success" name="{{ field.name }}" id="{{ field.id_for_label }}_true"
value="true" aria-label="{% trans 'Paid' %}" {% if field.value %}checked{% endif %}>
</div>
{% if field.help_text %}
<div class="help-text">{{ field.help_text|safe }}</div>
<div class="tw:text-base-content/60 tw:text-sm tw:mt-1">{{ field.help_text|safe }}</div>
{% endif %}
</div>

View File

@@ -1,6 +1,6 @@
{% load crispy_forms_field %}
<div class="btn-group w-100 mb-3"
<div class="tw:join tw:w-full tw:mb-3"
role="group"
aria-label="{{ field.label }}"
_="on click
@@ -10,14 +10,11 @@
end">
{% for choice in field.field.choices %}
<input type="checkbox"
class="btn-check"
class="tw:join-item tw:btn tw:btn-outline"
name="{{ field.html_name }}"
id="{{ field.html_name }}_{{ forloop.counter }}"
value="{{ choice.0 }}"
aria-label="{{ choice.1 }}"
{% if choice.0 in field.value %}checked{% endif %}>
<label class="btn btn-outline-dark w-100"
for="{{ field.html_name }}_{{ forloop.counter }}">
{{ choice.1 }}
</label>
{% endfor %}
</div>

View File

@@ -1,40 +1,34 @@
{% load i18n %}
{% load crispy_forms_field %}
<div class="form-group mb-3">
<div class="btn-group w-100" role="group" aria-label="{{ field.label }}">
<div class="tw:form-group tw:mb-3">
<div class="tw:join tw:w-full" role="group" aria-label="{{ field.label }}">
<input type="radio"
class="btn-check"
class="tw:join-item tw:btn tw:btn-neutral {% if field.errors %}tw:input-error{% endif %}"
name="{{ field.html_name }}"
id="{{ field.html_name }}_none_tr"
value=""
aria-label="{% trans 'Unchanged' %}"
{% if field.value is None %}checked{% endif %}>
<label class="btn btn-outline-secondary {% if field.errors %}is-invalid{% endif %} w-100"
for="{{ field.html_name }}_none_tr">
{% trans 'Unchanged' %}
</label>
{% for choice in field.field.choices %}
<input type="radio"
class="btn-check"
class="tw:join-item tw:btn {% if forloop.first %}tw:btn-success{% elif forloop.last %}tw:btn-error{% else %}tw:btn-primary{% endif %} {% if field.errors %}tw:input-error{% endif %}"
name="{{ field.html_name }}"
id="{{ field.html_name }}_{{ forloop.counter }}_tr"
value="{{ choice.0 }}"
aria-label="{{ choice.1 }}"
{% if choice.0 == field.value %}checked{% endif %}>
<label class="btn {% if forloop.first %}btn-outline-success{% elif forloop.last %}btn-outline-danger{% else %}btn-outline-primary{% endif %} {% if field.errors %}is-invalid{% endif %} w-100"
for="{{ field.html_name }}_{{ forloop.counter }}_tr">
{{ choice.1 }}
</label>
{% endfor %}
</div>
{% if field.errors %}
<div class="invalid-feedback d-block">
<div class="tw:text-error tw:text-sm tw:mt-1">
{% for error in field.errors %}
{{ error }}
{% endfor %}
</div>
{% endif %}
{% if field.help_text %}
<small class="form-text text-muted">{{ field.help_text }}</small>
<small class="tw:text-base-content/60 tw:text-sm">{{ field.help_text }}</small>
{% endif %}
</div>

View File

@@ -1,22 +1,19 @@
{% load i18n %}
{% load crispy_forms_field %}
<div class="form-group mb-3">
<div class="btn-group w-100" role="group" aria-label="{{ field.label }}">
<input type="radio" class="btn-check" name="{{ field.name }}" id="{{ field.id_for_label }}_null"
value="" {% if field.value is None %}checked{% endif %}>
<label class="btn btn-outline-secondary w-100" for="{{ field.id_for_label }}_null">{% trans 'Unchanged' %}</label>
<div class="tw:form-group tw:mb-3">
<div class="tw:join tw:w-full" role="group" aria-label="{{ field.label }}">
<input type="radio" class="tw:join-item tw:btn tw:btn-neutral" name="{{ field.name }}" id="{{ field.id_for_label }}_null"
value="" aria-label="{% trans 'Unchanged' %}" {% if field.value is None %}checked{% endif %}>
<input type="radio" class="btn-check" name="{{ field.name }}" id="{{ field.id_for_label }}_false"
value="false" {% if field.value is False %}checked{% endif %}">
<label class="btn btn-outline-primary w-100" for="{{ field.id_for_label }}_false">{% trans 'Projected' %}</label>
<input type="radio" class="tw:join-item tw:btn tw:btn-primary" name="{{ field.name }}" id="{{ field.id_for_label }}_false"
value="false" aria-label="{% trans 'Projected' %}" {% if field.value is False %}checked{% endif %}">
<input type="radio" class="btn-check" name="{{ field.name }}" id="{{ field.id_for_label }}_true"
value="true" {% if field.value is True %}checked{% endif %}>
<label class="btn btn-outline-success w-100" for="{{ field.id_for_label }}_true">{% trans 'Paid' %}</label>
<input type="radio" class="tw:join-item tw:btn tw:btn-success" name="{{ field.name }}" id="{{ field.id_for_label }}_true"
value="true" aria-label="{% trans 'Paid' %}" {% if field.value is True %}checked{% endif %}>
</div>
{% if field.help_text %}
<div class="help-text">{{ field.help_text|safe }}</div>
<div class="tw:text-base-content/60 tw:text-sm tw:mt-1">{{ field.help_text|safe }}</div>
{% endif %}
</div>