Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Makes the special handling of user fields apply only to non-custom field ones. (#19329)

Marcello Rocha4fc44960a7c7
diff --git a/app/models/custom_actions/actions/base.rb b/app/models/custom_actions/actions/base.rb
index 4995d3c9371..c499282473d 100644
--- a/app/models/custom_actions/actions/base.rb
+++ b/app/models/custom_actions/actions/base.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
@@ -75,9 +77,7 @@ class CustomActions::Actions::Base
end
end
- def key
- self.class.key
- end
+ delegate :key, to: :class
def required?
false
@@ -98,6 +98,10 @@ class CustomActions::Actions::Base
private
+ def deconstruct_keys(*)
+ { type:, custom_field_based: respond_to?(:custom_field) }
+ end
+
def validate_value_required(errors)
if required? && values.empty?
errors.add :actions,
diff --git a/app/views/custom_actions/_form.html.erb b/app/views/custom_actions/_form.html.erb
index d467f6392db..1d17b959e13 100644
--- a/app/views/custom_actions/_form.html.erb
+++ b/app/views/custom_actions/_form.html.erb
@@ -69,8 +69,8 @@
<% if %i(associated_property boolean user project).include?(action.type) %>
<div class="form--field-container">
<div class="form--select-container -middle">
- <% case action.type %>
- <% when :project %>
+ <% case action %>
+ <% in { type: :project } %>
<%= angular_component_tag "opce-project-autocompleter",
inputs: {
multiple: false,
@@ -81,7 +81,7 @@
labelForId: "custom_action_actions_#{action.key}",
inputValue: action.values.first
} %>
- <% when :user %>
+ <% in { type: :user, custom_field_based: false } %>
<% selected = action.value_objects.map { |v| { id: v[:value], name: v[:label] } } %>
<%= angular_component_tag "opce-user-autocompleter",
inputs: {
@@ -94,7 +94,7 @@
model: action.multi_value? ? selected : selected.first,
inputName: input_name,
filters: [
- { name: "status", operator: "!", values: [Principal.statuses["locked"].to_s] },
+ { name: "status", operator: "!", values: [Principal.statuses["locked"].to_s] }
],
appendTo: "body",
additionalOptions: [
@@ -110,6 +110,7 @@
<%= angular_component_tag "opce-autocompleter",
inputs: {
multiple: action.multi_value?,
+ hideSelected: true,
defaultData: false,
items: action.allowed_values.map { |v| { id: v[:value], name: v[:label] } },
model: action.multi_value? ? selected : selected.first,