From 726c7ea401a2789a546ab9b0271abc2d9ca06a8f Mon Sep 17 00:00:00 2001 From: Ross Date: Thu, 13 Nov 2025 21:32:28 +0000 Subject: [PATCH] Enhance user search functionality with advanced search tips and help panel --- generic/forms.py | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/generic/forms.py b/generic/forms.py index 91a3aaab..5230ce39 100755 --- a/generic/forms.py +++ b/generic/forms.py @@ -622,13 +622,39 @@ class UserUserGroupForm(ModelForm):
-
+
+ +
+
+ + +
+ Advanced search tips +
    +
  • Basic: type any part of a user's first name, last name, username or email (case-insensitive substring match). Example: smith or joe@example.com.
  • +
  • Wildcards: use * or % as the query to return many users (use carefully). Wildcard queries return up to 50 results; normal queries return up to 10.
  • +
  • Field-specific searches: prefix with field:term to restrict the search. Supported fields: +
      +
    • name: or full_name: — matches first OR last name (e.g. name:smith).
    • +
    • first: or first_name: — matches first name.
    • +
    • last: or last_name: — matches last name.
    • +
    • email: — matches email address.
    • +
    • username: — matches username.
    • +
    • id: or pk: — match by numeric user id (e.g. id:123).
    • +
    • grade: — match by grade name or grade id (e.g. grade:ST3 or grade:2).
    • +
    +
  • +
  • Grade filter: use the grade dropdown next to the search box to narrow results by trainee grade in addition to your query.
  • +
  • To add users, click the Add button beside a result. If an Add all results button appears, it will add all currently visible results.
  • +
  • If you expect many matches, narrow your query or use a field-specific search to improve relevance and performance.
  • +
+
@@ -645,6 +671,8 @@ class UserUserGroupForm(ModelForm): const select = document.getElementById('{field_id}'); const selectedList = document.getElementById('{selected_list_id}'); const gradeSelect = document.getElementById('grade_filter_{self.name}'); + const helpBtn = document.getElementById('user_search_help_btn_{self.name}'); + const helpPanel = document.getElementById('user_search_help_panel_{self.name}'); let timeout = null; function fetchResults(q) {{ @@ -670,6 +698,16 @@ class UserUserGroupForm(ModelForm): timeout = setTimeout(() => fetchResults(search.value), 50); }}); + // Toggle help panel visibility + if (helpBtn && helpPanel) {{ + helpBtn.addEventListener('click', function(e) {{ + e.preventDefault(); + helpPanel.classList.toggle('d-none'); + const expanded = !helpPanel.classList.contains('d-none'); + helpBtn.setAttribute('aria-expanded', expanded ? 'true' : 'false'); + }}); + }} + // fieldName for this widget instance const widgetFieldName = '{self.name}';