Filtres i ordres als resultats de cerca
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
{% if properties or property_results %}
|
||||
<div class="flex flex-row items-center">
|
||||
<p class="pr-2 py-2
|
||||
{% if properties %} text-beige {% else %} text-gray-400 {% endif %}
|
||||
">Filtres:</p>
|
||||
<ul class="flex flex-wrap justify-center my-1">
|
||||
{% for property in properties %}
|
||||
<li>
|
||||
{% set hx_vars = build_hx_vars({"properties": remove_property_str(property)}, order_params_dict) %}
|
||||
<button class="bg-beige rounded
|
||||
text-white
|
||||
m-1 px-2"
|
||||
hx-get="/api/content/temes"
|
||||
hx-target="#content"
|
||||
hx-include="[name=query]"
|
||||
hx-vars="{{ hx_vars }}"
|
||||
hx-swap="innerhtml"
|
||||
>
|
||||
{{ property }}
|
||||
</button>
|
||||
</li>
|
||||
{% endfor %}
|
||||
{% for property in property_results %}
|
||||
<li>
|
||||
{% set hx_vars = build_hx_vars({"properties": add_property_str(property)}, order_params_dict) %}
|
||||
<button class="border border-beige rounded
|
||||
text-white
|
||||
m-1 px-2"
|
||||
hx-get="/api/content/temes"
|
||||
hx-target="#content"
|
||||
hx-vars="{{ hx_vars }}"
|
||||
hx-swap="innerhtml"
|
||||
>
|
||||
{{ property }}
|
||||
</button>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
@@ -0,0 +1,67 @@
|
||||
<div class="flex flex-row items-center justify-center">
|
||||
{% set times_played_color = "text-gray-400" %}
|
||||
{% set times_played_caret = "off" %}
|
||||
{% set times_played_target_params = {"order_by": "'times_played'", "order": "'desc'"} %}
|
||||
|
||||
{% set last_played_color = "text-gray-400" %}
|
||||
{% set last_played_caret = "off" %}
|
||||
{% set last_played_target_params = {"order_by": "'last_played'", "order": "'desc'"} %}
|
||||
|
||||
{% if order_params is not none %}
|
||||
{% if order_params.order_by == OrderBy.TIMES_PLAYED %}
|
||||
{% set times_played_color = "text-beige" %}
|
||||
{% if order_params.order == Order.ASC %}
|
||||
{% set times_played_caret = "asc" %}
|
||||
{% set times_played_target_params = {} %}
|
||||
{% elif order_params.order == Order.DESC %}
|
||||
{% set times_played_caret = "desc" %}
|
||||
{% set times_played_target_params = {"order_by": "'times_played'", "order": "'asc'"} %}
|
||||
{% endif %}
|
||||
{% elif order_params.order_by == OrderBy.LAST_PLAYED %}
|
||||
{% set last_played_color = "text-beige" %}
|
||||
{% if order_params.order == Order.ASC %}
|
||||
{% set last_played_caret = "asc" %}
|
||||
{% set last_played_target_params = {} %}
|
||||
{% elif order_params.order == Order.DESC %}
|
||||
{% set last_played_caret = "desc" %}
|
||||
{% set last_played_target_params = {"order_by": "'last_played'", "order": "'asc'"} %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% set hx_vars = build_hx_vars({"properties": properties_str}, times_played_target_params) %}
|
||||
<button title="Ordena per cops tocat"
|
||||
class="{{ times_played_color }} mx-2 flex flex-row"
|
||||
hx-get="/api/temes/busca"
|
||||
hx-include="[name=query]"
|
||||
hx-vars="{{ hx_vars }}"
|
||||
hx-target="#search-results"
|
||||
hx-swap="outerHTML">
|
||||
<i class="mr-1 flex-none">{% include "icons/music-box.svg" %}</i>
|
||||
{% if times_played_caret == "asc" %}
|
||||
<i class="fa fa-caret-up flex-1 w-0" aria-hidden="true"></i>
|
||||
{% elif times_played_caret == "desc" %}
|
||||
<i class="fa fa-caret-down flex-1 w-0" aria-hidden="true"></i>
|
||||
{% else %}
|
||||
<div class="flex-1 w-0"></div>
|
||||
{% endif %}
|
||||
</button>
|
||||
|
||||
{% set hx_vars = build_hx_vars({"properties": properties_str}, last_played_target_params) %}
|
||||
<button title="Ordena per últim cop tocat"
|
||||
class="{{ last_played_color }} mx-2 flex flex-row"
|
||||
hx-get="/api/temes/busca"
|
||||
hx-include="[name=query]"
|
||||
hx-vars="{{ hx_vars }}"
|
||||
hx-target="#search-results"
|
||||
hx-swap="outerHTML">
|
||||
<i class="mr-1">{% include "icons/calendar.svg" %}</i>
|
||||
{% if last_played_caret == "asc" %}
|
||||
<i class="fa fa-caret-up flex-1 w-0" aria-hidden="true"></i>
|
||||
{% elif last_played_caret == "desc" %}
|
||||
<i class="fa fa-caret-down flex-1 w-0" aria-hidden="true"></i>
|
||||
{% else %}
|
||||
<div class="flex-1 w-0"></div>
|
||||
{% endif %}
|
||||
</button>
|
||||
</div>
|
||||
Reference in New Issue
Block a user