Files
WYGIWYH/app/templates/monthly_overview/pages/overview.html
T
2025-10-28 14:13:30 -03:00

209 lines
10 KiB
HTML

{% extends "layouts/base.html" %}
{% load crispy_forms_tags %}
{% load i18n %}
{% load month_name %}
{% load static %}
{% block title %}{% translate 'Monthly Overview' %} :: {{ month|month_name }}/{{ year }}{% endblock %}
{% block body_hyperscript %}
on keyup[code is 'ArrowLeft' and target.nodeName is 'BODY'] from body trigger 'previous_month' end
on keyup[code is 'ArrowRight' and target.nodeName is 'BODY'] from body trigger 'next_month' end
{% endblock %}
{% block content %}
<div class="tw:container tw:px-3 tw:md:px-3 tw:py-3 tw:gap-5">
<div class="tw:grid tw:grid-cols-1 tw:xl:grid-cols-12 tw:gap-x-4 tw:gap-y-3 tw:mb-4">
{# Date picker#}
<div class="tw:col-span-1 tw:xl:col-span-4 tw:flex tw:flex-row tw:items-center">
<div class="tw:text-base tw:h-full tw:flex tw:items-center">
<a role="button"
class="tw:pe-4 tw:py-2"
hx-boost="true"
hx-trigger="click, previous_month from:window"
href="{% url 'monthly_overview' month=previous_month year=previous_year %}"><i
class="fa-solid fa-chevron-left"></i></a>
</div>
<div class="tw:text-3xl tw:font-bold tw:font-mono tw:w-full tw:text-center"
hx-get="{% url 'month_year_picker' %}"
hx-target="#generic-offcanvas-left"
hx-trigger="click, date_picker from:window"
hx-vals='{"month": {{ month }}, "year": {{ year }}, "for": "monthly_overview", "field": "reference_date"}'
role="button">
{{ month|month_name }} {{ year }}
</div>
<div class="tw:text-base tw:mx-2 tw:h-full tw:flex tw:items-center">
<a role="button"
class="tw:ps-3 tw:py-2"
hx-boost="true"
hx-trigger="click, next_month from:window"
href="{% url 'monthly_overview' month=next_month year=next_year %}">
<i class="fa-solid fa-chevron-right"></i>
</a>
</div>
</div>
{# Action buttons#}
{# <div class="col-12 col-xl-8">#}
{# <c-ui.quick-transactions-buttons#}
{# :year="year"#}
{# :month="month"#}
{# ></c-ui.quick-transactions-buttons>#}
{# </div>#}
</div>
{# Monthly summary#}
<div class="tw:grid tw:grid-cols-1 tw:xl:grid-cols-12 tw:gap-x-4 tw:gap-y-3">
<div class="tw:col-span-1 tw:xl:col-span-4 tw:order-0 tw:xl:order-2">
<div role="tablist" class="tw:tabs tw:tabs-border">
<input type="radio" name="monthly_summary_tabs" class="tw:tab" aria-label="{% trans 'Summary' %}"
role="tab"
{% if summary_tab == 'summary' or not summary_tab %}checked="checked"{% endif %}
_="on click fetch {% url 'monthly_summary_select' selected='summary' %}"
aria-controls="summary-tab-pane" />
<div class="tw:tab-content tw:bg-base-100" id="summary-tab-pane" role="tabpanel">
<div id="summary"
hx-get="{% url 'monthly_summary' month=month year=year %}"
class="show-loading"
hx-trigger="load, updated from:window, selective_update from:window, every 10m">
</div>
</div>
<input type="radio" name="monthly_summary_tabs" class="tw:tab" aria-label="{% trans 'Currencies' %}"
role="tab"
{% if summary_tab == 'currency' %}checked="checked"{% endif %}
_="on click fetch {% url 'monthly_summary_select' selected='currency' %}"
aria-controls="currency-tab-pane" />
<div class="tw:tab-content tw:bg-base-100" id="currency-tab-pane" role="tabpanel">
<div id="currency-summary"
hx-get="{% url 'monthly_currency_summary' month=month year=year %}"
class="show-loading"
hx-trigger="load, updated from:window, selective_update from:window, every 10m">
</div>
</div>
<input type="radio" name="monthly_summary_tabs" class="tw:tab" aria-label="{% trans 'Accounts' %}"
role="tab"
{% if summary_tab == 'account' %}checked="checked"{% endif %}
_="on click fetch {% url 'monthly_summary_select' selected='account' %}"
aria-controls="account-tab-pane" />
<div class="tw:tab-content tw:bg-base-100" id="account-tab-pane" role="tabpanel">
<div id="account-summary"
hx-get="{% url 'monthly_account_summary' month=month year=year %}"
class="show-loading"
hx-trigger="load, updated from:window, selective_update from:window, every 10m">
</div>
</div>
</div>
</div>
<div class="tw:col-span-1 tw:xl:col-span-8 tw:order-2 tw:xl:order-1">
<div class="my-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">
<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="tw:join tw:w-full">
<button class="tw:btn tw:btn-secondary tw:join-item tw: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' %}">
<i class="fa-solid fa-filter fa-fw"></i>
</button>
{# Search box #}
<label for="quick-search" class="tw:hidden">
</label>
<input type="search"
class="tw:input tw:input-bordered tw:join-item tw:flex-1"
placeholder="{% translate 'Search' %}"
hx-preserve
id="quick-search"
_="on input or search or htmx:afterSwap from window
if my value is empty
trigger toggle on <.transactions-divider-collapse/>
else
trigger show on <.transactions-divider-collapse/>
end
show <.transactions-divider-title/> when my value is empty
show <.transaction/> in <#transactions-list/>
when its textContent.toLowerCase() contains my value.toLowerCase()">
{# Order by icon dropdown #}
<div class="tw:dropdown tw:dropdown-end">
<button tabindex="0" class="tw:btn tw:btn-secondary tw:join-item" type="button"
title="{% translate 'Order by' %}">
<i class="fa-solid fa-sort fa-fw"></i>
</button>
<ul tabindex="0" class="tw:dropdown-content tw:menu tw:bg-base-200 tw:rounded-box tw:z-[1] tw:w-52 tw:p-2 tw:shadow-md tw:mt-1">
<li>
<button class="{% if order == 'default' %}tw:menu-active{% endif %}" type="button"
_="on click remove .tw:menu-active from <li > button/> in the closest <ul/>
then add .tw: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' %}tw:menu-active{% endif %}" type="button"
_="on click remove .tw:menu-active from <li > button/> in the closest <ul/>
then add .tw: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' %}tw:menu-active{% endif %}" type="button"
_="on click remove .tw:menu-active from <li > button/> in the closest <ul/>
then add .tw:menu-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="tw:card tw:card-body tw:bg-base-200 tw:mt-2">
<div class="tw:text-right">
<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="tw:mt-3">
{% crispy filter.form %}
</form>
<div class="tw:text-right">
<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>
</div>
</div>
{# Transactions list#}
<div id="transactions"
class="show-loading"
hx-get="{% url 'monthly_transactions_list' month=month year=year %}"
hx-trigger="load, updated from:window, every 10m" hx-include="#filter, #order">
</div>
</div>
</div>
</div>
<c-ui.transactions_fab></c-ui.transactions_fab>
{% endblock %}