From 39eee13e882f6368f815286cad4afdb620141265 Mon Sep 17 00:00:00 2001 From: Klaus Zanders Date: Fri, 29 Nov 2024 15:30:10 +0100 Subject: [PATCH] correct filter search depending on object and add wrapper for dialog --- .../inputs/base/autocomplete/user_query_utils.rb | 11 +++++++++-- .../app/components/time_entries/time_entry_form.rb | 4 ++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/forms/custom_fields/inputs/base/autocomplete/user_query_utils.rb b/app/forms/custom_fields/inputs/base/autocomplete/user_query_utils.rb index e2d17241aed6..72f91a4d873a 100644 --- a/app/forms/custom_fields/inputs/base/autocomplete/user_query_utils.rb +++ b/app/forms/custom_fields/inputs/base/autocomplete/user_query_utils.rb @@ -51,10 +51,17 @@ def search_key end def filters - [ + filters = [ { name: "type", operator: "=", values: ["User", "Group", "PlaceholderUser"] }, - { name: "member", operator: "=", values: [@object.id.to_s] }, { name: "status", operator: "!", values: [Principal.statuses["locked"].to_s] } ] + + if @object.is_a?(Project) + filters << { name: "member", operator: "=", values: [@object.id.to_s] } + elsif @object.respond_to?(:project_id) + filters << { name: "member", operator: "=", values: [@object.project_id.to_s] } + end + + filters end end diff --git a/modules/costs/app/components/time_entries/time_entry_form.rb b/modules/costs/app/components/time_entries/time_entry_form.rb index f7291a1e3de8..b1915ef3f94f 100644 --- a/modules/costs/app/components/time_entries/time_entry_form.rb +++ b/modules/costs/app/components/time_entries/time_entry_form.rb @@ -23,6 +23,10 @@ class TimeEntryForm < ApplicationForm render_custom_fields(form: f) end + def additional_custom_field_input_arguments + { wrapper_id: "time-entry-dialog" } + end + private delegate :project, :work_package, to: :model