Skip to content

Commit

Permalink
Changed behaviour of the Member list when emptying the search box in …
Browse files Browse the repository at this point in the history
…the admin side panel (from the list being empty to it going back to the original list).
  • Loading branch information
filiptypjeu committed Aug 18, 2023
1 parent 3cd7de8 commit eea9910
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions teknologr/members/lookups.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ class MemberLookup(LookupChannel):
model = Member

def get_query(self, q, request):
members = findMembers(q)
return members
if q == '__ALL__':
return Member.objects.order_by('-modified')[:50]
return findMembers(q)

def get_result(self, obj):
""" result is the simple text that is the completion of what the person typed """
Expand Down
2 changes: 1 addition & 1 deletion teknologr/members/static/js/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ $(document).ready(function () {
timer = setTimeout(function(){
$.ajax({
// XXX: Why ')'???
url: "/ajax_select/ajax_lookup/member)?term=" + filter,
url: `/ajax_select/ajax_lookup/member)?term=${filter || "__ALL__"}`,
method: "GET",
}).done(function(data) {
$("#side-objects").empty();
Expand Down
1 change: 1 addition & 0 deletions teknologr/members/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def set_side_context(context, category, active_obj=None):
if category == 'members':
side['sname'] = 'medlem'
side['form'] = MemberForm(initial={'given_names': '', 'surname': ''}, auto_id="mmodal_%s")
# XXX: Duplicated in MemberLookup.get_query for when the search box is emptied
side['objects'] = Member.objects.order_by('-modified')[:50]
# Add the active member to the list if it is not there already
if active_obj and active_obj not in side['objects']:
Expand Down

0 comments on commit eea9910

Please sign in to comment.