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

Fix selection of custom value

Oliver Güntherf7ca11dc38ef
diff --git a/app/views/custom_actions/_form.html.erb b/app/views/custom_actions/_form.html.erb
index 70feac1c831..672ae2651c8 100644
--- a/app/views/custom_actions/_form.html.erb
+++ b/app/views/custom_actions/_form.html.erb
@@ -42,7 +42,6 @@
model: condition.value_objects.map { |v| { id: v[:value], name: v[:label] } },
inputName: input_name,
bindLabel: "name",
- bindValue: "id",
labelForId: "custom_action_conditions_#{condition.key}",
appendTo: "body"
} %>
@@ -81,15 +80,15 @@
inputValue: action.values.first
} %>
<% else %>
+ <% selected = action.value_objects.map { |v| { id: v[:value], name: v[:label] } } %>
<%= angular_component_tag "opce-autocompleter",
inputs: {
multiple: action.multi_value?,
defaultData: false,
items: action.allowed_values.map { |v| { id: v[:value], name: v[:label] } },
- model: action.value_objects.map { |v| { id: v[:value], name: v[:label] } },
+ model: action.multi_value? ? selected : selected.first,
inputName: input_name,
bindLabel: "name",
- bindValue: "id",
labelForId: "custom_action_actions_#{action.key}",
appendTo: "body"
} %>
diff --git a/spec/features/work_packages/custom_actions/custom_actions_spec.rb b/spec/features/work_packages/custom_actions/custom_actions_spec.rb
index dfaa6a1d65e..88e100809b3 100644
--- a/spec/features/work_packages/custom_actions/custom_actions_spec.rb
+++ b/spec/features/work_packages/custom_actions/custom_actions_spec.rb
@@ -458,6 +458,31 @@ RSpec.describe "Custom actions", :js, with_ee: %i[custom_actions] do
expect(page).to have_select("custom_action_actions_date", selected: "Current date")
end
+ it "editing a status custom action (Regression #61888)" do
+ # create custom action 'Unassign'
+ index_ca_page.visit!
+
+ new_ca_page = index_ca_page.new
+
+ new_ca_page.set_name("Status")
+ new_ca_page.set_description("Sets some status")
+ new_ca_page.add_action("Status", "Close")
+
+ new_ca_page.create
+
+ index_ca_page.expect_current_path
+ index_ca_page.expect_listed("Status")
+
+ date_action = CustomAction.last
+ expect(date_action.actions.length).to eq(1)
+ expect(date_action.actions.first.value_objects).to contain_exactly(label: "Closed", value: closed_status.id)
+
+ edit_page = index_ca_page.edit("Status")
+ page.within "#custom-actions-form--actions" do
+ edit_page.expect_selected_option "Close"
+ end
+ end
+
it "disables the custom action button and editing other fields when submiting the custom action" do
# create custom action 'Unassign'
index_ca_page.visit!