From 1466ea8c001a8679e2bfd2816f835c764088fdc8 Mon Sep 17 00:00:00 2001 From: Jelte Fennema-Nio Date: Fri, 18 Apr 2025 12:23:10 +0200 Subject: [PATCH] Make committer select box easier to use 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. --- media/commitfest/js/commitfest.js | 22 +++++++++++++++++++ pgcommitfest/commitfest/templates/base.html | 3 +++ .../commitfest/templates/base_form.html | 3 --- .../commitfest/templates/commitfest.html | 3 --- pgcommitfest/commitfest/templates/me.html | 3 --- pgcommitfest/commitfest/templates/patch.html | 2 +- .../commitfest/templates/selectize_css.html | 3 --- .../commitfest/templates/selectize_js.html | 1 - pgcommitfest/commitfest/views.py | 2 +- 9 files changed, 27 insertions(+), 15 deletions(-) delete mode 100644 pgcommitfest/commitfest/templates/selectize_css.html diff --git a/media/commitfest/js/commitfest.js b/media/commitfest/js/commitfest.js index 77d49fc2..158e572c 100644 --- a/media/commitfest/js/commitfest.js +++ b/media/commitfest/js/commitfest.js @@ -379,4 +379,26 @@ $(document).ready(() => { return false; }); }); + + $(".enable-selectize").selectize({ + plugins: ["remove_button"], + valueField: "id", + labelField: "value", + searchField: "value", + onFocus: function () { + if (this.$input.is("[multiple]")) { + return; + } + this.lastValue = this.getValue(); + this.clear(false); + }, + onBlur: function () { + if (this.$input.is("[multiple]")) { + return; + } + if (this.getValue() === "") { + this.setValue(this.lastValue); + } + }, + }); }); diff --git a/pgcommitfest/commitfest/templates/base.html b/pgcommitfest/commitfest/templates/base.html index c70a7f77..9af10521 100644 --- a/pgcommitfest/commitfest/templates/base.html +++ b/pgcommitfest/commitfest/templates/base.html @@ -6,6 +6,8 @@ + + {%block extrahead%}{%endblock%} @@ -49,6 +51,7 @@

{{title}}

+ {%block morescript%}{%endblock%} diff --git a/pgcommitfest/commitfest/templates/base_form.html b/pgcommitfest/commitfest/templates/base_form.html index 82e827d8..40518ca9 100644 --- a/pgcommitfest/commitfest/templates/base_form.html +++ b/pgcommitfest/commitfest/templates/base_form.html @@ -70,9 +70,6 @@

Search user

{%endif%} {%endblock%} -{%block extrahead%} - {%include "selectize_css.html" %} -{%endblock%} {%block morescript%} {%include "selectize_js.html" %} diff --git a/pgcommitfest/commitfest/templates/commitfest.html b/pgcommitfest/commitfest/templates/commitfest.html index 1a864981..972e0bf8 100644 --- a/pgcommitfest/commitfest/templates/commitfest.html +++ b/pgcommitfest/commitfest/templates/commitfest.html @@ -131,9 +131,6 @@

{{p.is_open|yesno:"Active patches,Closed patches"}}

{%endblock%} -{%block extrahead%} - {%include "selectize_css.html" %} -{%endblock%} {%block morescript%} {%include "selectize_js.html" %}