mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-04-25 10:08:36 +02:00
262 lines
12 KiB
HTML
262 lines
12 KiB
HTML
{% load i18n %}
|
|
<div class="tw-sticky tw-bottom-4 tw-left-0 tw-right-0 tw-z-50 tw-hidden mx-auto tw-w-fit" id="actions-bar"
|
|
_="on change from #transactions-list or htmx:afterSettle from window
|
|
if no <input[type='checkbox']:checked/> in #transactions-list
|
|
add .tw-hidden to #actions-bar
|
|
else
|
|
remove .tw-hidden from #actions-bar
|
|
then trigger selected_transactions_updated
|
|
end
|
|
end">
|
|
<div class="card slide-in-left">
|
|
<div class="card-body p-2">
|
|
{% spaceless %}
|
|
<div class="btn-group" role="group">
|
|
<button class="btn btn-secondary btn-sm"
|
|
data-bs-toggle="tooltip"
|
|
data-bs-title="{% translate 'Select All' %}"
|
|
_="on click set <#transactions-list input[type='checkbox']/>'s checked to true then call me.blur() then trigger change">
|
|
<i class="fa-regular fa-square-check tw-text-green-400"></i>
|
|
</button>
|
|
<button class="btn btn-secondary btn-sm"
|
|
data-bs-toggle="tooltip"
|
|
data-bs-title="{% translate 'Unselect All' %}"
|
|
_="on click set <#transactions-list input[type='checkbox']/>'s checked to false then call me.blur() then trigger change">
|
|
<i class="fa-regular fa-square tw-text-red-400"></i>
|
|
</button>
|
|
</div>
|
|
<div class="vr mx-3 tw-align-middle"></div>
|
|
<div class="btn-group me-3" role="group">
|
|
<button class="btn btn-secondary btn-sm"
|
|
hx-get="{% url 'transactions_bulk_pay' %}"
|
|
hx-include=".transaction"
|
|
data-bs-toggle="tooltip"
|
|
data-bs-title="{% translate 'Mark as paid' %}">
|
|
<i class="fa-regular fa-circle-check tw-text-green-400"></i>
|
|
</button>
|
|
<button class="btn btn-secondary btn-sm"
|
|
hx-get="{% url 'transactions_bulk_unpay' %}"
|
|
hx-include=".transaction"
|
|
data-bs-toggle="tooltip"
|
|
data-bs-title="{% translate 'Mark as unpaid' %}">
|
|
<i class="fa-regular fa-circle tw-text-red-400"></i>
|
|
</button>
|
|
</div>
|
|
<button class="btn btn-secondary btn-sm"
|
|
hx-get="{% url 'transactions_bulk_delete' %}"
|
|
hx-include=".transaction"
|
|
hx-trigger="confirmed"
|
|
data-bs-toggle="tooltip"
|
|
data-bs-title="{% translate 'Delete' %}"
|
|
data-bypass-on-ctrl="true"
|
|
data-title="{% translate "Are you sure?" %}"
|
|
data-text="{% translate "You won't be able to revert this!" %}"
|
|
data-confirm-text="{% translate "Yes, delete them!" %}"
|
|
_="install prompt_swal">
|
|
<i class="fa-solid fa-trash text-danger"></i>
|
|
</button>
|
|
<div class="vr mx-3 tw-align-middle"></div>
|
|
{# <span _="on selected_transactions_updated from #actions-bar#}
|
|
{# set realTotal to 0.0#}
|
|
{# set flatTotal to 0.0#}
|
|
{# for transaction in <.transaction:has(input[name='transactions']:checked)/>#}
|
|
{# set amt to first <.main-amount .amount/> in transaction#}
|
|
{# set amountValue to parseFloat(amt.getAttribute('data-amount'))#}
|
|
{# if not isNaN(amountValue)#}
|
|
{# set flatTotal to flatTotal + (amountValue * 100)#}
|
|
{##}
|
|
{# if transaction match .income#}
|
|
{# set realTotal to realTotal + (amountValue * 100)#}
|
|
{# else#}
|
|
{# set realTotal to realTotal - (amountValue * 100)#}
|
|
{# end#}
|
|
{# end#}
|
|
{# end#}
|
|
{# set realTotal to realTotal / 100#}
|
|
{# put realTotal.toLocaleString(undefined, {minimumFractionDigits: 0, maximumFractionDigits: 40}) into me#}
|
|
{# end#}
|
|
{# on click#}
|
|
{# set original_value to my innerText#}
|
|
{# writeText(my innerText) on navigator.clipboard#}
|
|
{# put '{% translate "copied!" %}' into me#}
|
|
{# wait 1s#}
|
|
{# put original_value into me#}
|
|
{# end"#}
|
|
{# class="" role="button"></span>#}
|
|
<div class="btn-group"
|
|
_="on selected_transactions_updated from #actions-bar
|
|
set realTotal to 0.0
|
|
set flatTotal to 0.0
|
|
set transactions to <.transaction:has(input[name='transactions']:checked)/>
|
|
set amountValues to []
|
|
|
|
for transaction in transactions
|
|
set amt to first <.main-amount .amount/> in transaction
|
|
set amountValue to parseFloat(amt.getAttribute('data-amount'))
|
|
append amountValue to amountValues
|
|
|
|
if not isNaN(amountValue)
|
|
set flatTotal to flatTotal + (amountValue * 100)
|
|
|
|
if transaction match .income
|
|
set realTotal to realTotal + (amountValue * 100)
|
|
else
|
|
set realTotal to realTotal - (amountValue * 100)
|
|
end
|
|
end
|
|
end
|
|
|
|
set realTotal to realTotal / 100
|
|
put realTotal.toLocaleString(undefined, {minimumFractionDigits: 0, maximumFractionDigits: 40}) into #real-total-front's innerText
|
|
put realTotal.toLocaleString(undefined, {minimumFractionDigits: 0, maximumFractionDigits: 40}) into #calc-menu-real-total's innerText
|
|
set flatTotal to flatTotal / 100
|
|
put flatTotal.toLocaleString(undefined, {minimumFractionDigits: 0, maximumFractionDigits: 40}) into #calc-menu-flat-total's innerText
|
|
put Math.max.apply(Math, amountValues) into #calc-menu-max's innerText
|
|
put Math.min.apply(Math, amountValues) into #calc-menu-min's innerText
|
|
put flatTotal / amountValues.length into #calc-menu-mean's innerText
|
|
put amountValues.length into #calc-menu-count's innerText
|
|
end"
|
|
>
|
|
<button class="btn btn-secondary btn-sm" _="on click
|
|
set original_value to #real-total-front's innerText
|
|
writeText(original_value) on navigator.clipboard
|
|
put '{% translate "copied!" %}' into #real-total-front's innerText
|
|
wait 1s
|
|
put original_value into #real-total-front's innerText
|
|
end">
|
|
<i class="fa-solid fa-plus fa-fw me-2 text-primary"></i>
|
|
<span id="real-total-front">0</span>
|
|
</button>
|
|
<button type="button" class="btn btn-sm btn-secondary dropdown-toggle dropdown-toggle-split"
|
|
data-bs-toggle="dropdown" aria-expanded="false" data-bs-auto-close="outside">
|
|
<span class="visually-hidden">{% trans "Toggle Dropdown" %}</span>
|
|
</button>
|
|
|
|
<ul class="dropdown-menu">
|
|
<li>
|
|
<div class="dropdown-item-text p-0">
|
|
<div>
|
|
<div class="text-body-secondary tw-text-xs tw-font-medium px-3">
|
|
{% trans "Flat Total" %}
|
|
</div>
|
|
<div class="dropdown-item px-3 tw-cursor-pointer"
|
|
id="calc-menu-flat-total"
|
|
_="on click
|
|
set original_value to my innerText
|
|
writeText(my innerText) on navigator.clipboard
|
|
put '{% translate "copied!" %}' into me
|
|
wait 1s
|
|
put original_value into me
|
|
end">
|
|
0
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</li>
|
|
<li>
|
|
<div class="dropdown-item-text p-0">
|
|
<div>
|
|
<div class="text-body-secondary tw-text-xs tw-font-medium px-3">
|
|
{% trans "Real Total" %}
|
|
</div>
|
|
<div class="dropdown-item px-3 tw-cursor-pointer"
|
|
id="calc-menu-real-total"
|
|
_="on click
|
|
set original_value to my innerText
|
|
writeText(my innerText) on navigator.clipboard
|
|
put '{% translate "copied!" %}' into me
|
|
wait 1s
|
|
put original_value into me
|
|
end">
|
|
0
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</li>
|
|
<li>
|
|
<div class="dropdown-item-text p-0">
|
|
<div>
|
|
<div class="text-body-secondary tw-text-xs tw-font-medium px-3">
|
|
{% trans "Mean" %}
|
|
</div>
|
|
<div class="dropdown-item px-3 tw-cursor-pointer"
|
|
id="calc-menu-mean"
|
|
_="on click
|
|
set original_value to my innerText
|
|
writeText(my innerText) on navigator.clipboard
|
|
put '{% translate "copied!" %}' into me
|
|
wait 1s
|
|
put original_value into me
|
|
end">
|
|
0
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</li>
|
|
<li>
|
|
<div class="dropdown-item-text p-0">
|
|
<div>
|
|
<div class="text-body-secondary tw-text-xs tw-font-medium px-3">
|
|
{% trans "Max" %}
|
|
</div>
|
|
<div class="dropdown-item px-3 tw-cursor-pointer"
|
|
id="calc-menu-max"
|
|
_="on click
|
|
set original_value to my innerText
|
|
writeText(my innerText) on navigator.clipboard
|
|
put '{% translate "copied!" %}' into me
|
|
wait 1s
|
|
put original_value into me
|
|
end">
|
|
0
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</li>
|
|
<li>
|
|
<div class="dropdown-item-text p-0">
|
|
<div>
|
|
<div class="text-body-secondary tw-text-xs tw-font-medium px-3">
|
|
{% trans "Min" %}
|
|
</div>
|
|
<div class="dropdown-item px-3 tw-cursor-pointer"
|
|
id="calc-menu-min"
|
|
_="on click
|
|
set original_value to my innerText
|
|
writeText(my innerText) on navigator.clipboard
|
|
put '{% translate "copied!" %}' into me
|
|
wait 1s
|
|
put original_value into me
|
|
end">
|
|
0
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</li>
|
|
<li>
|
|
<div class="dropdown-item-text p-0">
|
|
<div>
|
|
<div class="text-body-secondary tw-text-xs tw-font-medium px-3">
|
|
{% trans "Count" %}
|
|
</div>
|
|
<div class="dropdown-item px-3 tw-cursor-pointer"
|
|
id="calc-menu-count"
|
|
_="on click
|
|
set original_value to my innerText
|
|
writeText(my innerText) on navigator.clipboard
|
|
put '{% translate "copied!" %}' into me
|
|
wait 1s
|
|
put original_value into me
|
|
end">
|
|
0
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
{% endspaceless %}
|
|
</div>
|
|
</div>
|
|
</div>
|