From 8bab29678a854ec3a6e52d49609613f1c443b7c5 Mon Sep 17 00:00:00 2001 From: Alexander Meindl Date: Sat, 21 Mar 2020 10:48:46 +0100 Subject: [PATCH] visible support for additionals_select2_search_users --- app/helpers/additionals_queries_helper.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/helpers/additionals_queries_helper.rb b/app/helpers/additionals_queries_helper.rb index cd11aa2f..8ed96553 100644 --- a/app/helpers/additionals_queries_helper.rb +++ b/app/helpers/additionals_queries_helper.rb @@ -76,12 +76,13 @@ module AdditionalsQueriesHelper "#{object_type}_query_data_#{session[:session_id]}_#{project_id}" end - def additionals_select2_search_users(where_filter = '', where_params = {}) + def additionals_select2_search_users(options = {}) q = params[:q].to_s.strip exclude_id = params[:user_id].to_i scope = User.active.where(type: 'User') + scope = scope.visible unless options[:all_visible] scope = scope.where.not(id: exclude_id) if exclude_id.positive? - scope = scope.where(where_filter, where_params) if where_filter.present? + scope = scope.where(options[:where_filter], options[:where_params]) if options[:where_filter] scope = scope.like(q) if q.present? scope = scope.order(last_login_on: :desc) .limit(params[:limit] || Additionals::SELECT2_INIT_ENTRIES)