From ce419b57e2d8b3091d9703261a106f74000a3ba9 Mon Sep 17 00:00:00 2001 From: Jason Boyer Date: Fri, 20 Apr 2018 14:49:25 -0400 Subject: [PATCH] LP14973322: Search for Users by Profile Stop treating profile like a text value, instead include users in the selected profiles and descendants. To test ------- [0] Search for users by last name (and / or first) and do not select a profile, take note of results [1] Select the top of your permission group tree (Users, likely) and search again, results should be the same. [2] Select a group further down the tree (Circulators, Administrators, Patrons, etc.) and repeat the search, there should only be results from that group and its descendants. [3] Finally, select a group with no child groups. Results will only be that specific group. Signed-off-by: Jason Boyer Signed-off-by: Terran McCanna Signed-off-by: Galen Charlton Signed-off-by: Mike Rylander --- .../perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm | 7 +++++++ Open-ILS/web/js/ui/default/staff/services/patron_search.js | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm index a1e634ddab..134821a110 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm @@ -677,6 +677,7 @@ sub patron_search { # group 2 = phone, ident # group 3 = barcode # group 4 = dob + # group 5 = profile # Treatment of name fields depends on whether the org has # diacritic_insensitivity turned on or off. @@ -718,6 +719,10 @@ sub patron_search { my $addr = join ' AND ', map { "evergreen.lowercase(CAST($_ AS text)) ~ ?" } grep { ''.$$search{$_}{group} eq '1' } keys %$search; my @addrv = map { "^" . _clean_regex_chars($$search{$_}{value}) } grep { ''.$$search{$_}{group} eq '1' } keys %$search; + # should only be 1 profile sent but this construction makes dealing with the lists simpler. + my ($prof) = map { $$search{$_}{value} } grep {''.$$search{$_}{group} eq '5' } keys %$search; + $prof = int($prof) if $prof; # int or out + my $pv = _clean_regex_chars($$search{phone}{value}); my $iv = _clean_regex_chars($$search{ident}{value}); my $nv = _clean_regex_chars($$search{name}{value}); @@ -816,6 +821,7 @@ sub patron_search { } my $descendants = "actor.org_unit_descendants($search_org)"; + my $profile = "JOIN permission.grp_descendants($prof) p ON (p.id = users.profile)" if $prof; my $opt_in_where = ''; if (lc($strict_opt_in) eq 'true') { @@ -843,6 +849,7 @@ sub patron_search { SELECT $distinct_list FROM $u_table AS users $card JOIN $descendants d ON (d.id = users.home_ou) + $profile $select $clone_select $penalty_join diff --git a/Open-ILS/web/js/ui/default/staff/services/patron_search.js b/Open-ILS/web/js/ui/default/staff/services/patron_search.js index f19678f6c2..b0f1bede16 100644 --- a/Open-ILS/web/js/ui/default/staff/services/patron_search.js +++ b/Open-ILS/web/js/ui/default/staff/services/patron_search.js @@ -775,7 +775,7 @@ function($scope, $q, $routeParams, $timeout, $window, $location, egCore, angular.forEach(args, function(val, key) { if (!val) return; if (key == 'profile' && args.profile) { - search.profile = {value : args.profile.id(), group : 0}; + search.profile = {value : args.profile.id(), group : 5}; } else if (key == 'home_ou' && args.home_ou) { search.home_ou = args.home_ou.id(); // passed separately } else if (key == 'inactive') { -- 2.11.0