add SORTS_COMMENTS
This commit is contained in:
parent
95d68d013d
commit
c5cea4f8fa
5 changed files with 8 additions and 6 deletions
|
@ -47,6 +47,7 @@ SORTS_POSTS = {
|
|||
"bump": "fa-arrow-up"
|
||||
}
|
||||
SORTS_POSTS.update(SORTS_COMMON)
|
||||
SORTS_COMMENTS = SORTS_COMMON
|
||||
|
||||
IMGUR_KEY = environ.get("IMGUR_KEY").strip()
|
||||
PUSHER_ID = environ.get("PUSHER_ID", "").strip()
|
||||
|
|
|
@ -86,7 +86,7 @@ def inject_constants():
|
|||
"PERMS":PERMS,
|
||||
"FEATURES":FEATURES,
|
||||
"RENDER_DEPTH_LIMIT":RENDER_DEPTH_LIMIT,
|
||||
"SORTS_COMMON":SORTS_COMMON,
|
||||
"SORTS_COMMENTS":SORTS_COMMENTS,
|
||||
"SORTS_POSTS":SORTS_POSTS,
|
||||
}
|
||||
|
||||
|
|
|
@ -215,7 +215,7 @@ def settings_profile_post(v):
|
|||
|
||||
defaultsortingcomments = request.values.get("defaultsortingcomments")
|
||||
if defaultsortingcomments:
|
||||
if defaultsortingcomments in SORTS_COMMON:
|
||||
if defaultsortingcomments in SORTS_COMMENTS:
|
||||
v.defaultsortingcomments = defaultsortingcomments
|
||||
updated = True
|
||||
else: abort(400)
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
{%- macro sort_dropdown(is_comment, extra_query) -%}
|
||||
{% set all_sorts = SORTS_COMMENTS if is_comment else SORTS_POSTS %}
|
||||
<div class="dropdown dropdown-actions">
|
||||
<button class="btn btn-secondary dropdown-toggle" role="button" id="dropdownMenuButton2" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="fas {{SORTS_POSTS[sort]}} mr-1"></i> {{sort|capitalize}}
|
||||
<i class="fas {{all_sorts[sort]}} mr-1"></i> {{sort|capitalize}}
|
||||
</button>
|
||||
<div class="dropdown-menu smol-fp" x-placement="bottom-start" style="position: absolute; will-change: transform; top: 0px; left: 0px;">
|
||||
{% for possible_sort in (SORTS_COMMON if is_comment else SORTS_POSTS) %}
|
||||
{% for possible_sort in all_sorts %}
|
||||
{%- if sort != possible_sort -%}
|
||||
<a class="dropdown-item" href="?{{extra_query ~ '&' if extra_query else ''}}sort={{possible_sort}}&t={{t}}"><i class="fas {{SORTS_POSTS[possible_sort]}} mr-1"></i> {{possible_sort | capitalize}}</a>
|
||||
<a class="dropdown-item" href="?{{extra_query ~ '&' if extra_query else ''}}sort={{possible_sort}}&t={{t}}"><i class="fas {{all_sorts[possible_sort]}} mr-1"></i> {{possible_sort | capitalize}}</a>
|
||||
{%- endif -%}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
<p>Change the default sorting for comments.</p>
|
||||
<div class="input-group mb2">
|
||||
<select autocomplete="off" id='defaultsortingcomments' class="form-control" form="profile-settings" name="defaultsortingcomments" onchange="post_toast(this,'/settings/profile?defaultsortingcomments='+document.getElementById('defaultsortingcomments').value)">
|
||||
{% for entry in SORTS_COMMON %}
|
||||
{% for entry in SORTS_COMMENTS %}
|
||||
<option value="{{entry}}"{{' selected' if v.defaultsortingcomments==entry}}>{{entry}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue