Skip to content
Snippets Groups Projects
Commit 2f97a9ab authored by Roang's avatar Roang
Browse files

Extract filter macro to tagbox component

parent 7c113499
Branches
Tags release/forms/4.3.9
No related merge requests found
...@@ -2,15 +2,7 @@ ...@@ -2,15 +2,7 @@
{% import "plainui/components/nav.html" as navMacro with context %} {% import "plainui/components/nav.html" as navMacro with context %}
{% import "plainui/components/badge_elements.html.j2" as badgeMacro with context %} {% import "plainui/components/badge_elements.html.j2" as badgeMacro with context %}
{% import "plainui/components/wiki.html" as wikiMacro with context %} {% import "plainui/components/wiki.html" as wikiMacro with context %}
{% import "plainui/components/tagbox.html" as tagbox with context %}
{% macro filter(label, param_name, param_value) -%}
<a
href="{{ update_parameters(params, param_name, '' if param_value == params.get(param_name) else param_value, ['page']) }}"
class="hub-tag {% if params.get(param_name) == param_value %}hub-tag--secondary{% else %}hub-tag--secondary-outline{% endif %}"
>
{{ label }}
</a>
{%- endmacro %}
{% block title %} {% block title %}
{{ conf.name }} - Badges {{ conf.name }} - Badges
...@@ -40,13 +32,13 @@ ...@@ -40,13 +32,13 @@
<div class="hub-tag-divider"></div> <div class="hub-tag-divider"></div>
{% for category in categories %} {% for category in categories %}
{{ filter(category.name, 'category', category.slug) }} {{ tagbox.filter(category.name, 'category', category.slug) }}
{% endfor %} {% endfor %}
<div class="hub-tag-divider"></div> <div class="hub-tag-divider"></div>
{{ filter(_("yours"), 'owned', 'true') }} {{ tagbox.filter(_("yours"), 'owned', 'true') }}
{{ filter(_("missing"), 'owned', 'false') }} {{ tagbox.filter(_("missing"), 'owned', 'false') }}
</div> </div>
<div class="hub-card"> <div class="hub-card">
......
...@@ -10,9 +10,12 @@ ...@@ -10,9 +10,12 @@
{% import "plainui/components/tagbox.html" as tagsMacro with context %} {% import "plainui/components/tagbox.html" as tagsMacro with context %}
{% macro list(assemblies, my_favorite_assemblies, pagination=false, view_name='', metadata=false) -%} {% macro list(assemblies, my_favorite_assemblies, pagination=false, view_name='', metadata=false) -%}
{% if pagination %} <div class="hub-card hub-tags">
{{ paginator_alphabetical.pagination(view_name, paginator, page_obj) }} <a class="hub-tag
{% endif %} {% if view_all %}text-bg-warning{% endif %}"
href="{{ url(view_name) }}">ALL</a>
{% if pagination %}{{ paginator_alphabetical.pagination(view_name, paginator, page_obj) }}{% endif %}
</div>
{% if assemblies %} {% if assemblies %}
<ul class="hub-list"> <ul class="hub-list">
{% for assembly in assemblies %} {% for assembly in assemblies %}
......
...@@ -7,7 +7,12 @@ ...@@ -7,7 +7,12 @@
{% import "plainui/components/function_btns.html" as fbtns with context %} {% import "plainui/components/function_btns.html" as fbtns with context %}
{% import "plainui/components/paginator_alphabetical.html.j2" as paginator_alphabetical with context %} {% import "plainui/components/paginator_alphabetical.html.j2" as paginator_alphabetical with context %}
{% macro list(rooms, pagination=false, view_name='', metadata=false) -%} {% macro list(rooms, pagination=false, view_name='', metadata=false) -%}
<div class="hub-card hub-tags">
<a class="hub-tag
{% if view_all %}text-bg-warning{% endif %}"
href="{{ url(view_name) }}">ALL</a>
{% if pagination %}{{ paginator_alphabetical.pagination(view_name, paginator, page_obj) }}{% endif %} {% if pagination %}{{ paginator_alphabetical.pagination(view_name, paginator, page_obj) }}{% endif %}
</div>
<ul class="hub-list"> <ul class="hub-list">
{% for room in rooms %}{{ list_el(room) }}{% endfor %} {% for room in rooms %}{{ list_el(room) }}{% endfor %}
</ul> </ul>
......
...@@ -3,13 +3,8 @@ ...@@ -3,13 +3,8 @@
params: the current request parameters params: the current request parameters
#} #}
{% macro pagination(view_name, paginator, current_page) -%} {% macro pagination(view_name, paginator, current_page) -%}
<div class="hub-card hub-tags">
<a class="hub-tag
{% if view_all %}text-bg-warning{% endif %}"
href="{{ url(view_name) }}">ALL</a>
{% for paginator_page in paginator %} {% for paginator_page in paginator %}
<a class="hub-tag {% if current_page.index == paginator_page.index and not view_all %}text-bg-warning{% elif paginator_page|length == 0 %}text-bg-light{% endif %}" <a class="hub-tag {% if current_page.index == paginator_page.index and not view_all %}text-bg-warning{% elif paginator_page|length == 0 %}text-bg-light{% endif %}"
href="{{ url(view_name + '_paginated', page=paginator_page.index) }}">{{ paginator_page.index }}</a> href="{{ url(view_name + '_paginated', page=paginator_page.index) }}{{update_parameters(params, '', '')}}">{{ paginator_page.index }}</a>
{% endfor %} {% endfor %}
</div>
{%- endmacro %} {%- endmacro %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment