mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-05-20 06:37:24 +02:00
feat: automated replacement
This commit is contained in:
@@ -1,23 +1,23 @@
|
||||
{% load currency_display %}
|
||||
{% load i18n %}
|
||||
<div class="card-body show-loading" hx-get="{% url 'exchange_rates_list_pair' %}" hx-trigger="updated from:window" hx-swap="outerHTML" hx-vals='{"page": "{{ page_obj.number }}", "from": "{{ from_currency|default_if_none:"" }}", "to": "{{ to_currency|default_if_none:"" }}"}'>
|
||||
<div class="tw:card-body show-loading" hx-get="{% url 'exchange_rates_list_pair' %}" hx-trigger="updated from:window" hx-swap="outerHTML" hx-vals='{"page": "{{ page_obj.number }}", "from": "{{ from_currency|default_if_none:"" }}", "to": "{{ to_currency|default_if_none:"" }}"}'>
|
||||
{% if page_obj %}
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover text-nowrap">
|
||||
<div class="tw:overflow-x-auto">
|
||||
<table class="tw:table tw:table-hover tw:whitespace-nowrap">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" class="col-auto"></th>
|
||||
<th scope="col" class="col">{% translate 'Date' %}</th>
|
||||
<th scope="col" class="col">{% translate 'Pairing' %}</th>
|
||||
<th scope="col" class="col">{% translate 'Rate' %}</th>
|
||||
<th scope="col" class="tw:w-auto"></th>
|
||||
<th scope="col">{% translate 'Date' %}</th>
|
||||
<th scope="col">{% translate 'Pairing' %}</th>
|
||||
<th scope="col">{% translate 'Rate' %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for exchange_rate in page_obj %}
|
||||
<tr class="exchange-rate">
|
||||
<td class="col-auto">
|
||||
<div class="btn-group" role="group" aria-label="{% translate 'Actions' %}">
|
||||
<a class="btn btn-secondary btn-sm"
|
||||
<td class="tw:w-auto">
|
||||
<div class="tw:join" role="group" aria-label="{% translate 'Actions' %}">
|
||||
<a class="tw:btn tw:btn-secondary tw:btn-sm tw:join-item"
|
||||
role="button"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-title="{% translate "Edit" %}"
|
||||
@@ -25,7 +25,7 @@
|
||||
hx-target="#generic-offcanvas"
|
||||
hx-swap="innerHTML">
|
||||
<i class="fa-solid fa-pencil fa-fw"></i></a>
|
||||
<a class="btn btn-secondary btn-sm text-danger"
|
||||
<a class="tw:btn tw:btn-secondary tw:btn-sm tw:join-item tw:text-error"
|
||||
role="button"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-title="{% translate "Delete" %}"
|
||||
@@ -39,9 +39,9 @@
|
||||
_="install prompt_swal"><i class="fa-solid fa-trash fa-fw"></i></a>
|
||||
</div>
|
||||
</td>
|
||||
<td class="col-3">{{ exchange_rate.date|date:"SHORT_DATETIME_FORMAT" }}</td>
|
||||
<td class="col-3"><span class="badge rounded-pill text-bg-secondary">{{ exchange_rate.from_currency.name }}</span> x <span class="badge rounded-pill text-bg-secondary">{{ exchange_rate.to_currency.name }}</span></td>
|
||||
<td class="col-3">1 {{ exchange_rate.from_currency.name }} ≅ {% currency_display amount=exchange_rate.rate prefix=exchange_rate.to_currency.prefix suffix=exchange_rate.to_currency.suffix decimal_places=exchange_rate.to_currency.decimal_places%}</td>
|
||||
<td class="tw:w-1/4">{{ exchange_rate.date|date:"SHORT_DATETIME_FORMAT" }}</td>
|
||||
<td class="tw:w-1/4"><span class="tw:badge tw:badge-secondary tw:rounded-full">{{ exchange_rate.from_currency.name }}</span> x <span class="tw:badge tw:badge-secondary tw:rounded-full">{{ exchange_rate.to_currency.name }}</span></td>
|
||||
<td class="tw:w-1/4">1 {{ exchange_rate.from_currency.name }} ≅ {% currency_display amount=exchange_rate.rate prefix=exchange_rate.to_currency.prefix suffix=exchange_rate.to_currency.suffix decimal_places=exchange_rate.to_currency.decimal_places%}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
@@ -52,13 +52,12 @@
|
||||
{% endif %}
|
||||
|
||||
{% 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 %}"
|
||||
<div class="tw:join tw:flex tw:justify-center tw:mt-5">
|
||||
<button class="tw:join-item tw:btn tw:btn-sm tw:cursor-pointer {% if not page_obj.has_previous %}tw:btn-disabled{% endif %}"
|
||||
hx-get="{% if page_obj.has_previous %}{% url 'exchange_rates_list_pair' %}{% endif %}"
|
||||
hx-vals='{"page": 1, "from": "{{ from_currency|default_if_none:"" }}", "to": "{{ to_currency|default_if_none:"" }}"}'
|
||||
hx-include="#filter, #order"
|
||||
@@ -66,8 +65,7 @@
|
||||
aria-label="Primeira página"
|
||||
hx-swap="show:top">
|
||||
<span aria-hidden="true">«</span>
|
||||
</a>
|
||||
</li>
|
||||
</button>
|
||||
{% for page_number in page_obj.paginator.page_range %}
|
||||
{% comment %}
|
||||
This conditional allows us to display up to 3 pages before and after the current page
|
||||
@@ -78,44 +76,35 @@
|
||||
{% 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">
|
||||
<button class="tw:join-item tw:btn tw:btn-sm tw:btn-active tw:cursor-pointer">
|
||||
{{ page_number }}
|
||||
</a>
|
||||
</li>
|
||||
</button>
|
||||
{% else %}
|
||||
<li class="page-item">
|
||||
<a class="page-link tw:cursor-pointer"
|
||||
<button class="tw:join-item tw:btn tw:btn-sm tw:cursor-pointer"
|
||||
hx-get="{% url 'exchange_rates_list_pair' %}"
|
||||
hx-vals='{"page": {{ page_number }}, "from": "{{ from_currency|default_if_none:"" }}", "to": "{{ to_currency|default_if_none:"" }}"}'
|
||||
hx-target="#exchange-rates-table"
|
||||
hx-swap="show:top">
|
||||
{{ page_number }}
|
||||
</a>
|
||||
</li>
|
||||
</button>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if page_obj.number|add:3 < page_obj.paginator.num_pages %}
|
||||
<li class="page-item">
|
||||
<a class="page-link disabled"
|
||||
<button 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"
|
||||
</button>
|
||||
<button class="tw:join-item tw:btn tw:btn-sm tw:cursor-pointer"
|
||||
hx-get="{% url 'exchange_rates_list_pair' %}" hx-target="#exchange-rates-table"
|
||||
hx-vals='{"page": {{ page_obj.paginator.num_pages }}, "from": "{{ from_currency|default_if_none:"" }}", "to": "{{ to_currency|default_if_none:"" }}"}'
|
||||
hx-include="#filter, #order"
|
||||
hx-swap="show:top"
|
||||
aria-label="Última página">
|
||||
<span aria-hidden="true">{{ page_obj.paginator.num_pages }}</span>
|
||||
</a>
|
||||
</li>
|
||||
</button>
|
||||
{% endif %}
|
||||
<li class="page-item">
|
||||
<a class="page-link {% if not page_obj.has_next %}disabled{% endif %} tw:cursor-pointer"
|
||||
<button class="tw:join-item tw:btn tw:btn-sm {% if not page_obj.has_next %}tw:btn-disabled{% endif %} tw:cursor-pointer"
|
||||
hx-get="{% if page_obj.has_next %}{% url 'exchange_rates_list_pair' %}{% endif %}"
|
||||
hx-vals='{"page": {{ page_obj.paginator.num_pages }}, "from": "{{ from_currency|default_if_none:"" }}", "to": "{{ to_currency|default_if_none:"" }}"}'
|
||||
hx-include="#filter, #order"
|
||||
@@ -123,9 +112,8 @@
|
||||
hx-target="#exchange-rates-table"
|
||||
aria-label="Next">
|
||||
<span aria-hidden="true">»</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</button>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user