Skip to content

Commit

Permalink
Use bootstrap button group for sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
SaptakS committed May 1, 2020
1 parent fb36696 commit 6d6ead7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
1 change: 0 additions & 1 deletion weblate/static/loader-bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -1561,7 +1561,6 @@ $(function () {
}
});
$('#id_q').on('keydown', function (event) {
console.log("hello")
if (event.key === "Enter") {
$(this).closest('form').submit();
}
Expand Down
8 changes: 2 additions & 6 deletions weblate/static/style-bootstrap.css
Original file line number Diff line number Diff line change
Expand Up @@ -475,19 +475,15 @@ legend {
}
}
#query-sort-toggle {
width: 35px;
width: 40px;
padding-left: 0;
padding-right: 0;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
#query-sort-toggle span:not(.active) {
display: none;
}
#query-sort-dropdown {
width: 160px;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
width: 200px;
}
#is-exact span {
margin: 4px 4px 0 4px;
Expand Down
6 changes: 4 additions & 2 deletions weblate/templates/snippets/query-field.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,21 @@
<input type="hidden" id="id_sort_by" name="sort_by" value="{{ sort_query|default:'position,-priority' }}" aria-label="{% trans "Sort By" %}" />
<input type="hidden" id="id_sort_direction" name="sort_by_direction" value="{{ sort_direction|default:'' }}" aria-label="{% trans "Sort By" %}" />
<ul class="dropdown-menu">
<li><a data-sort="position,-priority">{% trans "Position & Priority" %}</a></li>
<li><a data-sort="position,-priority">{% trans "Position and Priority" %}</a></li>
<li><a data-sort="position">{% trans "Position" %}</a></li>
<li><a data-sort="priority">{% trans "Priority" %}</a></li>
<li><a data-sort="num_words">{% trans "Word count" %}</a></li>
<li><a data-sort="context">{% trans "Context" %}</a></li>
</ul>
</div>
<span class="input-group-btn">
<button type="button" id="query-sort-toggle" class="btn btn-default search-field">
<span class="search-label asc {% if not sort_direction %}active{% endif %}">
{% icon "sort-ascending.svg" %}
</span>
<span class="search-label desc {% if sort_direction %}active{% endif %}">{% icon "sort-descending.svg" %}</span>
</button>
</div>
</span>
</div><!-- /input-group -->
</div>
</div>
Expand Down
14 changes: 8 additions & 6 deletions weblate/utils/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,17 @@ def dispatch(self, request, *args, **kwargs):
def get_sort_name(request):
"""Gets sort name."""
sort_dict = {
"position": "Position",
"priority": "Priority",
"num_words": "Word count",
"context": "Context",
"position,-priority": "Position & Priority",
"position": _("Position"),
"priority": _("Priority"),
"num_words": _("Word count"),
"context": _("Context"),
"position,-priority": _("Position and Priority"),
}
result = {
"query": request.GET.get("sort_by", "position,-priority"),
"name": sort_dict.get(request.GET.get("sort_by", ""), "Position & Priority"),
"name": sort_dict.get(
request.GET.get("sort_by", ""), _("Position and Priority")
),
"direction": request.GET.get("sort_by_direction", ""),
}
return result
Expand Down

0 comments on commit 6d6ead7

Please sign in to comment.