Skip to content

Commit dccbc9c

Browse files
authored
Make committer select box easier to use (#66)
The select box for selecting a committer of a patch was kinda hard to use. This fixes it in two ways: 1. Sorts names by first names, instead of last names. This way the list actually looks ordered. 2. Use Selectize to make the select box searchable. To make such a change to selectize simpler in the future this starts including the selectize css/js on every page and adds a simple "enable-selectize" class that can be used to easily enable selectize on any select box.
1 parent 715eda1 commit dccbc9c

File tree

9 files changed

+27
-15
lines changed

9 files changed

+27
-15
lines changed

media/commitfest/js/commitfest.js

+22
Original file line numberDiff line numberDiff line change
@@ -379,4 +379,26 @@ $(document).ready(() => {
379379
return false;
380380
});
381381
});
382+
383+
$(".enable-selectize").selectize({
384+
plugins: ["remove_button"],
385+
valueField: "id",
386+
labelField: "value",
387+
searchField: "value",
388+
onFocus: function () {
389+
if (this.$input.is("[multiple]")) {
390+
return;
391+
}
392+
this.lastValue = this.getValue();
393+
this.clear(false);
394+
},
395+
onBlur: function () {
396+
if (this.$input.is("[multiple]")) {
397+
return;
398+
}
399+
if (this.getValue() === "") {
400+
this.setValue(this.lastValue);
401+
}
402+
},
403+
});
382404
});

pgcommitfest/commitfest/templates/base.html

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
<link rel="stylesheet" href="/media/commitfest/css/jquery-ui.css" type="text/css">
77
<link rel="stylesheet" href="/media/commitfest/css/bootstrap.css" />
88
<link rel="stylesheet" href="/media/commitfest/css/bootstrap-theme.min.css" />
9+
<link rel="stylesheet" href="/media/commitfest/css/selectize.css" />
10+
<link rel="stylesheet" href="/media/commitfest/css/selectize.default.css" />
911
<link rel="stylesheet" href="/media/commitfest/css/commitfest.css?{% static_file_param %}" />
1012
<link rel="shortcut icon" href="/media/commitfest/favicon.ico" />
1113
{%block extrahead%}{%endblock%}
@@ -49,6 +51,7 @@ <h1>{{title}}</h1>
4951
<script src="/media/commitfest/js/jquery.js"></script>
5052
<script src="/media/commitfest/js/jquery-ui.js"></script>
5153
<script src="/media/commitfest/js/bootstrap.js"></script>
54+
<script src="/media/commitfest/js/selectize.min.js"></script>
5255
<script src="/media/commitfest/js/commitfest.js?{% static_file_param %}"></script>
5356
{%block morescript%}{%endblock%}
5457
</html>

pgcommitfest/commitfest/templates/base_form.html

-3
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ <h3>Search user</h3>
7070
{%endif%}
7171
{%endblock%}
7272

73-
{%block extrahead%}
74-
{%include "selectize_css.html" %}
75-
{%endblock%}
7673
{%block morescript%}
7774

7875
{%include "selectize_js.html" %}

pgcommitfest/commitfest/templates/commitfest.html

-3
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,6 @@ <h3>{{p.is_open|yesno:"Active patches,Closed patches"}}</h3>
131131
</div>
132132
{%endblock%}
133133

134-
{%block extrahead%}
135-
{%include "selectize_css.html" %}
136-
{%endblock%}
137134
{%block morescript%}
138135
{%include "selectize_js.html" %}
139136
<script>

pgcommitfest/commitfest/templates/me.html

-3
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,6 @@ <h3>{%if user.is_authenticated%}Open patches you are subscribed to{%elif p.is_op
104104
{%endif%}
105105
{%endfor%}
106106
{%endblock%}
107-
{%block extrahead%}
108-
{%include "selectize_css.html" %}
109-
{%endblock%}
110107
{%block morescript%}
111108
{%include "selectize_js.html" %}
112109
{%endblock%}

pgcommitfest/commitfest/templates/patch.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ <h3>Flag as committed</h3>
213213
<form class="form" style="margin-bottom: 5px;">
214214
<div class="form-group">
215215
<label for="committerlist">Committer</label>
216-
<select id="committerSelect" class="form-control">
216+
<select id="committerSelect" class="enable-selectize">
217217
<option value="" style="display:none;"></option>
218218
{%for c in committers%}
219219
<option value="{{c.user.username}}">{{c.user.first_name}} {{c.user.last_name}}</option>

pgcommitfest/commitfest/templates/selectize_css.html

-3
This file was deleted.

pgcommitfest/commitfest/templates/selectize_js.html

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<script src="/media/commitfest/js/selectize.min.js"></script>
21
<script>
32
{% for f, url in form.selectize_fields.items %}
43
$('#id_{{f}}').selectize({

pgcommitfest/commitfest/views.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ def patch(request, patchid):
664664
cf = patch_commitfests[0].commitfest
665665

666666
committers = Committer.objects.filter(active=True).order_by(
667-
"user__last_name", "user__first_name"
667+
"user__first_name", "user__last_name"
668668
)
669669

670670
cfbot_branch = getattr(patch, "cfbot_branch", None)

0 commit comments

Comments
 (0)