always use select2 with initialize_methods

This commit is contained in:
Alexander Meindl 2022-02-26 17:39:59 +01:00
parent aef702f57d
commit 9d628dc357
2 changed files with 6 additions and 45 deletions

View File

@ -139,47 +139,20 @@ module AdditionalsQuery
end
def initialize_author_filter(position: nil)
if Additionals.user_with_select2?
add_available_filter 'author_id', order: position,
type: :author
else
add_available_filter 'author_id', order: position,
type: :list_optional,
values: -> { author_values }
end
end
def initialize_assignee_filter(position: nil)
if Additionals.user_with_select2?
add_available_filter 'assigned_to_id', order: position,
type: :assignee
else
add_available_filter 'assigned_to_id', order: position,
type: :list_optional,
values: -> { assigned_to_all_values }
end
end
def initialize_watcher_filter(position: nil)
return unless User.current.logged?
if Additionals.user_with_select2?
add_available_filter 'watcher_id', order: position,
type: :user_with_me
else
add_available_filter 'watcher_id', order: position,
type: :list,
values: -> { watcher_values_for_manage_public_queries }
end
end
# issue independend values. Use assigned_to_values from Redmine, if you want it only for issues
def assigned_to_all_values
assigned_to_values = []
assigned_to_values << label_me_value if User.current.logged?
assigned_to_values += principals.sort_by(&:status).collect { |s| [s.name, s.id.to_s, l("status_#{User::LABEL_BY_STATUS[s.status]}")] }
assigned_to_values
end
# not required for: assigned_to_id author_id user_id watcher_id updated_by last_updated_by
@ -196,14 +169,6 @@ module AdditionalsQuery
values
end
# watcher_values of query checks view_issue_watchers, this checks manage_public_queries permission
# and with users (not groups)
def watcher_values_for_manage_public_queries
watcher_values = [label_me_value]
watcher_values += users.collect { |s| [s.name, s.id.to_s] } if User.current.allowed_to? :manage_public_queries, project, global: true
watcher_values
end
def sql_for_watcher_id_field(field, operator, value)
watchable_type = queried_class == User ? 'Principal' : queried_class.to_s

View File

@ -77,10 +77,6 @@ module Additionals
ids.take limit
end
def user_with_select2?
AdditionalsPlugin.active_hrm?
end
def debug(message = 'running', console: false)
if console
RedminePluginKit::Debug.msg message