mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-07-10 14:52:42 +02:00
feat(transactions:action-bar): add more math options in a dropdown
This commit is contained in:
@@ -11,78 +11,252 @@
|
|||||||
<div class="card slide-in-left">
|
<div class="card slide-in-left">
|
||||||
<div class="card-body p-2">
|
<div class="card-body p-2">
|
||||||
{% spaceless %}
|
{% spaceless %}
|
||||||
<div class="btn-group" role="group">
|
<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"
|
<button class="btn btn-secondary btn-sm"
|
||||||
data-bs-toggle="tooltip"
|
hx-get="{% url 'transactions_bulk_delete' %}"
|
||||||
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"
|
hx-include=".transaction"
|
||||||
|
hx-trigger="confirmed"
|
||||||
data-bs-toggle="tooltip"
|
data-bs-toggle="tooltip"
|
||||||
data-bs-title="{% translate 'Mark as unpaid' %}">
|
data-bs-title="{% translate 'Delete' %}"
|
||||||
<i class="fa-regular fa-circle tw-text-red-400"></i>
|
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>
|
</button>
|
||||||
</div>
|
<div class="vr mx-3 tw-align-middle"></div>
|
||||||
<button class="btn btn-secondary btn-sm"
|
{# <span _="on selected_transactions_updated from #actions-bar#}
|
||||||
hx-get="{% url 'transactions_bulk_delete' %}"
|
{# set realTotal to 0.0#}
|
||||||
hx-include=".transaction"
|
{# set flatTotal to 0.0#}
|
||||||
hx-trigger="confirmed"
|
{# for transaction in <.transaction:has(input[name='transactions']:checked)/>#}
|
||||||
data-bs-toggle="tooltip"
|
{# set amt to first <.main-amount .amount/> in transaction#}
|
||||||
data-bs-title="{% translate 'Delete' %}"
|
{# set amountValue to parseFloat(amt.getAttribute('data-amount'))#}
|
||||||
data-bypass-on-ctrl="true"
|
{# if not isNaN(amountValue)#}
|
||||||
data-title="{% translate "Are you sure?" %}"
|
{# set flatTotal to flatTotal + (amountValue * 100)#}
|
||||||
data-text="{% translate "You won't be able to revert this!" %}"
|
{##}
|
||||||
data-confirm-text="{% translate "Yes, delete them!" %}"
|
{# if transaction match .income#}
|
||||||
_="install prompt_swal">
|
{# set realTotal to realTotal + (amountValue * 100)#}
|
||||||
<i class="fa-solid fa-trash text-danger"></i>
|
{# else#}
|
||||||
</button>
|
{# set realTotal to realTotal - (amountValue * 100)#}
|
||||||
<div class="vr mx-3 tw-align-middle"></div>
|
{# end#}
|
||||||
<span _="on selected_transactions_updated from #actions-bar
|
{# end#}
|
||||||
set realTotal to 0.0
|
{# end#}
|
||||||
set flatTotal to 0.0
|
{# set realTotal to realTotal / 100#}
|
||||||
for transaction in <.transaction:has(input[name='transactions']:checked)/>
|
{# put realTotal.toLocaleString(undefined, {minimumFractionDigits: 0, maximumFractionDigits: 40}) into me#}
|
||||||
set amt to first <.main-amount .amount/> in transaction
|
{# end#}
|
||||||
set amountValue to parseFloat(amt.getAttribute('data-amount'))
|
{# on click#}
|
||||||
if not isNaN(amountValue)
|
{# set original_value to my innerText#}
|
||||||
set flatTotal to flatTotal + (amountValue * 100)
|
{# 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 []
|
||||||
|
|
||||||
if transaction match .income
|
for transaction in transactions
|
||||||
set realTotal to realTotal + (amountValue * 100)
|
set amt to first <.main-amount .amount/> in transaction
|
||||||
else
|
set amountValue to parseFloat(amt.getAttribute('data-amount'))
|
||||||
set realTotal to realTotal - (amountValue * 100)
|
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
|
||||||
end
|
end
|
||||||
end
|
|
||||||
set realTotal to realTotal / 100
|
set realTotal to realTotal / 100
|
||||||
put realTotal.toLocaleString(undefined, {minimumFractionDigits: 0, maximumFractionDigits: 40}) into me
|
put realTotal.toLocaleString(undefined, {minimumFractionDigits: 0, maximumFractionDigits: 40}) into #real-total-front's innerText
|
||||||
end
|
put realTotal.toLocaleString(undefined, {minimumFractionDigits: 0, maximumFractionDigits: 40}) into #calc-menu-real-total's innerText
|
||||||
on click
|
set flatTotal to flatTotal / 100
|
||||||
set original_value to my innerText
|
put flatTotal.toLocaleString(undefined, {minimumFractionDigits: 0, maximumFractionDigits: 40}) into #calc-menu-flat-total's innerText
|
||||||
writeText(my innerText) on navigator.clipboard
|
log amountValues
|
||||||
put '{% translate "copied!" %}' into me
|
put Math.max.apply(Math, amountValues) into #calc-menu-max's innerText
|
||||||
wait 1s
|
put Math.min.apply(Math, amountValues) into #calc-menu-min's innerText
|
||||||
put original_value into me
|
put flatTotal / amountValues.length into #calc-menu-mean's innerText
|
||||||
end"
|
put amountValues.length into #calc-menu-count's innerText
|
||||||
class="" role="button"></span>
|
end"
|
||||||
|
>
|
||||||
|
<button class="btn btn-secondary btn-sm">
|
||||||
|
<i class="fa-solid fa-plus fa-fw me-2 text-primary"></i>
|
||||||
|
<span id="real-total-front"
|
||||||
|
_="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</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 %}
|
{% endspaceless %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user