mirror of
https://github.com/ae-utbm/sith.git
synced 2026-02-09 00:51:29 +00:00
Introduce htmx in sith files
* Convert FileModerationView into ListView and add pagination with htmx * Don't allow sas moderation in file moderation view * Split up base.jinja and introduce base_fragment.jinja * Improve FileModerationView performances and make it root only * Add permissions tests for file modération
This commit is contained in:
@@ -166,9 +166,37 @@
|
||||
current_page (django.core.paginator.Page): the current page object
|
||||
paginator (django.core.paginator.Paginator): the paginator object
|
||||
#}
|
||||
{{ paginate_server_side(current_page, paginator, False) }}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro paginate_htmx(current_page, paginator) %}
|
||||
{# Add pagination buttons for pages without Alpine but supporting framgents.
|
||||
|
||||
This must be coupled with a view that handles pagination
|
||||
with the Django Paginator object and supports framgents.
|
||||
|
||||
The relpaced fragment will be #content so make sure you are calling this macro inside your content block.
|
||||
|
||||
Parameters:
|
||||
current_page (django.core.paginator.Page): the current page object
|
||||
paginator (django.core.paginator.Paginator): the paginator object
|
||||
#}
|
||||
{{ paginate_server_side(current_page, paginator, True) }}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro paginate_server_side(current_page, paginator, use_htmx) %}
|
||||
<nav class="pagination">
|
||||
{% if current_page.has_previous() %}
|
||||
<a href="?page={{ current_page.previous_page_number() }}">
|
||||
<a
|
||||
{% if use_htmx -%}
|
||||
hx-get="?page={{ current_page.previous_page_number() }}"
|
||||
hx-swap="innerHTML"
|
||||
hx-target="#content"
|
||||
hx-push-url="true"
|
||||
{%- else -%}
|
||||
href="?page={{ current_page.previous_page_number() }}"
|
||||
{%- endif -%}
|
||||
>
|
||||
<button>
|
||||
<i class="fa fa-caret-left"></i>
|
||||
</button>
|
||||
@@ -182,16 +210,33 @@
|
||||
{% elif i == paginator.ELLIPSIS %}
|
||||
<strong>{{ paginator.ELLIPSIS }}</strong>
|
||||
{% else %}
|
||||
<a href="?page={{ i }}">
|
||||
<a
|
||||
{% if use_htmx -%}
|
||||
hx-get="?page={{ i }}"
|
||||
hx-swap="innerHTML"
|
||||
hx-target="#content"
|
||||
hx-push-url="true"
|
||||
{%- else -%}
|
||||
href="?page={{ i }}"
|
||||
{%- endif -%}
|
||||
>
|
||||
<button>{{ i }}</button>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if current_page.has_next() %}
|
||||
<a href="?page={{ current_page.next_page_number() }}">
|
||||
<button>
|
||||
<i class="fa fa-caret-right"></i>
|
||||
</button>
|
||||
<a
|
||||
{% if use_htmx -%}
|
||||
hx-get="?page={{ current_page.next_page_number() }}"
|
||||
hx-swap="innerHTML"
|
||||
hx-target="#content"
|
||||
hx-push-url="true"
|
||||
{%- else -%}
|
||||
href="?page={{ current_page.next_page_number() }}"
|
||||
{%- endif -%}
|
||||
><button>
|
||||
<i class="fa fa-caret-right"></i>
|
||||
</button>
|
||||
</a>
|
||||
{% else %}
|
||||
<button disabled="disabled"><i class="fa fa-caret-right"></i></button>
|
||||
|
||||
Reference in New Issue
Block a user