mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 14:13:21 +00:00
forum: use pure jinja for search bar
This commit is contained in:
parent
6891174935
commit
fc7e45190d
@ -22,7 +22,7 @@
|
||||
{% if not forum.is_category %}
|
||||
<a class="ib button" href="{{ url('forum:new_topic', forum_id=forum.id) }}">{% trans %}New topic{% endtrans %}</a>
|
||||
{% endif %}
|
||||
{{ display_search_bar() }}
|
||||
{{ display_search_bar(request) }}
|
||||
</p>
|
||||
{% if forum.children.exists() %}
|
||||
<div>
|
||||
|
@ -155,33 +155,12 @@
|
||||
{{ m.mark_as_read(user) or "" }}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro display_search_bar() %}
|
||||
{% macro display_search_bar(request) %}
|
||||
<form class="search_bar" action="{{ url('forum:search') }}" method="GET">
|
||||
<input type="text" id="forum_search_input" placeholder="{% trans %}Search{% endtrans %}" name="query"/>
|
||||
<input type="checkbox" id="forum_search_order_date" class="sreach_check" name="order" value="date" checked> {% trans %}Order by date{% endtrans %}<br>
|
||||
<input type="text" placeholder="{% trans %}Search{% endtrans %}" name="query" value="{{ request.GET.query|default('') }}"/>
|
||||
<input type="checkbox" class="sreach_check" name="order" value="date" {% if request.GET.order|default("") == "date" or (request.GET.order|default("") == "" and request.GET.query|default("") == "") -%}
|
||||
checked
|
||||
{%- endif -%}> {% trans %}Order by date{% endtrans %}<br>
|
||||
<input type="submit" class="search_bouton" value="{% trans %}Search{% endtrans %}"/>
|
||||
<script type="text/javascript">
|
||||
// Uncheck the order by date checkbox if previously unchecked
|
||||
const searchParams = new URLSearchParams(window.location.search);
|
||||
var waitForJQuery = setInterval(function () {
|
||||
if (typeof $ != 'undefined'){
|
||||
fillSearchBar();
|
||||
clearInterval(waitForJQuery);
|
||||
}
|
||||
}, 10);
|
||||
function fillSearchBar() {
|
||||
if (searchParams.has('query')){
|
||||
$('#forum_search_input').val(searchParams.get('query'));
|
||||
}
|
||||
if (
|
||||
(!searchParams.has('order') && searchParams.has('query') )||
|
||||
(searchParams.has('order') && searchParams.get('order') != 'date')
|
||||
) {
|
||||
$('#forum_search_order_date').removeAttr('checked');
|
||||
clearInterval(waitForJQuery);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
</form>
|
||||
{% endmacro %}
|
||||
|
@ -15,7 +15,7 @@
|
||||
<p>
|
||||
<a class="ib button" href="{{ url('forum:last_unread') }}">{% trans %}View last unread messages{% endtrans %}</a>
|
||||
<a class="ib button" href="{{ url('forum:favorite_topics') }}">{% trans %}Favorite topics{% endtrans %}</a>
|
||||
{{ display_search_bar() }}
|
||||
{{ display_search_bar(request) }}
|
||||
</p>
|
||||
{% if user.is_in_group(settings.SITH_GROUP_FORUM_ADMIN_ID) or user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID) %}
|
||||
<p>
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
{% block content %}
|
||||
{% if topic %}
|
||||
{{ display_search_bar() }}
|
||||
{{ display_search_bar(request) }}
|
||||
<p>
|
||||
<a href="{{ url('forum:main') }}">{% trans %}Forum{% endtrans %}</a>
|
||||
{% for f in topic.forum.get_parent_list() %}
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
{% block content %}
|
||||
<div id="forum">
|
||||
{{ display_search_bar() }}
|
||||
{{ display_search_bar(request) }}
|
||||
{% if object_list|length != 0 %}
|
||||
<br>
|
||||
<div class="search-results">
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
{% block content %}
|
||||
<p>
|
||||
{{ display_search_bar() }}
|
||||
{{ display_search_bar(request) }}
|
||||
<a href="{{ url('forum:main') }}">{% trans %}Forum{% endtrans %}</a>
|
||||
{% for f in topic.forum.get_parent_list()|reverse %}
|
||||
> <a href="{{ f.get_absolute_url() }}">{{ f }}</a>
|
||||
|
Loading…
Reference in New Issue
Block a user